Compare commits

...

247 Commits

Author SHA1 Message Date
Jim Meyering
c58f8e0f80 *** empty log message *** 2000-10-28 13:50:23 +00:00
Jim Meyering
328bfd1fb7 Disable this test by default; it's expensive.
Mark this as an expensive test.
2000-10-28 13:50:14 +00:00
Jim Meyering
a3f0f65334 *this* is not an expensive test 2000-10-28 13:49:43 +00:00
Jim Meyering
0a2ef3619c *** empty log message *** 2000-10-28 13:39:20 +00:00
Jim Meyering
5854bc4e0c *** empty log message *** 2000-10-28 13:38:52 +00:00
Jim Meyering
429ea1bad3 *** empty log message *** 2000-10-28 13:12:02 +00:00
Jim Meyering
efde89cc27 *** empty log message *** 2000-10-28 13:11:43 +00:00
Jim Meyering
d4d8f86b15 *** empty log message *** 2000-10-28 12:53:50 +00:00
Jim Meyering
69254ed7d2 Factor out the expensive-test-checking code, ... 2000-10-28 12:53:27 +00:00
Jim Meyering
7b86692737 Mark this as an expensive test. 2000-10-28 12:51:40 +00:00
Jim Meyering
c82dbabbea *** empty log message *** 2000-10-28 12:50:13 +00:00
Jim Meyering
3bd2a88618 source lang-default before the first `cd' 2000-10-28 12:46:59 +00:00
Jim Meyering
4c5cf8b144 source lang-default before the first `cd' 2000-10-28 12:36:37 +00:00
Jim Meyering
d1033dc2b9 source lang-default before the first `cd' 2000-10-28 12:36:17 +00:00
Jim Meyering
a36e91c826 source lang-default before changing directory 2000-10-28 12:33:26 +00:00
Jim Meyering
e9bcabbf05 *** empty log message *** 2000-10-28 12:29:54 +00:00
Jim Meyering
20d893e3e2 (jm_PREREQ): Add jm_PREREQ_MEMCHR.
(jm_PREREQ_MEMCHR): New function.
2000-10-28 12:29:45 +00:00
Jim Meyering
3610481c97 *** empty log message *** 2000-10-28 12:19:05 +00:00
Jim Meyering
b4c60a84e1 *** empty log message *** 2000-10-28 12:18:31 +00:00
Jim Meyering
a67cbceb5a Make `ls' a lot more efficient on systems (e.g., linux-2.4.*)
that save file type information in directory entries.

[enum filetype] (unknown):
Add members (as yet unused):
(HAVE_STRUCT_DIRENT_D_TYPE): Define.
(format_needs_type): New global.
(main): Set it.
(print_dir): Set `type' from directory entry, if possible.
(gobble_file): Add a parameter, TYPE.
Stat the file only if its type is unknown and we need the type.
Patch from Ulrich Drepper.
2000-10-28 12:18:21 +00:00
Jim Meyering
71a47cd7bb *** empty log message *** 2000-10-28 12:00:14 +00:00
Jim Meyering
8f945ecf3a *** empty log message *** 2000-10-28 11:59:34 +00:00
Jim Meyering
d7bb6bd985 *** empty log message *** 2000-10-28 11:50:00 +00:00
Jim Meyering
37c05b6267 Include assert.h.
(fillrand): Add a parameter, size_max.
Add an assertion.
Adjust caller.
(dopass): Break out of the `for (;;)' loop if size < offset.
That can happen now that dopass is called with SIZE == -1.
(do_wipefd): Accept a length of zero only for a regular file.
If lseek fails or returns 0 for a non-regular file, let dopass
determine the length.
Inspired by a patch from Alan Iwi.
2000-10-28 11:49:52 +00:00
Jim Meyering
37bcdce62a . 2000-10-28 08:25:21 +00:00
Jim Meyering
52a97ad805 Update from libc. 2000-10-28 08:24:44 +00:00
Jim Meyering
cc785dc620 *** empty log message *** 2000-10-28 08:22:17 +00:00
Jim Meyering
0f44320b83 Update from libc.
Adjust for portability:
[HAVE_STDLIB_H]: Include stdlib.h.
[HAVE_BP_SYM_H || _LIBC]: Guard inclusion of bp-sym.h.
Undef __memchr, too.
[!weak_alias]: Define __memchr to memchr.
2000-10-28 08:22:11 +00:00
Jim Meyering
3032dfa4ef *** empty log message *** 2000-10-28 07:56:40 +00:00
Jim Meyering
f199ae5181 Update from libc. 2000-10-28 07:56:12 +00:00
Jim Meyering
c2c9db2056 *** empty log message *** 2000-10-28 07:47:07 +00:00
Jim Meyering
13a9a251d8 (setusershell) [HAVE_FSEEKO]: Use fseek0.
Patch by Ulrich Drepper.
2000-10-28 07:47:04 +00:00
Jim Meyering
f0da6c980d Update from libc. 2000-10-28 07:15:32 +00:00
Jim Meyering
6673e992d4 *** empty log message *** 2000-10-26 22:36:58 +00:00
Jim Meyering
141a1086a2 (usage): Mention the time zone, UTC, and write the date
in ISO format in the description of %s.  Suggestion from Karl Berry.
2000-10-26 22:36:39 +00:00
Jim Meyering
f74e9bb483 (Authors of getdate): Add Paul Eggert. 2000-10-26 14:18:24 +00:00
Jim Meyering
a2bbbeb38f *** empty log message *** 2000-10-26 14:18:06 +00:00
Jim Meyering
f3e058b838 typo 2000-10-26 14:16:24 +00:00
Jim Meyering
9ed4fe029a . 2000-10-26 09:39:08 +00:00
Jim Meyering
49ac3c60d0 Update from libc. 2000-10-26 08:08:06 +00:00
Jim Meyering
d9ef180ae5 *** empty log message *** 2000-10-25 08:39:48 +00:00
Jim Meyering
9d29159931 Include dirname.h.
(main): Use dir_name_r rather than open-coding it.
2000-10-25 08:39:29 +00:00
Jim Meyering
342d5997cc *** empty log message *** 2000-10-25 08:36:13 +00:00
Jim Meyering
e63e45a195 (dir_name_r): Declare it. 2000-10-25 08:36:08 +00:00
Jim Meyering
6b4ccb9ba3 *** empty log message *** 2000-10-25 08:34:36 +00:00
Jim Meyering
22e86fcb3c *** empty log message *** 2000-10-25 06:01:31 +00:00
Jim Meyering
faf5915f7d cppi, on one line 2000-10-25 06:01:24 +00:00
Jim Meyering
d538aba94d Update from libc. 2000-10-25 06:00:26 +00:00
Jim Meyering
26f187aa36 *** empty log message *** 2000-10-24 08:20:17 +00:00
Jim Meyering
7e87cd0d6e (hard_locale): Revert last change -- it was simply
wrong.  That set_locale call must not have any side effects.
From Paul Eggert.
2000-10-24 08:20:13 +00:00
Jim Meyering
a20eb902b8 *** empty log message *** 2000-10-23 06:38:10 +00:00
Jim Meyering
da66e2e769 *** empty log message *** 2000-10-23 06:31:28 +00:00
Jim Meyering
963388111d *** empty log message *** 2000-10-23 06:29:30 +00:00
Jim Meyering
7499ea8154 *** empty log message *** 2000-10-23 06:28:01 +00:00
Jim Meyering
79f359ff8a Clean up version-related variables. 2000-10-23 06:27:50 +00:00
Jim Meyering
6a19cbc61b *** empty log message *** 2000-10-22 22:40:13 +00:00
Jim Meyering
9e546891f1 remove remnants of lang-default change 2000-10-22 21:24:40 +00:00
Jim Meyering
171aba014f source lang-default *before* the `cd' 2000-10-22 21:23:18 +00:00
Jim Meyering
ed3d57b572 *** empty log message *** 2000-10-22 21:13:53 +00:00
Jim Meyering
81e231a46d . 2000-10-22 21:12:59 +00:00
Jim Meyering
0622127ac6 include stdio.h 2000-10-22 21:11:53 +00:00
Jim Meyering
a76f632427 *** empty log message *** 2000-10-22 21:09:53 +00:00
Jim Meyering
bf660d1331 (md5_process_block) [OP]: Use `rol', not CYCLIC.
[CYCLIC]: Remove now-unused definition.
2000-10-22 21:09:43 +00:00
Jim Meyering
7bb9c7382f s/shasum/sha1sum/ 2000-10-22 14:40:44 +00:00
Jim Meyering
6e955cb84a *** empty log message *** 2000-10-22 14:25:12 +00:00
Jim Meyering
f08ced6c34 *** empty log message *** 2000-10-22 14:21:47 +00:00
Jim Meyering
c66278dffc renamed from shasum.c 2000-10-22 14:19:52 +00:00
Jim Meyering
ed2d4df754 renamed from shasum.x 2000-10-22 14:18:02 +00:00
Jim Meyering
1bc1a37f86 fix typo 2000-10-22 14:03:33 +00:00
Jim Meyering
674233fb72 *** empty log message *** 2000-10-22 13:17:10 +00:00
Jim Meyering
1f2219cabf (print_long_format): Wrap date format strings in _(...)
so they may be internationalized.  Suggestion from Christian Rose.
2000-10-22 13:15:22 +00:00
Jim Meyering
f0d9306c78 (make_path_private): Add a FIXME comment. 2000-10-22 13:10:20 +00:00
Jim Meyering
28c6609c86 Source lang-default rather than open-coding
the setting/exporting of LANG, LC_ALL, and LANGUAGE.
2000-10-22 13:09:28 +00:00
Jim Meyering
43c38af6a1 *** empty log message *** 2000-10-22 13:08:50 +00:00
Jim Meyering
7cbb85937a Source lang-default rather than open-coding
the setting/exporting of LANG, LC_ALL, and LANGUAGE.
2000-10-22 13:08:43 +00:00
Jim Meyering
8c61ed9ff1 . 2000-10-22 13:03:06 +00:00
Jim Meyering
6ba06cf611 *** empty log message *** 2000-10-22 13:02:40 +00:00
Jim Meyering
957f363d1d *** empty log message *** 2000-10-22 13:02:00 +00:00
Jim Meyering
38856139ea *** empty log message *** 2000-10-22 12:57:48 +00:00
Jim Meyering
206ffe5898 *** empty log message *** 2000-10-22 12:51:38 +00:00
Jim Meyering
34b462a936 . 2000-10-22 12:00:22 +00:00
Jim Meyering
82495b5d26 . 2000-10-22 11:56:18 +00:00
Jim Meyering
cf806f5d2d . 2000-10-22 11:51:50 +00:00
Jim Meyering
148e5d1b4d Factor out the differences between MD5 and SHA1,
and parameterize so this code may be used by both md5sum and the new
program, shasum.  Loosely based on a patch from Scott Miller.
2000-10-22 11:50:16 +00:00
Jim Meyering
8a149d2242 Support 8-byte integers, assuming they're printable with e.g., %lld.
Add support for printing data as unsigned
long long integers.
2000-10-22 07:33:21 +00:00
Jim Meyering
b84871a279 add missing backslash 2000-10-22 07:20:24 +00:00
Jim Meyering
807e464dec *** empty log message *** 2000-10-22 06:57:54 +00:00
Jim Meyering
1f3a6e1eb8 (O_DIRECTORY): Define, if needed.
(save_cwd) [HAVE_FCHDIR]: Use O_DIRECTORY when opening ".".
Suggestion from Ulrich Drepper.
2000-10-22 06:57:42 +00:00
Jim Meyering
a48426382d *** empty log message *** 2000-10-22 06:50:02 +00:00
Jim Meyering
77ad7205cb *** empty log message *** 2000-10-22 06:43:52 +00:00
Jim Meyering
c599760ff1 2000-10-21 20:07:49 +00:00
Jim Meyering
e563a1a5b5 . 2000-10-21 20:07:03 +00:00
Jim Meyering
4e329a1473 *** empty log message *** 2000-10-21 20:01:28 +00:00
Jim Meyering
fd717e8d45 *** empty log message *** 2000-10-21 20:00:37 +00:00
Jim Meyering
13e80acf07 The command, `yes ''|./cat -n' would stop printing after INT_MAX lines.
(cat): Never let `newlines' exceed 3.
2000-10-21 19:57:41 +00:00
Jim Meyering
51e2ffc524 Prevent a counter buffer overrun when numbering lines and when
processing 100 billion lines (or more) of input.

(LINE_COUNTER_BUF_LEN): Define to allow numbering as
many as 10^18 - 1 lines (the old limit was 10^11 - 1, and could
be exceeded without too much trouble).	Use this symbol rather
than hard-coding the constant everywhere.  Rather than overruning
for input with more lines, mark the line number by putting a
`>' in the leftmost slot.
(next_line_num): Fixed (now academic) possible line buffer overrun.
Patch by Jan Nieuwenhuizen.
2000-10-21 19:16:37 +00:00
Jim Meyering
379688e35d *** empty log message *** 2000-10-21 13:22:39 +00:00
Jim Meyering
4d2231d02c *** empty log message *** 2000-10-21 13:09:31 +00:00
Jim Meyering
c344de8d9b *** empty log message *** 2000-10-21 13:05:55 +00:00
Jim Meyering
fb5e934c73 (SORT_OUT_OF_ORDER): Define.
(main): Use it instead of hard-coding the `1'.
2000-10-21 13:05:40 +00:00
Jim Meyering
09ad98374b (main): Use EXIT_SUCCESS rather than 0.
Fail when checking (-c) with more than one file argument,
rather than simply ignoring the extra arguments.
2000-10-21 13:03:40 +00:00
Jim Meyering
6864ceca11 tweak comment 2000-10-21 12:46:58 +00:00
Jim Meyering
ef43db1c4b (dir_name_r): New function, factored out of dir_name.
(dir_name): Use dir_name_r.
2000-10-21 11:44:43 +00:00
Jim Meyering
b9dbd94712 *** empty log message *** 2000-10-21 11:29:01 +00:00
Jim Meyering
9ff69c8035 (memrchr): Declare if necessary.
(dir_name): Remove the restriction that there be no
trailing slashes.  Now, this code skips past them, effectively
ignoring them.
[TEST_DIRNAME] (main): New unit tests.
2000-10-21 11:28:42 +00:00
Jim Meyering
c03498f2e7 *** empty log message *** 2000-10-21 10:37:14 +00:00
Jim Meyering
e45c3dba07 (jm_PREREQ_DIRNAME): New macro. 2000-10-21 10:37:10 +00:00
Jim Meyering
bc6477ff72 (AC_REPLACE_FUNCS): Add memrchr. 2000-10-21 10:36:49 +00:00
Jim Meyering
e46f105350 (jm_CHECK_DECLS): Also check for memrchr. 2000-10-21 10:36:32 +00:00
Jim Meyering
6ab7032952 *** empty log message *** 2000-10-21 10:33:25 +00:00
Jim Meyering
a5301cb3e2 New file, derived from the one in GNU libc. 2000-10-21 10:27:59 +00:00
Jim Meyering
9bab244d20 . 2000-10-19 11:43:34 +00:00
Jim Meyering
3b5b337246 Update from master repository. 2000-10-19 11:43:28 +00:00
Jim Meyering
3b60294bd9 *** empty log message *** 2000-10-18 20:48:04 +00:00
Jim Meyering
7243403b27 (universal_time): Remove; it's just a temptation to do the wrong thing.
(main): The -u option now just sets TZ; it doesn't do anything else.
(show_date): Do not do anything special if -u is set.
This affects the behavior of the -I and -R options.
2000-10-18 20:47:25 +00:00
Jim Meyering
d478d6efec * src/date.c (universal_time): Remove; it's just a temptation to
do the wrong thing.
(main): The -u option now just sets TZ; it doesn't do anything else.
(show_date): Do not do anything special if -u is set.
This affects the behavior of the -I and -R options.

* doc/sh-utils.texi: Document the above.
2000-10-18 20:45:20 +00:00
Jim Meyering
dbfbb93424 Undo the effect of the 1997-07-12 change to date.c; it
broke "date -u MMDDhhmm" and it wasn't documented.
This reverts to the behavior of the 1996-01-03 patch.

(utc-0, utc-1, relative-2): Adjust to above change.
2000-10-18 19:03:30 +00:00
Jim Meyering
29a4bf90d3 Undo the effect of the 1997-07-12 change to date.c; it
broke "date -u MMDDhhmm" and it wasn't documented.
This reverts to the behavior of the 1996-01-03 patch.

(TZ_UTC0, MAYBE_SET_TZ_UTC0, set_tz): Remove.
(batch_convert): Don't futz with TZ.
(main): -u now parses all dates as UTC, not just some.
2000-10-18 19:02:56 +00:00
Jim Meyering
fe5cad6b29 space to tab 2000-10-18 19:02:34 +00:00
Jim Meyering
39520407ef *** empty log message *** 2000-10-18 09:51:00 +00:00
Jim Meyering
2e4b629e21 (Examples of date): Fix a typo. 2000-10-18 09:50:56 +00:00
Jim Meyering
eaca68c289 *** empty log message *** 2000-10-18 07:42:08 +00:00
Jim Meyering
7e02b6c989 Make sure the programs use C-locale formats
and translations.  Bruno Haible reported that this test would fail
when using other locales, because ls printed a translation of `total'.
2000-10-18 07:41:59 +00:00
Jim Meyering
32dfed954f *** empty log message *** 2000-10-17 08:45:42 +00:00
Jim Meyering
55f43f7915 *** empty log message *** 2000-10-17 08:45:32 +00:00
Jim Meyering
6cca23cec4 *** empty log message *** 2000-10-17 08:45:11 +00:00
Jim Meyering
0be2660d96 [PARAMS]: Define and use. 2000-10-17 08:45:07 +00:00
Jim Meyering
a8bf544803 *** empty log message *** 2000-10-17 06:45:57 +00:00
Jim Meyering
c841079462 Update from libc. 2000-10-17 06:45:49 +00:00
Jim Meyering
ad06715030 *** empty log message *** 2000-10-16 22:05:20 +00:00
Jim Meyering
66a4baa8a6 *** empty log message *** 2000-10-16 22:01:11 +00:00
Jim Meyering
ae2b7961cf *** empty log message *** 2000-10-16 14:31:38 +00:00
Jim Meyering
6f84766d19 *** empty log message *** 2000-10-16 14:30:39 +00:00
Jim Meyering
fd00df9c4d fix spell-o in comment 2000-10-16 08:10:58 +00:00
Jim Meyering
d15557db96 (rm_option_init): Remove FIXME-maybe comment. 2000-10-16 08:09:57 +00:00
Jim Meyering
b31c11e46b . 2000-10-16 08:09:42 +00:00
Jim Meyering
bdb5516fdd *** empty log message *** 2000-10-16 06:25:55 +00:00
Jim Meyering
c8c93cfefa *** empty log message *** 2000-10-16 06:25:29 +00:00
Jim Meyering
640221896f (hard_locale): Use "", not 0 as 2nd arg to setlocale.
From Jan Fedak.
2000-10-16 06:24:33 +00:00
Jim Meyering
d73ea5f65a . 2000-10-15 11:53:35 +00:00
Jim Meyering
d72623052b . 2000-10-12 02:36:18 +00:00
Jim Meyering
a5b38192d0 (Time directives) [%S]: Range is 0..60, not 0..61. 2000-10-12 02:28:27 +00:00
Jim Meyering
5681a0705f *** empty log message *** 2000-09-30 11:58:17 +00:00
Jim Meyering
04f6bb2648 *** empty log message *** 2000-09-30 09:50:23 +00:00
Jim Meyering
ad09410b04 (main): Rename local symbolic_mode' to specified_mode'. 2000-09-30 09:40:56 +00:00
Jim Meyering
cc4722e802 *** empty log message *** 2000-09-30 09:39:52 +00:00
Jim Meyering
f8e66794d9 (change_file_mode): Perform the chmod even if the
file mode permission bits are the same as those that should be set.
Omitting the chmod call would be alright with minimal 1003.1e DS17
ACLs, but eventually there will be other permissions in addition to
rwx.  E.g., add and delete for directories, and something analogous
to NT's take ownership permission.
2000-09-30 09:39:41 +00:00
Jim Meyering
e2b45cb9fe (main): Don't set the umask to 0 and hand-apply
the previously-set umask unconditionally.  Do that only when a
MODE has been specified.  Otherwise, call mkfifo with the full
creation mask (0777 or 0666) and let the kernel apply the umask.
The difference shows up only on file systems with ACL support
when the containing directory has a default ACL.
Patch by Andreas Gruenbacher.
(main): Rename local `symbolic_mode' to `specified_mode'.
Also, when MODE is specified, call chmod to ensure that the
permission bits are set as specified even when the containing
directory has a default ACL.
2000-09-30 08:56:06 +00:00
Jim Meyering
2170a48956 (main): Rename local symbolic_mode' to specified_mode'. 2000-09-30 08:53:27 +00:00
Jim Meyering
beebc69168 (main): Don't set the umask to 0 and hand-apply
the previously-set umask unconditionally.  Do that only when a
MODE has been specified.  Otherwise, call mknod with the full
creation mask (0777 or 0666) and let the kernel apply the umask.
The difference shows up only on file systems with ACL support
when the containing directory has a default ACL.
Patch by Andreas Gruenbacher.
(main): Rename local `symbolic_mode' to `specified_mode'.
Also, when MODE is specified, call chmod to ensure that the
permission bits are set as specified even when the containing
directory has a default ACL.
2000-09-30 08:53:10 +00:00
Jim Meyering
daf9d41918 (main): Rename local symbolic_mode' to specified_mode'. 2000-09-30 08:49:51 +00:00
Jim Meyering
105cbe3ea3 (main): Don't set the umask to 0 and hand-apply
the previously-set umask unconditionally.  Do that only when a
MODE has been specified.  Otherwise, call mkdir with the full
creation mask (0777 or 0666) and let the kernel apply the umask.
The difference shows up only on file systems with ACL support
when the containing directory has a default ACL.
Patch by Andreas Gruenbacher.
2000-09-30 08:49:17 +00:00
Jim Meyering
f14dbb1710 *** empty log message *** 2000-09-30 08:42:11 +00:00
Jim Meyering
ec8df1d330 *** empty log message *** 2000-09-30 08:35:05 +00:00
Jim Meyering
d7232f8ca7 Update to use newer template. 2000-09-30 08:32:55 +00:00
Jim Meyering
c217428f39 (main): Rename local symbolic_mode' to specified_mode'. 2000-09-30 08:20:23 +00:00
Jim Meyering
41939d7bfe Remove option-describing comment block. 2000-09-30 08:19:34 +00:00
Jim Meyering
e7f9f83fa1 *** empty log message *** 2000-09-30 08:10:36 +00:00
Jim Meyering
77eb8604f1 (TESTS): Add perm. 2000-09-30 08:10:31 +00:00
Jim Meyering
f8d8ad4e94 *** empty log message *** 2000-09-30 08:09:14 +00:00
Jim Meyering
52e7fcc46c *** empty log message *** 2000-09-30 08:08:21 +00:00
Jim Meyering
96cde75480 *** empty log message *** 2000-09-30 08:05:32 +00:00
Jim Meyering
55b181511c (usage): Add a separate usage line, just for `OPTION'. 2000-09-29 21:40:38 +00:00
Jim Meyering
6ce74d5d36 *** empty log message *** 2000-09-29 21:40:33 +00:00
Jim Meyering
588d70c624 *** empty log message *** 2000-09-29 21:39:51 +00:00
Jim Meyering
6a8e993550 Run `diff -c' only if cmp finds a difference.
Clean up.
2000-09-29 10:17:51 +00:00
Jim Meyering
087520e781 . 2000-09-25 22:38:16 +00:00
Jim Meyering
8879e63dee (long_opts): --exact doesn't take an argument. 2000-09-25 22:37:54 +00:00
Jim Meyering
1a37445686 *** empty log message *** 2000-09-25 22:37:17 +00:00
Jim Meyering
d6ce71fb68 *** empty log message *** 2000-09-25 22:36:45 +00:00
Jim Meyering
65e65dbf30 *** empty log message *** 2000-09-25 20:25:04 +00:00
Jim Meyering
ec00767a8e Don't use `diff -u'. It's not portable.
Run `diff -c' only if cmp finds a difference.
2000-09-25 20:23:43 +00:00
Jim Meyering
f443264116 *** empty log message *** 2000-09-25 20:23:11 +00:00
Jim Meyering
6292a2bb96 *** empty log message *** 2000-09-25 19:43:57 +00:00
Jim Meyering
2371d8faaf Use `(exit 1); exit' paradigm also for framework_failure. 2000-09-25 19:41:56 +00:00
Jim Meyering
2dc45ff0c8 *** empty log message *** 2000-09-25 10:52:09 +00:00
Jim Meyering
d2a170a785 (prev_version_file): Define and use. 2000-09-25 10:51:53 +00:00
Jim Meyering
2da0b15537 (PREV_VERSION): Get the value from a file, rather
than trying to derive it from the current version number.
This is much more robust.
(alpha): Record just-released version number in `.version',
and commit (post-tag).
2000-09-25 10:49:35 +00:00
Jim Meyering
9191f089b9 *** empty log message *** 2000-09-25 07:41:45 +00:00
Jim Meyering
5f201a38b6 *** empty log message *** 2000-09-25 07:33:07 +00:00
Jim Meyering
53feb25dd7 *** empty log message *** 2000-09-25 07:17:29 +00:00
Jim Meyering
9726d96742 *** empty log message *** 2000-09-25 00:23:17 +00:00
Jim Meyering
3283bb8b93 (usage): Match revised documentation better. 2000-09-25 00:09:10 +00:00
Jim Meyering
2b9d8efc91 *** empty log message *** 2000-09-25 00:01:22 +00:00
Jim Meyering
c3da9e25ed (rol): Define (from GnuPG). 2000-09-25 00:00:58 +00:00
Jim Meyering
ab367e6b13 Give credit (GnuPG) where due.
(M): Use rol rather than open-coding it.
Add a FIXME comment.
2000-09-24 23:59:39 +00:00
Jim Meyering
8d0687974f *** empty log message *** 2000-09-24 23:05:57 +00:00
Jim Meyering
230bf31c87 . 2000-09-24 18:42:23 +00:00
Jim Meyering
5f7aed5f78 *** empty log message *** 2000-09-24 11:57:41 +00:00
Jim Meyering
65b0c96d46 (main): Tweak a relatively new diagnostic. 2000-09-24 11:57:36 +00:00
Jim Meyering
cb05584160 *** empty log message *** 2000-09-23 19:27:41 +00:00
Jim Meyering
79043436ce Output more information when a test fails. 2000-09-23 19:27:33 +00:00
Jim Meyering
3584f04f59 adjust for change in behavior 2000-09-23 19:24:12 +00:00
Jim Meyering
1f5e4907c2 . 2000-09-23 09:29:54 +00:00
Jim Meyering
a04e5b9dbc (main): When used with --force, each of the --link and
--symbolic-link options now implies --remove-destination.
2000-09-22 20:41:40 +00:00
Jim Meyering
ce8d840e83 *** empty log message *** 2000-09-22 19:30:36 +00:00
Jim Meyering
39da0cbc3b (cp_option_init): Once again make it so install always
unlinks an existing destination before trying to open it for writing.
Otherwise, installing onto a running shared library would make the
running program malfunction.
2000-09-22 19:30:29 +00:00
Jim Meyering
dffa52e11a *** empty log message *** 2000-09-22 19:28:24 +00:00
Jim Meyering
60c672e7ec (TESTS): Add dir-rm-dest. 2000-09-22 19:27:31 +00:00
Jim Meyering
ace3c90796 *** empty log message *** 2000-09-22 18:31:02 +00:00
Jim Meyering
c2c680ad95 (do_move): Moving a directory specified with a trailing
slash from one partition to another, and giving it a different
name at the destination would cause mv to get a failed assertion.
Reported by Michael Stone.
(strip_trailing_slashes_2): Move function definition to precede new first use.
2000-09-22 15:40:43 +00:00
Jim Meyering
e34407ac09 *** empty log message *** 2000-09-22 15:39:03 +00:00
Jim Meyering
bca49a8c12 (TESTS): Add part-rename. 2000-09-22 15:38:37 +00:00
Jim Meyering
483f907eb8 (copy_internal): Don't try to unlink directories when
using --remove-dest with -R.
2000-09-22 14:14:55 +00:00
Jim Meyering
f680954f1f *** empty log message *** 2000-09-22 13:31:14 +00:00
Jim Meyering
e7a17082b4 *** empty log message *** 2000-09-21 14:40:09 +00:00
Jim Meyering
33675b72ce *** empty log message *** 2000-09-21 05:40:34 +00:00
Jim Meyering
7708d86636 (parse_user_spec): Remove debugging printf I'd added.
Argh!
2000-09-21 05:40:28 +00:00
Jim Meyering
ff8d7f3d98 *** empty log message *** 2000-09-20 09:43:37 +00:00
Jim Meyering
39e3db9605 *** empty log message *** 2000-09-20 09:43:07 +00:00
Jim Meyering
8619939503 *** empty log message *** 2000-09-20 08:06:06 +00:00
Jim Meyering
aba49610d9 *** empty log message *** 2000-09-20 08:05:39 +00:00
Jim Meyering
4b5edfea53 (libfetish_a_SOURCES): Add sha.c.
(noinst_HEADERS): Add sha.h.
Based on code from Scott G. Miller and from GnuPG.
2000-09-20 08:05:24 +00:00
Jim Meyering
98daab19b9 . 2000-09-20 07:38:56 +00:00
Jim Meyering
6924fde974 *** empty log message *** 2000-09-18 06:37:15 +00:00
Jim Meyering
cf19019bf9 (AC_FUNC_GETLOADAVG): Restore the initial value of LIBS.
Otherwise, everyone ends up linking with -lelf for some configurations.
Reported by Mike Stone.
2000-09-18 06:37:01 +00:00
Jim Meyering
eccfa6b591 shrink tmp array length from 80 to 16. 2000-09-17 13:02:43 +00:00
Jim Meyering
1778e41773 use gnupg R/M macros 2000-09-17 13:01:02 +00:00
Jim Meyering
2d3aded1bb checkpoint 2000-09-17 12:54:25 +00:00
Jim Meyering
9d524deb2b *** empty log message *** 2000-09-17 11:12:31 +00:00
Jim Meyering
12079963ab remove debug junk 2000-09-17 11:11:26 +00:00
Jim Meyering
30ee9b3006 moving to gnupg's version of sha1.c 2000-09-17 11:11:01 +00:00
Jim Meyering
e87dcda480 snapshot of massaged original 2000-09-17 11:08:06 +00:00
Jim Meyering
3d929fbda2 . 2000-09-16 16:49:23 +00:00
Jim Meyering
c0e5ce613e *** empty log message *** 2000-09-16 16:47:06 +00:00
Jim Meyering
59a8abac57 Update from libc. 2000-09-16 16:46:50 +00:00
Jim Meyering
89aa821b03 *** empty log message *** 2000-09-16 16:26:09 +00:00
Jim Meyering
eaa53735c2 (Changing Special Permissions): Remove this statement:
`a' in the USERS part of a symbolic mode does not cause the special
permissions to be affected...  It doesn't reflect what the code does
and isn't required by POSIX.  Reported by aldomel@ix.netcom.com via
Mike Stone.
2000-09-16 16:26:02 +00:00
Jim Meyering
2dfa2338b8 *** empty log message *** 2000-09-15 06:33:32 +00:00
Jim Meyering
a7f53c72b3 *** empty log message *** 2000-09-12 14:04:20 +00:00
Jim Meyering
f6234990b2 *** empty log message *** 2000-09-10 19:48:05 +00:00
Jim Meyering
9eb2ccc113 (LC_ALL): Set to `C' and export to ensure
that `ls' sorts the same way for everyone.  Reported by Vin Shelton.
2000-09-10 19:47:56 +00:00
Jim Meyering
92ae1c7d2a *** empty log message *** 2000-09-10 19:04:14 +00:00
Jim Meyering
31d9a98e82 (b_host): Use freefriends.org, not tug.org. 2000-09-10 19:04:09 +00:00
Jim Meyering
4df3e0f3b9 *** empty log message *** 2000-09-10 07:31:54 +00:00
Jim Meyering
834c4dbfe1 (_getopt_internal): Update from glibc. 2000-09-10 07:31:44 +00:00
Jim Meyering
3d7a795592 *** empty log message *** 2000-09-09 16:34:17 +00:00
Jim Meyering
1352d5e6ce (usage): Make second `Usage' line more precise
(also making it match the texinfo documentation).
2000-09-09 16:33:59 +00:00
Jim Meyering
327b8f63c0 *** empty log message *** 2000-09-09 16:02:37 +00:00
Jim Meyering
af49390ea7 Rename ISASCII to IN_CTYPE_DOMAIN. 2000-09-09 15:58:57 +00:00
Jim Meyering
ac42c1a725 Rename ISASCII to IN_CTYPE_DOMAIN. 2000-09-09 15:58:03 +00:00
Jim Meyering
5f9e998bca Rename ISASCII to IN_CTYPE_DOMAIN. 2000-09-09 15:56:26 +00:00
Jim Meyering
16bcaae35b (Setting the time): Correct the capitalization of
`HHMM' in the info-rendering of the texinfo documentation.
2000-09-09 14:35:39 +00:00
Jim Meyering
315d948fe2 *** empty log message *** 2000-09-09 14:35:18 +00:00
Jim Meyering
3016c52459 *** empty log message *** 2000-09-09 12:12:28 +00:00
Jim Meyering
a6e3bc0ace (announcement): Use a stricter regexp for the previous version. 2000-09-09 12:12:16 +00:00
Jim Meyering
940dc652a5 *** empty log message *** 2000-09-09 09:58:16 +00:00
112 changed files with 2702 additions and 667 deletions

View File

@@ -11,10 +11,15 @@ maintainer-check:
$(MAKE) distcheck
$(MAKE) my-distcheck
prev-version := $(shell echo $(VERSION)|tr a-z Xa-y)
prev_version_file = .prev-version
THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
PREV_VERSION := $(shell cat $(prev_version_file))
PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
tag-package = $(shell echo "$(PACKAGE)" | tr a-z A-Z)
tag-this-version = $(subst .,_,$(VERSION))
tag-prev-version = $(subst .,_,$(prev-version))
tag-prev-version = $(subst .,_,$(PREV_VERSION))
this-cvs-tag = $(tag-package)-$(tag-this-version)
prev-cvs-tag = $(tag-package)-$(tag-prev-version)
@@ -70,21 +75,15 @@ my-distcheck: writable-files po-check
echo "$(distdir).tar.gz is ready for distribution"; \
echo "========================"
THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
# FIXME: this works only for Gnits-style test releases.
PREV_VERSION := $(shell echo $(VERSION)|tr b-z a-y|sed 's/a$$//')
PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
v = Version
a_host = alpha.gnu.org
b_host = tug.org
b_host = freefriends.org
alpha_subdir = gnu/fetish
a_url_dir = $(alpha_subdir)
b_url_dir = $(alpha_subdir)
a_real_dir = /fs/share/ftp/$(alpha_subdir)
b_real_dir = /home/ftp/pub/$(alpha_subdir)
b_real_dir = fetish-ftp
url_dir_list = $(foreach x,a b,ftp://$($(x)_host)/$($(x)_url_dir))
@@ -122,14 +121,14 @@ announcement: NEWS ChangeLog $(distdir).tar.gz
echo "$(md5) $(distdir).tar.gz"; \
echo; \
echo NEWS:; \
sed -n "/$(THIS_VERSION_REGEXP)/,/$(PREV_VERSION_REGEXP)/p" NEWS \
sed -n "/$(THIS_VERSION_REGEXP)/,/^\[$(PREV_VERSION_REGEXP)/p" NEWS \
| grep -v '^\['; \
echo; \
echo ChangeLog entries:; \
find . -name ChangeLog \
| xargs cvs diff -up -r$(prev-cvs-tag) -rHEAD \
| sed -n 's/^+//p' \
| perl -ne 'm!^\+\+ (\./)?! or print,next;' \
| perl -ne 'm!^\+\+ (\./)?! or print,next;' \
-e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
)
@@ -162,6 +161,8 @@ alpha: writable-files po-check
&& xdelta delta -9 $(prev-tgz) $(distdir).tar.gz $(xd-delta) || :
ln $(release-archive-dir)/$(xd-delta) .
chmod a-w $(release-archive-dir)/$(xd-delta)
echo $(VERSION) > $(prev_version_file)
cvs ci -m. $(prev_version_file)
@echo =====================================
@echo =====================================
@echo 'scp $(xd-delta) $(distdir).tar.gz \'

9
THANKS
View File

@@ -16,6 +16,7 @@ aldomel aldomel@ix.netcom.com
Alen Muzinic zveki@fly.cc.fer.hr
Alexey Solovyov alekso@math.uu.se
Andre Novaes Cunha Andre.Cunha@br.global-one.net
Andreas Gruenbacher ag@bestbits.at
Andreas Jaeger jaeger@gnu.org
Andreas Luik luik@isa.de
Andreas Schwab schwab@suse.de
@@ -52,13 +53,15 @@ Charles Randall crandall@matchlogic.com
Chip Salzenberg chip@valinux.com
Chris Yeo cyeo@biking.org
Christi Alice Scarborough christi@chiark.greenend.org.uk
Christian Krackowizer kra1@technodat.co.at
Christian Krackowizer ckrackowiz@std.schuler-ag.com
Christian Rose menthos@menthos.com
Christian von Roques roques@pond.sub.org
Chuck Hedrick hedrick@klinzhai.rutgers.edu
Clark Morgan cmorgan@aracnet.com
Colin Plumb colin@nyx.net
Collin Rogowski collin@rogowski.de
Dan Hagerty hag@gnu.ai.it.edu
Dan Pascu dan@services.iiruc.ro
Daniel Bergstrom noa@melody.se
David Dyck dcd@tc.fluke.COM
David Godfrey dave@delta.demon.co.uk
@@ -118,6 +121,8 @@ James Sneeringer jvs@ocslink.com
James Tanis jtt@soscorp.com
James Youngman james+usenet@free-lunch.demon.co.uk
Jamie Lokier jamie@imbolc.ucc.ie
Jan Fedak J.Fedak@sh.cvut.cz
Jan Nieuwenhuizen janneke@gnu.org
Janos Farkas chexum@shadow.banki.hu
Jarkko Hietaniemi jhi@epsilon.hut.fi
Jeff Moore jbm@mordor.com
@@ -149,6 +154,7 @@ J
Kai-Uwe Rommel rommel@informatik.tu-muenchen.de
Kalle Olavi Niemitalo tosi@stekt.oulu.fi
Kamal Paul Nigam Kamal_Paul_Nigam@gs35.sp.cs.cmu.edu
Karl Eichwalder keichwa@gmx.net
Karl Heuer kwzh@gnu.org
Karsten Thygesen karthy@kom.auc.dk
Kaveh R. Ghazi ghazi@caip.rutgers.edu
@@ -161,6 +167,7 @@ Lars Hecking lhecking@nmrc.ucc.ie
Lehti Rami rammer@cs.tut.fi
Leonard N. Zubkoff lnz@dandelion.com
Lorne Baker lbaker@nitro.avint.net
M. P. Suzuki mpsuzuki@hiroshima-u.ac.jp
Maciej Kwapulinski pikpok@univ.gda.pl
Manas Garg manas@cygsoft.com
Manfred Hollstein manfred@s-direktnet.de

View File

@@ -440,7 +440,7 @@ to the local time.
@cindex pure numbers in date strings
The precise intepretation of a pure decimal number depends
the context in the date string.
on the context in the date string.
If the decimal number is of the form @var{yyyy}@var{mm}@var{dd} and no
other calendar date item (@pxref{Calendar date items}) appears before it
@@ -468,13 +468,14 @@ year.
@cindex Berets, Jim
@cindex MacKenzie, David
@cindex Meyering, Jim
@cindex Eggert, Paul
@code{getdate} was originally implemented by Steven M. Bellovin
(@email{smb@@research.att.com}) while at the University of North Carolina
at Chapel Hill. The code was later tweaked by a couple of people on
Usenet, then completely overhauled by Rich $alz (@email{rsalz@@bbn.com})
and Jim Berets (@email{jberets@@bbn.com}) in August, 1990. Various
revisions for the GNU system were made by David MacKenzie, Jim Meyering,
and others.
Paul Eggert and others.
@cindex Pinard, F.
@cindex Berry, K.

View File

@@ -276,18 +276,8 @@ o+t
Remember that the special permissions only affect files that are
executable, plus, on some systems, directories (on which they have
different meanings; @pxref{Mode Structure}). Using @samp{a}
in the @var{users} part of a symbolic mode does not cause the special
permissions to be affected; thus,
@example
a+s
@end example
@noindent
has @emph{no effect}. You must use @samp{u}, @samp{g}, and @samp{o}
explicitly to affect the special permissions. Also, the
combinations @samp{u+t}, @samp{g+t}, and @samp{o+s} have no effect.
different meanings; @pxref{Mode Structure}).
Also, the combinations @samp{u+t}, @samp{g+t}, and @samp{o+s} have no effect.
The @samp{=} operator is not very useful with special permissions; for
example, the mode:

View File

@@ -2202,7 +2202,7 @@ format of the @samp{%c} directive (described below). Synopses:
@example
date [@var{option}]@dots{} [+@var{format}]
date [-u|--utc|--universal] @c this avoids a newline in the output
[ @var{MMDDhhmm}[[@var{CC}]@var{YY}][.@var{ss}] ]
[ MMDDhhmm[[CC]YY][.ss] ]
@end example
@findex strftime @r{and @code{date}}
@@ -2258,7 +2258,7 @@ Note that this value is the number of seconds between the epoch
and the current date as defined by the localtime system call.
It isn't changed by the @samp{--date} option.
@item %S
second (00@dots{}61)
second (00@dots{}60)
@item %T
time, 24-hour (hh:mm:ss)
@item %X
@@ -2400,7 +2400,7 @@ zone.
The argument must consist entirely of digits, which have the following
meaning:
@table @var
@table @samp
@item MM
month
@item DD
@@ -2479,16 +2479,14 @@ Append the hours, minutes, and seconds.
@end table
If showing any time terms, then include the time zone using the format
@samp{%z}. If @samp{--utc} is also specified, use @samp{%Z} in place of
@samp{%z}.
@item -R
@itemx --rfc-822
@opindex -R
@opindex --rfc-822
Display the time and date using the RFC-822-specified
Display the time and date using the RFC-822-conforming
format, @samp{%a, %_d %b %Y %H:%M:%S %z}.
If @samp{--utc} is also specified, use @samp{GMT} in place of @samp{%z}.
@item -r @var{file}
@itemx --reference=@var{file}
@@ -2509,11 +2507,16 @@ Set the time and date to @var{datestr}, See @samp{-d} above.
@opindex -u
@opindex --utc
@opindex --universal
@cindex coordinated universal time
@cindex Coordinated Universal Time
@cindex UTC
@cindex Greenwich Mean Time
Print or set the time and date in Universal Coordinated Time instead of
in local (wall clock) time.
@cindex GMT
Use Coordinated Universal Time (@sc{utc}) by operating as if the
@env{TZ} environment variable was set to the string @samp{UTC0}.
Normally, @command{date} operates in the time zone indicated by
@env{TZ}, or the system default if @env{TZ} is not set. Coordinated
Universal Time is often called ``Greenwich Mean Time'' (@sc{gmt}) for
historical reasons.
@end table
@@ -2591,7 +2594,7 @@ To convert a date string to the number of seconds since the epoch
the @samp{%s} format. That can be useful in sorting and/or graphing
and/or comparing data by date. The following command outputs the
number of the seconds since the epoch for the time one second later
than the epoch, but in time zone five hours later (Cambridge, Massachusetts),
than the epoch, but in a time zone five hours later (Cambridge, Massachusetts),
thus a total of five hours and one second after the epoch:
@example

View File

@@ -3,7 +3,7 @@
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
\def\texinfoversion{2000-09-06.09}
\def\texinfoversion{2000-10-18.06}
%
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
% Free Software Foundation, Inc.
@@ -688,16 +688,25 @@ where each line of input produces a line of output.}
\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
\leftline{\hskip\leftskip{\rm#1}}}}
% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
\def\inmargin#1{%
\strut\vadjust{\nobreak\kern-\strutdepth
\vtop to \strutdepth{\baselineskip\strutdepth\vss
\llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
% @inmargin{TEXT} puts TEXT in the left margin next to the current
% paragraph. For more general purposes, use the \margin insertion class.
%
\newskip\inmarginspacing \inmarginspacing=1cm
\def\strutdepth{\dp\strutbox}
%
\def\inmargin#1{\strut\vadjust{%
\nobreak
\kern-\strutdepth
\vtop to \strutdepth{%
\baselineskip=\strutdepth
\vss
% if you have multiple lines of stuff to put here, you'll need to
% make the vbox yourself of the appropriate size.
\llap{#1\hskip\inmarginspacing}%
\null
}%
}}
%\hbox{{\rm#1}}\hfil\break}}
% @include file insert text of that file as input.
% Allow normal characters that we make active in the argument (a file name).

View File

@@ -217,3 +217,13 @@ p delta
n
p Start
q
b dir_name
r
n
p slash
n
n
n
p slash
p slash - path + 1
q

View File

@@ -1,5 +1,109 @@
2000-10-28 Jim Meyering <meyering@lucent.com>
* memchr.c: Update from libc.
Adjust for portability:
[HAVE_STDLIB_H]: Include stdlib.h.
[HAVE_BP_SYM_H || _LIBC]: Guard inclusion of bp-sym.h.
Undef __memchr, too.
[!weak_alias]: Define __memchr to memchr.
* regex.c: Update from libc.
* regex.h: Likewise.
* getopt1.c: Likewise.
* memcmp.c: Likewise.
* getusershell.c (setusershell) [HAVE_FSEEKO]: Use fseek0.
Patch by Ulrich Drepper.
2000-10-26 Jim Meyering <meyering@lucent.com>
* strftime.c: Update from libc.
2000-10-25 Jim Meyering <meyering@lucent.com>
* obstack.c: Update from libc.
2000-10-23 Jim Meyering <meyering@lucent.com>
* hard-locale.c (hard_locale): Revert last change -- it was simply
wrong. That set_locale call must not have any side effects.
From Paul Eggert.
2000-10-22 Jim Meyering <meyering@lucent.com>
* md5.c (md5_process_block) [OP]: Use `rol', not CYCLIC.
[CYCLIC]: Remove now-unused definition.
* save-cwd.c (O_DIRECTORY): Define, if needed.
(save_cwd) [HAVE_FCHDIR]: Use O_DIRECTORY when opening ".".
Suggestion from Ulrich Drepper.
2000-10-21 Jim Meyering <meyering@lucent.com>
* dirname.c (dir_name_r): New function, factored out of dir_name.
(dir_name): Use dir_name_r.
* dirname.h (dir_name_r): Declare it.
2000-10-21 Jim Meyering <meyering@lucent.com>
* dirname.c (memrchr): Declare if necessary.
(dir_name): Remove the restriction that there be no
trailing slashes. Now, this code skips past them, effectively
ignoring them.
[TEST_DIRNAME] (main): New unit tests.
* memrchr.c: New file from GNU libc.
Undef __memrchr, too.
[!weak_alias]: Define __memrchr to memrchr.
Guard weak_alias use with `#ifdef weak_alias'.
2000-10-17 Jim Meyering <meyering@lucent.com>
* quote.h (PARAMS): Define and use.
Reported by Akim Demaille.
* getopt.c: Update from libc.
2000-10-16 Jim Meyering <meyering@lucent.com>
* hard-locale.c (hard_locale): Use "", not 0 as 2nd arg to setlocale.
From Jan Fedak.
2000-09-25 Jim Meyering <meyering@lucent.com>
* md5.h (rol): Define (from GnuPG).
* sha.c: Give credit (GnuPG) where due.
(M): Use rol rather than open-coding it.
Add a FIXME comment.
2000-09-21 Jim Meyering <meyering@lucent.com>
* userspec.c (parse_user_spec): Remove debugging printf I'd added.
Reported by Michael Stone.
2000-09-20 Jim Meyering <meyering@lucent.com>
* Makefile.am (libfetish_a_SOURCES): Add sha.c.
(noinst_HEADERS): Add sha.h.
Based on code from Scott G. Miller and from GnuPG.
2000-09-15 Jim Meyering <meyering@lucent.com>
* regex.c: Update from libc.
2000-09-10 Jim Meyering <meyering@lucent.com>
* getopt.c (_getopt_internal): Update from glibc.
2000-09-09 Jim Meyering <meyering@lucent.com>
* quotearg.c: Rename ISASCII to IN_CTYPE_DOMAIN, so people don't
think it should be used as a general replacement for isascii.
* fnmatch.c: Likewise.
* mbswidth.c: Likewise
* regex.c: Likewise.
Don't use atoi.
* userspec.c: Include sys/param.h and limits.h.
Include xstrtol.h.

View File

@@ -15,7 +15,7 @@ libfetish_a_SOURCES = \
makepath.c mbswidth.c md5.c memcasecmp.c memcoll.c modechange.c \
path-concat.c \
quote.c quotearg.c readtokens.c safe-read.c same.c save-cwd.c \
savedir.c stripslash.c unicodeio.c userspec.c version-etc.c xgetcwd.c \
savedir.c sha.c stripslash.c unicodeio.c userspec.c version-etc.c xgetcwd.c \
xgethostname.c xmalloc.c xstrdup.c xstrtod.c xstrtol.c xstrtoul.c \
xstrtoumax.c yesno.c
@@ -30,7 +30,7 @@ noinst_HEADERS = \
linebuffer.h long-options.h mbswidth.h md5.h memcasecmp.h memcoll.h \
makepath.h mbswidth.h modechange.h mountlist.h nanosleep.h obstack.h \
path-concat.h pathmax.h posixtm.h quote.h quotearg.h readtokens.h \
readutmp.h regex.h safe-read.h same.h save-cwd.h savedir.h \
readutmp.h regex.h safe-read.h same.h save-cwd.h savedir.h sha.h \
strverscmp.h unicodeio.h version-etc.h xalloc.h xstrtod.h xstrtol.h
BUILT_SOURCES = getdate.c lstat.c stat.c

View File

@@ -130,7 +130,7 @@ libfetish_a_SOURCES = \
makepath.c mbswidth.c md5.c memcasecmp.c memcoll.c modechange.c \
path-concat.c \
quote.c quotearg.c readtokens.c safe-read.c same.c save-cwd.c \
savedir.c stripslash.c unicodeio.c userspec.c version-etc.c xgetcwd.c \
savedir.c sha.c stripslash.c unicodeio.c userspec.c version-etc.c xgetcwd.c \
xgethostname.c xmalloc.c xstrdup.c xstrtod.c xstrtol.c xstrtoul.c \
xstrtoumax.c yesno.c
@@ -146,7 +146,7 @@ noinst_HEADERS = \
linebuffer.h long-options.h mbswidth.h md5.h memcasecmp.h memcoll.h \
makepath.h mbswidth.h modechange.h mountlist.h nanosleep.h obstack.h \
path-concat.h pathmax.h posixtm.h quote.h quotearg.h readtokens.h \
readutmp.h regex.h safe-read.h same.h save-cwd.h savedir.h \
readutmp.h regex.h safe-read.h same.h save-cwd.h savedir.h sha.h \
strverscmp.h unicodeio.h version-etc.h xalloc.h xstrtod.h xstrtol.h
@@ -181,9 +181,9 @@ hash$U.o human$U.o idcache$U.o isdir$U.o linebuffer$U.o \
localcharset$U.o long-options$U.o makepath$U.o mbswidth$U.o md5$U.o \
memcasecmp$U.o memcoll$U.o modechange$U.o path-concat$U.o quote$U.o \
quotearg$U.o readtokens$U.o safe-read$U.o same$U.o save-cwd$U.o \
savedir$U.o stripslash$U.o unicodeio$U.o userspec$U.o version-etc$U.o \
xgetcwd$U.o xgethostname$U.o xmalloc$U.o xstrdup$U.o xstrtod$U.o \
xstrtol$U.o xstrtoul$U.o xstrtoumax$U.o yesno$U.o
savedir$U.o sha$U.o stripslash$U.o unicodeio$U.o userspec$U.o \
version-etc$U.o xgetcwd$U.o xgethostname$U.o xmalloc$U.o xstrdup$U.o \
xstrtod$U.o xstrtol$U.o xstrtoul$U.o xstrtoumax$U.o yesno$U.o
libfetish_a_OBJECTS = $(am_libfetish_a_OBJECTS)
AR = ar
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -213,33 +213,34 @@ $(DEPDIR)/localcharset$U.Po $(DEPDIR)/long-options$U.Po \
$(DEPDIR)/lstat.Po $(DEPDIR)/makepath$U.Po $(DEPDIR)/malloc.Po \
$(DEPDIR)/mbswidth$U.Po $(DEPDIR)/md5$U.Po $(DEPDIR)/memcasecmp$U.Po \
$(DEPDIR)/memchr.Po $(DEPDIR)/memcmp.Po $(DEPDIR)/memcoll$U.Po \
$(DEPDIR)/memcpy.Po $(DEPDIR)/memmove.Po $(DEPDIR)/memset.Po \
$(DEPDIR)/mktime.Po $(DEPDIR)/modechange$U.Po $(DEPDIR)/mountlist.Po \
$(DEPDIR)/nanosleep.Po $(DEPDIR)/obstack.Po $(DEPDIR)/path-concat$U.Po \
$(DEPDIR)/posixtm$U.Po $(DEPDIR)/putenv.Po $(DEPDIR)/quote$U.Po \
$(DEPDIR)/quotearg$U.Po $(DEPDIR)/readtokens$U.Po $(DEPDIR)/readutmp.Po \
$(DEPDIR)/realloc.Po $(DEPDIR)/regex.Po $(DEPDIR)/rmdir.Po \
$(DEPDIR)/rpmatch.Po $(DEPDIR)/safe-read$U.Po $(DEPDIR)/same$U.Po \
$(DEPDIR)/save-cwd$U.Po $(DEPDIR)/savedir$U.Po $(DEPDIR)/stat.Po \
$(DEPDIR)/stime.Po $(DEPDIR)/stpcpy.Po $(DEPDIR)/strcasecmp.Po \
$(DEPDIR)/strcspn.Po $(DEPDIR)/strdup.Po $(DEPDIR)/strftime.Po \
$(DEPDIR)/stripslash$U.Po $(DEPDIR)/strncasecmp.Po $(DEPDIR)/strndup.Po \
$(DEPDIR)/strnlen.Po $(DEPDIR)/strpbrk.Po $(DEPDIR)/strstr.Po \
$(DEPDIR)/strtod.Po $(DEPDIR)/strtol.Po $(DEPDIR)/strtoul.Po \
$(DEPDIR)/strtoull.Po $(DEPDIR)/strtoumax.Po $(DEPDIR)/strverscmp.Po \
$(DEPDIR)/unicodeio$U.Po $(DEPDIR)/userspec$U.Po $(DEPDIR)/utime.Po \
$(DEPDIR)/version-etc$U.Po $(DEPDIR)/xgetcwd$U.Po \
$(DEPDIR)/xgethostname$U.Po $(DEPDIR)/xmalloc$U.Po \
$(DEPDIR)/xstrdup$U.Po $(DEPDIR)/xstrtod$U.Po $(DEPDIR)/xstrtol$U.Po \
$(DEPDIR)/xstrtoul$U.Po $(DEPDIR)/xstrtoumax$U.Po $(DEPDIR)/yesno$U.Po
$(DEPDIR)/memcpy.Po $(DEPDIR)/memmove.Po $(DEPDIR)/memrchr.Po \
$(DEPDIR)/memset.Po $(DEPDIR)/mktime.Po $(DEPDIR)/modechange$U.Po \
$(DEPDIR)/mountlist.Po $(DEPDIR)/nanosleep.Po $(DEPDIR)/obstack.Po \
$(DEPDIR)/path-concat$U.Po $(DEPDIR)/posixtm$U.Po $(DEPDIR)/putenv.Po \
$(DEPDIR)/quote$U.Po $(DEPDIR)/quotearg$U.Po $(DEPDIR)/readtokens$U.Po \
$(DEPDIR)/readutmp.Po $(DEPDIR)/realloc.Po $(DEPDIR)/regex.Po \
$(DEPDIR)/rmdir.Po $(DEPDIR)/rpmatch.Po $(DEPDIR)/safe-read$U.Po \
$(DEPDIR)/same$U.Po $(DEPDIR)/save-cwd$U.Po $(DEPDIR)/savedir$U.Po \
$(DEPDIR)/sha$U.Po $(DEPDIR)/stat.Po $(DEPDIR)/stime.Po \
$(DEPDIR)/stpcpy.Po $(DEPDIR)/strcasecmp.Po $(DEPDIR)/strcspn.Po \
$(DEPDIR)/strdup.Po $(DEPDIR)/strftime.Po $(DEPDIR)/stripslash$U.Po \
$(DEPDIR)/strncasecmp.Po $(DEPDIR)/strndup.Po $(DEPDIR)/strnlen.Po \
$(DEPDIR)/strpbrk.Po $(DEPDIR)/strstr.Po $(DEPDIR)/strtod.Po \
$(DEPDIR)/strtol.Po $(DEPDIR)/strtoul.Po $(DEPDIR)/strtoull.Po \
$(DEPDIR)/strtoumax.Po $(DEPDIR)/strverscmp.Po $(DEPDIR)/unicodeio$U.Po \
$(DEPDIR)/userspec$U.Po $(DEPDIR)/utime.Po $(DEPDIR)/version-etc$U.Po \
$(DEPDIR)/xgetcwd$U.Po $(DEPDIR)/xgethostname$U.Po \
$(DEPDIR)/xmalloc$U.Po $(DEPDIR)/xstrdup$U.Po $(DEPDIR)/xstrtod$U.Po \
$(DEPDIR)/xstrtol$U.Po $(DEPDIR)/xstrtoul$U.Po \
$(DEPDIR)/xstrtoumax$U.Po $(DEPDIR)/yesno$U.Po
DIST_COMMON = README $(noinst_HEADERS) ChangeLog Makefile.am \
Makefile.in TODO __fpending.c alloca.c atexit.c chown.c dup2.c error.c \
error.h euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c \
getdate.c getgroups.c gethostname.c getline.c getloadavg.c getpass.c \
getusershell.c group-member.c lchown.c malloc.c memchr.c memcmp.c \
memcpy.c memmove.c memset.c mktime.c mountlist.c nanosleep.c obstack.c \
obstack.h putenv.c readutmp.c realloc.c regex.c rmdir.c rpmatch.c \
stime.c stpcpy.c strcasecmp.c strcspn.c strdup.c strftime.c \
memcpy.c memmove.c memrchr.c memset.c mktime.c mountlist.c nanosleep.c \
obstack.c obstack.h putenv.c readutmp.c realloc.c regex.c rmdir.c \
rpmatch.c stime.c stpcpy.c strcasecmp.c strcspn.c strdup.c strftime.c \
strncasecmp.c strndup.c strnlen.c strpbrk.c strstr.c strtod.c strtol.c \
strtoul.c strtoull.c strtoumax.c strverscmp.c utime.c
@@ -407,6 +408,8 @@ memcpy_.c: memcpy.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/memcpy.c; then echo $(srcdir)/memcpy.c; else echo memcpy.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > memcpy_.c
memmove_.c: memmove.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/memmove.c; then echo $(srcdir)/memmove.c; else echo memmove.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > memmove_.c
memrchr_.c: memrchr.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/memrchr.c; then echo $(srcdir)/memrchr.c; else echo memrchr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > memrchr_.c
memset_.c: memset.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/memset.c; then echo $(srcdir)/memset.c; else echo memset.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > memset_.c
mktime_.c: mktime.c $(ANSI2KNR)
@@ -449,6 +452,8 @@ save-cwd_.c: save-cwd.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/save-cwd.c; then echo $(srcdir)/save-cwd.c; else echo save-cwd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > save-cwd_.c
savedir_.c: savedir.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/savedir.c; then echo $(srcdir)/savedir.c; else echo savedir.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > savedir_.c
sha_.c: sha.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/sha.c; then echo $(srcdir)/sha.c; else echo sha.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > sha_.c
stat_.c: stat.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/stat.c; then echo $(srcdir)/stat.c; else echo stat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > stat_.c
stime_.c: stime.c $(ANSI2KNR)
@@ -522,17 +527,17 @@ getopt1_.o getpass_.o getstr_.o getugroups_.o getusershell_.o \
group-member_.o hard-locale_.o hash_.o human_.o idcache_.o isdir_.o \
lchown_.o linebuffer_.o localcharset_.o long-options_.o lstat_.o \
makepath_.o malloc_.o mbswidth_.o md5_.o memcasecmp_.o memchr_.o \
memcmp_.o memcoll_.o memcpy_.o memmove_.o memset_.o mktime_.o \
modechange_.o mountlist_.o nanosleep_.o obstack_.o path-concat_.o \
posixtm_.o putenv_.o quote_.o quotearg_.o readtokens_.o readutmp_.o \
realloc_.o regex_.o rmdir_.o rpmatch_.o safe-read_.o same_.o \
save-cwd_.o savedir_.o stat_.o stime_.o stpcpy_.o strcasecmp_.o \
strcspn_.o strdup_.o strftime_.o stripslash_.o strncasecmp_.o \
strndup_.o strnlen_.o strpbrk_.o strstr_.o strtod_.o strtol_.o \
strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o unicodeio_.o \
userspec_.o utime_.o version-etc_.o xgetcwd_.o xgethostname_.o \
xmalloc_.o xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o xstrtoumax_.o \
yesno_.o : $(ANSI2KNR)
memcmp_.o memcoll_.o memcpy_.o memmove_.o memrchr_.o memset_.o \
mktime_.o modechange_.o mountlist_.o nanosleep_.o obstack_.o \
path-concat_.o posixtm_.o putenv_.o quote_.o quotearg_.o readtokens_.o \
readutmp_.o realloc_.o regex_.o rmdir_.o rpmatch_.o safe-read_.o \
same_.o save-cwd_.o savedir_.o sha_.o stat_.o stime_.o stpcpy_.o \
strcasecmp_.o strcspn_.o strdup_.o strftime_.o stripslash_.o \
strncasecmp_.o strndup_.o strnlen_.o strpbrk_.o strstr_.o strtod_.o \
strtol_.o strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o \
unicodeio_.o userspec_.o utime_.o version-etc_.o xgetcwd_.o \
xgethostname_.o xmalloc_.o xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o \
xstrtoumax_.o yesno_.o : $(ANSI2KNR)
.y.c:
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
@@ -627,6 +632,7 @@ maintainer-clean-tags:
@AMDEP@include $(DEPDIR)/memcoll$U.Po
@AMDEP@include $(DEPDIR)/memcpy.Po
@AMDEP@include $(DEPDIR)/memmove.Po
@AMDEP@include $(DEPDIR)/memrchr.Po
@AMDEP@include $(DEPDIR)/memset.Po
@AMDEP@include $(DEPDIR)/mktime.Po
@AMDEP@include $(DEPDIR)/modechange$U.Po
@@ -648,6 +654,7 @@ maintainer-clean-tags:
@AMDEP@include $(DEPDIR)/same$U.Po
@AMDEP@include $(DEPDIR)/save-cwd$U.Po
@AMDEP@include $(DEPDIR)/savedir$U.Po
@AMDEP@include $(DEPDIR)/sha$U.Po
@AMDEP@include $(DEPDIR)/stat.Po
@AMDEP@include $(DEPDIR)/stime.Po
@AMDEP@include $(DEPDIR)/stpcpy.Po

View File

@@ -34,6 +34,13 @@ char *malloc ();
#endif
#include <assert.h>
#ifndef HAVE_DECL_MEMRCHR
"this configure-time declaration test was not run"
#endif
#if !HAVE_DECL_MEMRCHR
void *memrchr ();
#endif
#include "dirname.h"
#ifndef ISSLASH
@@ -42,15 +49,13 @@ char *malloc ();
#define BACKSLASH_IS_PATH_SEPARATOR ISSLASH ('\\')
/* Return the leading directories part of PATH,
allocated with malloc. If out of memory, return 0.
Assumes that trailing slashes have already been
removed. */
char *
dir_name (const char *path)
/* Return the length of `dirname (PATH)' and set *RESULT
to point to PATH or to `"."', as appropriate.
Works properly even if there are trailing slashes
(by effectively ignoring them). */
size_t
dir_name_r (const char *path, const char **result)
{
char *newpath;
char *slash;
int length; /* Length of result, not including NUL. */
@@ -62,11 +67,26 @@ dir_name (const char *path)
slash = b;
}
/* Make sure there are no trailing slashes. */
assert (slash == NULL /* There are no slashes in PATH. */
|| slash[1] != 0 /* There is a non-NUL byte after the last slash. */
|| path == slash /* PATH is just `/'. */
);
/* If the last byte of PATH is a slash, decrement SLASH until it's
pointing at the leftmost in a sequence of trailing slashes. */
if (slash && slash[1] == 0)
{
while (path < slash && ISSLASH (slash[-1]))
{
--slash;
}
if (path < slash)
{
slash = memrchr (path, '/', slash - path);
if (BACKSLASH_IS_PATH_SEPARATOR)
{
char *b = memrchr (path, '\\', slash - path);
if (b && slash < b)
slash = b;
}
}
}
if (slash == 0)
{
@@ -96,10 +116,67 @@ dir_name (const char *path)
length = slash - path + 1;
}
newpath = (char *) malloc (length + 1);
*result = path;
return length;
}
/* Return the leading directories part of PATH,
allocated with malloc. If out of memory, return 0.
Works properly even if there are trailing slashes
(by effectively ignoring them). */
char *
dir_name (const char *path)
{
const char *result;
size_t length = dir_name_r (path, &result);
char *newpath = (char *) malloc (length + 1);
if (newpath == 0)
return 0;
strncpy (newpath, path, length);
strncpy (newpath, result, length);
newpath[length] = 0;
return newpath;
}
#ifdef TEST_DIRNAME
/*
Run the test like this (expect no output):
gcc -DHAVE_CONFIG_H -DTEST_DIRNAME -I.. -O -Wall memrchr.c dirname.c
sed -n '/^BEGIN-DATA$/,/^END-DATA$/p' dirname.c|grep -v DATA|./a.out
BEGIN-DATA
foo//// .
bar/foo//// bar
foo/ .
/ /
. .
a .
END-DATA
*/
# define MAX_BUFF_LEN 1024
# include <stdio.h>
# include <stdlib.h>
int
main ()
{
char buff[MAX_BUFF_LEN + 1];
buff[MAX_BUFF_LEN] = 0;
while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0])
{
char path[MAX_BUFF_LEN];
char expected_result[MAX_BUFF_LEN];
char *result;
sscanf (buff, "%s %s", path, expected_result);
result = dir_name (path);
if (strcmp (result, expected_result))
printf ("%s: got %s, expected %s\n", path, result, expected_result);
}
exit (0);
}
#endif

View File

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

View File

@@ -40,12 +40,12 @@
# if defined STDC_HEADERS || !defined isascii
# define ISASCII(c) 1
# define IN_CTYPE_DOMAIN(c) 1
# else
# define ISASCII(c) isascii(c)
# define IN_CTYPE_DOMAIN(c) isascii(c)
# endif
# define ISUPPER(c) (ISASCII (c) && isupper (c))
# define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
# ifndef errno

View File

@@ -75,11 +75,12 @@
#endif
#ifndef _
/* This is for other GNU distributions with internationalized messages.
When compiling libc, the _ macro is predefined. */
# ifdef HAVE_LIBINTL_H
/* This is for other GNU distributions with internationalized messages. */
# if defined HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
# define _(msgid) gettext (msgid)
# ifndef _
# define _(msgid) gettext (msgid)
# endif
# else
# define _(msgid) (msgid)
# endif
@@ -671,7 +672,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
pfound = p;
indfound = option_index;
}
else if (pfound->has_arg != p->has_arg
else if (long_only
|| pfound->has_arg != p->has_arg
|| pfound->flag != p->flag
|| pfound->val != p->val)
/* Second or later nonexact match found. */

View File

@@ -20,7 +20,10 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#else
#endif
#include "getopt.h"
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
@@ -28,9 +31,6 @@
#define const
#endif
#endif
#endif
#include "getopt.h"
#include <stdio.h>

View File

@@ -103,7 +103,13 @@ setusershell ()
if (shellstream == NULL)
shellstream = fopen (SHELLS_FILE, "r");
else
fseek (shellstream, 0L, 0);
{
#ifdef HAVE_FSEEKO
fseeko (shellstream, 0, 0);
#else
fseek (shellstream, 0L, 0);
#endif
}
}
/* Close the shells file. */

View File

@@ -74,15 +74,13 @@ int wcwidth ();
/* Get ISPRINT. */
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
/* Undefine to protect against the definition in wctype.h of solaris2.6. */
# undef ISASCII
# define ISASCII(c) 1
# define IN_CTYPE_DOMAIN(c) 1
#else
# define ISASCII(c) isascii (c)
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
/* Undefine to protect against the definition in wctype.h of solaris2.6. */
#undef ISPRINT
#define ISPRINT(c) (ISASCII (c) && isprint (c))
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#include "mbswidth.h"

View File

@@ -304,19 +304,16 @@ md5_process_block (buffer, len, ctx)
{ \
a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \
++words; \
CYCLIC (a, s); \
a = rol (a, s); \
a += b; \
} \
while (0)
/* It is unfortunate that C does not provide an operator for
cyclic rotation. Hope the C compiler is smart enough. */
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
/* Before we start, one word to the strange constants.
They are defined in RFC 1321 as
T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64, or
perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin $_))}'
*/
/* Round 1. */
@@ -345,7 +342,7 @@ md5_process_block (buffer, len, ctx)
do \
{ \
a += f (b, c, d) + correct_words[k] + T; \
CYCLIC (a, s); \
a = rol (a, s); \
a += b; \
} \
while (0)

View File

@@ -143,4 +143,19 @@ extern int md5_stream __P ((FILE *stream, void *resblock));
digest. */
extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
/* The following is from gnupg-1.0.2's cipher/bithelp.h. */
/* Rotate a 32 bit integer by n bytes */
#if defined(__GNUC__) && defined(__i386__)
static inline md5_uint32
rol(md5_uint32 x, int n)
{
__asm__("roll %%cl,%0"
:"=r" (x)
:"0" (x),"c" (n));
return x;
}
#else
# define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
#endif
#endif

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 1991, 1993, 1997, 1999 Free Software Foundation, Inc.
/* Copyright (C) 1991,93,96,97,99,2000 Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
with help from Dan Sahlin (dan@sics.se) and
commentary by Jim Blandy (jimb@ai.mit.edu);
@@ -34,11 +34,18 @@ USA. */
# define __ptr_t char *
#endif /* C++ or ANSI C. */
#if defined (_LIBC)
#if defined _LIBC
# include <string.h>
# include <memcopy.h>
#else
# define reg_char char
#endif
#if defined (HAVE_LIMITS_H) || defined (_LIBC)
#if HAVE_STDLIB_H || defined _LIBC
# include <stdlib.h>
#endif
#if HAVE_LIMITS_H || defined _LIBC
# include <limits.h>
#endif
@@ -49,21 +56,28 @@ USA. */
#endif
#include <sys/types.h>
#if HAVE_BP_SYM_H || defined _LIBC
# include <bp-sym.h>
#else
# define BP_SYM(sym) sym
#endif
#undef memchr
#undef __memchr
/* Search no more than N bytes of S for C. */
__ptr_t
memchr (s, c, n)
__memchr (s, c_in, n)
const __ptr_t s;
int c;
int c_in;
size_t n;
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
unsigned long int longword, magic_bits, charmask;
unsigned reg_char c;
c = (unsigned char) c;
c = (unsigned char) c_in;
/* Handle the first few characters by reading one character at a time.
Do this until CHAR_PTR is aligned on a longword boundary. */
@@ -197,3 +211,6 @@ memchr (s, c, n)
return 0;
}
#ifdef weak_alias
weak_alias (__memchr, BP_SYM (memchr))
#endif

View File

@@ -49,6 +49,11 @@
#ifdef _LIBC
# include <memcopy.h>
# include <endian.h>
# if __BYTE_ORDER == __BIG_ENDIAN
# define WORDS_BIGENDIAN
# endif
#else /* Not in the GNU C library. */

209
lib/memrchr.c Normal file
View File

@@ -0,0 +1,209 @@
/* memrchr -- find the last occurrence of a byte in a memory block
Copyright (C) 1991, 93, 96, 97, 99, 2000 Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
with help from Dan Sahlin (dan@sics.se) and
commentary by Jim Blandy (jimb@ai.mit.edu);
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
and implemented by Roland McGrath (roland@ai.mit.edu).
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#undef __ptr_t
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
# define __ptr_t void *
#else /* Not C++ or ANSI C. */
# define __ptr_t char *
#endif /* C++ or ANSI C. */
#if defined (_LIBC)
# include <string.h>
# include <memcopy.h>
#else
# define reg_char char
#endif
#if defined (HAVE_LIMITS_H) || defined (_LIBC)
# include <limits.h>
#endif
#define LONG_MAX_32_BITS 2147483647
#ifndef LONG_MAX
# define LONG_MAX LONG_MAX_32_BITS
#endif
#include <sys/types.h>
#undef __memrchr
#undef memrchr
#ifndef weak_alias
# define __memrchr memrchr
#endif
/* Search no more than N bytes of S for C. */
__ptr_t
__memrchr (s, c_in, n)
const __ptr_t s;
int c_in;
size_t n;
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
unsigned long int longword, magic_bits, charmask;
unsigned reg_char c;
c = (unsigned char) c_in;
/* Handle the last few characters by reading one character at a time.
Do this until CHAR_PTR is aligned on a longword boundary. */
for (char_ptr = (const unsigned char *) s + n;
n > 0 && ((unsigned long int) char_ptr
& (sizeof (longword) - 1)) != 0;
--n)
if (*--char_ptr == c)
return (__ptr_t) char_ptr;
/* All these elucidatory comments refer to 4-byte longwords,
but the theory applies equally well to 8-byte longwords. */
longword_ptr = (unsigned long int *) char_ptr;
/* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
the "holes." Note that there is a hole just to the left of
each byte, with an extra at the end:
bits: 01111110 11111110 11111110 11111111
bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
The 1-bits make sure that carries propagate to the next 0-bit.
The 0-bits provide holes for carries to fall into. */
if (sizeof (longword) != 4 && sizeof (longword) != 8)
abort ();
#if LONG_MAX <= LONG_MAX_32_BITS
magic_bits = 0x7efefeff;
#else
magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff;
#endif
/* Set up a longword, each of whose bytes is C. */
charmask = c | (c << 8);
charmask |= charmask << 16;
#if LONG_MAX > LONG_MAX_32_BITS
charmask |= charmask << 32;
#endif
/* Instead of the traditional loop which tests each character,
we will test a longword at a time. The tricky part is testing
if *any of the four* bytes in the longword in question are zero. */
while (n >= sizeof (longword))
{
/* We tentatively exit the loop if adding MAGIC_BITS to
LONGWORD fails to change any of the hole bits of LONGWORD.
1) Is this safe? Will it catch all the zero bytes?
Suppose there is a byte with all zeros. Any carry bits
propagating from its left will fall into the hole at its
least significant bit and stop. Since there will be no
carry from its most significant bit, the LSB of the
byte to the left will be unchanged, and the zero will be
detected.
2) Is this worthwhile? Will it ignore everything except
zero bytes? Suppose every byte of LONGWORD has a bit set
somewhere. There will be a carry into bit 8. If bit 8
is set, this will carry into bit 16. If bit 8 is clear,
one of bits 9-15 must be set, so there will be a carry
into bit 16. Similarly, there will be a carry into bit
24. If one of bits 24-30 is set, there will be a carry
into bit 31, so all of the hole bits will be changed.
The one misfire occurs when bits 24-30 are clear and bit
31 is set; in this case, the hole at bit 31 is not
changed. If we had access to the processor carry flag,
we could close this loophole by putting the fourth hole
at bit 32!
So it ignores everything except 128's, when they're aligned
properly.
3) But wait! Aren't we looking for C, not zero?
Good point. So what we do is XOR LONGWORD with a longword,
each of whose bytes is C. This turns each byte that is C
into a zero. */
longword = *--longword_ptr ^ charmask;
/* Add MAGIC_BITS to LONGWORD. */
if ((((longword + magic_bits)
/* Set those bits that were unchanged by the addition. */
^ ~longword)
/* Look at only the hole bits. If any of the hole bits
are unchanged, most likely one of the bytes was a
zero. */
& ~magic_bits) != 0)
{
/* Which of the bytes was C? If none of them were, it was
a misfire; continue the search. */
const unsigned char *cp = (const unsigned char *) longword_ptr;
#if LONG_MAX > 2147483647
if (cp[7] == c)
return (__ptr_t) &cp[7];
if (cp[6] == c)
return (__ptr_t) &cp[6];
if (cp[5] == c)
return (__ptr_t) &cp[5];
if (cp[4] == c)
return (__ptr_t) &cp[4];
#endif
if (cp[3] == c)
return (__ptr_t) &cp[3];
if (cp[2] == c)
return (__ptr_t) &cp[2];
if (cp[1] == c)
return (__ptr_t) &cp[1];
if (cp[0] == c)
return (__ptr_t) cp;
}
n -= sizeof (longword);
}
char_ptr = (const unsigned char *) longword_ptr;
while (n-- > 0)
{
if (*--char_ptr == c)
return (__ptr_t) char_ptr;
}
return 0;
}
#ifdef weak_alias
weak_alias (__memrchr, memrchr)
#endif

View File

@@ -1,5 +1,5 @@
/* obstack.c - subroutines used implicitly by object stack macros
Copyright (C) 1988-1994,96,97,98,1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1988-1994,96,97,98,99,2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
@@ -282,9 +282,10 @@ _obstack_newchunk (h, length)
register long obj_size = h->next_free - h->object_base;
register long i;
long already;
char *object_base;
/* Compute size for new chunk. */
new_size = (obj_size + length) + (obj_size >> 3) + 100;
new_size = (obj_size + length) + (obj_size >> 3) + h->alignment_mask + 100;
if (new_size < h->chunk_size)
new_size = h->chunk_size;
@@ -296,6 +297,11 @@ _obstack_newchunk (h, length)
new_chunk->prev = old_chunk;
new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
/* Compute an aligned object_base in the new chunk */
object_base =
__INT_TO_PTR ((__PTR_TO_INT (new_chunk->contents) + h->alignment_mask)
& ~ (h->alignment_mask));
/* Move the existing object to the new chunk.
Word at a time is fast and is safe if the object
is sufficiently aligned. */
@@ -303,7 +309,7 @@ _obstack_newchunk (h, length)
{
for (i = obj_size / sizeof (COPYING_UNIT) - 1;
i >= 0; i--)
((COPYING_UNIT *)new_chunk->contents)[i]
((COPYING_UNIT *)object_base)[i]
= ((COPYING_UNIT *)h->object_base)[i];
/* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
but that can cross a page boundary on a machine
@@ -314,7 +320,7 @@ _obstack_newchunk (h, length)
already = 0;
/* Copy remaining bytes one by one. */
for (i = already; i < obj_size; i++)
new_chunk->contents[i] = h->object_base[i];
object_base[i] = h->object_base[i];
/* If the object just copied was the only data in OLD_CHUNK,
free that chunk and remove it from the chain.
@@ -325,7 +331,7 @@ _obstack_newchunk (h, length)
CALL_FREEFUN (h, old_chunk);
}
h->object_base = new_chunk->contents;
h->object_base = object_base;
h->next_free = h->object_base + obj_size;
/* The new chunk certainly contains no empty object yet. */
h->maybe_empty_object = 0;
@@ -451,7 +457,7 @@ _obstack_memory_used (h)
/* Define the error handler. */
# ifndef _
# ifdef HAVE_LIBINTL_H
# if defined HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
# ifndef _
# define _(Str) gettext (Str)

View File

@@ -1,4 +1,12 @@
/* prototypes for quote.c */
char const *quote_n (int n, char const *name);
char const *quote (char const *name);
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
char const *quote_n PARAMS ((int n, char const *name));
char const *quote PARAMS ((char const *name));

View File

@@ -92,15 +92,14 @@ size_t mbrtowc ();
#define INT_BITS (sizeof (int) * CHAR_BIT)
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
/* Undefine to protect against the definition in wctype.h of solaris2.6. */
# undef ISASCII
# define ISASCII(c) 1
# define IN_CTYPE_DOMAIN(c) 1
#else
# define ISASCII(c) isascii (c)
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
/* Undefine to protect against the definition in wctype.h of solaris2.6. */
#undef ISPRINT
#define ISPRINT(c) (ISASCII (c) && isprint (c))
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
struct quoting_options
{

View File

@@ -89,6 +89,10 @@
/* This is for other GNU distributions with internationalized messages. */
#if HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
# ifdef _LIBC
# undef gettext
# define gettext(msgid) __dcgettext ("libc", msgid, LC_MESSAGES)
# endif
#else
# define gettext(msgid) (msgid)
#endif
@@ -197,35 +201,34 @@ char *realloc ();
eliminate the && through constant folding."
Solaris defines some of these symbols so we must undefine them first. */
#undef ISASCII
#if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
# define ISASCII(c) 1
# define IN_CTYPE_DOMAIN(c) 1
#else
# define ISASCII(c) isascii(c)
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
#ifdef isblank
# define ISBLANK(c) (ISASCII (c) && isblank (c))
# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#ifdef isgraph
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
#else
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
#endif
#undef ISPRINT
#define ISPRINT(c) (ISASCII (c) && isprint (c))
#define ISDIGIT(c) (ISASCII (c) && isdigit (c))
#define ISALNUM(c) (ISASCII (c) && isalnum (c))
#define ISALPHA(c) (ISASCII (c) && isalpha (c))
#define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
#define ISLOWER(c) (ISASCII (c) && islower (c))
#define ISPUNCT(c) (ISASCII (c) && ispunct (c))
#define ISSPACE(c) (ISASCII (c) && isspace (c))
#define ISUPPER(c) (ISASCII (c) && isupper (c))
#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#ifdef _tolower
# define TOLOWER(c) _tolower(c)
@@ -1234,7 +1237,7 @@ typedef struct
# if defined MATCH_MAY_ALLOCATE
/* 4400 was enough to cause a crash on Alpha OSF/1,
whose default stack limit is 2mb. */
int re_max_failures = 20000;
int re_max_failures = 4000;
# else
int re_max_failures = 2000;
# endif
@@ -2712,7 +2715,7 @@ regex_compile (pattern, size, syntax, bufp)
PATFETCH (c);
/* Now add the multibyte character(s) we found
to the acceptabed list.
to the accept list.
XXX Note that this is not entirely correct.
we would have to match multibyte sequences
@@ -2725,7 +2728,10 @@ regex_compile (pattern, size, syntax, bufp)
if (c1 == 1)
range_start = extra[idx];
while (c1-- > 0)
SET_LIST_BIT (extra[idx++]);
{
SET_LIST_BIT (extra[idx]);
++idx;
}
}
#endif
had_char_class = false;
@@ -3507,23 +3513,19 @@ compile_range (range_start_char, p_ptr, pend, translate, syntax, b)
unsigned char *b;
{
unsigned this_char;
const char *p = *p_ptr;
reg_errcode_t ret;
char range_start[2];
char range_end[2];
char ch[2];
#if _LIBC
const unsigned char *collseq;
unsigned int start_colseq;
unsigned int end_colseq;
#else
unsigned end_char;
#endif
if (p == pend)
return REG_ERANGE;
/* Fetch the endpoints without translating them; the
appropriate translation is done in the bit-setting loop below. */
range_start[0] = range_start_char;
range_start[1] = '\0';
range_end[0] = p[0];
range_end[1] = '\0';
/* Have to increment the pointer into the pattern string, so the
caller isn't still at the ending character. */
(*p_ptr)++;
@@ -3531,19 +3533,34 @@ compile_range (range_start_char, p_ptr, pend, translate, syntax, b)
/* Report an error if the range is empty and the syntax prohibits this. */
ret = syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
/* Here we see why `this_char' has to be larger than an `unsigned
char' -- we would otherwise go into an infinite loop, since all
characters <= 0xff. */
ch[1] = '\0';
#if _LIBC
collseq = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
_NL_COLLATE_COLLSEQMB);
start_colseq = collseq[(unsigned char) TRANSLATE (range_start_char)];
end_colseq = collseq[(unsigned char) TRANSLATE (p[0])];
for (this_char = 0; this_char <= (unsigned char) -1; ++this_char)
{
ch[0] = this_char;
if (strcoll (range_start, ch) <= 0 && strcoll (ch, range_end) <= 0)
unsigned int this_colseq = collseq[(unsigned char) TRANSLATE (this_char)];
if (start_colseq <= this_colseq && this_colseq <= end_colseq)
{
SET_LIST_BIT (TRANSLATE (this_char));
ret = REG_NOERROR;
}
}
#else
/* Here we see why `this_char' has to be larger than an `unsigned
char' -- we would otherwise go into an infinite loop, since all
characters <= 0xff. */
range_start_char = TRANSLATE (range_start_char);
end_char = TRANSLATE (p[0]);
for (this_char = range_start_char; this_char <= end_char; ++this_char)
{
SET_LIST_BIT (TRANSLATE (this_char));
ret = REG_NOERROR;
}
#endif
return ret;
}

View File

@@ -513,13 +513,31 @@ extern int re_exec _RE_ARGS ((const char *));
# endif
#endif
/* GCC 2.95 and later have "__restrict"; C99 compilers have
"restrict", and "configure" may have defined "restrict". */
#ifndef __restrict
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
# if defined restrict || 199901L <= __STDC_VERSION__
# define __restrict restrict
# else
# define __restrict
# endif
# endif
/* For now unconditionally define __restrict_arr to expand to nothing.
Ideally we would have a test for the compiler which allows defining
it to restrict. */
# define __restrict_arr
#endif
/* POSIX compatibility. */
extern int regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern,
extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
const char *__restrict __pattern,
int __cflags));
extern int regexec _RE_ARGS ((const regex_t *__preg,
const char *__string, size_t __nmatch,
regmatch_t __pmatch[], int __eflags));
extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
const char *__restrict __string, size_t __nmatch,
regmatch_t __pmatch[__restrict_arr],
int __eflags));
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
char *__errbuf, size_t __errbuf_size));

View File

@@ -42,6 +42,10 @@
extern int errno;
#endif
#ifndef O_DIRECTORY
# define O_DIRECTORY 0
#endif
#include "save-cwd.h"
#include "error.h"
@@ -67,7 +71,7 @@ save_cwd (struct saved_cwd *cwd)
if (have_working_fchdir)
{
#if HAVE_FCHDIR
cwd->desc = open (".", O_RDONLY);
cwd->desc = open (".", O_RDONLY | O_DIRECTORY);
if (cwd->desc < 0)
{
error (0, errno, "cannot open current directory");

376
lib/sha.c Normal file
View File

@@ -0,0 +1,376 @@
/* sha.c - Functions to compute the SHA1 hash (message-digest) of files
or blocks of memory. Complies to the NIST specification FIPS-180-1.
Copyright (C) 2000 Scott G. Miller
Credits:
Robert Klep <robert@ilse.nl> -- Expansion function fix
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#if STDC_HEADERS || defined _LIBC
# include <stdlib.h>
# include <string.h>
#else
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#include "md5.h"
#include "sha.h"
/*
Not-swap is a macro that does an endian swap on architectures that are
big-endian, as SHA needs some data in a little-endian format
*/
#ifdef WORDS_BIGENDIAN
# define NOTSWAP(n) (n)
# define SWAP(n) \
(((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
#else
# define NOTSWAP(n) \
(((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
# define SWAP(n) (n)
#endif
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
/*
Takes a pointer to a 160 bit block of data (five 32 bit ints) and
intializes it to the start constants of the SHA1 algorithm. This
must be called before using hash in the call to sha_hash
*/
void
sha_init_ctx (struct sha_ctx *ctx)
{
ctx->A = 0x67452301;
ctx->B = 0xefcdab89;
ctx->C = 0x98badcfe;
ctx->D = 0x10325476;
ctx->E = 0xc3d2e1f0;
ctx->total[0] = ctx->total[1] = 0;
ctx->buflen = 0;
}
/* Put result from CTX in first 20 bytes following RESBUF. The result
must be in little endian byte order.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *
sha_read_ctx (const struct sha_ctx *ctx, void *resbuf)
{
((md5_uint32 *) resbuf)[0] = NOTSWAP (ctx->A);
((md5_uint32 *) resbuf)[1] = NOTSWAP (ctx->B);
((md5_uint32 *) resbuf)[2] = NOTSWAP (ctx->C);
((md5_uint32 *) resbuf)[3] = NOTSWAP (ctx->D);
((md5_uint32 *) resbuf)[4] = NOTSWAP (ctx->E);
return resbuf;
}
/* Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *
sha_finish_ctx (struct sha_ctx *ctx, void *resbuf)
{
/* Take yet unprocessed bytes into account. */
md5_uint32 bytes = ctx->buflen;
size_t pad;
/* Now count remaining bytes. */
ctx->total[0] += bytes;
if (ctx->total[0] < bytes)
++ctx->total[1];
pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
memcpy (&ctx->buffer[bytes], fillbuf, pad);
/* Put the 64-bit file length in *bits* at the end of the buffer. */
*(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = NOTSWAP (ctx->total[0] << 3);
*(md5_uint32 *) &ctx->buffer[bytes + pad] = NOTSWAP ((ctx->total[1] << 3) |
(ctx->total[0] >> 29));
/* Process last bytes. */
sha_process_block (ctx->buffer, bytes + pad + 8, ctx);
return sha_read_ctx (ctx, resbuf);
}
/* Compute SHA1 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
int
sha_stream (FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
#define BLOCKSIZE 4096
struct sha_ctx ctx;
char buffer[BLOCKSIZE + 72];
size_t sum;
/* Initialize the computation context. */
sha_init_ctx (&ctx);
/* Iterate over full file contents. */
while (1)
{
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
computation function processes the whole buffer so that with the
next round of the loop another block can be read. */
size_t n;
sum = 0;
/* Read block. Take care for partial reads. */
do
{
n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
sum += n;
}
while (sum < BLOCKSIZE && n != 0);
if (n == 0 && ferror (stream))
return 1;
/* If end of file is reached, end the loop. */
if (n == 0)
break;
/* Process buffer with BLOCKSIZE bytes. Note that
BLOCKSIZE % 64 == 0
*/
sha_process_block (buffer, BLOCKSIZE, &ctx);
}
/* Add the last bytes if necessary. */
if (sum > 0)
sha_process_bytes (buffer, sum, &ctx);
/* Construct result in desired memory. */
sha_finish_ctx (&ctx, resblock);
return 0;
}
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
void *
sha_buffer (const char *buffer, size_t len, void *resblock)
{
struct sha_ctx ctx;
/* Initialize the computation context. */
sha_init_ctx (&ctx);
/* Process whole buffer but last len % 64 bytes. */
sha_process_bytes (buffer, len, &ctx);
/* Put result in desired memory area. */
return sha_finish_ctx (&ctx, resblock);
}
void
sha_process_bytes (const void *buffer, size_t len, struct sha_ctx *ctx)
{
/* When we already have some bits in our internal buffer concatenate
both inputs first. */
if (ctx->buflen != 0)
{
size_t left_over = ctx->buflen;
size_t add = 128 - left_over > len ? len : 128 - left_over;
memcpy (&ctx->buffer[left_over], buffer, add);
ctx->buflen += add;
if (left_over + add > 64)
{
sha_process_block (ctx->buffer, (left_over + add) & ~63, ctx);
/* The regions in the following copy operation cannot overlap. */
memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
(left_over + add) & 63);
ctx->buflen = (left_over + add) & 63;
}
buffer = (const char *) buffer + add;
len -= add;
}
/* Process available complete blocks. */
if (len > 64)
{
sha_process_block (buffer, len & ~63, ctx);
buffer = (const char *) buffer + (len & ~63);
len &= 63;
}
/* Move remaining bytes in internal buffer. */
if (len > 0)
{
memcpy (ctx->buffer, buffer, len);
ctx->buflen = len;
}
}
/* --- Code below is the primary difference between md5.c and sha.c --- */
/* SHA1 round constants */
#define K1 0x5a827999L
#define K2 0x6ed9eba1L
#define K3 0x8f1bbcdcL
#define K4 0xca62c1d6L
/* Round functions. Note that F2 is the same as F4. */
#define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
#define F2(B,C,D) (B ^ C ^ D)
#define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
#define F4(B,C,D) (B ^ C ^ D)
/* Process LEN bytes of BUFFER, accumulating context into CTX.
It is assumed that LEN % 64 == 0.
Most of this code comes from GnuPG's cipher/sha1.c. */
void
sha_process_block (const void *buffer, size_t len, struct sha_ctx *ctx)
{
const md5_uint32 *words = buffer;
size_t nwords = len / sizeof (md5_uint32);
const md5_uint32 *endp = words + nwords;
md5_uint32 x[16];
md5_uint32 a = ctx->A;
md5_uint32 b = ctx->B;
md5_uint32 c = ctx->C;
md5_uint32 d = ctx->D;
md5_uint32 e = ctx->E;
/* First increment the byte count. RFC 1321 specifies the possible
length of the file up to 2^64 bits. Here we only compute the
number of bytes. Do a double word increment. */
ctx->total[0] += len;
if (ctx->total[0] < len)
++ctx->total[1];
#define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
, (x[I&0x0f] = rol(tm, 1)) )
#define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \
+ F( B, C, D ) \
+ K \
+ M; \
B = rol( B, 30 ); \
} while(0)
while (words < endp)
{
md5_uint32 tm;
int t;
/* FIXME: see sha1.c for a better implementation. */
for (t = 0; t < 16; t++)
{
x[t] = NOTSWAP (*words);
words++;
}
R( a, b, c, d, e, F1, K1, x[ 0] );
R( e, a, b, c, d, F1, K1, x[ 1] );
R( d, e, a, b, c, F1, K1, x[ 2] );
R( c, d, e, a, b, F1, K1, x[ 3] );
R( b, c, d, e, a, F1, K1, x[ 4] );
R( a, b, c, d, e, F1, K1, x[ 5] );
R( e, a, b, c, d, F1, K1, x[ 6] );
R( d, e, a, b, c, F1, K1, x[ 7] );
R( c, d, e, a, b, F1, K1, x[ 8] );
R( b, c, d, e, a, F1, K1, x[ 9] );
R( a, b, c, d, e, F1, K1, x[10] );
R( e, a, b, c, d, F1, K1, x[11] );
R( d, e, a, b, c, F1, K1, x[12] );
R( c, d, e, a, b, F1, K1, x[13] );
R( b, c, d, e, a, F1, K1, x[14] );
R( a, b, c, d, e, F1, K1, x[15] );
R( e, a, b, c, d, F1, K1, M(16) );
R( d, e, a, b, c, F1, K1, M(17) );
R( c, d, e, a, b, F1, K1, M(18) );
R( b, c, d, e, a, F1, K1, M(19) );
R( a, b, c, d, e, F2, K2, M(20) );
R( e, a, b, c, d, F2, K2, M(21) );
R( d, e, a, b, c, F2, K2, M(22) );
R( c, d, e, a, b, F2, K2, M(23) );
R( b, c, d, e, a, F2, K2, M(24) );
R( a, b, c, d, e, F2, K2, M(25) );
R( e, a, b, c, d, F2, K2, M(26) );
R( d, e, a, b, c, F2, K2, M(27) );
R( c, d, e, a, b, F2, K2, M(28) );
R( b, c, d, e, a, F2, K2, M(29) );
R( a, b, c, d, e, F2, K2, M(30) );
R( e, a, b, c, d, F2, K2, M(31) );
R( d, e, a, b, c, F2, K2, M(32) );
R( c, d, e, a, b, F2, K2, M(33) );
R( b, c, d, e, a, F2, K2, M(34) );
R( a, b, c, d, e, F2, K2, M(35) );
R( e, a, b, c, d, F2, K2, M(36) );
R( d, e, a, b, c, F2, K2, M(37) );
R( c, d, e, a, b, F2, K2, M(38) );
R( b, c, d, e, a, F2, K2, M(39) );
R( a, b, c, d, e, F3, K3, M(40) );
R( e, a, b, c, d, F3, K3, M(41) );
R( d, e, a, b, c, F3, K3, M(42) );
R( c, d, e, a, b, F3, K3, M(43) );
R( b, c, d, e, a, F3, K3, M(44) );
R( a, b, c, d, e, F3, K3, M(45) );
R( e, a, b, c, d, F3, K3, M(46) );
R( d, e, a, b, c, F3, K3, M(47) );
R( c, d, e, a, b, F3, K3, M(48) );
R( b, c, d, e, a, F3, K3, M(49) );
R( a, b, c, d, e, F3, K3, M(50) );
R( e, a, b, c, d, F3, K3, M(51) );
R( d, e, a, b, c, F3, K3, M(52) );
R( c, d, e, a, b, F3, K3, M(53) );
R( b, c, d, e, a, F3, K3, M(54) );
R( a, b, c, d, e, F3, K3, M(55) );
R( e, a, b, c, d, F3, K3, M(56) );
R( d, e, a, b, c, F3, K3, M(57) );
R( c, d, e, a, b, F3, K3, M(58) );
R( b, c, d, e, a, F3, K3, M(59) );
R( a, b, c, d, e, F4, K4, M(60) );
R( e, a, b, c, d, F4, K4, M(61) );
R( d, e, a, b, c, F4, K4, M(62) );
R( c, d, e, a, b, F4, K4, M(63) );
R( b, c, d, e, a, F4, K4, M(64) );
R( a, b, c, d, e, F4, K4, M(65) );
R( e, a, b, c, d, F4, K4, M(66) );
R( d, e, a, b, c, F4, K4, M(67) );
R( c, d, e, a, b, F4, K4, M(68) );
R( b, c, d, e, a, F4, K4, M(69) );
R( a, b, c, d, e, F4, K4, M(70) );
R( e, a, b, c, d, F4, K4, M(71) );
R( d, e, a, b, c, F4, K4, M(72) );
R( c, d, e, a, b, F4, K4, M(73) );
R( b, c, d, e, a, F4, K4, M(74) );
R( a, b, c, d, e, F4, K4, M(75) );
R( e, a, b, c, d, F4, K4, M(76) );
R( d, e, a, b, c, F4, K4, M(77) );
R( c, d, e, a, b, F4, K4, M(78) );
R( b, c, d, e, a, F4, K4, M(79) );
a = ctx->A += a;
b = ctx->B += b;
c = ctx->C += c;
d = ctx->D += d;
e = ctx->E += e;
}
}

75
lib/sha.h Normal file
View File

@@ -0,0 +1,75 @@
/* sha.h - Declaration of functions and datatypes for SHA1 sum computing
library functions.
Copyright (C) 1999, Scott G. Miller
*/
#ifndef _SHA_H
# define _SHA_H 1
# include <stdio.h>
# include "md5.h"
/* Structure to save state of computation between the single steps. */
struct sha_ctx
{
md5_uint32 A;
md5_uint32 B;
md5_uint32 C;
md5_uint32 D;
md5_uint32 E;
md5_uint32 total[2];
md5_uint32 buflen;
char buffer[128];
};
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is necessary that LEN is a multiple of 64!!! */
extern void sha_process_block __P ((const void *buffer, size_t len,
struct sha_ctx *ctx));
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is NOT required that LEN is a multiple of 64. */
extern void sha_process_bytes __P((const void *buffer, size_t len,
struct sha_ctx *ctx));
/* Initialize structure containing state of computation. */
extern void sha_init_ctx __P ((struct sha_ctx *ctx));
/* Process the remaining bytes in the buffer and put result from CTX
in first 16 bytes following RESBUF. The result is always in little
endian byte order, so that a byte-wise output yields to the wanted
ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
extern void *sha_finish_ctx __P ((struct sha_ctx *ctx, void *resbuf));
/* Put result from CTX in first 16 bytes following RESBUF. The result is
always in little endian byte order, so that a byte-wise output yields
to the wanted ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
extern void *sha_read_ctx __P ((const struct sha_ctx *ctx, void *resbuf));
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
extern int sha_stream __P ((FILE *stream, void *resblock));
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
extern void *sha_buffer __P ((const char *buffer, size_t len, void *resblock));
#endif

View File

@@ -457,8 +457,7 @@ static CHAR_T const month_name[][10] =
return _strftime_copytm (s, maxsize, format, &tmcopy ut_argument);
}
# undef my_strftime
# define my_strftime(S, Maxsize, Format, Tp) \
_strftime_copytm (S, Maxsize, Format, Tp)
# define my_strftime _strftime_copytm
#endif
@@ -801,8 +800,10 @@ my_strftime (s, maxsize, format, tp ut_argument)
subformat:
{
CHAR_T *old_start = p;
size_t len = my_strftime (NULL, (size_t) -1, subfmt, tp);
add (len, my_strftime (p, maxsize - i, subfmt, tp));
size_t len = my_strftime (NULL, (size_t) -1, subfmt,
tp ut_argument);
add (len, my_strftime (p, maxsize - i, subfmt,
tp ut_argument));
if (to_uppcase)
while (old_start < p)

View File

@@ -261,7 +261,6 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
if (xstrtoul (u, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|| tmp_long > MAXUID)
return _(E_invalid_user);
printf ("MAXUID: %u\n", (uid_t) MAXUID);
*uid = tmp_long;
}
}

View File

@@ -1,3 +1,20 @@
2000-10-28 Jim Meyering <meyering@lucent.com>
* prereq.m4 (jm_PREREQ): Add jm_PREREQ_MEMCHR.
(jm_PREREQ_MEMCHR): New function.
2000-10-21 Jim Meyering <meyering@lucent.com>
* check-decl.m4 (jm_CHECK_DECLS): Also check for memrchr.
* prereq.m4 (jm_PREREQ_DIRNAME): New macro.
* jm-macros.m4 (AC_REPLACE_FUNCS): Add memrchr.
2000-09-18 Jim Meyering <meyering@lucent.com>
* getloadavg.m4 (AC_FUNC_GETLOADAVG): Restore the initial value of LIBS.
Otherwise, everyone ends up linking with -lelf for some configurations.
Reported by Mike Stone.
2000-08-26 Jim Meyering <meyering@lucent.com>
* jm-macros.m4: Use jm_FUNC_FPENDING.
@@ -32,8 +49,8 @@
2000-07-16 Bruno Haible <haible@clisp.cons.org>
* mbswidth.m4: New file.
* prereq.m4 (jm_PREREQ): Call jm_PREREQ_MBSWIDTH.
* mbswidth.m4: New file.
* prereq.m4 (jm_PREREQ): Call jm_PREREQ_MBSWIDTH.
2000-07-14 Jim Meyering <meyering@lucent.com>

View File

@@ -1,4 +1,4 @@
#serial 15
#serial 16
dnl This is just a wrapper function to encapsulate this kludge.
dnl Putting it in a separate file like this helps share it between
@@ -55,6 +55,7 @@ AC_DEFUN(jm_CHECK_DECLS,
lseek,
malloc,
memchr,
memrchr,
nanosleep,
realloc,
stpcpy,

View File

@@ -99,5 +99,7 @@ if test "x$ac_save_LIBS" = x; then
else
GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$ac_save_LIBS!!"`
fi
LIBS=$ac_save_LIBS
AC_SUBST(GETLOADAVG_LIBS)dnl
])# AC_FUNC_GETLOADAVG

View File

@@ -1,4 +1,4 @@
#serial 25
#serial 26
dnl Misc type-related macros for fileutils, sh-utils, textutils.
@@ -116,7 +116,7 @@ AC_DEFUN(jm_MACROS,
dnl used by e.g. intl/*domain.c and lib/canon-host.c
AC_REPLACE_FUNCS(strdup)
AC_REPLACE_FUNCS(memchr memmove memcpy memset)
AC_REPLACE_FUNCS(memchr memcpy memmove memrchr memset)
AC_CHECK_FUNCS(getpagesize)
# By default, argmatch should fail calling usage (1).

View File

@@ -1,4 +1,4 @@
#serial 11
#serial 13
dnl These are the prerequisite macros for files in the lib/
dnl directories of the fileutils, sh-utils, and textutils packages.
@@ -7,10 +7,12 @@ AC_DEFUN(jm_PREREQ,
[
jm_PREREQ_ADDEXT
jm_PREREQ_CANON_HOST
jm_PREREQ_DIRNAME
jm_PREREQ_ERROR
jm_PREREQ_GETPAGESIZE
jm_PREREQ_HUMAN
jm_PREREQ_MBSWIDTH
jm_PREREQ_MEMCHR
jm_PREREQ_QUOTEARG
jm_PREREQ_READUTMP
jm_PREREQ_REGEX
@@ -39,6 +41,18 @@ AC_DEFUN(jm_PREREQ_CANON_HOST,
netinet/in.h arpa/inet.h)
])
AC_DEFUN(jm_PREREQ_DIRNAME,
[
AC_HEADER_STDC
AC_CHECK_HEADERS(string.h)
])
AC_DEFUN(jm_PREREQ_GETPAGESIZE,
[
AC_CHECK_FUNCS(getpagesize)
AC_CHECK_HEADERS(OS.h unistd.h)
])
# If you use human.c, you need the following files:
# uintmax_t.m4 inttypes_h.m4 ulonglong.m4
AC_DEFUN(jm_PREREQ_HUMAN,
@@ -49,10 +63,9 @@ AC_DEFUN(jm_PREREQ_HUMAN,
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
])
AC_DEFUN(jm_PREREQ_GETPAGESIZE,
AC_DEFUN(jm_PREREQ_MEMCHR,
[
AC_CHECK_FUNCS(getpagesize)
AC_CHECK_HEADERS(OS.h unistd.h)
AC_CHECK_HEADERS(limits.h stdlib.h bp-sym.h)
])
AC_DEFUN(jm_PREREQ_QUOTEARG,

4
man/sha1sum.x Normal file
View File

@@ -0,0 +1,4 @@
[NAME]
shasum \- compute and check SHA1 message digest
[DESCRIPTION]
.\" Add any additional description here

View File

@@ -1,5 +1,243 @@
2000-10-28 Jim Meyering <meyering@lucent.com>
* Version 4.0.28.
Make `ls' a lot more efficient on systems (e.g., linux-2.4.*)
that store file type information in directory entries.
* src/ls.c [enum filetype] (unknown):
Add members (as yet unused):
(HAVE_STRUCT_DIRENT_D_TYPE): Define.
(format_needs_type): New global.
(main): Set it.
(print_dir): Set `type' from directory entry, if possible.
(gobble_file): Add a parameter, TYPE.
Stat the file only if its type is unknown and we need the type.
Patch from Ulrich Drepper.
Shred can now determine the size of a block devices (e.g. /dev/fd0)
by writing until a write operation fails.
* src/shred.c: Include assert.h.
(fillrand): Add a parameter, size_max.
Adjust caller.
Add an assertion.
(dopass): Break out of the `for (;;)' loop if size < offset.
That can happen now that dopass is called with SIZE == -1.
(do_wipefd): Accept a length of zero only for a regular file.
If lseek fails or returns 0 for a non-regular file, let dopass
determine the length.
Inspired by a patch from Alan Iwi.
* tests/Makefile.am (EXTRA_DIST): Add lang-default.
* tests/rm/hash: Factor out the expensive-test-checking code, ...
* tests/expensive: ... into this new file.
* tests/cp/perm: Disable this test by default; it's expensive.
Mark this as an expensive test.
* tests/Makefile.am (EXTRA_DIST): Add expensive.
* doc/fileutils.texi (shred invocation): Give two examples.
2000-10-26 Jim Meyering <meyering@lucent.com>
* doc/getdate.texi (Authors of getdate): Add Paul Eggert.
2000-10-23 Jim Meyering <meyering@lucent.com>
* Makefile.am (EXTRA_DIST): Add .prev-version.
2000-10-22 Jim Meyering <meyering@lucent.com>
* src/cp.c (make_path_private): Add a FIXME comment.
* tests/lang-default: New file. Set LANG, LC_ALL, and LANGUAGE to ''
(rather than to `C') and export them into the environment.
Suggestion from Bruno Haible.
* tests/cp/backup-is-src: Source lang-default rather than open-coding
the setting/exporting of LANG, LC_ALL, and LANGUAGE.
* tests/cp/cp-mv-backup: Likewise.
* tests/cp/same-file: Likewise.
* tests/cp/slink-2-slink: Likewise.
* tests/cp/symlink-slash: Likewise.
* tests/ln/sf-1: Likewise.
* tests/ls/symlink-slash: Likewise.
* tests/ls/time-1: Likewise.
* tests/mv/backup-is-src: Likewise.
* tests/mv/diag: Likewise.
* tests/mv/force: Likewise.
* tests/mv/hard-link-1: Likewise.
* tests/mv/i-2: Likewise.
* tests/mv/into-self: Likewise.
* tests/mv/into-self-2: Likewise.
* tests/mv/into-self-3: Likewise.
* tests/mv/mv-special-1: Likewise.
* tests/mv/part-symlink: Likewise.
* tests/mv/partition-perm: Likewise.
* tests/rm/r-1: Likewise.
* tests/rm/r-2: Likewise.
2000-10-21 Jim Meyering <meyering@lucent.com>
* tests/cp/cp-parents: New test.
* tests/cp/Makefile.am (TESTS): Add cp-parents;
2000-10-19 Jim Meyering <meyering@lucent.com>
* doc/texinfo.tex: Update from master repository.
* config.sub: Likewise.
* config.guess: Likewise.
* depcomp: Likewise.
2000-10-18 Jim Meyering <meyering@lucent.com>
* tests/mv/part-symlink: Make sure the programs use C-locale formats
and translations. Bruno Haible reported that this test would fail
when using other locales, because ls printed a translation of `total'.
2000-10-16 Jim Meyering <meyering@lucent.com>
* src/ls.c (print_long_format): Wrap date format strings in _(...)
so they may be internationalized. Suggestion from Christian Rose.
2000-10-13 Jim Meyering <meyering@lucent.com>
* src/mv.c (rm_option_init): Remove FIXME-maybe comment.
2000-09-30 Jim Meyering <meyering@lucent.com>
* tests/du/two-args: Update to use newer template.
* src/install.c: Remove big, option-describing comment block.
(main): Rename local `symbolic_mode' to `specified_mode'.
* src/mkdir.c (main): Don't set the umask to 0 and hand-apply
the previously-set umask unconditionally. Do that only when a
MODE has been specified. Otherwise, call mkdir with the full
creation mask (0777 or 0666) and let the kernel apply the umask.
The difference shows up only on file systems with ACL support
when the containing directory has a default ACL.
Patch by Andreas Gruenbacher.
(main): Rename local `symbolic_mode' to `specified_mode'.
* src/mknod.c (main): Likewise (but `call mknod', not mkdir).
Also, when MODE is specified, call chmod to ensure that the
permission bits are set as specified even when the containing
directory has a default ACL.
Patch by Andreas Gruenbacher.
* src/mkfifo.c (main): Likewise (but `call mkfifo', not mkdir).
Patch by Andreas Gruenbacher.
* tests/mkdir/perm: New test.
* tests/mkdir/Makefile.am (TESTS): Add perm.
2000-08-17 Andreas Gruenbacher <ag@bestbits.at>
* src/chmod.c (change_file_mode): Perform the chmod even if the
file mode permission bits are the same as those that should be set.
Omitting the chmod call would be alright with minimal 1003.1e DS17
ACLs, but eventually there may be other permissions in addition to
rwx. E.g., add and delete for directories, and something analogous
to NT's take ownership permission.
2000-09-25 Jim Meyering <meyering@lucent.com>
* tests/cp/same-file: Don't use `diff -u'. It's not portable.
Reported by Christian Krackowizer.
* tests/cp/same-file: Run `diff -c' only if cmp finds a difference.
* tests/mv/part-symlink: Likewise. And clean up.
`shred --exact file1 file2' wouldn't touch `file1'
* src/shred.c (long_opts): --exact doesn't take an argument.
Reported by Alan Iwi.
* tests/shred/exact: New test for this.
* tests/shred/Makefile.am (TESTS): Add exact.
* Makefile.maint (PREV_VERSION): Get the value from a file, rather
than trying to derive it from the current version number.
This is much more robust.
(alpha): Record just-released version number in `.prev-version',
and commit (post-tag).
* Version 4.0.27.
2000-09-24 Paul Eggert <eggert@twinsun.com>
* doc/fileutils.texi: Update to more closely match changes in 4.0z.
* src/cp.c (usage): Match revised documentation better.
2000-09-24 Jim Meyering <meyering@lucent.com>
* src/cp.c (main): Tweak a relatively new diagnostic.
2000-09-23 Jim Meyering <meyering@lucent.com>
* tests/ls/time-1: Output more information when a test fails.
2000-09-22 Jim Meyering <meyering@lucent.com>
* src/install.c (cp_option_init): Once again make it so install always
unlinks an existing destination before trying to open it for writing.
Otherwise, installing onto a running shared library would make the
running program malfunction.
Reported by Dan Pascu via Michael Stone.
* src/mv.c (do_move): Moving a directory specified with a trailing
slash from one partition to another, and giving it a different
name at the destination would cause mv to get a failed assertion.
Reported by Michael Stone.
(strip_trailing_slashes_2): Move function definition to precede
new first use.
* tests/mv/part-rename: New test for the above fix.
* tests/mv/Makefile.am (TESTS): Add part-rename.
* src/copy.c (copy_internal): Don't try to unlink directories when
using --remove-dest with -R.
* tests/cp/dir-rm-dest: New test for the above fix.
* tests/cp/Makefile.am (TESTS): Add dir-rm-dest.
2000-09-19 Jim Meyering <meyering@lucent.com>
* doc/fileutils.texi (cp invocation): Describe how --force works.
Update description of -P (soon to change meaning to conform w/POSIX).
Describe --remove-destination.
* src/cp.c (main): When used with --force, each of the --link and
--symbolic-link options now implies --remove-destination.
Reported by Miles Bader via Mike Stone.
* tests/cp/link: New file. Test for the above fix.
* tests/cp/same-file: Adjust for this change in behavior.
2000-09-15 Volker Borchert <bt@teknon.de>
* tests/Makefile.am (check-root, root-hint): New targets.
(check-recursive): Depend on root-hint.
* Makefile.am (check-root): New target.
2000-09-16 Jim Meyering <meyering@lucent.com>
* doc/perm.texi (Changing Special Permissions): Remove this statement:
``a' in the USERS part of a symbolic mode does not cause the special
permissions to be affected'... It doesn't reflect what the code does
and isn't required by POSIX. Reported by aldomel@ix.netcom.com via
Mike Stone.
2000-09-15 Jim Meyering <meyering@lucent.com>
* config.sub: Update from master repository.
2000-09-10 Jim Meyering <meyering@lucent.com>
* tests/cp/cp-mv-backup (LC_ALL): Set to `C' and export to ensure
that `ls' sorts the same way for everyone. Reported by Vin Shelton.
* Makefile.maint (b_host): Use freefriends.org, not tug.org.
2000-09-09 Jim Meyering <meyering@lucent.com>
* Makefile.maint (announcement): Use a stricter regexp for the
previous version.
* Version 4.0z.
* tests/cp/special-bits: New file.
@@ -83,6 +321,8 @@
do this. Now, you must use `cp --remove-destination' to get this
behavior. Now, `cp -f' and `mv -f' work as required by POSIX.
[unlink_dest_after_failed_open]: Add member.
Paul Eggert reported that `cp -f' removes an existing destination
file unconditionally, and that is contrary to POSIX.
* src/copy.c (same_file_ok): New function, extracted from copy_internal,
and rewritten.
@@ -979,7 +1219,7 @@
2000-02-02 Jim Meyering <meyering@lucent.com>
* tests/touch/Makefile.am (TESTS): Add fifo.
* tests/touch/fifo (fail): New file.
* tests/touch/fifo: New file.
2000-02-01 Jim Meyering <meyering@lucent.com>

View File

@@ -1,4 +1,20 @@
Changes in release 4.01:
[4.0.28]
* ls is much more efficient on systems (e.g., linux-2.4.*) that store file
type information in directory entries.
* shred now automatically determines the size of each block device argument
* ls's date/time format strings are now local dependent
* mkdir, mknod, mkfifo, and chmod work better in conjunction with ACLs
* `cp --parents dir1/ dir2' no longer gets a failed assertion
* shred now determines the size of block devices like /dev/fd0
* `shred --exact file1 file2' now erases `file1', too
[4.0.27]
* install once again unlinks an existing destination before trying to open it
* mv no longer gets a failed assertion when moving a directory (specified with
a trailing slash) from one partition to another, and giving it a different
name at the destination.
* `cp --link -f src existing-dest' no longer fails (bug introduced in 4.0z)
* cp's new --remove-destination option now works with -R
[4.0z]
* `cp -p' once again preserves `special' permission bits (this bug was
introduced in 4.0y)

View File

@@ -1,3 +1,61 @@
2000-10-27 Jim Meyering <meyering@lucent.com>
* src/date.c (usage): Mention the time zone, UTC, and write the date
in ISO format in the description of %s. Suggestion from Karl Berry.
2000-10-25 Jim Meyering <meyering@lucent.com>
* src/dirname.c: Include dirname.h.
(main): Use dir_name_r rather than open-coding it.
2000-10-23 Jim Meyering <meyering@lucent.com>
* Makefile.am (EXTRA_DIST): Add .prev-version.
2000-10-18 Paul Eggert <eggert@twinsun.com>
* src/date.c (universal_time): Remove; it's just a temptation to
do the wrong thing.
(main): The -u option now just sets TZ; it doesn't do anything else.
(show_date): Do not do anything special if -u is set.
This affects the behavior of the -I and -R options.
* doc/sh-utils.texi: Document the above.
2000-10-18 Jim Meyering <meyering@lucent.com>
* doc/sh-utils.texi (Examples of date): Fix a typo.
2000-10-11 Jim Meyering <meyering@lucent.com>
* doc/sh-utils.texi (Time directives) [%S]: Range is 0..60, not 0..61.
2000-10-06 Paul Eggert <eggert@twinsun.com>
Undo the effect of the 1997-07-12 change to date.c; it
broke "date -u MMDDhhmm" and it wasn't documented.
This reverts to the behavior of the 1996-01-03 patch.
* src/date.c (TZ_UTC0, MAYBE_SET_TZ_UTC0, set_tz): Remove.
(batch_convert): Don't futz with TZ.
(main): -u now parses all dates as UTC, not just some.
* tests/date/Test.pm (utc-0, utc-1, relative-2): Adjust to
above change.
2000-09-29 Jim Meyering <meyering@lucent.com>
* src/yes.c (usage): Add a separate usage line, just for `OPTION'.
Suggestion from M. P. Suzuki.
2000-09-09 Jim Meyering <meyering@lucent.com>
* src/date.c (usage): Make the second `Usage' line more precise
(also making it match the texinfo documentation).
From Karl Eichwalder.
* doc/sh-utils.texi (Setting the time): Correct the capitalization of
`HHMM' in the info-rendering of the texinfo documentation.
Reported by Karl Eichwalder.
2000-08-14 Jim Meyering <meyering@lucent.com>
* src/tee.c (main): Remove incorrect `FIXME' comment.
@@ -431,8 +489,8 @@
2000-01-21 Bruno Haible <haible@linuix.math.u-bordeaux.fr>
Add support for octal and hexadecimal output.
* seq.c (intconv): New variable.
Add support for octal and hexadecimal output.
* seq.c (intconv): New variable.
(usage): Update.
(main): Call scan_arg instead of scan_double_arg. Call check_format
before scan_arg.
@@ -1793,8 +1851,8 @@
1997-08-31 Jim Meyering <meyering@na-net.ornl.gov>
* src/who.c (main): New option --lookup (-l).
(print_entry): Only call canon_host if user explicitly asks for it.
(usage): Describe --lookup.
(print_entry): Only call canon_host if user explicitly asks for it.
(usage): Describe --lookup.
From Galen Hazelwood.
* configure.in (ALL_LINGUAS): Add Spanish (es).

View File

@@ -1,3 +1,62 @@
2000-10-23 Jim Meyering <meyering@lucent.com>
* Makefile.maint: Clean up version-related variables.
* Version 2.0.8.
* Makefile.am (EXTRA_DIST): Add .prev-version.
2000-10-22 Jim Meyering <meyering@lucent.com>
* tests/Makefile.am (SUBDIRS): Add sha1sum.
* tests/sha1sum/basic-1: New file.
* configure.in (AC_OUTPUT): Add tests/sha1sum/Makefile.
* src/Makefile.am (bin_PROGRAMS): Add sha1sum.
(md5sum_SOURCES): Define.
(sha1sum_SOURCES): Define.
(noinst_HEADERS): Add checksum.h.
* src/md5sum.c: Factor out the differences between MD5 and SHA1,
and parameterize so this code may be used by both md5sum and the new
program, sha1sum. Loosely based on a patch from Scott Miller.
* src/checksum.h: New file.
* src/md5.c: New file that simply defines `algorithm'.
* src/sha1sum.c: Likewise.
* man/Makefile.am (man_MANS): Add sha1sum.1.
* man/sha1sum.x: New file.
Support 8-byte integers, assuming they're printable with e.g., %lld.
* src/od.c: Add support for printing data as unsigned
long long integers.
2000-10-21 Jim Meyering <meyering@lucent.com>
The command, `yes ''|./cat -n' would stop printing after INT_MAX lines.
* src/cat.c (cat): Never let `newlines' exceed 3.
2000-10-21 Jim Meyering <meyering@lucent.com>
Prevent a counter buffer overrun when numbering lines and when
processing 100 billion lines (or more) of input.
* src/cat.c (LINE_COUNTER_BUF_LEN): Define to allow numbering as
many as 10^18 - 1 lines (the old limit was 10^11 - 1, and could
be exceeded without too much trouble). Use this symbol rather
than hard-coding the constant everywhere.
(next_line_num): Rather than overrunning for input with more lines,
mark the line number by putting a `>' in the leftmost slot.
Patch by Jan Nieuwenhuizen.
* src/sort.c (SORT_OUT_OF_ORDER): Define.
(main): Use it instead of hard-coding the `1'.
2000-10-10 Jim Meyering <meyering@lucent.com>
* src/sort.c (main): Use EXIT_SUCCESS rather than 0.
Fail when checking (-c) with more than one file argument,
rather than simply ignoring the extra arguments.
2000-09-07 Jim Meyering <meyering@lucent.com>
* src/cut.c: Remove obsolete comment block.
@@ -84,7 +143,7 @@
2000-08-06 Paul Eggert <eggert@twinsun.com>
* src/sort.c (usage): Warn more succintly about the effects of
* src/sort.c (usage): Warn more succinctly about the effects of
the locale on sort order.
2000-08-06 Jim Meyering <meyering@lucent.com>
@@ -2160,8 +2219,8 @@
1998-02-16 Jim Meyering <meyering@eng.ascend.com>
* configure.in (jm_FUNC_LSTAT): Use it.
(jm_FUNC_STAT): Use it.
* configure.in (jm_FUNC_LSTAT): Use it.
(jm_FUNC_STAT): Use it.
* lib/Makefile.am (EXTRA_DIST): Add lstat.c and stat.c.
1998-02-06 Jim Meyering <meyering@eng.ascend.com>
@@ -2190,8 +2249,8 @@
1998-01-30 Paul Eggert <eggert@twinsun.com>
* configure.in (AC_LFS): Put before anything that can affect or use
CPPFLAGS, LDFLAGS, or LIBS.
* configure.in (AC_LFS): Put before anything that can affect or use
CPPFLAGS, LDFLAGS, or LIBS.
1998-01-25 Jim Meyering <meyering@na-net.ornl.gov>

View File

@@ -1,5 +1,10 @@
Changes in release 2.1
[2.0h]
[2.0.8]
* od now supports 8-byte integers, assuming they're printable with e.g., %lld
* new program: sha1sum
* wc accepts new -m option: count (potentially multi-byte) characters
* wc's `--chars' option is now equivalent to -m, not --bytes as it used to be
* `cat -n' works properly when processing 2^31 or more lines
[2.0g]
* sort's --help output now warns that it is locale-aware
* tail: fix a buffer underrun error that occurred on an empty pipe,

View File

@@ -55,19 +55,26 @@ static char *infile;
/* Descriptor on which input file is open. */
static int input_desc;
/* Buffer for line numbers. */
static char line_buf[13] =
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', '\t', '\0'};
/* Buffer for line numbers.
An 11 digit counter may overflow within an hour on a P2/466,
an 18 digit counter needs about 1000y */
#define LINE_COUNTER_BUF_LEN 20
static char line_buf[LINE_COUNTER_BUF_LEN] =
{
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0',
'\t', '\0'
};
/* Position in `line_buf' where printing starts. This will not change
unless the number of lines is larger than 999999. */
static char *line_num_print = line_buf + 5;
static char *line_num_print = line_buf + LINE_COUNTER_BUF_LEN - 8;
/* Position of the first digit in `line_buf'. */
static char *line_num_start = line_buf + 10;
static char *line_num_start = line_buf + LINE_COUNTER_BUF_LEN - 3;
/* Position of the last digit in `line_buf'. */
static char *line_num_end = line_buf + 10;
static char *line_num_end = line_buf + LINE_COUNTER_BUF_LEN - 3;
/* Preserves the `cat' function's local `newlines' between invocations. */
static int newlines2 = 0;
@@ -129,7 +136,10 @@ next_line_num (void)
*endp-- = '0';
}
while (endp >= line_num_start);
*--line_num_start = '1';
if (line_num_start > line_buf)
*--line_num_start = '1';
else
*line_buf = '>';
if (line_num_start < line_num_print)
line_num_print--;
}
@@ -340,13 +350,21 @@ cat (
if (++newlines > 0)
{
/* Are multiple adjacent empty lines to be substituted by
single ditto (-s), and this was the second empty line? */
if (squeeze_empty_lines && newlines >= 2)
if (newlines >= 2)
{
ch = *bpin++;
continue;
/* Limit this to 2 here. Otherwise, with lots of
consecutive newlines, the counter could wrap
around at INT_MAX. */
newlines = 2;
/* Are multiple adjacent empty lines to be substituted
by single ditto (-s), and this was the second empty
line? */
if (squeeze_empty_lines)
{
ch = *bpin++;
continue;
}
}
/* Are line numbers to be written at empty lines (-n)? */
@@ -775,8 +793,8 @@ main (int argc, char **argv)
{
inbuf = (unsigned char *) xmalloc (insize + 1);
/* Why are (OUTSIZE - 1 + INSIZE * 4 + 13) bytes allocated for
the output buffer?
/* Why are (OUTSIZE - 1 + INSIZE * 4 + LINE_COUNTER_BUF_LEN)
bytes allocated for the output buffer?
A test whether output needs to be written is done when the input
buffer empties or when a newline appears in the input. After
@@ -788,10 +806,12 @@ main (int argc, char **argv)
If the last character in the preceding block of input was a
newline, a line number may be written (according to the given
options) as the first thing in the output buffer. (Done after the
new input is read, but before processing of the input begins.) A
line number requires seldom more than 13 positions. */
new input is read, but before processing of the input begins.)
A line number requires seldom more than LINE_COUNTER_BUF_LEN
positions. */
outbuf = (unsigned char *) xmalloc (outsize - 1 + insize * 4 + 13);
outbuf = (unsigned char *) xmalloc (outsize - 1 + insize * 4
+ LINE_COUNTER_BUF_LEN);
cat (inbuf, insize, outbuf, outsize, quote,
output_tabs, numbers, numbers_at_empty_lines, mark_line_ends,

16
src/checksum.h Normal file
View File

@@ -0,0 +1,16 @@
#include <config.h>
#include <sys/types.h>
#include <stdio.h>
#include "system.h"
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
ALG_UNSPECIFIED = 0,
ALG_MD5 = CHAR_MAX + 1,
ALG_SHA1
};
extern int algorithm;

View File

@@ -137,6 +137,8 @@ change_file_mode (const char *file, const struct mode_change *changes,
struct stat file_stats;
mode_t newmode;
int errors = 0;
int fail;
int saved_errno;
if (lstat (file, &file_stats))
{
@@ -161,24 +163,19 @@ change_file_mode (const char *file, const struct mode_change *changes,
newmode = mode_adjust (file_stats.st_mode, changes);
if (newmode != (file_stats.st_mode & CHMOD_MODE_BITS))
fail = chmod (file, newmode);
saved_errno = errno;
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
if (fail)
{
int fail = chmod (file, newmode);
int saved_errno = errno;
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
if (fail)
{
if (force_silent == 0)
error (0, saved_errno, _("changing permissions of %s"),
quote (file));
errors = 1;
}
if (force_silent == 0)
error (0, saved_errno, _("changing permissions of %s"),
quote (file));
errors = 1;
}
else if (verbosity == V_high)
describe_change (file, newmode, CH_NO_CHANGE_REQUESTED);
if (recurse && S_ISDIR (file_stats.st_mode))
errors |= change_dir_mode (file, changes, &file_stats);

View File

@@ -723,10 +723,10 @@ copy_internal (const char *src_path, const char *dst_path,
}
new_dst = 1;
}
else if (x->unlink_dest_before_opening
|| (x->xstat == lstat
&& ! S_ISREG (src_sb.st_mode)
&& ! S_ISDIR (src_sb.st_mode)))
else if (! S_ISDIR (dst_sb.st_mode)
&& (x->unlink_dest_before_opening
|| (x->xstat == lstat
&& ! S_ISREG (src_sb.st_mode))))
{
if (unlink (dst_path) && errno != ENOENT)
{

View File

@@ -156,14 +156,11 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
-a, --archive same as -dpR\n\
--backup[=CONTROL] make a backup of each existing destination file\n\
-b like --backup but does not accept an argument\n\
-d, --no-dereference preserve links\n\
-f, --force if a preexisting destination file cannot be\n\
opened, then unlink it and try again\n\
-d, --no-dereference never follow symbolic links\n\
-f, --force if an existing destination file cannot be\n\
opened, remove it and try again\n\
-i, --interactive prompt before overwrite\n\
-H follow symbolic links that are explicitly\n\
specified in the command line, but do not\n\
follow symlinks that are found via recursive\n\
traversal\n\
-H follow command-line symbolic links\n\
-l, --link link files instead of copying\n\
-L, --dereference always follow symbolic links\n\
-p, --preserve preserve file attributes if possible\n\
@@ -173,7 +170,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
-r copy recursively, non-directories as files\n\
WARNING: use -R instead when you might copy\n\
special files like FIFOs or /dev/zero\n\
--remove-destination unlink each preexisting destination file before\n\
--remove-destination remove each existing destination file before\n\
attempting to open it (contrast with --force)\n\
--sparse=WHEN control creation of sparse files\n\
-R, --recursive copy directories recursively\n\
@@ -333,6 +330,8 @@ re_protect (const char *const_dst_path, int src_offset,
Return 0 if parent of CONST_DIRPATH exists as a directory with the proper
permissions when done, otherwise 1. */
/* FIXME: find a way to synch this function with the one in lib/makepath.c. */
static int
make_path_private (const char *const_dirpath, int src_offset, int mode,
const char *verbose_fmt_string, struct dir_attr **attr_list,
@@ -846,7 +845,7 @@ main (int argc, char **argv)
error (0, 0,
_("\
Warning: the meaning of `-P' will change in the future to conform to POSIX.\n\
Use `--parents' for the old meaning, and `--no-dereference' for the new."));
Use `--parents' for the old meaning, and `--no-dereference' for the new one."));
}
if (backup_suffix_string)
@@ -882,6 +881,11 @@ Use `--parents' for the old meaning, and `--no-dereference' for the new."));
x.xstat = stat;
}
/* If --force (-f) was specified and we're in link-creation mode,
first remove any existing destination file. */
if (x.unlink_dest_after_failed_open && (x.hard_link || x.symbolic_link))
x.unlink_dest_before_opening = 1;
/* Allocate space for remembering copied and created files. */
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);

View File

@@ -79,9 +79,6 @@ static int iso_8601_format = 0;
/* If non-zero, display time in RFC-822 format for mail or news. */
static int rfc_format = 0;
/* If nonzero, print or set Coordinated Universal Time. */
static int universal_time = 0;
static struct option const long_options[] =
{
{"date", required_argument, NULL, 'd'},
@@ -98,17 +95,12 @@ static struct option const long_options[] =
{NULL, 0, NULL, 0}
};
#define TZ_UTC0 "TZ=UTC0"
#if LOCALTIME_CACHE
# define TZSET tzset ()
#else
# define TZSET /* empty */
#endif
#define MAYBE_SET_TZ_UTC0 \
do { if (universal_time) set_tz (TZ_UTC0); } while (0)
#ifdef _DATE_FMT
# define DATE_FMT_LANGINFO() nl_langinfo (_DATE_FMT)
#else
@@ -125,7 +117,7 @@ usage (int status)
{
printf (_("\
Usage: %s [OPTION]... [+FORMAT]\n\
or: %s [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n\
or: %s [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]\n\
"),
program_name, program_name);
printf (_("\
@@ -169,7 +161,7 @@ specifies Coordinated Universal Time. Interpreted sequences are:\n\
%%n a newline\n\
%%p locale's AM or PM\n\
%%r time, 12-hour (hh:mm:ss [AP]M)\n\
%%s seconds since 00:00:00, Jan 1, 1970 (a GNU extension)\n\
%%s seconds since `00:00:00 1970-01-01 UTC' (a GNU extension)\n\
%%S second (00..60)\n\
%%t a horizontal tab\n\
%%T time, 24-hour (hh:mm:ss)\n\
@@ -195,16 +187,6 @@ the following modifiers between `%%' and a numeric directive.\n\
exit (status);
}
/* Set the TZ environment variable. */
static void
set_tz (const char *tz_eq_zone)
{
if (putenv (tz_eq_zone) != 0)
error (1, 0, "memory exhausted");
TZSET;
}
/* Parse each line in INPUT_FILENAME as with --date and display each
resulting time and date. If the file cannot be opened, tell why
then exit. Issue a diagnostic for any lines that cannot be parsed.
@@ -219,7 +201,6 @@ batch_convert (const char *input_filename, const char *format)
int line_length;
size_t buflen;
time_t when;
char *initial_TZ IF_LINT (= NULL);
if (strcmp (input_filename, "-") == 0)
{
@@ -237,23 +218,6 @@ batch_convert (const char *input_filename, const char *format)
line = NULL;
buflen = 0;
if (universal_time)
{
initial_TZ = getenv ("TZ");
if (initial_TZ == NULL)
{
initial_TZ = xstrdup ("TZ=");
}
else
{
size_t tz_len = strlen (initial_TZ);
char *buf = xmalloc (3 + tz_len + 1);
memcpy (mempcpy (buf, "TZ=", 3), initial_TZ, tz_len + 1);
initial_TZ = buf;
}
}
status = 0;
while (1)
{
@@ -264,13 +228,6 @@ batch_convert (const char *input_filename, const char *format)
break;
}
if (universal_time)
{
/* When given a universal time option, restore the initial
value of TZ before parsing each string. */
set_tz (initial_TZ);
}
when = get_date (line, NULL);
if (when == -1)
@@ -282,14 +239,10 @@ batch_convert (const char *input_filename, const char *format)
}
else
{
MAYBE_SET_TZ_UTC0;
show_date (format, when);
}
}
if (universal_time)
free (initial_TZ);
if (fclose (in_stream) == EOF)
error (2, errno, "`%s'", input_filename);
@@ -352,7 +305,12 @@ main (int argc, char **argv)
set_date = 1;
break;
case 'u':
universal_time = 1;
/* POSIX.2 says that `date -u' is equivalent to setting the TZ
environment variable, so this option should do nothing other
than setting TZ. */
if (putenv ("TZ=UTC0") != 0)
xalloc_die ();
TZSET;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
@@ -460,10 +418,6 @@ argument must be a format string beginning with `+'."),
}
}
/* When given a universal time option, set TZ to UTC0 after
parsing the specified date, but before printing it. */
MAYBE_SET_TZ_UTC0;
show_date (format, when);
}
@@ -480,14 +434,13 @@ show_date (const char *format, time_t when)
struct tm *tm;
char *out = NULL;
size_t out_length = 0;
/* ISO 8601 formats, in local and UTC. See below regarding %z */
static char *iso_format_string[5][2] =
/* ISO 8601 formats. See below regarding %z */
static char const * const iso_format_string[] =
{
{"", ""},
{"%Y-%m-%d", "%Y-%m-%d"},
{"%Y-%m-%dT%H%z", "%Y-%m-%dT%HZ"},
{"%Y-%m-%dT%H:%M%z", "%Y-%m-%dT%H:%MZ"},
{"%Y-%m-%dT%H:%M:%S%z", "%Y-%m-%dT%H:%M:%SZ"}
"%Y-%m-%d",
"%Y-%m-%dT%H%z",
"%Y-%m-%dT%H:%M%z",
"%Y-%m-%dT%H:%M:%S%z"
};
tm = localtime (&when);
@@ -502,11 +455,9 @@ show_date (const char *format, time_t when)
RFC time format outside the continental United States and GMT. */
if (rfc_format)
format = (universal_time
? "%a, %_d %b %Y %H:%M:%S GMT"
: "%a, %_d %b %Y %H:%M:%S %z");
format = "%a, %_d %b %Y %H:%M:%S %z";
else if (iso_8601_format)
format = iso_format_string[iso_8601_format][universal_time];
format = iso_format_string[iso_8601_format - 1];
else
{
char *date_fmt = DATE_FMT_LANGINFO ();

View File

@@ -734,7 +734,7 @@ buggy_lseek_support (int fdesc)
on some special files but doesn't return an error, either.
In particular, the Linux tape drivers are a problem.
For example, when I did the following using dd-4.0y or earlier on a
Linux-2.2.17 system with a Exabyte SCSI tape drive:
Linux-2.2.17 system with an Exabyte SCSI tape drive:
dev=/dev/nst0
reset='mt -f $dev rewind; mt -f $dev fsf 1'

View File

@@ -24,6 +24,7 @@
#include "system.h"
#include "long-options.h"
#include "error.h"
#include "dirname.h"
#include "closeout.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -64,8 +65,8 @@ output `.' (meaning the current directory).\n\
int
main (int argc, char **argv)
{
register char *path;
register char *slash;
const char *result;
size_t len;
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -91,20 +92,9 @@ main (int argc, char **argv)
usage (1);
}
path = argv[1];
strip_trailing_slashes (path);
slash = strrchr (path, '/');
if (slash == NULL)
path = (char *) ".";
else
{
/* Remove any trailing slashes and final element. */
while (slash > path && *slash == '/')
--slash;
slash[1] = 0;
}
puts (path);
len = dir_name_r (argv[1], &result);
fwrite (result, 1, len, stdout);
putchar ('\n');
exit (0);
}

View File

@@ -15,50 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Copy files and set their permission modes and, if possible,
their owner and group. Used similarly to `cp'; typically
used in Makefiles to copy programs into their destination
directories. It can also be used to create the destination
directories and any leading directories, and to set the final
directory's modes. It refuses to copy files onto themselves.
Options:
-g, --group=GROUP
Set the group ownership of the installed file or directory
to the group ID of GROUP (default is process's current
group). GROUP may also be a numeric group ID.
-m, --mode=MODE
Set the permission mode for the installed file or directory
to MODE, which is an octal number (default is u=rwx,g=rx,o=rx).
-o, --owner=OWNER
If run as root, set the ownership of the installed file to
the user ID of OWNER (default is root). OWNER may also be
a numeric user ID.
-c No effect. For compatibility with old Unix versions of install.
-s, --strip
Strip the symbol tables from installed files.
-p, --preserve-timestamps
Retain creation and modification timestamps when installing files.
-d, --directory
Create a directory and its leading directories, if they
do not already exist. Set the owner, group and mode
as given on the command line. Any leading directories
that are created are also given those attributes.
This is different from the SunOS 4.0 install, which gives
directories that it creates the default attributes.
-D
Like the -d option, but a file is installed, along with the directory.
Useful when installing into a new directory, and the install
process doesn't properly comprehend making directories.
David MacKenzie <djm@gnu.ai.mit.edu> */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu> */
#ifdef _AIX
#pragma alloca
@@ -189,8 +146,8 @@ cp_option_init (struct cp_options *x)
{
x->copy_as_regular = 1;
x->dereference = DEREF_ALWAYS;
x->unlink_dest_before_opening = 0;
x->unlink_dest_after_failed_open = 1;
x->unlink_dest_before_opening = 1;
x->unlink_dest_after_failed_open = 0;
/* If unlink fails, try to proceed anyway. */
x->failed_unlink_is_fatal = 0;
@@ -226,7 +183,7 @@ main (int argc, char **argv)
{
int optc;
int errors = 0;
const char *symbolic_mode = NULL;
const char *specified_mode = NULL;
int make_backups = 0;
char *backup_suffix_string;
char *version_control_string = NULL;
@@ -292,7 +249,7 @@ main (int argc, char **argv)
group_name = optarg;
break;
case 'm':
symbolic_mode = optarg;
specified_mode = optarg;
break;
case 'o':
owner_name = optarg;
@@ -328,11 +285,11 @@ main (int argc, char **argv)
usage (1);
}
if (symbolic_mode)
if (specified_mode)
{
struct mode_change *change = mode_compile (symbolic_mode, 0);
struct mode_change *change = mode_compile (specified_mode, 0);
if (change == MODE_INVALID)
error (1, 0, _("invalid mode %s"), quote (symbolic_mode));
error (1, 0, _("invalid mode %s"), quote (specified_mode));
else if (change == MODE_MEMORY_EXHAUSTED)
xalloc_die ();
mode = mode_adjust (0, change);

View File

@@ -197,12 +197,30 @@ int rpl_lstat PARAMS((const char *, struct stat *));
# define lstat(Name, Stat_buf) rpl_lstat(Name, Stat_buf)
#endif
#if defined _DIRENT_HAVE_D_TYPE || defined DTTOIF
# define HAVE_STRUCT_DIRENT_D_TYPE 1
#else
# define HAVE_STRUCT_DIRENT_D_TYPE 0
#endif
enum filetype
{
#if HAVE_STRUCT_DIRENT_D_TYPE
unknown = DT_UNKNOWN,
fifo = DT_FIFO,
chardev = DT_CHR,
directory = DT_DIR,
blockdev = DT_BLK,
normal = DT_REG,
symbolic_link = DT_LNK,
sock = DT_SOCK,
arg_directory = 100
#else
symbolic_link,
directory,
arg_directory, /* Directory given as command line arg. */
normal /* All others. */
#endif
};
struct fileinfo
@@ -290,8 +308,8 @@ static int rev_cmp_version PARAMS ((const struct fileinfo *file2,
const struct fileinfo *file1));
static int decode_switches PARAMS ((int argc, char **argv));
static int file_interesting PARAMS ((const struct dirent *next));
static uintmax_t gobble_file PARAMS ((const char *name, int explicit_arg,
const char *dirname));
static uintmax_t gobble_file PARAMS ((const char *name, enum filetype type,
int explicit_arg, const char *dirname));
static void print_color_indicator PARAMS ((const char *name, unsigned int mode,
int linkok));
static void put_indicator PARAMS ((const struct bin_str *ind));
@@ -629,6 +647,11 @@ static int line_length;
static int format_needs_stat;
/* Similar to `format_needs_stat', but set if only the file type is
needed. */
static int format_needs_type;
/* The exit status to use if we don't get any fatal errors. */
static int exit_status;
@@ -845,8 +868,9 @@ main (int argc, char **argv)
format_needs_stat = sort_type == sort_time || sort_type == sort_size
|| format == long_format
|| trace_links || trace_dirs || indicator_style != none
|| print_block_size || print_inode || print_with_color;
|| trace_links || trace_dirs || print_block_size || print_inode;
format_needs_type = (format_needs_stat == 0
&& (print_with_color || indicator_style != none));
if (dired && format == long_format)
{
@@ -864,13 +888,13 @@ main (int argc, char **argv)
dir_defaulted = 0;
for (; i < argc; i++)
{
gobble_file (argv[i], 1, "");
gobble_file (argv[i], unknown, 1, "");
}
if (dir_defaulted)
{
if (immediate_dirs)
gobble_file (".", 1, "");
gobble_file (".", unknown, 1, "");
else
queue_directory (".", 0);
}
@@ -1701,7 +1725,17 @@ print_dir (const char *name, const char *realname)
while ((next = readdir (reading)) != NULL)
if (file_interesting (next))
total_blocks += gobble_file (next->d_name, 0, name);
{
enum filetype type = unknown;
#if HAVE_STRUCT_DIRENT_D_TYPE
if (next->d_type == DT_DIR || next->d_type == DT_CHR
|| next->d_type == DT_BLK || next->d_type == DT_SOCK
|| next->d_type == DT_FIFO)
type = next->d_type;
#endif
total_blocks += gobble_file (next->d_name, type, 0, name);
}
if (CLOSEDIR (reading))
{
@@ -1812,7 +1846,8 @@ clear_files (void)
Return the number of blocks that the file occupies. */
static uintmax_t
gobble_file (const char *name, int explicit_arg, const char *dirname)
gobble_file (const char *name, enum filetype type, int explicit_arg,
const char *dirname)
{
register uintmax_t blocks;
register int val;
@@ -1829,7 +1864,8 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
files[files_index].linkmode = 0;
files[files_index].linkok = 0;
if (explicit_arg || format_needs_stat)
if (explicit_arg || format_needs_stat
|| (format_needs_type && type == unknown))
{
/* `path' is the absolute pathname of this file. */
@@ -1937,7 +1973,13 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
}
}
else
blocks = 0;
{
files[files_index].filetype = type;
#if HAVE_STRUCT_DIRENT_D_TYPE
files[files_index].stat.st_mode = DTTOIF (type);
#endif
blocks = 0;
}
files[files_index].name = xstrdup (name);
files_index++;
@@ -2345,11 +2387,11 @@ print_long_format (const struct fileinfo *f)
Allow a 1 hour slop factor for what is considered "the future",
to allow for NFS server/client clock disagreement.
Show the year instead of the time of day. */
fmt = "%b %e %Y";
fmt = _("%b %e %Y");
}
else
{
fmt = "%b %e %H:%M";
fmt = _("%b %e %H:%M");
}
}

2
src/md5.c Normal file
View File

@@ -0,0 +1,2 @@
#include "checksum.h"
int algorithm = ALG_MD5;

View File

@@ -1,5 +1,4 @@
/* Compute MD5 checksum of files or strings according to the definition
of MD5 in RFC 1321 from April 1992.
/* Compute MD5 or SHA1 checksum of files or strings
Copyright (C) 1995-2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -24,16 +23,19 @@
#include <stdio.h>
#include <sys/types.h>
#include "md5.h"
#include "getline.h"
#include "system.h"
#include "md5.h"
#include "sha.h"
#include "checksum.h"
#include "getline.h"
#include "closeout.h"
#include "error.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "md5sum"
#define PROGRAM_NAME (algorithm == ALG_MD5 ? "md5sum" : "shasum")
#define AUTHORS "Ulrich Drepper"
#define AUTHORS "Ulrich Drepper and Scott Miller"
/* Most systems do not distinguish between external and internal
text representations. */
@@ -58,24 +60,44 @@
# endif
#endif
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum --check'. This length does
#define DIGEST_TYPE_STRING(Alg) ((Alg) == ALG_MD5 ? "MD5" : "SHA1")
#define DIGEST_STREAM(Alg) ((Alg) == ALG_MD5 ? md5_stream : sha_stream)
#define DIGEST_BITS(Alg) ((Alg) == ALG_MD5 ? 128 : 160)
#define DIGEST_HEX_BYTES(Alg) (DIGEST_BITS (Alg) / 4)
#define DIGEST_BIN_BYTES(Alg) (DIGEST_BITS (Alg) / 8)
#define MAX_DIGEST_BIN_BYTES MAX (DIGEST_BIN_BYTES (ALG_MD5), \
DIGEST_BIN_BYTES (ALG_SHA1))
/* The minimum length of a valid digest line. This length does
not include any newline character at the end of a line. */
#define MIN_DIGEST_LINE_LENGTH (32 /* message digest length */ \
+ 2 /* blank and binary indicator */ \
+ 1 /* minimum filename length */ )
#define MIN_DIGEST_LINE_LENGTH(Alg) \
(DIGEST_HEX_BYTES (Alg) /* length of hexadecimal message digest */ \
+ 2 /* blank and binary indicator */ \
+ 1 /* minimum filename length */ )
/* Nonzero if any of the files read were the standard input. */
static int have_read_stdin;
/* The minimum length of a valid checksum line for the selected algorithm. */
static int min_digest_line_length;
/* Set to the length of a digest hex string for the selected algorithm. */
static size_t digest_hex_bytes;
/* With --check, don't generate any output.
The exit code indicates success or failure. */
static int status_only = 0;
/* With --check, print a message to standard error warning about each
improperly formatted MD5 checksum line. */
improperly formatted checksum line. */
static int warn = 0;
/* Declared and set via one of the wrapper .c files. */
/* int algorithm = ALG_UNSPECIFIED; */
/* The name this program was run with. */
char *program_name;
@@ -103,25 +125,30 @@ usage (int status)
printf (_("\
Usage: %s [OPTION] [FILE]...\n\
or: %s [OPTION] --check [FILE]\n\
Print or check MD5 checksums.\n\
Print or check %s (%d-bit) checksums.\n\
With no FILE, or when FILE is -, read standard input.\n\
\n\
-b, --binary read files in binary mode (default on DOS/Windows)\n\
-c, --check check MD5 sums against given list\n\
-c, --check check %s sums against given list\n\
-t, --text read files in text mode (default)\n\
\n\
The following two options are useful only when verifying checksums:\n\
--status don't output anything, status code shows success\n\
-w, --warn warn about improperly formated MD5 checksum lines\n\
-w, --warn warn about improperly formated checksum lines\n\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
The sums are computed as described in RFC 1321. When checking, the input\n\
The sums are computed as described in %s. When checking, the input\n\
should be a former output of this program. The default mode is to print\n\
a line with checksum, a character indicating type (`*' for binary, ` ' for\n\
text), and name for each FILE.\n"),
program_name, program_name);
program_name, program_name,
DIGEST_TYPE_STRING (algorithm),
DIGEST_BITS (algorithm),
DIGEST_TYPE_STRING (algorithm),
(algorithm == ALG_MD5 ? "RFC 1321" : "FIPS-180-1")
);
puts (_("\nReport bugs to <bug-textutils@gnu.org>."));
}
@@ -140,11 +167,11 @@ split_3 (char *s, size_t s_len, unsigned char **u, int *binary, char **w)
while (ISWHITE (s[i]))
++i;
/* The line must have at least 35 (36 if the first is a backslash)
more characters to contain correct message digest information.
Ignore this line if it is too short. */
if (!(s_len - i >= MIN_DIGEST_LINE_LENGTH
|| (s[i] == '\\' && s_len - i >= 1 + MIN_DIGEST_LINE_LENGTH)))
/* The line must have at least `min_digest_line_length - 1' (or one more, if
the first is a backslash) more characters to contain correct message digest
information. Ignore this line if it is too short. */
if (!(s_len - i >= min_digest_line_length
|| (s[i] == '\\' && s_len - i >= 1 + min_digest_line_length)))
return 1;
if (s[i] == '\\')
@@ -154,10 +181,10 @@ split_3 (char *s, size_t s_len, unsigned char **u, int *binary, char **w)
}
*u = (unsigned char *) &s[i];
/* The first field has to be the 32-character hexadecimal
/* The first field has to be the n-character hexadecimal
representation of the message digest. If it is not followed
immediately by a white space it's an error. */
i += 32;
i += digest_hex_bytes;
if (!ISWHITE (s[i]))
return 1;
@@ -230,12 +257,13 @@ hex_digits (unsigned char const *s)
return 1;
}
/* An interface to md5_stream. Operate on FILENAME (it may be "-") and
put the result in *MD5_RESULT. Return non-zero upon failure, zero
to indicate success. */
/* An interface to the function, DIGEST_STREAM, (either md5_stream or sha_stream).
Operate on FILENAME (it may be "-") and put the result in *BIN_RESULT.
Return non-zero upon failure, zero to indicate success. */
static int
md5_file (const char *filename, int binary, unsigned char *md5_result)
digest_file (const char *filename, int binary, unsigned char *bin_result,
int (*digest_stream)(FILE *, void *))
{
FILE *fp;
int err;
@@ -265,7 +293,7 @@ md5_file (const char *filename, int binary, unsigned char *md5_result)
}
}
err = md5_stream (fp, md5_result);
err = (*digest_stream) (fp, bin_result);
if (err)
{
error (0, errno, "%s", filename);
@@ -284,13 +312,13 @@ md5_file (const char *filename, int binary, unsigned char *md5_result)
}
static int
md5_check (const char *checkfile_name)
digest_check (const char *checkfile_name, int (*digest_stream)(FILE *, void *))
{
FILE *checkfile_stream;
int n_properly_formated_lines = 0;
int n_mismatched_checksums = 0;
int n_open_or_read_failures = 0;
unsigned char md5buffer[16];
unsigned char bin_buffer[MAX_DIGEST_BIN_BYTES];
size_t line_number;
char *line;
size_t line_chars_allocated;
@@ -318,7 +346,7 @@ md5_check (const char *checkfile_name)
{
char *filename;
int binary;
unsigned char *md5num;
unsigned char *hex_digest;
int err;
int line_length;
@@ -336,14 +364,15 @@ md5_check (const char *checkfile_name)
if (line[line_length - 1] == '\n')
line[--line_length] = '\0';
err = split_3 (line, line_length, &md5num, &binary, &filename);
if (err || !hex_digits (md5num))
err = split_3 (line, line_length, &hex_digest, &binary, &filename);
if (err || !hex_digits (hex_digest))
{
if (warn)
{
error (0, 0,
_("%s: %lu: improperly formatted MD5 checksum line"),
checkfile_name, (unsigned long) line_number);
_("%s: %lu: improperly formatted %s checksum line"),
checkfile_name, (unsigned long) line_number,
DIGEST_TYPE_STRING (algorithm));
}
}
else
@@ -356,7 +385,7 @@ md5_check (const char *checkfile_name)
++n_properly_formated_lines;
fail = md5_file (filename, binary, md5buffer);
fail = digest_file (filename, binary, bin_buffer, digest_stream);
if (fail)
{
@@ -369,23 +398,24 @@ md5_check (const char *checkfile_name)
}
else
{
size_t digest_bin_bytes = digest_hex_bytes / 2;
size_t cnt;
/* Compare generated binary number with text representation
in check file. Ignore case of hex digits. */
for (cnt = 0; cnt < 16; ++cnt)
for (cnt = 0; cnt < digest_bin_bytes; ++cnt)
{
if (TOLOWER (md5num[2 * cnt]) != bin2hex[md5buffer[cnt] >> 4]
|| (TOLOWER (md5num[2 * cnt + 1])
!= (bin2hex[md5buffer[cnt] & 0xf])))
if (TOLOWER (hex_digest[2 * cnt]) != bin2hex[bin_buffer[cnt] >> 4]
|| (TOLOWER (hex_digest[2 * cnt + 1])
!= (bin2hex[bin_buffer[cnt] & 0xf])))
break;
}
if (cnt != 16)
if (cnt != digest_bin_bytes)
++n_mismatched_checksums;
if (!status_only)
{
printf ("%s: %s\n", filename,
(cnt != 16 ? _("FAILED") : _("OK")));
(cnt != digest_bin_bytes ? _("FAILED") : _("OK")));
fflush (stdout);
}
}
@@ -411,8 +441,8 @@ md5_check (const char *checkfile_name)
if (n_properly_formated_lines == 0)
{
/* Warn if no tests are found. */
error (0, 0, _("%s: no properly formatted MD5 checksum lines found"),
checkfile_name);
error (0, 0, _("%s: no properly formatted %s checksum lines found"),
checkfile_name, DIGEST_TYPE_STRING (algorithm));
}
else
{
@@ -448,7 +478,7 @@ md5_check (const char *checkfile_name)
int
main (int argc, char **argv)
{
unsigned char md5buffer[16];
unsigned char bin_buffer[MAX_DIGEST_BIN_BYTES];
int do_check = 0;
int opt;
char **string = NULL;
@@ -513,6 +543,9 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
min_digest_line_length = MIN_DIGEST_LINE_LENGTH (algorithm);
digest_hex_bytes = DIGEST_HEX_BYTES (algorithm);
if (file_type_specified && do_check)
{
error (0, 0, _("the --binary and --text options are meaningless when \
@@ -553,10 +586,13 @@ verifying checksums"));
for (i = 0; i < n_strings; ++i)
{
size_t cnt;
md5_buffer (string[i], strlen (string[i]), md5buffer);
if (algorithm == ALG_MD5)
md5_buffer (string[i], strlen (string[i]), bin_buffer);
else
sha_buffer (string[i], strlen (string[i]), bin_buffer);
for (cnt = 0; cnt < 16; ++cnt)
printf ("%02x", md5buffer[cnt]);
for (cnt = 0; cnt < (digest_hex_bytes / 2); ++cnt)
printf ("%02x", bin_buffer[cnt]);
printf (" \"%s\"\n", string[i]);
}
@@ -570,7 +606,8 @@ verifying checksums"));
usage (EXIT_FAILURE);
}
err = md5_check ((optind == argc) ? "-" : argv[optind]);
err = digest_check ((optind == argc) ? "-" : argv[optind],
DIGEST_STREAM (algorithm));
}
else
{
@@ -582,7 +619,8 @@ verifying checksums"));
int fail;
char *file = argv[optind];
fail = md5_file (file, binary, md5buffer);
fail = digest_file (file, binary, bin_buffer,
DIGEST_STREAM (algorithm));
err |= fail;
if (!fail)
{
@@ -593,8 +631,8 @@ verifying checksums"));
if (strchr (file, '\n') || strchr (file, '\\'))
putchar ('\\');
for (i = 0; i < 16; ++i)
printf ("%02x", md5buffer[i]);
for (i = 0; i < (digest_hex_bytes / 2); ++i)
printf ("%02x", bin_buffer[i]);
putchar (' ');
if (binary)

View File

@@ -77,7 +77,7 @@ main (int argc, char **argv)
{
mode_t newmode;
mode_t parent_mode;
const char *symbolic_mode = NULL;
const char *specified_mode = NULL;
const char *verbose_fmt_string = NULL;
int errors = 0;
int optc;
@@ -101,7 +101,7 @@ main (int argc, char **argv)
create_parents = 1;
break;
case 'm':
symbolic_mode = optarg;
specified_mode = optarg;
break;
case 'v': /* --verbose */
verbose_fmt_string = _("created directory %s");
@@ -119,17 +119,18 @@ main (int argc, char **argv)
usage (1);
}
newmode = S_IRWXUGO & ~ umask (0);
parent_mode = S_IWUSR | S_IXUSR | newmode;
if (symbolic_mode)
newmode = S_IRWXUGO;
if (specified_mode)
{
struct mode_change *change = mode_compile (symbolic_mode, 0);
struct mode_change *change = mode_compile (specified_mode, 0);
newmode &= ~ umask (0);
if (change == MODE_INVALID)
error (1, 0, _("invalid mode %s"), quote (symbolic_mode));
error (1, 0, _("invalid mode %s"), quote (specified_mode));
else if (change == MODE_MEMORY_EXHAUSTED)
xalloc_die ();
newmode = mode_adjust (newmode, change);
}
parent_mode = S_IWUSR | S_IXUSR | newmode;
for (; optind < argc; ++optind)
{
@@ -150,8 +151,11 @@ main (int argc, char **argv)
/* mkdir(2) is required to honor only the file permission bits.
In particular, it needn't do anything about `special' bits,
so if any were set in newmode, apply them with chmod. */
if (fail == 0 && (newmode & ~S_IRWXUGO))
so if any were set in newmode, apply them with chmod.
This extra step is necessary in some cases when the containing
directory has a default ACL. */
if (fail == 0 && specified_mode)
{
fail = chmod (argv[optind], newmode);
if (fail)
@@ -160,7 +164,8 @@ main (int argc, char **argv)
}
}
errors |= fail;
if (fail)
errors = 1;
}
exit (errors);

View File

@@ -15,12 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Options:
-m, --mode=mode Set the mode of created fifo's to MODE, which is
symbolic as in chmod and uses the umask as a point of
departure.
David MacKenzie <djm@ai.mit.edu> */
/* David MacKenzie <djm@ai.mit.edu> */
#include <config.h>
#include <stdio.h>
@@ -76,7 +71,7 @@ main (int argc, char **argv)
{
mode_t newmode;
struct mode_change *change;
const char *symbolic_mode;
const char *specified_mode;
int errors = 0;
int optc;
@@ -87,7 +82,7 @@ main (int argc, char **argv)
atexit (close_stdout);
symbolic_mode = NULL;
specified_mode = NULL;
#ifndef S_ISFIFO
error (4, 0, _("fifo files not supported"));
@@ -99,7 +94,7 @@ main (int argc, char **argv)
case 0:
break;
case 'm':
symbolic_mode = optarg;
specified_mode = optarg;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
@@ -114,11 +109,11 @@ main (int argc, char **argv)
usage (1);
}
newmode = ((S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
& ~ umask (0));
if (symbolic_mode)
newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (specified_mode)
{
change = mode_compile (symbolic_mode, 0);
newmode &= ~ umask (0);
change = mode_compile (specified_mode, 0);
if (change == MODE_INVALID)
error (1, 0, _("invalid mode"));
else if (change == MODE_MEMORY_EXHAUSTED)
@@ -128,11 +123,23 @@ main (int argc, char **argv)
for (; optind < argc; ++optind)
{
if (mkfifo (argv[optind], newmode))
{
error (0, errno, _("cannot make fifo %s"), quote (argv[optind]));
errors = 1;
}
int fail = mkfifo (argv[optind], newmode);
if (fail)
error (0, errno, _("cannot create fifo `%s'"), quote (argv[optind]));
/* If the containing directory happens to have a default ACL, chmod
ensures the file mode permission bits are still set as desired. */
if (fail == 0 && specified_mode)
{
fail = chmod (argv[optind], newmode);
if (fail)
error (0, errno, _("cannot set permissions of fifo `%s'"),
quote (argv[optind]));
}
if (fail)
errors = 1;
}
exit (errors);

View File

@@ -86,7 +86,7 @@ main (int argc, char **argv)
{
mode_t newmode;
struct mode_change *change;
const char *symbolic_mode;
const char *specified_mode;
int optc;
int i_major, i_minor;
long int tmp_major, tmp_minor;
@@ -99,7 +99,7 @@ main (int argc, char **argv)
atexit (close_stdout);
symbolic_mode = NULL;
specified_mode = NULL;
while ((optc = getopt_long (argc, argv, "m:", longopts, NULL)) != -1)
{
@@ -108,7 +108,7 @@ main (int argc, char **argv)
case 0:
break;
case 'm':
symbolic_mode = optarg;
specified_mode = optarg;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
@@ -117,11 +117,11 @@ main (int argc, char **argv)
}
}
newmode = ((S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
& ~ umask (0));
if (symbolic_mode)
newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (specified_mode)
{
change = mode_compile (symbolic_mode, 0);
newmode &= ~ umask (0);
change = mode_compile (specified_mode, 0);
if (change == MODE_INVALID)
error (1, 0, _("invalid mode"));
else if (change == MODE_MEMORY_EXHAUSTED)
@@ -223,5 +223,16 @@ major and minor device numbers may not be specified for fifo files"));
usage (1);
}
/* Perform an explicit chmod to ensure the file mode permission bits
are set as specified. This extra step is necessary in some cases
when the containing directory has a default ACL. */
if (specified_mode)
{
if (chmod (argv[optind], newmode))
error (0, errno, _("cannot set permissions of `%s'"),
quote (argv[optind]));
}
exit (0);
}

View File

@@ -88,7 +88,6 @@ rm_option_init (struct rm_options *x)
{
x->unlink_dirs = 0;
/* FIXME: maybe this should be 1. The POSIX spec doesn't specify. */
x->ignore_missing_files = 0;
x->recursive = 1;
@@ -145,6 +144,18 @@ is_real_dir (const char *path)
return lstat (path, &stats) == 0 && S_ISDIR (stats.st_mode);
}
static int
strip_trailing_slashes_2 (char *path)
{
char *end_p = path + strlen (path) - 1;
char *slash = end_p;
while (slash > path && *slash == '/')
*slash-- = '\0';
return slash < end_p;
}
/* Move SOURCE onto DEST. Handles cross-filesystem moves.
If SOURCE is a directory, DEST must not exist.
Return 0 if successful, non-zero if an error occurred. */
@@ -233,6 +244,11 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
remove_init ();
fspec_init_file (&fs, dir_to_remove);
/* Remove any trailing slashes. This is necessary if we
took the else branch of movefile. */
strip_trailing_slashes_2 (fs.filename);
status = rm (&fs, 1, &rm_options);
assert (VALID_STATUS (status));
if (status == RM_ERROR)
@@ -251,18 +267,6 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
return fail;
}
static int
strip_trailing_slashes_2 (char *path)
{
char *end_p = path + strlen (path) - 1;
char *slash = end_p;
while (slash > path && *slash == '/')
*slash-- = '\0';
return slash < end_p;
}
/* Move file SOURCE onto DEST. Handles the case when DEST is a directory.
DEST_IS_DIR must be nonzero when DEST is a directory or a symlink to a
directory and zero otherwise.

View File

@@ -77,6 +77,8 @@ enum size_spec
SHORT,
INT,
LONG,
LONG_LONG,
/* FIXME: add INTMAX support, too */
FLOAT_SINGLE,
FLOAT_DOUBLE,
FLOAT_LONG_DOUBLE
@@ -229,7 +231,11 @@ static FILE *in_stream;
/* If nonzero, at least one of the files we read was standard input. */
static int have_read_stdin;
#define LONGEST_INTEGRAL_TYPE long int
#ifdef HAVE_UNSIGNED_LONG_LONG
# define LONGEST_INTEGRAL_TYPE unsigned long long
#else
# define LONGEST_INTEGRAL_TYPE long int
#endif
#define MAX_INTEGRAL_TYPE_SIZE sizeof(LONGEST_INTEGRAL_TYPE)
static enum size_spec integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1];
@@ -441,6 +447,21 @@ print_long (long unsigned int n_bytes, const char *block,
}
}
#ifdef HAVE_UNSIGNED_LONG_LONG
static void
print_long_long (long unsigned int n_bytes, const char *block,
const char *fmt_string)
{
int i;
for (i = n_bytes / sizeof (unsigned long long); i > 0; i--)
{
unsigned long long tmp = *(const unsigned long long *) block;
printf (fmt_string, tmp);
block += sizeof (unsigned long long);
}
}
#endif
static void
print_float (long unsigned int n_bytes, const char *block,
const char *fmt_string)
@@ -704,7 +725,9 @@ this system doesn't provide a %lu-byte integral type"), s_orig, size);
fmt = SIGNED_DECIMAL;
sprintf (fmt_string, " %%%u%sd",
(field_width = bytes_to_signed_dec_digits[size]),
(size_spec == LONG ? "l" : ""));
(size_spec == LONG ? "l"
: (size_spec == LONG_LONG ? "ll"
: "")));
break;
case 'o':
@@ -756,6 +779,10 @@ this system doesn't provide a %lu-byte integral type"), s_orig, size);
print_function = print_long;
break;
case LONG_LONG:
print_function = print_long_long;
break;
default:
abort ();
}
@@ -1596,6 +1623,9 @@ main (int argc, char **argv)
integral_type_size[sizeof (short int)] = SHORT;
integral_type_size[sizeof (int)] = INT;
integral_type_size[sizeof (long int)] = LONG;
#ifdef HAVE_UNSIGNED_LONG_LONG
integral_type_size[sizeof (long long)] = LONG_LONG;
#endif
for (i = 0; i <= MAX_FP_TYPE_SIZE; i++)
fp_type_size[i] = NO_SIZE;

View File

@@ -1,7 +1,7 @@
struct rm_options
{
/* If nonzero, ignore nonexistant files. */
/* If nonzero, ignore nonexistent files. */
int ignore_missing_files;
/* If nonzero, query the user about whether to remove each file. */

2
src/sha1sum.c Normal file
View File

@@ -0,0 +1,2 @@
#include "checksum.h"
int algorithm = ALG_SHA1;

View File

@@ -83,6 +83,7 @@
#include <getopt.h>
#include <stdio.h>
#include <assert.h>
#include <setjmp.h>
#include <signal.h>
#include <sys/types.h>
@@ -438,7 +439,7 @@ struct Options
static struct option const long_opts[] =
{
{"exact", required_argument, NULL, 'x'},
{"exact", no_argument, NULL, 'x'},
{"force", no_argument, NULL, 'f'},
{"iterations", required_argument, NULL, 'n'},
{"size", required_argument, NULL, 's'},
@@ -990,13 +991,14 @@ fillpattern (int type, unsigned char *r, size_t size)
}
/*
* Fill a buffer with random data.
* size is rounded UP to a multiple of ISAAC_BYTES.
* Fill a buffer, R (of size SIZE_MAX), with random data.
* SIZE is rounded UP to a multiple of ISAAC_BYTES.
*/
static void
fillrand (struct isaac_state *s, word32 *r, size_t size)
fillrand (struct isaac_state *s, word32 *r, size_t size_max, size_t size)
{
size = (size + ISAAC_BYTES - 1) / ISAAC_BYTES;
assert (size <= size_max);
while (size--)
{
@@ -1083,12 +1085,14 @@ dopass (int fd, char const *qname, off_t *sizep, int type,
lim = sizeof r;
if ((off_t) lim > size - offset && size != -1)
{
if (size < offset)
break;
lim = (size_t) (size - offset);
if (!lim)
break;
}
if (type < 0)
fillrand (s, r, lim);
fillrand (s, r, sizeof r, lim);
/* Loop to retry partial writes. */
for (soff = 0; soff < lim; soff += ssize)
{
@@ -1422,17 +1426,33 @@ do_wipefd (int fd, char const *qname, struct isaac_state *s,
size = flags->size;
if (size == -1)
{
size = (S_ISREG (st.st_mode)
? st.st_size
: lseek (fd, (off_t) 0, SEEK_END));
if (size < (S_ISREG (st.st_mode) ? 0 : -1))
/* Accept a length of zero only if it's a regular file.
For any other type of file, try to get the size another way. */
if (S_ISREG (st.st_mode))
{
error (0, 0, _("%s: file has negative size"), qname);
return -1;
size = st.st_size;
if (size < 0)
{
error (0, 0, _("%s: file has negative size"), qname);
return -1;
}
}
else
{
size = lseek (fd, (off_t) 0, SEEK_END);
if (size <= 0)
{
/* We are unable to determine the length, up front.
Let dopass do that as part of its first iteration. */
size = -1;
}
}
if (0 <= size && !(flags->exact))
{
size += ST_BLKSIZE (st) - 1 - (size - 1) % ST_BLKSIZE (st);
/* If in rounding up, we've just overflowed, use the maximum. */
if (size < 0)
size = TYPE_MAXIMUM (off_t);
}

View File

@@ -73,6 +73,7 @@ double strtod ();
not properly sorted. Any other irregular exit must exit with a
status code greater than 1. */
#define SORT_FAILURE 2
#define SORT_OUT_OF_ORDER 1
#define C_DECIMAL_POINT '.'
#define NEGATION_SIGN '-'
@@ -2242,9 +2243,14 @@ but lacks following character offset"));
if (checkonly)
{
if (nfiles > 1)
error (SORT_FAILURE, 0,
_("too many arguments; with -c, there may be at most\
one file argument"));
/* POSIX requires that sort return 1 IFF invoked with -c and the
input is not properly sorted. */
exit (check (files, nfiles) == 0 ? 0 : 1);
exit (check (files, nfiles) == 0 ? EXIT_SUCCESS : SORT_OUT_OF_ORDER);
}
if (!STREQ (outfile, "-"))

View File

@@ -46,7 +46,12 @@ usage (int status)
program_name);
else
{
printf (_("Usage: %s [OPTION]... [STRING]...\n"), program_name);
printf (_("\
Usage: %s [STRING]...\n\
or: %s OPTION\n\
"),
program_name, program_name);
printf (_("\
Repeatedly output a line with all specified STRING(s), or `y'.\n\
\n\

View File

@@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = \
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
same-file cp-mv-backup symlink-slash slink-2-slink fail-perm dir-slash \
perm cp-HL special-bits
perm cp-HL special-bits link dir-rm-dest cp-parents
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
MAKE=$(MAKE) \

View File

@@ -120,7 +120,7 @@ AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = \
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
same-file cp-mv-backup symlink-slash slink-2-slink fail-perm dir-slash \
perm cp-HL special-bits
perm cp-HL special-bits link dir-rm-dest cp-parents
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \

View File

@@ -16,12 +16,7 @@ if test $framework_failure = 1; then
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
. $srcdir/../lang-default
# This cp command should exit nonzero.
cp --b=simple a~ a > out 2>&1 && fail=1

View File

@@ -6,8 +6,8 @@ if test "$VERBOSE" = yes; then
cp --version
fi
LANGUAGE=C; export LANGUAGE
LANG=C; export LANG
# Ensure that ls sorts the same way for everyone.
. $srcdir/../lang-default
. $srcdir/../envvar-check

33
tests/cp/cp-parents Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh
# cp -R --parents dir-specified-with-trailing-slash/ other-dir
# would get a failed assertion.
if test "$VERBOSE" = yes; then
set -x
mv --version
fi
pwd=`pwd`
tmp=cp-parents.$$
trap 'status=$?; cd $pwd; exec 1>&2; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
. $srcdir/../envvar-check
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
mkdir foo bar || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
# With 4.0.37 and earlier (back to when?), this would fail
# with the failed assertion from dirname.c.
cp -R --parents foo/ bar || fail=1
(exit $fail); exit

32
tests/cp/dir-rm-dest Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
# verify that cp's --remove-destination option works with -R
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
pwd=`pwd`
tmp=cprmdest.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
mkdir d e || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
# Do it once with no destination...
cp -R --remove-destination d e || fail=1
# ...and again, with an existing destination.
cp -R --remove-destination d e || fail=1
(exit $fail); exit

33
tests/cp/link Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh
# Make sure cp --link -f works when the target exists.
# This failed for 4.0z (due to a bug introduced in that test release).
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
pwd=`pwd`
tmp=cp-link.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
touch src || framework_failure=1
touch dest || framework_failure=1
touch dest2 || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
cp -f --link src dest || fail=1
cp -f --symbolic-link src dest2 || fail=1
(exit $fail); exit

View File

@@ -1,6 +1,8 @@
#!/bin/sh
# Make sure the permission-preserving code in copy.c (mv, cp, install) works.
. $srcdir/../expensive
if test "$VERBOSE" = yes; then
set -x
cp --version

View File

@@ -7,8 +7,7 @@ if test "$VERBOSE" = yes; then
cp --version
fi
LANGUAGE=C; export LANGUAGE
LANG=C; export LANG
. $srcdir/../lang-default
VERSION_CONTROL=numbered; export VERSION_CONTROL
@@ -109,7 +108,7 @@ cat <<\EOF > $expected
0 -l (foo symlink -> foo)
0 -dl (foo symlink -> foo)
0 -fl (foo symlink -> foo)
0 -dfl (foo symlink -> foo)
0 -dfl (foo symlink)
0 -bl (foo symlink -> foo)
0 -bdl (foo symlink symlink.~1~ -> foo)
0 -bfl (foo symlink -> foo)
@@ -182,8 +181,10 @@ cat <<\EOF > $expected
EOF
# Uncomment this if you see a failure and want to try to diagnose it.
diff -u $expected $actual 1>&2
fail=0;
cmp $expected $actual
exit $?
# Some folks don't have diff.
cmp $expected $actual \
|| { diff -c $expected $actual 1>&2; fail=1; }
(exit $fail); exit

View File

@@ -10,12 +10,7 @@ fi
. $srcdir/../envvar-check
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
. $srcdir/../lang-default
pwd=`pwd`
tmp=sl2sl-$$

View File

@@ -2,6 +2,9 @@
# make sure `cp -p' preserves special bits
# This works only when run as root.
# This test would fail due to a bug introduced in 4.0y.
# The bug was fixed in 4.0z.
if test "$VERBOSE" = yes; then
set -x
cp --version

View File

@@ -7,6 +7,8 @@ if test "$VERBOSE" = yes; then
cp --version
fi
. $srcdir/../lang-default
tmp=t-cpsymsl.$$
framework_failure=0
@@ -23,7 +25,7 @@ fi
fail=0
cp -dR symlink/ s || fail=1
set `LANGUAGE=C LC_ALL=C ls -l s`
set `ls -l s`
# Prior to fileutils-4.0q, the following would have output ...`s -> dir'
# because the trailing slash was removed unconditionally (now you have to

View File

@@ -95,15 +95,12 @@ sub test_vector
['next-mo', "-d '$d1 next month' '+%Y-%m-%d %T'", {}, "$dm $t0", 0],
['next-y', "-d '$d1 next year' '+%Y-%m-%d %T'", {}, "$dy $t0", 0],
# These utc-* tests failed for sh-utils-1.16.
['utc-0', "-u -d '08/01/97 6:00' '+%D,%H:%M'", {}, "08/01/97,10:00", 0],
# Same as above, but don't rely on TZ in environment.
['utc-0', "-u -d '08/01/97 6:00' '+%D,%H:%M'", {}, "08/01/97,06:00", 0],
['utc-0a', "-u -d '08/01/97 6:00 UTC +4 hours' '+%D,%H:%M'", {},
"08/01/97,10:00", 0],
# Make sure --file=FILE works with -u.
['utc-1', "-u --file=- '+%Y-%m-%d %T'", "$d0 $t0\n$d0 $t0\n",
"$d0 $th\n$d0 $th", 0],
# Same as above, but don't rely on TZ in environment.
"$d0 $t0\n$d0 $t0", 0],
['utc-1a', "-u --file=- '+%Y-%m-%d %T'",
"$d0 $t0 UTC +1 hour\n$d0 $t0 UTC +1 hour\n",
"$d0 $th\n$d0 $th", 0],
@@ -138,9 +135,8 @@ sub test_vector
{}, "2000-06-15 09:43:57", 0],
# Relative seconds, no time.
# This test is fragile! It works only if TZ is set to UTC+1 (as below).
['relative-2', "--utc -d '1970-01-01 UTC +961062237 sec' $fmt", {},
"2000-06-15 10:43:57", 0],
"2000-06-15 09:43:57", 0],
# FIXME: add a lot more...
);

View File

@@ -7,9 +7,19 @@ if test "$VERBOSE" = yes; then
du --version
fi
pwd=`pwd`
tmp=du2-$$
trap 'status=$?; rm -rf $tmp && exit $status' 0
trap 'exit $?' 1 2 13 15
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
(exit 1); exit
fi
mkdir -p $tmp/1 $tmp/2
@@ -21,4 +31,4 @@ du $tmp/1 $tmp/2 > /dev/null || fail=1
du . $tmp > /dev/null || fail=1
du .. $tmp > /dev/null || fail=1
exit $fail
(exit $fail); exit

11
tests/expensive Normal file
View File

@@ -0,0 +1,11 @@
if test "$RUN_EXPENSIVE_TESTS" != yes; then
cat <<EOF >&2
$0: This test is relatively expensive, so it is disabled by default.
To run it anyway, rerun make check with the RUN_EXPENSIVE_TESTS
environment variable set to yes. E.g.,
env RUN_EXPENSIVE_TESTS=yes make check
EOF
exit 77
fi

7
tests/lang-default Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
# Set locale-related environment variables so we get consistent
# message translations, time formats, sort orderings, etc.
LANGUAGE=''; export LANGUAGE
LC_ALL=''; export LC_ALL
LANG=''; export LANG

View File

@@ -7,6 +7,9 @@ if test "$VERBOSE" = yes; then
ln --version
fi
# Make sure we get English translations.
. $srcdir/../lang-default
tmp=t-ln.$$
test_failure=0
@@ -20,14 +23,6 @@ if test $test_failure = 1; then
exit 1
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
fail=0
ln -sf a b > err 2>&1 && fail=1
case `cat err` in

View File

@@ -6,6 +6,8 @@ if test "$VERBOSE" = yes; then
ls --version
fi
. $srcdir/../lang-default
tmp=t-ls.$$
framework_failure=0
@@ -20,9 +22,6 @@ if test $framework_failure = 1; then
exit 1
fi
LANGUAGE=C; export LANGUAGE
LANG=C; export LANG
fail=0
set `ls -l symlink/`

View File

@@ -6,6 +6,11 @@ if test "$VERBOSE" = yes; then
ls --version
fi
# Date output in ls -l is locale-sensitive, so this test fails if the
# current locale produces a date that doesn't match the embedded value
# here (Jan 15 23:00:00 1998), which is in the C (POSIX) locale.
. $srcdir/../lang-default
tmp=t-ls.$$
framework_failure=0
@@ -43,12 +48,6 @@ sleep 2
# Create a link, updating c's ctime.
ln c d || framework_failure=1
# Date output in ls -l is locale-sensitive, so this test fails if the
# current locale produces a date that doesn't match the embedded value
# here (Jan 15 23:00:00 1998), which is in the C (POSIX) locale.
LC_ALL=C
export LC_ALL
# Before we go any further, verify that touch's -m option works.
set -- `ls --full -l a`
case "$*" in
@@ -58,7 +57,12 @@ case "$*" in
cat >&2 << \EOF
A basic test of touch -a has just failed, so the subsequent
tests in this file will not be run.
In the output below, the date of last modification for `a' should
have been Jan 15 23:00:00 1998.
EOF
#`
ls --full -l a
framework_failure=1
;;
esac
@@ -72,7 +76,11 @@ case "$*" in
cat >&2 << \EOF
A basic test of touch -m has just failed, so the subsequent
tests in this file will not be run.
In the output below, the date of last access for `a' should
have been Jan 14 11:00:00 1998.
EOF
ls --full -lu a
framework_failure=1
;;
esac
@@ -98,9 +106,14 @@ else
# In spite of documentation, (e.g., stat(2)), neither link nor chmod
# update a file's st_ctime on SunOS4.1.4.
cat >&2 << \EOF
failed ls ctime test -- this is expected at least for SunOS4.1.4
failed ls ctime test -- this failure is expected at least for SunOS4.1.4
and for tmpfs file systems on Solaris 5.5.1.
In the output below, `c' should have had a ctime more recent than
that of `a', but does not.
EOF
#'
ls -ctl --full-time a c
fail=1
fi

View File

@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = p-1 p-2 special-1
TESTS = p-1 p-2 special-1 perm
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
PATH=`pwd`/../../src:$$PATH

View File

@@ -117,7 +117,7 @@ l = @l@
AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = p-1 p-2 special-1
TESTS = p-1 p-2 special-1 perm
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
PATH=`pwd`/../../src:$$PATH

56
tests/mkdir/perm Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/sh
# Verify that mkdir's `-m MODE' option works properly
# with various umask settings.
if test "$VERBOSE" = yes; then
set -x
mkdir --version
fi
pwd=`pwd`
tmp=perm.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
(exit 1); exit
fi
fail=0
# umask -m option resulting perm
tests='
000 : :drwxrwxrwx:
000 : -m 016 :d-----xrw-:
077 : :drwx------:
050 : :drwx-w-rwx:
050 : -m 312 :d-wx--x-w-:
160 : :drw---xrwx:
'
old_IFS=$IFS
IFS=':
'
set - $tests
IFS=$old_IFS
while :; do
case $# in 0|1|2) break;; esac
umask=$1 mode=$2 expected_perms=$3
shift; shift; shift
umask $umask
mkdir $mode d || fail=1
actual_perms=`ls -ld d | sed 's/ .*//'`
test "$expected_perms" = "$actual_perms" \
|| { fail=1; echo expected $expected_perms, got $actual_perms; }
rmdir d || fail=1
done
(exit $fail); exit

View File

@@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = i-2 mv-special-1 into-self into-self-2 into-self-3 backup-is-src \
i-1 hard-link-1 force partition-perm to-symlink dir-file diag \
part-symlink
part-symlink part-rename
EXTRA_DIST = $(TESTS) setup
TESTS_ENVIRONMENT = \

View File

@@ -119,7 +119,7 @@ AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = i-2 mv-special-1 into-self into-self-2 into-self-3 backup-is-src \
i-1 hard-link-1 force partition-perm to-symlink dir-file diag \
part-symlink
part-symlink part-rename
EXTRA_DIST = $(TESTS) setup

View File

@@ -26,12 +26,7 @@ if test $framework_failure = 1; then
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
. $srcdir/../lang-default
# This mv command should exit nonzero.
mv --b=simple $a2 $a > out 2>&1 && fail=1

View File

@@ -6,6 +6,9 @@ if test "$VERBOSE" = yes; then
mv --version
fi
# Make sure we get English translations.
. $srcdir/../lang-default
pwd=`pwd`
tmp=diag-$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
@@ -24,14 +27,6 @@ if test $framework_failure = 1; then
exit 1
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
# These mv commands should all exit nonzero.
# Too few args. This first one did fail, but with an incorrect diagnostic

View File

@@ -20,12 +20,7 @@ if test $framework_failure = 1; then
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
. $srcdir/../lang-default
# This mv command should exit nonzero.
mv $ff $ff > out 2>&1 && fail=1

View File

@@ -26,12 +26,7 @@ if test $framework_failure = 1; then
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
. $srcdir/../lang-default
mv $dir $other_partition_tmpdir || fail=1

View File

@@ -11,12 +11,7 @@ fi
. $srcdir/../envvar-check
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
. $srcdir/../lang-default
pwd=`pwd`
tmp=cp-mv-if-$$

View File

@@ -23,12 +23,7 @@ fi
fail=0
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
. $srcdir/../lang-default
# This mv command should fail.
mv $dir $file $dir > out 2>&1 && fail=1

View File

@@ -34,12 +34,7 @@ if test $framework_failure = 1; then
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
. $srcdir/../lang-default
# This mv command should exit nonzero.
mv $symlink $file > out 2>&1 && fail=1

View File

@@ -19,12 +19,7 @@ if test $framework_failure = 1; then
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
. $srcdir/../lang-default
# This mv command should exit nonzero.
mv $dir1 $dir2 $dir2 > out 2>&1 && fail=1

View File

@@ -1,6 +1,8 @@
#! /bin/sh
. $srcdir/setup
# Make sure we get English translations.
. $srcdir/../lang-default
if test -z "$other_partition_tmpdir"; then
exit 77
@@ -26,14 +28,6 @@ if test $framework_failure = 1; then
exit 77
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
fail=0
mv --verbose $null $dir $other_partition_tmpdir > out || fail=1
# Make sure the files are gone.

37
tests/mv/part-rename Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/sh
# Moving a directory specified with a trailing slash from one partition to
# another, and giving it a different name at the destination would cause mv
# to get a failed assertion.
if test "$VERBOSE" = yes; then
set -x
mv --version
fi
pwd=`pwd`
tmp=part-ren.$$
trap 'status=$?; cd $pwd; exec 1>&2; rm -rf $tmp $other_partition_tmpdir && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
. $srcdir/setup
. $srcdir/../envvar-check
if test -z "$other_partition_tmpdir"; then
(exit 77); exit
fi
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
mkdir foo || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
mv foo/ $other_partition_tmpdir/bar || fail=1
(exit $fail); exit

View File

@@ -17,6 +17,8 @@ pwd_tmp=$pwd/$tmp
. $srcdir/setup
. $srcdir/../envvar-check
# Make sure the programs use C-locale formats/translations.
. $srcdir/../lang-default
if test -z "$other_partition_tmpdir"; then
(exit 77); exit
@@ -150,7 +152,7 @@ for copy in cp mv; do
done
test $fail = 1 &&
{ (exit $?); exit; }
{ (exit 1); exit; }
cat <<\EOF > $expected
1 cp loc_reg rem_sl [cp: `loc_reg' and `rem_sl' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
@@ -199,9 +201,8 @@ cat <<\EOF > $expected
EOF
# Uncomment this if you see a failure and want to try to diagnose it.
#diff -u $expected $actual 1>&2
# Some folks may don't have diff.
cmp $expected $actual \
|| { diff -c $expected $actual 1>&2; fail=1; }
cmp $expected $actual
(exit $?); exit
(exit $fail); exit

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