Compare commits

...

457 Commits

Author SHA1 Message Date
Jim Meyering
5da70319a7 from libc 2002-06-26 06:13:24 +00:00
Jim Meyering
8ac1a9f278 *** empty log message *** 2002-06-25 08:21:13 +00:00
Jim Meyering
6e78c788f0 (prompt): Add a comment to help translators work
around the problem of making the translations of the adjective
`write-protected' and the corresponding run-time-variable noun
(e.g., file, directory, symlink, etc.) consistent.  From Paul Eggert.
2002-06-25 08:21:07 +00:00
Jim Meyering
35f99d5347 *** empty log message *** 2002-06-24 11:12:56 +00:00
Jim Meyering
de1abda345 *** empty log message *** 2002-06-24 10:56:55 +00:00
Jim Meyering
e6d1f21ea6 (usage): Add missing open-quote. 2002-06-24 10:56:50 +00:00
Jim Meyering
2223ca3c2d *** empty log message *** 2002-06-24 10:39:37 +00:00
Jim Meyering
4605ddcc95 *** empty log message *** 2002-06-22 18:08:52 +00:00
Jim Meyering
4dcdd8be06 *** empty log message *** 2002-06-22 18:08:10 +00:00
Jim Meyering
67e6f0f233 *** empty log message *** 2002-06-22 18:03:44 +00:00
Jim Meyering
8965df82d1 (ISASCII, ISPRINT): Undefine, to avoid warning about
redefinition due to Solaris5.6's definition in /usr/include/sys/euc.h.
2002-06-22 18:03:40 +00:00
Jim Meyering
453257fa71 *** empty log message *** 2002-06-22 16:20:19 +00:00
Jim Meyering
9e7746f4c0 (segv_handler, c_stack_action) [! defined SA_SIGINFO]:
Do not assume SA_SIGINFO behavior.
Bug reported by Jim Meyering on NetBSD 1.5.2.
2002-06-22 16:20:15 +00:00
Jim Meyering
7721a2148a *** empty log message *** 2002-06-22 10:11:25 +00:00
Jim Meyering
64a1747ac5 Update from diffutils-2.8.2. 2002-06-22 10:11:14 +00:00
Jim Meyering
2e53304940 . 2002-06-22 10:09:47 +00:00
Jim Meyering
299741bf33 *** empty log message *** 2002-06-22 10:09:33 +00:00
Jim Meyering
a715ff5d80 (libfetish_a_SOURCES): Add exitfail.c and exitfail.h. 2002-06-22 09:26:57 +00:00
Jim Meyering
e3dbc8d753 New files, from diffutils-2.8.2. 2002-06-22 09:25:36 +00:00
Jim Meyering
d8cfcf1a19 *** empty log message *** 2002-06-22 09:23:32 +00:00
Jim Meyering
7fc37adff9 (libfetish_a_SOURCES): Add c-stack.c, too. 2002-06-22 09:23:17 +00:00
Jim Meyering
53ba358c4b New file, from diffutils-2.8.2. 2002-06-22 09:03:14 +00:00
Jim Meyering
f9114f866d from diffutils-2.8.2 2002-06-22 09:01:22 +00:00
Jim Meyering
846b65a50e (jm_PREREQ): Add jm_PREREQ_C_STACK. 2002-06-22 09:01:10 +00:00
Jim Meyering
6e8cd75ccf *** empty log message *** 2002-06-22 08:55:43 +00:00
Jim Meyering
3a88e9055b . 2002-06-22 08:54:28 +00:00
Jim Meyering
10ff1d4404 Update from diffutils-2.8.2. 2002-06-22 08:54:23 +00:00
Jim Meyering
fe02d6163d . 2002-06-22 08:53:17 +00:00
Jim Meyering
6088c6dba5 *** empty log message *** 2002-06-22 08:53:02 +00:00
Jim Meyering
04c5110e59 (jm_PREREQ_EXCLUDE): Rename: jm_FUNC_FNMATCH to AC_FUNC_FNMATCH_GNU. 2002-06-22 08:52:56 +00:00
Jim Meyering
555d569125 * jm-macros.m4 (jm_CHECK_ALL_TYPES): Don't require AC__GNU_SOURCE,
now that configure.ac uses AC_GNU_SOURCE.
	(jm_MACROS): Rename: jm_FUNC_FNMATCH to AC_FUNC_FNMATCH_GNU.
2002-06-22 08:51:02 +00:00
Jim Meyering
ff6434052f (libfetish_a_SOURCES): Add fnmatch_.h in place of fnmatch.h.
(EXTRA_DIST): Add fnmatch_loop.c.
2002-06-22 08:47:57 +00:00
Jim Meyering
c230b93ee1 . 2002-06-22 08:34:59 +00:00
Jim Meyering
06f7295ae7 *** empty log message *** 2002-06-22 08:32:50 +00:00
Jim Meyering
f35ad592ca from diffutils-2.8.2. 2002-06-22 08:32:40 +00:00
Jim Meyering
8b213cb96f Change each use of AC_CHECK_HEADERS(stdbool.h) to AC_HEADER_STDBOOL 2002-06-22 08:29:29 +00:00
Jim Meyering
1cbf3518b8 New file, from diffutils-2.8.2. 2002-06-22 08:27:18 +00:00
Jim Meyering
7d04e0b63c Accommodate the slightly different diagnostic we
get on some systems, due to `unlink (dir)' failing with EACCES
rather than EPERM.  E.g. for ReiserFS on Linux-2.4.18.
2002-06-22 06:49:57 +00:00
Jim Meyering
fb10c254d8 *** empty log message *** 2002-06-22 06:49:43 +00:00
Jim Meyering
003d4e0cbe Update from gettext-0.11.2. 2002-06-21 21:23:01 +00:00
Jim Meyering
b3e0a2f188 *** empty log message *** 2002-06-21 17:42:12 +00:00
Jim Meyering
04bc254d7a bump serial# 2002-06-21 17:42:06 +00:00
Jim Meyering
6d9cf68838 (jm_PREREQ_QUOTEARG): Reflect name change: s/AC_MBSTATE_T/AC_TYPE_MBSTATE_T. 2002-06-21 17:41:58 +00:00
Jim Meyering
442596279b Reflect name change: s/AC_MBSTATE_T/AC_TYPE_MBSTATE_T. 2002-06-21 17:41:02 +00:00
Jim Meyering
04b4ee1245 Update from diffutils-2.8.2. 2002-06-21 17:38:30 +00:00
Jim Meyering
848d68e2c7 Add comment, from diffutils-2.8.2. 2002-06-21 15:39:12 +00:00
Jim Meyering
1e1836f7ca *** empty log message *** 2002-06-21 15:29:28 +00:00
Jim Meyering
4877e7ad84 . 2002-06-21 15:21:49 +00:00
Jim Meyering
15606fc8a9 tiny tweaks 2002-06-21 13:20:39 +00:00
Jim Meyering
fc3520c6fc (stat invocation): New section. From Michael Meskes. 2002-06-21 13:19:31 +00:00
Jim Meyering
0c788cabce . 2002-06-21 12:48:36 +00:00
Jim Meyering
a170c7e497 *** empty log message *** 2002-06-21 12:48:06 +00:00
Jim Meyering
fff4a08af1 (wget-update): Checkout into config/.
Warn when skipping a file.
2002-06-21 12:48:00 +00:00
Jim Meyering
047ab72566 *** empty log message *** 2002-06-21 12:34:49 +00:00
Jim Meyering
3ec40eb458 *** empty log message *** 2002-06-21 12:34:44 +00:00
Jim Meyering
e2a70948d4 Include sys/statvfs.h.
[!HAVE_SYS_STATVFS_H && !HAVE_SYS_VFS_H]: Include sys/param.h
and sys/mount.h, to get decl of struct statfs on NetBSD 1.5.2.
(NAMEMAX_FORMAT, STRUCT_STATVFS): Define.
(HAVE_STRUCT_STATXFS_F_TYPE, SB_F_NAMEMAX): Define.
Remove `static' attribute from decl of program_name.
(human_fstype): Use f_basetype or f_fstypename if available.
(print_human_time): Use nstrftime and an ISO format string, in
place of strftime with `%c'.  The latter is too locale-dependent.
(print_statfs): Deal with lots of portability issues: some fields
are available only with statfs, others only with statvfs, and
some are available in both, but with different types.
(do_statfs) [DEFAULT_FORMAT_TERSE]: Factor out.
[DEFAULT_FORMAT_VERBOSE]: Likewise.
2002-06-21 12:34:36 +00:00
Jim Meyering
a905df79ad . 2002-06-21 12:16:27 +00:00
Jim Meyering
0ab9ebc469 *** empty log message *** 2002-06-21 12:15:39 +00:00
Jim Meyering
807ad57ff1 *** empty log message *** 2002-06-21 12:13:51 +00:00
Jim Meyering
2b45b199f8 *** empty log message *** 2002-06-21 12:12:08 +00:00
Jim Meyering
ecbe7fb826 (jm_CHECK_ALL_HEADERS): Check for hurd.h. 2002-06-21 12:12:00 +00:00
Jim Meyering
071b36fd90 Change all `preserving ...' diagnostics to
`failed to preserve ...' to make the failure clearer.
2002-06-21 12:10:02 +00:00
Jim Meyering
d7313803f0 Include hurd.h.
(copy_internal): Preserve the stat.st_author field.
2002-06-21 12:06:17 +00:00
Jim Meyering
26ba37793c *** empty log message *** 2002-06-21 07:20:49 +00:00
Jim Meyering
2f223b443c (LOGIN_NAME_MAX): Define if not already defined.
(ID_LENGTH_MAX): Define.
(ST_DM_MODE): New macro.  Code moved from...
(print_long_format): ...here.
(print_long_format): Itemize and comment the individual parts
of init_bigbuf.  Use the above *_MAX macros.
2002-06-21 07:20:36 +00:00
Jim Meyering
7758b0efd3 Change defined(X)' syntax to defined X' in cpp directives. 2002-06-20 15:58:18 +00:00
Jim Meyering
343d7d4065 *** empty log message *** 2002-06-19 11:13:29 +00:00
Jim Meyering
f35cc0e4a0 Report an error if neither S_ISREG nor
S_IFREG is defined, instead of using a test specific to glibc
2.2.  This should be safe, since POSIX requires S_ISREG and
Unix Version 7 had S_IFREG.  We don't need to check for
<sys/types.h> since we don't use any symbols that it defines.
2002-06-19 11:12:59 +00:00
Jim Meyering
86adc7266e Interpret a permissions string of
drwxr-xr-x (DOS/Windows) as meaning the cwd is not setgid.
Reported by Rich Dawe.
2002-06-17 07:06:29 +00:00
Jim Meyering
57db2c8659 *** empty log message *** 2002-06-17 07:06:19 +00:00
Jim Meyering
6d797a5b97 use newer testing framework 2002-06-16 19:18:22 +00:00
Jim Meyering
3d16018d2e *** empty log message *** 2002-06-15 16:04:16 +00:00
Jim Meyering
6a4bcbb5d6 Include <sys/types.h> before system.h. 2002-06-15 16:03:57 +00:00
Jim Meyering
240330ca78 *** empty log message *** 2002-06-15 14:05:31 +00:00
Jim Meyering
719c68fe2e ls --author 2002-06-15 14:05:25 +00:00
Jim Meyering
34f5f485be *** empty log message *** 2002-06-15 13:43:20 +00:00
Jim Meyering
dc70d62988 *** empty log message *** 2002-06-15 13:42:54 +00:00
Jim Meyering
75dedb9944 (jm_CHECK_ALL_TYPES): Check for st_author. 2002-06-15 13:42:22 +00:00
Jim Meyering
45f4bb1290 (st_author) [! HAVE_STRUCT_STAT_ST_AUTHOR]: New macro.
(print_author): New var.
(AUTHOR_OPTION): New enum val.
(long_options, decode_switches, print_long_format, usage):
Support --author.
(format_user): New function.
(print_long_format): Use it.  Make print buffer a bit bigger.
2002-06-15 13:41:46 +00:00
Jim Meyering
dda6cbbb1c *** empty log message *** 2002-06-15 13:26:42 +00:00
Jim Meyering
4c52326d70 (ls invocation): Document new option: --author. 2002-06-15 13:26:38 +00:00
Jim Meyering
2fd73898d2 use trap stuff from sample-test 2002-06-15 10:19:36 +00:00
Jim Meyering
4726bde475 use trap stuff from sample-test 2002-06-15 10:17:35 +00:00
Jim Meyering
a44fd51a81 now that $tmp has two components, use mkdir's -p option to create it 2002-06-15 10:16:22 +00:00
Jim Meyering
35e9b38dd8 now that $tmp has two components, use mkdir's -p option to create it 2002-06-15 10:15:00 +00:00
Jim Meyering
a2e113a2db use trap stuff from sample-test 2002-06-15 10:04:30 +00:00
Jim Meyering
767aa7bf70 use trap stuff from sample-test 2002-06-15 09:58:37 +00:00
Jim Meyering
9234b6f7e0 *** empty log message *** 2002-06-15 09:54:28 +00:00
Jim Meyering
77bc22f77a (trap): in chmod, use u+rwx, not 700 2002-06-15 09:54:08 +00:00
Jim Meyering
646e37ff59 *** empty log message *** 2002-06-15 09:46:43 +00:00
Jim Meyering
bf7c8ba557 (trap): Make sure the temporary hierarchy is writable before removing it. 2002-06-15 09:46:32 +00:00
Jim Meyering
59f339c1f8 Use better trap.
trap 'status=$?; cd $pwd; chmod -R 700 $t0; rm -rf $t0 && exit $status' 0
2002-06-15 09:45:05 +00:00
Jim Meyering
2309be536f Use quoted here doc by default,
so e.g., backticks don't need to be escaped.
2002-06-15 09:41:47 +00:00
Jim Meyering
14c7cfea4c (TESTS): Add perm-1. 2002-06-15 09:40:25 +00:00
Jim Meyering
6f809229ef *** empty log message *** 2002-06-15 09:40:07 +00:00
Jim Meyering
f09cbdc4b4 *** empty log message *** 2002-06-15 08:47:55 +00:00
Jim Meyering
ef159d5cdb . 2002-06-15 08:47:25 +00:00
Jim Meyering
58e6f3d386 *** empty log message *** 2002-06-15 08:47:12 +00:00
Jim Meyering
39237a241f (lstat.c, stat.c, .sin.sed): Use t-$@, rather than $@-t,
so that each temporary file name is unique and valid in the first
8 characters, for operation under DOS.
2002-06-15 08:46:59 +00:00
Jim Meyering
8ba0cddae4 (FILE_TYPE_H): Guard entire contents with #ifndef.
For GNU libc 2.2 and newer, ensure that <sys/types.h> and <sys/stat.h>
have been included before this file.
2002-06-15 08:43:45 +00:00
Jim Meyering
13221a5a13 For GNU libc 2.2 and newer, ensure that <sys/types.h>
has been included before this file.
2002-06-15 08:40:55 +00:00
Jim Meyering
3351c8aada . 2002-06-15 08:04:23 +00:00
Jim Meyering
19548deac9 Change temp file names to accommodate DOS 8.3 file name limitation. 2002-06-15 08:03:24 +00:00
Jim Meyering
ff43f6b441 Change temp. file name: s/\.err/_err/, for DOS. 2002-06-15 08:02:16 +00:00
Jim Meyering
1d51d96e1e Change temp file names to accommodate DOS 8.3 file name limitation. 2002-06-15 08:01:41 +00:00
Jim Meyering
140f272a56 Remove leading `.' from temp. names. 2002-06-15 08:01:20 +00:00
Jim Meyering
9da59fff0d Change temp file names to accommodate DOS 8.3 file name limitation. 2002-06-15 07:56:40 +00:00
Jim Meyering
06b1f74288 *** empty log message *** 2002-06-15 07:37:29 +00:00
Jim Meyering
dbb90872ee (S_ISLNK): Define to 0 if neither S_ISLNK nor S_IFLNK is defined. 2002-06-15 07:37:21 +00:00
Jim Meyering
cb8155615a (S_ISLNK): Define to 0 if neither S_ISLNK nor S_IFLNK is defined. 2002-06-15 07:36:57 +00:00
Jim Meyering
b29576f01f *** empty log message *** 2002-06-15 06:54:05 +00:00
Jim Meyering
d404816448 (S_ISNAM): Add to list of S_IS* macros.
Rearrange #if directives for each S_IS macro.
From diffutils-2.8.2.
2002-06-15 06:53:57 +00:00
Jim Meyering
02d8535f9e *** empty log message *** 2002-06-14 07:53:01 +00:00
Jim Meyering
dfe88896b5 Use the version from diffutils-2.8.2. 2002-06-14 07:52:32 +00:00
Jim Meyering
0f19d3650b update from master sources 2002-06-13 09:30:02 +00:00
Jim Meyering
10c95a54b5 tweak expected message 2002-06-12 08:02:12 +00:00
Jim Meyering
f849e0aaac (do_move): Give one diagnostic, not two, when unable to
unlink a destination file.  This bug was introduced in fileutils-3.16l.

$ /bin/mv /etc/passwd /tmp
/bin/mv: cannot unlink `/etc/passwd': Permission denied
/bin/mv: cannot remove `/etc/passwd': Permission denied
[Exit 1]
2002-06-12 08:01:48 +00:00
Jim Meyering
7e6aff288f (rm): Fix typo in assertion. 2002-06-12 08:00:50 +00:00
Jim Meyering
c5b3b8e2b6 tweak output: s/ directory// 2002-06-07 14:57:19 +00:00
Jim Meyering
e20a6cfb82 *** empty log message *** 2002-06-07 14:49:33 +00:00
Jim Meyering
bae1890d5b Also accept the permission-denied diagnostic
issued by some losing systems.  Reported by Volker Borchert.
2002-06-07 14:49:21 +00:00
Jim Meyering
b2816db207 . 2002-06-07 14:44:02 +00:00
Jim Meyering
2e6f8bf01e *** empty log message *** 2002-06-07 14:43:41 +00:00
Jim Meyering
a3eb51b0e2 (jm_PREREQ_STAT): Check for sys/param.h and sys/mount.h.
They're needed at least for NetBSD 1.5.2.
($statxfs_includes): Include those same headers.
($statxfs_includes): Include sys/vfs.h if available.
($statxfs_includes): Likewise for sys/statvfs.h.
Check for the following members in both structs statfs and statvfs:
f_basetype, f_type, f_fsid.__val, f_namemax, f_namelen.
2002-06-07 14:43:36 +00:00
Jim Meyering
6d3ea70cf7 *** empty log message *** 2002-06-07 14:39:21 +00:00
Jim Meyering
b965b62436 (remove_entry): Use DT_IS_DIR only if
HAVE_STRUCT_DIRENT_D_TYPE is defined.
2002-06-07 14:39:09 +00:00
Jim Meyering
8bd3e55a54 . 2002-06-06 07:48:26 +00:00
Jim Meyering
cb93da5115 *** empty log message *** 2002-06-03 11:07:02 +00:00
Jim Meyering
9897e1994c (rm invocation): Add the warning (also in the --help output)
that the contents of a removed file are often recoverable.
2002-06-03 11:06:58 +00:00
Jim Meyering
52fc0276d7 *** empty log message *** 2002-06-02 21:30:07 +00:00
Jim Meyering
ce73721712 (enum RM_status) [RM_NONEMPTY_DIR]: New member.
(UPDATE_STATUS): New macro.
Include save-cwd.h.
(struct File_spec): Remove declaration.
Update prototypes.
2002-06-02 21:28:41 +00:00
Jim Meyering
0f6d0c6016 (main): Adapt to new calling sequence for rm. 2002-06-02 20:50:33 +00:00
Jim Meyering
a4b18d8961 (do_move): Adapt to new calling sequence for rm. 2002-06-02 20:50:20 +00:00
Jim Meyering
fb205872c1 Merge in all changes from no-recursion branch.
* src/remove.c (enum Ternary): Define type.
(prompt): Add a parameter.  Adjust callers.
(remove_entry): Attempt rmdir here, only if a directory is
`known' to be empty.  Significant rework.
(remove_dir): Propagate failure `up' also when rmdir fails.

In interactive mode, prompt only once about an empty directory.
* src/remove.c (enum Prompt_action): Define.
(prompt): Two new parameters.  Adjust all callers.

Performance.
* src/remove.c (remove_entry) [!ROOT_CAN_UNLINK_DIRS]:
Don't call rmdir here.

* src/remove.c (AD_pop_and_chdir): Don't use errno (it's not valid)
in diagnostic for changed dev/ino.
(remove_entry): Tweak diagnostic.

* src/remove.c (ROOT_CAN_UNLINK_DIRS): Define.
(AD_pop_and_chdir): Propagate status as we traverse back `up' the tree.
(DO_UNLINK, DO_RMDIR): Define.
(remove_entry) [ROOT_CAN_UNLINK_DIRS]: Add code so this works also on
systems where root can use `unlink' to remove directories.

* src/remove.c: Include file-type.h.
Include file type in prompt when asking whether to remove file.
Based on a patch from Paul Eggert.

* src/remove.c (prompt): Add comment.

* src/remove.c (remove_dir): Fix another (known) leak.

* src/remove.c (hash_freer): New function.
(AD_mark_helper): Use it.
(AD_mark_as_unremovable): xstrdup the filename argument.
(remove_dir): Free directory name.

* src/remove.c (remove_entry): Fail also when trying to remove a
directory without the --recursive option.
Change a diagnostic, s/unlink/remove/, now that it can apply also
to a directory.

* src/remove.c (is_empty_dir): New function.
(prompt): New function, factored out of...
(remove_entry): ...here.  Call it.
(remove_dir): Call prompt before rmdir.

* src/remove.c (remove_entry): Add support for prompting (e.g., -i).

* src/remove.h (UPDATE_STATUS): New macro.
* src/remove.c [AD_ent] (status): New member.  This lets us propagate
the status from a subdirectory to its parent via AD_pop_and_chdir.
(AD_push_initial): Set it.
(AD_push): Likewise.
(remove_cwd_entries): Change return type to enum RM_status, and
adjust all callers.
(rm): Use UPDATE_STATUS rather than open-coding it.

* src/remove.c (remove_entry): New function, factored out of...
(remove_cwd_entries): ...here, and...
(rm_1): ...here.

* src/remove.c (remove_cwd_entries): Add support for --verbose.
(remove_dir): Likewise.
(rm_1): Likewise.

* src/remove.c (rm): Free cwd_state, if necessary.

* src/remove.c (rm_1): Remove now useless (always true)
user_specified_name parameter.  Adjust sole caller.

* src/remove.c (rm): New function.  This interface allows
one to remove multiple arguments at a time.  This is important in
that it allows us to hide the remove_init/remove_fini functions and
the cwd_state parameter.
(rm_1): Renamed from rm.
(remove_init, remove_fini): Remove functions.  Each body is now
part of `rm'.
2002-06-02 20:49:03 +00:00
Jim Meyering
a4ff1d036d *** empty log message *** 2002-06-02 20:45:46 +00:00
Jim Meyering
26693888de . 2002-06-02 20:39:20 +00:00
Jim Meyering
63a8743830 (TESTS): Add rm5. 2002-06-02 20:39:00 +00:00
Jim Meyering
2ef6aec8ce Adjust, now that we no longer report `removing all entries of directory ...'. 2002-06-02 20:37:43 +00:00
Jim Meyering
d38d008a1d adjust 2002-06-02 20:36:19 +00:00
Jim Meyering
09184490e9 don't give a diagnostic about each parent 2002-06-02 20:35:07 +00:00
Jim Meyering
c27d78e6e0 *** empty log message *** 2002-06-01 09:38:48 +00:00
Jim Meyering
3b96dac1d7 Remove use of D_TYPE_IN_DIRENT, now that that symbol has been renamed. 2002-06-01 09:38:41 +00:00
Jim Meyering
c96356eba9 *** empty log message *** 2002-06-01 09:37:58 +00:00
Jim Meyering
1d478cbd05 (jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE): Rename macro:
s/D_TYPE_IN_DIRENT/HAVE_STRUCT_DIRENT_D_TYPE/.
2002-06-01 09:37:53 +00:00
Jim Meyering
10d0bbfbc7 *** empty log message *** 2002-06-01 08:41:31 +00:00
Jim Meyering
76c7142a55 *** empty log message *** 2002-05-30 07:50:19 +00:00
Jim Meyering
e913eebe7c (copy_reg): Use a temporary to avoid a warning
from gcc -W about comparison between signed and unsigned.
(copy_internal): Likewise, but use a cast.
2002-05-30 07:49:56 +00:00
Jim Meyering
79278d0cad . 2002-05-29 13:16:40 +00:00
Jim Meyering
8af3bb0443 more acronyms 2002-05-28 10:03:56 +00:00
Jim Meyering
e8b70f2823 *** empty log message *** 2002-05-28 08:50:57 +00:00
Jim Meyering
79e4cbd57a (jm_FUNC_READDIR): Undefine mkdir', not rmdir'. 2002-05-28 08:50:53 +00:00
Jim Meyering
0057fa16a4 use a better test 2002-05-27 21:38:21 +00:00
Jim Meyering
924d623ac8 *** empty log message *** 2002-05-27 20:05:16 +00:00
Jim Meyering
636fceb22a Use @acronym in place of most uses of @sc. 2002-05-27 20:05:03 +00:00
Jim Meyering
ab0ab21b2e (check-texinfo): Adapt to reflect that now we use @acronym{POSIX}. 2002-05-27 20:01:03 +00:00
Jim Meyering
625d533476 *** empty log message *** 2002-05-27 16:44:12 +00:00
Jim Meyering
2eef2b57dd (AC_FUNC_GETTIMEOFDAY_CLOBBER): Also replace localtime. 2002-05-27 16:44:07 +00:00
Jim Meyering
faa8bced59 *** empty log message *** 2002-05-27 16:43:00 +00:00
Jim Meyering
d2be1268c4 Fix a problem seen only on nonconforming systems whereby ls.c's
use of localtime, and then of gettimeofday would cause trouble:
the localtime call used to initialize rpl_gettimeofday's save
mechanism would clobber ls's current local time information so
that in any long listing the first file would always be listed
with date 1970-01-01.  Analysis by Volker Borchert.

(localtime): Undefine.
(rpl_localtime): New function.
2002-05-27 16:42:55 +00:00
Jim Meyering
c75c72a9fc *** empty log message *** 2002-05-27 15:09:34 +00:00
Jim Meyering
fc1018de0e (jm_FUNC_READDIR): Undefine `rmdir' so we don't try to
use the replacement function; it wouldn't resolve at link time.
Reported by Volker Borchert.
2002-05-27 15:09:29 +00:00
Jim Meyering
7ec9be427c *** empty log message *** 2002-05-26 15:29:17 +00:00
Jim Meyering
5e15547dad Use @acronym in place of most uses of @sc. 2002-05-26 15:29:10 +00:00
Jim Meyering
e9f9963e6b fix typo: s/S_TYPEISTMO/S_TYPEISMQ/ 2002-05-25 22:42:05 +00:00
Jim Meyering
ad9071c4ba fix typo 2002-05-25 22:39:13 +00:00
Jim Meyering
0ef5b0241e remove typo 2002-05-25 22:39:07 +00:00
Jim Meyering
ef71f8a52d Adapt for changed format of --verbose output. 2002-05-24 16:40:33 +00:00
Jim Meyering
4c9753bdf7 . 2002-05-24 14:09:45 +00:00
Jim Meyering
e8e002ad91 *** empty log message *** 2002-05-24 09:01:11 +00:00
Jim Meyering
36efe03850 *** empty log message *** 2002-05-24 08:59:17 +00:00
Jim Meyering
37877a3b9c renamed from nice 2002-05-24 08:37:05 +00:00
Jim Meyering
81c4b1fcff *** empty log message *** 2002-05-24 08:26:57 +00:00
Jim Meyering
516c58c84c *** empty log message *** 2002-05-24 08:24:37 +00:00
Jim Meyering
f930c9ca0e (validate_path): Compare the result of the function --
not its (constant) address -- against zero.
2002-05-24 08:24:29 +00:00
Jim Meyering
8e1915ff14 test for fix in 2.0.13 2002-05-24 08:23:19 +00:00
Jim Meyering
710a1bc347 *** empty log message *** 2002-05-24 07:41:19 +00:00
Jim Meyering
c55ed2c0a9 . 2002-05-23 07:02:11 +00:00
Jim Meyering
f08e272c8b tweak for new diagnostics
add a nonempty file
2002-05-22 09:49:14 +00:00
Jim Meyering
c2e4117240 Include "file-type.h", etc. 2002-05-22 08:39:30 +00:00
Jim Meyering
90e0ba933e *** empty log message *** 2002-05-22 08:38:33 +00:00
Jim Meyering
b2615f2b7f *** empty log message *** 2002-05-22 08:38:30 +00:00
Jim Meyering
ae6d164b7a . 2002-05-22 08:37:58 +00:00
Jim Meyering
0e7a38dbbe (libfetish_a_SOURCES): Add file-type.c and file-type.h. 2002-05-22 08:37:35 +00:00
Jim Meyering
1be69adaeb *** empty log message *** 2002-05-22 08:36:32 +00:00
Jim Meyering
925390f0bf (S_ISREG, S_ISDIR): Define if not already defined.
(S_TYPEISSEM, S_TYPEISSHM, S_TYPEISTMO): Likewise.
2002-05-22 08:35:31 +00:00
Jim Meyering
92255513cd (file_type): New file/function. Extracted from diffutils. 2002-05-22 07:49:35 +00:00
Jim Meyering
42e9ac45ff *** empty log message *** 2002-05-22 07:33:54 +00:00
Jim Meyering
eaa373aeb6 [struct dummy]: Renamed. Don't rely on portability of
zero-length arrays.  Instead, use sizes of -1 or +1.
2002-05-22 07:33:43 +00:00
Jim Meyering
cea518eba5 *** empty log message *** 2002-05-21 23:15:19 +00:00
Jim Meyering
fdadb32d0a (S_ISLNK, S_ISFIFO, S_ISSOCK, S_ISCHR, S_ISBLK, S_ISDOOR): Define here instead. 2002-05-21 23:15:05 +00:00
Jim Meyering
b2cb94b93c (S_ISLNK, S_ISFIFO S_ISSOCK S_ISCHR S_ISBLK S_ISDOOR): Remove definitions. 2002-05-21 23:14:42 +00:00
Jim Meyering
c09bf755a6 . 2002-05-21 23:08:27 +00:00
Jim Meyering
137f240e4a . 2002-05-21 23:02:51 +00:00
Jim Meyering
59d5765b0f (TESTS): Add rm1, rm2, rm3, rm4. 2002-05-21 22:59:16 +00:00
Jim Meyering
0ded127f4c . 2002-05-21 22:58:48 +00:00
Jim Meyering
205cfe4695 *** empty log message *** 2002-05-14 21:31:48 +00:00
Jim Meyering
24f18f089d This bug was introduced with my change of 2000-10-22 (textutils-2.0.8).
(ulonglong_t): Move declaration to precede new use.
[enum size_spec] (N_SIZE_SPECS): New member.
(width_bytes): Add initializer corresponding to ulonglong_t type.
(struct assert_width_bytes_matches_size_spec_decl): Declare.
Based on a patch from Tony Kocurko.
2002-05-14 21:31:42 +00:00
Jim Meyering
61dd314ba4 *** empty log message *** 2002-05-14 21:22:57 +00:00
Jim Meyering
24a893ff63 undo last delta -- it belongs on the no-recursion branch 2002-05-13 08:50:50 +00:00
Jim Meyering
ef0776dddd . 2002-05-13 08:50:15 +00:00
Jim Meyering
6095c9a3f8 *** empty log message *** 2002-05-12 21:47:24 +00:00
Jim Meyering
ebc0c4c72f Add FIXME comment. 2002-05-03 11:46:59 +00:00
Jim Meyering
65e6baf5a9 (print_uptime): Fix last change so that we use ngettext properly. 2002-05-03 11:17:01 +00:00
Jim Meyering
072ec8dc77 (print_uptime): Use ngettext for day/days and user/users.
Suggestion from Karl Eichwalder.
2002-05-03 09:58:37 +00:00
Jim Meyering
ef8e614b04 *** empty log message *** 2002-05-03 08:13:18 +00:00
Jim Meyering
d51a8422a2 *** empty log message *** 2002-05-03 08:13:09 +00:00
Jim Meyering
7b53d3d127 (usage): Add a little to the description of --list.
Uncapitalize first word and remove period at end of each one line
option description.
2002-05-03 08:12:25 +00:00
Jim Meyering
36d90a4f13 *** empty log message *** 2002-05-03 06:57:52 +00:00
Jim Meyering
09d4a8f165 (usage): Tweak description of --users.
From Karl Eichwalder.
2002-05-03 06:57:43 +00:00
Jim Meyering
c7475ee11e *** empty log message *** 2002-05-01 14:23:15 +00:00
Jim Meyering
2431a66944 . 2002-05-01 14:22:33 +00:00
Jim Meyering
b016bc2d4f . 2002-05-01 11:49:03 +00:00
Jim Meyering
bdd9db581f *** empty log message *** 2002-05-01 06:56:32 +00:00
Jim Meyering
29fbbc05c9 *** empty log message *** 2002-05-01 06:54:38 +00:00
Jim Meyering
2a061153f6 *** empty log message *** 2002-05-01 06:53:45 +00:00
Jim Meyering
8bbc4ca7ec *** empty log message *** 2002-05-01 06:51:55 +00:00
Jim Meyering
56130b3231 *** empty log message *** 2002-04-30 09:45:48 +00:00
Jim Meyering
5a40d9ead2 (jm_PREREQ): Add jm_PREREQ_STAT. 2002-04-30 09:37:26 +00:00
Jim Meyering
13d897efcf *** empty log message *** 2002-04-30 09:30:13 +00:00
Jim Meyering
0c4c742189 (keycompare, compare): Replace #ifdef ENABLE_NLS with if (HAVE_SETLOCALE).
(hard_LC_COLLATE): Define even if ! ENABLE_NLS.
(main): Always initialize hard_LC_COLLATE.
Put initialization next to other locale-related stuff.

Include <langinfo.h> even if ! ENABLE_NLS.
(decimal_point, th_sep): Depend on HAVE_SETLOCALE, not ENABLE_NLS.
(main): Likewise.
(MONTHTAB_CONST): Remove; all uses removed.
(struct_month_cmp, inittables): Do not depend on ENABLE_NLS.
(main): hard_LC_TIME locale does not depend on ENABLE_NLS.
2002-04-30 09:29:45 +00:00
Jim Meyering
9d64f63aaa (keycmp): Replace #ifdef ENABLE_NLS with if (HAVE_SETLOCALE).
(hard_LC_COLLATE): Define even if ! ENABLE_NLS.
(main): Always initialize hard_LC_COLLATE.
Put initialization next to other locale-related stuff.
2002-04-30 09:25:37 +00:00
Jim Meyering
d7984a3fdb (compare_files): Replace #ifdef ENABLE_NLS with if (HAVE_SETLOCALE).
(hard_LC_COLLATE): Define even if ! ENABLE_NLS.
(main): Always initialize hard_LC_COLLATE.
Put initialization next to other locale-related stuff.
2002-04-30 09:23:38 +00:00
Jim Meyering
17d3a3e28c (HAVE_SETLOCALE): Define to 0 if not defined. 2002-04-30 09:21:21 +00:00
Jim Meyering
20ee294371 *** empty log message *** 2002-04-30 09:20:32 +00:00
Jim Meyering
6e40a95415 *** empty log message *** 2002-04-30 09:20:26 +00:00
Jim Meyering
24ad720079 (jm_PREREQ_HARD_LOCALE): Check for stdlib.h.
Do not check for alloca.h (no longer used) or stdbool.h (was never
used?).  Add AM_C_PROTOTYPES since hard-locale.h uses it.
2002-04-30 09:20:19 +00:00
Jim Meyering
bb3842917c *** empty log message *** 2002-04-30 09:18:24 +00:00
Jim Meyering
9c46845348 Upgrade to version used in GNU Diffutils 2.8.1. 2002-04-30 09:17:50 +00:00
Jim Meyering
2cc5a65c0f *** empty log message *** 2002-04-29 08:23:14 +00:00
Jim Meyering
15bef4ddb6 (tail_forever): Do not treat
max_n_unchanged_stats_between_opens specially (as if it were
infinite) if it has its maximal value.  Similarly for
max_n_consecutive_size_changes_between_opens.
2002-04-29 08:23:06 +00:00
Jim Meyering
5ce88fe525 *** empty log message *** 2002-04-29 07:31:56 +00:00
Jim Meyering
676991e630 (parse_obsolescent_option): Do not limit the maximum
line/byte count to be less than ULONG_MAX on systems where
OFF_T_MAX is larger.
2002-04-29 07:30:57 +00:00
Jim Meyering
f3959d84d3 *** empty log message *** 2002-04-29 07:02:21 +00:00
Jim Meyering
86459445f9 *** empty log message *** 2002-04-29 07:01:34 +00:00
Jim Meyering
ad0f322065 (jm_PREREQ_SIG2STR): Remove; all callers changed. 2002-04-29 07:01:29 +00:00
Jim Meyering
735b546108 Do not include <sys/wait.h>; no longer needed. 2002-04-29 07:00:23 +00:00
Jim Meyering
94650aa4ba (SIGNUM_BOUND): Do not use WTERMSIG, to avoid
depending on <sys/wait.h> and WTERMSIG.  Default to 64 instead
of 127, since 64 is the largest conceivable number for ancient
nonstandard hosts.
2002-04-29 06:59:24 +00:00
Jim Meyering
786fcaf4a2 *** empty log message *** 2002-04-28 23:54:55 +00:00
Jim Meyering
eae0819e3d add comment for prev change 2002-04-28 23:54:47 +00:00
Jim Meyering
550a02c909 (make_id_equals_comment): Cast sizeof expression (used as field
width argument) to `int'.
2002-04-28 23:54:06 +00:00
Jim Meyering
1e2a59b68a (PIDSTR_DECL_AND_INIT): Cast ut_pid value to int. 2002-04-28 23:47:53 +00:00
Jim Meyering
7fb3529376 . 2002-04-28 23:14:28 +00:00
Jim Meyering
3a898d66ba *** empty log message *** 2002-04-28 23:14:20 +00:00
Jim Meyering
699c46f88b *** empty log message *** 2002-04-28 23:12:01 +00:00
Jim Meyering
5565903d7c (jm_MACROS): Remove use of AC_FUNC_STRNLEN. 2002-04-28 23:11:56 +00:00
Jim Meyering
c14da32ec4 Add jm_PREREQ_STRNLEN.
Use AC_FUNC_STRNLEN here instead.
2002-04-28 23:11:45 +00:00
Jim Meyering
db37e581bc Don't AC_REQUIRE([AC_PROG_CC_STDC]).
With autoconf-2.53a, it's part of AC_PROG_CC.
2002-04-28 22:36:42 +00:00
Jim Meyering
75bb9f0a2a *** empty log message *** 2002-04-28 21:59:47 +00:00
Jim Meyering
89e4bfabcd Don't include xalloc.h.
It's already included via system.h.
2002-04-28 21:59:40 +00:00
Jim Meyering
57b792bb8a . 2002-04-28 21:58:19 +00:00
Jim Meyering
625cb88756 *** empty log message *** 2002-04-28 21:57:52 +00:00
Jim Meyering
01084fbd8d Change @code{PROG}' to @command{PROG}'. 2002-04-28 21:57:40 +00:00
Jim Meyering
219be37b93 Change @code{PROG} to @command{PROG} for the fileutils. 2002-04-28 21:55:03 +00:00
Jim Meyering
3be197ed19 Begin changing @code{PROG} to @command{PROG}. 2002-04-28 21:46:20 +00:00
Jim Meyering
2bac14f45a Use @command{(un)?link}, not @code{...} where appropriate 2002-04-28 21:35:55 +00:00
Jim Meyering
ed05aed044 Rewrite from scratch. Support everything
required by POSIX 1003.1-2001; when this conflicts with Bash,
stick with POSIX.  The conflicts are kill -l output format,
and lower case signal names preceded by `-' (e.g., "kill -hup"
is no longer supported).  Remove -L or --long-list option.
Add -t or --table option.  Rename --sigspec to --signal;
remove --signum and do not advertise obsolescent option -n.
Use str2sig and str2sig to convert between signal names and
numbers.
2002-04-28 21:32:36 +00:00
Jim Meyering
02be728995 . 2002-04-28 21:31:21 +00:00
Jim Meyering
cb75a8c02d *** empty log message *** 2002-04-28 21:30:59 +00:00
Jim Meyering
f7978a042c (jm_PREREQ): Add jm_PREREQ_SIG2STR. 2002-04-28 21:30:50 +00:00
Jim Meyering
6980e29da9 (jm_MACROS): Add AC_REPLACE_FUNCS(sig2str). 2002-04-28 21:29:39 +00:00
Jim Meyering
79d4ae4bf8 *** empty log message *** 2002-04-28 21:28:56 +00:00
Jim Meyering
03d0ba4c06 Remove definition of unused WTERMSIG. 2002-04-28 21:20:49 +00:00
Jim Meyering
b41ca51fc6 New file: from Paul Eggert. 2002-04-28 21:17:45 +00:00
Jim Meyering
8e6c9373c1 *** empty log message *** 2002-04-28 21:16:24 +00:00
Jim Meyering
dbaf821f82 (libfetish_a_SOURCES): Add sig2str.h. 2002-04-28 21:16:19 +00:00
Jim Meyering
b8b5ed3d52 *** empty log message *** 2002-04-28 21:15:37 +00:00
Jim Meyering
8075fc59b5 *** empty log message *** 2002-04-28 21:15:05 +00:00
Jim Meyering
d22026207c (kill invocation): Document the above.
Document POSIX signals better.
2002-04-28 21:14:59 +00:00
Jim Meyering
b5d5f6fffd *** empty log message *** 2002-04-28 21:07:11 +00:00
Jim Meyering
e464e1da1c Avoid new warnings from gcc.
[struct COLUMN] <name>: Declare member to be const.
(init_fps): Declare local variable `firstname' to be const.
2002-04-28 21:07:01 +00:00
Jim Meyering
ec4ea625c9 . 2002-04-28 18:43:52 +00:00
Jim Meyering
38fa93be81 *** empty log message *** 2002-04-28 17:29:12 +00:00
Jim Meyering
a1319f687c (integer_expected_error): Add `const' to paramater
declarations to avoid new warning from gcc.
2002-04-28 17:12:53 +00:00
Jim Meyering
059c9672ff (test_syntax_error): Add `const' to paramater
declarations to avoid new warning from gcc.
2002-04-28 17:09:12 +00:00
Jim Meyering
8a2075ba7d (cycle_check): Add a comment. 2002-04-27 06:46:18 +00:00
Jim Meyering
a6050a7291 (cycle_check): New function containing code factored
out of remove_dir.  The sole difference is that upon detecting a
cycle, rm now dies unconditionally.  Before, in interactive mode,
it would ask the user whether to continue.
(remove_dir): Call cycle_check.
2002-04-27 06:33:08 +00:00
Jim Meyering
d1cf325739 *** empty log message *** 2002-04-25 20:38:20 +00:00
Jim Meyering
6cc8245afb (usage): Adjust ordering to match that of default output. 2002-04-25 20:38:16 +00:00
Jim Meyering
93066fab51 *** empty log message *** 2002-04-25 20:16:15 +00:00
Jim Meyering
daeef68961 remove comment for reverted change 2002-04-25 19:51:40 +00:00
Jim Meyering
c5e9725e5b . 2002-04-25 19:47:08 +00:00
Jim Meyering
e94bd40348 . 2002-04-25 18:58:39 +00:00
Jim Meyering
6576e27321 . 2002-04-25 18:58:07 +00:00
Jim Meyering
d29bfd529e *** empty log message *** 2002-04-25 18:03:30 +00:00
Jim Meyering
e758541f7e *** empty log message *** 2002-04-25 18:03:07 +00:00
Jim Meyering
0cf2e85eda *** empty log message *** 2002-04-25 18:02:59 +00:00
Jim Meyering
de9a50b611 Avoid warnings from gcc.
Declare input_file and output_file to be `const'.
(skip): Declare `file' parameter to be `const', too.
2002-04-25 18:02:52 +00:00
Jim Meyering
b6dd48b361 *** empty log message *** 2002-04-25 17:14:28 +00:00
Jim Meyering
184edc32ab *** empty log message *** 2002-04-25 16:40:18 +00:00
Jim Meyering
0199003cf9 Remove hash table, active_dir_map, used to detect directory cycles.
Instead, detect them lazily with just O(1) memory.
Suggestion from Andi Kleen.

(is_power_of_two): New function.
(print_nth_dir, make_active_dir_ent): Remove functions.
(hash_active_dir_ent, hash_compare_active_dir_ents): Likewise.
(remove_dir): Check for cycles here, ...
(rm): ... and don't check for cycles here.

(rm): Call fspec_get_full_mode here, rather than
fspec_get_filetype_mode.  We want to get the dev/ino earlier, and
at the same time as when we get the file type, to avoid the risk
that an attacker would change e.g. a directory to a symlink before
we record its dev/ino.
2002-04-25 16:40:04 +00:00
Jim Meyering
bbd396f52f Revert last change. 2002-04-25 16:32:32 +00:00
Jim Meyering
2a15b5cbc4 Revert last change. 2002-04-25 16:31:41 +00:00
Jim Meyering
2dbf41d0d0 *** empty log message *** 2002-04-25 16:01:32 +00:00
Jim Meyering
c80374e8e8 . 2002-04-25 15:40:12 +00:00
Jim Meyering
e53320438b *** empty log message *** 2002-04-25 15:39:39 +00:00
Jim Meyering
1bb22e3075 Remove ENABLE_NLS-related code.
(_, N_) Remove definitions.
Include "gettext.h" instead.
2002-04-25 15:38:17 +00:00
Jim Meyering
fc7d0fef5f *** empty log message *** 2002-04-24 07:54:51 +00:00
Jim Meyering
b2861672f1 filtered through cppi 2002-04-24 07:54:40 +00:00
Jim Meyering
9cd1ed4307 *** empty log message *** 2002-04-24 07:52:49 +00:00
Jim Meyering
8a054458d4 (INCLUDES): Remove -I../intl.
(libfetish_a_SOURCES): Add gettext.h.
2002-04-24 07:52:39 +00:00
Jim Meyering
570703fb5e *** empty log message *** 2002-04-24 07:50:53 +00:00
Jim Meyering
0b79c81d9d (jm_PREREQ_HARD_LOCALE): New macro.
(jm_PREREQ): Use it.
2002-04-24 07:50:48 +00:00
Jim Meyering
6acdf37888 bump serial # to 9 2002-04-24 07:49:39 +00:00
Jim Meyering
1391eaea5d Check for these headers: locale.h unistd.h mach/mach.h fcntl.h.
Check for this function: setlocale.
2002-04-24 07:49:00 +00:00
Jim Meyering
d3de1d0186 (rm): Call exit with EXIT_FAILURE, not `1'. 2002-04-22 09:42:00 +00:00
Jim Meyering
a15c26266f *** empty log message *** 2002-04-22 07:36:00 +00:00
Jim Meyering
c32c344dd6 (main): Adjust caller of remove_init. 2002-04-22 07:35:54 +00:00
Jim Meyering
e305ef0fa8 (do_move): Adjust caller of remove_init. 2002-04-22 07:35:41 +00:00
Jim Meyering
f1014ac7cc (remove_init): Adjust prototype. 2002-04-22 07:35:32 +00:00
Jim Meyering
8fd6feded9 (rm, remove_init, remove_fini): Don't use or even
initialize the active_dir_map unless --recursive (-r) is specified.
2002-04-22 07:35:20 +00:00
Jim Meyering
c175e3f6c8 update framework 2002-04-20 14:49:46 +00:00
Jim Meyering
73f2d11007 update framework 2002-04-19 22:57:04 +00:00
Jim Meyering
f2bb69ebb0 Use this:
(exit $fail); exit
not this:
  exit $fail
2002-04-19 22:50:36 +00:00
Jim Meyering
0129239343 upgrade to use better framework 2002-04-19 22:41:59 +00:00
Jim Meyering
92d76e1e92 upgrade to use better framework 2002-04-19 22:39:05 +00:00
Jim Meyering
dc2f3bc5e4 *** empty log message *** 2002-04-19 22:36:11 +00:00
Jim Meyering
1a35394a57 upgrade to use better framework 2002-04-19 22:36:03 +00:00
Jim Meyering
2b5e6e4835 clean-up 2002-04-19 21:59:57 +00:00
Jim Meyering
306c8e8b4f Lots of clean-up:
E.g.,

    (exit $fail); exit

    t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
    trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
2002-04-19 21:55:30 +00:00
Jim Meyering
3cc80a4390 *** empty log message *** 2002-04-19 21:54:27 +00:00
Jim Meyering
ff015c529a *** empty log message *** 2002-04-19 21:53:42 +00:00
Jim Meyering
ebf16be3ea Use tmpdir named $0.tmp/$$. Create with mkdir -p. 2002-04-19 21:53:01 +00:00
Jim Meyering
4061c49579 Use better trap, etc. 2002-04-19 21:38:32 +00:00
Jim Meyering
d01146b817 *** empty log message *** 2002-04-19 21:18:28 +00:00
Jim Meyering
d0ae660607 Use better trap. 2002-04-19 21:17:45 +00:00
Jim Meyering
5aaccdf6a7 use better trap 2002-04-19 21:17:08 +00:00
Jim Meyering
dc3a2321e0 Set $tmp the new way. 2002-04-19 20:50:43 +00:00
Jim Meyering
3f094fd26b Use `rm', not $RM. Use better trap. 2002-04-19 19:55:21 +00:00
Jim Meyering
e86cf7f5e6 Use `rm', not $RM. Use better trap. 2002-04-19 19:54:15 +00:00
Jim Meyering
ad9fd82850 Use `rm', not $RM. Use better trap. 2002-04-19 19:53:03 +00:00
Jim Meyering
da5debc995 don't fiddle with TMPDIR 2002-04-19 19:51:29 +00:00
Jim Meyering
9f79f8d7e0 don't bother with TMPDIR 2002-04-19 19:47:16 +00:00
Jim Meyering
56931437e3 Use automatically-derived name for temporary
directory.  This is more 8.3-friendly.  Based on a suggestion from Richard Dawe.
2002-04-19 19:39:45 +00:00
Jim Meyering
5051a33ba6 *** empty log message *** 2002-04-17 08:55:39 +00:00
Jim Meyering
8d851e17c0 . 2002-04-17 08:54:38 +00:00
Jim Meyering
1df5e317dc (TESTS): Add no-create-missing. 2002-04-17 08:54:32 +00:00
Jim Meyering
950d7008ea *** empty log message *** 2002-04-17 08:54:21 +00:00
Jim Meyering
8a2d561e45 *** empty log message *** 2002-04-17 08:53:50 +00:00
Jim Meyering
ccf99a6d4c (touch): Don't report errors for nonexistent files
when --no-create is in effect.  Based on a patch from TAKAI Kousuke.
2002-04-17 08:49:27 +00:00
Jim Meyering
78ec76159b *** empty log message *** 2002-04-17 08:47:33 +00:00
Jim Meyering
28ea23054e s/POSIX/@sc{posix}/ 2002-04-16 11:26:32 +00:00
Jim Meyering
cea6ca618e *** empty log message *** 2002-04-16 10:43:04 +00:00
Jim Meyering
a9ecff59e4 (jm_PREREQ_READUTMP): Also check for these members: ut_pid, ut_id, ut_exit. 2002-04-16 10:43:00 +00:00
Jim Meyering
b1f44ffb39 (UT_TYPE): Remove definition (now in who.c).
(HAVE_STRUCT_XTMP_UT_EXIT, HAVE_STRUCT_XTMP_UT_ID): Define.
(HAVE_STRUCT_XTMP_UT_PID, HAVE_STRUCT_XTMP_UT_TYPE): Define.
2002-04-16 10:41:33 +00:00
Jim Meyering
2e0e925d3b *** empty log message *** 2002-04-16 10:39:42 +00:00
Jim Meyering
6f0db0ac6e (UT_TYPE_UNDEF, UT_TYPE, IS_USER_PROCESS): Define.
(print_line): Use "%-8.8s" for the format: the user name is not
always NUL terminated.
(scan_entries) [need_users]: Use IS_USER_PROCESS, so that this works
even on systems without ut_type.
2002-04-16 10:39:29 +00:00
Jim Meyering
aef17cff0f (BOOT_TIME): Define.
(NEW_TIME): Define to 0, not INT_MAX.
(UT_PID, UT_ID, UT_EXIT_E_TERMINATION, UT_EXIT_E_EXIT): Define.
Replace literal uses of ut_pid, ut_id, and ut_exit members with
uses through macros.
(make_id_equals_comment): New function, factored out of three others.
2002-04-16 09:49:28 +00:00
Jim Meyering
92cad6a4e5 *** empty log message *** 2002-04-16 06:51:00 +00:00
Jim Meyering
5bd81eab0f (human_fstype): Rename from print_human_fstype, and rework accordingly.
(print_statfs): Use human_fstype to honor format width on %T.
2002-04-16 06:50:54 +00:00
Jim Meyering
598064934e Add copyright comment. 2002-04-16 06:27:39 +00:00
Jim Meyering
c75c37dc2b *** empty log message *** 2002-04-15 19:05:33 +00:00
Jim Meyering
67492390d4 *** empty log message *** 2002-04-15 19:04:32 +00:00
Jim Meyering
480aa4b7c1 *** empty log message *** 2002-04-15 19:03:52 +00:00
Jim Meyering
9a9958dafc Document kill. 2002-04-15 19:03:47 +00:00
Jim Meyering
2262fbb298 add FIXME comments 2002-04-15 10:46:45 +00:00
Jim Meyering
a36a4fdedc *** empty log message *** 2002-04-15 10:37:45 +00:00
Jim Meyering
57d75ea4d8 Include xalloc.h.
Use xmalloc everywhere, not malloc.
2002-04-15 10:37:35 +00:00
Jim Meyering
7880914895 *** empty log message *** 2002-04-15 08:52:52 +00:00
Jim Meyering
b214c8214c Handle "lld" vs "ld" printf formats the same way Bash does.
Include inttypes.h.
(PRIdMAX, PRIuMAX): Define, if not already defined.
(print_statfs): Use those macros, not the literal strings.
(print_stat): Likewise.
2002-04-15 08:50:57 +00:00
Jim Meyering
68f054be8f *** empty log message *** 2002-04-15 08:41:34 +00:00
Jim Meyering
d9feb76a02 (usage): Give a verbose description of --squeeze-repeats,
including the mention of SET1.
2002-04-15 08:41:23 +00:00
Jim Meyering
872325a656 *** empty log message *** 2002-04-15 07:21:49 +00:00
Jim Meyering
d133be1fc3 (print_human_fstype): Add missing break;' for case S_MAGIC_MINIX:'. 2002-04-15 07:21:42 +00:00
Jim Meyering
ad02a0f47d remove parens in #if directives 2002-04-15 07:20:15 +00:00
Jim Meyering
f7d204bce4 *** empty log message *** 2002-04-14 12:53:10 +00:00
Jim Meyering
2b38bcb26a *** empty log message *** 2002-04-14 12:53:00 +00:00
Jim Meyering
6d89182e28 (statfs_secure): Define.
(print_stat): Remove another #ifdef.
(do_statfs): Likewise.
(print_statfs): Prefer/use fputs over printf.
(print_stat): Likewise.
2002-04-14 12:52:48 +00:00
Jim Meyering
30215a98cc filter through GNU indent 2002-04-14 08:20:15 +00:00
Jim Meyering
c8088a6184 Split some long lines.
(verbose_usage): Remove function.
2002-04-14 08:18:49 +00:00
Jim Meyering
82395d065e *** empty log message *** 2002-04-14 08:15:22 +00:00
Jim Meyering
5120cb1bc9 remove parens in #if directives 2002-04-14 08:14:37 +00:00
Jim Meyering
e407204f28 fix TABs 2002-04-14 08:14:15 +00:00
Jim Meyering
af3fa53348 *** empty log message *** 2002-04-14 08:13:50 +00:00
Jim Meyering
4fc8280fa6 *** empty log message *** 2002-04-14 07:50:19 +00:00
Jim Meyering
9e92d099ce *** empty log message *** 2002-04-14 07:49:20 +00:00
Jim Meyering
7c3982f666 (verbose_usage): Remove function. Move contents into usage.
Remove lots of #if directives involving FLASK_LINUX
[!FLASK_LINUX] (is_flask_enabled): Define.
(stat_secure, lstat_secure): Define.
(print_statfs): Remove lots of nested #if directives.
Instead, rely on support fo %llu and %lld printf formats --
but that is only temporary, since it's not porable enough.
(main): Hoist is_flask_enabled test to be done here, rather
than in each of do_stat and do_statfs for every argument.
2002-04-14 07:47:44 +00:00
Jim Meyering
b6e520d478 [HAVE_SYS_VFS_H]: Guard incluion of sys/vfs.h.
Constify many parameters.
(print_statfs): Fix typo: Use %u (to match %lu) for namelen, not %d.
2002-04-14 06:55:13 +00:00
Jim Meyering
2c41df8b40 alphabetize entries in a menu
In xref, use libc instead of library.
2002-04-14 06:27:10 +00:00
Jim Meyering
86168539c7 . 2002-04-13 17:10:57 +00:00
Jim Meyering
d849f68245 add a couple `const' 2002-04-13 14:35:46 +00:00
Jim Meyering
91990a324b (print_human_fstype): Revamp in a similar fashion. Don't use strdup. 2002-04-13 14:34:58 +00:00
Jim Meyering
ac829d6935 (print_human_type): Call fputs once rather than calling printf many times.
Declare most functions to be `static'.
2002-04-13 14:23:00 +00:00
Jim Meyering
d1a60cddfe Include system.h, error.h, and many other headers.
[HAVE_SYS_SYSMACROS_H]: Guard inclusion of sys/sysmacros.h.
(PROGRAM_NAME, AUTHORS): Define.
(long_options): Declare/define.
(print_human_access): Rewrite to use mode_string.
(usage): Rewrite.
(main): Use getopt_long.
2002-04-13 14:11:44 +00:00
Jim Meyering
8d8acf4b3c Direct from Debian's stat_3.3-1, modulo trailing blanks (removed)
and cpp directive (indented via cppi).
2002-04-13 13:47:14 +00:00
Jim Meyering
fadc4d4786 *** empty log message *** 2002-04-13 12:40:43 +00:00
Jim Meyering
9eb27b5fad Document link and unlink. 2002-04-13 12:40:36 +00:00
Jim Meyering
b1e1f83089 *** empty log message *** 2002-04-12 21:03:34 +00:00
Jim Meyering
ad935391c2 (dirfd): Elide prototype if dirfd is a macro. 2002-04-12 21:03:28 +00:00
Jim Meyering
5f057a69d6 *** empty log message *** 2002-04-12 20:51:01 +00:00
Jim Meyering
d635ea46cb (checking for getmntinfo function...): Remove now-bogus
check for f_type in sys/mount.h.  Instead, just test for the existence
of the getmntinfo function.  Needed for Darwin 5.3.
2002-04-12 20:50:53 +00:00
Jim Meyering
51816f9adb *** empty log message *** 2002-04-12 20:48:36 +00:00
Jim Meyering
50bc2a4286 (UTILS_FUNC_DIRFD): Also detect when dirfd is a macro.
This is necessary at least on Darwin 5.3.
2002-04-12 20:48:29 +00:00
Jim Meyering
7f01432879 *** empty log message *** 2002-04-12 11:04:02 +00:00
Jim Meyering
d11a1de3ed *** empty log message *** 2002-04-12 11:03:13 +00:00
Jim Meyering
c6590a2f61 Don't AC_REPLACE(strnlen), now that we use
AC_FUNC_STRNLEN.  That would end up putting two copies of strnlen.o
in the library, and that makes some versions of ranlib object.
2002-04-12 11:02:59 +00:00
Jim Meyering
f5da3f584b *** empty log message *** 2002-04-12 10:47:18 +00:00
Jim Meyering
5771d0193b . 2002-04-12 10:46:55 +00:00
Jim Meyering
f52a204a4e Include long-options.h.
[long_opts]: Remove.
(usage): Tweak --help output; use *_OPTION_DESCRIPTION macros.
(main): Don't use getopt directly.  Use parse_long_options instead.
Tweak a diagnostic.
Use EXIT_FAILURE rather than a literal `1'.
(main): If POSIXLY_CORRECT is set, don't recognize --help or --version,
so the program can operate on a file with one of those names.
2002-04-12 10:41:54 +00:00
Jim Meyering
21126e288b Include long-options.h.
[long_opts]: Remove.
(usage): Tweak --help output; use *_OPTION_DESCRIPTION macros.
(main): Don't use getopt directly.  Use parse_long_options instead.
Tweak a diagnostic.
Use EXIT_FAILURE rather than a literal `1'.
2002-04-12 10:41:22 +00:00
Jim Meyering
d1aa15101c *** empty log message *** 2002-04-12 10:41:00 +00:00
Jim Meyering
92c4ad70ea *** empty log message *** 2002-04-12 10:40:09 +00:00
Jim Meyering
1247f879f9 *** empty log message *** 2002-04-12 10:39:43 +00:00
Jim Meyering
b46ec3cd33 from Debian's fileutils_4.1-10 2002-04-12 10:07:17 +00:00
Jim Meyering
f0ea374271 *** empty log message *** 2002-04-09 17:55:48 +00:00
Jim Meyering
72af85a647 (jm_FUNC_REALLOC): Change the `checking ...' message
to be more precise.  Rather than saying we're checking whether the
function `works', say what we're testing.
2002-04-09 17:55:36 +00:00
Jim Meyering
aa77b79b4b (jm_FUNC_MALLOC): Change the `checking ...' message
to be more precise.  Rather than saying we're checking whether the
function `works', say what we're testing.
2002-04-09 17:55:23 +00:00
Jim Meyering
f36cf8b4d8 *** empty log message *** 2002-04-08 09:39:19 +00:00
Jim Meyering
a8a0842148 Use new directives, @copying and @insertcopying,
thus now requiring texinfo-4.2 to create the .info file.
2002-04-08 09:38:58 +00:00
Jim Meyering
8c3b497f01 *** empty log message *** 2002-04-07 21:46:15 +00:00
Jim Meyering
61d6d975af Tweak comments to reflect reality. 2002-04-07 21:46:11 +00:00
Jim Meyering
b5422e71f7 *** empty log message *** 2002-04-07 15:57:10 +00:00
Jim Meyering
c20f3cd330 Add VERBOSE=yes support. 2002-04-07 15:52:14 +00:00
Jim Meyering
a88ba0dd94 Fix typo in VERBOSE=yes handling. 2002-04-07 15:51:12 +00:00
Jim Meyering
81c7cd4c29 . 2002-03-30 15:49:57 +00:00
Jim Meyering
f79efa913c with --reply=no, no need for input file `no' 2002-03-30 15:26:46 +00:00
Jim Meyering
8b861292c6 --, not --- 2002-03-30 15:22:04 +00:00
Jim Meyering
39f54be321 *** empty log message *** 2002-03-30 15:20:22 +00:00
Jim Meyering
9bfbfd3b8a *** empty log message *** 2002-03-30 15:19:04 +00:00
Jim Meyering
fff7466c36 Use --reply=no rather than -i.
The latter depends on whether stdin is a tty.
2002-03-30 15:18:54 +00:00
Jim Meyering
bd2fa30652 . 2002-03-30 10:40:32 +00:00
Jim Meyering
fffcc47efc . 2002-03-30 07:24:19 +00:00
Jim Meyering
302c89b285 (do_move): Correct a comment. 2002-03-30 07:12:23 +00:00
Jim Meyering
3dd09fbf17 *** empty log message *** 2002-03-30 07:11:34 +00:00
Jim Meyering
baa4aff633 (forget_created): Prototype. 2002-03-30 07:11:24 +00:00
Jim Meyering
aa3694f1ff (forget_created): New function. 2002-03-30 07:11:13 +00:00
Jim Meyering
9211474a6e (copy_internal): Move the block that sets `earlier_file'
down to just before the first use of that variable.  Otherwise, it was
possible to make mv (and probably cp, too) malfunction when copying
hard-linked files into a directory containing at least one of the
source file names.  Call forget_created everywhere thereafter where
this function returns without creating a destination file that might
subsequently be linked.  Reported by Iida Yosiaki.
2002-03-30 07:10:57 +00:00
Jim Meyering
ca76cd842a New test for the above.
Based on an example from Iida Yosiaki.
2002-03-29 23:11:41 +00:00
Jim Meyering
6879364228 (TESTS): Add i-link-no. 2002-03-29 23:11:28 +00:00
Jim Meyering
0a2845a592 *** empty log message *** 2002-03-29 23:09:52 +00:00
Jim Meyering
d4e06e8c46 *** empty log message *** 2002-03-28 08:07:41 +00:00
Jim Meyering
61789dd7d5 . 2002-03-28 07:59:24 +00:00
Jim Meyering
df92958bed *** empty log message *** 2002-03-27 08:05:14 +00:00
Jim Meyering
c559453c89 *** empty log message *** 2002-03-27 07:57:00 +00:00
Jim Meyering
65ab259cdb *** empty log message *** 2002-03-25 09:53:28 +00:00
Jim Meyering
563ff6778d update copyright 2002-03-25 09:53:18 +00:00
Jim Meyering
eae700da7d (age_of): Return -1 and 0 rather than 0 and 1.
Might as well keep it simple, and like bash.
(binary_operator): Fix bug with -nt and -ot, when one of the
files did not exist.  We want to be compatible with the ksh93
documentation, and with Bash.
2002-03-25 09:53:07 +00:00
Jim Meyering
dc3bf580fc *** empty log message *** 2002-03-25 09:52:46 +00:00
Jim Meyering
d2ed2e78cf (File characteristic tests): Document the
behavior of test -nt and -ot when one of the files does not exist,
using the same behavior that is documented in ksh93.
2002-03-25 09:52:25 +00:00
Jim Meyering
c799d7b979 adjust spacing in expected diagnostic 2002-03-19 09:55:21 +00:00
Jim Meyering
73c74c33e6 use only one space after semicolon 2002-03-19 08:49:28 +00:00
Jim Meyering
c1635e0379 . 2002-03-18 09:51:22 +00:00
Jim Meyering
2486f9acdf . 2002-03-18 09:50:45 +00:00
Jim Meyering
af1a8f76a6 *** empty log message *** 2002-03-17 19:28:04 +00:00
Jim Meyering
1c1565ff39 *** empty log message *** 2002-03-17 19:21:54 +00:00
Jim Meyering
c3d98f8640 (TESTS): Add part-fail. 2002-03-17 19:21:49 +00:00
Jim Meyering
cf504308fe *** empty log message *** 2002-03-17 19:21:24 +00:00
Jim Meyering
3677890d37 (usage): Mention that --format=FORMAT must be
a *floating-point* format, also in description of that option.
(usage): Also add the `=' signs here: --format=FORMAT,
--separator=STRING.
2002-03-17 19:21:16 +00:00
Jim Meyering
2af2bec9b2 *** empty log message *** 2002-03-17 16:18:35 +00:00
Jim Meyering
30f0e39058 *** empty log message *** 2002-03-17 16:17:38 +00:00
Jim Meyering
fc1e984e89 *** empty log message *** 2002-03-17 16:17:29 +00:00
Jim Meyering
24c61a8949 *** empty log message *** 2002-03-17 16:02:47 +00:00
Jim Meyering
b3354081ac (copy_internal) [move_mode]: Give a better diagnostic
(using errno from the failed unlink) when a cross-device `mv'
fails, e.g., because the destination cannot be unlinked.
Prompted by a report from Karl Berry.
2002-03-17 16:00:54 +00:00
Jim Meyering
aedb44867d *** empty log message *** 2002-03-16 09:47:01 +00:00
Jim Meyering
65a82e4c26 *** empty log message *** 2002-03-16 09:46:40 +00:00
Jim Meyering
28571ed121 *** empty log message *** 2002-03-16 09:43:19 +00:00
Jim Meyering
3a0036e766 . 2002-03-14 12:19:49 +00:00
Jim Meyering
fa0309e396 *** empty log message *** 2002-03-12 12:12:02 +00:00
201 changed files with 9895 additions and 3696 deletions

View File

@@ -273,9 +273,10 @@ move_if_change ?= move-if-change
# The following pseudo table associates a local directory and a URL
# with each of the files that belongs to some other package and is
# regularly updated from the specified URL.
wget_files ?= $(srcdir)/config.guess $(srcdir)/config.sub \
wget_files ?= $(srcdir)/config/config.guess \
$(srcdir)/config/config.sub \
$(srcdir)/src/ansi2knr.c \
$(srcdir)/doc/texinfo.tex
$(srcdir)/config/texinfo.tex
get-targets = $(patsubst %, get-%, $(wget_files))
config.guess-url_prefix = $(ftp-gnu)/config/
@@ -299,11 +300,12 @@ $(get-targets):
automake_repo=:pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake
.PHONY: wget-update
wget-update: $(get-targets)
for f in depcomp missing mkinstalldirs; do \
test -f $$f || continue; \
echo checking out $$f...; \
$(CVS) -d $(automake_repo) co -p automake/lib/$$f > $$f.t \
&& $(move_if_change) $$f.t $$f; \
cd config && \
for f in depcomp missing mkinstalldirs; do \
test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
echo checking out $$f...; \
$(CVS) -d $(automake_repo) co -p automake/lib/$$f > $$f.t \
&& $(move_if_change) $$f.t $$f; \
done
define emit-upload-commands

10
THANKS
View File

@@ -11,12 +11,15 @@ Adam Klein aklein@debian.org
Akim Demaille demaille@inf.enst.fr
Alain Magloire alain@qnx.com
Alan Iwi iwi@atm.ox.ac.uk
Albert Chin-A-Young china@thewrittenword.com
Albert Hopkins ahopkins@dynacare.com
Alberto Accomazzi alberto@cfa0.harvard.edu
aldomel aldomel@ix.netcom.com
Alen Muzinic zveki@fly.cc.fer.hr
Alexandre Duret-Lutz duret_g@epita.fr
Alexey Solovyov alekso@math.uu.se
Alfred M. Szmidt ams@kemisten.nu
Andi Kleen freitag@alancoxonachip.com
Andre Novaes Cunha Andre.Cunha@br.global-one.net
Andreas Gruenbacher ag@bestbits.at
Andreas Jaeger jaeger@gnu.org
@@ -113,6 +116,7 @@ Fr
Gabor Z. Papp gzp@gzp.org.hu
Galen Hazelwood galenh@micron.net
Gary Anderson ganderson@clark.net
Gaute Hvoslef Kvalnes gaute@verdsveven.com
Gaël Quéri gqueri@mail.dotcom.fr
Geoff Kuenning geoff@cs.hmc.edu
Geoff Odhner geoff@franklin.com
@@ -137,6 +141,7 @@ Ian Bruce ian.bruce@myrealbox.com
Ian Jackson ijackson@chiark.greenend.org.uk
Ian Lance Taylor ian@cygnus.com
Ian Turner vectro@pipeline.com
Iida Yosiaki iida@gnu.org
James james@albion.glarp.com
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
James Sneeringer jvs@ocslink.com
@@ -203,6 +208,7 @@ Manfred Hollstein manfred@s-direktnet.de
Marc Boucher marc@mbsi.ca
Marc Olzheim marcolz@stack.nl
Marco Franzen Marco.Franzen@Thyron.com
Marcus Brinkmann http://www.marcus-brinkmann.de
Marcus Daniels marcus@ee.pdx.edu
Mark A. Thomas thommark@access.digex.net
Mark D. Roth roth@uiuc.edu
@@ -238,6 +244,7 @@ Michael Gaughen mgaughen@polyserve.com
Michael Hasselberg mikelh@zonta.ping.de
Michael Hohn hohn@math.utah.edu
Michael J. Croghan mcroghan@usatoday.com
Michael Piefel piefel@informatik.hu-berlin.de
Michael Steffens michael.steffens@s.netic.de
Michael Stone mstone@debian.org
Michael Stutz stutz@dsl.org
@@ -308,14 +315,17 @@ Stephen Smoogen ??????????
Steve McConnel steve@acadcomp.sil.org
Stuart Kemp skemp@peter.bmc.com
Tadayoshi Funaba tadf@kt.rim.or.jp
TAKAI Kousuke takai@vlsi.kuee.kyoto-u.ac.jp
Theodore Ts'o tytso@rsts-11.mit.edu
Thomas Bushnell thomas@gnu.ai.mit.edu
Thomas Quinot thomas@Cuivre.FR.EU.ORG
Tim J. Robbins tjr@FreeBSD.org
Tim Smithers mouse@dmouse.com.au
Tim Waugh twaugh@redhat
Todd A. Jacobs tjacobs@codegnome.org
Tom Quinn trq@dionysos.thphys.ox.ac.uk
Ton Hospel thospel@mail.dma.be
Tony Kocurko akocurko@mun.ca
Tony Leneis tony@plaza.ds.adp.com
Tony Robinson ajr@eng.cam.ac.uk
Torbjorn Granlund tege@nada.kth.se

38
config/config.guess vendored
View File

@@ -3,7 +3,7 @@
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002 Free Software Foundation, Inc.
timestamp='2002-03-04'
timestamp='2002-05-29'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -98,7 +98,7 @@ trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int dummy(){}" > $dummy.c ;
for c in cc gcc c89 ; do
for c in cc gcc c89 c99 ; do
($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
if test $? = 0 ; then
CC_FOR_BUILD="$c"; break ;
@@ -142,6 +142,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
@@ -428,6 +429,9 @@ EOF
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit 0 ;;
Night_Hawk:*:*:PowerMAX_OS)
echo powerpc-harris-powermax
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
@@ -760,7 +764,7 @@ EOF
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -771,15 +775,15 @@ EOF
#undef CPU
#undef mips
#undef mipsel
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mipsel
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mipsel
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips
#else
CPU=
#endif
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
rm -f $dummy.c
@@ -917,13 +921,13 @@ EOF
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
@@ -958,7 +962,7 @@ EOF
exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0)
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -1059,12 +1063,12 @@ EOF
echo `uname -p`-apple-darwin${UNAME_RELEASE}
exit 0 ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
if test "${UNAME_MACHINE}" = "x86pc"; then
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
echo i386-${UNAME_MACHINE}-nto-qnx
else
echo `uname -p`-${UNAME_MACHINE}-nto-qnx
fi
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit 0 ;;
*:QNX:*:4*)
echo i386-pc-qnx

49
config/config.sub vendored
View File

@@ -3,7 +3,7 @@
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002 Free Software Foundation, Inc.
timestamp='2002-03-07'
timestamp='2002-06-20'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -230,23 +230,30 @@ case $basic_machine in
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
| c4x | clipper \
| d10v | d30v | dsp16xx \
| d10v | d30v | dlx | dsp16xx \
| fr30 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k \
| m32r | m68000 | m68k | m88k | mcore \
| mips | mips16 | mips64 | mips64el | mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el | mips64vr4300 \
| mips64vr4300el | mips64vr5000 | mips64vr5000el \
| mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \
| mipsisa32 | mipsisa64 \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mipsisa32 | mipsisa32el \
| mipsisa64 | mipsisa64el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| ns16k | ns32k \
| openrisc | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| sh | sh[34] | sh[34]eb | shbe | shle | sh64 \
| sh | sh[34] | sh[34]eb | shbe | shle | sh64 | sh64le \
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
| strongarm \
| tahoe | thumb | tic80 | tron \
@@ -281,31 +288,39 @@ case $basic_machine in
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armv*-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* \
| bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c54x-* \
| clipper-* | cydra-* \
| d10v-* | d30v-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fr30-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* \
| m32r-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | mcore-* \
| mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
| mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \
| mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipstx39 | mipstx39el \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \
| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
@@ -1090,7 +1105,7 @@ case $os in
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova*)
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* | -powermax*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1409,7 +1424,7 @@ case $basic_machine in
-ptx*)
vendor=sequent
;;
-vxsim* | -vxworks*)
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)

View File

@@ -207,18 +207,22 @@ aix)
;;
tru64)
# The Tru64 AIX compiler uses -MD to generate dependencies as a side
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
base=`echo "$object" | sed -e 's/\.o$/.d/' -e 's/\.lo$/.d/'`
tmpdepfile1="$base.o.d"
tmpdepfile2="$base.d"
if test "$libtool" = yes; then
tmpdepfile1="$dir.libs/$base.lo.d"
tmpdepfile2="$dir.libs/$base.d"
"$@" -Wc,-MD
else
tmpdepfile1="$dir$base.o.d"
tmpdepfile2="$dir$base.d"
"$@" -MD
fi
@@ -250,34 +254,40 @@ tru64)
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
test -z "$dashmflag" && dashmflag=-M
( IFS=" "
case " $* " in
*" --mode=compile "*) # this is libtool, let us make it quiet
for arg
do # cycle over the arguments
case "$arg" in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
# always write the proprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'. We will use -o /dev/null later,
# however we can't do the remplacement now because
# `-o $object' might simply not be used
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
done
test -z "$dashmflag" && dashmflag=-M
"$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
@@ -295,36 +305,31 @@ dashXmstdout)
;;
makedepend)
"$@" || exit $?
# X makedepend
(
shift
cleared=no
for arg in "$@"; do
case $cleared in no)
set ""; shift
cleared=yes
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift;;
-*)
;;
*)
set fnord "$@" "$arg"; shift;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
-*)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tail +3 "$tmpdepfile" | tr ' ' '
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
@@ -334,35 +339,39 @@ makedepend)
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
( IFS=" "
case " $* " in
*" --mode=compile "*)
for arg
do # cycle over the arguments
case $arg in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
# always write the proprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
"$@" -E |
done
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
@@ -374,47 +383,25 @@ msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
( IFS=" "
case " $* " in
*" --mode=compile "*)
for arg
do # cycle over the arguments
case $arg in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"

View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
@@ -293,23 +293,23 @@ WARNING: \`$1' is missing on your system. You should only need it if
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar ${1+"$@"} && exit 0
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar ${1+"$@"} && exit 0
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" ${1+"$@"} && exit 0
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" ${1+"$@"} && exit 0
tar "$firstarg" "$@" && exit 0
;;
esac
fi

View File

@@ -4,7 +4,7 @@
# Created: 1993-05-16
# Public domain
# $Id: mkinstalldirs,v 1.1 2002/02/16 14:23:56 meyering Exp $
# $Id: mkinstalldirs,v 1.2 2002/06/13 09:30:02 meyering Exp $
errstatus=0
dirmode=""

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{2002-03-01.06}
\def\texinfoversion{2002-06-04.06}
%
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
% 2000, 01, 02 Free Software Foundation, Inc.
@@ -53,7 +53,7 @@
% texindex foo.??
% tex foo.texi
% tex foo.texi
% dvips foo.dvi -o # or whatever, to process the dvi file; this makes foo.ps.
% dvips foo.dvi -o # or whatever; this makes foo.ps.
% The extra TeX runs get the cross-reference information correct.
% Sometimes one run after texindex suffices, and sometimes you need more
% than two; texi2dvi does it as many times as necessary.
@@ -846,7 +846,6 @@ where each line of input produces a line of output.}
% @math gets a chance to work. This could perhaps be fixed, but for now
% at least we can have real math in the main text, where it's needed most.
%
%
\let\implicitmath = $%$ font-lock fix
%
% One complication: _ usually means subscripts, but it could also mean
@@ -857,10 +856,22 @@ where each line of input produces a line of output.}
{\catcode95 = \active % 95 = _
\gdef\mathunderscore{%
\catcode95=\active
\def_{\ifnum\fam=\slfam\_\else\sb\fi}%
\def_{\ifnum\fam=\slfam \_\else\sb\fi}%
}}
%
\def\math{\tex\mathcode`\_="8000\mathunderscore \implicitmath\finishmath}
% Another complication: we want \\ (and @\) to output a \ character.
% FYI, plain.tex uses \\ as a temporary control sequence (why?), but
% this is not advertised and we don't care. Texinfo does not
% otherwise define @\.
%
% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
%
\def\math{%
\tex
\mathcode`\_="8000 \mathunderscore
\let\\ = \mathbackslash
\implicitmath\finishmath}
\def\finishmath#1{#1\implicitmath\Etex}
% @bullet and @minus need the same treatment as @math, just above.
@@ -1431,11 +1442,19 @@ where each line of input produces a line of output.}
\def\realdash{-}
\def\codedash{-\discretionary{}{}{}}
\def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}}
\def\codeunder{%
% this is all so @math{@code{var_name}+1} can work. In math mode, _
% is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
% will therefore expand the active definition of _, which is us
% (inside @code that is), therefore an endless loop.
\ifusingtt{\ifmmode
\mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
\else\normalunderscore \fi
\discretionary{}{}{}}%
{\_}%
}
\def\codex #1{\tclose{#1}\endgroup}
%\let\exp=\tclose %Was temporary
% @kbd is like @code, except that if the argument is just one @key command,
% then @kbd has no effect.
@@ -1637,8 +1656,6 @@ where each line of input produces a line of output.}
\global\let\contents = \relax
\global\let\shortcontents = \relax
\fi
%
\ifpdf \pdfmakepagedesttrue \fi
}
\def\finishtitlepage{%
@@ -2396,20 +2413,19 @@ width0pt\relax} \fi
\let\item = \relax
}
% Ignore @ignore ... @end ignore.
% Ignore @ignore, @ifhtml, @ifinfo, @ifplaintext, @ifnottex, @html, @menu,
% @direntry, and @documentdescription.
%
\def\ignore{\doignore{ignore}}
% Also ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu,
% @documentdescription, and @direntry text.
%
\def\ifinfo{\doignore{ifinfo}}
\def\ifhtml{\doignore{ifhtml}}
\def\ifinfo{\doignore{ifinfo}}
\def\ifplaintext{\doignore{ifplaintext}}
\def\ifnottex{\doignore{ifnottex}}
\def\html{\doignore{html}}
\def\menu{\doignore{menu}}
\def\documentdescription{\doignore{documentdescription}}
\def\direntry{\doignore{direntry}}
\def\documentdescription{\doignore{documentdescription}}
\def\documentdescriptionword{documentdescription}
% @dircategory CATEGORY -- specify a category of the dir file
% which this file should belong to. Ignore this in TeX.
@@ -2436,14 +2452,21 @@ width0pt\relax} \fi
% We must not have @c interpreted as a control sequence.
\catcode`\@ = 12
%
% Make the letter c a comment character so that the rest of the line
% will be ignored. This way, the document can have (for example)
% @c @end ifinfo
% and the @end ifinfo will be properly ignored.
% (We've just changed @ to catcode 12.)
\catcode`\c = 14
\def\ignoreword{#1}%
\ifx\ignoreword\documentdescriptionword
% The c kludge breaks documentdescription, since
% `documentdescription' contains a `c'. Means not everything will
% be ignored inside @documentdescription, but oh well...
\else
% Make the letter c a comment character so that the rest of the line
% will be ignored. This way, the document can have (for example)
% @c @end ifinfo
% and the @end ifinfo will be properly ignored.
% (We've just changed @ to catcode 12.)
\catcode`\c = 14
\fi
%
% And now expand that command.
% And now expand the command defined above.
\doignoretext
}
@@ -2634,19 +2657,21 @@ width0pt\relax} \fi
\def\ifclearfail{\nestedignore{ifclear}}
\defineunmatchedend{ifclear}
% @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text
% following, through the first @end iftex (etc.). Make `@end iftex'
% (etc.) valid only after an @iftex.
% @iftex, @ifnothtml, @ifnotinfo, @ifnotplaintext always succeed; we
% read the text following, through the first @end iftex (etc.). Make
% `@end iftex' (etc.) valid only after an @iftex.
%
\def\iftex{\conditionalsucceed{iftex}}
\def\ifnothtml{\conditionalsucceed{ifnothtml}}
\def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
\def\ifnotplaintext{\conditionalsucceed{ifnotplaintext}}
\defineunmatchedend{iftex}
\defineunmatchedend{ifnothtml}
\defineunmatchedend{ifnotinfo}
\defineunmatchedend{ifnotplaintext}
% We can't just want to start a group at @iftex (for example) and end it
% at @end iftex, since then @set commands inside the conditional have no
% We can't just want to start a group at @iftex (etc.) and end it at
% @end iftex, since then @set commands inside the conditional have no
% effect (they'd get reverted at the end of the group). So we must
% define \Eiftex to redefine itself to be its previous value. (We can't
% just define it to fail again with an ``unmatched end'' error, since
@@ -2861,7 +2886,7 @@ width0pt\relax} \fi
% If an index command is used in an @example environment, any spaces
% therein should become regular spaces in the raw index file, not the
% expansion of \tie (\\leavevmode \penalty \@M \ ).
% expansion of \tie (\leavevmode \penalty \@M \ ).
{\obeyspaces
\gdef\unsepspaces{\obeyspaces\let =\space}}
@@ -3906,7 +3931,7 @@ width0pt\relax} \fi
% argument, which will end up as the last argument to the \...entry macro.
%
% We open the .toc file here instead of at @setfilename or any other
% given time so that @contents can be put in the document anywhere.
% fixed time so that @contents can be put in the document anywhere.
%
\newif\iftocfileopened
\def\writetocentry#1{%
@@ -3915,6 +3940,14 @@ width0pt\relax} \fi
\global\tocfileopenedtrue
\fi
\iflinks \write\tocfile{#1{\folio}}\fi
%
% Tell \shipout to create a page destination if we're doing pdf, which
% will be the target of the links in the table of contents. We can't
% just do it on every page because the title pages are numbered 1 and
% 2 (the page numbers aren't printed), and so are the first two pages
% of the document. Thus, we'd have two destinations named `1', and
% two named `2'.
\ifpdf \pdfmakepagedesttrue \fi
}
\newskip\contentsrightmargin \contentsrightmargin=1in
@@ -4115,36 +4148,27 @@ width0pt\relax} \fi
\message{environments,}
% @foo ... @end foo.
% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
%
% Since these characters are used in examples, it should be an even number of
% \tt widths. Each \tt character is 1en, so two makes it 1em.
% Furthermore, these definitions must come after we define our fonts.
\newbox\dblarrowbox \newbox\longdblarrowbox
\newbox\pushcharbox \newbox\bullbox
\newbox\equivbox \newbox\errorbox
%{\tentt
%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
% Adapted from the manmac format (p.420 of TeXbook)
%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
% depth .1ex\hfil}
%}
% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
%
\def\point{$\star$}
\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
% The @error{} command.
% Adapted from the TeXbook's \boxit.
%
\newbox\errorbox
%
{\tentt \global\dimen0 = 3em}% Width of the box.
\dimen2 = .55pt % Thickness of rules
% The text. (`r' is open on the right, `e' somewhat less so on the left.)
\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
%
\global\setbox\errorbox=\hbox to \dimen0{\hfil
\hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
\advance\hsize by -2\dimen2 % Rules.
@@ -4155,8 +4179,7 @@ width0pt\relax} \fi
\kern3pt\vrule width\dimen2}% Space to right.
\hrule height\dimen2}
\hfil}
% The @error{} command.
%
\def\error{\leavevmode\lower.7ex\copy\errorbox}
% @tex ... @end tex escapes into raw Tex temporarily.
@@ -4196,9 +4219,9 @@ width0pt\relax} \fi
\def\@{@}%
\let\Etex=\endgroup}
% Define @lisp ... @endlisp.
% Define @lisp ... @end lisp.
% @lisp does a \begingroup so it can rebind things,
% including the definition of @endlisp (which normally is erroneous).
% including the definition of @end lisp (which normally is erroneous).
% Amount to narrow the margins by for @lisp.
\newskip\lispnarrowing \lispnarrowing=0.4in
@@ -4596,6 +4619,21 @@ width0pt\relax} \fi
\endgroup\nonfillfinish\endgroup
}
% @copying ... @end copying.
% Save the text away for @insertcopying later.
%
\newbox\copyingbox
%
\def\copying{\begingroup
\parindent = 0pt % looks wrong on title page
\def\Ecopying{\egroup\endgroup}%
\global\setbox\copyingbox = \vbox\bgroup
}
% @insertcopying.
%
\def\insertcopying{\unvcopy\copyingbox}
\message{defuns,}
% @defun etc.
@@ -4692,56 +4730,60 @@ width0pt\relax} \fi
{\df #1}\enskip % Generate function name
}
% Actually process the body of a definition
% #1 should be the terminating control sequence, such as \Edefun.
% #2 should be the "another name" control sequence, such as \defunx.
% #3 should be the control sequence that actually processes the header,
% such as \defunheader.
\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
\medbreak %
% Define the end token that this defining construct specifies
% so that it will exit this group.
\def#1{\endgraf\endgroup\medbreak}%
\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
\parindent=0in
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\begingroup %
\catcode 61=\active % 61 is `='
\obeylines\activeparens\spacesplit#3}
% Common pieces to start any @def...
% #1 is the \E... control sequence to end the definition (which we define).
% #2 is the \...x control sequence for consecutive fns (which we define).
% #3 is the control sequence to call to resume processing.
% #4, delimited by the space, is the class name.
%
\def\defmethparsebody#1#2#3#4 {\begingroup\inENV %
\medbreak %
% Define the end token that this defining construct specifies
% so that it will exit this group.
\def#1{\endgraf\endgroup\medbreak}%
\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
\parindent=0in
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
% Used for @deftypemethod and @deftypeivar.
% #1 is the \E... control sequence to end the definition (which we define).
% #2 is the \...x control sequence for consecutive fns (which we define).
% #3 is the control sequence to call to resume processing.
% #4, delimited by a space, is the class name.
% #5 is the method's return type.
%
\def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV
% #2 is the \...x control sequence (which our caller defines).
% #3 is the control sequence to process the header, such as \defunheader.
%
\def\parsebodycommon#1#2#3{%
\begingroup\inENV
% If there are two @def commands in a row, we'll have a \nobreak,
% which is there to keep the function description together with its
% header. But if there's nothing but headers, we want to allow a
% break after all.
\ifnum\lastpenalty = 10000 \penalty0 \fi
\medbreak
%
% Define the \E... end token that this defining construct specifies
% so that it will exit this group.
\def#1{\endgraf\endgroup\medbreak}%
\def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
%
\parindent=0in
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}}
}
% Process body of @defun, @deffn, @defmac, etc.
%
\def\defparsebody#1#2#3{%
\parsebodycommon{#1}{#2}{#3}%
\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
\catcode61=\active % 61 is `='
\begingroup\obeylines\activeparens
\spacesplit#3%
}
% #1, #2, #3 are the common arguments (see \defparsebody).
% #4, delimited by the space, is the class name.
%
\def\defmethparsebody#1#2#3#4 {%
\parsebodycommon{#1}{#2}{#3}%
\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
\begingroup\obeylines\activeparens
\spacesplit{#3{#4}}%
}
% Used for @deftypemethod and @deftypeivar.
% #1, #2, #3 are the common arguments (see \defparsebody).
% #4, delimited by a space, is the class name.
% #5 is the method's return type.
%
\def\deftypemethparsebody#1#2#3#4 #5 {%
\parsebodycommon{#1}{#2}{#3}%
\def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
\begingroup\obeylines\activeparens
\spacesplit{#3{#4}{#5}}%
}
% Used for @deftypeop. The change from \deftypemethparsebody is an
% extra argument at the beginning which is the `category', instead of it
@@ -4750,64 +4792,49 @@ width0pt\relax} \fi
% input at hand. Thus also need a control sequence (passed as #5) for
% the \E... definition to assign the category name to.
%
\def\deftypeopparsebody#1#2#3#4#5 #6 {\begingroup\inENV
\medbreak
\def#1{\endgraf\endgroup\medbreak}%
\def\deftypeopparsebody#1#2#3#4#5 #6 {%
\parsebodycommon{#1}{#2}{#3}%
\def#2##1 ##2 ##3 {%
\def#4{##1}%
\begingroup\obeylines\activeparens\spacesplit{#3{##2}{##3}}}%
\parindent=0in
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\begingroup\obeylines\activeparens\spacesplit{#3{#5}{#6}}}
\begingroup\obeylines\activeparens
\spacesplit{#3{#5}{#6}}%
}
\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
\medbreak %
% Define the end token that this defining construct specifies
% so that it will exit this group.
\def#1{\endgraf\endgroup\medbreak}%
\def#2##1 ##2 {\def#4{##1}%
\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
\parindent=0in
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
% For @defop.
\def\defopparsebody #1#2#3#4#5 {%
\parsebodycommon{#1}{#2}{#3}%
\def#2##1 ##2 {\def#4{##1}%
\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
\begingroup\obeylines\activeparens
\spacesplit{#3{#5}}%
}
% These parsing functions are similar to the preceding ones
% except that they do not make parens into active characters.
% These are used for "variables" since they have no arguments.
\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
\medbreak %
% Define the end token that this defining construct specifies
% so that it will exit this group.
\def#1{\endgraf\endgroup\medbreak}%
\def#2{\begingroup\obeylines\spacesplit#3}%
\parindent=0in
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\begingroup %
\catcode 61=\active %
\obeylines\spacesplit#3}
% This is used for \def{tp,vr}parsebody. It could probably be used for
% some of the others, too, with some judicious conditionals.
%
\def\parsebodycommon#1#2#3{%
\begingroup\inENV %
\medbreak %
% Define the end token that this defining construct specifies
% so that it will exit this group.
\def#1{\endgraf\endgroup\medbreak}%
\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
\parindent=0in
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\def\defvarparsebody #1#2#3{%
\parsebodycommon{#1}{#2}{#3}%
\def#2{\begingroup\obeylines\spacesplit#3}%
\catcode61=\active %
\begingroup\obeylines
\spacesplit#3%
}
% @defopvar.
\def\defopvarparsebody #1#2#3#4#5 {%
\parsebodycommon{#1}{#2}{#3}%
\def#2##1 ##2 {\def#4{##1}%
\begingroup\obeylines\spacesplit{#3{##2}}}%
\begingroup\obeylines
\spacesplit{#3{#5}}%
}
\def\defvrparsebody#1#2#3#4 {%
\parsebodycommon{#1}{#2}{#3}%
\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
\begingroup\obeylines
\spacesplit{#3{#4}}%
}
@@ -4822,6 +4849,8 @@ width0pt\relax} \fi
%
\def\deftpparsebody #1#2#3#4 {%
\parsebodycommon{#1}{#2}{#3}%
\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
\begingroup\obeylines
\spacesplit{\parsetpheaderline{#3{#4}}}\empty
}
@@ -4838,33 +4867,19 @@ width0pt\relax} \fi
#1{\removeemptybraces#2\relax}{#3}%
}%
\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
\medbreak %
% Define the end token that this defining construct specifies
% so that it will exit this group.
\def#1{\endgraf\endgroup\medbreak}%
\def#2##1 ##2 {\def#4{##1}%
\begingroup\obeylines\spacesplit{#3{##2}}}%
\parindent=0in
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\begingroup\obeylines\spacesplit{#3{#5}}}
% Split up #2 at the first space token.
% call #1 with two arguments:
% the first is all of #2 before the space token,
% the second is all of #2 after that space token.
% If #2 contains no space token, all of it is passed as the first arg
% and the second is passed as empty.
%
{\obeylines
\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
\ifx\relax #3%
#1{#2}{}\else #1{#2}{#3#4}\fi}}
% So much for the things common to all kinds of definitions.
% Define @defun.
% First, define the processing that is wanted for arguments of \defun
@@ -5274,7 +5289,7 @@ width0pt\relax} \fi
\message{Warning: redefining \the\macname}%
\else
\expandafter\ifx\csname \the\macname\endcsname \relax
\else \errmessage{The name \the\macname\space is reserved}\fi
\else \errmessage{Macro name \the\macname\space already defined}\fi
\global\cslet{macsave.\the\macname}{\the\macname}%
\global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
% Add the macroname to \macrolist

View File

@@ -1,3 +1,55 @@
2002-06-21 Jim Meyering <meyering@lucent.com>
* coreutils.texi (stat invocation): New section. From Michael Meskes.
2002-05-19 Paul Eggert <eggert@twinsun.com>
* coreutils.texi (ls invocation): Document new option: --author.
2002-06-03 Jim Meyering <meyering@lucent.com>
* coreutils.texi (rm invocation): Add the warning (also in the --help
output) that the contents of a removed file are often recoverable.
2002-05-27 Jim Meyering <meyering@lucent.com>
* Makefile.am (check-texinfo): Adapt to reflect that now we use
@acronym{POSIX}.
2002-05-26 Jim Meyering <meyering@lucent.com>
* coreutils.texi: Use @acronym in place of most uses of @sc.
* getdate.texi (Date input formats): Likewise.
2002-04-28 Jim Meyering <meyering@lucent.com>
* coreutils.texi: Change `@code{PROG}' to `@command{PROG}'.
2002-04-28 Paul Eggert <eggert@twinsun.com>
* coreutils.texi (kill invocation): Document the above.
Document POSIX signals better.
2002-04-15 Jim Meyering <meyering@lucent.com>
* coreutils.texi: Document kill.
Written by Marcus Brinkmann.
2002-04-13 Jim Meyering <meyering@lucent.com>
* coreutils.texi: Document link and unlink.
2002-04-08 Jim Meyering <meyering@lucent.com>
* coreutils.texi: Use new directives, @copying and @insertcopying,
thus now requiring texinfo-4.2 to create the .info file.
2002-02-26 Paul Eggert <eggert@twinsun.com>
* coreutils.texi (File characteristic tests): Document the
behavior of test -nt and -ot when one of the files does not exist,
using the same behavior that is documented in ksh93.
2002-03-05 Paul Eggert <eggert@twinsun.com>
* coreutils.texi (cut invocation): Say that selected input is

View File

@@ -31,6 +31,8 @@ $(INFO_DEPS): $(EXTRA_DIST)
# List words/regexps here that should not appear in the texinfo documentation.
check-texinfo:
grep timezone $(srcdir)/*.texi && exit 1 || :
grep -w POSIX $(srcdir)/*.texi 2> /dev/null && exit 1 || :
@PERL@ -ne \
'/\bPOSIX\b/ && !/\@acronym{POSIX}/ || /{posix}/ and print,exit 1' \
$(srcdir)/*.texi 2> /dev/null && : || exit 1
check: check-texinfo

View File

@@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.6 from Makefile.am.
# Makefile.in generated by automake 1.6.2 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
@@ -49,6 +49,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
@@ -232,7 +233,7 @@ mostlyclean-aminfo:
maintainer-clean-aminfo:
cd $(srcdir) && \
for i in $(INFO_DEPS); do \
list='$(INFO_DEPS)'; for i in $$list; do \
rm -f $$i; \
if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \
rm -f $$i-[0-9]*; \
@@ -247,7 +248,7 @@ top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
@list='$(DISTFILES)'; for file in $$list; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
@@ -257,8 +258,10 @@ distdir: $(DISTFILES)
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir)$$dir \
|| exit 1; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
@@ -294,7 +297,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@@ -388,7 +391,9 @@ $(INFO_DEPS): $(EXTRA_DIST)
# List words/regexps here that should not appear in the texinfo documentation.
check-texinfo:
grep timezone $(srcdir)/*.texi && exit 1 || :
grep -w POSIX $(srcdir)/*.texi 2> /dev/null && exit 1 || :
@PERL@ -ne \
'/\bPOSIX\b/ && !/\@acronym{POSIX}/ || /{posix}/ and print,exit 1' \
$(srcdir)/*.texi 2> /dev/null && : || exit 1
check: check-texinfo
# Tell versions [3.59,3.63) of GNU make to not export all variables.

8
doc/code-vs-command Normal file
View File

@@ -0,0 +1,8 @@
perl -pi -e \
's/\@code\{('"$(echo cp dd df dir dircolors du install ln ls mkdir mkfifo mknod mv shred touch vdir|tr ' ' '|')"')\}/\@command{$1}/' coreutils.texi
perl -pi -e \
's/\@code\{('"$(echo cp dd df dir dircolors du install ln ls mkdir mkfifo mknod mv shred touch vdir|tr ' ' '|')"')\}/\@command{$1}/' coreutils.texi
regex=$((textutils; shellutils) | tr -s ' ' '|')
perl -pi -e 's/\@code\{('"$regex"')\}/\@command{$1}/' coreutils.texi

File diff suppressed because it is too large Load Diff

View File

@@ -35,13 +35,13 @@ programs accept. These are the strings you, as a user, can supply as
arguments to the various programs. The C interface (via the
@code{getdate} function) is not described here.
@cindex beginning of time, for @sc{posix}
@cindex epoch, for @sc{posix}
@cindex beginning of time, for @acronym{POSIX}
@cindex epoch, for @acronym{POSIX}
Although the date syntax here can represent any possible time since the
year zero, computer integers often cannot represent such a wide range of
time. On @sc{posix} systems, the clock starts at 1970-01-01 00:00:00
@sc{utc}: @sc{posix} does not require support for times before the
@sc{posix} Epoch and times far in the future. Traditional Unix systems
time. On @acronym{POSIX} systems, the clock starts at 1970-01-01 00:00:00
@sc{utc}: @acronym{POSIX} does not require support for times before the
@acronym{POSIX} Epoch and times far in the future. Traditional Unix systems
have 32-bit signed @code{time_t} and can represent times from 1901-12-13
20:45:52 through 2038-01-19 03:14:07 @sc{utc}. Systems with 64-bit
signed @code{time_t} can represent all the times in the known

View File

@@ -1,3 +1,119 @@
2002-06-22 Jim Meyering <meyering@lucent.com>
* fnmatch.c (ISASCII, ISPRINT): Undefine, to avoid warning about
redefinition due to Solaris5.6's definition in /usr/include/sys/euc.h.
2002-06-22 Paul Eggert <eggert@twinsun.com>
* c-stack.h (segv_handler, c_stack_action) [! defined SA_SIGINFO]:
Do not assume SA_SIGINFO behavior.
Bug reported by Jim Meyering on NetBSD 1.5.2.
2002-06-22 Jim Meyering <meyering@lucent.com>
* c-stack.c, c-stack.h: New files, from diffutils-2.8.2.
* exitfail.c, exitfail.h: Likewise.
* Makefile.am (libfetish_a_SOURCES): Add exitfail.c and exitfail.h.
* Makefile.am (libfetish_a_SOURCES): Add fnmatch_.h in place
of fnmatch.h.
(EXTRA_DIST): Add fnmatch_loop.c.
(libfetish_a_SOURCES): Add c-stack.c and c-stack.h.
* fnmatch_loop.c: New file, from diffutils-2.8.2.
* fnmatch.c: Update from diffutils-2.8.2.
* fnmatch_.h: New file. From diffutils-2.8.2.
* fnmatch.h: Remove file.
2002-06-18 Paul Eggert <eggert@twinsun.com>
* file-type.h: Report an error if neither S_ISREG nor
S_IFREG is defined, instead of using a test specific to glibc
2.2. This should be safe, since POSIX requires S_ISREG and
Unix Version 7 had S_IFREG. We don't need to check for
<sys/types.h> since we don't use any symbols that it defines.
2002-06-15 Jim Meyering <meyering@lucent.com>
* file-type.h (FILE_TYPE_H): Guard entire contents with #ifndef.
For GNU libc 2.2 and newer, ensure that <sys/types.h> and <sys/stat.h>
have been included before this file.
2002-06-13 Richard Dawe <richdawe@bigfoot.com>
* Makefile.am (lstat.c, stat.c, .sin.sed): Use t-$@, rather than $@-t,
so that each temporary file name is unique and valid in the first
8 characters, for operation under DOS.
2002-06-15 Jim Meyering <meyering@lucent.com>
Work even with DJGPP 2.03, which lacks support for symlinks.
From Richard Dawe.
* xstat.in (S_ISLNK): Define to 0 if neither S_ISLNK nor S_IFLNK
is defined.
* lchown.c (S_ISLNK): Likewise.
2002-06-14 Jim Meyering <meyering@lucent.com>
* file-type.h: Use the version from diffutils-2.8.2.
* file-type.c: Likewise.
2002-05-27 Jim Meyering <meyering@lucent.com>
Fix a problem seen only on nonconforming systems whereby ls.c's
use of localtime, and then of gettimeofday would cause trouble:
the localtime call used to initialize rpl_gettimeofday's save
mechanism would clobber ls's current local time information so
that in any long listing the first file would always be listed
with date 1970-01-01. Analysis by Volker Borchert.
* gettimeofday.c (localtime): Undefine.
(rpl_localtime): New function.
2002-05-22 Jim Meyering <meyering@lucent.com>
* Makefile.am (libfetish_a_SOURCES): Add file-type.c and file-type.h.
* file-type.h: New file.
* file-type.c (file_type): New file/function. Extracted from diffutils.
2002-04-29 Paul Eggert <eggert@twinsun.com>
* hard-locale.c: Upgrade to version used in GNU Diffutils 2.8.1.
2002-04-28 Paul Eggert <eggert@twinsun.com>
* sig2str.h (SIGNUM_BOUND): Do not use WTERMSIG, to avoid
depending on <sys/wait.h> and WTERMSIG. Default to 64 instead
of 127, since 64 is the largest conceivable number for ancient
nonstandard hosts.
* sig2str.c: Do not include <sys/wait.h>; no longer needed.
2002-04-28 Jim Meyering <meyering@lucent.com>
* sig2str.c (WTERMSIG): Remove definition (unused).
2002-04-28 Paul Eggert <eggert@twinsun.com>
* sig2str.h, sig2str.c: New files.
* Makefile.am (libfetish_a_SOURCES): Add sig2str.h.
2002-04-24 Jim Meyering <meyering@lucent.com>
* gettext.h: New file, from Gettext.
* Makefile.am (INCLUDES): Remove -I../intl.
(libfetish_a_SOURCES): Add gettext.h.
2002-04-16 Jim Meyering <meyering@lucent.com>
* readutmp.h (UT_TYPE): Remove definition (now in who.c).
(HAVE_STRUCT_XTMP_UT_EXIT, HAVE_STRUCT_XTMP_UT_ID): Define.
(HAVE_STRUCT_XTMP_UT_PID, HAVE_STRUCT_XTMP_UT_TYPE): Define.
2002-04-12 Jim Meyering <meyering@lucent.com>
* dirfd.h (dirfd): Elide prototype if dirfd is a macro.
2002-03-10 Jim Meyering <meyering@lucent.com>
* makepath.c (make_path): Remove a comma from a diagnostic.

View File

@@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = ../src/ansi2knr
noinst_LIBRARIES = libfetish.a
INCLUDES = -I.. -I$(srcdir) -I../intl
INCLUDES = -I.. -I$(srcdir)
DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@
## Put relatively complex files at the beginning of the list so
@@ -28,14 +28,17 @@ libfetish_a_SOURCES = \
basename.c \
bumpalloc.h \
canon-host.c \
c-stack.c c-stack.h \
closeout.c closeout.h \
diacrit.c diacrit.h \
dirname.c dirname.h \
dirfd.h \
dup-safer.c \
exclude.c exclude.h \
exitfail.c exitfail.h \
filemode.c filemode.h \
fnmatch.h \
file-type.c file-type.h \
fnmatch_.h \
fopen-safer.c \
fsusage.h \
full-write.c full-write.h \
@@ -43,6 +46,7 @@ libfetish_a_SOURCES = \
getpagesize.h \
getstr.c getstr.h \
gettime.c \
gettext.h \
getugroups.c \
group-member.h \
hard-locale.c hard-locale.h \
@@ -74,6 +78,7 @@ libfetish_a_SOURCES = \
savedir.c savedir.h \
settime.c \
sha.c sha.h \
sig2str.h \
stdio-safer.h \
stripslash.c \
strverscmp.h \
@@ -104,15 +109,17 @@ BUILT_SOURCES = getdate.c lstat.c stat.c unlocked-io.h
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
DISTCLEANFILES = lstat.c stat.c unlocked-io.h
EXTRA_DIST = xstat.in config.charset ref-add.sin ref-del.sin gen-uio
EXTRA_DIST = xstat.in config.charset ref-add.sin ref-del.sin gen-uio \
fnmatch_loop.c
lstat.c: xstat.in
sed \
-e '/@IGNORE@/d' \
-e 's/@xstat@/lstat/g' \
-e '/_LSTAT_ONLY@/d' \
-e '/@BEGIN_STAT_ONLY@/,/@END_STAT_ONLY@/d' \
$(srcdir)/xstat.in > $@-t
mv $@-t $@
$(srcdir)/xstat.in > t-$@
mv t-$@ $@
stat.c: xstat.in
sed \
@@ -120,8 +127,8 @@ stat.c: xstat.in
-e 's/@xstat@/stat/g' \
-e '/_STAT_ONLY@/d' \
-e '/@BEGIN_LSTAT_ONLY@/,/@END_LSTAT_ONLY@/d' \
$(srcdir)/xstat.in > $@-t
mv $@-t $@
$(srcdir)/xstat.in > t-$@
mv t-$@ $@
# The following is needed in order to install a simple file in $(libdir)
# which is shared with other installed packages. We use a list of referencing
@@ -166,8 +173,8 @@ charset.alias: config.charset
SUFFIXES = .sed .sin
.sin.sed:
sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > $@-t
mv $@-t $@
sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > t-$@
mv t-$@ $@
CLEANFILES = charset.alias ref-add.sed ref-del.sed

View File

@@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.6 from Makefile.am.
# Makefile.in generated by automake 1.6.2 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
@@ -49,6 +49,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
@@ -122,7 +123,7 @@ AUTOMAKE_OPTIONS = ../src/ansi2knr
noinst_LIBRARIES = libfetish.a
INCLUDES = -I.. -I$(srcdir) -I../intl
INCLUDES = -I.. -I$(srcdir)
DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@
libfetish_a_SOURCES = \
@@ -141,14 +142,17 @@ libfetish_a_SOURCES = \
basename.c \
bumpalloc.h \
canon-host.c \
c-stack.c c-stack.h \
closeout.c closeout.h \
diacrit.c diacrit.h \
dirname.c dirname.h \
dirfd.h \
dup-safer.c \
exclude.c exclude.h \
exitfail.c exitfail.h \
filemode.c filemode.h \
fnmatch.h \
file-type.c file-type.h \
fnmatch_.h \
fopen-safer.c \
fsusage.h \
full-write.c full-write.h \
@@ -156,6 +160,7 @@ libfetish_a_SOURCES = \
getpagesize.h \
getstr.c getstr.h \
gettime.c \
gettext.h \
getugroups.c \
group-member.h \
hard-locale.c hard-locale.h \
@@ -187,6 +192,7 @@ libfetish_a_SOURCES = \
savedir.c savedir.h \
settime.c \
sha.c sha.h \
sig2str.h \
stdio-safer.h \
stripslash.c \
strverscmp.h \
@@ -217,7 +223,9 @@ BUILT_SOURCES = getdate.c lstat.c stat.c unlocked-io.h
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
DISTCLEANFILES = lstat.c stat.c unlocked-io.h
EXTRA_DIST = xstat.in config.charset ref-add.sin ref-del.sin gen-uio
EXTRA_DIST = xstat.in config.charset ref-add.sin ref-del.sin gen-uio \
fnmatch_loop.c
charset_alias = $(DESTDIR)$(libdir)/charset.alias
charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
@@ -243,9 +251,10 @@ am_libfetish_a_OBJECTS = acl$U.$(OBJEXT) getdate$U.$(OBJEXT) \
getopt$U.$(OBJEXT) getopt1$U.$(OBJEXT) hash$U.$(OBJEXT) \
hash-pjw$U.$(OBJEXT) addext$U.$(OBJEXT) argmatch$U.$(OBJEXT) \
backupfile$U.$(OBJEXT) basename$U.$(OBJEXT) \
canon-host$U.$(OBJEXT) closeout$U.$(OBJEXT) diacrit$U.$(OBJEXT) \
dirname$U.$(OBJEXT) dup-safer$U.$(OBJEXT) exclude$U.$(OBJEXT) \
filemode$U.$(OBJEXT) fopen-safer$U.$(OBJEXT) \
canon-host$U.$(OBJEXT) c-stack$U.$(OBJEXT) closeout$U.$(OBJEXT) \
diacrit$U.$(OBJEXT) dirname$U.$(OBJEXT) dup-safer$U.$(OBJEXT) \
exclude$U.$(OBJEXT) exitfail$U.$(OBJEXT) filemode$U.$(OBJEXT) \
file-type$U.$(OBJEXT) fopen-safer$U.$(OBJEXT) \
full-write$U.$(OBJEXT) getstr$U.$(OBJEXT) gettime$U.$(OBJEXT) \
getugroups$U.$(OBJEXT) hard-locale$U.$(OBJEXT) \
human$U.$(OBJEXT) idcache$U.$(OBJEXT) isdir$U.$(OBJEXT) \
@@ -292,24 +301,26 @@ am__depfiles_maybe = depfiles
@AMDEP_TRUE@ $(DEPDIR)/readutmp.Po $(DEPDIR)/realloc.Po \
@AMDEP_TRUE@ $(DEPDIR)/regex.Po $(DEPDIR)/rename.Po \
@AMDEP_TRUE@ $(DEPDIR)/rmdir.Po $(DEPDIR)/rpmatch.Po \
@AMDEP_TRUE@ $(DEPDIR)/stat.Po $(DEPDIR)/stpcpy.Po \
@AMDEP_TRUE@ $(DEPDIR)/strcasecmp.Po $(DEPDIR)/strcspn.Po \
@AMDEP_TRUE@ $(DEPDIR)/strdup.Po $(DEPDIR)/strncasecmp.Po \
@AMDEP_TRUE@ $(DEPDIR)/strndup.Po $(DEPDIR)/strnlen.Po \
@AMDEP_TRUE@ $(DEPDIR)/strpbrk.Po $(DEPDIR)/strstr.Po \
@AMDEP_TRUE@ $(DEPDIR)/strtod.Po $(DEPDIR)/strtoimax.Po \
@AMDEP_TRUE@ $(DEPDIR)/strtol.Po $(DEPDIR)/strtoll.Po \
@AMDEP_TRUE@ $(DEPDIR)/strtoul.Po $(DEPDIR)/strtoull.Po \
@AMDEP_TRUE@ $(DEPDIR)/strtoumax.Po $(DEPDIR)/strverscmp.Po \
@AMDEP_TRUE@ $(DEPDIR)/tempname.Po $(DEPDIR)/utime.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/acl$U.Po ./$(DEPDIR)/addext$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/argmatch$U.Po \
@AMDEP_TRUE@ $(DEPDIR)/sig2str.Po $(DEPDIR)/stat.Po \
@AMDEP_TRUE@ $(DEPDIR)/stpcpy.Po $(DEPDIR)/strcasecmp.Po \
@AMDEP_TRUE@ $(DEPDIR)/strcspn.Po $(DEPDIR)/strdup.Po \
@AMDEP_TRUE@ $(DEPDIR)/strncasecmp.Po $(DEPDIR)/strndup.Po \
@AMDEP_TRUE@ $(DEPDIR)/strnlen.Po $(DEPDIR)/strpbrk.Po \
@AMDEP_TRUE@ $(DEPDIR)/strstr.Po $(DEPDIR)/strtod.Po \
@AMDEP_TRUE@ $(DEPDIR)/strtoimax.Po $(DEPDIR)/strtol.Po \
@AMDEP_TRUE@ $(DEPDIR)/strtoll.Po $(DEPDIR)/strtoul.Po \
@AMDEP_TRUE@ $(DEPDIR)/strtoull.Po $(DEPDIR)/strtoumax.Po \
@AMDEP_TRUE@ $(DEPDIR)/strverscmp.Po $(DEPDIR)/tempname.Po \
@AMDEP_TRUE@ $(DEPDIR)/utime.Po ./$(DEPDIR)/acl$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/addext$U.Po ./$(DEPDIR)/argmatch$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/backupfile$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/basename$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/basename$U.Po ./$(DEPDIR)/c-stack$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/canon-host$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/closeout$U.Po ./$(DEPDIR)/diacrit$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/dirname$U.Po ./$(DEPDIR)/dup-safer$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/exclude$U.Po ./$(DEPDIR)/filemode$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/exclude$U.Po ./$(DEPDIR)/exitfail$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/file-type$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/filemode$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/fopen-safer$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/full-write$U.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/getdate$U.Po ./$(DEPDIR)/getopt$U.Po \
@@ -362,7 +373,7 @@ DIST_COMMON = README ChangeLog Makefile.am Makefile.in TODO \
group-member.c lchown.c malloc.c memchr.c memcmp.c memcpy.c \
memmove.c memrchr.c memset.c mkdir.c mkstemp.c mktime.c \
mountlist.c nanosleep.c obstack.c obstack.h putenv.c readutmp.c \
realloc.c regex.c rename.c rmdir.c rpmatch.c stpcpy.c \
realloc.c regex.c rename.c rmdir.c rpmatch.c sig2str.c stpcpy.c \
strcasecmp.c strcspn.c strdup.c strncasecmp.c strndup.c \
strnlen.c strpbrk.c strstr.c strtod.c strtoimax.c strtol.c \
strtoll.c strtoul.c strtoull.c strtoumax.c strverscmp.c \
@@ -444,6 +455,7 @@ mostlyclean-kr:
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rename.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rmdir.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpmatch.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sig2str.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/stat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/stpcpy.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcasecmp.Po@am__quote@
@@ -469,12 +481,15 @@ mostlyclean-kr:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argmatch$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backupfile$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-stack$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/canon-host$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/closeout$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diacrit$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirname$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup-safer$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exclude$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exitfail$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-type$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filemode$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fopen-safer$U.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/full-write$U.Po@am__quote@
@@ -537,7 +552,7 @@ distclean-depend:
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$<
$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
.c.obj:
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@@ -561,6 +576,8 @@ backupfile_.c: backupfile.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/backupfile.c; then echo $(srcdir)/backupfile.c; else echo backupfile.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > backupfile_.c || rm -f backupfile_.c
basename_.c: basename.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/basename.c; then echo $(srcdir)/basename.c; else echo basename.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > basename_.c || rm -f basename_.c
c-stack_.c: c-stack.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/c-stack.c; then echo $(srcdir)/c-stack.c; else echo c-stack.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > c-stack_.c || rm -f c-stack_.c
canon-host_.c: canon-host.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/canon-host.c; then echo $(srcdir)/canon-host.c; else echo canon-host.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > canon-host_.c || rm -f canon-host_.c
chown_.c: lib/chown.c $(ANSI2KNR)
@@ -583,6 +600,10 @@ euidaccess_.c: lib/euidaccess.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/lib/euidaccess.c; then echo $(srcdir)/lib/euidaccess.c; else echo lib/euidaccess.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > euidaccess_.c || rm -f euidaccess_.c
exclude_.c: exclude.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/exclude.c; then echo $(srcdir)/exclude.c; else echo exclude.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > exclude_.c || rm -f exclude_.c
exitfail_.c: exitfail.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/exitfail.c; then echo $(srcdir)/exitfail.c; else echo exitfail.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > exitfail_.c || rm -f exitfail_.c
file-type_.c: file-type.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/file-type.c; then echo $(srcdir)/file-type.c; else echo file-type.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > file-type_.c || rm -f file-type_.c
fileblocks_.c: lib/fileblocks.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/lib/fileblocks.c; then echo $(srcdir)/lib/fileblocks.c; else echo lib/fileblocks.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > fileblocks_.c || rm -f fileblocks_.c
filemode_.c: filemode.c $(ANSI2KNR)
@@ -725,6 +746,8 @@ settime_.c: settime.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/settime.c; then echo $(srcdir)/settime.c; else echo settime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > settime_.c || rm -f settime_.c
sha_.c: sha.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(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 || rm -f sha_.c
sig2str_.c: lib/sig2str.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/lib/sig2str.c; then echo $(srcdir)/lib/sig2str.c; else echo lib/sig2str.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > sig2str_.c || rm -f sig2str_.c
stat_.c: lib/stat.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/lib/stat.c; then echo $(srcdir)/lib/stat.c; else echo lib/stat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > stat_.c || rm -f stat_.c
stpcpy_.c: lib/stpcpy.c $(ANSI2KNR)
@@ -801,11 +824,12 @@ yesno_.c: yesno.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/yesno.c; then echo $(srcdir)/yesno.c; else echo yesno.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > yesno_.c || rm -f yesno_.c
__fpending_.$(OBJEXT) acl_.$(OBJEXT) addext_.$(OBJEXT) \
alloca_.$(OBJEXT) argmatch_.$(OBJEXT) atexit_.$(OBJEXT) \
backupfile_.$(OBJEXT) basename_.$(OBJEXT) canon-host_.$(OBJEXT) \
chown_.$(OBJEXT) closeout_.$(OBJEXT) diacrit_.$(OBJEXT) \
dirfd_.$(OBJEXT) dirname_.$(OBJEXT) dup-safer_.$(OBJEXT) \
dup2_.$(OBJEXT) error_.$(OBJEXT) euidaccess_.$(OBJEXT) \
exclude_.$(OBJEXT) fileblocks_.$(OBJEXT) filemode_.$(OBJEXT) \
backupfile_.$(OBJEXT) basename_.$(OBJEXT) c-stack_.$(OBJEXT) \
canon-host_.$(OBJEXT) chown_.$(OBJEXT) closeout_.$(OBJEXT) \
diacrit_.$(OBJEXT) dirfd_.$(OBJEXT) dirname_.$(OBJEXT) \
dup-safer_.$(OBJEXT) dup2_.$(OBJEXT) error_.$(OBJEXT) \
euidaccess_.$(OBJEXT) exclude_.$(OBJEXT) exitfail_.$(OBJEXT) \
file-type_.$(OBJEXT) fileblocks_.$(OBJEXT) filemode_.$(OBJEXT) \
fnmatch_.$(OBJEXT) fopen-safer_.$(OBJEXT) fsusage_.$(OBJEXT) \
ftruncate_.$(OBJEXT) full-write_.$(OBJEXT) getdate_.$(OBJEXT) \
getgroups_.$(OBJEXT) gethostname_.$(OBJEXT) getline_.$(OBJEXT) \
@@ -828,23 +852,23 @@ quote_.$(OBJEXT) quotearg_.$(OBJEXT) readtokens_.$(OBJEXT) \
readutmp_.$(OBJEXT) realloc_.$(OBJEXT) regex_.$(OBJEXT) \
rename_.$(OBJEXT) rmdir_.$(OBJEXT) rpmatch_.$(OBJEXT) \
safe-read_.$(OBJEXT) same_.$(OBJEXT) save-cwd_.$(OBJEXT) \
savedir_.$(OBJEXT) settime_.$(OBJEXT) sha_.$(OBJEXT) stat_.$(OBJEXT) \
stpcpy_.$(OBJEXT) strcasecmp_.$(OBJEXT) strcspn_.$(OBJEXT) \
strdup_.$(OBJEXT) strftime_.$(OBJEXT) stripslash_.$(OBJEXT) \
strncasecmp_.$(OBJEXT) strndup_.$(OBJEXT) strnlen_.$(OBJEXT) \
strpbrk_.$(OBJEXT) strstr_.$(OBJEXT) strtod_.$(OBJEXT) \
strtoimax_.$(OBJEXT) strtol_.$(OBJEXT) strtoll_.$(OBJEXT) \
strtoul_.$(OBJEXT) strtoull_.$(OBJEXT) strtoumax_.$(OBJEXT) \
strverscmp_.$(OBJEXT) tempname_.$(OBJEXT) unicodeio_.$(OBJEXT) \
userspec_.$(OBJEXT) utime_.$(OBJEXT) version-etc_.$(OBJEXT) \
xgetcwd_.$(OBJEXT) xgethostname_.$(OBJEXT) xmalloc_.$(OBJEXT) \
xmemcoll_.$(OBJEXT) xreadlink_.$(OBJEXT) xstrdup_.$(OBJEXT) \
xstrtod_.$(OBJEXT) xstrtoimax_.$(OBJEXT) xstrtol_.$(OBJEXT) \
xstrtoul_.$(OBJEXT) xstrtoumax_.$(OBJEXT) yesno_.$(OBJEXT) : \
$(ANSI2KNR)
savedir_.$(OBJEXT) settime_.$(OBJEXT) sha_.$(OBJEXT) sig2str_.$(OBJEXT) \
stat_.$(OBJEXT) stpcpy_.$(OBJEXT) strcasecmp_.$(OBJEXT) \
strcspn_.$(OBJEXT) strdup_.$(OBJEXT) strftime_.$(OBJEXT) \
stripslash_.$(OBJEXT) strncasecmp_.$(OBJEXT) strndup_.$(OBJEXT) \
strnlen_.$(OBJEXT) strpbrk_.$(OBJEXT) strstr_.$(OBJEXT) \
strtod_.$(OBJEXT) strtoimax_.$(OBJEXT) strtol_.$(OBJEXT) \
strtoll_.$(OBJEXT) strtoul_.$(OBJEXT) strtoull_.$(OBJEXT) \
strtoumax_.$(OBJEXT) strverscmp_.$(OBJEXT) tempname_.$(OBJEXT) \
unicodeio_.$(OBJEXT) userspec_.$(OBJEXT) utime_.$(OBJEXT) \
version-etc_.$(OBJEXT) xgetcwd_.$(OBJEXT) xgethostname_.$(OBJEXT) \
xmalloc_.$(OBJEXT) xmemcoll_.$(OBJEXT) xreadlink_.$(OBJEXT) \
xstrdup_.$(OBJEXT) xstrtod_.$(OBJEXT) xstrtoimax_.$(OBJEXT) \
xstrtol_.$(OBJEXT) xstrtoul_.$(OBJEXT) xstrtoumax_.$(OBJEXT) \
yesno_.$(OBJEXT) : $(ANSI2KNR)
.y.c:
$(YACCCOMPILE) `test -f $< || echo '$(srcdir)/'`$<
$(YACCCOMPILE) `test -f '$<' || echo '$(srcdir)/'`$<
sed '/^#/ s|y\.tab\.c|$@|' y.tab.c >$@
rm -f y.tab.c
if test -f y.tab.h; then \
@@ -905,7 +929,7 @@ top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
@list='$(DISTFILES)'; for file in $$list; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
@@ -915,8 +939,10 @@ distdir: $(DISTFILES)
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir)$$dir \
|| exit 1; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
@@ -949,7 +975,7 @@ clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@@ -1004,14 +1030,15 @@ uninstall-am: uninstall-info-am uninstall-local
mostlyclean-generic mostlyclean-kr tags uninstall uninstall-am \
uninstall-info-am uninstall-local
lstat.c: xstat.in
sed \
-e '/@IGNORE@/d' \
-e 's/@xstat@/lstat/g' \
-e '/_LSTAT_ONLY@/d' \
-e '/@BEGIN_STAT_ONLY@/,/@END_STAT_ONLY@/d' \
$(srcdir)/xstat.in > $@-t
mv $@-t $@
$(srcdir)/xstat.in > t-$@
mv t-$@ $@
stat.c: xstat.in
sed \
@@ -1019,8 +1046,8 @@ stat.c: xstat.in
-e 's/@xstat@/stat/g' \
-e '/_STAT_ONLY@/d' \
-e '/@BEGIN_LSTAT_ONLY@/,/@END_LSTAT_ONLY@/d' \
$(srcdir)/xstat.in > $@-t
mv $@-t $@
$(srcdir)/xstat.in > t-$@
mv t-$@ $@
# The following is needed in order to install a simple file in $(libdir)
# which is shared with other installed packages. We use a list of referencing
@@ -1060,8 +1087,8 @@ charset.alias: config.charset
$(SHELL) $(srcdir)/config.charset '@host@' > t-$@
mv t-$@ $@
.sin.sed:
sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > $@-t
mv $@-t $@
sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > t-$@
mv t-$@ $@
###############################################

429
lib/c-stack.c Normal file
View File

@@ -0,0 +1,429 @@
/* Stack overflow handling.
Copyright (C) 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Paul Eggert. */
/* NOTES:
A program that uses alloca, dynamic arrays, or large local
variables may extend the stack by more than a page at a time. If
so, when the stack overflows the operating system may not detect
the overflow until the program uses the array, and this module may
incorrectly report a program error instead of a stack overflow.
To avoid this problem, allocate only small objects on the stack; a
program should be OK if it limits single allocations to a page or
less. Allocate larger arrays in static storage, or on the heap
(e.g., with malloc). Yes, this is a pain, but we don't know of any
better solution that is portable.
No attempt has been made to deal with multithreaded applications.
If ! HAVE_XSI_STACK_OVERFLOW_HEURISTIC, the current implementation
assumes that, if the RLIMIT_STACK limit changes during execution,
then c_stack_action is invoked immediately afterwards. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef __attribute__
# if __GNUC__ < 3 || __STRICT_ANSI__
# define __attribute__(x)
# endif
#endif
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include <errno.h>
#ifndef ENOTSUP
# define ENOTSUP EINVAL
#endif
#ifndef EOVERFLOW
# define EOVERFLOW EINVAL
#endif
#include <signal.h>
#if ! HAVE_STACK_T && ! defined stack_t
typedef struct sigaltstack stack_t;
#endif
#include <stdlib.h>
#include <string.h>
#if HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
#if HAVE_UCONTEXT_H
# include <ucontext.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifndef STDERR_FILENO
# define STDERR_FILENO 2
#endif
#if DEBUG
# include <stdio.h>
#endif
#include "c-stack.h"
#include "exitfail.h"
extern char *program_name;
/* The user-specified action to take when a SEGV-related program error
or stack overflow occurs. */
static void (* volatile segv_action) (int);
/* Translated messages for program errors and stack overflow. Do not
translate them in the signal handler, since gettext is not
async-signal-safe. */
static char const * volatile program_error_message;
static char const * volatile stack_overflow_message;
/* Output an error message, then exit with status EXIT_FAILURE if it
appears to have been a stack overflow, or with a core dump
otherwise. This function is async-signal-safe. */
static void die (int) __attribute__ ((noreturn));
static void
die (int signo)
{
char const *message =
signo ? program_error_message : stack_overflow_message;
segv_action (signo);
write (STDERR_FILENO, program_name, strlen (program_name));
write (STDERR_FILENO, ": ", 2);
write (STDERR_FILENO, message, strlen (message));
write (STDERR_FILENO, "\n", 1);
if (! signo)
_exit (exit_failure);
kill (getpid (), signo);
abort ();
}
#if HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK
/* Direction of the C runtime stack. This function is
async-signal-safe. */
# if STACK_DIRECTION
# define find_stack_direction(ptr) STACK_DIRECTION
# else
static int
find_stack_direction (char const *addr)
{
char dummy;
return ! addr ? find_stack_direction (&dummy) : addr < &dummy ? 1 : -1;
}
# endif
# if HAVE_XSI_STACK_OVERFLOW_HEURISTIC
# define get_stack_location(argv) 0
# else
# if defined RLIMIT_STACK && defined _SC_PAGESIZE
/* Return the minimum machine address deducible from ARGV. This
includes the addresses of all the strings that ARGV points at, as
well as the address of ARGV itself. */
static char const *
min_address_from_argv (char * const *argv)
{
char const *min = (char const *) argv;
char const *p;
while ((p = *argv++))
if (p < min)
min = p;
return min;
}
/* Return the maximum machine address deducible from ARGV. */
static char const *
max_address_from_argv (char * const *argv)
{
char const *max = *argv;
char const *max1;
char const *p;
while ((p = *argv++))
if (max < p)
max = p;
max1 = (char const *) (argv + 1);
return max && max1 < max ? max + strlen (max) + 1 : max1;
}
# endif
/* The base and size of the stack, determined at startup. */
static char const * volatile stack_base;
static size_t volatile stack_size;
/* Store the base and size of the stack into the static variables
STACK_BASE and STACK_SIZE. The base is the numerically lowest
address in the stack. Return -1 (setting errno) if this cannot be
done. */
static int
get_stack_location (char * const *argv)
{
# if ! (defined RLIMIT_STACK && defined _SC_PAGESIZE)
errno = ENOTSUP;
return -1;
# else
struct rlimit rlimit;
int r = getrlimit (RLIMIT_STACK, &rlimit);
if (r == 0)
{
char const *base;
size_t size = rlimit.rlim_cur;
extern char **environ;
size_t page_size = sysconf (_SC_PAGESIZE);
int stack_direction = find_stack_direction (0);
# if HAVE_GETCONTEXT && HAVE_DECL_GETCONTEXT
ucontext_t context;
if (getcontext (&context) == 0)
{
base = context.uc_stack.ss_sp;
if (stack_direction < 0)
base -= size - context.uc_stack.ss_size;
}
else
# endif
{
if (stack_direction < 0)
{
char const *a = max_address_from_argv (argv);
char const *b = max_address_from_argv (environ);
base = (a < b ? b : a) - size;
base += - (size_t) base % page_size;
}
else
{
char const *a = min_address_from_argv (argv);
char const *b = min_address_from_argv (environ);
base = a < b ? a : b;
base -= (size_t) base % page_size;
}
}
if (size != rlimit.rlim_cur
|| rlimit.rlim_cur < 0
|| base + size < base
# ifdef RLIM_SAVED_CUR
|| rlimit.rlim_cur == RLIM_SAVED_CUR
# endif
# ifdef RLIM_SAVED_MAX
|| rlimit.rlim_cur == RLIM_SAVED_MAX
# endif
# ifdef RLIM_INFINITY
|| rlimit.rlim_cur == RLIM_INFINITY
# endif
)
{
errno = EOVERFLOW;
return -1;
}
stack_base = base;
stack_size = size;
# if DEBUG
fprintf (stderr, "get_stack_location base=%p size=%lx\n",
base, (unsigned long) size);
# endif
}
return r;
# endif
}
# endif
/* Storage for the alternate signal stack. */
static union
{
char buffer[SIGSTKSZ];
/* These other members are for proper alignment. There's no
standard way to guarantee stack alignment, but this seems enough
in practice. */
long double ld;
long l;
void *p;
} alternate_signal_stack;
# if defined SA_ONSTACK && defined SA_SIGINFO && defined _SC_PAGESIZE
/* Handle a segmentation violation and exit. This function is
async-signal-safe. */
static void segv_handler (int, siginfo_t *, void *) __attribute__((noreturn));
static void
segv_handler (int signo, siginfo_t *info,
void *context __attribute__ ((unused)))
{
/* Clear SIGNO if it seems to have been a stack overflow. */
if (0 < info->si_code)
{
/* If the faulting address is within the stack, or within one
page of the stack end, assume that it is a stack
overflow. */
# if HAVE_XSI_STACK_OVERFLOW_HEURISTIC
ucontext_t const *user_context = context;
char const *stack_base = user_context->uc_stack.ss_sp;
size_t stack_size = user_context->uc_stack.ss_size;
# endif
char const *faulting_address = info->si_addr;
size_t s = faulting_address - stack_base;
size_t page_size = sysconf (_SC_PAGESIZE);
if (find_stack_direction (0) < 0)
s += page_size;
if (s < stack_size + page_size)
signo = 0;
# if DEBUG
{
char buf[1024];
sprintf (buf,
"segv_handler fault=%p base=%p size=%lx page=%lx signo=%d\n",
faulting_address, stack_base, (unsigned long) stack_size,
(unsigned long) page_size, signo);
write (STDERR_FILENO, buf, strlen (buf));
}
# endif
}
die (signo);
}
# endif
static void
null_action (int signo __attribute__ ((unused)))
{
}
/* Assuming ARGV is the argument vector of `main', set up ACTION so
that it is invoked on C stack overflow. Return -1 (setting errno)
if this cannot be done.
When ACTION is called, it is passed an argument equal to SIGSEGV
for a segmentation violation that does not appear related to stack
overflow, and is passed zero otherwise.
A null ACTION acts like an action that does nothing.
ACTION must be async-signal-safe. ACTION together with its callees
must not require more than SIGSTKSZ bytes of stack space. */
int
c_stack_action (char * const *argv __attribute__ ((unused)),
void (*action) (int))
{
int r = get_stack_location (argv);
if (r != 0)
return r;
{
stack_t st;
st.ss_flags = 0;
st.ss_sp = alternate_signal_stack.buffer;
st.ss_size = sizeof alternate_signal_stack.buffer;
r = sigaltstack (&st, 0);
if (r != 0)
return r;
}
segv_action = action ? action : null_action;
program_error_message = _("program error");
stack_overflow_message = _("stack overflow");
{
# if ! (defined SA_ONSTACK && defined SA_SIGINFO && defined _SC_PAGESIZE)
return signal (SIGSEGV, die) == SIG_ERR ? -1 : 0;
# else
struct sigaction act;
sigemptyset (&act.sa_mask);
/* POSIX 1003.1-2001 says SA_RESETHAND implies SA_NODEFER, but
this is not true on Solaris 8 at least. It doesn't hurt to use
SA_NODEFER here, so leave it in. */
act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
act.sa_sigaction = segv_handler;
return sigaction (SIGSEGV, &act, 0);
# endif
}
}
#else /* ! (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK) */
int
c_stack_action (char * const *argv __attribute__ ((unused)),
void (*action) (int) __attribute__ ((unused)))
{
errno = ENOTSUP;
return -1;
}
#endif
#if DEBUG
int volatile exit_failure;
static long
recurse (char *p)
{
char array[500];
array[0] = 1;
return *p + recurse (array);
}
char *program_name;
int
main (int argc __attribute__ ((unused)), char **argv)
{
program_name = argv[0];
fprintf (stderr, "The last line of output should be \"stack overflow\".\n");
if (c_stack_action (argv, 0) == 0)
return recurse ("\1");
perror ("c_stack_action");
return 1;
}
#endif /* DEBUG */
/*
Local Variables:
compile-command: "gcc -DDEBUG -DHAVE_CONFIG_H -I.. -g -O -Wall -W c-stack.c"
End:
*/

19
lib/c-stack.h Normal file
View File

@@ -0,0 +1,19 @@
/* Stack overflow handling.
Copyright (C) 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
int c_stack_action (char * const *, void (*) (int));

View File

@@ -22,6 +22,6 @@
#ifndef HAVE_DECL_DIRFD
"this configure-time declaration test was not run"
#endif
#if !HAVE_DECL_DIRFD
#if !HAVE_DECL_DIRFD && !defined dirfd
int dirfd (DIR const *);
#endif

31
lib/exitfail.c Normal file
View File

@@ -0,0 +1,31 @@
/* Failure exit status
Copyright (C) 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifndef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif
int volatile exit_failure = EXIT_FAILURE;

20
lib/exitfail.h Normal file
View File

@@ -0,0 +1,20 @@
/* Failure exit status
Copyright (C) 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
extern int volatile exit_failure;

72
lib/file-type.c Normal file
View File

@@ -0,0 +1,72 @@
/* Return a string describing the type of a file.
Copyright (C) 1993, 1994, 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Paul Eggert. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include "file-type.h"
#include <gettext.h>
#define _(text) gettext (text)
char const *
file_type (struct stat const *st)
{
/* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107 for some of
these formats.
To keep diagnostics grammatical in English, the returned string
must start with a consonant. */
if (S_ISREG (st->st_mode))
return st->st_size == 0 ? _("regular empty file") : _("regular file");
if (S_ISDIR (st->st_mode))
return _("directory");
if (S_ISBLK (st->st_mode))
return _("block special file");
if (S_ISCHR (st->st_mode))
return _("character special file");
if (S_ISFIFO (st->st_mode))
return _("fifo");
if (S_ISLNK (st->st_mode))
return _("symbolic link");
if (S_ISSOCK (st->st_mode))
return _("socket");
if (S_TYPEISMQ (st))
return _("message queue");
if (S_TYPEISSEM (st))
return _("semaphore");
if (S_TYPEISSHM (st))
return _("shared memory object");
return _("weird file");
}

161
lib/file-type.h Normal file
View File

@@ -0,0 +1,161 @@
/* Return a string describing the type of a file.
Copyright (C) 1993, 1994, 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Paul Eggert and Jim Meyering. */
#ifndef FILE_TYPE_H
# define FILE_TYPE_H 1
# if ! defined S_ISREG && ! defined S_IFREG
you must include <sys/stat.h> before including this file
# endif
char const *file_type (struct stat const *);
# ifndef S_IFMT
# define S_IFMT 0170000
# endif
# if STAT_MACROS_BROKEN
# undef S_ISBLK
# undef S_ISCHR
# undef S_ISDIR
# undef S_ISDOOR
# undef S_ISFIFO
# undef S_ISLNK
# undef S_ISNAM
# undef S_ISMPB
# undef S_ISMPC
# undef S_ISNWK
# undef S_ISREG
# undef S_ISSOCK
# endif
# ifndef S_ISBLK
# ifdef S_IFBLK
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
# else
# define S_ISBLK(m) 0
# endif
# endif
# ifndef S_ISCHR
# ifdef S_IFCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
# else
# define S_ISCHR(m) 0
# endif
# endif
# ifndef S_ISDIR
# ifdef S_IFDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
# else
# define S_ISDIR(m) 0
# endif
# endif
# ifndef S_ISDOOR /* Solaris 2.5 and up */
# ifdef S_IFDOOR
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
# else
# define S_ISDOOR(m) 0
# endif
# endif
# ifndef S_ISFIFO
# ifdef S_IFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
# else
# define S_ISFIFO(m) 0
# endif
# endif
# ifndef S_ISLNK
# ifdef S_IFLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# else
# define S_ISLNK(m) 0
# endif
# endif
# ifndef S_ISMPB /* V7 */
# ifdef S_IFMPB
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
# else
# define S_ISMPB(m) 0
# define S_ISMPC(m) 0
# endif
# endif
# ifndef S_ISNAM /* Xenix */
# ifdef S_IFNAM
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
# else
# define S_ISNAM(m) 0
# endif
# endif
# ifndef S_ISNWK /* HP/UX */
# ifdef S_IFNWK
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
# else
# define S_ISNWK(m) 0
# endif
# endif
# ifndef S_ISREG
# ifdef S_IFREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
# else
# define S_ISREG(m) 0
# endif
# endif
# ifndef S_ISSOCK
# ifdef S_IFSOCK
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
# else
# define S_ISSOCK(m) 0
# endif
# endif
# ifndef S_TYPEISSEM
# ifdef S_INSEM
# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
# else
# define S_TYPEISSEM(p) 0
# endif
# endif
# ifndef S_TYPEISSHM
# ifdef S_INSHD
# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
# else
# define S_TYPEISSHM(p) 0
# endif
# endif
# ifndef S_TYPEISMQ
# define S_TYPEISMQ(p) 0
# endif
#endif /* FILE_TYPE_H */

View File

@@ -1,4 +1,5 @@
/* Copyright 1991, 1992, 1993, 1996, 1997, 2000 Free Software Foundation, Inc.
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -10,9 +11,9 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#if HAVE_CONFIG_H
# include <config.h>
@@ -23,208 +24,362 @@
# define _GNU_SOURCE 1
#endif
#ifdef __GNUC__
# define alloca __builtin_alloca
# define HAVE_ALLOCA 1
#else
# if defined HAVE_ALLOCA_H || defined _LIBC
# include <alloca.h>
# else
# ifdef _AIX
# pragma alloca
# else
# ifndef alloca
char *alloca ();
# endif
# endif
# endif
#endif
#if ! defined __builtin_expect && __GNUC__ < 3
# define __builtin_expect(expr, expected) (expr)
#endif
#include <assert.h>
#include <errno.h>
#include <fnmatch.h>
#include <ctype.h>
#if defined STDC_HEADERS || !defined isascii
# define IN_CTYPE_DOMAIN(c) 1
#if HAVE_STRING_H || defined _LIBC
# include <string.h>
#else
# define IN_CTYPE_DOMAIN(c) isascii (c)
# if HAVE_STRINGS_H
# include <strings.h>
# endif
#endif
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
#if defined STDC_HEADERS || defined _LIBC
# include <stddef.h>
# include <stdlib.h>
#endif
/* For platform which support the ISO C amendement 1 functionality we
support user defined character classes. */
#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
# include <wchar.h>
# include <wctype.h>
#endif
/* We need some of the locale data (the collation sequence information)
but there is no interface to get this information in general. Therefore
we support a correct implementation only in glibc. */
#ifdef _LIBC
# include "../locale/localeinfo.h"
# include "../locale/elem-hash.h"
# include "../locale/coll-lookup.h"
# include <shlib-compat.h>
# define CONCAT(a,b) __CONCAT(a,b)
# define mbsinit __mbsinit
# define mbsrtowcs __mbsrtowcs
# define fnmatch __fnmatch
extern int fnmatch (const char *pattern, const char *string, int flags);
#endif
/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */
#define NO_LEADING_PERIOD(flags) \
((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))
/* Comment out all this code if we are using the GNU C Library, are not
actually compiling the library itself, and have not detected a bug
in the library. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU
#ifndef errno
# undef ISASCII /* defined in Solaris5.6's /usr/include/sys/euc.h */
# if defined STDC_HEADERS || !defined isascii
# define ISASCII(c) 1
# else
# define ISASCII(c) isascii(c)
# endif
# ifdef isblank
# define ISBLANK(c) (ISASCII (c) && isblank (c))
# else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
# endif
# ifdef isgraph
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
# else
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
# endif
# undef ISPRINT /* defined in Solaris5.6's /usr/include/sys/euc.h */
# 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 STREQ(s1, s2) ((strcmp (s1, s2) == 0))
# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
/* The GNU C library provides support for user-defined character classes
and the functions from ISO C amendement 1. */
# ifdef CHARCLASS_NAME_MAX
# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
# else
/* This shouldn't happen but some implementation might still have this
problem. Use a reasonable default value. */
# define CHAR_CLASS_MAX_LENGTH 256
# endif
# ifdef _LIBC
# define IS_CHAR_CLASS(string) __wctype (string)
# else
# define IS_CHAR_CLASS(string) wctype (string)
# endif
# ifdef _LIBC
# define ISWCTYPE(WC, WT) __iswctype (WC, WT)
# else
# define ISWCTYPE(WC, WT) iswctype (WC, WT)
# endif
# if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
/* In this case we are implementing the multibyte character handling. */
# define HANDLE_MULTIBYTE 1
# endif
# else
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
# define IS_CHAR_CLASS(string) \
(STREQ (string, "alpha") || STREQ (string, "upper") \
|| STREQ (string, "lower") || STREQ (string, "digit") \
|| STREQ (string, "alnum") || STREQ (string, "xdigit") \
|| STREQ (string, "space") || STREQ (string, "print") \
|| STREQ (string, "punct") || STREQ (string, "graph") \
|| STREQ (string, "cntrl") || STREQ (string, "blank"))
# endif
/* Avoid depending on library functions or files
whose names are inconsistent. */
# if !defined _LIBC && !defined getenv && !HAVE_DECL_GETENV
extern char *getenv ();
# endif
# ifndef errno
extern int errno;
#endif
# endif
/* Match STRING against the filename pattern PATTERN, returning zero if
it matches, nonzero if not. */
int
fnmatch (const char *pattern, const char *string, int flags)
{
register const char *p = pattern, *n = string;
register char c;
/* Global variable. */
static int posixly_correct;
# ifndef internal_function
/* Inside GNU libc we mark some function in a special way. In other
environments simply ignore the marking. */
# define internal_function
# endif
/* Note that this evaluates C many times. */
#define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER ((unsigned char) (c)) \
? tolower ((unsigned char) (c)) \
: (c))
# ifdef _LIBC
# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
# else
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
# endif
# define CHAR char
# define UCHAR unsigned char
# define INT int
# define FCT internal_fnmatch
# define EXT ext_match
# define END end_pattern
# define L(CS) CS
# ifdef _LIBC
# define BTOWC(C) __btowc (C)
# else
# define BTOWC(C) btowc (C)
# endif
# define STRLEN(S) strlen (S)
# define STRCAT(D, S) strcat (D, S)
# ifdef _LIBC
# define MEMPCPY(D, S, N) __mempcpy (D, S, N)
# else
# if HAVE_MEMPCPY
# define MEMPCPY(D, S, N) mempcpy (D, S, N)
# else
# define MEMPCPY(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
# endif
# endif
# define MEMCHR(S, C, N) memchr (S, C, N)
# define STRCOLL(S1, S2) strcoll (S1, S2)
# include "fnmatch_loop.c"
while ((c = *p++) != '\0')
# if HANDLE_MULTIBYTE
# define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
# define CHAR wchar_t
# define UCHAR wint_t
# define INT wint_t
# define FCT internal_fnwmatch
# define EXT ext_wmatch
# define END end_wpattern
# define L(CS) L##CS
# define BTOWC(C) (C)
# ifdef _LIBC
# define STRLEN(S) __wcslen (S)
# define STRCAT(D, S) __wcscat (D, S)
# define MEMPCPY(D, S, N) __wmempcpy (D, S, N)
# else
# define STRLEN(S) wcslen (S)
# define STRCAT(D, S) wcscat (D, S)
# if HAVE_WMEMPCPY
# define MEMPCPY(D, S, N) wmempcpy (D, S, N)
# else
# define MEMPCPY(D, S, N) (wmemcpy (D, S, N) + (N))
# endif
# endif
# define MEMCHR(S, C, N) wmemchr (S, C, N)
# define STRCOLL(S1, S2) wcscoll (S1, S2)
# define WIDE_CHAR_VERSION 1
# undef IS_CHAR_CLASS
/* We have to convert the wide character string in a multibyte string. But
we know that the character class names consist of alphanumeric characters
from the portable character set, and since the wide character encoding
for a member of the portable character set is the same code point as
its single-byte encoding, we can use a simplified method to convert the
string to a multibyte character string. */
static wctype_t
is_char_class (const wchar_t *wcs)
{
char s[CHAR_CLASS_MAX_LENGTH + 1];
char *cp = s;
do
{
c = FOLD (c);
switch (c)
/* Test for a printable character from the portable character set. */
# ifdef _LIBC
if (*wcs < 0x20 || *wcs > 0x7e
|| *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
return (wctype_t) 0;
# else
switch (*wcs)
{
case '?':
if (*n == '\0')
return FNM_NOMATCH;
else if ((flags & FNM_FILE_NAME) && *n == '/')
return FNM_NOMATCH;
else if ((flags & FNM_PERIOD) && *n == '.' &&
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
case L' ': case L'!': case L'"': case L'#': case L'%':
case L'&': case L'\'': case L'(': case L')': case L'*':
case L'+': case L',': case L'-': case L'.': case L'/':
case L'0': case L'1': case L'2': case L'3': case L'4':
case L'5': case L'6': case L'7': case L'8': case L'9':
case L':': case L';': case L'<': case L'=': case L'>':
case L'?':
case L'A': case L'B': case L'C': case L'D': case L'E':
case L'F': case L'G': case L'H': case L'I': case L'J':
case L'K': case L'L': case L'M': case L'N': case L'O':
case L'P': case L'Q': case L'R': case L'S': case L'T':
case L'U': case L'V': case L'W': case L'X': case L'Y':
case L'Z':
case L'[': case L'\\': case L']': case L'^': case L'_':
case L'a': case L'b': case L'c': case L'd': case L'e':
case L'f': case L'g': case L'h': case L'i': case L'j':
case L'k': case L'l': case L'm': case L'n': case L'o':
case L'p': case L'q': case L'r': case L's': case L't':
case L'u': case L'v': case L'w': case L'x': case L'y':
case L'z': case L'{': case L'|': case L'}': case L'~':
break;
case '\\':
if (!(flags & FNM_NOESCAPE))
{
c = *p++;
if (c == '\0')
/* Trailing \ loses. */
return FNM_NOMATCH;
c = FOLD (c);
}
if (FOLD (*n) != c)
return FNM_NOMATCH;
break;
case '*':
if ((flags & FNM_PERIOD) && *n == '.' &&
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
for (c = *p++; c == '?' || c == '*'; c = *p++)
{
if (c == '?')
{
/* A ? needs to match one character. */
if (*n == '\0' || (*n == '/' && (flags & FNM_FILE_NAME)))
/* There isn't another character; no match. */
return FNM_NOMATCH;
else
/* One character of the string is consumed in matching
this ? wildcard, so *??? won't match if there are
less than three characters. */
++n;
}
}
if (c == '\0')
{
if ((flags & (FNM_FILE_NAME | FNM_LEADING_DIR)) == FNM_FILE_NAME)
for (; *n != '\0'; n++)
if (*n == '/')
return FNM_NOMATCH;
return 0;
}
{
char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
c1 = FOLD (c1);
for (--p; *n != '\0'; ++n)
if ((c == '[' || FOLD (*n) == c1) &&
fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
return 0;
else if (*n == '/' && (flags & FNM_FILE_NAME))
break;
return FNM_NOMATCH;
}
case '[':
{
/* Nonzero if the sense of the character class is inverted. */
register int not;
if (*n == '\0')
return FNM_NOMATCH;
if ((flags & FNM_PERIOD) && *n == '.' &&
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
not = (*p == '!' || *p == '^');
if (not)
++p;
c = *p++;
for (;;)
{
register char cstart = c, cend = c;
if (!(flags & FNM_NOESCAPE) && c == '\\')
{
if (*p == '\0')
return FNM_NOMATCH;
cstart = cend = *p++;
}
cstart = cend = FOLD (cstart);
if (c == '\0')
/* [ (unterminated) loses. */
return FNM_NOMATCH;
c = *p++;
c = FOLD (c);
if ((flags & FNM_FILE_NAME) && c == '/')
/* [/] can never match. */
return FNM_NOMATCH;
if (c == '-' && *p != ']')
{
cend = *p++;
if (!(flags & FNM_NOESCAPE) && cend == '\\')
cend = *p++;
if (cend == '\0')
return FNM_NOMATCH;
cend = FOLD (cend);
c = *p++;
}
if (FOLD (*n) >= cstart && FOLD (*n) <= cend)
goto matched;
if (c == ']')
break;
}
if (!not)
return FNM_NOMATCH;
break;
matched:;
/* Skip the rest of the [...] that already matched. */
while (c != ']')
{
if (c == '\0')
/* [... (unterminated) loses. */
return FNM_NOMATCH;
c = *p++;
if (!(flags & FNM_NOESCAPE) && c == '\\')
{
if (*p == '\0')
return FNM_NOMATCH;
/* XXX 1003.2d11 is unclear if this is right. */
++p;
}
}
if (not)
return FNM_NOMATCH;
}
break;
default:
if (c != FOLD (*n))
return FNM_NOMATCH;
return (wctype_t) 0;
}
# endif
++n;
/* Avoid overrunning the buffer. */
if (cp == s + CHAR_CLASS_MAX_LENGTH)
return (wctype_t) 0;
*cp++ = (char) *wcs++;
}
while (*wcs != L'\0');
if (*n == '\0')
return 0;
*cp = '\0';
if ((flags & FNM_LEADING_DIR) && *n == '/')
/* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
return 0;
return FNM_NOMATCH;
#undef FOLD
# ifdef _LIBC
return __wctype (s);
# else
return wctype (s);
# endif
}
# define IS_CHAR_CLASS(string) is_char_class (string)
# include "fnmatch_loop.c"
# endif
int
fnmatch (pattern, string, flags)
const char *pattern;
const char *string;
int flags;
{
# if HANDLE_MULTIBYTE
if (__builtin_expect (MB_CUR_MAX, 1) != 1)
{
mbstate_t ps;
size_t n;
wchar_t *wpattern;
wchar_t *wstring;
/* Convert the strings into wide characters. */
memset (&ps, '\0', sizeof (ps));
n = mbsrtowcs (NULL, &pattern, 0, &ps);
if (__builtin_expect (n, 0) == (size_t) -1)
/* Something wrong.
XXX Do we have to set `errno' to something which mbsrtows hasn't
already done? */
return -1;
wpattern = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t));
assert (mbsinit (&ps));
(void) mbsrtowcs (wpattern, &pattern, n + 1, &ps);
assert (mbsinit (&ps));
n = mbsrtowcs (NULL, &string, 0, &ps);
if (__builtin_expect (n, 0) == (size_t) -1)
/* Something wrong.
XXX Do we have to set `errno' to something which mbsrtows hasn't
already done? */
return -1;
wstring = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t));
assert (mbsinit (&ps));
(void) mbsrtowcs (wstring, &string, n + 1, &ps);
return internal_fnwmatch (wpattern, wstring, wstring + n,
flags & FNM_PERIOD, flags);
}
# endif /* mbstate_t and mbsrtowcs or _LIBC. */
return internal_fnmatch (pattern, string, string + strlen (string),
flags & FNM_PERIOD, flags);
}
# ifdef _LIBC
# undef fnmatch
versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3);
# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3)
strong_alias (__fnmatch, __fnmatch_old)
compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
# endif
# endif
#endif /* _LIBC or not __GNU_LIBRARY__. */

View File

@@ -1,69 +0,0 @@
/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
#ifdef __cplusplus
extern "C" {
#endif
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
#undef __P
#define __P(protos) protos
#else /* Not C++ or ANSI C. */
#undef __P
#define __P(protos) ()
/* We can get away without defining `const' here only because in this file
it is used only inside the prototype for `fnmatch', which is elided in
non-ANSI C where `const' is problematical. */
#endif /* C++ or ANSI C. */
/* We #undef these before defining them because some losing systems
(HP-UX A.08.07 for example) define these in <unistd.h>. */
#undef FNM_PATHNAME
#undef FNM_NOESCAPE
#undef FNM_PERIOD
/* Bits set in the FLAGS argument to `fnmatch'. */
#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE)
#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
#endif
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
#define FNM_NOMATCH 1
/* Match STRING against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
extern int fnmatch __P ((const char *__pattern, const char *__string,
int __flags));
#ifdef __cplusplus
}
#endif
#endif /* fnmatch.h */

80
lib/fnmatch_.h Normal file
View File

@@ -0,0 +1,80 @@
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _FNMATCH_H
# define _FNMATCH_H 1
# ifdef __cplusplus
extern "C" {
# endif
# if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
# if !defined __GLIBC__ || !defined __P
# undef __P
# define __P(protos) protos
# endif
# else /* Not C++ or ANSI C. */
# undef __P
# define __P(protos) ()
/* We can get away without defining `const' here only because in this file
it is used only inside the prototype for `fnmatch', which is elided in
non-ANSI C where `const' is problematical. */
# endif /* C++ or ANSI C. */
# ifndef __const
# define __const const
# endif
/* We #undef these before defining them because some losing systems
(HP-UX A.08.07 for example) define these in <unistd.h>. */
# undef FNM_PATHNAME
# undef FNM_NOESCAPE
# undef FNM_PERIOD
/* Bits set in the FLAGS argument to `fnmatch'. */
# define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
# define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
# define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
# if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
# endif
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
# define FNM_NOMATCH 1
/* This value is returned if the implementation does not support
`fnmatch'. Since this is not the case here it will never be
returned but the conformance test suites still require the symbol
to be defined. */
# ifdef _XOPEN_SOURCE
# define FNM_NOSYS (-1)
# endif
/* Match NAME against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
extern int fnmatch __P ((__const char *__pattern, __const char *__name,
int __flags));
# ifdef __cplusplus
}
# endif
#endif /* fnmatch.h */

1189
lib/fnmatch_loop.c Normal file

File diff suppressed because it is too large Load Diff

59
lib/gettext.h Normal file
View File

@@ -0,0 +1,59 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef _LIBGETTEXT_H
# define _LIBGETTEXT_H 1
/* NLS can be disabled through the configure --disable-nls option. */
# if ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
# include <libintl.h>
# else
/* Disabled NLS.
The casts to 'const char *' serve the purpose of producing warnings
for invalid uses of the value returned from these functions.
On pre-ANSI systems without 'const', the config.h file is supposed to
contain "#define const". */
# define gettext(Msgid) ((const char *) (Msgid))
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
# define ngettext(Msgid1, Msgid2, N) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define dngettext(Domainname, Msgid1, Msgid2, N) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define textdomain(Domainname) ((const char *) (Domainname))
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
# endif
/* A pseudo function call that serves as a marker for the automated
extraction of messages, but does not call gettext(). The run-time
translation is done at a different place in the code.
The argument, String, should be a literal string. Concatenated strings
and other string expressions won't work.
The macro's expansion is not parenthesized, so that it is suitable as
initializer for static 'char[]' or 'const char[]' variables. */
# define gettext_noop(String) String
#endif /* _LIBGETTEXT_H */

View File

@@ -1,7 +1,7 @@
/* Work around the bug in some systems whereby gettimeofday clobbers the
static buffer that localtime uses for it's return value. The gettimeofday
function from Mac OS X 10.0.4, i.e. Darwin 1.3.7 has this problem.
Copyright (C) 2001 Free Software Foundation, Inc.
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,9 +21,10 @@
#include <config.h>
/* Disable the definition of gettimeofday (from config.h) so we can use
the library version. */
/* Disable the definitions of gettimeofday and localtime (from config.h)
so we can use the library versions here. */
#undef gettimeofday
#undef localtime
#include <sys/types.h>
@@ -42,6 +43,23 @@
static struct tm *localtime_buffer_addr;
/* This is a wrapper for localtime. It is used only on systems for which
gettimeofday clobbers the static buffer used for localtime's result.
On the first call, record the address of the static buffer that
localtime uses for its result. */
struct tm *
rpl_localtime (const time_t *timep)
{
struct tm *tm = localtime (timep);
if (! localtime_buffer_addr)
localtime_buffer_addr = tm;
return tm;
}
/* This is a wrapper for gettimeofday. It is used only on systems for which
gettimeofday clobbers the static buffer used for localtime's result.

View File

@@ -1,5 +1,6 @@
/* hard-locale.c -- Determine whether a locale is hard.
Copyright 1997, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,41 +20,26 @@
# include <config.h>
#endif
#if __GNUC__
# define alloca __builtin_alloca
#else
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef _AIX
# pragma alloca
# else
# ifdef _WIN32
# include <malloc.h>
# include <io.h>
# else
# ifndef alloca
char *alloca ();
# endif
# endif
# endif
# endif
#endif
#if HAVE_LOCALE_H
# include <locale.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#endif
#include "hard-locale.h"
/* Return nonzero if the current CATEGORY locale is hard, i.e. if you
can't get away with assuming traditional C or POSIX behavior. */
int
hard_locale (int category)
{
#if ! (defined ENABLE_NLS && HAVE_SETLOCALE)
#if ! HAVE_SETLOCALE
return 0;
#else
@@ -62,22 +48,28 @@ hard_locale (int category)
if (p)
{
# if defined __GLIBC__ && __GLIBC__ >= 2
# if defined __GLIBC__ && 2 <= __GLIBC__
if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
hard = 0;
# else
char *locale = alloca (strlen (p) + 1);
strcpy (locale, p);
char *locale = malloc (strlen (p) + 1);
if (locale)
{
strcpy (locale, p);
/* Temporarily set the locale to the "C" and "POSIX" locales to
find their names, so that we can determine whether one or the
other is the caller's locale. */
if (((p = setlocale (category, "C")) && strcmp (p, locale) == 0)
|| ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0))
hard = 0;
/* Temporarily set the locale to the "C" and "POSIX" locales
to find their names, so that we can determine whether one
or the other is the caller's locale. */
if (((p = setlocale (category, "C"))
&& strcmp (p, locale) == 0)
|| ((p = setlocale (category, "POSIX"))
&& strcmp (p, locale) == 0))
hard = 0;
/* Restore the caller's locale. */
setlocale (category, locale);
/* Restore the caller's locale. */
setlocale (category, locale);
free (locale);
}
# endif
}

View File

@@ -1,5 +1,5 @@
/* Provide a stub lchown function for systems that lack it.
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,8 +30,13 @@ extern int errno;
#ifdef STAT_MACROS_BROKEN
# undef S_ISLNK
#endif
#if !defined(S_ISLNK) && defined(S_IFLNK)
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#ifndef S_ISLNK
# ifdef S_IFLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# else
# define S_ISLNK(m) 0
# endif
#endif
/* Declare chown to avoid a warning. Don't include unistd.h,

View File

@@ -1,5 +1,5 @@
/* Declarations for GNU's read utmp module.
Copyright (C) 1992-2001 Free Software Foundation, Inc.
Copyright (C) 1992-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -69,9 +69,6 @@
# undef UT_USER
# define UT_USER(Utmp) ((Utmp)->ut_name)
# endif
# if defined HAVE_STRUCT_UTMPX_UT_TYPE
# define UT_TYPE(Utmp) ((Utmp)->ut_type)
# endif
# else
@@ -82,12 +79,25 @@
# undef UT_USER
# define UT_USER(Utmp) Utmp->ut_name
# endif
# if defined HAVE_STRUCT_UTMP_UT_TYPE
# define UT_TYPE(Utmp) ((Utmp)->ut_type)
# endif
# endif
# define HAVE_STRUCT_XTMP_UT_EXIT \
(HAVE_STRUCT_UTMP_UT_EXIT \
|| HAVE_STRUCT_UTMPX_UT_EXIT)
# define HAVE_STRUCT_XTMP_UT_ID \
(HAVE_STRUCT_UTMP_UT_ID \
|| HAVE_STRUCT_UTMPX_UT_ID)
# define HAVE_STRUCT_XTMP_UT_PID \
(HAVE_STRUCT_UTMP_UT_PID \
|| HAVE_STRUCT_UTMPX_UT_PID)
# define HAVE_STRUCT_XTMP_UT_TYPE \
(HAVE_STRUCT_UTMP_UT_TYPE \
|| HAVE_STRUCT_UTMPX_UT_TYPE)
typedef struct UTMP_STRUCT_NAME STRUCT_UTMP;
# include <time.h>

346
lib/sig2str.c Normal file
View File

@@ -0,0 +1,346 @@
/* sig2str.c -- convert between signal names and numbers
Copyright (C) 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Paul Eggert. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "sig2str.h"
#ifndef SIGRTMIN
# define SIGRTMIN 0
# undef SIGRTMAX
#endif
#ifndef SIGRTMAX
# define SIGRTMAX (SIGRTMIN - 1)
#endif
#define NUMNAME(name) { SIG##name, #name }
/* Signal names and numbers. Put the preferred name first. */
static struct numname { int num; char const name[8]; } numname_table[] =
{
/* Signals required by POSIX 1003.1-2001 base, listed in
traditional numeric order. */
#ifdef SIGHUP
NUMNAME (HUP),
#endif
#ifdef SIGINT
NUMNAME (INT),
#endif
#ifdef SIGQUIT
NUMNAME (QUIT),
#endif
#ifdef SIGILL
NUMNAME (ILL),
#endif
#ifdef SIGTRAP
NUMNAME (TRAP),
#endif
#ifdef SIGABRT
NUMNAME (ABRT),
#endif
#ifdef SIGFPE
NUMNAME (FPE),
#endif
#ifdef SIGKILL
NUMNAME (KILL),
#endif
#ifdef SIGBUS
NUMNAME (BUS),
#endif
#ifdef SIGSEGV
NUMNAME (SEGV),
#endif
#ifdef SIGPIPE
NUMNAME (PIPE),
#endif
#ifdef SIGALRM
NUMNAME (ALRM),
#endif
#ifdef SIGTERM
NUMNAME (TERM),
#endif
#ifdef SIGUSR1
NUMNAME (USR1),
#endif
#ifdef SIGUSR2
NUMNAME (USR2),
#endif
#ifdef SIGCHLD
NUMNAME (CHLD),
#endif
#ifdef SIGURG
NUMNAME (URG),
#endif
#ifdef SIGSTOP
NUMNAME (STOP),
#endif
#ifdef SIGTSTP
NUMNAME (TSTP),
#endif
#ifdef SIGCONT
NUMNAME (CONT),
#endif
#ifdef SIGTTIN
NUMNAME (TTIN),
#endif
#ifdef SIGTTOU
NUMNAME (TTOU),
#endif
/* Signals required by POSIX 1003.1-2001 with the XSI extension. */
#ifdef SIGSYS
NUMNAME (SYS),
#endif
#ifdef SIGPOLL
NUMNAME (POLL),
#endif
#ifdef SIGVTALRM
NUMNAME (VTALRM),
#endif
#ifdef SIGPROF
NUMNAME (PROF),
#endif
#ifdef SIGXCPU
NUMNAME (XCPU),
#endif
#ifdef SIGXFSZ
NUMNAME (XFSZ),
#endif
/* Unix Version 7. */
#ifdef SIGIOT
NUMNAME (IOT), /* Older name for ABRT. */
#endif
#ifdef SIGEMT
NUMNAME (EMT),
#endif
/* USG Unix. */
#ifdef SIGPHONE
NUMNAME (PHONE),
#endif
#ifdef SIGWIND
NUMNAME (WIND),
#endif
/* Unix System V. */
#ifdef SIGCLD
NUMNAME (CLD),
#endif
#ifdef SIGPWR
NUMNAME (PWR),
#endif
/* GNU/Linux 2.2 and Solaris 8. */
#ifdef SIGCANCEL
NUMNAME (CANCEL),
#endif
#ifdef SIGLWP
NUMNAME (LWP),
#endif
#ifdef SIGWAITING
NUMNAME (WAITING),
#endif
#ifdef SIGFREEZE
NUMNAME (FREEZE),
#endif
#ifdef SIGTHAW
NUMNAME (THAW),
#endif
#ifdef SIGLOST
NUMNAME (LOST),
#endif
#ifdef SIGWINCH
NUMNAME (WINCH),
#endif
/* GNU/Linux 2.2. */
#ifdef SIGINFO
NUMNAME (INFO),
#endif
#ifdef SIGIO
NUMNAME (IO),
#endif
#ifdef SIGSTKFLT
NUMNAME (STKFLT),
#endif
/* AIX 5L. */
#ifdef SIGDANGER
NUMNAME (DANGER),
#endif
#ifdef SIGGRANT
NUMNAME (GRANT),
#endif
#ifdef SIGMIGRATE
NUMNAME (MIGRATE),
#endif
#ifdef SIGMSG
NUMNAME (MSG),
#endif
#ifdef SIGPRE
NUMNAME (PRE),
#endif
#ifdef SIGRETRACT
NUMNAME (RETRACT),
#endif
#ifdef SIGSAK
NUMNAME (SAK),
#endif
#ifdef SIGSOUND
NUMNAME (SOUND),
#endif
/* Older AIX versions. */
#ifdef SIGALRM1
NUMNAME (ALRM1), /* unknown; taken from Bash 2.05 */
#endif
#ifdef SIGKAP
NUMNAME (KAP), /* Older name for SIGGRANT. */
#endif
#ifdef SIGVIRT
NUMNAME (VIRT), /* unknown; taken from Bash 2.05 */
#endif
#ifdef SIGWINDOW
NUMNAME (WINDOW), /* Older name for SIGWINCH. */
#endif
/* BeOS */
#ifdef SIGKILLTHR
NUMNAME (KILLTHR),
#endif
/* Older HP-UX versions. */
#ifdef SIGDIL
NUMNAME (DIL),
#endif
/* Korn shell and Bash, of uncertain vintage. */
{ 0, "EXIT" }
};
#define NUMNAME_ENTRIES (sizeof numname_table / sizeof numname_table[0])
/* ISDIGIT differs from isdigit, as follows:
- Its arg may be any int or unsigned int; it need not be an unsigned char.
- It's guaranteed to evaluate its argument exactly once.
- It's typically faster.
POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
ISDIGIT_LOCALE unless it's important to use the locale's definition
of `digit' even when the host does not conform to POSIX. */
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
/* Convert the signal name SIGNAME to a signal number. Return the
signal number if successful, -1 otherwise. */
static int
str2signum (char const *signame)
{
if (ISDIGIT (*signame))
{
char *endp;
long int n = strtol (signame, &endp, 10);
if (! *endp && n <= SIGNUM_BOUND)
return n;
}
else
{
int i;
for (i = 0; i < NUMNAME_ENTRIES; i++)
if (strcmp (numname_table[i].name, signame) == 0)
return numname_table[i].num;
{
char *endp;
int rtmin = SIGRTMIN;
int rtmax = SIGRTMAX;
if (0 < rtmin && strncmp (signame, "RTMIN", 5) == 0)
{
long int n = strtol (signame + 5, &endp, 10);
if (! *endp && 0 <= n && n <= rtmax - rtmin)
return rtmin + n;
}
else if (0 < rtmax && strncmp (signame, "RTMAX", 5) == 0)
{
long int n = strtol (signame + 5, &endp, 10);
if (! *endp && rtmin - rtmax <= n && n <= 0)
return rtmax + n;
}
}
}
return -1;
}
/* Convert the signal name SIGNAME to the signal number *SIGNUM.
Return 0 if successful, -1 otherwise. */
int
str2sig (char const *signame, int *signum)
{
*signum = str2signum (signame);
return *signum < 0 ? -1 : 0;
}
/* Convert SIGNUM to a signal name in SIGNAME. SIGNAME must point to
a buffer of at least SIG2STR_MAX bytes. Return 0 if successful, -1
otherwise. */
int
sig2str (int signum, char *signame)
{
int i;
for (i = 0; i < NUMNAME_ENTRIES; i++)
if (numname_table[i].num == signum)
{
strcpy (signame, numname_table[i].name);
return 0;
}
{
int rtmin = SIGRTMIN;
int rtmax = SIGRTMAX;
if (! (rtmin <= signum && signum <= rtmax))
return -1;
if (signum <= rtmin + (rtmax - rtmin) / 2)
{
int delta = signum - rtmin;
sprintf (signame, delta ? "RTMIN+%d" : "RTMIN", delta);
}
else
{
int delta = rtmax - signum;
sprintf (signame, delta ? "RTMAX-%d" : "RTMAX", delta);
}
return 0;
}
}

47
lib/sig2str.h Normal file
View File

@@ -0,0 +1,47 @@
/* sig2str.h -- convert between signal names and numbers
Copyright (C) 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Paul Eggert. */
/* Include <signal.h> before including this file. */
/* Don't override system declarations of SIG2STR_MAX, sig2str, str2sig. */
#ifndef SIG2STR_MAX
/* Upper bound on the string length of an integer converted to string.
302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
add 1 for integer division truncation; add 1 more for a minus sign. */
# define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
/* Size of a buffer needed to hold a signal name like "HUP". */
# define SIG2STR_MAX (sizeof "SIGRTMAX" + INT_STRLEN_BOUND (int) - 1)
int sig2str (int, char *);
int str2sig (char const *, int *);
#endif
/* An upper bound on signal numbers allowed by the system. */
#if defined _sys_nsig
# define SIGNUM_BOUND (_sys_nsig - 1)
#elif defined NSIG
# define SIGNUM_BOUND (NSIG - 1)
#else
# define SIGNUM_BOUND 64
#endif

View File

@@ -4,7 +4,7 @@
/* Work around the bug in some systems whereby @xstat@ succeeds when
given the zero-length file name argument. The @xstat@ from SunOS4.1.4
has this bug.
Copyright (C) 1997-2001 Free Software Foundation, Inc.
Copyright (C) 1997-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -39,8 +39,13 @@ extern int errno;
#ifdef STAT_MACROS_BROKEN
# undef S_ISLNK
#endif
#if !defined(S_ISLNK) && defined(S_IFLNK)
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#ifndef S_ISLNK
# ifdef S_IFLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# else
# define S_ISLNK(m) 0
# endif
#endif
#ifndef HAVE_DECL_FREE

View File

@@ -1,3 +1,132 @@
2002-06-22 Jim Meyering <meyering@lucent.com>
* c-stack.m4: New file, from diffutils-2.8.2.
* prereq.m4 (jm_PREREQ): Add jm_PREREQ_C_STACK.
* jm-macros.m4 (jm_CHECK_ALL_TYPES): Don't require AC__GNU_SOURCE,
now that configure.ac uses AC_GNU_SOURCE.
(jm_MACROS): Rename: jm_FUNC_FNMATCH to AC_FUNC_FNMATCH_GNU.
* prereq.m4 (jm_PREREQ_EXCLUDE): Likewise, wrt jm_FUNC_FNMATCH.
Update to latest tools. Suggestions from Paul Eggert.
* stdbool.m4: New file, from diffutils-2.8.2.
* gnu-source.m4: Update from diffutils-2.8.2.
* fnmatch.m4: Likewise.
* prereq.m4: Change each use of AC_CHECK_HEADERS(stdbool.h)
to AC_HEADER_STDBOOL
2002-06-21 Jim Meyering <meyering@lucent.com>
* c-bs-a.m4: Add comment, from diffutils-2.8.2.
* mbrtowc.m4: Likewise.
* mbstate_t.m4: Update from diffutils-2.8.2.
* mbswidth.m4: Reflect name change:
s/AC_MBSTATE_T/AC_TYPE_MBSTATE_T.
* prereq.m4 (jm_PREREQ_QUOTEARG): Likewise.
* lib-link.m4: Update from gettext-0.11.2.
* gettext.m4: Likewise.
* jm-macros.m4 (jm_CHECK_ALL_HEADERS): Check for hurd.h.
From Alfred M. Szmidt.
2002-05-19 Paul Eggert <eggert@twinsun.com>
* jm-macros.m4 (jm_CHECK_ALL_TYPES): Check for st_author.
2002-06-07 Jim Meyering <meyering@lucent.com>
* prereq.m4 (jm_PREREQ_STAT): Check for sys/param.h and sys/mount.h.
They're needed at least for NetBSD 1.5.2.
($statxfs_includes): Include those same headers.
($statxfs_includes): Include sys/vfs.h if available.
($statxfs_includes): Likewise for sys/statvfs.h.
Check for the following members in both structs statfs and statvfs:
f_basetype, f_type, f_fsid.__val, f_namemax, f_namelen.
2002-06-01 Jim Meyering <meyering@lucent.com>
* d-type.m4 (jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE): Rename macro:
s/D_TYPE_IN_DIRENT/HAVE_STRUCT_DIRENT_D_TYPE/.
2002-05-28 Jim Meyering <meyering@lucent.com>
* readdir.m4 (jm_FUNC_READDIR): Undefine `mkdir', not `rmdir'.
Reported by Volker Borchert.
2002-05-27 Jim Meyering <meyering@lucent.com>
* gettimeofday.m4 (AC_FUNC_GETTIMEOFDAY_CLOBBER): Also replace
localtime.
* readdir.m4 (jm_FUNC_READDIR): Undefine `rmdir' so we don't try to
use the replacement function; it wouldn't resolve at link time.
Reported by Volker Borchert.
2002-04-30 Jim Meyering <meyering@lucent.com>
* prereq.m4 (jm_PREREQ): Add jm_PREREQ_STAT.
2002-04-29 Paul Eggert <eggert@twinsun.com>
* prereq.m4 (jm_PREREQ_HARD_LOCALE): Check for stdlib.h.
Do not check for alloca.h (no longer used) or stdbool.h (was never
used?). Add AM_C_PROTOTYPES since hard-locale.h uses it.
2002-04-28 Paul Eggert <eggert@twinsun.com>
* prereq.m4 (jm_PREREQ_SIG2STR): Remove; all callers changed.
2002-04-29 Jim Meyering <meyering@lucent.com>
* jm-macros.m4 (jm_MACROS): Remove use of AC_FUNC_STRNLEN.
* prereq.m4: Add jm_PREREQ_STRNLEN.
Use AC_FUNC_STRNLEN here instead.
* jm-macros.m4: Don't AC_REQUIRE([AC_PROG_CC_STDC]).
With autoconf-2.53a, it's part of AC_PROG_CC.
2002-04-28 Paul Eggert <eggert@twinsun.com>
* jm-macros.m4 (jm_MACROS): Add AC_REPLACE_FUNCS(sig2str).
* prereq.m4 (jm_PREREQ): Add jm_PREREQ_SIG2STR.
2002-04-24 Jim Meyering <meyering@lucent.com>
* prereq.m4 (jm_PREREQ_HARD_LOCALE): New macro.
(jm_PREREQ): Use it.
* getloadavg.m4: Check for these headers: locale.h unistd.h
mach/mach.h fcntl.h.
Check for this function: setlocale.
2002-04-16 Jim Meyering <meyering@lucent.com>
* prereq.m4 (jm_PREREQ_READUTMP): Also check for these members:
ut_pid, ut_id, ut_exit.
2002-04-12 Jim Meyering <meyering@lucent.com>
* ls-mntd-fs.m4 (checking for getmntinfo function...): Remove now-bogus
check for f_type in sys/mount.h. Instead, just test for the existence
of the getmntinfo function. Needed for Darwin 5.3.
* dirfd.m4 (UTILS_FUNC_DIRFD): Also detect when dirfd is a macro.
This is necessary at least on Darwin 5.3.
* jm-macros.m4: Don't AC_REPLACE(strnlen), now that we use
AC_FUNC_STRNLEN. Otherwise, we'd end up putting two copies of strnlen.o
in the library, and that makes some versions of ranlib object.
2002-04-09 Jim Meyering <meyering@lucent.com>
* malloc.m4: (jm_FUNC_MALLOC): Change the `checking ...' message
to be more precise. Rather than saying we're checking whether the
function `works', say what we're testing.
* realloc.m4 (jm_FUNC_REALLOC): Likewise.
Reported by Bruno Haible.
2002-02-27 Paul Eggert <eggert@twinsun.com>
* jm-macros.m4 (jm_MACROS): Do not replace stime; no longer used.

View File

@@ -8,6 +8,7 @@ afs.m4 \
assert.m4 \
bison.m4 \
c-bs-a.m4 \
c-stack.m4 \
check-decl.m4 \
chown.m4 \
codeset.m4 \
@@ -71,6 +72,7 @@ search-libs.m4 \
st_dm_mode.m4 \
st_mtim.m4 \
stat.m4 \
stdbool.m4 \
strerror_r.m4 \
strftime.m4 \
timespec.m4 \

View File

@@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.6 from Makefile.am.
# Makefile.in generated by automake 1.6.2 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
@@ -49,6 +49,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
@@ -125,6 +126,7 @@ afs.m4 \
assert.m4 \
bison.m4 \
c-bs-a.m4 \
c-stack.m4 \
check-decl.m4 \
chown.m4 \
codeset.m4 \
@@ -188,6 +190,7 @@ search-libs.m4 \
st_dm_mode.m4 \
st_mtim.m4 \
stat.m4 \
stdbool.m4 \
strerror_r.m4 \
strftime.m4 \
timespec.m4 \
@@ -223,7 +226,7 @@ top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
@list='$(DISTFILES)'; for file in $$list; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
@@ -233,8 +236,10 @@ distdir: $(DISTFILES)
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir)$$dir \
|| exit 1; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
@@ -266,7 +271,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"

View File

@@ -1,4 +1,10 @@
#serial 4
# c-bs-a.m4 serial 4 (fileutils-4.1.3)
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.

136
m4/c-stack.m4 Normal file
View File

@@ -0,0 +1,136 @@
# Check prerequisites for compiling lib/c-stack.c.
# Copyright (C) 2002 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# Written by Paul Eggert.
AC_DEFUN([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC],
[# for STACK_DIRECTION
AC_REQUIRE([AC_FUNC_ALLOCA])
AC_CACHE_CHECK([for working C stack overflow detection],
ac_cv_sys_xsi_stack_overflow_heuristic,
[AC_TRY_RUN(
[
#include <signal.h>
#include <ucontext.h>
static union
{
char buffer[SIGSTKSZ];
long double ld;
long u;
void *p;
} alternate_signal_stack;
#if STACK_DIRECTION
# define find_stack_direction(ptr) STACK_DIRECTION
#else
static int
find_stack_direction (char const *addr)
{
char dummy;
return (! addr ? find_stack_direction (&dummy)
: addr < &dummy ? 1 : -1);
}
#endif
static void
segv_handler (int signo, siginfo_t *info, void *context)
{
if (0 < info->si_code)
{
ucontext_t const *user_context = context;
char const *stack_min = user_context->uc_stack.ss_sp;
size_t stack_size = user_context->uc_stack.ss_size;
char const *faulting_address = info->si_addr;
size_t s = faulting_address - stack_min;
size_t page_size = sysconf (_SC_PAGESIZE);
if (find_stack_direction (0) < 0)
s += page_size;
if (s < stack_size + page_size)
_exit (0);
}
_exit (1);
}
static int
c_stack_action (void)
{
stack_t st;
struct sigaction act;
int r;
st.ss_flags = 0;
st.ss_sp = alternate_signal_stack.buffer;
st.ss_size = sizeof alternate_signal_stack.buffer;
r = sigaltstack (&st, 0);
if (r != 0)
return r;
sigemptyset (&act.sa_mask);
act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
act.sa_sigaction = segv_handler;
return sigaction (SIGSEGV, &act, 0);
}
static int
recurse (char *p)
{
char array[500];
array[0] = 1;
return *p + recurse (array);
}
int
main (void)
{
c_stack_action ();
return recurse ("\1");
}
],
[ac_cv_sys_xsi_stack_overflow_heuristic=yes],
[ac_cv_sys_xsi_stack_overflow_heuristic=no],
[ac_cv_sys_xsi_stack_overflow_heuristic=cross-compiling])])
if test $ac_cv_sys_xsi_stack_overflow_heuristic = yes; then
AC_DEFINE(HAVE_XSI_STACK_OVERFLOW_HEURISTIC, 1,
[Define to 1 if extending the stack slightly past the limit causes
a SIGSEGV, and an alternate stack can be established with sigaltstack,
and the signal handler is passed a context that specifies the
run time stack. This behavior is defined by POSIX 1003.1-2001
with the X/Open System Interface (XSI) option
and is a standardized way to implement a SEGV-based stack
overflow detection heuristic.])
fi])
AC_DEFUN([jm_PREREQ_C_STACK],
[AC_REQUIRE([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC])
# for STACK_DIRECTION
AC_REQUIRE([AC_FUNC_ALLOCA])
AC_CHECK_FUNCS(getcontext sigaltstack)
AC_CHECK_DECLS([getcontext], , , [#include <ucontext.h>])
AC_CHECK_DECLS([sigaltstack], , , [#include <signal.h>])
AC_CHECK_HEADERS(sys/resource.h ucontext.h unistd.h)
AC_CHECK_TYPES([stack_t], , , [#include <signal.h>])])

View File

@@ -1,4 +1,4 @@
#serial 4
#serial 5
dnl From Jim Meyering.
dnl
@@ -34,7 +34,7 @@ AC_DEFUN([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
]
)
if test $jm_cv_struct_dirent_d_type = yes; then
AC_DEFINE(D_TYPE_IN_DIRENT, 1,
AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1,
[Define if there is a member named d_type in the struct describing
directory headers.])
fi

View File

@@ -1,4 +1,4 @@
#serial 1
#serial 2
dnl Find out how to get the file descriptor associated with an open DIR*.
dnl From Jim Meyering
@@ -25,9 +25,19 @@ AC_DEFUN([UTILS_FUNC_DIRFD],
AC_CHECK_FUNCS(dirfd)
AC_CHECK_DECLS([dirfd], , , $dirfd_headers)
# Use the replacement only if we have neither the function
# nor a declaration.
if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd = no,no; then
AC_CACHE_CHECK([whether dirfd is a macro],
jm_cv_func_dirfd_macro,
AC_EGREP_CPP([dirent_header_defines_dirfd], [$dirfd_headers
#ifdef dirfd
dirent_header_defines_dirfd
#endif],
jm_cv_func_dirfd_macro=yes,
jm_cv_func_dirfd_macro=no))
# Use the replacement only if we have no function, macro,
# or declaration with that name.
if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd,$jm_cv_func_dirfd_macro \
= no,no,no; then
AC_REPLACE_FUNCS([dirfd])
AC_CACHE_CHECK(
[how to get the file descriptor associated with an open DIR*],

View File

@@ -1,15 +1,87 @@
#serial 5
# Check for fnmatch.
dnl Determine whether to add fnmatch.o to LIBOBJS and to
dnl define fnmatch to rpl_fnmatch.
dnl
# This is a modified version of autoconf's AC_FUNC_FNMATCH.
# This file should be removed after Autoconf 2.54 is required.
AC_DEFUN([jm_FUNC_FNMATCH],
[
AC_FUNC_FNMATCH
if test $ac_cv_func_fnmatch_works = no; then
AC_LIBOBJ(fnmatch)
AC_DEFINE(fnmatch, rpl_fnmatch,
[Define to rpl_fnmatch if the replacement function should be used.])
fi
])
# Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
# -------------------------------------------------------------------------
# If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
# IF-FALSE. Use CACHE_VAR.
AC_DEFUN([_AC_FUNC_FNMATCH_IF],
[AC_CACHE_CHECK(
[for working $1 fnmatch],
[$2],
[# Some versions of Solaris, SCO, and the GNU C Library
# have a broken or incompatible fnmatch.
# So we run a test program. If we are cross-compiling, take no chance.
# Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[#include <fnmatch.h>
# define y(a, b, c) (fnmatch (a, b, c) == 0)
# define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
],
[exit
(!(y ("a*", "abc", 0)
&& n ("d*/*1", "d/s/1", FNM_PATHNAME)
&& y ("a\\\\bc", "abc", 0)
&& n ("a\\\\bc", "abc", FNM_NOESCAPE)
&& y ("*x", ".x", 0)
&& n ("*x", ".x", FNM_PERIOD)
&& m4_if([$1], [GNU],
[y ("xxXX", "xXxX", FNM_CASEFOLD)
&& y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
&& n ("d*/*1", "d/s/1", FNM_FILE_NAME)
&& y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
&& y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
&& y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
1)));])],
[$2=yes],
[$2=no],
[$2=cross])])
AS_IF([test $$2 = yes], [$3], [$4])
])# _AC_FUNC_FNMATCH_IF
# _AC_LIBOBJ_FNMATCH
# ------------------
# Prepare the replacement of fnmatch.
AC_DEFUN([_AC_LIBOBJ_FNMATCH],
[AC_REQUIRE([AC_C_CONST])dnl
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
AC_CHECK_DECLS([getenv])
AC_CHECK_FUNCS([mbsrtowcs mempcpy wmempcpy])
AC_CHECK_HEADERS([wchar.h wctype.h])
AC_LIBOBJ([fnmatch])
AC_CONFIG_LINKS([lib/fnmatch.h:lib/fnmatch_.h])
AC_DEFINE(fnmatch, rpl_fnmatch,
[Define to rpl_fnmatch if the replacement function should be used.])
])# _AC_LIBOBJ_FNMATCH
# AC_FUNC_FNMATCH_GNU
# -------------------
AC_DEFUN([AC_FUNC_FNMATCH_GNU],
[AC_REQUIRE([AC_GNU_SOURCE])
_AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
[rm -f lib/fnmatch.h],
[_AC_LIBOBJ_FNMATCH])
])# AC_FUNC_FNMATCH_GNU

View File

@@ -1,4 +1,4 @@
#serial 8
#serial 9
# A replacement for autoconf's macro by the same name. This version
# accepts an optional argument specifying the name of the $srcdir-relative
@@ -12,6 +12,9 @@ undefine([AC_FUNC_GETLOADAVG])
AC_DEFUN([AC_FUNC_GETLOADAVG],
[ac_have_func=no # yes means we've found a way to get the load average.
AC_CHECK_HEADERS(locale.h unistd.h mach/mach.h fcntl.h)
AC_CHECK_FUNCS(setlocale)
# By default, expect to find getloadavg.c in $srcdir/.
ac_lib_dir_getloadavg=$srcdir
# But if there's an argument, DIR, expect to find getloadavg.c in $srcdir/DIR.

View File

@@ -1,4 +1,4 @@
# gettext.m4 serial 12 (gettext-0.11)
# gettext.m4 serial 14 (gettext-0.11.2)
dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
@@ -116,9 +116,10 @@ AC_DEFUN([AM_GNU_GETTEXT],
AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
[AC_TRY_LINK([#include <libintl.h>
extern int _nl_msg_cat_cntr;],
extern int _nl_msg_cat_cntr;
extern int *_nl_domain_bindings;],
[bindtextdomain ("", "");
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
gt_cv_func_gnugettext_libc=yes,
gt_cv_func_gnugettext_libc=no)])
@@ -140,18 +141,28 @@ return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
LIBS="$LIBS $LIBINTL"
dnl Now see whether libintl exists and does not depend on libiconv.
AC_TRY_LINK([#include <libintl.h>
extern int _nl_msg_cat_cntr;],
extern int _nl_msg_cat_cntr;
extern
#ifdef __cplusplus
"C"
#endif
const char *_nl_expand_alias ();],
[bindtextdomain ("", "");
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
gt_cv_func_gnugettext_libintl=yes,
gt_cv_func_gnugettext_libintl=no)
dnl Now see whether libintl exists and depends on libiconv.
if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <libintl.h>
extern int _nl_msg_cat_cntr;],
extern int _nl_msg_cat_cntr;
extern
#ifdef __cplusplus
"C"
#endif
const char *_nl_expand_alias ();],
[bindtextdomain ("", "");
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
[LIBINTL="$LIBINTL $LIBICONV"
LTLIBINTL="$LTLIBINTL $LTLIBICONV"
gt_cv_func_gnugettext_libintl=yes
@@ -169,6 +180,11 @@ return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("",
|| { test "$gt_cv_func_gnugettext_libintl" = "yes" \
&& test "$PACKAGE" != gettext; }; then
gt_use_preinstalled_gnugettext=yes
else
dnl Reset the values set by searching for libintl.
LIBINTL=
LTLIBINTL=
INCINTL=
fi
ifelse(gt_included_intl, yes, [

View File

@@ -1,4 +1,4 @@
#serial 1
#serial 2
dnl From Jim Meyering.
dnl
@@ -6,8 +6,8 @@ dnl See if gettimeofday clobbers the static buffer that localtime uses
dnl for it's return value. The gettimeofday function from Mac OS X 10.0.4,
dnl i.e. Darwin 1.3.7 has this problem.
dnl
dnl If it does, then arrange to use gettimeofday only via the wrapper
dnl function that works around the problem.
dnl If it does, then arrange to use gettimeofday and localtime only via
dnl the wrapper functions that work around the problem.
AC_DEFUN([AC_FUNC_GETTIMEOFDAY_CLOBBER],
[
@@ -59,6 +59,8 @@ main ()
])
if test $jm_cv_func_gettimeofday_clobber = yes; then
AC_LIBOBJ(gettimeofday)
AC_DEFINE(localtime, rpl_localtime,
[Define to rpl_localtime if the replacement function should be used.])
AC_DEFINE(gettimeofday, rpl_gettimeofday,
[Define to rpl_gettimeofday if the replacement function should be used.])
AC_DEFINE(GETTIMEOFDAY_CLOBBERS_LOCALTIME_BUFFER, 1,

View File

@@ -1,25 +1,12 @@
#serial 3
# Make sure _GNU_SOURCE is defined where necessary: as early as possible
# for configure-time tests, as well as for every source file that includes
# config.h.
# From Jim Meyering.
AC_DEFUN([AC__GNU_SOURCE],
[
# Make sure that _GNU_SOURCE is defined for all subsequent
# configure-time compile tests.
# This definition must be emitted (into confdefs.h) before any
# test that involves compilation.
cat >>confdefs.h <<\EOF
# AC_GNU_SOURCE
# --------------
AC_DEFUN([AC_GNU_SOURCE],
[AH_VERBATIM([_GNU_SOURCE],
[/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
EOF
# Emit this code into config.h.in.
# The ifndef is to avoid redefinition warnings.
AH_VERBATIM([_GNU_SOURCE], [#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif])
# undef _GNU_SOURCE
#endif])dnl
AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
AC_DEFINE([_GNU_SOURCE])
])

View File

@@ -1,4 +1,4 @@
#serial 45 -*- autoconf -*-
#serial 48 -*- autoconf -*-
dnl Misc type-related macros for fileutils, sh-utils, textutils.
@@ -50,7 +50,7 @@ AC_DEFUN([jm_MACROS],
AC_REQUIRE([jm_FUNC_READDIR])
AC_REQUIRE([jm_FUNC_MEMCMP])
AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
AC_REQUIRE([jm_FUNC_FNMATCH])
AC_REQUIRE([AC_FUNC_FNMATCH_GNU])
AC_REQUIRE([jm_FUNC_GROUP_MEMBER])
AC_REQUIRE([jm_FUNC_PUTENV])
AC_REQUIRE([jm_AFS])
@@ -76,11 +76,11 @@ AC_DEFUN([jm_MACROS],
AC_REPLACE_FUNCS(strcasecmp strncasecmp)
AC_REPLACE_FUNCS(dup2)
AC_REPLACE_FUNCS(gethostname getusershell)
AC_REPLACE_FUNCS(sig2str)
AC_REPLACE_FUNCS(strcspn stpcpy strstr strtol strtoul)
AC_REPLACE_FUNCS(strpbrk)
AC_REPLACE_FUNCS(euidaccess memcmp rmdir rpmatch strndup strverscmp)
AC_REPLACE_FUNCS(atexit)
AC_REPLACE_FUNCS(strnlen)
AC_REPLACE_FUNCS(getpass)
dnl used by e.g. intl/*domain.c and lib/canon-host.c
@@ -160,7 +160,6 @@ AC_DEFUN([jm_MACROS],
AC_FUNC_OBSTACK
AC_FUNC_STRTOD
AC_FUNC_STRNLEN
# See if linking `seq' requires -lm.
# It does on nearly every system. The single exception (so far) is
@@ -208,6 +207,7 @@ AC_DEFUN([jm_CHECK_ALL_HEADERS],
fcntl.h \
fenv.h \
float.h \
hurd.h \
limits.h \
memory.h \
mntent.h \
@@ -246,11 +246,6 @@ AC_DEFUN([jm_CHECK_ALL_HEADERS],
# This macro must be invoked before any tests that run the compiler.
AC_DEFUN([jm_CHECK_ALL_TYPES],
[
# FIXME: I shouldn't have to require this macro here. Rather, it should
# be required by any autoconf macro that performs a compile-time test or
# otherwise uses confdefs.h.
AC_REQUIRE([AC__GNU_SOURCE])
dnl This test must come as early as possible after the compiler configuration
dnl tests, because the choice of the file model can (in principle) affect
dnl whether functions and headers are available, whether they work, etc.
@@ -263,7 +258,6 @@ AC_DEFUN([jm_CHECK_ALL_TYPES],
dnl Checks for typedefs, structures, and compiler characteristics.
AC_REQUIRE([AC_C_BIGENDIAN])
AC_REQUIRE([AC_PROG_CC_STDC])
AC_REQUIRE([AC_C_CONST])
AC_REQUIRE([AC_C_VOLATILE])
AC_REQUIRE([AC_C_INLINE])
@@ -272,7 +266,10 @@ AC_DEFUN([jm_CHECK_ALL_TYPES],
AC_REQUIRE([jm_CHECK_ALL_HEADERS])
AC_REQUIRE([AC_HEADER_DIRENT])
AC_REQUIRE([AC_HEADER_STDC])
AC_CHECK_MEMBERS([struct stat.st_blksize],,,[$ac_includes_default
AC_CHECK_MEMBERS(
[struct stat.st_author,
struct stat.st_blksize],,,
[$ac_includes_default
#include <sys/stat.h>
])
AC_REQUIRE([AC_STRUCT_ST_BLOCKS])

View File

@@ -1,4 +1,4 @@
# lib-link.m4 serial 1 (gettext-0.11)
# lib-link.m4 serial 2 (gettext-0.11.2)
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
@@ -434,6 +434,33 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
fi
fi
;;
-R*)
dir=`echo "X$dep" | sed -e 's/^X-R//'`
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $dir"
fi
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $dir"
fi
;;
-l*)
dnl Handle this in the next round.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`

View File

@@ -195,12 +195,7 @@ if test -z "$ac_list_mounted_fs"; then
AC_MSG_CHECKING([for getmntinfo function])
AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
[
ok=
if test $ac_cv_func_getmntinfo = yes; then
AC_EGREP_HEADER(f_type;, sys/mount.h,
ok=yes)
fi
test -n "$ok" \
test "$ac_cv_func_getmntinfo" = yes \
&& fu_cv_sys_mounted_getmntinfo=yes \
|| fu_cv_sys_mounted_getmntinfo=no
])
@@ -209,7 +204,7 @@ if test -z "$ac_list_mounted_fs"; then
ac_list_mounted_fs=found
AC_DEFINE(MOUNTED_GETMNTINFO, 1,
[Define if there is a function named getmntinfo for reading the
list of mounted filesystems. (4.4BSD)])
list of mounted filesystems. (4.4BSD, Darwin)])
fi
fi

View File

@@ -1,4 +1,4 @@
#serial 5
#serial 6
dnl From Jim Meyering.
dnl Determine whether malloc accepts 0 as its argument.
@@ -12,7 +12,8 @@ AC_DEFUN([jm_FUNC_MALLOC],
AC_DEFINE(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
[Define if the malloc check has been performed. ])
AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
AC_CACHE_CHECK([whether malloc(0) returns a non-NULL pointer],
jm_cv_func_working_malloc,
[AC_TRY_RUN([
char *malloc ();
int
@@ -23,7 +24,7 @@ AC_DEFUN([jm_FUNC_MALLOC],
],
jm_cv_func_working_malloc=yes,
jm_cv_func_working_malloc=no,
dnl When crosscompiling, assume malloc is broken.
dnl When crosscompiling, assume malloc(0) returns NULL.
jm_cv_func_working_malloc=no)
])
if test $jm_cv_func_working_malloc = no; then

View File

@@ -1,4 +1,10 @@
#serial 4
# mbrtowc.m4 serial 4 (fileutils-4.1.3)
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert

View File

@@ -1,4 +1,10 @@
# serial 9
# mbstate_t.m4 serial 9
dnl Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
# From Paul Eggert.
@@ -6,24 +12,21 @@
# so you can't declare an object of that type.
# Check for this incompatibility with Standard C.
# Include stdlib.h first, because otherwise this test would fail on Linux
# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits
# a syntax error in wchar.h due to the use of undefined __int32_t.
AC_DEFUN([AC_MBSTATE_T],
[
AC_CHECK_HEADERS(stdlib.h)
AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
[AC_TRY_COMPILE([
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include <wchar.h>],
[mbstate_t x; return sizeof x;],
ac_cv_type_mbstate_t=yes,
ac_cv_type_mbstate_t=no)])
if test $ac_cv_type_mbstate_t = no; then
AC_DEFINE(mbstate_t, int,
# AC_TYPE_MBSTATE_T
# -----------------
AC_DEFUN([AC_TYPE_MBSTATE_T],
[AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[AC_INCLUDES_DEFAULT
# include <wchar.h>],
[mbstate_t x; return sizeof x;])],
[ac_cv_type_mbstate_t=yes],
[ac_cv_type_mbstate_t=no])])
if test $ac_cv_type_mbstate_t = yes; then
AC_DEFINE([HAVE_MBSTATE_T], 1,
[Define to 1 if <wchar.h> declares mbstate_t.])
else
AC_DEFINE([mbstate_t], int,
[Define to a type if <wchar.h> does not define.])
fi])

View File

@@ -1,4 +1,4 @@
#serial 6
#serial 7
dnl autoconf tests required for use of mbswidth.c
dnl From Bruno Haible.
@@ -32,5 +32,5 @@ AC_DEFUN([jm_PREREQ_MBSWIDTH],
AC_DEFINE_UNQUOTED(HAVE_DECL_WCWIDTH, $ac_val,
[Define to 1 if you have the declaration of wcwidth(), and to 0 otherwise.])
AC_MBSTATE_T
AC_TYPE_MBSTATE_T
])

View File

@@ -1,4 +1,4 @@
#serial 22
#serial 26
dnl These are the prerequisite macros for files in the lib/
dnl directories of the fileutils, sh-utils, and textutils packages.
@@ -6,11 +6,13 @@ dnl directories of the fileutils, sh-utils, and textutils packages.
AC_DEFUN([jm_PREREQ],
[
jm_PREREQ_ADDEXT
jm_PREREQ_C_STACK
jm_PREREQ_CANON_HOST
jm_PREREQ_DIRNAME
jm_PREREQ_ERROR
jm_PREREQ_EXCLUDE
jm_PREREQ_GETPAGESIZE
jm_PREREQ_HARD_LOCALE
jm_PREREQ_HASH
jm_PREREQ_HUMAN
jm_PREREQ_MBSWIDTH
@@ -20,6 +22,8 @@ AC_DEFUN([jm_PREREQ],
jm_PREREQ_QUOTEARG
jm_PREREQ_READUTMP
jm_PREREQ_REGEX
jm_PREREQ_STAT
jm_PREREQ_STRNLEN
jm_PREREQ_TEMPNAME # called by mkstemp
jm_PREREQ_XGETCWD
jm_PREREQ_XREADLINK
@@ -56,8 +60,8 @@ AC_DEFUN([jm_PREREQ_DIRNAME],
AC_DEFUN([jm_PREREQ_EXCLUDE],
[
jm_FUNC_FNMATCH
AC_CHECK_HEADERS(stdbool.h)
AC_FUNC_FNMATCH_GNU
AC_HEADER_STDBOOL
])
AC_DEFUN([jm_PREREQ_GETPAGESIZE],
@@ -66,9 +70,17 @@ AC_DEFUN([jm_PREREQ_GETPAGESIZE],
AC_CHECK_HEADERS(OS.h unistd.h)
])
AC_DEFUN([jm_PREREQ_HARD_LOCALE],
[
AC_CHECK_HEADERS(locale.h stdlib.h string.h)
AC_CHECK_FUNCS(setlocale)
AM_C_PROTOTYPES
])
AC_DEFUN([jm_PREREQ_HASH],
[
AC_CHECK_HEADERS(stdlib.h stdbool.h)
AC_CHECK_HEADERS(stdlib.h)
AC_HEADER_STDBOOL
AC_REQUIRE([jm_CHECK_DECLS])
])
@@ -105,7 +117,7 @@ AC_DEFUN([jm_PREREQ_QUOTEARG],
AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h)
AC_HEADER_STDC
AC_C_BACKSLASH_A
AC_MBSTATE_T
AC_TYPE_MBSTATE_T
AM_C_PROTOTYPES
])
@@ -133,6 +145,12 @@ $ac_includes_default
AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_type],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_type],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_pid],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_pid],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_id],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_id],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_exit],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_exit],,,[$utmp_includes])
AC_LIBOBJ(readutmp)
fi
])
@@ -148,6 +166,54 @@ AC_DEFUN([jm_PREREQ_REGEX],
AC_FUNC_ALLOCA
])
AC_DEFUN([jm_PREREQ_STAT],
[
AC_CHECK_HEADERS(sys/sysmacros.h sys/statvfs.h sys/vfs.h inttypes.h)
AC_CHECK_HEADERS(sys/param.h sys/mount.h)
AC_CHECK_FUNCS(statvfs)
jm_AC_TYPE_LONG_LONG
statxfs_includes="\
$ac_includes_default
#if HAVE_SYS_STATVFS_H
# include <sys/statvfs.h>
#endif
#if HAVE_SYS_VFS_H
# include <sys/vfs.h>
#endif
#if ( ! HAVE_SYS_STATVFS_H && ! HAVE_SYS_VFS_H && HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H )
/* NetBSD 1.5.2 needs these, for the declaration of struct statfs. */
# include <sys/param.h>
# include <sys/mount.h>
#endif
"
AC_CHECK_MEMBERS([struct statfs.f_basetype],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statvfs.f_basetype],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statfs.f_type],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statvfs.f_type],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statfs.f_fsid.__val],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statvfs.f_fsid.__val],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statfs.f_namemax],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statvfs.f_namemax],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statfs.f_namelen],,,[$statxfs_includes])
AC_CHECK_MEMBERS([struct statvfs.f_namelen],,,[$statxfs_includes])
])
AC_DEFUN([jm_PREREQ_STRNLEN],
[
AC_FUNC_STRNLEN
AC_HEADER_STDC
AC_CHECK_HEADERS(memory.h)
AC_CHECK_DECLS([memchr])
# This is necessary because automake-1.6.1 doens't understand
# that the above use of AC_FUNC_STRNLEN means we may have to use
# lib/strnlen.c.
test $ac_cv_func_strnlen_working = yes \
&& AC_LIBOBJ(strnlen)
])
AC_DEFUN([jm_PREREQ_TEMPNAME],
[
AC_HEADER_STDC

View File

@@ -50,6 +50,9 @@ AC_CACHE_CHECK([for working readdir], jm_cv_func_working_readdir,
(Basename[0] == '.' && (Basename[1] == '\0' \
|| (Basename[1] == '.' && Basename[2] == '\0')))
/* Don't try to use replacement mkdir; it wouldn't resolve at link time. */
# undef mkdir
static void
create_300_file_dir (const char *dir)
{

View File

@@ -1,4 +1,4 @@
#serial 5
#serial 6
dnl From Jim Meyering.
dnl Determine whether realloc works when both arguments are 0.
@@ -12,7 +12,8 @@ AC_DEFUN([jm_FUNC_REALLOC],
AC_DEFINE(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
[Define if the realloc check has been performed. ])
AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
AC_CACHE_CHECK([whether realloc(0,0) returns a non-NULL pointer],
jm_cv_func_working_realloc,
[AC_TRY_RUN([
char *realloc ();
int
@@ -23,7 +24,7 @@ AC_DEFUN([jm_FUNC_REALLOC],
],
jm_cv_func_working_realloc=yes,
jm_cv_func_working_realloc=no,
dnl When crosscompiling, assume realloc is broken.
dnl When crosscompiling, assume realloc(0,0) returns NULL.
jm_cv_func_working_realloc=no)
])
if test $jm_cv_func_working_realloc = no; then

62
m4/stdbool.m4 Normal file
View File

@@ -0,0 +1,62 @@
# Check for stdbool.h that conforms to C99.
# Copyright (C) 2002 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AC_DEFUN([AC_HEADER_STDBOOL],
[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
[ac_cv_header_stdbool_h],
[AC_TRY_COMPILE(
[
#include <stdbool.h>
#ifndef bool
"error: bool is not defined"
#endif
#ifndef false
"error: false is not defined"
#endif
#if false
"error: false is not 0"
#endif
#ifndef true
"error: false is not defined"
#endif
#if true != 1
"error: true is not 1"
#endif
#ifndef __bool_true_false_are_defined
"error: __bool_true_false_are_defined is not defined"
#endif
struct s { _Bool s: 1; _Bool t; } s;
char a[true == 1 ? 1 : -1];
char b[false == 0 ? 1 : -1];
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
char d[(bool) -0.5 == true ? 1 : -1];
bool e = &s;
char f[(_Bool) -0.0 == false ? 1 : -1];
char g[true];
char h[sizeof (_Bool)];
char i[sizeof s.t];
],
[ return !a + !b + !c + !d + !e + !f + !g + !h + !i; ],
[ac_cv_header_stdbool_h=yes],
[ac_cv_header_stdbool_h=no])])
if test $ac_cv_header_stdbool_h = yes; then
AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
fi])

4
man/link.x Normal file
View File

@@ -0,0 +1,4 @@
[NAME]
link \- call the link function to create a link to a file
[DESCRIPTION]
.\" Add any additional description here

4
man/unlink.x Normal file
View File

@@ -0,0 +1,4 @@
[NAME]
unlink \- call the unlink function to remove the specified file
[DESCRIPTION]
.\" Add any additional description here

View File

@@ -1,3 +1,501 @@
2002-06-25 Jim Meyering <meyering@lucent.com>
* Version 4.1.10.
* src/remove.c (prompt): Add a comment to help translators work
around the problem of making the translations of the adjective
`write-protected' and the corresponding run-time-variable noun
(e.g., file, directory, symlink, etc.) consistent. From Paul Eggert.
2002-06-24 Jim Meyering <meyering@lucent.com>
* src/stat.c (usage): Add missing open-quote.
Reported by Michael Piefel.
2002-06-22 Jim Meyering <meyering@lucent.com>
* Version 4.1.9.
* configure.ac: Invoke AC_GNU_SOURCE very early.
* tests/rm/rm1: Accommodate the slightly different diagnostic we
get on some systems, due to `unlink (dir)' failing with EACCES
rather than EPERM. E.g. for ReiserFS on Linux-2.4.18.
2002-06-21 Jim Meyering <meyering@lucent.com>
* Makefile.maint (wget-update): Checkout into config/.
Warn when skipping a file.
* src/stat.c: Include sys/statvfs.h.
[!HAVE_SYS_STATVFS_H && !HAVE_SYS_VFS_H]: Include sys/param.h
and sys/mount.h, to get decl of struct statfs on NetBSD 1.5.2.
(NAMEMAX_FORMAT, STRUCT_STATVFS): Define.
(HAVE_STRUCT_STATXFS_F_TYPE, SB_F_NAMEMAX): Define.
Remove `static' attribute from decl of program_name.
(human_fstype): Use f_basetype or f_fstypename if available.
(print_human_time): Use nstrftime and an ISO format string, in
place of strftime with `%c'. The latter is too locale-dependent.
(print_statfs): Deal with lots of portability issues: some fields
are available only with statfs, others only with statvfs, and
some are available in both, but with different types.
(do_statfs) [DEFAULT_FORMAT_TERSE]: Factor out.
[DEFAULT_FORMAT_VERBOSE]: Likewise.
* src/copy.c: Change all `preserving ...' diagnostics to
`failed to preserve ...' to make the failure clearer.
* src/cp.c: Likewise.
2002-04-03 Alfred M. Szmidt <ams@kemisten.nu>
* src/copy.c Include hurd.h.
(copy_internal): Preserve the stat.st_author field.
2002-06-21 Jim Meyering <meyering@lucent.com>
* src/ls.c (LOGIN_NAME_MAX): Define if not already defined.
(ID_LENGTH_MAX): Define.
(ST_DM_MODE): New macro. Code moved from...
(print_long_format): ...here.
(print_long_format): Itemize and comment the individual parts
of init_bigbuf. Use the above *_MAX macros.
2002-06-20 Jim Meyering <meyering@lucent.com>
* src/system.h: Change `defined(X)' syntax to `defined X'
in cpp directives.
2002-06-17 Jim Meyering <meyering@lucent.com>
* tests/setgid-check: Interpret a permissions string of
drwxr-xr-x (DOS/Windows) as meaning the cwd is not setgid.
Reported by Rich Dawe.
2002-05-19 Paul Eggert <eggert@twinsun.com>
Add support for new ls option --author, for GNU/Hurd.
Derived from a suggestion by Alfred M. Szmidt.
* doc/coreutils.texi (ls invocation), NEWS: Document this.
* m4/jm-macros.m4 (jm_CHECK_ALL_TYPES): Check for st_author.
* src/ls.c (st_author) [! HAVE_STRUCT_STAT_ST_AUTHOR]: New macro.
(print_author): New var.
(AUTHOR_OPTION): New enum val.
(long_options, decode_switches, print_long_format, usage):
Support --author.
(format_user): New function.
(print_long_format): Use it. Make print buffer a bit bigger.
2002-06-15 Jim Meyering <meyering@lucent.com>
* tests/sample-test (trap): Make sure the temporary hierarchy is
writable before removing it.
* tests/mv/perm-1: New file, to demonstrate fix of 2002-06-12.
* tests/mv/Makefile.am (TESTS): Add perm-1.
* src/system.h: For GNU libc 2.2 and newer, ensure that <sys/types.h>
has been included before this file.
2002-06-13 Richard Dawe <richdawe@bigfoot.com>
Accommodate DOS file name limitations.
* tests/cp/same-file: Change temp. file name: s/\.err/_err/, for DOS.
* tests/mv/force: Similar.
* tests/mv/into-self: Similar.
* tests/touch/no-rights: Similar.
* tests/mv/mv-special-1: Remove leading `.' from temp. names.
2002-06-15 Jim Meyering <meyering@lucent.com>
* src/sys2.h (S_ISNAM): Add to list of S_IS* macros.
Rearrange #if directives for each S_IS macro.
From diffutils-2.8.2.
2002-06-12 Jim Meyering <meyering@lucent.com>
* src/mv.c (do_move): Give one diagnostic, not two, when unable to
unlink a destination file. This bug was introduced in fileutils-3.16l.
2002-06-07 Jim Meyering <meyering@lucent.com>
* tests/mv/part-fail: Also accept the permission-denied diagnostic
issued by some losing systems. Reported by Volker Borchert.
* src/remove.c (remove_entry): Use DT_IS_DIR only if
HAVE_STRUCT_DIRENT_D_TYPE is defined.
2002-06-02 Jim Meyering <meyering@lucent.com>
`rm' no longer uses explicit recursion, and as such is now able
to remove hierarchies of effectively unlimited depth. Prior to
this change, on typical systems, rm would fail (segfault) to remove
hierarchies of depth greater than about 25,000.
* src/remove.c: Merge in all changes from no-recursion branch.
See below for details.
* src/remove.h: Likewise.
* src/mv.c (do_move): Adapt to new calling sequence for rm.
* src/rm.c (main): Likewise.
2002-06-02 Jim Meyering <meyering@lucent.com>
* tests/rm/r-2: Adjust, now that we no longer report
`removing all entries of directory ...'.
* tests/rm/r-1: Likewise.
* src/remove.c (enum Ternary): Define type.
(prompt): Add a parameter. Adjust callers.
(remove_entry): Attempt rmdir here, only if a directory is
`known' to be empty. Significant rework.
(remove_dir): Propagate failure `up' also when rmdir fails.
2002-06-01 Jim Meyering <meyering@lucent.com>
* tests/rm/Makefile.am (TESTS): Add rm5.
* tests/rm/rm5: New test.
2002-05-30 Jim Meyering <meyering@lucent.com>
In interactive mode, prompt only once about an empty directory.
* src/remove.c (enum Prompt_action): Define.
(prompt): Two new parameters. Adjust all callers.
Performance.
* src/remove.c (remove_entry) [!ROOT_CAN_UNLINK_DIRS]:
Don't call rmdir here.
2002-05-29 Jim Meyering <meyering@lucent.com>
* src/remove.c (AD_pop_and_chdir): Don't use errno (it's not valid)
in diagnostic for changed dev/ino.
(remove_entry): Tweak diagnostic.
2002-05-27 Jim Meyering <meyering@lucent.com>
* src/remove.c (ROOT_CAN_UNLINK_DIRS): Define.
(AD_pop_and_chdir): Propagate status as we traverse back `up' the tree.
(DO_UNLINK, DO_RMDIR): Define.
(remove_entry) [ROOT_CAN_UNLINK_DIRS]: Add code so this works also on
systems where root can use `unlink' to remove directories.
2002-05-24 Jim Meyering <meyering@lucent.com>
* tests/mv/mv-special-1: Adapt for changed format of --verbose output.
2002-05-22 Jim Meyering <meyering@lucent.com>
* src/remove.c: Include file-type.h.
Include file type in prompt when asking whether to remove file.
Based on a patch from Paul Eggert.
* src/remove.c (prompt): Add comment.
* src/remove.c (remove_dir): Fix another (known) leak.
* tests/rm/rm3: Don't depend on order of traversal of dir entries.
It is nondeterministic on some types of filesystems.
* src/remove.c (hash_freer): New function.
(AD_mark_helper): Use it.
(AD_mark_as_unremovable): xstrdup the filename argument.
(remove_dir): Free directory name.
* src/remove.c (remove_entry): Fail also when trying to remove a
directory without the --recursive option.
Change a diagnostic, s/unlink/remove/, now that it can apply also
to a directory.
* src/remove.c (is_empty_dir): New function.
(prompt): New function, factored out of...
(remove_entry): ...here. Call it.
(remove_dir): Call prompt before rmdir.
* src/remove.c (remove_entry): Add support for prompting (e.g., -i).
* src/remove.h (UPDATE_STATUS): New macro.
Include save-cwd.h.
(struct File_spec): Remove declaration.
Update prototypes.
* src/remove.c [AD_ent] (status): New member. This lets us propagate
the status from a subdirectory to its parent via AD_pop_and_chdir.
(AD_push_initial): Set it.
(AD_push): Likewise.
(remove_cwd_entries): Change return type to enum RM_status, and
adjust all callers.
(rm): Use UPDATE_STATUS rather than open-coding it.
* src/remove.c (remove_entry): New function, factored out of...
(remove_cwd_entries): ...here, and...
(rm_1): ...here.
* src/remove.c (remove_cwd_entries): Add support for --verbose.
(remove_dir): Likewise.
(rm_1): Likewise.
2002-05-18 Jim Meyering <meyering@lucent.com>
* tests/rm/rm3: New file.
* tests/rm/rm4: New file.
* tests/rm/Makefile.am (TESTS): Add rm3 and rm4.
2002-05-17 Jim Meyering <meyering@lucent.com>
* tests/rm/rm1: New file.
* tests/rm/rm2: New file.
* tests/rm/unread2: New file.
* tests/rm/Makefile.am (TESTS): Add rm1, rm2, and unread2.
* src/remove.h (enum RM_status) [RM_NONEMPTY_DIR]: New member.
2002-05-13 Jim Meyering <meyering@lucent.com>
* src/remove.c (rm): Free cwd_state, if necessary.
2002-05-01 Jim Meyering <meyering@lucent.com>
* src/remove.c (rm_1): Remove now useless (always true)
user_specified_name parameter. Adjust sole caller.
* src/remove.c (rm): New function. This interface allows
one to remove multiple arguments at a time. This is important in
that it allows us to hide the remove_init/remove_fini functions and
the cwd_state parameter.
(rm_1): Renamed from rm.
(remove_init, remove_fini): Remove functions. Each body is now
part of `rm'.
* src/remove.h (rm): Update prototype.
2002-06-01 Jim Meyering <meyering@lucent.com>
* src/ls.c: Remove use of D_TYPE_IN_DIRENT, now that that symbol
has been renamed.
2002-05-30 Jim Meyering <meyering@lucent.com>
* src/copy.c (copy_reg): Use a temporary to avoid a warning
from gcc -W about comparison between signed and unsigned.
(copy_internal): Likewise, but use a cast.
2002-05-22 Jim Meyering <meyering@lucent.com>
* src/sys2.h (S_ISREG, S_ISDIR): Define if not already defined.
(S_TYPEISSEM, S_TYPEISSHM, S_TYPEISTMO): Likewise.
* src/ls.c (S_ISLNK, S_ISFIFO, S_ISSOCK, S_ISCHR, S_ISBLK, S_ISDOOR):
Remove definitions.
* src/sys2.c (S_ISLNK, S_ISFIFO, S_ISSOCK, S_ISCHR, S_ISBLK, S_ISDOOR):
Define here instead.
2002-04-27 Jim Meyering <meyering@lucent.com>
* src/remove.c (cycle_check): New function containing code factored
out of remove_dir. The sole difference is that upon detecting a
cycle, rm now dies unconditionally. Before, in interactive mode,
it would ask the user whether to continue.
(remove_dir): Call cycle_check.
2002-04-25 Jim Meyering <meyering@lucent.com>
Avoid new warnings from gcc.
* src/dd.c: Declare input_file and output_file to be `const'.
(skip): Declare `file' parameter to be `const', too.
Remove hash table, active_dir_map, used to detect directory cycles.
Instead, detect them lazily with just O(1) memory.
Suggestion from Andi Kleen.
* src/remove.c (is_power_of_two): New function.
(print_nth_dir, make_active_dir_ent): Remove functions.
(hash_active_dir_ent, hash_compare_active_dir_ents): Likewise.
(remove_dir): Check for cycles here, ...
(rm): ... and don't check for cycles here.
* src/remove.c (rm): Call fspec_get_full_mode here, rather than
fspec_get_filetype_mode. We want to get the dev/ino earlier, and
at the same time as when we get the file type, to avoid the risk
that an attacker would change e.g. a directory to a symlink before
we record its dev/ino.
* configure.ac (AC_CONFIG_FILES): Remove intl/Makefile.
(AM_GNU_GETTEXT): Add external arg.
* intl/: Remove directory.
* Makefile.am (SUBDIRS): Remove intl.
(DISTCLEANFILES): Remove definition.
* src/sys2.h: Remove ENABLE_NLS-related code.
(_, N_) Remove definitions.
Include "gettext.h" instead.
* src/Makefile.am (INCLUDES): Remove -I../intl.
2002-04-22 Jim Meyering <meyering@lucent.com>
* src/remove.c (rm): Call exit with EXIT_FAILURE, not `1'.
2002-04-19 Jim Meyering <meyering@lucent.com>
* tests/cp/*: Clean up.
* tests/sample-test: Use a temporary directory named
`basename $0`.tmp/$$. Create with mkdir -p.
* tests/cp/backup-1: Use better trap, etc.
* tests/mkdir/p-2: Use better trap.
* tests/mkdir/p-1: Likewise.
* tests/mkdir/concurrent-1: Likewise.
* tests/rm/deep-1: Set $tmp the new way.
* tests/rm/ir-1: Use `rm', not $RM. Use better trap.
* tests/rm/i-1: Likewise.
* tests/rm/f-1: Likewise.
* tests/sample-test: Use automatically-derived name for temporary
directory. This is more 8.3-friendly. Based on a suggestion from
Richard Dawe.
* tests/sample-test: New file.
* tests/Makefile.am (EXTRA_DIST): Add sample-test.
2002-04-17 Jim Meyering <meyering@lucent.com>
* src/touch.c (touch): Don't report errors for nonexistent files
when --no-create is in effect. Based on a patch from TAKAI Kousuke.
* tests/touch/no-create-missing: New file/test for above.
* tests/touch/Makefile.am (TESTS): Add no-create-missing.
2002-04-16 Jim Meyering <meyering@lucent.com>
* src/stat.c: Add copyright comment.
(human_fstype): Rename from print_human_fstype, and rework accordingly.
(print_statfs): Use human_fstype to honor format width on %T.
2002-04-15 Jim Meyering <meyering@lucent.com>
Handle "lld" vs "ld" printf formats the same way Bash does.
* src/stat.c: Include inttypes.h.
(PRIdMAX, PRIuMAX): Define, if not already defined.
(print_statfs): Use those macros, not the literal strings.
(print_stat): Likewise.
Suggestion from Paul Eggert.
* src/stat.c (print_human_fstype): Add missing `break;'
for `case S_MAGIC_MINIX:'.
2002-04-14 Jim Meyering <meyering@lucent.com>
* src/stat.c (statfs_secure): Define.
(print_stat): Remove another #ifdef.
(do_statfs): Likewise.
(print_statfs): Prefer/use fputs over printf.
(print_stat): Likewise.
* src/Makefile.am (bin_PROGRAMS): Add stat.
(noinst_HEADERS): Add fs.h.
* src/stat.c [HAVE_SYS_VFS_H]: Guard incluion of sys/vfs.h.
Constify many parameters.
(print_statfs): Fix typo: Use %u (to match %lu) for namelen, not %d.
(verbose_usage): Remove function. Move contents into usage.
Remove lots of #if directives involving FLASK_LINUX
[!FLASK_LINUX] (is_flask_enabled): Define.
(stat_secure, lstat_secure): Define.
(print_statfs): Remove lots of nested #if directives.
Instead, rely on support fo %llu and %lld printf formats --
but that is only temporary, since it's not porable enough.
(main): Hoist is_flask_enabled test to be done here, rather
than in each of do_stat and do_statfs for every argument.
2002-04-13 Jim Meyering <meyering@lucent.com>
* src/stat.c: Include system.h, error.h, and many other headers.
[HAVE_SYS_SYSMACROS_H]: Guard inclusion of sys/sysmacros.h.
(PROGRAM_NAME, AUTHORS): Define.
(long_options): Declare/define.
(print_human_access): Rewrite to use mode_string.
(usage): Rewrite.
(main): Use getopt_long.
(print_human_type): Call fputs once rather than calling
printf many times.
(print_human_fstype): Revamp in a similar fashion. Don't use strdup.
Declare most functions to be `static'.
2002-04-12 Jim Meyering <meyering@lucent.com>
* src/Makefile.am (LDADD): List ../lib/libfetish.a both before
and after @LIBINTL@. Thanks to Paul Eggert for the fix and to
Bruno Haible for diagnosing the problem.
* src/link.c: Include long-options.h.
[long_opts]: Remove.
(usage): Tweak --help output; use *_OPTION_DESCRIPTION macros.
(main): Don't use getopt directly. Use parse_long_options instead.
Tweak a diagnostic.
Use EXIT_FAILURE rather than a literal `1'.
* src/unlink.c: Likewise.
(main): If POSIXLY_CORRECT is set, don't recognize --help or --version,
so the program can operate on a file with one of those names.
2002-04-11 Jim Meyering <meyering@lucent.com>
New programs link and unlink.
* src/Makefile.am (bin_PROGRAMS): Add link and unlink.
* src/link.c, src/unlink.c: New files, from Debian's fileutils_4.1-10.
Written by Michael Stone.
* man/link.x: New file.
* man/unlink.x: New file.
* man/Makefile.am: Add link and unlink.
2002-04-07 Jim Meyering <meyering@lucent.com>
* tests/install/basic-1: Tweak comments to reflect reality.
* tests/cp/fail-perm: Add VERBOSE=yes support.
* tests/mv/mv-special-1: Fix typo in VERBOSE=yes handling.
Reported by Richard Dawe.
2002-03-30 Jim Meyering <meyering@lucent.com>
* Version 4.1.8.
* tests/mv/i-link-no: Use --reply=no rather than -i.
The latter depends on whether stdin is a tty and hence would
fail in some situations where --reply=no doesn't.
* src/mv.c (do_move): Correct a comment.
* src/copy.c (copy_internal): Move the block that sets `earlier_file'
down to just before the first use of that variable. Otherwise, it was
possible to make mv (and probably cp, too) malfunction when copying
hard-linked files into a directory containing at least one of the
source file names. Call forget_created everywhere thereafter where
this function returns without creating a destination file that might
subsequently be linked. Reported by Iida Yosiaki.
* src/cp-hash.c (forget_created): New function.
* src/cp-hash.h (forget_created): Prototype.
* tests/mv/i-link-no: New test for the above.
Based on an example from Iida Yosiaki.
* tests/mv/Makefile.am (TESTS): Add i-link-no.
2002-03-17 Jim Meyering <meyering@lucent.com>
* src/copy.c (copy_internal) [move_mode]: Give a better diagnostic,
by using errno from the failed unlink, when a cross-device `mv'
fails, e.g., because the destination cannot be unlinked.
Prompted by a report from Karl Berry.
* tests/mv/part-fail: New test for the above.
* tests/mv/Makefile.am (TESTS): Add part-fail.
2002-03-16 Jim Meyering <meyering@lucent.com>
* src/Makefile.am (datadir): Don't override $(datadir)
which might be set by --datadir and different from $(prefix)/share.
Patch from Albert Chin-A-Young.
2002-03-10 Jim Meyering <meyering@lucent.com>
* Version 4.1.7.

View File

@@ -1,3 +1,11 @@
[4.1.9]
* rm can now remove very deep hierarchies, in spite of any limit on stack size
* new programs: link, unlink, and stat
* New ls option: --author (for the Hurd).
* `touch -c no-such-file' no longer fails, per POSIX
[4.1.8]
* mv no longer mistakenly creates links to preexisting destination files
that aren't moved
[4.1.7]
* rm: close a hole that would allow a running rm process to be subverted
[4.1.6]

View File

@@ -1,8 +1,140 @@
2002-03-10 Jim Meyering <meyering@lucent.com>
2002-06-22 Jim Meyering <meyering@lucent.com>
* Version 2.0.13.
* configure.ac: Invoke AC_GNU_SOURCE very early.
2002-05-24 Jim Meyering <meyering@lucent.com>
* tests/nice: Move this file...
* tests/misc/nice: ...to here.
* tests/Makefile.am (TESTS): Remove nice.
* tests/misc/Makefile.am (TESTS): Add nice.
* configure.ac (AC_CONFIG_FILES): Add tests/misc/Makefile.
* src/pathchk.c (validate_path): Compare the result of the function --
not its (constant) address -- against zero.
Patch from Tim J. Robbins <tjr@FreeBSD.ORG>
* tests/misc/pathchk1: New test for the above.
* tests/misc: New directory.
* tests/Makefile.am (SUBDIRS): Add misc.
* tests/misc/Makefile.am: New file.
2002-05-03 Jim Meyering <meyering@lucent.com>
* src/uptime.c (print_uptime): Use ngettext for day/days and user/users.
Suggestion from Karl Eichwalder.
* src/kill.c (usage): Add a little to the description of --list.
Uncapitalize first word and remove period at end of each one line
option description.
* src/who.c (usage): Tweak description of --users.
From Karl Eichwalder.
2002-04-29 Jim Meyering <meyering@lucent.com>
* Version 2.0.12.
* configure.ac (AM_INIT_AUTOMAKE): Specify the required version
Avoid warnings from gcc.
* src/who.c (PIDSTR_DECL_AND_INIT): Cast ut_pid value to int.
(make_id_equals_comment): Cast sizeof expression (used as field
width argument) to `int'.
* configure, config.hin, Makefile.in, etc.: Regenerate using
autoconf-2.53a.
2002-04-28 Jim Meyering <meyering@lucent.com>
* src/who.c: Don't include xalloc.h.
It's already included via system.h.
2002-04-28 Paul Eggert <eggert@twinsun.com>
* src/kill.c: Rewrite from scratch. Support everything
required by POSIX 1003.1-2001; when this conflicts with Bash,
stick with POSIX. The conflicts are kill -l output format,
and lower case signal names preceded by `-' (e.g., "kill -hup"
is no longer supported). Remove -L or --long-list option.
Add -t or --table option. Rename --sigspec to --signal;
remove --signum and do not advertise obsolescent option -n.
Use str2sig and str2sig to convert between signal names and
numbers.
* doc/coreutils.texi (kill invocation): Document the above.
Document POSIX signals better.
* lib/sig2str.h, lib/sig2str.c: New files.
* configure.ac (AC_CHECK_DECLS): Add str2signal, strtoimax,
sys_siglist, _sys_siglist.
* lib/Makefile.am (libfetish_a_SOURCES): Add sig2str.h.
* m4/jm-macros.m4 (jm_MACROS): Add AC_REPLACE_FUNCS(sig2str).
* m4/prereq.m4 (jm_PREREQ): Add jm_PREREQ_SIG2STR.
(jm_PREREQ_SIG2STR): New macro.
2002-04-28 Jim Meyering <meyering@lucent.com>
* src/test.c (test_syntax_error): Add `const' to paramater
declarations to avoid new warning from gcc.
(integer_expected_error): Likewise.
2002-04-25 Jim Meyering <meyering@lucent.com>
* configure.ac (AM_GNU_GETTEXT): Add external arg.
(AC_CONFIG_FILES): Remove intl/Makefile.
* Makefile.am (SUBDIRS): Remove intl.
* src/Makefile.am (INCLUDES): Remove -I../intl.
2002-04-16 Jim Meyering <meyering@lucent.com>
* src/who.c (BOOT_TIME): Define.
(NEW_TIME): Define to 0, not INT_MAX.
(UT_PID, UT_ID, UT_EXIT_E_TERMINATION, UT_EXIT_E_EXIT): Define.
Replace literal uses of ut_pid, ut_id, and ut_exit members with
uses through macros.
(make_id_equals_comment): New function, factored out of three others.
(UT_TYPE_UNDEF, UT_TYPE, IS_USER_PROCESS): Define.
(print_line): Use "%-8.8s" for the format: the user name is not
always NUL terminated.
(scan_entries) [need_users]: Use IS_USER_PROCESS, so that this works
even on systems without ut_type.
2002-04-15 Jim Meyering <meyering@lucent.com>
* src/who.c: Include xalloc.h.
Use xmalloc everywhere, not malloc.
2002-04-12 Jim Meyering <meyering@lucent.com>
* src/Makefile.am (LDADD): List ../lib/libfetish.a both before
and after @LIBINTL@. Thanks to Paul Eggert for the fix and to
Bruno Haible for diagnosing the problem.
2002-02-26 Paul Eggert <eggert@twinsun.com>
* src/test.c (age_of): Return -1 and 0 rather than 0 and 1.
Might as well keep it simple, and like bash.
(binary_operator): Fix bug with -nt and -ot, when one of the
files did not exist. We want to be compatible with the ksh93
documentation, and with Bash.
2002-03-17 Jim Meyering <meyering@lucent.com>
* src/seq.c (usage): Mention that --format=FORMAT must be
a *floating-point* format, also in description of that option.
Reported by Karl Eichwalder.
(usage): Also add the `=' signs here: --format=FORMAT,
--separator=STRING.
2002-03-16 Jim Meyering <meyering@lucent.com>
* src/Makefile.am (datadir): Don't override $(datadir)
which might be set by --datadir and different from $(prefix)/share.
Patch from Albert Chin-A-Young.
2002-03-10 Jim Meyering <meyering@lucent.com>
* configure.ac (AM_INIT_AUTOMAKE): Specify here the required version
of automake (1.6), and options (gnits dist-bzip2), rather than...
* Makefile.am (AUTOMAKE_OPTIONS): ...here. Remove definition.
@@ -333,7 +465,7 @@
2001-08-19 Jim Meyering <meyering@lucent.com>
* src/Makefile.am (bin_PROGRAMS): Add kill.
* src/kill.c: New file.
* src/kill.c: New program. Written by Marcus Brinkmann.
2001-08-19 Jim Meyering <meyering@lucent.com>
@@ -498,10 +630,6 @@
(main): Handle new options.
Mostly from Michael Stone.
FIXME (remove this, later): This probably doesn't compile on any
type of system except Linux, due to the unprotected uses of e.g.,
utmp_ent->ut_exit.e_termination.
2001-05-11 Paul Eggert <eggert@twinsun.com>
dirname code cleanup. base_name now behaves more compatibly

View File

@@ -1,5 +1,13 @@
Changes in release 2.1
[2.0.13]
* pathchk now exits nonzero for a path with a directory component
that specifies a non-directory
[2.0.12]
* kill: new program
* who accepts new options: --all (-a), --boot (-b), --dead (-d), --login,
--process (-p), --runlevel (-r), --short (-s), --time (-t), --users (-u).
The -u option now produces POSIX-specified results and is the same as
the long option `--users'. --idle is no longer the same as -u.
* The following changes apply on systems conforming to POSIX 1003.1-2001,
and are required by the new POSIX standard:
- `date -I' is no longer supported. Instead, use `date --iso-8601'.
@@ -19,6 +27,7 @@ Changes in release 2.1
opposite sides of a daylight savings time transition.
This problem arose only with relative date strings like `last monday'.
It was not a problem with strings that include absolute dates.
* factor is twice as fast, for large numbers
[2.0.11]
* setting the date now works properly, even when using -u
* `date -f - < /dev/null' no longer dumps core

View File

@@ -1,7 +1,114 @@
2002-03-10 Jim Meyering <meyering@lucent.com>
2002-06-22 Jim Meyering <meyering@lucent.com>
* Version 2.0.22.
* configure.ac: Invoke AC_GNU_SOURCE very early.
2002-06-15 Jim Meyering <meyering@lucent.com>
* src/cksum.c: Include <sys/types.h> before system.h.
2002-05-22 Jim Meyering <meyering@lucent.com>
* src/od.c [struct dummy]: Renamed. Don't rely on portability of
zero-length arrays. Instead, use sizes of -1 or +1.
Reported by Eric Backus.
2002-05-14 Jim Meyering <meyering@lucent.com>
This bug was introduced with my change of 2000-10-22 (textutils-2.0.8).
* src/od.c (ulonglong_t): Move declaration to precede new use.
[enum size_spec] (N_SIZE_SPECS): New member.
(width_bytes): Add initializer corresponding to ulonglong_t type.
(struct assert_width_bytes_matches_size_spec_decl): Declare.
Based on a patch from Tony Kocurko.
2002-04-29 Paul Eggert <eggert@twinsun.com>
Use ENABLE_NLS only for gettext-related stuff, not also for
setlocale-related stuff. From a patch suggested by Bruno
Haible.
Since setlocale is now almost universal, this patch also
removes some of the optimizations that clutter up the code and
which don't help all that much even on hosts that lack
setlocale.
* lib/hard-locale.c: Upgrade to version used in GNU Diffutils 2.8.1.
* m4/prereq.m4 (jm_PREREQ_HARD_LOCALE): Check for stdlib.h.
Do not check for alloca.h (no longer used) or stdbool.h (was never
used?). Add AM_C_PROTOTYPES since hard-locale.h uses it.
* src/sys2.h (HAVE_SETLOCALE): Define to 0 if not defined.
* src/comm.c (compare_files): Replace #ifdef ENABLE_NLS
with if (HAVE_SETLOCALE).
* src/join.c (keycmp): Likewise.
* src/sort.c (keycompare, compare): Likewise.
* src/comm.c (hard_LC_COLLATE): Define even if ! ENABLE_NLS.
* src/join.c (hard_LC_COLLATE): Likewise.
* src/sort.c (hard_LC_COLLATE): Likewise.
* src/comm.c (main): Always initialize hard_LC_COLLATE.
Put initialization next to other locale-related stuff.
* src/join.c (main): Likewise.
* src/sort.c (main): Likewise.
* src/sort.c: Include <langinfo.h> even if ! ENABLE_NLS.
(decimal_point, th_sep): Depend on HAVE_SETLOCALE, not ENABLE_NLS.
(main): Likewise.
(MONTHTAB_CONST): Remove; all uses removed.
(struct_month_cmp, inittables): Do not depend on ENABLE_NLS.
(main): hard_LC_TIME locale does not depend on ENABLE_NLS.
2002-04-29 Jim Meyering <meyering@lucent.com>
* src/tail.c (parse_obsolescent_option): Do not limit the maximum
line/byte count (when specified via obsolete option syntax) to be
less than ULONG_MAX on systems where OFF_T_MAX is larger.
2002-04-28 Paul Eggert <eggert@twinsun.com>
* src/tail.c (tail_forever): Do not treat
max_n_unchanged_stats_between_opens specially (as if it were
infinite) if it has its maximal value. Similarly for
max_n_consecutive_size_changes_between_opens.
2002-04-28 Jim Meyering <meyering@lucent.com>
Avoid new warnings from gcc.
* src/pr.c [struct COLUMN] <name>: Declare member to be const.
(init_fps): Declare local variable `firstname' to be const.
2002-04-25 Jim Meyering <meyering@lucent.com>
* src/wc.c (usage): Adjust ordering to match that of default output.
Suggestion from Gaute Hvoslef Kvalnes.
* configure.ac (AM_GNU_GETTEXT): Add external arg.
(AC_CONFIG_FILES): Remove intl/Makefile.
* Makefile.am (SUBDIRS): Remove intl.
* src/Makefile.am (INCLUDES): Remove -I../intl.
2002-04-15 Jim Meyering <meyering@lucent.com>
* src/tr.c (usage): Give a verbose description of --squeeze-repeats,
including the mention of SET1. Reported by Dan Jacobson.
2002-04-12 Jim Meyering <meyering@lucent.com>
* src/Makefile.am (LDADD): List ../lib/libfetish.a both before
and after @LIBINTL@. Thanks to Paul Eggert for the fix and to
Bruno Haible for diagnosing the problem.
2002-03-16 Jim Meyering <meyering@lucent.com>
* src/Makefile.am (datadir): Don't override $(datadir)
which might be set by --datadir and different from $(prefix)/share.
Patch from Albert Chin-A-Young.
2002-03-10 Jim Meyering <meyering@lucent.com>
* configure.ac (AM_INIT_AUTOMAKE): Specify the required version
of automake (1.6), and options (gnits dist-bzip2), rather than...
* Makefile.am (AUTOMAKE_OPTIONS): ...here. Remove definition.
@@ -17,7 +124,7 @@
2002-02-23 Paul Eggert <eggert@twinsun.com>
* src/cat.c (simple_cat, cat, main): Used char * rather than
* src/cat.c (simple_cat, cat, main): Use char * rather than
unsigned char *, to avoid some technical violations of the C
standard, and to avoid the need for casts. I guess the
unsigned char * was probably there for improved performance

View File

@@ -48,6 +48,7 @@
#define AUTHORS "Q. Frank Xia"
#include <stdio.h>
#include <sys/types.h>
#include "system.h"
#if !defined UINT_FAST32_MAX && !defined uint_fast32_t
@@ -116,7 +117,6 @@ main (void)
#else /* !CRCTAB */
# include <getopt.h>
# include <sys/types.h>
# include "closeout.h"
# include "long-options.h"
# include "error.h"

View File

@@ -41,10 +41,8 @@
/* The name this program was run with. */
char *program_name;
#ifdef ENABLE_NLS
/* Nonzero if the LC_COLLATE locale is hard. */
static int hard_LC_COLLATE;
#endif
/* If nonzero, print lines that are found only in file 1. */
static int only_file_1;
@@ -176,12 +174,10 @@ compare_files (char **infiles)
order = -1;
else
{
#ifdef ENABLE_NLS
if (hard_LC_COLLATE)
if (HAVE_SETLOCALE && hard_LC_COLLATE)
order = xmemcoll (thisline[0]->buffer, thisline[0]->length - 1,
thisline[1]->buffer, thisline[1]->length - 1);
else
#endif
{
size_t len = min (thisline[0]->length, thisline[1]->length) - 1;
order = memcmp (thisline[0]->buffer, thisline[1]->buffer, len);
@@ -230,13 +226,10 @@ main (int argc, char **argv)
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
atexit (close_stdout);
#ifdef ENABLE_NLS
hard_LC_COLLATE = hard_locale (LC_COLLATE);
#endif
only_file_1 = 1;
only_file_2 = 1;
both = 1;

View File

@@ -26,6 +26,10 @@
#include <assert.h>
#include <sys/types.h>
#if HAVE_HURD_H
# include <hurd.h>
#endif
#include "system.h"
#include "error.h"
#include "backupfile.h"
@@ -367,7 +371,8 @@ copy_reg (const char *src_path, const char *dst_path,
}
if (ip == 0)
{
if (full_write (dest_desc, buf, n_read) != n_read)
size_t n = n_read;
if (full_write (dest_desc, buf, n) != n)
{
error (0, errno, _("writing %s"), quote (dst_path));
return_val = -1;
@@ -791,7 +796,6 @@ copy_internal (const char *src_path, const char *dst_path,
char *earlier_file = NULL;
char *dst_backup = NULL;
int backup_succeeded = 0;
int rename_errno;
int delayed_fail;
int copied_as_regular = 0;
int ran_chown = 0;
@@ -816,38 +820,6 @@ copy_internal (const char *src_path, const char *dst_path,
src_type = src_sb.st_mode;
/* Associate the destination path with the source device and inode
so that if we encounter a matching dev/ino pair in the source tree
we can arrange to create a hard link between the corresponding names
in the destination tree.
Sometimes, when preserving links, we have to record dev/ino even
though st_nlink == 1:
- when using -H and processing a command line argument;
that command line argument could be a symlink pointing to another
command line argument. With `cp -H --preserve=link', we hard-link
those two destination files.
- likewise for -L except that it applies to all files, not just
command line arguments.
Also record directory dev/ino when using --recursive. We'll use that
info to detect this problem: cp -R dir dir. FIXME-maybe: ideally,
directory info would be recorded in a separate hash table, since
such entries are useful only while a single command line hierarchy
is being copied -- so that separate table could be cleared between
command line args. Using the same hash table to preserve hard
links means that it may not be cleared. */
if ((x->preserve_links
&& (1 < src_sb.st_nlink
|| (command_line_arg
&& x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
|| x->dereference == DEREF_ALWAYS))
|| (x->recursive && S_ISDIR (src_type)))
{
earlier_file = remember_copied (dst_path, src_sb.st_ino, src_sb.st_dev);
}
src_mode = src_sb.st_mode;
if (S_ISDIR (src_type) && !x->recursive)
@@ -1085,6 +1057,38 @@ copy_internal (const char *src_path, const char *dst_path,
putchar ('\n');
}
/* Associate the destination path with the source device and inode
so that if we encounter a matching dev/ino pair in the source tree
we can arrange to create a hard link between the corresponding names
in the destination tree.
Sometimes, when preserving links, we have to record dev/ino even
though st_nlink == 1:
- when using -H and processing a command line argument;
that command line argument could be a symlink pointing to another
command line argument. With `cp -H --preserve=link', we hard-link
those two destination files.
- likewise for -L except that it applies to all files, not just
command line arguments.
Also record directory dev/ino when using --recursive. We'll use that
info to detect this problem: cp -R dir dir. FIXME-maybe: ideally,
directory info would be recorded in a separate hash table, since
such entries are useful only while a single command line hierarchy
is being copied -- so that separate table could be cleared between
command line args. Using the same hash table to preserve hard
links means that it may not be cleared. */
if ((x->preserve_links
&& (1 < src_sb.st_nlink
|| (command_line_arg
&& x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
|| x->dereference == DEREF_ALWAYS))
|| (x->recursive && S_ISDIR (src_type)))
{
earlier_file = remember_copied (dst_path, src_sb.st_ino, src_sb.st_dev);
}
/* Did we copy this inode somewhere else (in this command line argument)
and therefore this is a second hard link to the inode? */
@@ -1173,6 +1177,11 @@ copy_internal (const char *src_path, const char *dst_path,
error (0, 0, _("cannot move %s to a subdirectory of itself, %s"),
quote_n (0, top_level_src_path),
quote_n (1, top_level_dst_path));
/* Note that there is no need to call forget_created here,
(compare with the other calls in this file) since the
destination directory didn't exist before. */
*copy_into_self = 1;
/* FIXME-cleanup: Don't return zero here; adjust mv.c accordingly.
The only caller that uses this code (mv.c) ends up setting its
@@ -1210,20 +1219,19 @@ copy_internal (const char *src_path, const char *dst_path,
error (0, errno,
_("cannot move %s to %s"),
quote_n (0, src_path), quote_n (1, dst_path));
forget_created (src_sb.st_ino, src_sb.st_dev);
return 1;
}
/* Save this value of errno to use in case the unlink fails. */
rename_errno = errno;
/* The rename attempt has failed. Remove any existing destination
file so that a cross-device `mv' acts as if it were really using
the rename syscall. */
if (unlink (dst_path) && errno != ENOENT)
{
/* Use the value of errno from the failed rename. */
error (0, rename_errno, _("cannot move %s to %s"),
error (0, errno,
_("inter-device move failed: %s to %s; unable to remove target"),
quote_n (0, src_path), quote_n (1, dst_path));
forget_created (src_sb.st_ino, src_sb.st_dev);
return 1;
}
@@ -1412,7 +1420,7 @@ copy_internal (const char *src_path, const char *dst_path,
char *dest_link_val = (char *) alloca (src_link_len + 1);
int dest_link_len = readlink (dst_path, dest_link_val,
src_link_len + 1);
if (dest_link_len == src_link_len
if ((size_t) dest_link_len == src_link_len
&& strncmp (dest_link_val, src_link_val, src_link_len) == 0)
same_link = 1;
}
@@ -1436,7 +1444,8 @@ copy_internal (const char *src_path, const char *dst_path,
# if HAVE_LCHOWN
if (DO_CHOWN (lchown, dst_path, src_sb.st_uid, src_sb.st_gid))
{
error (0, errno, _("preserving ownership for %s"), dst_path);
error (0, errno, _("failed to preserve ownership for %s"),
dst_path);
goto un_backup;
}
# else
@@ -1498,12 +1507,24 @@ copy_internal (const char *src_path, const char *dst_path,
ran_chown = 1;
if (DO_CHOWN (chown, dst_path, src_sb.st_uid, src_sb.st_gid))
{
error (0, errno, _("preserving ownership for %s"), quote (dst_path));
error (0, errno, _("failed to preserve ownership for %s"),
quote (dst_path));
if (x->require_preserve)
return 1;
}
}
#if HAVE_STRUCT_STAT_ST_AUTHOR
/* Preserve the st_author field. */
{
file_t file = getdport (dst_path);
if (file_chauthor (file, src_sb.st_author))
error (0, errno, _("failed to preserve authorship for %s"),
quote (dst_path));
mach_port_deallocate (mach_task_self (), file);
}
#endif
/* Permissions of newly-created regular files were set upon `open' in
copy_reg. But don't return early if there were any special bits and
we had to run chown, because the chown must have reset those bits. */
@@ -1525,6 +1546,13 @@ copy_internal (const char *src_path, const char *dst_path,
return delayed_fail;
un_backup:
/* We didn't create the destination.
Remove the entry associating the source dev/ino with the
destination file name, so we don't try to `preserve' a link
to a file we didn't create. */
forget_created (src_sb.st_ino, src_sb.st_dev);
if (dst_backup)
{
if (rename (dst_backup, dst_path))

View File

@@ -1,5 +1,5 @@
/* cp-hash.c -- file copying (hash search routines)
Copyright (C) 89, 90, 91, 1995-2001 Free Software Foundation.
Copyright (C) 89, 90, 91, 1995-2002 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -84,6 +84,23 @@ src_to_dest_free (void *x)
free (x);
}
/* Remove the entry matching INO/DEV from the table
that maps source ino/dev to destination file name. */
void
forget_created (ino_t ino, dev_t dev)
{
struct Src_to_dest probe;
struct Src_to_dest *ent;
probe.st_ino = ino;
probe.st_dev = dev;
probe.name = NULL;
ent = hash_delete (src_to_dest, &probe);
if (ent)
src_to_dest_free (ent);
}
/* Add PATH to the list of files that we have created.
Return 1 if we can't stat PATH, otherwise 0. */

View File

@@ -1,4 +1,5 @@
void hash_init PARAMS ((void));
void forget_all PARAMS ((void));
void forget_created PARAMS ((ino_t ino, dev_t dev));
char *remember_copied PARAMS ((const char *node, ino_t ino, dev_t dev));
int remember_created PARAMS ((const char *path));

View File

@@ -322,7 +322,8 @@ re_protect (const char *const_dst_path, int src_offset,
if (utime (dst_path, &utb))
{
error (0, errno, _("preserving times for %s"), quote (dst_path));
error (0, errno, _("failed to preserve times for %s"),
quote (dst_path));
return 1;
}
}
@@ -335,7 +336,7 @@ re_protect (const char *const_dst_path, int src_offset,
if (chown (dst_path, src_sb.st_uid, src_sb.st_gid)
&& ((errno != EPERM && errno != EINVAL) || myeuid == 0))
{
error (0, errno, _("preserving ownership for %s"),
error (0, errno, _("failed to preserve ownership for %s"),
quote (dst_path));
return 1;
}
@@ -345,7 +346,7 @@ re_protect (const char *const_dst_path, int src_offset,
{
if (chmod (dst_path, src_sb.st_mode & x->umask_kill))
{
error (0, errno, _("preserving permissions for %s"),
error (0, errno, _("failed to preserve permissions for %s"),
quote (dst_path));
return 1;
}

View File

@@ -1,5 +1,5 @@
/* dd -- convert a file while copying it.
Copyright (C) 85, 90, 91, 1995-2001 Free Software Foundation, Inc.
Copyright (C) 85, 90, 91, 1995-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -89,10 +89,10 @@
char *program_name;
/* The name of the input file, or NULL for the standard input. */
static char *input_file = NULL;
static char const *input_file = NULL;
/* The name of the output file, or NULL for the standard output. */
static char *output_file = NULL;
static char const *output_file = NULL;
/* The number of bytes in which atomic reads are done. */
static size_t input_blocksize = 0;
@@ -793,7 +793,8 @@ skip_via_lseek (char const *filename, int fdesc, off_t offset, int whence)
nonzero. */
static void
skip (int fdesc, char *file, uintmax_t records, size_t blocksize, char *buf)
skip (int fdesc, char const *file, uintmax_t records, size_t blocksize,
char *buf)
{
off_t offset = records * blocksize;

View File

@@ -1,27 +1,36 @@
/* define the magic numbers as given by statfs(2) */
/* please send additions to meskes@debian.org */
#define AFFS_SUPER_MAGIC 0xADFF
#define EXT_SUPER_MAGIC 0x137D
#define EXT2_OLD_SUPER_MAGIC 0xEF51
#define EXT2_SUPER_MAGIC 0xEF53
#define HPFS_SUPER_MAGIC 0xF995E849
#define ISOFS_SUPER_MAGIC 0x9660
#define MINIX_SUPER_MAGIC 0x137F /* orig. minix */
#define MINIX_SUPER_MAGIC2 0x138F /* 30 char minix */
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 */
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2, 30 char names */
#define MSDOS_SUPER_MAGIC 0x4d44
#define NCP_SUPER_MAGIC 0x564c
#define NFS_SUPER_MAGIC 0x6969
#define PROC_SUPER_MAGIC 0x9fa0
#define SMB_SUPER_MAGIC 0x517B
#define XENIX_SUPER_MAGIC 0x012FF7B4
#define SYSV4_SUPER_MAGIC 0x012FF7B5
#define SYSV2_SUPER_MAGIC 0x012FF7B6
#define COH_SUPER_MAGIC 0x012FF7B7
#define UFS_MAGIC 0x00011954
#define _XIAFS_SUPER_MAGIC 0x012FD16D
#define NTFS_SUPER_MAGIC 0x5346544e
#define TMPFS_MAGIC 0x1021994
#define REISERFS_MAGIC 0x52654973
#if defined __linux__
# define S_MAGIC_AFFS 0xADFF
# define S_MAGIC_EXT 0x137D
# define S_MAGIC_EXT2_OLD 0xEF51
# define S_MAGIC_EXT2 0xEF53
# define S_MAGIC_HPFS 0xF995E849
# define S_MAGIC_ISOFS 0x9660
# define S_MAGIC_ISOFS_WIN 0x4000
# define S_MAGIC_ISOFS_R_WIN 0x4004
# define S_MAGIC_MINIX 0x137F
# define S_MAGIC_MINIX_30 0x138F
# define S_MAGIC_MINIX_V2 0x2468
# define S_MAGIC_MINIX_V2_30 0x2478
# define S_MAGIC_MSDOS 0x4d44
# define S_MAGIC_FAT 0x4006
# define S_MAGIC_NCP 0x564c
# define S_MAGIC_NFS 0x6969
# define S_MAGIC_PROC 0x9fa0
# define S_MAGIC_SMB 0x517B
# define S_MAGIC_XENIX 0x012FF7B4
# define S_MAGIC_SYSV4 0x012FF7B5
# define S_MAGIC_SYSV2 0x012FF7B6
# define S_MAGIC_COH 0x012FF7B7
# define S_MAGIC_UFS 0x00011954
# define S_MAGIC_XIAFS 0x012FD16D
# define S_MAGIC_NTFS 0x5346544e
# define S_MAGIC_TMPFS 0x1021994
# define S_MAGIC_REISERFS 0x52654973
# define S_MAGIC_CRAMFS 0x28cd3d45
# define S_MAGIC_ROMFS 0x7275
#elif defined __GNU__
# include <hurd/hurd_types.h>
#endif

View File

@@ -88,10 +88,8 @@ struct seq
/* The name this program was run with. */
char *program_name;
#ifdef ENABLE_NLS
/* Nonzero if the LC_COLLATE locale is hard. */
static int hard_LC_COLLATE;
#endif
/* If nonzero, print unpairable lines in file 1 or 2. */
static int print_unpairables_1, print_unpairables_2;
@@ -372,10 +370,8 @@ keycmp (struct line *line1, struct line *line2)
}
else
{
#ifdef ENABLE_NLS
if (hard_LC_COLLATE)
if (HAVE_SETLOCALE && hard_LC_COLLATE)
return xmemcoll ((char *) beg1, len1, (char *) beg2, len2);
#endif
diff = memcmp (beg1, beg2, min (len1, len2));
}
@@ -744,13 +740,10 @@ main (int argc, char **argv)
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
atexit (close_stdout);
#ifdef ENABLE_NLS
hard_LC_COLLATE = hard_locale (LC_COLLATE);
#endif
/* Initialize this before parsing options. In parsing options,
it may be increased. */
uni_blank.nfields = 1;

View File

@@ -1,5 +1,5 @@
/* kill -- send a signal to a process
Copyright (C) 2001 Free Software Foundation, Inc.
Copyright (C) 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,300 +15,68 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Marcus Brinkmann. */
/* Written by Paul Eggert. */
#include <config.h>
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
#include <signal.h>
#if HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#ifndef WIFSIGNALED
# define WIFSIGNALED(s) (((s) & 0xFFFF) - 1 < (unsigned int) 0xFF)
#endif
#ifndef WTERMSIG
# define WTERMSIG(s) ((s) & 0x7F)
#endif
#include "system.h"
#include "closeout.h"
#include "human.h"
#include "error.h"
#include "xstrtol.h"
#include "sig2str.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "kill"
#define AUTHORS "Marcus Brinkmann"
#define AUTHORS "Paul Eggert"
/* An invalid signal number. */
#define NO_SIG -1
/* A structure holding the number and the name of a signal. */
struct sigspec
{
int signum;
char *signame;
};
/* The list of signals was taken from bash 2.05. The best name for a
signal comes after any possible alias, so it is read it from back
to front. This is why the terminating null entry comes first. */
static struct sigspec sigspecs[] =
{
{ NO_SIG, NULL },
/* Null is used to test for the existance and ownership of a PID. */
{ 0, "0" },
/* AIX */
#if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
{ SIGLOST, "LOST" },
#if ! (HAVE_DECL_STRTOIMAX || defined strtoimax)
intmax_t strtoimax ();
#endif
#if defined (SIGMSG) /* HFT input data pending */
{ SIGMSG, "MSG" },
#if ! (HAVE_DECL_STRSIGNAL || defined strsignal)
# if ! (HAVE_DECL_SYS_SIGLIST || defined sys_siglist)
# if HAVE_DECL__SYS_SIGLIST || defined _sys_siglist
# define sys_siglist _sys_siglist
# endif
# endif
# if HAVE_DECL_SYS_SIGLIST || defined sys_siglist
# define strsignal(signum) (0 <= (signum) && (signum) <= SIGNUM_BOUND \
? sys_siglist[signum] \
: 0)
# endif
# ifndef strsignal
# define strsignal(signum) 0
# endif
#endif
#if defined (SIGDANGER) /* system crash imminent */
{ SIGDANGER, "DANGER" },
#endif
#if defined (SIGMIGRATE) /* migrate process to another CPU */
{ SIGMIGRATE, "MIGRATE" },
#endif
#if defined (SIGPRE) /* programming error */
{ SIGPRE, "PRE" },
#endif
#if defined (SIGVIRT) /* AIX virtual time alarm */
{ SIGVIRT, "VIRT" },
#endif
#if defined (SIGALRM1) /* m:n condition variables */
{ SIGALRM1, "ALRM1" },
#endif
#if defined (SIGWAITING) /* m:n scheduling */
{ SIGWAITING, "WAITING" },
#endif
#if defined (SIGGRANT) /* HFT monitor mode granted */
{ SIGGRANT, "GRANT" },
#endif
#if defined (SIGKAP) /* keep alive poll from native keyboard */
{ SIGKAP, "KAP" },
#endif
#if defined (SIGRETRACT) /* HFT monitor mode retracted */
{ SIGRETRACT, "RETRACT" },
#endif
#if defined (SIGSOUND) /* HFT sound sequence has completed */
{ SIGSOUND, "SOUND" },
#endif
#if defined (SIGSAK) /* Secure Attention Key */
{ SIGSAK, "SAK" },
#endif
/* SunOS5 */
#if defined (SIGLWP) /* special signal used by thread library */
{ SIGLWP, "LWP" },
#endif
#if defined (SIGFREEZE) /* special signal used by CPR */
{ SIGFREEZE, "FREEZE" },
#endif
#if defined (SIGTHAW) /* special signal used by CPR */
{ SIGTHAW, "THAW" },
#endif
#if defined (SIGCANCEL) /* thread cancellation signal used by libthread */
{ SIGCANCEL, "CANCEL" },
#endif
/* HP-UX */
#if defined (SIGDIL) /* DIL signal (?) */
{ SIGDIL, "DIL" },
#endif
/* System V */
#if defined (SIGCLD) /* Like SIGCHLD. */
{ SIGCLD, "CLD" },
#endif
#if defined (SIGPWR) /* power state indication */
{ SIGPWR, "PWR" },
#endif
#if defined (SIGPOLL) /* Pollable event (for streams) */
{ SIGPOLL, "POLL" },
#endif
/* Unknown */
#if defined (SIGWINDOW)
{ SIGWINDOW, "WINDOW" },
#endif
/* Common */
#if defined (SIGHUP) /* hangup */
{ SIGHUP, "HUP" },
#endif
#if defined (SIGINT) /* interrupt */
{ SIGINT, "INT" },
#endif
#if defined (SIGQUIT) /* quit */
{ SIGQUIT, "QUIT" },
#endif
#if defined (SIGILL) /* illegal instruction (not reset when caught) */
{ SIGILL, "ILL" },
#endif
#if defined (SIGTRAP) /* trace trap (not reset when caught) */
{ SIGTRAP, "TRAP" },
#endif
#if defined (SIGIOT) /* IOT instruction */
{ SIGIOT, "IOT" },
#endif
#if defined (SIGABRT) /* Cause current process to dump core. */
{ SIGABRT, "ABRT" },
#endif
#if defined (SIGEMT) /* EMT instruction */
{ SIGEMT, "EMT" },
#endif
#if defined (SIGFPE) /* floating point exception */
{ SIGFPE, "FPE" },
#endif
#if defined (SIGKILL) /* kill (cannot be caught or ignored) */
{ SIGKILL, "KILL" },
#endif
#if defined (SIGBUS) /* bus error */
{ SIGBUS, "BUS" },
#endif
#if defined (SIGSEGV) /* segmentation violation */
{ SIGSEGV, "SEGV" },
#endif
#if defined (SIGSYS) /* bad argument to system call */
{ SIGSYS, "SYS" },
#endif
#if defined (SIGPIPE) /* write on a pipe with no one to read it */
{ SIGPIPE, "PIPE" },
#endif
#if defined (SIGALRM) /* alarm clock */
{ SIGALRM, "ALRM" },
#endif
#if defined (SIGTERM) /* software termination signal from kill */
{ SIGTERM, "TERM" },
#endif
#if defined (SIGURG) /* urgent condition on IO channel */
{ SIGURG, "URG" },
#endif
#if defined (SIGSTOP) /* sendable stop signal not from tty */
{ SIGSTOP, "STOP" },
#endif
#if defined (SIGTSTP) /* stop signal from tty */
{ SIGTSTP, "TSTP" },
#endif
#if defined (SIGCONT) /* continue a stopped process */
{ SIGCONT, "CONT" },
#endif
#if defined (SIGCHLD) /* to parent on child stop or exit */
{ SIGCHLD, "CHLD" },
#endif
#if defined (SIGTTIN) /* to readers pgrp upon background tty read */
{ SIGTTIN, "TTIN" },
#endif
#if defined (SIGTTOU) /* like TTIN for output if (tp->t_local&LTOSTOP) */
{ SIGTTOU, "TTOU" },
#endif
#if defined (SIGIO) /* input/output possible signal */
{ SIGIO, "IO" },
#endif
#if defined (SIGXCPU) /* exceeded CPU time limit */
{ SIGXCPU, "XCPU" },
#endif
#if defined (SIGXFSZ) /* exceeded file size limit */
{ SIGXFSZ, "XFSZ" },
#endif
#if defined (SIGVTALRM) /* virtual time alarm */
{ SIGVTALRM, "VTALRM" },
#endif
#if defined (SIGPROF) /* profiling time alarm */
{ SIGPROF, "PROF" },
#endif
#if defined (SIGWINCH) /* window changed */
{ SIGWINCH, "WINCH" },
#endif
/* 4.4 BSD */
#if defined (SIGINFO) && !defined (_SEQUENT_) /* information request */
{ SIGINFO, "INFO" },
#endif
#if defined (SIGUSR1) /* user defined signal 1 */
{ SIGUSR1, "USR1" },
#endif
#if defined (SIGUSR2) /* user defined signal 2 */
{ SIGUSR2, "USR2" },
#endif
#if defined (SIGKILLTHR) /* BeOS: Kill Thread */
{ SIGKILLTHR, "KILLTHR" }
#endif
};
/* The last entry of the complete signal list, including real time
signals. */
struct sigspec *sigspecs_last;
/* The number of sigspecs in the list. */
int sigspecs_size;
/* The number of digits in NSIG (approx.). */
int nsig_digits;
/* The name this program was run with, for error messages. */
char *program_name;
/* All options which require an argument are known to the
pre-scan loop in main(). */
#define OPT_SIGSPEC_LONG "sigspec"
#define OPT_SIGNUM_LONG "signum"
static char const short_options[] =
"0::1::2::3::4::5::6::7::8::9::"
"A::B::C::D::E::F::G::H::I::J::K::L::M::"
"N::O::P::Q::R::S::T::U::V::W::X::Y::Z::"
"ln:s:t";
static struct option const long_options[] =
{
{"list", no_argument, NULL, 'l'},
{"long-list", no_argument, NULL, 'L'},
{OPT_SIGSPEC_LONG, required_argument, NULL, 's'},
{OPT_SIGNUM_LONG, required_argument, NULL, 'n'},
{"signal", required_argument, NULL, 's'},
{"table", no_argument, NULL, 't'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
@@ -323,282 +91,208 @@ usage (int status)
else
{
printf (_("\
Usage: %s [-s SIGSPEC | -n SIGNUM | -SIGSPEC] PID ...\n\
or: %s -l [SIGSPEC] ...\n\
Usage: %s [-s SIGNAL | -SIGNAL] PID...\n\
or: %s -l [SIGNAL]...\n\
or: %s -t [SIGNAL]...\n\
"),
program_name, program_name);
program_name, program_name, program_name);
fputs (_("\
Send the signal named by SIGSPEC or SIGNUM to processes named by PID.\n\
\n\
-s, --" OPT_SIGSPEC_LONG " SIGSPEC name or number of signal to be sent\n\
-n, --" OPT_SIGNUM_LONG " SIGNUM number of signal to be sent\n\
\n\
-l, --list list the signal names\n\
-L, --long-list list the signal names with their numbers\n\
Send signals to processes, or list signals.\n\
\n\
"), stdout);
fputs (_("\
Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
-s, --signal=SIGNAL, -SIGNAL\n\
specify the name or number of the signal to be sent\n\
-l, --list list signal names, or convert signal names to/from numbers\n\
-t, --table print a table of signal information\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
fputs (_("\
\n\
kill returns true if at least one signal was successfully sent, or\n\
false if an error occurs or an invalid option is encountered.\n\
fputs (_("\n\
SIGNAL may be a signal name like `HUP', or a signal number like `1',\n\
or an exit status of a process terminated by a signal.\n\
PID is an integer; if negative it identifies a process group.\n\
"), stdout);
puts (_("\nReport bugs to <bug-sh-utils@gnu.org>."));
}
exit (status);
}
/* The function is called once before option parsing. It calculates
the maximum number of digits in a signum, adds the realtime signal
specs to the signal list, and adds all signals of the form -SIGTERM
and -TERM as possible options. */
static void
initialize (void)
/* Convert OPERAND to a signal number with printable representation SIGNAME.
Return the signal number, or -1 if unsuccessful. */
static int
operand2sig (char const *operand, char *signame)
{
char number[LONGEST_HUMAN_READABLE + 1];
struct sigspec *newspecs;
int signum;
nsig_digits = strlen (human_readable ((uintmax_t) NSIG, number, 1, 1));
sigspecs_size = sizeof (sigspecs) / sizeof (struct sigspec);
#if defined (SIGRTMIN) || defined (SIGRTMAX)
/* POSIX 1003.1b-1993 defines real time signals. The following code
is so convoluted because it also takes care of incomplete
implementations. */
# ifndef SIGRTMIN
# define SIGRTMIN SIGRTMAX
# endif
# ifndef SIGRTMAX
# define SIGRTMAX SIGRTMIN
# endif
/* Sanity check. */
if (SIGRTMAX >= SIGRTMIN)
if (ISDIGIT (*operand))
{
int rtsigc = SIGRTMAX - SIGRTMIN + 1;
int i;
/* Account for "RTMIN+" resp "RTMAX-", the number and '\0'. */
int maxlength = nsig_digits + 6 + 1;
newspecs = xmalloc (sizeof (struct sigspec)
* (sigspecs_size + rtsigc));
/* After this, newspecs will always point to the last element of
the array. */
newspecs->signum = NO_SIG;
newspecs->signame = NULL;
(++newspecs)->signum = SIGRTMAX;
newspecs->signame = "RTMAX";
if (rtsigc > 1)
{
(++newspecs)->signum = SIGRTMIN;
newspecs->signame = "RTMIN";
}
/* Create new elements for all missing realtime signals. */
for (i = 0; i < rtsigc - 2; i++)
{
(++newspecs)->signum = SIGRTMIN + 1 + i;
newspecs->signame = xmalloc (maxlength);
snprintf (newspecs->signame, maxlength, "%s%d",
(i < (rtsigc - 2)/2
? "RTMIN+" : "RTMAX-"),
(i < (rtsigc - 2)/2
? i + 1 : (rtsigc - 2) - i));
}
/* Copy the existing elements in the following space. */
for (i = 1; i < sigspecs_size; i++)
*(++newspecs) = sigspecs[i];
sigspecs_last = newspecs;
sigspecs_size += rtsigc;
char *endp;
long int l = (errno = 0, strtol (operand, &endp, 10));
int i = l;
signum = (operand == endp || *endp || errno || i != l ? -1
: WIFSIGNALED (i) ? WTERMSIG (i)
: i);
}
#else
sigspecs_last = sigspecs + (sigspecs_size - 1);
#endif
else
{
/* Convert signal to upper case in the C locale, not in the
current locale. Don't assume ASCII; it might be EBCDIC. */
char *upcased = xstrdup (operand);
char *p;
for (p = upcased; *p; p++)
if (strchr ("abcdefghijklmnopqrstuvwxyz", *p))
*p += 'A' - 'a';
/* Look for the signal name, possibly prefixed by "SIG",
and possibly lowercased. */
if (! (str2sig (upcased, &signum) == 0
|| (upcased[0] == 'S' && upcased[1] == 'I' && upcased[2] == 'G'
&& str2sig (upcased + 3, &signum) == 0)))
signum = -1;
free (upcased);
}
if (signum < 0 || sig2str (signum, signame) != 0)
{
error (0, 0, _("%s: invalid signal"), operand);
return -1;
}
return signum;
}
/* Print a row of `kill -t' output. NUM_WIDTH is the maximum signal
number width, and SIGNUM is the signal number to print. The
maximum name width is NAME_WIDTH, and SIGNAME is the name to print. */
static void
print_table_row (int num_width, int signum,
int name_width, char const *signame)
{
char const *description = strsignal (signum);
printf ("%*d %-*s %s\n", num_width, signum, name_width, signame,
description ? description : "?");
}
typedef enum { LIST_NONE, LIST_FLAT, LIST_PRETTY } list_t;
/* Print a list of signal names. If TABLE, print a table.
Print the names specified by ARGV if nonzero; otherwise,
print all known names. Return a suitable exit status. */
/* Print out a table listing all signals specifications with their
preferred name. */
static void
list_signals (list_t type)
static int
list_signals (bool table, char *const *argv)
{
int i = 0;
int entrylen = 0;
int unsorted;
int entries;
int last_signum = NO_SIG;
int column = 0;
struct sigspec *spec = sigspecs_last;
struct sigspec **specs = xmalloc (sizeof (struct sigspec *)
* (sigspecs_size - 1));
int signum;
int status = EXIT_SUCCESS;
char signame[SIG2STR_MAX];
/* Gather maximum name length and prepare sort array. Note that the
list is reversed in the array. This is taken into account by the
output routine below. */
while (spec->signum != NO_SIG)
if (table)
{
specs[i++] = spec;
if (spec->signame && strlen (spec->signame) > entrylen)
entrylen = strlen (spec->signame);
spec--;
}
int name_width = 0;
/* Sort the array by signal number. This is a simple bubble sort,
but the point is that the order of entries with the same signum
is presevered (otherwise the preferred alias is lost). */
if (sigspecs_size > 2)
do
{
unsorted = 0;
/* Compute the maximum width of a signal number. */
int num_width = 1;
for (signum = 1; signum <= SIGNUM_BOUND / 10; signum *= 10)
num_width++;
for (i = 0; i < sigspecs_size - 2; i++)
/* Compute the maximum width of a signal name. */
for (signum = 1; signum <= SIGNUM_BOUND; signum++)
if (sig2str (signum, signame) == 0)
{
if (specs[i]->signum > specs[i+1]->signum)
size_t len = strlen (signame);
if (name_width < len)
name_width = len;
}
if (argv)
for (; *argv; argv++)
{
signum = operand2sig (*argv, signame);
if (signum < 0)
status = EXIT_FAILURE;
else
print_table_row (num_width, signum, name_width, signame);
}
else
for (signum = 1; signum <= SIGNUM_BOUND; signum++)
if (sig2str (signum, signame) == 0)
print_table_row (num_width, signum, name_width, signame);
}
else
{
if (argv)
for (; *argv; argv++)
{
signum = operand2sig (*argv, signame);
if (signum < 0)
status = EXIT_FAILURE;
else
{
struct sigspec *saved = specs[i];
specs[i] = specs[i+1];
specs[i+1] = saved;
unsorted = 1;
if (ISDIGIT (**argv))
puts (signame);
else
printf ("%d\n", signum);
}
}
}
while (unsorted);
/* Account for "NR) NAME ". Calculate for 79 columns, the 80 takes
into account that the last entry is not followed by a space. */
entrylen += nsig_digits + 2 + 1;
entries = 80 / entrylen;
if (entries < 1)
entries = 1;
for (i = 0; i < sigspecs_size - 1; i++)
{
/* Skip duplicated signal numbers, signums without name and the
special signal number `0'. */
if (specs[i]->signame && specs[i]->signum
&& (last_signum == NO_SIG || last_signum != specs[i]->signum))
{
switch (type)
{
case LIST_PRETTY:
column++;
printf ("%*i) %-*s", nsig_digits, specs[i]->signum,
entrylen - nsig_digits - 2 + (column != entries ? 1 : 0),
specs[i]->signame);
if (column == entries - 1)
{
column = 0;
putchar ('\n');
}
break;
case LIST_FLAT:
column += printf ("%s%s",
(column == 0 ? ""
: (column + strlen (specs[i]->signame) > 78
? "\n" : " ")),
specs[i]->signame);
if (column > 79)
column = strlen (specs[i]->signame);
break;
default:
break;
}
last_signum = specs[i]->signum;
}
if (i == sigspecs_size - 2)
putchar ('\n');
else
for (signum = 1; signum <= SIGNUM_BOUND; signum++)
if (sig2str (signum, signame) == 0)
puts (signame);
}
}
return status;
}
/* Turn a string into a signal number, or a number into a signal
number. If STRING is "2", or "INT", then return the integer 2.
Return NO_SIG if STRING doesn't contain a valid signal
descriptor. */
/* Send signal SIGNUM to all the processes or process groups specified
by ARGV. Return a suitable exit status. */
static int
decode_signal (char const *sigspec)
send_signals (int signum, char *const *argv)
{
struct sigspec const *spec = sigspecs_last;
long l;
int status = EXIT_SUCCESS;
char const *arg = *argv;
if (xstrtol (sigspec, NULL, 0, &l, "") == LONGINT_OK)
if (! arg)
{
int sig = l;
if (sig != l)
return NO_SIG;
while (spec->signum != NO_SIG && spec->signum != sig)
spec--;
return spec->signum;
error (0, 0, _("missing operand after `%s'"), argv[-1]);
usage (EXIT_FAILURE);
}
/* A leading `SIG' may be omitted. */
while (spec->signum != NO_SIG)
do
{
if (spec->signame
&& (strcasecmp (sigspec, spec->signame) == 0
|| (strncasecmp (sigspec, "SIG", 3) == 0
&& strcasecmp (sigspec + 3, spec->signame) == 0)))
return (spec->signum);
spec--;
char *endp;
intmax_t n = (errno = 0, strtoimax (arg, &endp, 10));
pid_t pid = n;
if (errno == ERANGE || pid != n || arg == endp || *endp)
{
error (0, 0, _("%s: invalid process id"), arg);
status = EXIT_FAILURE;
}
else if (kill (pid, signum) != 0)
{
error (0, errno, "%s", arg);
status = EXIT_FAILURE;
}
}
return NO_SIG;
while ((arg = *++argv));
return status;
}
/* Find the preferred name for the signal with the number SIGNUM. */
static char const *const
name_signal (int signum)
{
struct sigspec const *spec = sigspecs_last;
while (spec->signum != NO_SIG && spec->signum != signum)
spec--;
return spec->signame;
}
/* Send the signal SIGNUM to process PID, using kill (). If an error
occurs, it is reported and passed through to the caller. */
static int
send_signal (pid_t pid, int signum)
{
int err;
err = kill (pid, signum);
if (err)
{
uintmax_t nr = (uintmax_t) (pid < 0 ? -pid : pid);
char number[LONGEST_HUMAN_READABLE + 1];
error (0, errno, "(%s%s)", (pid < 0 ? "-" : ""),
human_readable (nr, number, 1, 1));
}
return err;
}
int
main (int argc, char **argv)
{
int optc;
int err = 0;
int success = 0;
list_t list = LIST_NONE;
int sig_num = NO_SIG;
int i;
char **extra_opt;
int extra_opt_size = 0;
bool list = false;
bool table = false;
int signum = -1;
char signame[SIG2STR_MAX];
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -607,162 +301,74 @@ main (int argc, char **argv)
atexit (close_stdout);
initialize ();
extra_opt = xmalloc ((argc - 1) * sizeof (char *));
for (i = 1; i < argc; i++)
{
intmax_t dummy;
/* getopt will ignore everything following `--', so we do as
well. */
if (!strcmp ("--", argv[i]))
break;
/* Skip this argument if it doesn't look like an option. */
if (argv[i][0] != '-')
continue;
/* Skip it if it follows an option requiring an argument. */
if (i > 1 && argv[i-1][0] == '-')
{
/* A short option that doesn't look like -nTERM. */
if ((argv[i-1][1] == 'n' || argv[i-1][1] == 's')
&& argv[i-1][2] == '\0')
continue;
/* A long option (not `--', which was excluded above). */
if (argv[i-1][1] == '-'
&& (!strncmp (OPT_SIGNUM_LONG, &(argv[i-1][2]),
strlen (&argv[i-1][2]))
|| !strncmp (OPT_SIGSPEC_LONG, &(argv[i-1][2]),
strlen (&argv[i-1][2]))))
continue;
}
/* At this point we know that this argument is not argument to
another option, and that it starts with `-' but is not `--'. */
if (decode_signal (&(argv[i][1])) != NO_SIG
|| xstrtoimax (argv[i], NULL, 10, &dummy, "") == LONGINT_OK)
{
/* It is either a valid signal specifier or potentially a
valid process group. So remember it and make getopt not
care about it. */
extra_opt[extra_opt_size++] = argv[i];
argv[i][0] = 'X';
}
}
while ((optc = getopt_long (argc, argv, "s:n:lL", long_options, NULL))
while ((optc = getopt_long (argc, argv, short_options, long_options, NULL))
!= -1)
switch (optc)
{
case 's':
case 'n':
if (sig_num != NO_SIG)
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
if (optind != 2)
{
error (0, 0, _("%s: only one signal specififier allowed"), optarg);
usage (1);
/* This option is actually a process-id. */
optind--;
goto no_more_options;
}
sig_num = decode_signal (optarg);
if (sig_num == NO_SIG)
error (1, 0, _("%s: invalid signal specifier"), optarg);
/* Fall through. */
case 'A': case 'B': case 'C': case 'D': case 'E':
case 'F': case 'G': case 'H': case 'I': case 'J':
case 'K': case 'L': case 'M': case 'N': case 'O':
case 'P': case 'Q': case 'R': case 'S': case 'T':
case 'U': case 'V': case 'W': case 'X': case 'Y':
case 'Z':
if (! optarg)
optarg = argv[optind - 1] + strlen (argv[optind - 1]);
if (optarg != argv[optind - 1] + 2)
{
error (0, 0, _("invalid option -- %c"), optc);
usage (EXIT_FAILURE);
}
optarg--;
/* Fall through. */
case 'n': /* -n is not documented, but is for Bash compatibility. */
case 's':
if (0 <= signum)
{
error (0, 0, _("%s: multiple signals specified"), optarg);
usage (EXIT_FAILURE);
}
signum = operand2sig (optarg, signame);
if (signum < 0)
usage (EXIT_FAILURE);
break;
case 't':
table = true;
/* Fall through. */
case 'l':
list = LIST_FLAT;
break;
case 'L':
list = LIST_PRETTY;
if (list)
{
error (0, 0, _("multiple -l or -t options specified"));
usage (EXIT_FAILURE);
}
list = true;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
usage (1);
usage (EXIT_FAILURE);
}
no_more_options:;
argc -= optind;
argv += optind;
for (i = 0; i < extra_opt_size; i++)
extra_opt[i][0] = '-';
if (extra_opt_size > 0 && sig_num == NO_SIG)
if (signum < 0)
signum = SIGTERM;
else if (list)
{
char **arg = argv;
/* Find the first extra option collected in the remaining
argument list and if necessary, replace it with the first
remaining argument. This is a precaution in case getopt()
mangles the order of non-option arguments. */
while (*arg && *arg != extra_opt[0])
arg++;
if (*arg && *arg != argv[0])
*arg = argv[0];
argc--;
argv++;
/* Interpret the first one as a signal specifier. */
sig_num = decode_signal (&(extra_opt[0][1]));
if (sig_num == NO_SIG)
error (1, 0, _("%s: invalid signal specifier"), extra_opt[0]);
error (0, 0, _("cannot combine signal with -l or -t"));
usage (EXIT_FAILURE);
}
if (!list && sig_num == NO_SIG)
sig_num = SIGTERM;
if (argc == 0)
{
if (list)
list_signals (list);
else
{
error (0, 0, _("too few arguments"));
usage (1);
}
}
else
{
int j;
for (j = 0; j < argc; j++)
if (list)
{
int signum = decode_signal (argv[j]);
if (signum == NO_SIG)
{
error (0, 0, _("%s: invalid signal specifier"), argv[j]);
err = 1;
}
else
{
char const *const name = name_signal (signum);
printf ("%s\n", name ? name : "(unknown)");
success = 1;
}
}
else
{
intmax_t nr;
pid_t pid;
int inval = 0;
if (xstrtoimax (argv[j], NULL, 10, &nr, "") != LONGINT_OK)
inval = 1;
pid = (pid_t) nr;
if (inval || pid != nr)
{
error (0, 0, _("%s: invalid process id"), argv[j]);
err = 1;
continue;
}
if (send_signal (pid, sig_num))
err = 1;
else
success = 1;
}
}
exit ((success || !err) ? 0 : 1);
return (list
? list_signals (table, optind == argc ? NULL : argv + optind)
: send_signals (signum, argv + optind));
}

102
src/link.c Normal file
View File

@@ -0,0 +1,102 @@
/* link utility for GNU.
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Michael Stone */
/* Implementation overview:
Simply call the system 'link' function */
#include <config.h>
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
#include <assert.h>
#include "system.h"
#include "error.h"
#include "long-options.h"
#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "link"
#define AUTHORS "Michael Stone"
/* Name this program was run with. */
char *program_name;
void
usage (int status)
{
if (status != 0)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
{
printf (_("\
Usage: %s FILE1 FILE2\n\
or: %s OPTION\n"), program_name, program_name);
fputs (_("Call the link function to create a link named FILE2\
to an existing FILE1.\n\n"),
stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
}
exit (status);
}
int
main (int argc, char **argv)
{
program_name = argv[0];
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
AUTHORS, usage);
/* The above handles --help and --version.
Since there is no other invocation of getopt, handle `--' here. */
if (1 < argc && STREQ (argv[1], "--"))
{
--argc;
++argv;
}
if (argc < 3)
{
error (0, 0, _("too few arguments"));
usage (1);
}
if (3 < argc)
{
error (0, 0, _("too many arguments"));
usage (1);
}
if (link (argv[1], argv[2]) != 0)
error (EXIT_FAILURE, errno, _("cannot create link %s to %s"),
quote_n (0, argv[2]), quote_n (1, argv[1]));
exit (0);
}

128
src/ls.c
View File

@@ -149,32 +149,6 @@ int wcwidth ();
# define HAVE_SYMLINKS 0
#endif
/* If any of the S_* macros are undefined, define them here so each
use doesn't have to be guarded with e.g., #ifdef S_ISLNK. */
#ifndef S_ISLNK
# define S_ISLNK(Mode) 0
#endif
#ifndef S_ISFIFO
# define S_ISFIFO(Mode) 0
#endif
#ifndef S_ISSOCK
# define S_ISSOCK(Mode) 0
#endif
#ifndef S_ISCHR
# define S_ISCHR(Mode) 0
#endif
#ifndef S_ISBLK
# define S_ISBLK(Mode) 0
#endif
#ifndef S_ISDOOR
# define S_ISDOOR(Mode) 0
#endif
/* Arrange to make lstat calls go through the wrapper function
on systems with an lstat function that does not dereference symlinks
that are specified with a trailing slash. */
@@ -184,11 +158,9 @@ int rpl_lstat PARAMS((const char *, struct stat *));
# define lstat(Name, Stat_buf) rpl_lstat(Name, Stat_buf)
#endif
#if D_TYPE_IN_DIRENT && defined DTTOIF
# define HAVE_STRUCT_DIRENT_D_TYPE 1
#if HAVE_STRUCT_DIRENT_D_TYPE && defined DTTOIF
# define DT_INIT(Val) = Val
#else
# define HAVE_STRUCT_DIRENT_D_TYPE 0
# define DT_INIT(Val) /* empty */
#endif
@@ -198,6 +170,30 @@ int rpl_lstat PARAMS((const char *, struct stat *));
# define TIMESPEC_NS(timespec) 0
#endif
#if ! HAVE_STRUCT_STAT_ST_AUTHOR
# define st_author st_uid
#endif
/* Cray/Unicos DMF: use the file's migrated, not real, status */
#if HAVE_ST_DM_MODE
# define ST_DM_MODE(Stat_buf) ((Stat_buf).st_dm_mode)
#else
# define ST_DM_MODE(Stat_buf) ((Stat_buf).st_mode)
#endif
#ifndef LOGIN_NAME_MAX
# if _POSIX_LOGIN_NAME_MAX
# define LOGIN_NAME_MAX _POSIX_LOGIN_NAME_MAX
# else
# define LOGIN_NAME_MAX 17
# endif
#endif
/* The maximum length of a string representation of a user or group ID,
not counting any terminating NUL byte. */
#define ID_LENGTH_MAX \
MAX (LOGIN_NAME_MAX - 1, LONGEST_HUMAN_READABLE)
enum filetype
{
unknown DT_INIT (DT_UNKNOWN),
@@ -461,6 +457,10 @@ static int sort_reverse;
static int print_owner = 1;
/* Nonzero means to display author information. */
static bool print_author;
/* Nonzero means to display group information. -G and -o turn this off. */
static int print_group = 1;
@@ -697,7 +697,8 @@ static int exit_status;
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
BLOCK_SIZE_OPTION = CHAR_MAX + 1,
AUTHOR_OPTION = CHAR_MAX + 1,
BLOCK_SIZE_OPTION,
COLOR_OPTION,
FORMAT_OPTION,
FULL_TIME_OPTION,
@@ -747,6 +748,7 @@ static struct option const long_options[] =
{"time-style", required_argument, 0, TIME_STYLE_OPTION},
{"color", optional_argument, 0, COLOR_OPTION},
{"block-size", required_argument, 0, BLOCK_SIZE_OPTION},
{"author", no_argument, 0, AUTHOR_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
@@ -1494,6 +1496,10 @@ decode_switches (int argc, char **argv)
format = one_per_line;
break;
case AUTHOR_OPTION:
print_author = true;
break;
case SORT_OPTION:
sort_type = XARGMATCH ("--sort", optarg, sort_args, sort_types);
sort_type_specified = 1;
@@ -2741,20 +2747,39 @@ get_current_time (void)
current_time_ns = 999999999;
}
/* Format into BUFFER the name or id of the user with id U. Return
the length of the formatted buffer, not counting the terminating
null. */
static size_t
format_user (char *buffer, uid_t u)
{
char const *name = (numeric_ids ? NULL : getuser (u));
if (name)
sprintf (buffer, "%-8s ", name);
else
sprintf (buffer, "%-8lu ", (unsigned long) u);
return strlen (buffer);
}
/* Print information about F in long format. */
static void
print_long_format (const struct fileinfo *f)
{
char modebuf[12];
/* 7 fields that may require LONGEST_HUMAN_READABLE bytes,
1 10-byte mode string,
1 35-byte time string (may be longer in some locales -- see below)
or LONGEST_HUMAN_READABLE integer,
9 spaces, one following each of these fields, and
1 trailing NUL byte. */
char init_bigbuf[7 * LONGEST_HUMAN_READABLE + 10
+ MAX (35, LONGEST_HUMAN_READABLE)
+ 9 + 1];
char init_bigbuf
[LONGEST_HUMAN_READABLE + 1 /* inode */
+ LONGEST_HUMAN_READABLE + 1 /* size in blocks */
+ sizeof (modebuf) - 1 + 1 /* mode string */
+ LONGEST_HUMAN_READABLE + 1 /* st_nlink */
+ ID_LENGTH_MAX + 1 /* owner name */
+ ID_LENGTH_MAX + 1 /* group name */
+ ID_LENGTH_MAX + 1 /* author name */
+ LONGEST_HUMAN_READABLE + 1 /* major device number */
+ LONGEST_HUMAN_READABLE + 1 /* minor device number */
+ 35 + 1 /* usual length of time/date -- may be longer; see below */
];
char *buf = init_bigbuf;
size_t bufsize = sizeof (init_bigbuf);
size_t s;
@@ -2763,12 +2788,10 @@ print_long_format (const struct fileinfo *f)
int when_ns IF_LINT (= 0);
struct tm *when_local;
#if HAVE_ST_DM_MODE
/* Cray DMF: look at the file's migrated, not real, status */
mode_string (f->stat.st_dm_mode, modebuf);
#else
mode_string (f->stat.st_mode, modebuf);
#endif
/* Compute mode string. On most systems, it's based on st_mode.
On systems with migration (via the stat.st_dm_mode field), use
the file's migrated status. */
mode_string (ST_DM_MODE (f->stat), modebuf);
modebuf[10] = (FILE_HAS_ACL (f) ? '+' : ' ');
modebuf[11] = '\0';
@@ -2815,14 +2838,7 @@ print_long_format (const struct fileinfo *f)
p += strlen (p);
if (print_owner)
{
char const *user_name = (numeric_ids ? NULL : getuser (f->stat.st_uid));
if (user_name)
sprintf (p, "%-8s ", user_name);
else
sprintf (p, "%-8lu ", (unsigned long) f->stat.st_uid);
p += strlen (p);
}
p += format_user (p, f->stat.st_uid);
if (print_group)
{
@@ -2834,6 +2850,9 @@ print_long_format (const struct fileinfo *f)
p += strlen (p);
}
if (print_author)
p += format_user (p, f->stat.st_author);
if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))
sprintf (p, "%3lu, %3lu ",
(unsigned long) major (f->stat.st_rdev),
@@ -3584,6 +3603,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
fputs (_("\
-a, --all do not hide entries starting with .\n\
-A, --almost-all do not list implied . and ..\n\
--author print the author of each file\n\
-b, --escape print octal escapes for nongraphic characters\n\
"), stdout);
fputs (_("\

View File

@@ -186,7 +186,7 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
if (!fail)
{
const char *dir_to_remove;
char const *dir_to_remove;
if (copy_into_self)
{
/* In general, when copy returns with copy_into_self set, SOURCE is
@@ -206,7 +206,7 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
else if (rename_succeeded)
{
/* No need to remove anything. SOURCE was successfully
renamed to DEST. */
renamed to DEST. Or the user declined to rename a file. */
dir_to_remove = NULL;
}
else
@@ -239,42 +239,15 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
if (dir_to_remove != NULL)
{
struct rm_options rm_options;
struct File_spec fs;
enum RM_status status;
static int first_rm = 1;
static struct dev_ino cwd_dev_ino;
if (first_rm)
{
struct stat cwd_sb;
if (lstat (".", &cwd_sb))
error (EXIT_FAILURE, errno, _("cannot lstat `.'"));
first_rm = 0;
cwd_dev_ino.st_dev = cwd_sb.st_dev;
cwd_dev_ino.st_ino = cwd_sb.st_ino;
}
rm_option_init (&rm_options);
rm_options.verbose = x->verbose;
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 (fs.filename);
status = rm (&fs, 1, &rm_options, &cwd_dev_ino);
status = rm (1, &dir_to_remove, &rm_options);
assert (VALID_STATUS (status));
if (status == RM_ERROR)
fail = 1;
remove_fini ();
if (fail)
error (0, errno, _("cannot remove %s"), quote (dir_to_remove));
}
}

View File

@@ -66,6 +66,14 @@ typedef double LONG_DOUBLE;
# define LDBL_DIG DBL_DIG
#endif
#if HAVE_UNSIGNED_LONG_LONG
typedef unsigned long long ulonglong_t;
#else
/* This is just a place-holder to avoid a few `#if' directives.
In this case, the type isn't actually used. */
typedef unsigned long int ulonglong_t;
#endif
enum size_spec
{
NO_SIZE,
@@ -77,7 +85,8 @@ enum size_spec
/* FIXME: add INTMAX support, too */
FLOAT_SINGLE,
FLOAT_DOUBLE,
FLOAT_LONG_DOUBLE
FLOAT_LONG_DOUBLE,
N_SIZE_SPECS
};
enum output_format
@@ -136,11 +145,20 @@ static const int width_bytes[] =
sizeof (short int),
sizeof (int),
sizeof (long int),
sizeof (ulonglong_t),
sizeof (float),
sizeof (double),
sizeof (LONG_DOUBLE)
};
/* Ensure that for each member of `enum size_spec' there is an
initializer in the width_bytes array. */
struct dummy
{
int assert_width_bytes_matches_size_spec_decl
[sizeof width_bytes / sizeof width_bytes[0] == N_SIZE_SPECS ? 1 : -1];
};
/* Names for some non-printing characters. */
static const char *const charname[33] =
{
@@ -231,14 +249,6 @@ static FILE *in_stream;
/* If nonzero, at least one of the files we read was standard input. */
static int have_read_stdin;
#if HAVE_UNSIGNED_LONG_LONG
typedef unsigned long long ulonglong_t;
#else
/* This is just a place-holder to avoid a few `#if' directives.
In this case, the type isn't actually used. */
typedef unsigned long int ulonglong_t;
#endif
#define MAX_INTEGRAL_TYPE_SIZE sizeof (ulonglong_t)
static enum size_spec integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1];

View File

@@ -1,5 +1,5 @@
/* pathchk -- check whether pathnames are valid or portable
Copyright (C) 1991-2001 Free Software Foundation, Inc.
Copyright (C) 1991-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -325,7 +325,7 @@ validate_path (char *path, int portability)
if (!last_elem)
{
exists = dir_ok (path);
if (dir_ok == 0)
if (exists == 0)
{
free (parent);
return 1;

View File

@@ -380,7 +380,7 @@ struct COLUMN;
struct COLUMN
{
FILE *fp; /* Input stream for this column. */
char *name; /* File name. */
char const *name; /* File name. */
enum
{
OPEN,
@@ -1335,7 +1335,7 @@ init_fps (int number_of_files, char **av)
int i, files_left;
COLUMN *p;
FILE *firstfp;
char *firstname;
char const *firstname;
total_files = 0;

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,4 @@
#include "save-cwd.h"
struct rm_options
{
@@ -25,24 +26,23 @@ struct rm_options
enum RM_status
{
/* These must be listed in order of increasing seriousness. */
RM_OK = 1,
RM_OK = 2,
RM_USER_DECLINED,
RM_ERROR
RM_ERROR,
RM_NONEMPTY_DIR
};
#define VALID_STATUS(S) \
((S) == RM_OK || (S) == RM_USER_DECLINED || (S) == RM_ERROR)
struct File_spec
{
char *filename;
unsigned int have_filetype_mode:1;
unsigned int have_full_mode:1;
unsigned int have_device:1;
mode_t mode;
ino_t st_ino;
dev_t st_dev;
};
#define UPDATE_STATUS(S, New_value) \
do \
{ \
if ((New_value) == RM_ERROR \
|| ((New_value) == RM_USER_DECLINED && (S) == RM_OK)) \
(S) = (New_value); \
} \
while (0)
struct dev_ino
{
@@ -50,10 +50,5 @@ struct dev_ino
dev_t st_dev;
};
enum RM_status rm PARAMS ((struct File_spec *fs,
int user_specified_name,
struct rm_options const *x,
struct dev_ino const *cwd_dev_ino));
void fspec_init_file PARAMS ((struct File_spec *fs, const char *filename));
void remove_init PARAMS ((void));
void remove_fini PARAMS ((void));
enum RM_status rm PARAMS ((size_t n_files, char const *const *file,
struct rm_options const *x));

View File

@@ -16,7 +16,7 @@
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Paul Rubin, David MacKenzie, and Richard Stallman.
Reworked to use chdir and hash tables by Jim Meyering. */
Reworked to use chdir and avoid recursion by Jim Meyering. */
/* Implementation overview:
@@ -185,35 +185,15 @@ main (int argc, char **argv)
}
}
remove_init ();
{
struct stat cwd_sb;
struct dev_ino cwd_dev_ino;
size_t n_files = argc - optind;
char const *const *file = (char const *const *) argv + optind;
/* FIXME: this lstat is not always necessary -- e.g., if there are no
directories, or if all directories arguments are specified via
absolute names. */
if (lstat (".", &cwd_sb))
error (EXIT_FAILURE, errno, _("cannot lstat `.'"));
cwd_dev_ino.st_dev = cwd_sb.st_dev;
cwd_dev_ino.st_ino = cwd_sb.st_ino;
for (; optind < argc; optind++)
{
struct File_spec fs;
enum RM_status status;
fspec_init_file (&fs, argv[optind]);
status = rm (&fs, 1, &x, &cwd_dev_ino);
assert (VALID_STATUS (status));
if (status == RM_ERROR)
fail = 1;
}
enum RM_status status = rm (n_files, file, &x);
assert (VALID_STATUS (status));
if (status == RM_ERROR)
fail = 1;
}
remove_fini ();
exit (fail);
}

View File

@@ -1,5 +1,5 @@
/* seq - print sequence of numbers to standard output.
Copyright (C) 1994-2001 Free Software Foundation, Inc.
Copyright (C) 1994-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -87,8 +87,8 @@ Usage: %s [OPTION]... LAST\n\
fputs (_("\
Print numbers from FIRST to LAST, in steps of INCREMENT.\n\
\n\
-f, --format FORMAT use printf(3) style FORMAT (default: %g)\n\
-s, --separator STRING use STRING to separate numbers (default: \\n)\n\
-f, --format=FORMAT use printf style floating-point FORMAT (default: %g)\n\
-s, --separator=STRING use STRING to separate numbers (default: \\n)\n\
-w, --equal-width equalize width by padding with leading zeroes\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);

View File

@@ -52,7 +52,7 @@ struct rlimit { size_t rlim_cur; };
#define AUTHORS N_ ("Mike Haertel and Paul Eggert")
#if defined ENABLE_NLS && HAVE_LANGINFO_H
#if HAVE_LANGINFO_H
# include <langinfo.h>
#endif
@@ -91,7 +91,7 @@ double strtod ();
#define NEGATION_SIGN '-'
#define NUMERIC_ZERO '0'
#ifdef ENABLE_NLS
#if HAVE_SETLOCALE
static char decimal_point;
static int th_sep; /* if CHAR_MAX + 1, then there is no thousands separator */
@@ -194,15 +194,9 @@ static char fold_toupper[UCHAR_LIM];
#define MONTHS_PER_YEAR 12
#if defined ENABLE_NLS && HAVE_NL_LANGINFO
# define MONTHTAB_CONST /* empty */
#else
# define MONTHTAB_CONST const
#endif
/* Table mapping month names to integers.
Alphabetic order allows binary search. */
static MONTHTAB_CONST struct month monthtab[] =
static struct month monthtab[] =
{
{"APR", 4},
{"AUG", 8},
@@ -536,7 +530,7 @@ zaptemp (const char *name)
}
}
#if defined ENABLE_NLS && HAVE_NL_LANGINFO
#if HAVE_NL_LANGINFO
static int
struct_month_cmp (const void *m1, const void *m2)
@@ -568,7 +562,7 @@ inittables (void)
fold_toupper[i] = i;
}
#if defined ENABLE_NLS && HAVE_NL_LANGINFO
#if HAVE_NL_LANGINFO
/* If we're not in the "C" locale, read different names for months. */
if (hard_LC_TIME)
{
@@ -591,7 +585,7 @@ inittables (void)
qsort ((void *) monthtab, MONTHS_PER_YEAR,
sizeof (struct month), struct_month_cmp);
}
#endif /* NLS */
#endif
}
/* Specify the amount of main memory to use when sorting. */
@@ -1366,10 +1360,9 @@ keycompare (const struct line *a, const struct line *b)
}
else if (key->month)
diff = getmonth (texta, lena) - getmonth (textb, lenb);
#ifdef ENABLE_NLS
/* Sorting like this may become slow, so in a simple locale the user
can select a faster sort that is similar to ascii sort */
else if (hard_LC_COLLATE)
else if (HAVE_SETLOCALE && hard_LC_COLLATE)
{
if (ignore || translate)
{
@@ -1407,7 +1400,6 @@ keycompare (const struct line *a, const struct line *b)
else
diff = xmemcoll (texta, lena, textb, lenb);
}
#endif
else if (ignore)
{
#define CMP_WITH_IGNORE(A, B) \
@@ -1527,10 +1519,8 @@ compare (register const struct line *a, register const struct line *b)
diff = - NONZERO (blen);
else if (blen == 0)
diff = NONZERO (alen);
#ifdef ENABLE_NLS
else if (hard_LC_COLLATE)
else if (HAVE_SETLOCALE && hard_LC_COLLATE)
diff = xmemcoll (a->text, alen, b->text, blen);
#endif
else if (! (diff = memcmp (a->text, b->text, min (alen, blen))))
diff = alen < blen ? -1 : alen != blen;
@@ -2187,13 +2177,12 @@ main (int argc, char **argv)
atexit (cleanup);
#ifdef ENABLE_NLS
hard_LC_COLLATE = hard_locale (LC_COLLATE);
# if HAVE_NL_LANGINFO
#if HAVE_NL_LANGINFO
hard_LC_TIME = hard_locale (LC_TIME);
# endif
#endif
#if HAVE_SETLOCALE
/* Let's get locale's representation of the decimal point */
{
struct lconv *lconvp = localeconv ();
@@ -2210,8 +2199,7 @@ main (int argc, char **argv)
if (! th_sep || lconvp->thousands_sep[1])
th_sep = CHAR_MAX + 1;
}
#endif /* NLS */
#endif
have_read_stdin = 0;
inittables ();

987
src/stat.c Normal file
View File

@@ -0,0 +1,987 @@
/* stat.c -- display file or filesystem status
Copyright (C) 2001, 2002 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Written by Michael Meskes. */
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SYSMACROS_H
# include <sys/sysmacros.h>
#endif
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <time.h>
#if HAVE_SYS_STATVFS_H
# include <sys/statvfs.h>
#endif
#if HAVE_SYS_VFS_H
# include <sys/vfs.h>
#endif
/* NetBSD 1.5.2 needs these, for the declaration of struct statfs. */
#if !HAVE_SYS_STATVFS_H && !HAVE_SYS_VFS_H
# if HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H
# include <sys/param.h>
# include <sys/mount.h>
# endif
#endif
#include <string.h>
#include <malloc.h>
#include <ctype.h>
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#if ! defined PRIdMAX
# if HAVE_LONG_LONG
# define PRIdMAX "lld"
# else
# define PRIdMAX "ld"
# endif
#endif
#if ! defined PRIuMAX
# if HAVE_LONG_LONG
# define PRIuMAX "llu"
# else
# define PRIuMAX "lu"
# endif
#endif
#include "system.h"
#include "closeout.h"
#include "error.h"
#include "filemode.h"
#include "fs.h"
#include "getopt.h"
#include "quotearg.h"
#include "xreadlink.h"
#ifdef FLASK_LINUX
# include <selinux/fs_secure.h>
# include <linux/flask/security.h>
# include <selinux/flask_util.h> /* for is_flask_enabled() */
# define SECURITY_ID_T security_id_t
#else
# define SECURITY_ID_T int
# define is_flask_enabled() 0
# define stat_secure(a,b,c) stat(a,b)
# define lstat_secure(a,b,c) lstat(a,b)
# define statfs_secure(a,b,c) statfs(a,b)
#endif
#define NAMEMAX_FORMAT PRIuMAX
#if HAVE_STRUCT_STATVFS_F_BASETYPE
# define STRUCT_STATVFS struct statvfs
# define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATVFS
# if HAVE_STRUCT_STATVFS_F_NAMEMAX
# define SB_F_NAMEMAX(S) ((uintmax_t) ((S)->f_namemax))
# endif
#else
# define STRUCT_STATVFS struct statfs
# define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATFS
# if HAVE_STRUCT_STATFS_F_NAMELEN
# define SB_F_NAMEMAX(S) ((uintmax_t) ((S)->f_namelen))
# endif
#endif
#ifndef SB_F_NAMEMAX
/* NetBSD 1.5.2 has neither f_namemax nor f_namelen. */
# define SB_F_NAMEMAX(S) "*"
# undef NAMEMAX_FORMAT
# define NAMEMAX_FORMAT "s"
#endif
size_t nstrftime PARAMS ((char *, size_t, char const *,
struct tm const *, int, int));
#define PROGRAM_NAME "stat"
#define AUTHORS "Michael Meskes"
static struct option const long_options[] = {
{"link", no_argument, 0, 'l'},
{"format", required_argument, 0, 'c'},
{"filesystem", no_argument, 0, 'f'},
{"secure", no_argument, 0, 's'},
{"terse", no_argument, 0, 't'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
};
char *program_name;
static void
print_human_type (mode_t mode)
{
char const *type;
switch (mode & S_IFMT)
{
case S_IFDIR:
type = "Directory";
break;
case S_IFCHR:
type = "Character Device";
break;
case S_IFBLK:
type = "Block Device";
break;
case S_IFREG:
type = "Regular File";
break;
case S_IFLNK:
type = "Symbolic Link";
break;
case S_IFSOCK:
type = "Socket";
break;
case S_IFIFO:
type = "Fifo File";
break;
default:
type = "Unknown";
}
fputs (type, stdout);
}
/* Return the type of the specified file system.
Some systems have statfvs.f_basetype[FSTYPSZ]. (AIX, HP-UX, and Solaris)
Others have statfs.f_fstypename[MFSNAMELEN]. (NetBSD 1.5.2)
Still others have neither and have to get by with f_type (Linux). */
static char *
human_fstype (STRUCT_STATVFS const *statfsbuf)
{
#if HAVE_STRUCT_STATVFS_F_BASETYPE
return statfsbuf->f_basetype;
#else
# if HAVE_STRUCT_STATFS_F_FSTYPENAME
return statfsbuf->f_fstypename;
# else
char const *type;
switch (statfsbuf->f_type)
{
# if defined __linux__
case S_MAGIC_AFFS:
type = "affs";
break;
case S_MAGIC_EXT:
type = "ext";
break;
case S_MAGIC_EXT2_OLD:
type = "ext2";
break;
case S_MAGIC_EXT2:
type = "ext2/ext3";
break;
case S_MAGIC_HPFS:
type = "hpfs";
break;
case S_MAGIC_ISOFS:
type = "isofs";
break;
case S_MAGIC_ISOFS_WIN:
type = "isofs";
break;
case S_MAGIC_ISOFS_R_WIN:
type = "isofs";
break;
case S_MAGIC_MINIX:
type = "minix";
break;
case S_MAGIC_MINIX_30:
type = "minix (30 char.)";
break;
case S_MAGIC_MINIX_V2:
type = "minix v2";
break;
case S_MAGIC_MINIX_V2_30:
type = "minix v2 (30 char.)";
break;
case S_MAGIC_MSDOS:
type = "msdos";
break;
case S_MAGIC_FAT:
type = "fat";
break;
case S_MAGIC_NCP:
type = "novell";
break;
case S_MAGIC_NFS:
type = "nfs";
break;
case S_MAGIC_PROC:
type = "proc";
break;
case S_MAGIC_SMB:
type = "smb";
break;
case S_MAGIC_XENIX:
type = "xenix";
break;
case S_MAGIC_SYSV4:
type = "sysv4";
break;
case S_MAGIC_SYSV2:
type = "sysv2";
break;
case S_MAGIC_COH:
type = "coh";
break;
case S_MAGIC_UFS:
type = "ufs";
break;
case S_MAGIC_XIAFS:
type = "xia";
break;
case S_MAGIC_NTFS:
type = "ntfs";
break;
case S_MAGIC_TMPFS:
type = "tmpfs";
break;
case S_MAGIC_REISERFS:
type = "reiserfs";
break;
case S_MAGIC_CRAMFS:
type = "cramfs";
break;
case S_MAGIC_ROMFS:
type = "romfs";
break;
# elif __GNU__
case FSTYPE_UFS:
type = "ufs";
break;
case FSTYPE_NFS:
type = "nfs";
break;
case FSTYPE_GFS:
type = "gfs";
break;
case FSTYPE_LFS:
type = "lfs";
break;
case FSTYPE_SYSV:
type = "sysv";
break;
case FSTYPE_FTP:
type = "ftp";
break;
case FSTYPE_TAR:
type = "tar";
break;
case FSTYPE_AR:
type = "ar";
break;
case FSTYPE_CPIO:
type = "cpio";
break;
case FSTYPE_MSLOSS:
type = "msloss";
break;
case FSTYPE_CPM:
type = "cpm";
break;
case FSTYPE_HFS:
type = "hfs";
break;
case FSTYPE_DTFS:
type = "dtfs";
break;
case FSTYPE_GRFS:
type = "grfs";
break;
case FSTYPE_TERM:
type = "term";
break;
case FSTYPE_DEV:
type = "dev";
break;
case FSTYPE_PROC:
type = "proc";
break;
case FSTYPE_IFSOCK:
type = "ifsock";
break;
case FSTYPE_AFS:
type = "afs";
break;
case FSTYPE_DFS:
type = "dfs";
break;
case FSTYPE_PROC9:
type = "proc9";
break;
case FSTYPE_SOCKET:
type = "socket";
break;
case FSTYPE_MISC:
type = "misc";
break;
case FSTYPE_EXT2FS:
type = "ext2/ext3";
break;
case FSTYPE_HTTP:
type = "http";
break;
case FSTYPE_MEMFS:
type = "memfs";
break;
case FSTYPE_ISO9660:
type = "iso9660";
break;
# endif
default:
type = NULL;
break;
}
if (type)
return (char *) type;
{
static char buf[sizeof "UNKNOWN (0x%x)" - 2
+ 2 * sizeof (statfsbuf->f_type)];
sprintf (buf, "UNKNOWN (0x%x)", statfsbuf->f_type);
return buf;
}
# endif
#endif
}
static void
print_human_access (struct stat const *statbuf)
{
char modebuf[11];
mode_string (statbuf->st_mode, modebuf);
modebuf[10] = 0;
fputs (modebuf, stdout);
}
static void
print_human_time (time_t const *t)
{
char str[80];
#if 0 /* %c is too locale-dependent. */
if (strftime (str, 40, "%c", localtime (t)) > 0)
#else
if (nstrftime (str, sizeof str, "%Y-%m-%d %H:%M:%S.%N %z",
localtime (t), 0, 0) > 0)
#endif
fputs (str, stdout);
else
printf ("Cannot calculate human readable time, sorry");
}
/* print statfs info */
static void
print_statfs (char *pformat, char m, char const *filename,
void const *data, SECURITY_ID_T sid)
{
STRUCT_STATVFS const *statfsbuf = data;
#ifdef FLASK_LINUX
char sbuf[256];
int rv;
unsigned int sbuflen = sizeof (sbuf);
#endif
switch (m)
{
case 'n':
strcat (pformat, "s");
printf (pformat, filename);
break;
case 'i':
#if HAVE_STRUCT_STATXFS_F_FSID___VAL
strcat (pformat, "x %-8x");
printf (pformat, statfsbuf->f_fsid.__val[0], /* u_long */
statfsbuf->f_fsid.__val[1]);
#else
strcat (pformat, "Lx");
printf (pformat, statfsbuf->f_fsid);
#endif
break;
case 'l':
strcat (pformat, NAMEMAX_FORMAT);
printf (pformat, SB_F_NAMEMAX (statfsbuf));
break;
case 't':
#if HAVE_STRUCT_STATXFS_F_TYPE
strcat (pformat, "lx");
printf (pformat, (long int) (statfsbuf->f_type)); /* no equiv. */
#else
strcat (pformat, "s");
printf (pformat, "*");
#endif
break;
case 'T':
strcat (pformat, "s");
printf (pformat, human_fstype (statfsbuf));
break;
case 'b':
strcat (pformat, PRIdMAX);
printf (pformat, (intmax_t) (statfsbuf->f_blocks));
break;
case 'f':
strcat (pformat, PRIdMAX);
printf (pformat, (intmax_t) (statfsbuf->f_bfree));
break;
case 'a':
strcat (pformat, PRIdMAX);
printf (pformat, (intmax_t) (statfsbuf->f_bavail));
break;
case 's':
strcat (pformat, "ld");
printf (pformat, (long int) (statfsbuf->f_bsize));
break;
case 'c':
strcat (pformat, PRIdMAX);
printf (pformat, (intmax_t) (statfsbuf->f_files));
break;
case 'd':
strcat (pformat, PRIdMAX);
printf (pformat, (intmax_t) (statfsbuf->f_ffree));
break;
#ifdef FLASK_LINUX
case 'S':
strcat (pformat, "d");
printf (pformat, sid);
break;
case 'C':
rv = security_sid_to_context (sid, (security_context_t *) &sbuf,
&sbuflen);
if (rv < 0)
sprintf (sbuf, "<error finding security context %d>", sid);
fputs (sbuf, stdout);
break;
#endif
default:
strcat (pformat, "c");
printf (pformat, m);
break;
}
}
/* print stat info */
static void
print_stat (char *pformat, char m, char const *filename,
void const *data, SECURITY_ID_T sid)
{
char linkname[256];
int i;
struct stat *statbuf = (struct stat *) data;
struct passwd *pw_ent;
struct group *gw_ent;
#ifdef FLASK_LINUX
char sbuf[256];
int rv;
unsigned int sbuflen = sizeof (sbuf);
#endif
switch (m)
{
case 'n':
strcat (pformat, "s");
printf (pformat, filename);
break;
case 'N':
strcat (pformat, "s");
if ((statbuf->st_mode & S_IFMT) == S_IFLNK)
{
if ((i = readlink (filename, linkname, 256)) == -1)
{
perror (filename);
return;
}
linkname[(i >= 256) ? 255 : i] = '\0';
/*printf("\"%s\" -> \"%s\"", filename, linkname); */
printf ("\"");
printf (pformat, filename);
printf ("\" -> \"");
printf (pformat, linkname);
printf ("\"");
}
else
{
printf ("\"");
printf (pformat, filename);
printf ("\"");
}
break;
case 'd':
strcat (pformat, "d");
printf (pformat, (int) statbuf->st_dev);
break;
case 'D':
strcat (pformat, "x");
printf (pformat, (int) statbuf->st_dev);
break;
case 'i':
strcat (pformat, "d");
printf (pformat, (int) statbuf->st_ino);
break;
case 'a':
strcat (pformat, "o");
printf (pformat, statbuf->st_mode & 07777);
break;
case 'A':
print_human_access (statbuf);
break;
case 'f':
strcat (pformat, "x");
printf (pformat, statbuf->st_mode);
break;
case 'F':
print_human_type (statbuf->st_mode);
break;
case 'h':
strcat (pformat, "d");
printf (pformat, (int) statbuf->st_nlink);
break;
#ifdef FLASK_LINUX
case 'S':
strcat (pformat, "d");
printf (pformat, sid);
break;
case 'C':
rv = security_sid_to_context (sid, (security_context_t *) &sbuf,
&sbuflen);
if (rv < 0)
sprintf (sbuf, "<error finding security context %d>", sid);
fputs (sbuf, stdout);
break;
#endif
case 'u':
strcat (pformat, "d");
printf (pformat, statbuf->st_uid);
break;
case 'U':
strcat (pformat, "s");
setpwent ();
pw_ent = getpwuid (statbuf->st_uid);
printf (pformat, (pw_ent != 0L) ? pw_ent->pw_name : "UNKNOWN");
break;
case 'g':
strcat (pformat, "d");
printf (pformat, statbuf->st_gid);
break;
case 'G':
strcat (pformat, "s");
setgrent ();
gw_ent = getgrgid (statbuf->st_gid);
printf (pformat, (gw_ent != 0L) ? gw_ent->gr_name : "UNKNOWN");
break;
case 't':
strcat (pformat, "x");
printf (pformat, major (statbuf->st_rdev));
break;
case 'T':
strcat (pformat, "x");
printf (pformat, minor (statbuf->st_rdev));
break;
case 's':
strcat (pformat, PRIuMAX);
printf (pformat, (uintmax_t) (statbuf->st_size));
break;
case 'b':
strcat (pformat, "u");
printf (pformat, (unsigned int) statbuf->st_blocks);
break;
case 'o':
strcat (pformat, "d");
printf (pformat, (int) statbuf->st_blksize);
break;
case 'x':
print_human_time (&(statbuf->st_atime));
break;
case 'X':
strcat (pformat, "d");
printf (pformat, (int) statbuf->st_atime);
break;
case 'y':
print_human_time (&(statbuf->st_mtime));
break;
case 'Y':
strcat (pformat, "d");
printf (pformat, (int) statbuf->st_mtime);
break;
case 'z':
print_human_time (&(statbuf->st_ctime));
break;
case 'Z':
strcat (pformat, "d");
printf (pformat, (int) statbuf->st_ctime);
break;
default:
strcat (pformat, "c");
printf (pformat, m);
break;
}
}
static void
print_it (char const *masterformat, char const *filename,
void (*print_func) (char *, char, char const *,
void const *, SECURITY_ID_T),
void const *data, SECURITY_ID_T sid)
{
char *m, *b, *format;
char pformat[65];
/* create a working copy of the format string */
format = strdup (masterformat);
if (!format)
{
perror (filename);
return;
}
b = format;
while (b)
{
if ((m = strchr (b, (int) '%')) != NULL)
{
strcpy (pformat, "%");
*m++ = '\0';
fputs (b, stdout);
/* copy all format specifiers to our format string */
while (isdigit (*m) || strchr ("#0-+. I", *m))
{
char copy[2] = "a";
*copy = *m;
/* make sure the format specifier is not too long */
if (strlen (pformat) > 63)
fprintf (stderr,
"Warning: Format specifier too long, truncating: %s\n",
pformat);
else
strcat (pformat, copy);
m++;
}
switch (*m)
{
case '\0':
case '%':
fputs ("%", stdout);
break;
default:
print_func (pformat, *m, filename, data, sid);
break;
}
b = m + 1;
}
else
{
fputs (b, stdout);
b = NULL;
}
}
free (format);
printf ("\n");
}
/* stat the filesystem and print what we find */
static void
do_statfs (char const *filename, int terse, int secure, char const *format)
{
STRUCT_STATVFS statfsbuf;
SECURITY_ID_T sid = -1;
int i;
if (secure)
i = statfs_secure (filename, &statfsbuf, &sid);
else
i = statfs (filename, &statfsbuf);
if (i == -1)
{
perror (filename);
return;
}
if (format == NULL)
{
if (terse)
{
#define DEFAULT_FORMAT_TERSE "%n %i %l %t %b %f %a %s %c %d"
#define DEFAULT_FORMAT_VERBOSE \
" File: \"%n\"\n" \
" ID: %-8i Namelen: %-7l Type: %T\n" \
"Blocks: Total: %-10b Free: %-10f Available: %-10a Size: %s\n" \
"Inodes: Total: %-10c Free: %-10d"
if (secure)
format = DEFAULT_FORMAT_TERSE " %S %C";
else
format = DEFAULT_FORMAT_TERSE;
}
else
{
if (secure)
format = DEFAULT_FORMAT_VERBOSE " SID: %-14S S_Context: %C\n";
else
format = DEFAULT_FORMAT_VERBOSE;
}
}
print_it (format, filename, print_statfs, &statfsbuf, sid);
}
/* stat the file and print what we find */
static void
do_stat (char const *filename, int follow_links, int terse, int secure,
char const *format)
{
struct stat statbuf;
int i;
SECURITY_ID_T sid = -1;
if (secure)
i = ((follow_links == 1)
? stat_secure (filename, &statbuf, &sid)
: lstat_secure (filename, &statbuf, &sid));
else
i = ((follow_links == 1)
? stat (filename, &statbuf) : lstat (filename, &statbuf));
if (i == -1)
{
perror (filename);
return;
}
if (format == NULL)
{
if (terse != 0)
{
if (secure)
format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %S %C";
else
format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o";
}
else
{
/* tmp hack to match orignal output until conditional implemented */
i = statbuf.st_mode & S_IFMT;
if (i == S_IFCHR || i == S_IFBLK)
{
if (secure)
format =
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
" Device type: %t,%T\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
" SID: %-14S S_Context: %C\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n";
else
format =
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
" Device type: %t,%T\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n";
}
else
{
if (secure)
format =
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %-5h\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
" SID: %-14S S_Context: %C\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n";
else
format =
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %-5h\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n";
}
}
}
print_it (format, filename, print_stat, &statbuf, sid);
}
void
usage (int status)
{
if (status != 0)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
{
printf (_("Usage: %s [OPTION] FILE...\n"), program_name);
fputs (_("\
Display file or filesystem status.\n\
\n\
-f, --filesystem display filesystem status instead of file status\n\
-c --format=FORMAT FIXME\n\
-l, --link follow links\n\
-s, --secure FIXME\n\
-t, --terse print the information in terse form\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
fputs (_("\n\
The valid format sequences for files (without --filesystem):\n\
\n\
%A - Access rights in human readable form\n\
%a - Access rights in octal\n\
%b - Number of blocks allocated\n\
%C - Security context in SE-Linux\n\
"), stdout);
fputs (_("\
%D - Device number in hex\n\
%d - Device number in decimal\n\
%F - File type\n\
%f - raw mode in hex\n\
%G - Group name of owner\n\
%g - Group ID of owner\n\
"), stdout);
fputs (_("\
%h - Number of hard links\n\
%i - Inode number\n\
%N - Quoted File name with dereference if symbolic link\n\
%n - File name\n\
%o - IO block size\n\
%S - Security ID in SE-Linux\n\
%s - Total size, in bytes\n\
%T - Minor device type in hex\n\
%t - Major device type in hex\n\
"), stdout);
fputs (_("\
%U - User name of owner\n\
%u - User ID of owner\n\
%X - Time of last access as seconds since Epoch\n\
%x - Time of last access\n\
%Y - Time of last modification as seconds since Epoch\n\
%y - Time of last modification\n\
%Z - Time of last change as seconds since Epoch\n\
%z - Time of last change\n\
\n\
"), stdout);
fputs (_("\
Valid format sequences for file systems:\n\
\n\
%a - Free blocks available to non-superuser\n\
%b - Total data blocks in file system\n\
%C - Security context in SE-Linux\n\
%c - Total file nodes in file system\n\
%d - Free file nodes in file system\n\
%f - Free blocks in file system\n\
"), stdout);
fputs (_("\
%i - File System id in hex\n\
%l - Maximum length of filenames\n\
%n - File name\n\
%S - Security ID in SE-Linux\n\
%s - Optimal transfer block size\n\
%T - Type in human readable form\n\
%t - Type in hex\n\
"), stdout);
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
}
exit (status);
}
int
main (int argc, char *argv[])
{
int c;
int i;
int follow_links = 0;
int fs = 0;
int terse = 0;
int secure = 0;
char *format = NULL;
program_name = argv[0];
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
atexit (close_stdout);
while ((c = getopt_long (argc, argv, "c:flst", long_options, NULL)) != -1)
{
switch (c)
{
case 'c':
format = optarg;
break;
case 'l':
follow_links = 1;
break;
case 'f':
fs = 1;
break;
case 's':
secure = 1;
break;
case 't':
terse = 1;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
usage (EXIT_FAILURE);
}
}
if (argc == optind)
{
error (0, 0, _("too few arguments"));
usage (EXIT_FAILURE);
}
if (!is_flask_enabled ())
secure = 0;
for (i = optind; i < argc; i++)
{
if (fs == 0)
do_stat (argv[i], follow_links, terse, secure, format);
else
do_statfs (argv[i], terse, secure, format);
}
exit (EXIT_SUCCESS);
}

View File

@@ -3,6 +3,10 @@
more time, I'll merge the remaining things in system.h and everything
in this file will go back there. */
#ifndef S_IFMT
# define S_IFMT 0170000
#endif
#if STAT_MACROS_BROKEN
# undef S_ISBLK
# undef S_ISCHR
@@ -10,48 +14,129 @@
# undef S_ISDOOR
# undef S_ISFIFO
# undef S_ISLNK
# undef S_ISNAM
# undef S_ISMPB
# undef S_ISMPC
# undef S_ISNWK
# undef S_ISREG
# undef S_ISSOCK
#endif /* STAT_MACROS_BROKEN. */
#ifndef S_IFMT
# define S_IFMT 0170000
#endif
#if !defined(S_ISBLK) && defined(S_IFBLK)
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#endif
#if !defined(S_ISCHR) && defined(S_IFCHR)
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#endif
#if !defined(S_ISDIR) && defined(S_IFDIR)
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#if !defined(S_ISREG) && defined(S_IFREG)
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#if !defined(S_ISFIFO) && defined(S_IFIFO)
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#endif
#if !defined(S_ISLNK) && defined(S_IFLNK)
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#endif
#if !defined(S_ISSOCK) && defined(S_IFSOCK)
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
#endif
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
#endif
#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
#endif
#if !defined(S_ISDOOR) && defined(S_IFDOOR) /* Solaris 2.5 and up */
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
#endif
#ifndef S_ISBLK
# ifdef S_IFBLK
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
# else
# define S_ISBLK(m) 0
# endif
#endif
#ifndef S_ISCHR
# ifdef S_IFCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
# else
# define S_ISCHR(m) 0
# endif
#endif
#ifndef S_ISDIR
# ifdef S_IFDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
# else
# define S_ISDIR(m) 0
# endif
#endif
#ifndef S_ISDOOR /* Solaris 2.5 and up */
# ifdef S_IFDOOR
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
# else
# define S_ISDOOR(m) 0
# endif
#endif
#ifndef S_ISFIFO
# ifdef S_IFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
# else
# define S_ISFIFO(m) 0
# endif
#endif
#ifndef S_ISLNK
# ifdef S_IFLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# else
# define S_ISLNK(m) 0
# endif
#endif
#ifndef S_ISMPB /* V7 */
# ifdef S_IFMPB
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
# else
# define S_ISMPB(m) 0
# define S_ISMPC(m) 0
# endif
#endif
#ifndef S_ISNAM /* Xenix */
# ifdef S_IFNAM
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
# else
# define S_ISNAM(m) 0
# endif
#endif
#ifndef S_ISNWK /* HP/UX */
# ifdef S_IFNWK
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
# else
# define S_ISNWK(m) 0
# endif
#endif
#ifndef S_ISREG
# ifdef S_IFREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
# else
# define S_ISREG(m) 0
# endif
#endif
#ifndef S_ISSOCK
# ifdef S_IFSOCK
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
# else
# define S_ISSOCK(m) 0
# endif
#endif
#ifndef S_TYPEISSEM
# ifdef S_INSEM
# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
# else
# define S_TYPEISSEM(p) 0
# endif
#endif
#ifndef S_TYPEISSHM
# ifdef S_INSHD
# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
# else
# define S_TYPEISSHM(p) 0
# endif
#endif
#ifndef S_TYPEISMQ
# define S_TYPEISMQ(p) 0
#endif
/* If any of the following are undefined,
define them to their de facto standard values. */
#if !S_ISUID
# define S_ISUID 04000
#endif
@@ -260,27 +345,18 @@ char *alloca ();
#if HAVE_LOCALE_H
# include <locale.h>
#endif
#if !HAVE_SETLOCALE
#else
# define setlocale(Category, Locale) /* empty */
#endif
#if ENABLE_NLS
# include <libintl.h>
# if HAVE_GETTEXT && !HAVE_DCGETTEXT && !defined dcgettext
# define dcgettext(Domain, Text, Category) Text
# endif
# define _(Text) gettext (Text)
#else
# undef bindtextdomain
# define bindtextdomain(Domain, Directory) /* empty */
# undef textdomain
# define textdomain(Domain) /* empty */
# undef dcgettext
# define dcgettext(Domainname, Text, Category) Text
# define _(Text) Text
#include "gettext.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
#ifndef HAVE_SETLOCALE
# define HAVE_SETLOCALE 0
#endif
#define N_(Text) Text
#define STREQ(a, b) (strcmp ((a), (b)) == 0)

View File

@@ -1,5 +1,5 @@
/* system-dependent definitions for fileutils, textutils, and sh-utils packages.
Copyright (C) 1989, 1991-2001 Free Software Foundation, Inc.
Copyright (C) 1989, 1991-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,9 +17,15 @@
/* Include sys/types.h before this file. */
#if 2 <= __GLIBC__ && 2 <= __GLIBC_MINOR__
# if ! defined _SYS_TYPES_H
you must include <sys/types.h> before including this file
# endif
#endif
#include <sys/stat.h>
#if !defined(HAVE_MKFIFO)
#if !defined HAVE_MKFIFO
# define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
#endif
@@ -146,7 +152,7 @@ typedef enum {false = 0, true = 1} bool;
# include <sys/file.h>
#endif
#if !defined (SEEK_SET)
#if !defined SEEK_SET
# define SEEK_SET 0
# define SEEK_CUR 1
# define SEEK_END 2
@@ -238,7 +244,7 @@ typedef enum {false = 0, true = 1} bool;
ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS. */
#ifndef HAVE_STRUCT_STAT_ST_BLOCKS
# define ST_BLKSIZE(statbuf) DEV_BSIZE
# if defined(_POSIX_SOURCE) || !defined(BSIZE) /* fileblocks.c uses BSIZE. */
# if defined _POSIX_SOURCE || !defined BSIZE /* fileblocks.c uses BSIZE. */
# define ST_NBLOCKS(statbuf) \
(S_ISREG ((statbuf).st_mode) \
|| S_ISDIR ((statbuf).st_mode) \
@@ -253,16 +259,16 @@ typedef enum {false = 0, true = 1} bool;
/* Some systems, like Sequents, return st_blksize of 0 on pipes. */
# define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
? (statbuf).st_blksize : DEV_BSIZE)
# if defined(hpux) || defined(__hpux__) || defined(__hpux)
# if defined hpux || defined __hpux__ || defined __hpux
/* HP-UX counts st_blocks in 1024-byte units.
This loses when mixing HP-UX and BSD filesystems with NFS. */
# define ST_NBLOCKSIZE 1024
# else /* !hpux */
# if defined(_AIX) && defined(_I386)
# if defined _AIX && defined _I386
/* AIX PS/2 counts st_blocks in 4K units. */
# define ST_NBLOCKSIZE (4 * 1024)
# else /* not AIX PS/2 */
# if defined(_CRAY)
# if defined _CRAY
# define ST_NBLOCKS(statbuf) \
(S_ISREG ((statbuf).st_mode) \
|| S_ISDIR ((statbuf).st_mode) \

View File

@@ -962,7 +962,8 @@ tail_forever (struct File_spec *f, int nfiles)
if (stats.st_size == f[i].size)
{
f[i].n_consecutive_size_changes = 0;
if (++f[i].n_unchanged_stats > max_n_unchanged_stats_between_opens
if ((max_n_unchanged_stats_between_opens
<= f[i].n_unchanged_stats++)
&& follow_mode == Follow_name)
{
recheck (&f[i]);
@@ -971,14 +972,11 @@ tail_forever (struct File_spec *f, int nfiles)
continue;
}
/* Size changed. */
++f[i].n_consecutive_size_changes;
/* Ensure that a file that's unlinked or moved aside, yet always
growing will be recognized as having been renamed. */
if (follow_mode == Follow_name
&& (f[i].n_consecutive_size_changes
> max_n_consecutive_size_changes_between_opens))
if ((max_n_consecutive_size_changes_between_opens
<= f[i].n_consecutive_size_changes++)
&& follow_mode == Follow_name)
{
f[i].n_consecutive_size_changes = 0;
recheck (&f[i]);
@@ -1360,13 +1358,13 @@ parse_obsolescent_option (int argc, const char *const *argv,
else
{
strtol_error s_err;
unsigned long int tmp_ulong;
uintmax_t tmp;
char *end;
s_err = xstrtoul (n_string, &end, 10, &tmp_ulong,
*n_string_end == 'b' ? "b" : NULL);
if (s_err == LONGINT_OK && tmp_ulong <= OFF_T_MAX)
*n_units = (off_t) tmp_ulong;
s_err = xstrtoumax (n_string, &end, 10, &tmp,
*n_string_end == 'b' ? "b" : NULL);
if (s_err == LONGINT_OK && tmp <= OFF_T_MAX)
*n_units = (off_t) tmp;
else
{
/* Extract a NUL-terminated string for the error message. */

View File

@@ -2,7 +2,7 @@
/* Modified to run with the GNU shell by bfox. */
/* Copyright (C) 1987-2001 Free Software Foundation, Inc.
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -122,12 +122,12 @@ static int term PARAMS ((void));
static int and PARAMS ((void));
static int or PARAMS ((void));
static void test_syntax_error PARAMS ((char *format, char *arg))
static void test_syntax_error PARAMS ((char const *format, char const *arg))
ATTRIBUTE_NORETURN;
static void beyond PARAMS ((void)) ATTRIBUTE_NORETURN;
static void
test_syntax_error (char *format, char *arg)
test_syntax_error (char const *format, char const *arg)
{
fprintf (stderr, "%s: ", argv[0]);
fprintf (stderr, format, arg);
@@ -229,7 +229,7 @@ beyond (void)
/* Syntax error for when an integer argument was expected, but
something else was found. */
static void
integer_expected_error (char *pch)
integer_expected_error (char const *pch)
{
test_syntax_error (_("integer expression expected %s\n"), pch);
}
@@ -293,19 +293,15 @@ isint (register char *string, intmax_t *result)
}
/* Find the modification time of FILE, and stuff it into *AGE.
Return nonzero if successful, else zero. */
Return 0 if successful, -1 if not. */
static int
age_of (char *filename, time_t *age)
{
struct stat finfo;
if (test_stat (filename, &finfo) < 0)
return (0);
if (age)
int r = test_stat (filename, &finfo);
if (r == 0)
*age = finfo.st_mtime;
return (1);
return r;
}
/*
@@ -520,13 +516,13 @@ binary_operator (void)
{
/* nt - newer than */
time_t lt, rt;
int le, re;
pos += 3;
if (l_is_l || r_is_l)
test_syntax_error (_("-nt does not accept -l\n"), NULL);
if (age_of (argv[op - 1], &lt) && age_of (argv[op + 1], &rt))
return (TRUE == (lt > rt));
else
return (FALSE);
le = age_of (argv[op - 1], &lt);
re = age_of (argv[op + 1], &rt);
return le > re || (le == 0 && lt > rt);
}
if (argv[op][2] == 'e' && !argv[op][3])
@@ -594,12 +590,13 @@ binary_operator (void)
{
/* ot - older than */
time_t lt, rt;
int le, re;
pos += 3;
if (l_is_l || r_is_l)
test_syntax_error (_("-ot does not accept -l\n"), NULL);
if (age_of (argv[op - 1], &lt) && age_of (argv[op + 1], &rt))
return (TRUE == (lt < rt));
return (FALSE);
le = age_of (argv[op - 1], &lt);
re = age_of (argv[op + 1], &rt);
return le < re || (re == 0 && lt < rt);
}
break;
}

View File

@@ -163,7 +163,12 @@ touch (const char *file)
if (open_errno)
error (0, open_errno, _("creating %s"), quote (file));
else
error (0, errno, _("failed to get attributes of %s"), quote (file));
{
if (no_create && errno == ENOENT)
return 0;
error (0, errno, _("failed to get attributes of %s"),
quote (file));
}
close (fd);
return 1;
}
@@ -211,7 +216,11 @@ touch (const char *file)
if (open_errno)
error (0, open_errno, _("creating %s"), quote (file));
else
error (0, errno, _("setting times of %s"), quote (file));
{
if (no_create && errno == ENOENT)
return 0;
error (0, errno, _("setting times of %s"), quote (file));
}
return 1;
}

View File

@@ -334,7 +334,9 @@ writing to standard output.\n\
\n\
-c, --complement first complement SET1\n\
-d, --delete delete characters in SET1, do not translate\n\
-s, --squeeze-repeats replace sequence of characters with one\n\
-s, --squeeze-repeats replace each input sequence of a repeated character\n\
that is listed in SET1 with a single occurrence\n\
of that character\n\
-t, --truncate-set1 first truncate SET1 to length of SET2\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);

102
src/unlink.c Normal file
View File

@@ -0,0 +1,102 @@
/* unlink utility for GNU.
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Michael Stone */
/* Implementation overview:
Simply call the system 'unlink' function */
#include <config.h>
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
#include <assert.h>
#include "system.h"
#include "error.h"
#include "long-options.h"
#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "unlink"
#define AUTHORS "Michael Stone"
/* Name this program was run with. */
char *program_name;
void
usage (int status)
{
if (status != 0)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
{
printf (_("\
Usage: %s FILE\n\
or: %s OPTION\n"), program_name, program_name);
fputs (_("Call the unlink function to remove the specified FILE.\n\n"),
stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
}
exit (status);
}
int
main (int argc, char **argv)
{
program_name = argv[0];
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
atexit (close_stdout);
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
if (getenv ("POSIXLY_CORRECT") == NULL)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
AUTHORS, usage);
/* The above handles --help and --version.
Since there is no other invocation of getopt, handle `--' here. */
if (1 < argc && STREQ (argv[1], "--"))
{
--argc;
++argv;
}
if (argc < 2)
{
error (0, 0, _("too few arguments"));
usage (1);
}
if (2 < argc)
{
error (0, 0, _("too many arguments"));
usage (1);
}
if (unlink (argv[1]) != 0)
error (EXIT_FAILURE, errno, _("cannot unlink %s"), quote (argv[1]));
exit (0);
}

View File

@@ -1,5 +1,5 @@
/* GNU's uptime.
Copyright (C) 1992-2001 Free Software Foundation, Inc.
Copyright (C) 1992-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -122,9 +122,9 @@ print_uptime (int n, const STRUCT_UTMP *this)
the german translation is meaningless. */
tmn->tm_min, (tmn->tm_hour < 12 ? _("am") : _("pm")));
if (updays > 0)
printf ("%d %s,", updays, (updays == 1 ? _("day") : _("days")));
printf (" %2d:%02d, %d %s", uphours, upmins, entries,
(entries == 1) ? _("user") : _("users"));
printf (ngettext("%d day", "%d days", updays), updays);
printf (" %2d:%02d, ", uphours, upmins);
printf (ngettext ("%d user", "%d users", entries), entries);
#if defined (HAVE_GETLOADAVG) || defined (C_GETLOADAVG)
loads = getloadavg (avg, 3);

View File

@@ -1,5 +1,5 @@
/* wc - print the number of bytes, words, and lines in files
Copyright (C) 85, 91, 1995-2001 Free Software Foundation, Inc.
Copyright (C) 85, 91, 1995-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -130,7 +130,7 @@ Usage: %s [OPTION]... [FILE]...\n\
"),
program_name);
fputs (_("\
Print newline, word, and byte counts for each FILE, and a total line if\n\
Print byte, word, and newline counts for each FILE, and a total line if\n\
more than one FILE is specified. With no FILE, or when FILE is -,\n\
read standard input.\n\
-c, --bytes print the byte counts\n\

140
src/who.c
View File

@@ -1,5 +1,5 @@
/* GNU's who.
Copyright (C) 1992-2001 Free Software Foundation, Inc.
Copyright (C) 1992-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -31,8 +31,8 @@
#include <sys/types.h>
#include "system.h"
#include "error.h"
#include "readutmp.h"
#include "error.h"
#include "closeout.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -68,12 +68,57 @@
# define DEAD_PROCESS INT_MAX
#endif
#ifndef BOOT_TIME
# define BOOT_TIME 0
#endif
#ifndef NEW_TIME
# define NEW_TIME INT_MAX
# define NEW_TIME 0
#endif
#define IDLESTR_LEN 6
#if HAVE_STRUCT_XTMP_UT_PID
# define UT_PID(U) ((U)->ut_pid)
# define PIDSTR_DECL_AND_INIT(Var, Utmp_ent) \
char Var[INT_STRLEN_BOUND (Utmp_ent->ut_pid) + 1]; \
sprintf (Var, "%d", (int) (Utmp_ent->ut_pid))
#else
# define UT_PID(U) 0
# define PIDSTR_DECL_AND_INIT(Var, Utmp_ent) \
const char *Var = ""
#endif
#if HAVE_STRUCT_XTMP_UT_ID
# define UT_ID(U) ((U)->ut_id)
#else
/* Of course, sizeof "whatever" is the size of a pointer (often 4),
but that's ok, since the actual string has a length of only 2. */
# define UT_ID(U) "??"
#endif
#if HAVE_STRUCT_XTMP_UT_EXIT
# define UT_EXIT_E_TERMINATION(U) ((U)->ut_exit.e_termination)
# define UT_EXIT_E_EXIT(U) ((U)->ut_exit.e_exit)
#else
# define UT_EXIT_E_TERMINATION(U) 0
# define UT_EXIT_E_EXIT(U) 0
#endif
#define UT_TYPE_UNDEF 255
#if HAVE_STRUCT_XTMP_UT_TYPE
# define UT_TYPE(U) ((U)->ut_type)
#else
# define UT_TYPE(U) UT_TYPE_UNDEF
#endif
#define IS_USER_PROCESS(U) \
(UT_USER (utmp_buf)[0] \
&& (UT_TYPE (utmp_buf) == USER_PROCESS \
|| (UT_TYPE (utmp_buf) == UT_TYPE_UNDEF \
&& UT_TIME_MEMBER (utmp_buf) != 0)))
int gethostname ();
char *ttyname ();
char *canon_host ();
@@ -212,7 +257,7 @@ print_line (const char *user, const char state, const char *line,
const char *time_str, const char *idle, const char *pid,
const char *comment, const char *exitstr)
{
printf ("%-8s", user ? user : " .");
printf ("%-8.8s", user ? user : " .");
if (include_mesg)
printf (" %c", state);
printf (" %-12s", line);
@@ -230,15 +275,6 @@ print_line (const char *user, const char state, const char *line,
putchar ('\n');
}
#if HAVE_STRUCT_XTMP_UT_PID
# define PIDSTR_DECL_AND_INIT(Var) \
char Var[INT_STRLEN_BOUND (utmp_ent->ut_pid) + 1]; \
sprintf (Var, "%d", utmp_ent->ut_pid)
#else
# define PIDSTR_DECL_AND_INIT(Var) \
const char *Var = ""
#endif
/* Send properly parsed USER_PROCESS info to print_line */
static void
print_user (const STRUCT_UTMP *utmp_ent)
@@ -254,7 +290,7 @@ print_user (const STRUCT_UTMP *utmp_ent)
#define DEV_DIR_LEN (sizeof (DEV_DIR_WITH_TRAILING_SLASH) - 1)
char line[sizeof (utmp_ent->ut_line) + DEV_DIR_LEN + 1];
PIDSTR_DECL_AND_INIT (pidstr);
PIDSTR_DECL_AND_INIT (pidstr, utmp_ent);
/* Copy ut_line into LINE, prepending `/dev/' if ut_line is not
already an absolute pathname. Some system may put the full,
@@ -353,63 +389,63 @@ print_boottime (const STRUCT_UTMP *utmp_ent)
print_line ("", ' ', "system boot", time_string (utmp_ent), "", "", "", "");
}
static char *
make_id_equals_comment (STRUCT_UTMP const *utmp_ent)
{
char *comment = xmalloc (sizeof (_("id=")) + sizeof UT_ID (utmp_ent) + 1);
/* Cast field width argument to `int' to avoid warning from gcc. */
sprintf (comment, "%s%.*s", _("id="), (int) sizeof UT_ID (utmp_ent),
UT_ID (utmp_ent));
return comment;
}
static void
print_deadprocs (const STRUCT_UTMP *utmp_ent)
{
static char *comment, *exitstr;
PIDSTR_DECL_AND_INIT (pidstr);
if (!comment)
comment =
(char *) malloc (sizeof (_("id=")) + sizeof (utmp_ent->ut_id) + 1);
sprintf (comment, "%s%.*s", _("id="), sizeof utmp_ent->ut_id,
utmp_ent->ut_id);
static char *exitstr;
char *comment = make_id_equals_comment (utmp_ent);
PIDSTR_DECL_AND_INIT (pidstr, utmp_ent);
/* FIXME: ut_exit works with GNU/Linux but is probably not portable. */
if (!exitstr)
exitstr = (char *) malloc (sizeof (_("term="))
+ INT_STRLEN_BOUND (utmp_ent->ut_exit.e_termination) + 1
+ sizeof (_("exit="))
+ INT_STRLEN_BOUND (utmp_ent->ut_exit.e_exit)
+ 1);
sprintf (exitstr, "%s%d %s%d", _("term="), utmp_ent->ut_exit.e_termination,
_("exit="), utmp_ent->ut_exit.e_exit);
exitstr = xmalloc (sizeof (_("term="))
+ INT_STRLEN_BOUND (UT_EXIT_E_TERMINATION (utmp_ent)) + 1
+ sizeof (_("exit="))
+ INT_STRLEN_BOUND (UT_EXIT_E_EXIT (utmp_ent))
+ 1);
sprintf (exitstr, "%s%d %s%d", _("term="), UT_EXIT_E_TERMINATION (utmp_ent),
_("exit="), UT_EXIT_E_EXIT (utmp_ent));
/* FIXME: add idle time? */
print_line ("", ' ', utmp_ent->ut_line,
time_string (utmp_ent), "", pidstr, comment, exitstr);
free (comment);
}
static void
print_login (const STRUCT_UTMP *utmp_ent)
{
static char *comment;
PIDSTR_DECL_AND_INIT (pidstr);
if (!comment)
comment =
(char *) malloc (sizeof (_("id=")) + sizeof (utmp_ent->ut_id) + 1);
sprintf (comment, "%s%s", _("id="), utmp_ent->ut_id);
char *comment = make_id_equals_comment (utmp_ent);
PIDSTR_DECL_AND_INIT (pidstr, utmp_ent);
/* FIXME: add idle time? */
print_line ("LOGIN", ' ', utmp_ent->ut_line,
time_string (utmp_ent), "", pidstr, comment, "");
free (comment);
}
static void
print_initspawn (const STRUCT_UTMP *utmp_ent)
{
static char *comment;
PIDSTR_DECL_AND_INIT (pidstr);
if (!comment)
comment =
(char *) malloc (sizeof (_("id=")) + sizeof (utmp_ent->ut_id) + 1);
sprintf (comment, "%s%s", _("id="), utmp_ent->ut_id);
char *comment = make_id_equals_comment (utmp_ent);
PIDSTR_DECL_AND_INIT (pidstr, utmp_ent);
print_line ("", ' ', utmp_ent->ut_line,
time_string (utmp_ent), "", pidstr, comment, "");
free (comment);
}
static void
@@ -424,20 +460,15 @@ static void
print_runlevel (const STRUCT_UTMP *utmp_ent)
{
static char *runlevline, *comment;
/* FIXME: The following is correct for linux, may need help
on other platforms */
#if 1 || HAVE_STRUCT_XTMP_UT_PID
int last = utmp_ent->ut_pid / 256;
int curr = utmp_ent->ut_pid % 256;
#endif
int last = UT_PID (utmp_ent) / 256;
int curr = UT_PID (utmp_ent) % 256;
if (!runlevline)
runlevline = (char *) malloc (sizeof (_("run-level")) + 3);
runlevline = xmalloc (sizeof (_("run-level")) + 3);
sprintf (runlevline, "%s %c", _("run-level"), curr);
if (!comment)
comment = (char *) malloc (sizeof (_("last=")) + 2);
comment = xmalloc (sizeof (_("last=")) + 2);
sprintf (comment, "%s%c", _("last="), (last == 'N') ? 'S' : last);
print_line ("", ' ', runlevline, time_string (utmp_ent),
@@ -501,8 +532,7 @@ scan_entries (int n, const STRUCT_UTMP *utmp_buf)
strncmp (ttyname_b, utmp_buf->ut_line,
sizeof (utmp_buf->ut_line)) == 0)
{
if (need_users && UT_USER (utmp_buf)[0]
&& UT_TYPE (utmp_buf) == USER_PROCESS)
if (need_users && IS_USER_PROCESS (utmp_buf))
print_user (utmp_buf);
else if (need_runlevel && UT_TYPE (utmp_buf) == RUN_LVL)
print_runlevel (utmp_buf);
@@ -578,7 +608,7 @@ usage (int status)
"), stdout);
fputs (_("\
-T, -w, --mesg add user's message status as +, - or ?\n\
-u, --users lists users logged in\n\
-u, --users list users logged in\n\
--message same as -T\n\
--writable same as -T\n\
"), stdout);

View File

@@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.5d from Makefile.am.
# Makefile.in generated by automake 1.6.1 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
@@ -48,6 +48,7 @@ INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
@@ -216,8 +217,10 @@ distdir: $(DISTFILES)
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir)$$dir \
|| exit 1; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \

View File

@@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.6 from Makefile.am.
# Makefile.in generated by automake 1.6.2 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
@@ -49,6 +49,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
@@ -203,7 +204,7 @@ top_distdir = ../..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
@list='$(DISTFILES)'; for file in $$list; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
@@ -213,8 +214,10 @@ distdir: $(DISTFILES)
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir)$$dir \
|| exit 1; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
@@ -247,7 +250,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"

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