Compare commits

...

1996 Commits

Author SHA1 Message Date
Jim Meyering
44b11d6e67 (usage): Fix parentheses. 1996-07-10 03:56:45 +00:00
Jim Meyering
108f50670d . 1996-07-10 03:45:03 +00:00
Jim Meyering
5885cbf0d2 (UID_T_MAX): Use `(unsigned long)1' rather than
`(uid_t)1' to avoid problems on systems where uid_t is signed.
(GID_T_MAX): Likewise for gid_t.
From Kjetil Torgrim Homme <kjetilho@ifi.uio.no>.
1996-07-10 03:33:01 +00:00
Jim Meyering
640cdd2df4 . 1996-07-10 03:32:41 +00:00
Jim Meyering
a4d13e4b8f (long_options): Add print-data-base and print-database.
(usage): Rearrange option descriptions.
1996-07-10 03:26:18 +00:00
Jim Meyering
12beb90e58 . 1996-07-10 03:18:55 +00:00
Jim Meyering
4623f5dca3 (usage): Add a one-line description to --help message.
From Karl Berry.
1996-07-10 03:18:31 +00:00
Jim Meyering
b124be4eb1 Change C-shell to `C shell'. 1996-07-10 03:16:30 +00:00
Jim Meyering
c8feafc2a5 . 1996-07-10 03:15:51 +00:00
Jim Meyering
84b6d13a3c (dc_parse_stream): Don't give `unrecognized keyword'
message unless we've processed a matching TERM directive.
1996-07-10 03:15:39 +00:00
Jim Meyering
fb604ebdf4 . 1996-07-10 03:09:05 +00:00
Jim Meyering
778dd49f55 . 1996-07-10 03:06:54 +00:00
Jim Meyering
3e0fdc1a0b (MAXCOST): Use (unsigned long)1' rather than (COST)1'
so the left operand of the << isn't signed.
From Kjetil Torgrim Homme.
1996-07-10 03:02:54 +00:00
Jim Meyering
c4610f8bb6 . 1996-07-09 23:23:49 +00:00
Jim Meyering
824081f660 (install-data): Don't install NLS files when they're not requested.
From Ulrich Drepper.  Reported by Kjetil Torgrim Homme <kjetilho@ifi.uio.no>.
1996-07-09 23:23:33 +00:00
Jim Meyering
417bda1b99 . 1996-07-08 04:26:31 +00:00
Jim Meyering
dbb6fa88fd . 1996-07-08 04:26:09 +00:00
Jim Meyering
013f2fe433 Make initial colors for `color_indicator' match those
currently in dircolors.hin.
1996-07-08 04:25:49 +00:00
Jim Meyering
de75384c2b . 1996-07-08 04:23:38 +00:00
Jim Meyering
9d691ba42f Include termios.h.
Guard inclusion of sys/ioctl.h with #ifdef GWINSZ_IN_SYS_IOCTL,
rather than HAVE_SYS_IOCTL_H.  Modelled after sh-utils' stty.c
at suggestion from Chip Bennett <BennettC@j64.stratcom.af.mil>.
1996-07-08 04:19:36 +00:00
Jim Meyering
744ef2d96f Recognize more filename extensions. From Joshua Cowan. 1996-07-08 03:58:36 +00:00
Jim Meyering
0d978396d7 . 1996-07-08 03:55:55 +00:00
Jim Meyering
581db2ffeb . 1996-07-08 03:41:37 +00:00
Jim Meyering
0d1de84756 . 1996-07-07 20:20:44 +00:00
Jim Meyering
c4f9b63aea . 1996-07-06 22:53:29 +00:00
Jim Meyering
0472107417 (usage): Factor out backup-related text into separate string/printf statement. 1996-07-06 22:50:57 +00:00
Jim Meyering
e1de1d3a93 (usage): Factor out backup-related text into separate string/printf statement. 1996-07-06 22:50:36 +00:00
Jim Meyering
46b486ab5b . 1996-07-06 22:29:57 +00:00
Jim Meyering
68bd38e8a0 . 1996-07-06 21:55:23 +00:00
Jim Meyering
b5c86e8130 (su_SOURCES): Remove group-member.c.
(EXTRA_DIST): Add group-member.c here.
1996-07-06 17:50:16 +00:00
Jim Meyering
bd54740062 . 1996-07-06 17:49:27 +00:00
Jim Meyering
8596e37d97 . 1996-07-06 12:04:47 +00:00
Jim Meyering
5eb689ade0 Fix typo: top-srcdir -> top_srcdir. 1996-07-06 04:05:15 +00:00
Jim Meyering
195f8a213e [!STDC_HEADERS]: Declare free. From Marcus Daniels. 1996-07-06 03:17:09 +00:00
Jim Meyering
4d6b56a932 . 1996-07-06 03:02:44 +00:00
Jim Meyering
62a9c01c6d . 1996-07-06 03:00:44 +00:00
Jim Meyering
12dd329a29 Merge from gettext-0.10.23. 1996-07-06 02:59:12 +00:00
Jim Meyering
4a7000742c ($(PACKAGE).pot): Merge from gettext-0.10.23. 1996-07-06 02:58:59 +00:00
Jim Meyering
f41e1ff806 . 1996-07-05 03:58:06 +00:00
Jim Meyering
fa5ef15197 . 1996-07-05 03:40:39 +00:00
Jim Meyering
2b1f600cbd (usage): Remove space before newline in usage message. 1996-07-05 03:40:21 +00:00
Jim Meyering
0396e35b5a . 1996-07-05 03:39:21 +00:00
Jim Meyering
9824efff73 (usage): Remove space before newline in usage message. 1996-07-05 03:39:12 +00:00
Jim Meyering
7fbe57368e (usage): Remove space before newline in usage message. 1996-07-05 02:49:48 +00:00
Jim Meyering
21c0d8f1f0 (usage): Remove space before newline in usage message. 1996-07-05 02:29:10 +00:00
Jim Meyering
316490baea (usage): Remove space before newline in usage message. 1996-07-05 02:28:29 +00:00
Jim Meyering
bd77322580 . 1996-07-04 22:52:25 +00:00
Jim Meyering
09cf102456 . 1996-07-04 22:52:01 +00:00
Jim Meyering
f8514af7a6 (split_3): Add missing semicolon. From Jim Blandy. 1996-07-04 22:51:52 +00:00
Jim Meyering
6b4aadc588 . 1996-07-04 18:18:03 +00:00
Jim Meyering
e2e512d2d6 . 1996-07-04 18:14:46 +00:00
Jim Meyering
a7d29c59fa (main): Fix typo in last change. 1996-07-04 17:41:05 +00:00
Jim Meyering
b2e339dc25 . 1996-07-04 17:35:51 +00:00
Jim Meyering
e7342330e5 Make dir --version' and vdir --version' print their names, not `ls'.
Reported by Ulrich Drepper.
1996-07-04 17:35:47 +00:00
Jim Meyering
3f868304cf . 1996-07-04 14:53:28 +00:00
Jim Meyering
2926167cfa (md5_file): Replace obsolete comment with a description
of the function.
(md5_check): Don't use "s"-adding trick to form the plural of
`checksum.'  That doesn't work well with translation.
Suggestions from Ulrich Drepper.
1996-07-04 14:53:25 +00:00
Jim Meyering
84448306a4 . 1996-07-04 12:41:58 +00:00
Jim Meyering
b97436b18b (MIN_DIGEST_LINE_LENGTH): New macro.
[NEWLINE_REPLACEMENT_STRING*]: Remove macros.
(main): Output a leading backslash for a line describing a file
whose name contains a newline.  Then translate each NEWLINE byte
in the file name to the string, "\\n", and each backslash to "\\\\".
File names that don't contain NEWLINE aren't translated.
(split_3): Rewrite to handle file names with embedded newlines.
Miles Bader and Jim Blandy suggested this new encoding scheme.
1996-07-04 12:41:53 +00:00
Jim Meyering
db07df5448 . 1996-07-04 12:36:18 +00:00
Jim Meyering
4adeb81260 (split_3): Correct test for 35-byte line to accomodate
fact that leading blanks may be stripped.
1996-07-04 04:22:25 +00:00
Jim Meyering
9684207d04 . 1996-07-03 23:00:45 +00:00
Jim Meyering
b467d6d513 Include sys/types.h before system.h.
From Jim Blandy (jimb@cyclic.com).
1996-07-03 22:59:18 +00:00
Jim Meyering
36454232a5 . 1996-07-03 22:42:58 +00:00
Jim Meyering
ce85352146 [!MAXUID]: Define after inclusion of system.h to avoid
warning about redefinition on SunOS4, Solaris2.4 and SGI-irix5.3.
From Kaveh Ghazi.
1996-07-03 22:42:41 +00:00
Jim Meyering
7786c6e2cf . 1996-07-03 04:18:38 +00:00
Jim Meyering
4bd1ffa49a . 1996-07-03 04:05:07 +00:00
Jim Meyering
38762b8f78 (usage): Add omitted \n\ at the end of a line in the usage message. 1996-07-03 04:04:06 +00:00
Jim Meyering
7b2cea5ab2 [!EXIT_SUCCESS]: Define it.
[!EXIT_FAILURE]: Define it.
1996-07-03 04:00:36 +00:00
Jim Meyering
b0d3bfa316 . 1996-07-03 04:00:29 +00:00
Jim Meyering
1672bf6d27 (strndup): Include stdio.h and sys/types.h to
get definition of NULL and size_t on SunOS4.1.3.
1996-07-03 03:59:02 +00:00
Jim Meyering
8736952b0b . 1996-07-03 02:52:20 +00:00
Jim Meyering
bd1fc1c256 . 1996-07-02 04:55:06 +00:00
Jim Meyering
bb4d193ac7 [NEWLINE_REPLACEMENT_STRING]: Define.
(split_3): Translate NL bytes not to NUL, but to
NEWLINE_REPLACEMENT_STRING.
Suggested by Ulrich Drepper.
(main): Translate back to NL-containing filename.
1996-07-02 04:54:51 +00:00
Jim Meyering
7379bd7274 . 1996-07-02 04:48:57 +00:00
Jim Meyering
1372968ab0 (do_link): Update messages to ease translation.
Suggestion from Santiago Vila.
1996-07-02 04:48:32 +00:00
Jim Meyering
d2b4bca42e (main): Remove now-unnecessary diagnostic about filename containing NEWLINE. 1996-07-01 03:48:10 +00:00
Jim Meyering
6dceaa1d9d (split_3): Take an additional parameter, S_LEN.
Adapt caller.
Map translated NEWLINE-containing filename back into the original
NEWLINE-containing name.
(md5_check): Translate NEWLINE bytes to NUL bytes in filename.
1996-07-01 03:47:16 +00:00
Jim Meyering
b288652bbd . 1996-06-30 21:42:53 +00:00
Jim Meyering
2b37242292 (usage): Fix typo, 3nd->3rd, in usage message.
From Santiago Vila <sanvila@unex.es>.
1996-06-30 21:42:49 +00:00
Jim Meyering
afd2d8e4cf . 1996-06-30 14:30:00 +00:00
Jim Meyering
c18996947c . 1996-06-30 14:29:29 +00:00
Jim Meyering
23b80c8e30 . 1996-06-30 04:24:26 +00:00
Jim Meyering
3b92bd0090 . 1996-06-30 00:01:20 +00:00
Jim Meyering
14bc2891a8 . 1996-06-29 23:59:14 +00:00
Jim Meyering
1ebe204c2f . 1996-06-29 23:58:48 +00:00
Jim Meyering
27725d0745 . 1996-06-29 16:45:17 +00:00
Jim Meyering
8977920253 . 1996-06-29 05:33:00 +00:00
Jim Meyering
41b9ee8834 . 1996-06-29 05:29:08 +00:00
Jim Meyering
c4d50b0133 . 1996-06-29 05:28:48 +00:00
Jim Meyering
bb389bead8 Remove u from Colour. 1996-06-29 05:28:32 +00:00
Jim Meyering
326cc336af . 1996-06-29 04:12:05 +00:00
Jim Meyering
cd53ea93c5 (dc_parse_stream): Move enum states dcl into this function.
(dc_parse_stream): Remove parameter RESULT.
Adapt callers.
1996-06-29 04:11:43 +00:00
Jim Meyering
aec69ce220 . 1996-06-29 04:08:10 +00:00
Jim Meyering
b2d08f91db . 1996-06-29 04:07:18 +00:00
Jim Meyering
50cdbb37c8 . 1996-06-29 03:58:52 +00:00
Jim Meyering
e81d02baf1 (do_link): Allow `ln -sf --backup k k' to succeed in creating the
self-referential symlink, doing so doesn't remove the source but merely
renames it.
1996-06-29 03:58:48 +00:00
Jim Meyering
b73817cc6e . 1996-06-28 04:15:56 +00:00
Jim Meyering
0fefdeb526 . 1996-06-28 03:04:11 +00:00
Jim Meyering
8dfac9573a . 1996-06-27 04:27:10 +00:00
Jim Meyering
369361ae70 . 1996-06-27 02:37:51 +00:00
Jim Meyering
1afd3473fb (install-data): Add `else true;' to avoid
letting failing if-condition cause make to fail.
From Fred Fish (fnf@ninemoons.com).
1996-06-27 02:37:40 +00:00
Jim Meyering
117fb47f99 Elaborate on how sort -n works. 1996-06-27 02:34:30 +00:00
Jim Meyering
1bff89846b . 1996-06-26 12:39:19 +00:00
Jim Meyering
ba87d08c0e (do_link): Remove `!symlink &&' conjunct. 1996-06-26 12:31:13 +00:00
Jim Meyering
d9c0413f79 (same_name): Declare parameters to be const. 1996-06-26 12:05:35 +00:00
Jim Meyering
216777ea17 (same_name): New function.
(do_link): Use it to test reliably whether A and B (from
ln --force A B) are hard links to the same file.
From Andreas Schwab.
1996-06-26 12:02:02 +00:00
Jim Meyering
325411e109 . 1996-06-26 02:57:01 +00:00
Jim Meyering
e5aecd47c4 . 1996-06-25 05:16:30 +00:00
Jim Meyering
c84a7a232e . 1996-06-25 05:09:55 +00:00
Jim Meyering
16c5d19ce5 (strndup): Deansify.
[!STDC_HEADERS]: Include string.h and stdlib.h.
1996-06-25 05:06:53 +00:00
Jim Meyering
ac96f15bf3 (EXTRA_DIST): Add strndup.c.
(fu_SOURCES): Add getline.c.
(noinst_HEADERS): Add getline.h.
1996-06-25 05:05:43 +00:00
Jim Meyering
0c0537fdce . 1996-06-25 04:58:18 +00:00
Jim Meyering
f58702e8f9 (decode_switches): Allow 0 as argument to --tabsize (-T) option.
Interpret as a directive to use no TAB characters to separate columns.
(indent): Handle TABSIZE == 0.
1996-06-25 04:56:22 +00:00
Jim Meyering
80c03e37ba . 1996-06-25 04:26:12 +00:00
Jim Meyering
71e65bb036 (dc_parse_stream): Give `unrecognized keyword' for misspelled
`TERM' keyword as well as for others.
1996-06-25 04:26:01 +00:00
Jim Meyering
522141076e . 1996-06-25 03:41:41 +00:00
Jim Meyering
408a47499e (dc_parse_stream): Remove spurious newline in error message.
(dc_parse_file): Remove erroneous test of ERR.
1996-06-25 03:41:29 +00:00
Jim Meyering
30a65b1aa3 Use an obstack to accumulate value of LS_COLORS. 1996-06-24 03:06:52 +00:00
Jim Meyering
0a3fdd250a . 1996-06-24 03:01:46 +00:00
Jim Meyering
b617aa5f3f Add comma after e.g. in comment.
From Karl B.
1996-06-23 19:15:15 +00:00
Jim Meyering
8b0cf1dde4 . 1996-06-23 19:03:56 +00:00
Jim Meyering
d392de74de * (parse_line): Rewrite to avoid modifying LINE.
Put LINE first in parameter list.
Adjust caller.
(dc_parse_stream): Free KEYWD and ARG.
(main): Give diagnostic for unreasonable combinations of
options/arguments.
1996-06-23 19:03:31 +00:00
Jim Meyering
e5b4feb70a copied from id-utils-3.0k 1996-06-23 17:58:15 +00:00
Jim Meyering
af41baeb91 (main): New option --print (-p).
Detect write failure.
Add --bourne-shell and --c-shell aliases for --sh and --csh resp.
1996-06-22 22:27:32 +00:00
Jim Meyering
5540d977f4 . 1996-06-22 22:27:14 +00:00
Jim Meyering
98b663a29b Major overhaul. No longer read from /etc/DIR_COLORS or from ~/.dircolors.
Defaults are now compiled in.  If you specify a file on the command line,
it is used instead of the compiled-in defaults.
1996-06-22 22:02:37 +00:00
Jim Meyering
e3c3d0b385 (parse_ls_color): Use STREQ here instead of strcmp(...) == 0. 1996-06-19 04:22:28 +00:00
Jim Meyering
cfda609a21 (selected_fstype, excluded_fstype, show_disk, main):
Use STREQ here instead of strcmp(...) == 0.
1996-06-19 04:21:49 +00:00
Jim Meyering
229598b807 . 1996-06-19 04:17:36 +00:00
Jim Meyering
4c6221ee37 . 1996-06-19 04:14:29 +00:00
Jim Meyering
d76f7a7ce4 . 1996-06-19 04:11:32 +00:00
Jim Meyering
fc05e28803 (copy_reg): Cast both sides of comparison to size_t to avoid warning
about `comparison between signed and unsigned' from gcc -Wall.
1996-06-19 04:10:17 +00:00
Jim Meyering
0bbec4b26e . 1996-06-19 03:39:00 +00:00
Jim Meyering
93cff2fae1 . 1996-06-19 03:32:08 +00:00
Jim Meyering
ec0f2c34d3 (decode_switches): Correct typo in error message:
enironment -> environment.  From Santiago Vila Doncel
<sanvila@unex.es>.
1996-06-19 03:31:59 +00:00
Jim Meyering
e26d180b8c (decode_switches): Correct typo in error message: enironment -> environment.
From Santiago Vila Doncel <sanvila@unex.es>.
1996-06-19 03:25:44 +00:00
Jim Meyering
cb0cd6afdb . 1996-06-19 03:21:05 +00:00
Jim Meyering
b95e3d2f47 (do_copy): Use STREQ here instead of strcmp(...) == 0.
Declare pointer parameters const as appropriate.
1996-06-19 03:19:51 +00:00
Jim Meyering
b5eadff384 . 1996-06-19 03:15:58 +00:00
Jim Meyering
a0321a68c0 (do_copy): Change message from `missing file argument' to
more precise `missing destination file'.  From Karl Berry.
1996-06-19 02:56:06 +00:00
Jim Meyering
9ed0e96ba7 . 1996-06-19 02:53:14 +00:00
Jim Meyering
087f809fe7 . 1996-06-19 02:52:02 +00:00
Jim Meyering
dd6c617d24 . 1996-06-19 02:51:09 +00:00
Jim Meyering
b4e8fc709e (STREQ): New macro. 1996-06-19 02:00:24 +00:00
Jim Meyering
487366d091 . 1996-06-19 02:00:16 +00:00
Jim Meyering
6099222717 (do_copy): When the force and backup options have been
specified and the source and destination are the same name for an
existing, regular file, convert the user's command, e.g.
`cp --force --backup foo foo' to `cp --force foo fooSUFFIX'
where SUFFIX is determined by any version control options used.
At urging of (most recently) Karl Berry.
1996-06-19 01:59:12 +00:00
Jim Meyering
608e780536 . 1996-06-19 01:48:25 +00:00
Jim Meyering
0f73666749 . 1996-06-19 01:41:35 +00:00
Jim Meyering
e72e877181 . 1996-06-16 18:52:46 +00:00
Jim Meyering
4063f0aea3 . 1996-06-16 18:49:50 +00:00
Jim Meyering
0c8d33de03 . 1996-06-16 18:49:08 +00:00
Jim Meyering
e94070eb22 . 1996-06-16 18:48:30 +00:00
Jim Meyering
8aef0cde12 . 1996-06-16 18:47:38 +00:00
Jim Meyering
d355dcec62 (EXTRA_DIST): Add texinfo.tex. But it will
be removed once automake is fixed to add it automatically.
1996-06-16 18:47:30 +00:00
Jim Meyering
c0a9e11235 . 1996-06-16 18:41:48 +00:00
Jim Meyering
8469bec1cc . 1996-06-16 03:23:53 +00:00
Jim Meyering
28a71c3409 . 1996-06-16 03:23:06 +00:00
Jim Meyering
85c407a740 (EXTRA_DIST): Add basename.c.
(fu_SOURCES): Remove basename.c.
1996-06-16 03:21:47 +00:00
Jim Meyering
2a01f209a6 . 1996-06-16 03:18:07 +00:00
Jim Meyering
1137a26bcf Update from time-1.7. 1996-06-14 04:42:33 +00:00
Jim Meyering
8157b18b8a . 1996-06-14 03:52:05 +00:00
Jim Meyering
c8c25a4610 ($(PACKAGE).pot): Reapply change of May 30.
Depend on POTFILES only when using maintainer mode.
1996-06-14 03:51:57 +00:00
Jim Meyering
031e782bb9 . 1996-06-14 03:33:18 +00:00
Jim Meyering
289ee58ce3 . 1996-06-12 04:32:54 +00:00
Jim Meyering
53af79cfe4 . 1996-06-12 04:30:58 +00:00
Jim Meyering
57beda9b45 . 1996-06-11 17:26:10 +00:00
Jim Meyering
0f3ff1725d . 1996-06-11 00:13:09 +00:00
Jim Meyering
7188179fc0 . 1996-06-11 00:12:53 +00:00
Jim Meyering
6544a589ed . 1996-06-11 00:12:08 +00:00
Jim Meyering
79ae2a4af9 . 1996-06-10 23:23:53 +00:00
Jim Meyering
b952290dc3 . 1996-06-10 23:20:06 +00:00
Jim Meyering
737f1f03a5 . 1996-06-08 04:29:59 +00:00
Jim Meyering
cf83dc5456 . 1996-06-08 03:16:21 +00:00
Jim Meyering
652ad8aaa3 . 1996-06-07 05:14:55 +00:00
Jim Meyering
5e969c1033 . 1996-06-07 03:16:35 +00:00
Jim Meyering
e42cc5be8a Update from gettext-0.10.16. 1996-06-07 02:59:01 +00:00
Jim Meyering
8cb05a6bfa . 1996-06-06 03:54:38 +00:00
Jim Meyering
4fb75ded4c . 1996-06-02 04:49:35 +00:00
Jim Meyering
1c883e2882 Rename MO_ to SHELLTYPE_. 1996-06-02 02:58:05 +00:00
Jim Meyering
d6bf80ccc7 Declare pointer parameters const as appropriate. 1996-06-02 02:52:37 +00:00
Jim Meyering
cd536776a0 . 1996-06-01 23:08:53 +00:00
Jim Meyering
f51eb4a5cc (decode_switches): Set print_with_color in one statement. 1996-06-01 23:08:35 +00:00
Jim Meyering
de40301f0a Rename options and internal variables to reflect change to
--color=WHEN where WHEN is never, always, or auto (for consistency
with e.g. cp --sparse=WHEN.  For at least a while, the original
slackware-supported arguments `none', `force', `yes', etc will be
supported but deprecated by lack of documentation.
(decode_switches): Use STDOUT_FILENO instead of `1' in is_tty test.
(usage): Update/add description of the --color option.
1996-06-01 18:36:19 +00:00
Jim Meyering
aa41cdbb65 . 1996-06-01 03:21:53 +00:00
Jim Meyering
4d02bdd9b0 . 1996-06-01 03:19:25 +00:00
Jim Meyering
41e8b21fb7 . 1996-06-01 03:06:06 +00:00
Jim Meyering
fe9da7ee9b . 1996-05-31 03:45:49 +00:00
Jim Meyering
bd8218fbe9 . 1996-05-31 03:45:31 +00:00
Jim Meyering
d52bc68220 . 1996-05-31 03:45:16 +00:00
Jim Meyering
090cd9f443 . 1996-05-31 03:44:15 +00:00
Jim Meyering
b6c83bbaa0 . 1996-05-31 03:42:11 +00:00
Jim Meyering
5946c46972 . 1996-05-31 03:36:22 +00:00
Jim Meyering
20522f2f5d (main): Interpret the old-style +VALUE and -VALUE
options like -c VALUE and -c +VALUE (resp) when VALUE has one of
the [bkm] suffix multipliers.  This makes the code consistent
with --help output.
1996-05-31 03:35:32 +00:00
Jim Meyering
7b297f76c4 . 1996-05-31 03:08:07 +00:00
Jim Meyering
3c467c0d22 (limfield): #ifdef-out a block of code that makes
GNU sort incompatible with Unix sort when a key-end spec refers
to the N'th character in a field that has fewer than N characters.
The POSIX spec doesn't appear to specify behavior for this case.
From Karl Heuer.
1996-05-31 03:07:45 +00:00
Jim Meyering
b2ae052c6d . 1996-05-31 02:36:34 +00:00
Jim Meyering
8ee7e2c0c8 (.po.mo): Reenable dependency and rule.
It is required when using native NLS, e.g. on Solaris.
From Marcus Daniels.
1996-05-31 02:35:59 +00:00
Jim Meyering
3270b340e8 ($(PACKAGE).pot): Depend on POTFILES only when using maintainer mode.
Reported by Karl Heuer.
1996-05-31 02:26:23 +00:00
Jim Meyering
22978078f7 (stamp-cat-id): Avoid using temp filename longer than 14 characters.
(mostlyclean): Likewise.
From Karl Heuer.
1996-05-31 00:58:51 +00:00
Jim Meyering
53e41464fd (decode_one_format): Use %lu (not %d) printf formats
corresponding to unsigned long, SIZE.
1996-05-31 00:51:48 +00:00
Jim Meyering
86f7daf592 . 1996-05-31 00:51:23 +00:00
Jim Meyering
91e12f541f . 1996-05-30 06:34:25 +00:00
Jim Meyering
176a02c5d9 (installcheck): New target. 1996-05-30 06:34:16 +00:00
Jim Meyering
c6836cfdda . 1996-05-30 05:23:02 +00:00
Jim Meyering
090a56eb9c (decode_one_format): Take another parameter.
Give a specific diagnostic for invalid format spec here rather
than an overly general one from caller's caller.
(decode_format_string): Update caller.
(main): Don't give diagnostic here when decode_format_string fails.
Remove assertions that could fail on some Crays because they don't
have a two-byte type.
Johan Danielsson (joda@pdc.kth.se) reported the failed assertions.
1996-05-30 05:09:56 +00:00
Jim Meyering
8c0d3621b3 . 1996-05-30 05:09:31 +00:00
Jim Meyering
86d6d4c47c . 1996-05-30 02:32:19 +00:00
Jim Meyering
f1d4b41340 (docolon): Give a warning when the first character
of the basic regular expression is `^'.
1996-05-30 02:32:03 +00:00
Jim Meyering
ab8cec12c9 . 1996-05-30 02:31:45 +00:00
Jim Meyering
3bd31fac90 (main): Use STDIN_FILENO instead of less portable fileno (stdin). 1996-05-30 00:59:50 +00:00
Jim Meyering
31f9f9f24c . 1996-05-29 04:46:00 +00:00
Jim Meyering
e7b4a0bced . 1996-05-28 23:42:01 +00:00
Jim Meyering
a3b44d2fd5 . 1996-05-28 23:41:11 +00:00
Jim Meyering
55dcae1c8d (main): Don't mark "%s" as a translatable string.
From Gran Uddeborg.
1996-05-28 23:40:11 +00:00
Jim Meyering
a01eaef0fd (print_stats): Don't mark "%u %s" as a translatable string.
From Gran Uddeborg (gvran@uddeborg.pp.se).
1996-05-28 23:39:12 +00:00
Jim Meyering
9da759a317 (main): Use STDIN_FILENO and STDOUT_FILENO instead of less portable fileno(*). 1996-05-28 01:42:07 +00:00
Jim Meyering
d2d2d043ff Hack out broken WEAK junk. 1996-05-24 03:06:01 +00:00
Jim Meyering
afd4dcf3b2 Define __P. 1996-05-24 02:45:38 +00:00
Jim Meyering
9b7bbe7b0b . 1996-05-23 13:14:11 +00:00
Jim Meyering
d84462d473 FIXME: fill this in 1996-05-23 13:13:35 +00:00
Jim Meyering
e3579cb231 . 1996-05-23 13:05:04 +00:00
Jim Meyering
1a34934e94 (read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
From Johan Danielsson (joda@pdc.kth.se).
1996-05-23 13:04:41 +00:00
Jim Meyering
c2705c1e62 [_CRAY]: Don't include sys/filsys.h because although
Unicos-9 has it, it's not needed and would cause other problems
because it requires inclusion of other, non-standard headers.
1996-05-23 13:04:03 +00:00
Jim Meyering
63d49273c4 (usage): Make --literal (-N) description clearer. 1996-05-23 12:52:54 +00:00
Jim Meyering
2df44bba5b Add copyright header. 1996-05-22 12:37:29 +00:00
Jim Meyering
4b17c0b9ac Update from GNU libc-copies. 1996-05-22 12:37:11 +00:00
Jim Meyering
71d6f09173 . 1996-05-22 12:07:38 +00:00
Jim Meyering
5faf3cd5fb . 1996-05-22 12:03:18 +00:00
Jim Meyering
b4a30ded4c . 1996-05-21 12:15:50 +00:00
Jim Meyering
e1dc14d3a1 (euidaccess) [!S_IROTH]: Define.
[!S_IWOTH]: Define.
[!S_IXOTH]: Define.
Marcus Daniels <marcus@sysc.pdx.edu> reported that m68k NEXTSTEP 3.2
doesn't define S_IROTH or S_IWOTH unless some posix compile option
is used and associated symbols defined.
1996-05-21 12:15:27 +00:00
Jim Meyering
4c8f853735 (xgetgroups): New function, factored out of
print_group_list and print_full_info.
(print_group_list): Call it.
(print_full_info): Call it.

From Andreas Schwab:
(print_group_list): When USERNAME is specified use
getugroups to get the number of groups.
(print_full_info): Likewise.
1996-05-21 04:19:02 +00:00
Jim Meyering
6225a43223 . 1996-05-21 04:13:19 +00:00
Jim Meyering
abda80a05a . 1996-05-21 04:12:36 +00:00
Jim Meyering
6ab8d020db . 1996-05-21 04:11:45 +00:00
Jim Meyering
5daa998b30 . 1996-05-21 03:58:12 +00:00
Jim Meyering
5840eaec8d . 1996-05-21 03:57:51 +00:00
Jim Meyering
4a6d0824c9 . 1996-05-21 03:57:21 +00:00
Jim Meyering
166523ca2b . 1996-05-21 03:52:57 +00:00
Jim Meyering
04a5f54547 . 1996-05-21 03:40:45 +00:00
Jim Meyering
8f47502291 . 1996-05-21 02:56:29 +00:00
Jim Meyering
fb71b69665 . 1996-05-20 04:31:49 +00:00
Jim Meyering
f8a5744b34 . 1996-05-20 02:46:30 +00:00
Jim Meyering
e3fa3463d6 (usage): Make it a little clearer. 1996-05-20 02:46:22 +00:00
Jim Meyering
a712177a4b Tweak indentation. 1996-05-19 20:25:28 +00:00
Jim Meyering
b9ad7b9a9c . 1996-05-19 19:46:25 +00:00
Jim Meyering
47e20014b0 . 1996-05-19 18:15:59 +00:00
Jim Meyering
2f4e768ff4 . 1996-05-19 18:10:22 +00:00
Jim Meyering
f1aea23023 . 1996-05-19 17:14:19 +00:00
Jim Meyering
4734b96d4e . 1996-05-19 17:13:58 +00:00
Jim Meyering
faf0038376 New option: --no-dereference (-h).
[!MAXUID]: Define to INT_MAX.
(change_file_group): Use lchown if --no-dereference (-h) was given.
(usage): Update.
(main): Fail if user requests --no-dereference on a system that
doesn't have support for it.
1996-05-19 17:13:36 +00:00
Jim Meyering
dd7aea80f7 New option: --no-dereference (-h).
(change_file_owner): Use lchown if --no-dereference (-h) was given.
(usage): Update.
(main): Fail if user requests --no-dereference on a system that
doesn't have support for it.
1996-05-19 14:36:09 +00:00
Jim Meyering
4ff1b892d0 . 1996-05-18 19:35:36 +00:00
Jim Meyering
22125a047d . 1996-05-18 19:29:22 +00:00
Jim Meyering
b2191ea8e1 (main): Don't recognize --help, --h, --he, --version, --v, etc.
if the POSIXLY_CORRECT environment variable is set.
1996-05-18 18:37:11 +00:00
Jim Meyering
971c5b1379 (main): Don't recognize --help, --h, --he, --version, --v, etc.
if the POSIXLY_CORRECT environment variable is set.
1996-05-18 18:36:36 +00:00
Jim Meyering
2d8de9b8ab (main): Don't recognize --help, --h, --he, --version, --v, etc.
if the POSIXLY_CORRECT environment variable is set.
(docolon) [RE_SYNTAX_POSIX_BASIC]: Revert my misguided change of Mar 1.
1996-05-18 18:36:10 +00:00
Jim Meyering
271a7e6bb3 . 1996-05-17 03:19:01 +00:00
Jim Meyering
573c16a666 Update prototype to match. 1996-05-17 03:16:54 +00:00
Jim Meyering
bae16cb45b (get_fs_usage): Declare parameter PATH to be const. 1996-05-17 03:16:34 +00:00
Jim Meyering
b80225264a . 1996-05-17 03:16:21 +00:00
Jim Meyering
dcc145f13a Rearrange function definitions to precede respective uses to obviate
all forward dcls. Remove forward dcls.
Declare parameters const as appropriate.
1996-05-16 05:00:12 +00:00
Jim Meyering
51958e82aa . 1996-05-16 04:59:49 +00:00
Jim Meyering
ca0a087f3d . 1996-05-16 04:44:39 +00:00
Jim Meyering
22dc22c127 . 1996-05-16 04:31:54 +00:00
Jim Meyering
a56783bbb4 (selected_fstype): Move definition to precede use.
Remove prototype.  Declare parameter FSTYPE to be const.
(excluded_fstype): Likewise.
(main): Fail with a diagnostic if both --human-readable and
--portability are used.
Likewise if --megabytes and --portability are used.
1996-05-16 04:31:45 +00:00
Jim Meyering
699808bcad (do_link): Declare pointer parameters to be const. 1996-05-16 04:13:52 +00:00
Jim Meyering
7176037aa2 . 1996-05-16 04:02:10 +00:00
Jim Meyering
55447abbdf (getdate.c): Disable dependencies that can
require rerunning YACC when not in maintainer mode.
(posixtm.c): Likewise.
1996-05-16 04:01:39 +00:00
Jim Meyering
2c226bf49d Update prototypes. 1996-05-16 03:58:44 +00:00
Jim Meyering
8a623ebc61 (mode_compile): Declare parameter MODE_STRING const.
Remove register attribute.
(mode_adjust): Likewise for CHANGES.
1996-05-16 03:57:49 +00:00
Jim Meyering
fce70ef38b (describe_change): Declare pointer parameters to be const.
(change_file_mode): Likewise.
(change_dir_mode): Likewise.
1996-05-16 03:55:44 +00:00
Jim Meyering
9622bd6207 (md5_t_stats): Restructure pluralization of error message so it's easier
to translate.
1996-05-15 04:45:12 +00:00
Jim Meyering
f177941b93 (print_stats): Restructure pluralization of error message so it's easier
to translate.
1996-05-15 04:37:50 +00:00
Jim Meyering
a2c6905133 (main): Restructure pluralization of error message so it's easier to translate. 1996-05-15 04:37:08 +00:00
Jim Meyering
3df9acbfc9 . 1996-05-15 02:03:39 +00:00
Jim Meyering
9f58b3b3d5 . 1996-05-13 05:33:36 +00:00
Jim Meyering
e6b5a4d682 *** empty log message *** 1996-05-13 05:31:33 +00:00
Jim Meyering
1fb27efd70 . 1996-05-12 03:25:59 +00:00
Jim Meyering
d4a3e63ec8 Sat May 11 13:30:53 1996 enami tsugutomo <enami@ba2.so-net.or.jp>
* regex.c (re_match_2_internal): Fix off-by-one error; don't use
       length of exactn as character, and don't use length of bitmap of
       charset as bitmap.
1996-05-12 02:57:30 +00:00
Jim Meyering
f64964aa1d . 1996-05-11 01:59:25 +00:00
Jim Meyering
97775c5655 (all-yes): Always depend on CATALOGS. From Ulrich Drepper.
(.po.mo): Disable dependency and rule when not in maintainer mode.
1996-05-11 01:49:04 +00:00
Jim Meyering
483e2421c9 . 1996-05-10 05:10:34 +00:00
Jim Meyering
ac4a274dcf . 1996-05-10 03:31:07 +00:00
Jim Meyering
8b3d87d197 . 1996-05-10 03:30:32 +00:00
Jim Meyering
bee873f407 . 1996-05-10 03:27:51 +00:00
Jim Meyering
7b33a9910c . 1996-05-10 03:26:38 +00:00
Jim Meyering
d60264342d . 1996-05-10 03:20:30 +00:00
Jim Meyering
3cd2c9e1c8 , 1996-05-10 03:06:48 +00:00
Jim Meyering
c94ffee869 (all-yes): Also dependend on GMOFILES.
Depend on CATALOGS and GMOFILES files only in maintainer mode.
1996-05-10 03:05:51 +00:00
Jim Meyering
7da69e79df . 1996-05-08 05:01:01 +00:00
Jim Meyering
a79461545e . 1996-05-08 03:11:42 +00:00
Jim Meyering
32e36bd888 Update from GNU libc. 1996-05-07 03:41:17 +00:00
Jim Meyering
15e49fdbfb . 1996-05-06 04:20:07 +00:00
Jim Meyering
1b0419e8fd . 1996-05-06 01:28:23 +00:00
Jim Meyering
bd395b3bfc (main): Use fputs, not puts. Avoids spurious newline. 1996-05-06 01:26:25 +00:00
Jim Meyering
b7c1e2526a . 1996-05-06 01:25:32 +00:00
Jim Meyering
9300fb41f8 . 1996-05-05 18:48:42 +00:00
Jim Meyering
c434fa5195 Look for SYSTEM_FILE, not USER_FILE in SHAREDIR. 1996-05-05 02:41:29 +00:00
Jim Meyering
7f504f2317 . 1996-05-05 02:15:53 +00:00
Jim Meyering
cafa5c1c2d Make enumerated constants upper case.
(main): Don't rely on ANSI-style string concatenation.
Add `static' and/or `const' to some file scope variables.
1996-05-05 02:15:23 +00:00
Jim Meyering
73a90d1006 . 1996-05-05 02:04:32 +00:00
Jim Meyering
d4e2205ea9 Remove useless void casts of *printf return values. 1996-05-05 02:04:04 +00:00
Jim Meyering
8e9d1adf75 . 1996-05-05 01:56:17 +00:00
Jim Meyering
2f6c94da4c [IN_CTYPE_DOMAIN]: Rename from ISASCII. 1996-05-05 01:55:52 +00:00
Jim Meyering
68898bb9a7 . 1996-05-05 01:55:26 +00:00
Jim Meyering
812fdadfca [IN_CTYPE_DOMAIN]: Rename from ISASCII. 1996-05-05 01:55:16 +00:00
Jim Meyering
0e307a526c . 1996-05-05 01:55:04 +00:00
Jim Meyering
c1997cb5c3 . 1996-05-05 01:53:15 +00:00
Jim Meyering
74445dae42 [IN_CTYPE_DOMAIN]: Rename from ISASCII. 1996-05-05 01:51:50 +00:00
Jim Meyering
fcf3192814 [IN_CTYPE_DOMAIN]: Rename from ISASCII. 1996-05-05 01:51:26 +00:00
Jim Meyering
916861c0e8 . 1996-05-05 01:40:46 +00:00
Jim Meyering
437e9a0bc4 . 1996-05-02 02:47:10 +00:00
Jim Meyering
389c4049b3 (parse_ls_color, usage): Remove support for alternate spellings:
--colours and LS_COLOURS.
(parse_ls_color): Reverse sense of test for LS_COLORS environment
variable and return -- save a level of indentation on a 100+-line block.
1996-05-02 02:45:43 +00:00
Jim Meyering
a9ec4db8f2 . 1996-05-02 02:37:09 +00:00
Jim Meyering
9cda4e6527 . 1996-05-02 02:35:53 +00:00
Jim Meyering
cf1bd0e401 (EXTRA_DIST): Add strcasecmp.c. 1996-05-01 05:24:54 +00:00
Jim Meyering
419daeb511 . 1996-05-01 05:20:22 +00:00
Jim Meyering
5555b3c9db . 1996-05-01 05:19:38 +00:00
Jim Meyering
482d5be531 (parse_ls_color, usage): Remove support for alternate spellings:
--colours and LS_COLOURS.
1996-05-01 05:19:34 +00:00
Jim Meyering
87afdbeb7d . 1996-04-30 03:51:11 +00:00
Jim Meyering
a84f4f6087 . 1996-04-30 03:49:12 +00:00
Jim Meyering
12da649245 (usage): Change TAB in message to spaces. Doing that seems
to have worked around a problem with something in gettext that was
producing a truncated usage message for date's usage.
Franois Pinard.
1996-04-30 03:30:51 +00:00
Jim Meyering
22aec49d4c (main): Separate messages about too few' and too many'
arguments to ease translation.
From Franc,ois.
1996-04-30 03:29:01 +00:00
Jim Meyering
6580f24783 Mark translatable strings.
(main): Separate messages about `too few' and `too many'
arguments to ease translation.
From Franc,ois.
1996-04-30 03:26:34 +00:00
Jim Meyering
a3c143bd82 Mark translatable strings. 1996-04-30 03:20:38 +00:00
Jim Meyering
07e148c8e7 (print_name_with_quoting): Add braces around inner if-else stmt. 1996-04-29 04:53:53 +00:00
Jim Meyering
8455ea2e13 (LEN_STR_PAIR): New macro.
(color_indicator): Use it in this declaration.
(parse_ls_color): Use error, not fprintf.
(decode_switches): Add a comment.
1996-04-29 04:52:16 +00:00
Jim Meyering
95439d0f33 (parse_ls_color): Use strcpy to initialize 3-character array.
Automatic aggregate initialization isn't portable.
1996-04-29 04:31:24 +00:00
Jim Meyering
aa7d0d8c85 Remove all ^L's.
(get_funky_string): Declare static and move to precede single
caller: parse_ls_color.
1996-04-29 04:29:06 +00:00
Jim Meyering
3ce3cb772d (get_funky_string): Upper-case anon. union `state'. 1996-04-29 04:26:47 +00:00
Jim Meyering
e08a28e045 Apply color ls changes from Drepper. 1996-04-29 04:24:07 +00:00
Jim Meyering
6ea9602009 . 1996-04-29 04:04:59 +00:00
Jim Meyering
ea11fd8868 FIXME 1996-04-29 01:44:33 +00:00
Jim Meyering
346b0368cf . 1996-04-29 01:43:52 +00:00
Jim Meyering
175585876f . 1996-04-29 01:36:49 +00:00
Jim Meyering
1ecd1b9c52 . 1996-04-29 01:35:24 +00:00
Jim Meyering
30f76e827e (main): Give a better diagnostic for `sort -0'. Reported by Karl Berry. 1996-04-29 01:35:18 +00:00
Jim Meyering
8b9e784e1e . 1996-04-29 01:29:16 +00:00
Jim Meyering
5a5938db82 (copy_rest): Don't copy past end of prefix. Output
trailing spaces if the prefix had any.  Before, the command
perl -e 'print "| S";' |fmt -p' |  '|tr '\0' @ output `|@S'.
Reported by Franois Pinard.
1996-04-29 01:28:06 +00:00
Jim Meyering
3c57cea2ce . 1996-04-28 22:12:33 +00:00
Jim Meyering
0143b2901f . 1996-04-28 21:41:28 +00:00
Jim Meyering
527b07a1ad Indent CPP conditionals. 1996-04-28 21:41:20 +00:00
Jim Meyering
347c2d6d30 [HAVE_ST_BLOCKS || _POSIX_VERSION]: Add extern dcl
of unused variable so that after preprocessing, the file will never
be empty.  Otherwise, some compilers in ANSI mode (among them, the
Dec Alpha OSF 2.0 C compiler) reject empty files.  From Kaveh Ghazi.
1996-04-28 21:34:00 +00:00
Jim Meyering
9af8f15624 . 1996-04-27 04:11:35 +00:00
Jim Meyering
c17caa0c0f Fri Apr 26 05:52:03 1996 Karl Eichwalder <ke@ke.Central.DE>
* ls.c (usage): Add newline at end of printf format string.
1996-04-27 04:10:54 +00:00
Jim Meyering
77da45645d . 1996-04-25 04:38:01 +00:00
Jim Meyering
8b2c88998b Add copyright. 1996-04-25 04:33:03 +00:00
Jim Meyering
4cf126f7ce . 1996-04-25 04:32:42 +00:00
Jim Meyering
1c4ecd2a95 Get year as last rather than 6th field in output of date.
Otherwise, people with 2-word TZ (like `MET DST') lost.
1996-04-25 04:28:22 +00:00
Jim Meyering
56d10407e7 (main): Use verbose_fmt_string, not string literal in
call to make_path for --parents.  From Uli.
1996-04-25 03:10:57 +00:00
Jim Meyering
f3194fe603 (do_link): With --force, don't remove DEST when it's
the same as SOURCE.  Before, `ln -f FILE FILE' would remove FILE.
Reported by Bruno Haible.
1996-04-25 02:47:07 +00:00
Jim Meyering
f59d1dac46 (do_link): Remove duplicate `if (lstat' block. 1996-04-25 02:34:36 +00:00
Jim Meyering
359f885aae . 1996-04-24 05:05:39 +00:00
Jim Meyering
272f8d891e (usage): The long-named arg is --human-readable, not --human. 1996-04-24 05:05:34 +00:00
Jim Meyering
25f22cdc5d Be consistent. Accept --human-readable, not --human.
(usage): Reflect the change.
1996-04-24 05:04:44 +00:00
Jim Meyering
af781b708c . 1996-04-24 04:54:04 +00:00
Jim Meyering
0a9eb68f77 . 1996-04-24 04:51:29 +00:00
Jim Meyering
59d334f4d4 update Copyright years for 1996 1996-04-24 04:50:53 +00:00
Jim Meyering
e6eece1575 update Copyright years for 1996 1996-04-24 04:45:54 +00:00
Jim Meyering
8fbeb80792 . 1996-04-24 04:43:27 +00:00
Jim Meyering
dc98736719 update Copyright years for 1996 1996-04-24 04:42:21 +00:00
Jim Meyering
3f4c6398be . 1996-04-24 04:30:07 +00:00
Jim Meyering
7e4384f810 . 1996-04-24 04:29:20 +00:00
Jim Meyering
fdd4dd9b35 (find_backup_file_name): Constify decls of formal parameters. 1996-04-24 04:29:00 +00:00
Jim Meyering
bba8ab25f1 (find_backup_file_name, max_backup_version, make_version_name,
version_number, concat): Constify decls of formal parameters.
1996-04-24 04:28:21 +00:00
Jim Meyering
aa05c43a5f . 1996-04-24 04:08:14 +00:00
Jim Meyering
69e6145e1e [HAVE_LCHOWN]: Define chown to lchown. 1996-04-24 03:44:29 +00:00
Jim Meyering
fb19d01b96 [chown]: Move definition up a little. 1996-04-24 03:41:33 +00:00
Jim Meyering
b380f45a13 [HAVE_LCHOWN]: Define chown to lchown. 1996-04-24 03:41:10 +00:00
Jim Meyering
8e12bada8a [HAVE_LCHOWN]: Define chown to lchown. 1996-04-24 03:40:18 +00:00
Jim Meyering
ade410fae0 [HAVE_LCHOWN]: Define chown to lchown. 1996-04-24 03:35:55 +00:00
Jim Meyering
6d668c6160 . 1996-04-24 03:25:02 +00:00
Jim Meyering
78273e9d23 (main): Declare to return int, not void. 1996-04-24 03:24:54 +00:00
Jim Meyering
2b5207bc59 (main): Declare to return int, not void. 1996-04-24 03:23:54 +00:00
Jim Meyering
deeb3e0c49 (usage): Add missing close paren and open paren. 1996-04-24 03:23:37 +00:00
Jim Meyering
2b00449aa7 . 1996-04-24 03:13:47 +00:00
Jim Meyering
98d8740ccd (su_SOURCES): Remove getopt.c and getopt1.c.
(EXTRA_DIST): Add getopt.c and getopt1.c
1996-04-24 03:13:41 +00:00
Jim Meyering
56bc01ab4a . 1996-04-24 03:09:50 +00:00
Jim Meyering
1d43796211 . 1996-04-24 02:34:42 +00:00
Jim Meyering
e8a641509f . 1996-04-22 03:20:47 +00:00
Jim Meyering
674180c97f (usage): Use FIRST, LAST consistently in description. 1996-04-22 03:20:14 +00:00
Jim Meyering
c264e159a4 (usage): Describe new %V format. 1996-04-22 03:19:14 +00:00
Jim Meyering
a5a67731da . 1996-04-22 03:17:19 +00:00
Jim Meyering
d7bf7dee47 (usage): Reflect that now --no-sync is the default. 1996-04-22 03:17:14 +00:00
Jim Meyering
3032beba73 New version from gettext-0.10.12. 1996-04-22 03:02:55 +00:00
Jim Meyering
50b029f4d9 (md5_check): Remove spurious `\n' at end of error format string. 1996-04-22 03:00:52 +00:00
Jim Meyering
c07d15973c (decode_one_format): Use printf's L modifier for long doubles,
not `l'.  From Eric Backus.
1996-04-21 21:07:13 +00:00
Jim Meyering
5beebbd8da Include <values.h>.
[!BITSPERBYTE]: Define.
[OFF_T_MAX]: Use BITSPERBYTE, not 8, and cast the result to off_t.
1996-04-21 14:17:13 +00:00
Jim Meyering
763d748cf2 . 1996-04-21 13:32:54 +00:00
Jim Meyering
0e442c97a5 . 1996-04-21 05:20:10 +00:00
Jim Meyering
2411847f16 Include xstrtol.h.
[!BITSPERBYTE]: Define.
[!UID_T_MAX]: Define.
[!GID_T_MAX]: Define.
(get_ids): Use xstrtol, not atoi.
(is_number): Remove now-unused function.
1996-04-21 05:18:19 +00:00
Jim Meyering
874f418e03 Remove obsolete FIXME. 1996-04-21 05:15:39 +00:00
Jim Meyering
0126f74936 (decode_switches): Replace two more atoi uses with xstrtol. 1996-04-21 04:45:12 +00:00
Jim Meyering
7d956ece8c (decode_switches): Use getenv (POSIXLY_CORRECT), not undefined posix_pedantic. 1996-04-21 04:11:43 +00:00
Jim Meyering
ee708ff4aa (decode_switches): Clean up last change.
[posix_pedantic]: Don't consider TABSIZE environment variable.
1996-04-21 04:07:41 +00:00
Jim Meyering
c1f1f8ac3a (decode_switches): Use xstrtol, not atoi.
Detect and ignore invalid value for COLUMNS environment variable.
In error about invalid TABSIZE, don't reference optarg!
1996-04-21 03:52:30 +00:00
Jim Meyering
0aa556c39c . 1996-04-21 03:27:32 +00:00
Jim Meyering
b76ab178d1 (usage): Improve help message. From Karl Berry. 1996-04-21 03:26:46 +00:00
Jim Meyering
dfbe6788b4 (usage): Improve help message. From Karl Berry. 1996-04-21 03:25:53 +00:00
Jim Meyering
1d2c0959c9 (usage): Improve help message.
Enclose message strings in _().
From Karl Berry.
1996-04-21 03:24:47 +00:00
Jim Meyering
fc0f5b4539 . 1996-04-20 04:50:26 +00:00
Jim Meyering
49af3f858e . 1996-04-20 04:46:11 +00:00
Jim Meyering
0528939c0a . 1996-04-20 03:51:17 +00:00
Jim Meyering
a2d90c1616 No longer call sync by default. 1996-04-20 03:51:10 +00:00
Jim Meyering
5ac0cdbfce (main): Make separation of case for n_files == 0 more clear. 1996-04-20 03:43:10 +00:00
Jim Meyering
b8654f033b . 1996-04-19 05:07:58 +00:00
Jim Meyering
f60c8ea48b (copy_reg): Rearrange arithmetic in conditional to avoid
integer overflow with large files.
1996-04-19 05:07:52 +00:00
Jim Meyering
dafd2cb4e2 (basename): Rewrite so it doesn't rely on strrchr,
and hence doesn't need to include string.h -- on some alpha-based
OSF systems, there's a conflicting prototype for basename in string.h.
Reported by Kaveh Ghazi.
1996-04-19 04:41:27 +00:00
Jim Meyering
f970591c5a . 1996-04-19 04:34:53 +00:00
Jim Meyering
d729e4cab7 . 1996-04-19 03:17:31 +00:00
Jim Meyering
cccb23f01b (main): Make code clearer: use new variable `n_files' in
place of `argc - optind'.  Use `file' instead of `argv + optind'.
1996-04-19 03:17:23 +00:00
Jim Meyering
199923e3cc Indent cpp-directives. 1996-04-18 23:02:17 +00:00
Jim Meyering
706389d9df . 1996-04-17 05:03:22 +00:00
Jim Meyering
bba21e6815 . 1996-04-17 05:02:34 +00:00
Jim Meyering
0f459ed24c . 1996-04-17 05:01:56 +00:00
Jim Meyering
c1a0ddea63 . 1996-04-17 05:01:10 +00:00
Jim Meyering
337e927dae . 1996-04-17 05:00:17 +00:00
Jim Meyering
d8ab22727f . 1996-04-17 03:41:47 +00:00
Jim Meyering
505b859fe9 Test cpp-defined __sun as well as sun, because
in strict ANSI mode, only __sun is defined.  From Kaveh Ghazi.
1996-04-14 02:12:46 +00:00
Jim Meyering
e6cfa98486 . 1996-04-14 00:34:30 +00:00
Jim Meyering
93bd527109 . 1996-04-13 18:27:27 +00:00
Jim Meyering
d283aef5ca (usage): Add missing `\n\' at the end of newly added lines for %e and %z. 1996-04-13 18:27:24 +00:00
Jim Meyering
be333ac3a5 (print_uptime): Invoke getloadavg only if we have it. 1996-04-13 18:26:39 +00:00
Jim Meyering
62b978f77c . 1996-04-13 18:13:16 +00:00
Jim Meyering
84e64a529a Unprotoize.
[ISASCII]: Define.
[ISUPPER]: Define.
1996-04-13 18:13:09 +00:00
Jim Meyering
b4a20010e6 (decode_field_spec): Rename local variable `valid'
to invalid (and reverse sense) to avoid conflict with the
macro definition in /usr/include/locale.h on SunOS 4.1.3.
1996-04-13 18:11:43 +00:00
Jim Meyering
b8b9306a9a . 1996-04-13 04:42:15 +00:00
Jim Meyering
5ec32b62e5 . 1996-04-13 03:59:26 +00:00
Jim Meyering
c659704b20 (main): Add new option: --verbose.
Remove long-deprecated and nowhere-documented --path, a synonym
for --parents.  It was confusing to get an error about `--p'
being ambiguous.
1996-04-13 03:59:20 +00:00
Jim Meyering
ce339a4a50 . 1996-04-13 03:58:33 +00:00
Jim Meyering
53ff5566ce . 1996-04-13 03:18:47 +00:00
Jim Meyering
c1bf67ee67 Mark translatable strings in new code. 1996-04-13 03:17:44 +00:00
Jim Meyering
5dbe03ea6c . 1996-04-13 03:07:54 +00:00
Jim Meyering
a2b6134e37 . 1996-04-13 03:05:56 +00:00
Jim Meyering
d82c2c9274 (usage): Document %e and %z. Reported by Karl Berry. 1996-04-13 03:04:21 +00:00
Jim Meyering
cc6711057e . 1996-04-13 02:54:59 +00:00
Jim Meyering
c60619245a . 1996-04-13 02:54:13 +00:00
Jim Meyering
a7b3ea4189 . 1996-04-12 04:27:03 +00:00
Jim Meyering
7057c83fd4 Reindent.
(UT_TIME_MEMBER): New macro.
(print_uptime): Use it instead of #ifdef HAVE_UTMPX_H #else.
(print_entry): Likewise.
1996-04-11 02:30:09 +00:00
Jim Meyering
737ea4d4f9 (print_uptime) [UPTIME]: New function. From Kaveh Ghazi. 1996-04-10 04:57:09 +00:00
Jim Meyering
ac22df9290 . 1996-04-10 04:03:47 +00:00
Jim Meyering
a33c222135 . 1996-04-10 03:52:01 +00:00
Jim Meyering
f6d1e06932 . 1996-04-10 03:51:41 +00:00
Jim Meyering
447a13cdd4 Document uniq's new --ignore-case option. 1996-04-10 03:51:07 +00:00
Jim Meyering
727a9ed970 Add new option --ignore-case (-i).
Include memcasecmp.h.
(different): Compare with memcasecmp if ignoring case.
(main): Handle 'i'.
1996-04-10 03:50:31 +00:00
Jim Meyering
5d5979d9a8 (memcasecmp): Remove static definition of function.
Include memcasecmp.h instead.
1996-04-10 03:47:28 +00:00
Jim Meyering
5eb19629b0 . 1996-04-10 03:29:05 +00:00
Jim Meyering
cbfdc4fd51 . 1996-04-08 04:57:19 +00:00
Jim Meyering
24c0303794 . 1996-04-08 04:56:36 +00:00
Jim Meyering
d9422a21e0 . 1996-04-08 04:54:35 +00:00
Jim Meyering
4be30f34c2 . 1996-04-08 04:54:00 +00:00
Jim Meyering
4da76e0c6f (mon_week_ISO): New function to implement new %V format.
(sun_week): Make TM parameter `const'.
(mon_week): Likewise.
(mon_week): Rewrite to correctly implement %W format..
1996-04-08 04:53:54 +00:00
Jim Meyering
39c92b4dc4 (print_numbers): Fix off-by-one error in backwards-counting loop.
Reported by Karl Eichwalder.
1996-04-08 04:37:45 +00:00
Jim Meyering
c74a04a26f . 1996-04-07 17:56:40 +00:00
Jim Meyering
aedf3f9fc5 updage from gettext-0.10.12 1996-04-07 17:53:50 +00:00
Jim Meyering
7e76b8b7da (usage): Give minimal description of the program.
(print_factors): Give a better diagnostic.
(main): Suggest --help upon failure.
Reported by Karl Eichwalder <ke@ke.Central.DE>.
1996-04-07 17:46:03 +00:00
Jim Meyering
d9fe359377 . 1996-04-07 17:27:27 +00:00
Jim Meyering
c32c5775be Fiddle with messages. 1996-04-07 17:27:11 +00:00
Jim Meyering
3220407d48 (print_numbers): Give more precise diagnostic when increment
is inconsistent with FROM and TO.
(usage): Clean up help message.
1996-04-07 17:10:21 +00:00
Jim Meyering
45c51b256a (main): Rearrange loops to get it right.
Reported by Karl Eichwalder <ke@ke.Central.DE>.
1996-04-07 16:59:12 +00:00
Jim Meyering
c1505fc01f (sun_week): Make %U work properly.
Before, `date -d '1 Jan 1995' +%U' output `00'.  Now it prints `01'.
1996-04-05 23:33:09 +00:00
Jim Meyering
cca1377d96 . 1996-04-05 16:08:32 +00:00
Jim Meyering
8024d6459c . 1996-04-05 16:04:56 +00:00
Jim Meyering
78732c5421 Remove diagnostic. 1996-04-05 16:04:15 +00:00
Jim Meyering
0e199278c1 (main): Use `if' stmt, not while loop, around getopt invocation.
Otherwise, `./nice --a=1 -1 ./nice' (in which old-style option
follows a long option) gets an error.
1996-04-05 13:32:39 +00:00
Jim Meyering
9d22ab92f9 Patch from Frank Korz. 1996-04-05 13:14:59 +00:00
Jim Meyering
8a6f26dfd6 . 1996-04-05 04:37:05 +00:00
Jim Meyering
43b84ec02e Remove fixed FIXME. 1996-04-05 04:00:05 +00:00
Jim Meyering
dadd9cf997 . 1996-04-05 03:58:37 +00:00
Jim Meyering
dacd5d7572 . 1996-04-05 03:55:07 +00:00
Jim Meyering
a8b09f0b0a . 1996-04-05 03:28:34 +00:00
Jim Meyering
7670167015 . 1996-04-05 03:27:21 +00:00
Jim Meyering
7f00439ebe . 1996-04-05 03:11:47 +00:00
Jim Meyering
a6263137d7 . 1996-04-05 01:22:42 +00:00
Jim Meyering
efb6a6917b . 1996-04-04 23:16:13 +00:00
Jim Meyering
987f70fee5 . 1996-04-04 23:10:35 +00:00
Jim Meyering
42a0e84308 The following commands all failed unnecessarily.
tr -cs '[:upper:]' '[X*]'
tr -dcs '[:lower:]' n-rs-z
tr -ds '[:xdigit:]' [:alnum:]'
tr -dcs '[:alnum:]' [:digit:]'
tr -dc '[:upper:]'
Reported by Ross Ridge (ross@worf.mks.com).
(validate): Add missing conjunct (translating) in test for
`translating and complementing character classes' error.  Before,
valid uses of tr could fail.  E.g. `tr -dcs '[:cntrl:]' '[:alnum:]''.
(homogeneous_spec_list): New function.
(validate): Use it to relax the old (overly restrictive) restriction
that prohibited use of complemented character classes when translating.
Now, that is allowed as long as the translation maps many to one.
(get_spec_stats): Rename and redefine global has_char_class from
has_upper_or_lower.
1996-04-04 23:08:30 +00:00
Jim Meyering
564707901d . 1996-04-04 20:57:13 +00:00
Jim Meyering
70a316cc3d Add tests from Ross Ridge. 1996-04-04 20:22:10 +00:00
Jim Meyering
7ef62e1fda . 1996-04-04 12:58:29 +00:00
Jim Meyering
118e780f0d . 1996-04-04 12:45:16 +00:00
Jim Meyering
3c5b5b8b03 . 1996-04-03 13:19:59 +00:00
Jim Meyering
0a6412bea9 Include stdio.h before grp.h.
Because <grp.h> on alpha OSF1 V2.0 uses "FILE *".  From Kaveh Ghazi.
1996-04-03 13:19:16 +00:00
Jim Meyering
4a8b8d5f68 . 1996-04-03 12:56:09 +00:00
Jim Meyering
e00bceb7f2 update from gettext-0.10.11 1996-04-03 12:52:22 +00:00
Jim Meyering
58dce30461 . 1996-04-03 12:33:23 +00:00
Jim Meyering
3583bcd14d . 1996-04-03 12:28:18 +00:00
Jim Meyering
3191649a85 (copy_reg): Use ST_NBLOCKS (sb) * 512', not sb.st_blocks *
DEV_BSIZE.'  From H.J. Lu (hjl@lucon.org).
1996-04-03 12:20:24 +00:00
Jim Meyering
4325d27ddd Include assert.h (disabled).
(path_concat): New function.
(do_copy): Use path_concat instead of open-coding part of its
functionality in two places.  This has the additional benefit
of avoiding forming destination names like `D//file' when the
destination directory D includes a trailing slash -- as would
happen when cp is used like this:
mkdir D; touch file D/file; cp -i file D/
Reported by Franois Pinard.
1996-04-03 05:42:14 +00:00
Jim Meyering
834a0cf023 . 1996-04-02 15:57:23 +00:00
Jim Meyering
778abcac1e . 1996-04-02 14:28:26 +00:00
Jim Meyering
741c894274 (unsetenv): unprotoize. 1996-04-01 04:29:28 +00:00
Jim Meyering
651e543fd6 . 1996-04-01 00:16:11 +00:00
Jim Meyering
ae56578d18 . 1996-03-31 23:30:43 +00:00
Jim Meyering
74ca57dfe8 . 1996-03-31 22:31:30 +00:00
Jim Meyering
91aab55475 . 1996-03-31 17:20:34 +00:00
Jim Meyering
fa9c4632bb . 1996-03-31 17:20:02 +00:00
Jim Meyering
3d1c60aba7 . 1996-03-31 17:19:06 +00:00
Jim Meyering
399abab9bc (quote_filename): Use ISGRAPH and ISPRINT in place of
ASCII-centric tests against literals.
(length_of_file_name_and_frills): Likewise.
1996-03-31 17:18:28 +00:00
Jim Meyering
908040f25e Rip out color support. 1996-03-31 14:22:12 +00:00
Jim Meyering
ac906fde2f update from FSF:/home/gd/gnu/lib 1996-03-30 14:26:16 +00:00
Jim Meyering
57dcd53d86 Update from libc. 1996-03-30 12:39:36 +00:00
Jim Meyering
45479ef311 Upgrade from gettext-0.10.10. 1996-03-30 12:19:38 +00:00
Jim Meyering
21fb4595e6 . 1996-03-30 04:18:13 +00:00
Jim Meyering
43c812bc6a . 1996-03-29 16:14:36 +00:00
Jim Meyering
86110845b2 . 1996-03-29 05:47:21 +00:00
Jim Meyering
f9045181fd . 1996-03-29 05:45:25 +00:00
Jim Meyering
850ad58630 . 1996-03-29 05:01:14 +00:00
Jim Meyering
a95c870766 . 1996-03-29 05:00:05 +00:00
Jim Meyering
56d806cf6f . 1996-03-29 04:54:45 +00:00
Jim Meyering
c2efd628df . 1996-03-29 04:53:57 +00:00
Jim Meyering
5eceb4fed1 . 1996-03-28 06:19:37 +00:00
Jim Meyering
38457c3dac . 1996-03-28 06:18:24 +00:00
Jim Meyering
fee163dd57 Move usage to precede main.
Say `too few arguments' if that's why we display usage.
Protoize.
Include error.h.
Update copyright.
1996-03-28 06:17:34 +00:00
Jim Meyering
f954f74302 . 1996-03-28 06:14:59 +00:00
Jim Meyering
0271d97259 from Roland 1996-03-28 05:42:56 +00:00
Jim Meyering
9cb8617078 . 1996-03-28 05:35:48 +00:00
Jim Meyering
7c5f9f7faa (cksum): Use format "%lu %ld" (instead of "%10lu %8ld")
to be POSIX compliant.  From Stephen Gildea <gildea@x.org>.
1996-03-28 05:35:31 +00:00
Jim Meyering
053855b040 . 1996-03-26 05:46:05 +00:00
Jim Meyering
a5b5719d3b Document and example --rfc.
Document %z and %Z.
1996-03-26 05:44:03 +00:00
Jim Meyering
01b69091e2 . 1996-03-24 18:50:47 +00:00
Jim Meyering
d30fa5d58e . 1996-03-24 18:49:38 +00:00
Jim Meyering
b54cd94fe7 . 1996-03-24 18:48:25 +00:00
Jim Meyering
5de0b392f2 Update FSF's address. 1996-03-24 18:47:09 +00:00
Jim Meyering
3613700a38 Update FSF's address. 1996-03-24 18:40:53 +00:00
Jim Meyering
318a497768 Update FSF's address. 1996-03-24 18:33:12 +00:00
Jim Meyering
7b428cdeda . 1996-03-24 18:23:44 +00:00
Jim Meyering
b28595b502 . 1996-03-24 18:20:25 +00:00
Jim Meyering
f9714aa24d Include xstrtod.h.
(scan_double_arg): Use xstrtod rather than strtod directly.
1996-03-24 18:16:10 +00:00
Jim Meyering
a9ff449aa6 . 1996-03-24 18:13:56 +00:00
Jim Meyering
236c02759b Make parameters const where appropriate.
Rename global FROM to START.
(print_numbers): Rewrite loops to avoid incrementing.  Instead,
use `x = first + i * increment' paradigm.  Otherwise, with inexact
increment, you could miss the last value.
1996-03-24 17:50:09 +00:00
Jim Meyering
777948e773 Protoize and reorder functions. 1996-03-24 17:43:41 +00:00
Jim Meyering
6e45576dd6 (main): Reformat if-block a little.
Declare index I to be of type size_t to avoid warning from gcc -Wall.
1996-03-24 17:21:40 +00:00
Jim Meyering
2bc35b0348 . 1996-03-24 16:59:29 +00:00
Jim Meyering
818d29db9b Call error with EXIT_FAILURE (rather than `1') as first actual parameter. 1996-03-24 16:59:11 +00:00
Jim Meyering
47f70113d4 Exit with status EXIT_SUCCESS or EXIT_FAILURE, rather than 0 or 1.
This doesn't change `error (1' calls.
1996-03-24 14:58:01 +00:00
Jim Meyering
2fa0c16e5e . 1996-03-24 05:15:00 +00:00
Jim Meyering
8060afb088 . 1996-03-24 02:31:39 +00:00
Jim Meyering
a1bc39d130 . 1996-03-24 02:26:30 +00:00
Jim Meyering
e6fae6c23f [SORT_FAILURE]: New macro.
Be careful to exit with 1 only when -c is used and the
input is not properly sorted.  In all other cases, use
SORT_FAILURE as required by POSIX.
(main): Change some `error (1, ...' to use SORT_FAILURE.
Upon successful termination, exit with EXIT_SUCCESS instead of `0'.
Replace all uses of `2' (as exit code) with SORT_FAILURE.
1996-03-24 02:26:21 +00:00
Jim Meyering
adb160df0f . 1996-03-24 02:20:06 +00:00
Jim Meyering
74a776f9ae . 1996-03-24 02:19:39 +00:00
Jim Meyering
12ea18c68d . 1996-03-24 02:19:31 +00:00
Jim Meyering
f870ecb4a6 . 1996-03-22 04:57:19 +00:00
Jim Meyering
6d6bfafbdd . 1996-03-22 04:55:00 +00:00
Jim Meyering
7178674807 Include assert.h, but disable assertions.
(process_line_count): Replace if-abort with a slightly relaxed
assertion.  Before, `echo |csplit - 1 1' would abort.
Reported by Samuli.Karkkainen@hut.fi.
(parse_patterns): Disallow uses like `csplit FILE 0' with zero
line number, `csplit FILE 2 1' with decreasing line numbers, and
warn about uses like `csplit FILE 3 3' that have equal line numbers.
1996-03-22 04:54:46 +00:00
Jim Meyering
1954f681c6 (main): Declare to be of type int, not void. 1996-03-21 22:47:02 +00:00
Jim Meyering
bb6a548712 (main): Declare to be of type int, not void. 1996-03-21 22:45:19 +00:00
Jim Meyering
403816eb85 . 1996-03-21 22:43:38 +00:00
Jim Meyering
adb7c216b2 (main): Declare to be of type int, not void. 1996-03-21 22:41:04 +00:00
Jim Meyering
92d78458e0 . 1996-03-21 13:00:25 +00:00
Jim Meyering
dd5db06467 (main): Declare to return int, not void. From Peter Seebach
<seebs@taniemarie.solon.com>.
1996-03-21 13:00:15 +00:00
Jim Meyering
b13e6b03cc . 1996-03-18 05:52:07 +00:00
Jim Meyering
a2b8387b70 . 1996-03-16 22:37:33 +00:00
Jim Meyering
4229a555fc Don't include version.h.
(main): Use PACKAGE_VERSION instead of version_string.
1996-03-16 22:30:54 +00:00
Jim Meyering
688833b80e . 1996-03-16 16:54:48 +00:00
Jim Meyering
ca0246a4c1 Don't include version.h.
(main): Use PACKAGE_VERSION instead of version_string.
1996-03-16 16:49:28 +00:00
Jim Meyering
c1cdafa1b4 Change @VERSION@ to @PKG_VERSION@. 1996-03-16 16:41:36 +00:00
Jim Meyering
ed960988ee . 1996-03-16 16:14:50 +00:00
Jim Meyering
3ee97d4d5b Don't include version.h.
(main): Use PACKAGE_VERSION instead of version_string.
1996-03-16 16:14:26 +00:00
Jim Meyering
b34f300eaf . 1996-03-16 05:44:09 +00:00
Jim Meyering
2e5cc5e04e (read_utmp): Declare n_read to be of type size_t rather than int. 1996-03-16 05:44:02 +00:00
Jim Meyering
182c784a99 (validate_path): Cast path_max to size_t before
comparing with strlen(path).
1996-03-16 05:43:24 +00:00
Jim Meyering
b14b621029 Remove __P-protected prototype for basename.
Reported by Franois Pinard.
(remove_suffix): Move to precede use.  Remove prototype.
Declare formal parameter SUFFIX to be const.
1996-03-16 05:42:53 +00:00
Jim Meyering
8825dba4e7 . 1996-03-14 05:21:43 +00:00
Jim Meyering
9922b56ffb add ## comment on first line 1996-03-14 05:15:16 +00:00
Jim Meyering
6681674e3c (EXTRA_DIST): Renamed form DIST_OTHER. 1996-03-14 05:05:22 +00:00
Jim Meyering
99f35e8204 . 1996-03-14 04:52:29 +00:00
Jim Meyering
c46f149efd . 1996-03-13 05:24:33 +00:00
Jim Meyering
644d185dea . 1996-03-13 05:13:52 +00:00
Jim Meyering
6fc4ae7a28 (main): Initialize for internationalized message support:
call setlocale, bindtextdomain, and textdomain.
1996-03-12 23:49:29 +00:00
Jim Meyering
3f92a4421a . 1996-03-12 04:20:57 +00:00
Jim Meyering
7a4a5dd66c . 1996-03-12 04:14:47 +00:00
Jim Meyering
fe456215a6 [_]: Don't define this away. 1996-03-12 04:02:07 +00:00
Jim Meyering
65957278ab . 1996-03-12 04:01:04 +00:00
Jim Meyering
6f2e1d1ce2 (max_backup_version): Declare file_name_length to be of type size_t. 1996-03-12 03:58:25 +00:00
Jim Meyering
51078dff7f . 1996-03-12 03:35:21 +00:00
Jim Meyering
03824c9e29 . 1996-03-12 03:29:57 +00:00
Jim Meyering
10c96c43ac (main): Initialize for internationalized message support: call setlocale,
bindtextdomain, and textdomain.
1996-03-12 03:08:30 +00:00
Jim Meyering
8e8fd5439a Add definitions and includes for NLS. 1996-03-12 03:06:47 +00:00
Jim Meyering
d3bcbd9968 . 1996-03-11 22:07:30 +00:00
Jim Meyering
6526b37460 (write_bytes): Renamed from xfwrite.
Remove SIZE parameter.  It was always 1.
Update all callers.
Rename NELEM parameter to N_BYTES and change its type to size_t.
1996-03-11 22:07:21 +00:00
Jim Meyering
9379b5aed5 Merge changes from FSF. 1996-03-10 05:00:20 +00:00
Jim Meyering
f2794b3c5d . 1996-03-09 20:26:12 +00:00
Jim Meyering
f090816a3f (star_digits_closebracket): Declare formal param, IDX, and local I to
be of type size_t (rather than int) to avoid warnings from gcc -Wall.
1996-03-09 20:25:29 +00:00
Jim Meyering
d385bbc985 (memcasecmp): Declare local I to be unsigned to avoid warning from gcc -Wall. 1996-03-09 20:24:01 +00:00
Jim Meyering
715765a548 (main): Initialize for internationalized message support: call setlocale,
bindtextdomain, and textdomain.
1996-03-09 20:19:13 +00:00
Jim Meyering
de0fdbb080 . 1996-03-09 20:17:53 +00:00
Jim Meyering
e6800f5073 Use /usr/bin/perl.
Remove unused $test.
1996-03-09 17:53:59 +00:00
Jim Meyering
e1ff4d762b Change some more " to '. 1996-03-09 17:53:18 +00:00
Jim Meyering
ffccedee33 Fix for perl5 (there were % inside double-quoted strings).
Change a lot of "" to ''.
1996-03-09 17:50:59 +00:00
Jim Meyering
8ddd60a387 (copy): Comment change to avoid overwriting source with backup. 1996-03-09 04:59:22 +00:00
Jim Meyering
eaf359df0c . 1996-03-08 02:26:21 +00:00
Jim Meyering
ff6400a018 (main): Tell read_filesystem_list that it should determine file system type
when the user specifies --print-type or -T.  From Michael Rendell
<michael@cs.mun.ca>
1996-03-08 02:25:40 +00:00
Jim Meyering
a74458a36e (print_entry): Use STRUCT_UTMP, not `struct utmp'. 1996-03-07 03:41:22 +00:00
Jim Meyering
e6c847ea05 . 1996-03-07 03:41:11 +00:00
Jim Meyering
c7d28e2bd8 . 1996-03-06 05:13:10 +00:00
Jim Meyering
898f3e5757 . 1996-03-06 05:10:30 +00:00
Jim Meyering
c239e82816 (usage): Reorder --time and --help so --help is the latter (just
before --version) to be consistent with other usage functions.
1996-03-06 05:04:05 +00:00
Jim Meyering
aaa9cb7c22 (RelativeMonth): Add 1900 to the year so that relative date specs
that push the year through the end of the century work.  For example,
`date -d "01/01/1998 3 years" +%Y' now prints 2001.
From Peter Dalgaard (pd@kubism.ku.dk).
1996-03-06 04:57:01 +00:00
Jim Meyering
73d802bead . 1996-03-06 04:50:26 +00:00
Jim Meyering
29b0ceae9f . 1996-03-05 05:47:09 +00:00
Jim Meyering
b21af8a7dd (main): Exit after processing --version. 1996-03-05 05:47:04 +00:00
Jim Meyering
7a888be2e5 . 1996-03-02 05:46:23 +00:00
Jim Meyering
815b5ca1d5 (WINDOWS_SETFILEMODE_BINARY): New macro.
(skip) [_WIN32 && _O_BINARY]: Use it.
(read_char): Likewise.
(read_block): Likewise.
Based on changes by Gary Newman <gnewman@shore.net>.
1996-03-02 05:45:45 +00:00
Jim Meyering
76118226b6 Document sort -z. From eichin@cygnus.com. 1996-03-02 03:42:56 +00:00
Jim Meyering
091c054eed . 1996-03-02 03:00:54 +00:00
Jim Meyering
3d2a9041f9 (docolon): Don't use deceptively-named RE_SYNTAX_POSIX_BASIC -- it recognizes
non-BRE \?, \+, and \|.  Instead, use RE_SYNTAX_POSIX_MINIMAL_BASIC.
1996-03-02 02:45:20 +00:00
Jim Meyering
aeb85812a1 . 1996-02-29 05:19:24 +00:00
Jim Meyering
3a3b589b06 . 1996-02-29 05:10:23 +00:00
Jim Meyering
20c8b4db54 . 1996-02-29 05:09:45 +00:00
Jim Meyering
c44dd6ddad . 1996-02-29 05:09:32 +00:00
Jim Meyering
446976666c General cleanup. Use xstrtoul, not atoi.
Change output format.  Allow inputs as large as ULONG_MAX.
Allow more than one command line argument.
1996-02-29 05:07:34 +00:00
Jim Meyering
c997ad6f05 . 1996-02-29 03:08:29 +00:00
Jim Meyering
27a6efc25b . 1996-02-29 03:06:42 +00:00
Jim Meyering
557514f55c (wrapf) [!__STDC__]: Indent by one space the first line of the pre-ANSI
function definition so ansi2knr doesn't munge it.
1996-02-29 03:06:10 +00:00
Jim Meyering
5ba09e9ace . 1996-02-29 02:55:04 +00:00
Jim Meyering
60ae95f973 . 1996-02-29 02:53:42 +00:00
Jim Meyering
9a181424ac (eval6): Cast strlen to int to avoid warning from gcc -Wall. 1996-02-29 02:53:37 +00:00
Jim Meyering
4e3478c9d6 . 1996-02-29 02:33:57 +00:00
Jim Meyering
3803547285 . 1996-02-29 02:27:43 +00:00
Jim Meyering
cbdd4ce994 Use @sc{} around POSIX and POSIX.2. 1996-02-29 02:14:16 +00:00
Jim Meyering
3749705b11 . 1996-02-28 05:14:04 +00:00
Jim Meyering
c940655b0f . 1996-02-28 05:11:50 +00:00
Jim Meyering
db18c4898e Adapt for automake-0.30.
(noinst_HEADERS): Rename from HEADERS.
1996-02-28 05:10:05 +00:00
Jim Meyering
5d78a2a235 . 1996-02-28 05:05:21 +00:00
Jim Meyering
268ddc7d50 Revert last change. Comment didn't add anything. 1996-02-27 03:57:49 +00:00
Jim Meyering
dee715bb6f Elaborate comment. 1996-02-27 03:33:23 +00:00
Jim Meyering
edac0ff420 (copy): Remove bogus (now that we're using full_write) increment of w_partial.
Change sense of the tests (though they're equivalent) that check
the value returned by full_write. making it clearer where errno
is valid.  full_write always writes the full amount or fails.
1996-02-27 03:24:31 +00:00
Jim Meyering
3f10c64fca . 1996-02-27 03:24:07 +00:00
Jim Meyering
d706ee318c . 1996-02-26 04:20:07 +00:00
Jim Meyering
a4d2c17357 . 1996-02-25 12:55:48 +00:00
Jim Meyering
6f37efd8b2 (batch_convert): Put `' around filename in error in case it's empty. 1996-02-25 05:31:26 +00:00
Jim Meyering
746c5e5528 Unprotoize. 1996-02-24 18:30:46 +00:00
Jim Meyering
6ff9e537fe . 1996-02-24 18:29:11 +00:00
Jim Meyering
b12057e3bd __P-protect forward declarations.
(main): Protoize function definition.
1996-02-24 18:27:11 +00:00
Jim Meyering
34e1cf8304 (cmpf): Indent macro uses so ansi2knr doesn't mistake them
for function dcls and munge them.
(arithf): Likewise.
(arithdivf): Likewise.
1996-02-24 18:25:29 +00:00
Jim Meyering
178d3b59d5 . 1996-02-23 16:29:43 +00:00
Jim Meyering
ce4e2493ee [HAVE_SYS_SOCKET_H]: Include <sys/socket.h> for definition of AF_INET
on at least SunOS 4.
1996-02-23 16:14:27 +00:00
Jim Meyering
85f9983c19 (docolon): Set re_syntax_options to RE_SYNTAX_POSIX_BASIC
so expr's pattern matching uses BASIC (not GNU-extended) REs.
Reported by Jim Kingdon.
1996-02-23 16:13:53 +00:00
Jim Meyering
9cb56e2980 (print_entry): Use strchr, not index. 1996-02-23 16:12:01 +00:00
Jim Meyering
c5134a9b13 (batch_convert): Declare BUFLEN local to be of type size_t, not int. 1996-02-23 16:11:14 +00:00
Jim Meyering
475d6600c1 . 1996-02-23 14:40:13 +00:00
Jim Meyering
3dbdcab168 . 1996-02-23 14:37:47 +00:00
Jim Meyering
756fe67e60 (xfields) [without -t]: Ignore leading blanks.
From David Dyck	(dcd@tc.fluke.COM).
1996-02-22 00:58:12 +00:00
Jim Meyering
23d07a32b2 . 1996-02-22 00:57:24 +00:00
Jim Meyering
9f82a64eb6 . 1996-02-22 00:56:40 +00:00
Jim Meyering
79b86f69e6 . 1996-02-21 19:53:35 +00:00
Jim Meyering
4d81490eb3 . 1996-02-20 02:33:14 +00:00
Jim Meyering
28a24ea3be [TOLOWER]: Define.
(usage): Briefly describe new --ignore-case (-i) option.
(memcasecmp): New function.
(main): Set IGNORE_CASE for -i.
(keycmp): Compare with memcasecmp if IGNORE_CASE is set.
Suggestion and an initial patch from Alberto Accomazzi
<alberto@cfa0.harvard.edu>.
1996-02-18 18:08:01 +00:00
Jim Meyering
6a4e9d5422 . 1996-02-18 18:07:36 +00:00
Jim Meyering
777d5f0ba8 (join): Describe new --ignore-case (-i) option. 1996-02-18 17:58:01 +00:00
Jim Meyering
9e7cf8346d . 1996-02-18 04:11:40 +00:00
Jim Meyering
1f37d82ce4 Add -z option. Change all occurrences of '\n' to `eolchar'.
(usage): Describe it.
(main): Set eolchar to 0 for -z.
From Mark W. Eichin <eichin@cygnus.com>.
1996-02-18 00:55:08 +00:00
Jim Meyering
baf2a7b0fe . 1996-02-17 03:45:17 +00:00
Jim Meyering
73d5e9c5dd Mark a few error strings for translation.
From Franc,ois Pinard.
1996-02-17 03:42:26 +00:00
Jim Meyering
daf7870cb0 . 1996-02-16 05:16:46 +00:00
Jim Meyering
796e41bedf . 1996-02-16 05:15:26 +00:00
Jim Meyering
816194943b (copy): Detect (and fail) when creating backup file would destroy source.
Reported by Martin C. Martin <mcm@cs.cmu.edu>.
1996-02-16 05:08:04 +00:00
Jim Meyering
2eabfeeea8 . 1996-02-16 03:30:58 +00:00
Jim Meyering
5715c04ceb . 1996-02-14 05:49:26 +00:00
Jim Meyering
dd05029135 (main): When failing because there were `too many arguments,' say so. 1996-02-14 05:48:48 +00:00
Jim Meyering
78362fb43a . 1996-02-13 05:37:09 +00:00
Jim Meyering
1723365c85 . 1996-02-13 05:31:19 +00:00
Jim Meyering
7e9524d7b9 . 1996-02-13 05:30:27 +00:00
Jim Meyering
c4b593538b Be careful to always return something. 1996-02-13 05:28:38 +00:00
Jim Meyering
0b2ebf9875 (print_entry): If possible, canonicalize the host hame.
From Miles Bader (miles@gnu.ai.mit.edu).
1996-02-13 05:27:16 +00:00
Jim Meyering
aa35ed104c . 1996-02-13 05:24:05 +00:00
Jim Meyering
737a7a7116 . 1996-02-13 05:23:35 +00:00
Jim Meyering
4634a5c628 . 1996-02-13 05:22:15 +00:00
Jim Meyering
c33725a845 (info_TEXINFOS): Renamed from TEXINFOS. 1996-02-13 05:21:44 +00:00
Jim Meyering
e70623f196 (CONFIG_HEADER): Don't define. Automake now does it. 1996-02-13 05:21:12 +00:00
Jim Meyering
862593b1f7 . 1996-02-13 05:17:50 +00:00
Jim Meyering
215318944a . 1996-02-13 03:24:52 +00:00
Jim Meyering
58e02de834 [.TRUE]: Undefine before defining.
[FALSE]: Undefine before defining.
From Derek Clegg (dclegg@next.com).
1996-02-13 03:12:52 +00:00
Jim Meyering
e02a4a825a . 1996-02-13 03:12:38 +00:00
Jim Meyering
73c74c0303 (canon_host): Cast returned he->h_name to char*. 1996-02-04 13:22:22 +00:00
Jim Meyering
2d882a7200 . 1996-02-04 12:47:33 +00:00
Jim Meyering
d2a3720ad0 . 1996-02-03 22:20:54 +00:00
Jim Meyering
e6777f1523 . 1996-02-03 03:24:22 +00:00
Jim Meyering
41d5fb8189 (main): Decalare local, BS. 1996-02-01 06:16:57 +00:00
Jim Meyering
3480c29030 . 1996-02-01 06:14:18 +00:00
Jim Meyering
a5c268a9f9 __P-protect dcls. 1996-02-01 06:13:54 +00:00
Jim Meyering
4f3121b654 . 1996-02-01 06:11:41 +00:00
Jim Meyering
73b2951ffe . 1996-02-01 06:10:10 +00:00
Jim Meyering
46505987ea (main): Accept new option, --rfc-822 (-R).
(show_date): Use RFC822-mandated strftime format.
From H. Peter Anvin (hpa@storm.net).
(usage): Add a line describing the new option.
1996-02-01 05:44:59 +00:00
Jim Meyering
bf58f8aea9 . 1996-02-01 05:44:38 +00:00
Jim Meyering
6c52fbcdfd (add_num_tz): New function.
(strftime): Handle new %z format.
From H. Peter Anvin (hpa@storm.net).
Don't use local, LENGTH, before it's defined.
1996-02-01 05:40:32 +00:00
Jim Meyering
e76eb59d84 (main): New options --human-readable (-h) and --megabytes (-m).
(human_readable_1k_blocks): New function.
(print_header): Honor new options.
(show_dev): Honor new options.
Add ifdef'd-out code to avoid printing lines for mount points that
match ^/auto/.* and ^/tmp_mnt.*.  Rather than hard-coding those
two prefixes, the code should allow the user to specify a regular
expression.  From Larry McVoy (lm@sgi.com).

(human_readable_1k_blocks): Likewise
(usage): Update usage message to reflect additions.
1996-02-01 05:30:14 +00:00
Jim Meyering
5b093c28e1 . 1996-02-01 05:29:26 +00:00
Jim Meyering
9d3b949aa6 . 1996-02-01 05:26:35 +00:00
Jim Meyering
a468d7579f (dump_remainder): Flush stdout when tailing-forever on multiple files.
From Carlos Canau <Carlos.Canau@relay.puug.pt>.
1996-02-01 05:25:54 +00:00
Jim Meyering
4eb32cb4f2 . 1996-02-01 05:22:08 +00:00
Jim Meyering
8f08533808 . 1996-02-01 04:22:48 +00:00
Jim Meyering
3b69e6514c Remove comma after last item in enum.
(human_readable): Fix off-by-one error that converted
1024*1024 to 1024K rather than 1G.  Describe the function.
1996-02-01 04:13:26 +00:00
Jim Meyering
9018ec3d41 (skip): Change type of parameter #5 from char* to unsigned char* to match
type of argument.
(copy): Cast first arg in memset call to char* to avoid warnings from
SunOS's acc.
(copy_simple): Likewise.
1996-02-01 03:50:06 +00:00
Jim Meyering
5d16193294 (getdate.c, posixtm.c): Add rules for building these. 1996-02-01 03:43:49 +00:00
Jim Meyering
61b305d30d (DIST_OTHER): Add perm.texi and getdate.texi. Remove mdate-sh. 1996-02-01 03:42:56 +00:00
Jim Meyering
efc9004234 . 1996-01-31 17:01:05 +00:00
Jim Meyering
ba733f2d38 . 1996-01-31 14:53:02 +00:00
Jim Meyering
34a122edc8 . 1996-01-30 01:27:32 +00:00
Jim Meyering
a5afd877aa . 1996-01-26 05:25:09 +00:00
Jim Meyering
1289479fce . 1996-01-25 12:00:18 +00:00
Jim Meyering
7bfb13dea7 Tweak usage. 1996-01-20 14:27:56 +00:00
Jim Meyering
744d31d57a (main): New options --human-readable (-h) and --megabytes (-m).
(human_readable): New function.
From Larry McVoy (lm@sgi.com).
1996-01-20 14:26:04 +00:00
Jim Meyering
a58305d61e . 1996-01-20 12:41:13 +00:00
Jim Meyering
3bd2561144 . 1996-01-20 12:37:23 +00:00
Jim Meyering
156a61c86d (usage): Copy backup/suffix stuff from ln.c.
(main): Handle 'S' in getopt switch.
1996-01-20 12:37:12 +00:00
Jim Meyering
5850877aea (BUILT_SOURCES): Set to posixtm.c getdate.c. 1996-01-20 12:35:06 +00:00
Jim Meyering
847dcc878b . 1996-01-20 12:33:59 +00:00
Jim Meyering
84791e75cc . 1996-01-20 12:22:38 +00:00
Jim Meyering
e30230223c Year is 6th field, not 7th. 1996-01-20 12:18:50 +00:00
Jim Meyering
884e63790c . 1996-01-20 12:11:48 +00:00
Jim Meyering
a0b8bf89d3 . 1996-01-19 17:39:42 +00:00
Jim Meyering
c3e64b1b2d (copy_files): Accept backup options just as cp, ln, and
mv do: --backup (-b).  From Marty Leisner <leisner@sdsp.mc.xerox.c>.
1996-01-19 17:39:06 +00:00
Jim Meyering
2131b2e9d5 Protoize. 1996-01-19 16:05:23 +00:00
Jim Meyering
6981af01ee . 1996-01-19 16:00:29 +00:00
Jim Meyering
863c253425 (argdecode): Declare parameter const. 1996-01-17 17:50:08 +00:00
Jim Meyering
08d800d44e (advance): Protoize function. 1996-01-17 17:46:12 +00:00
Jim Meyering
e23e3f656a Break some long lines.
Add const attribute to a few parameters.
1996-01-17 17:44:22 +00:00
Jim Meyering
4ad4b8aaec (integer_arg): Use xstrtol instead of open-coding this. 1996-01-17 17:41:00 +00:00
Jim Meyering
0f32a82524 (.su_SOURCES): Add xstrtol.c.
(HEADERS): Add xstrtol.h.
1996-01-17 17:38:27 +00:00
Jim Meyering
2a0d3143dd (visible): Change parameter type to unsigned int from unsigned char. 1996-01-17 17:20:41 +00:00
Jim Meyering
6e867c19c9 Protoize and __P-protect forward dcls. 1996-01-17 17:19:07 +00:00
Jim Meyering
c78152220a Indent cpp directives. 1996-01-14 04:31:59 +00:00
Jim Meyering
be2519d4dd . 1996-01-14 04:19:34 +00:00
Jim Meyering
9800c1597f Include config.h. 1996-01-14 04:18:48 +00:00
Jim Meyering
2bf12371d8 . 1996-01-08 06:15:59 +00:00
Jim Meyering
7243acff2a . 1996-01-08 06:15:20 +00:00
Jim Meyering
bfa30819b9 . 1996-01-08 04:54:29 +00:00
Jim Meyering
ac5e053d8f . 1996-01-08 04:53:30 +00:00
Jim Meyering
13751495a1 (print_element): Change type of argument from char
to int to avoid potential promotion problem.
1996-01-07 04:08:44 +00:00
Jim Meyering
1d2f218bff (print_esc_char): Change type of argument from char to int to avoid
potential promotion problem.
1996-01-07 04:06:41 +00:00
Jim Meyering
00b953713e Fix typo in __P use. 1996-01-07 04:04:48 +00:00
Jim Meyering
ed4a024430 . 1996-01-06 11:57:17 +00:00
Jim Meyering
53398947a1 Protoize and __P-protect forward dcls. 1996-01-06 11:44:05 +00:00
Jim Meyering
5e14cce7ae Define WHO and include new file, who-users.c. 1996-01-06 11:17:50 +00:00
Jim Meyering
27276e481d . 1996-01-06 11:16:08 +00:00
Jim Meyering
7949927db6 rename from who.c 1996-01-06 11:13:11 +00:00
Jim Meyering
634853cee6 Remove NGROUPS_MAX junk. It wasn't being used. 1996-01-06 06:10:08 +00:00
Jim Meyering
0f100b0d3f (putenv): Declare.
(universal_time): Remove.
(main): If -u is given, set TZ to "UTC0"; this causes date to use
UTC uniformly and fixes bugs in the handling of date -u +'%s %Z'.
(show_date): Just use localtime and a single format, since TZ will
be set properly if -u is given.  From Paul Eggert.
1996-01-06 06:07:23 +00:00
Jim Meyering
83adf65c37 Remove no-longer-used NGROUPS_MAX cpp macros.
(print_group_list) [HAVE_GETGROUPS]: Reorganize to use getgroups (0, NULL)
to compute number of groups at run time rather than relying on NGROUPS_MAX
at compile time.
(print_full_info) [HAVE_GETGROUPS]: Likewise.
Suggestion from Roland McGrath.
1996-01-06 06:04:09 +00:00
Jim Meyering
67b467223a . 1996-01-06 05:28:49 +00:00
Jim Meyering
2e6b75c735 . 1996-01-06 00:30:45 +00:00
Jim Meyering
0ec5eacc92 . 1996-01-05 04:56:53 +00:00
Jim Meyering
b024130dc2 . 1996-01-05 02:46:41 +00:00
Jim Meyering
aff66fa170 Include rx.h after limit.h to avoid warning about
redeclaration of RE_DUP_MAX in limit.h.  rx.h protects its
definition.  From Kaveh Ghazi.
1996-01-05 02:44:42 +00:00
Jim Meyering
92e8245d90 . 1996-01-05 02:37:28 +00:00
Jim Meyering
c300ac7a4d [SYNTAX]: Rename from SYNTAX_TABLE.
[SYNTAX_TABLE]: Remove extern dcl or re_syntax_table.
(RE_SEARCH_2_FN): Cast string1 and string2 to avoid pointer type
mismatch errors from e.g. SunOS's /bin/cc.
Reported by Kaveh Ghazi.
1996-01-05 02:35:39 +00:00
Jim Meyering
67b836ed72 . 1996-01-04 12:48:25 +00:00
Jim Meyering
388569f846 . 1996-01-04 05:35:34 +00:00
Jim Meyering
981d081027 (usage): Tweak wording in --help output. 1996-01-04 05:31:58 +00:00
Jim Meyering
6a7bd50a0b Use $year', not year' as expr arg. 1996-01-04 05:29:09 +00:00
Jim Meyering
f280d719f3 update from gettext 1996-01-04 05:24:48 +00:00
Jim Meyering
1d39399861 . 1996-01-03 18:20:16 +00:00
Jim Meyering
008d74220b . 1996-01-03 06:04:46 +00:00
Jim Meyering
0f0189167b Fix comments. 1996-01-03 05:55:26 +00:00
Jim Meyering
bf6bcd3c16 . 1996-01-03 05:51:15 +00:00
Jim Meyering
b439039b9b . 1996-01-03 05:49:22 +00:00
Jim Meyering
2cada8c970 . 1996-01-02 06:10:49 +00:00
Jim Meyering
360b2870d8 (keycompare): Rewrite cases handling -i and -if to fix bug whereby
non-ascii characters (supposed to be ignored with -i) were treated
as significant.  Reported by Carl Johnson <carlj@cjlinux.home.org>.
1996-01-02 06:10:39 +00:00
Jim Meyering
b669dbd1ad 14b: Just like 14a, but add -f. 1996-01-02 00:15:46 +00:00
Jim Meyering
b81692a8a9 Correct 14a per manual. 1996-01-01 23:55:02 +00:00
Jim Meyering
dfa0cede72 . 1996-01-01 22:33:52 +00:00
Jim Meyering
add1d7c11f . 1995-12-31 06:46:46 +00:00
Jim Meyering
221ef68cc3 . 1995-12-31 04:12:10 +00:00
Jim Meyering
a7190a7381 (extract_regexp) [!WITH_REGEX]: Initialize re_compiled.syntax_parens.
From Andreas Schwab.
1995-12-31 04:10:13 +00:00
Jim Meyering
f721ed2bf4 . 1995-12-26 05:50:19 +00:00
Jim Meyering
6dde9c58fe . 1995-12-23 18:19:26 +00:00
Jim Meyering
f1a5372cbc . 1995-12-23 17:39:21 +00:00
Jim Meyering
c22b040b21 (decode_switches): Make -o a synonym for -lG for compatibility
with most other versions of ls.  Reported by Karl Berry.
(usage): Update.
1995-12-23 17:38:08 +00:00
Jim Meyering
0c5abc43a0 . 1995-12-23 16:39:20 +00:00
Jim Meyering
d5f4d5f22e (usage): Align text in -n line. 1995-12-22 15:30:31 +00:00
Jim Meyering
2a5c6dea54 . 1995-12-22 06:51:26 +00:00
Jim Meyering
05d30f2715 (cleanup): New function -- broken out from quit.
(interrupt_handler): Rewrite to reset default signal handler,
call cleanup, then repost caught signal.
1995-12-22 06:49:10 +00:00
Jim Meyering
c8d085374c . 1995-12-22 06:39:47 +00:00
Jim Meyering
9ceb93e7ff . 1995-12-22 05:31:58 +00:00
Jim Meyering
b808e70940 Include argmatch.h. 1995-12-22 05:31:17 +00:00
Jim Meyering
654ad9e596 (main): Accept new option, --sparse={never,auto,always},
to control creation of sparse files.
(copy_reg): Set local, make_holes, from global flag_sparse.
Include argmatch.h.
1995-12-22 05:30:48 +00:00
Jim Meyering
8cff7ef2b9 (argmatch): Add const attribute to parameters.
(invalid_arg): Add const attribute to parameters.
1995-12-22 05:17:31 +00:00
Jim Meyering
137cf55755 . 1995-12-22 05:16:11 +00:00
Jim Meyering
ddc22e05ab . 1995-12-22 05:15:35 +00:00
Jim Meyering
42fcbf3950 (HEADERS): Add argmatch.h. 1995-12-21 23:06:40 +00:00
Jim Meyering
11f5ed65ba . 1995-12-21 23:05:56 +00:00
Jim Meyering
99cf57df5f . 1995-12-20 05:47:35 +00:00
Jim Meyering
b71a140977 . 1995-12-19 04:31:06 +00:00
Jim Meyering
e49897affc [SYMBOLIC_SPACE_STRING]: New macro.
(do_link): Use it instead of open-coded #ifdef.
For --verbose, say `create link DEST to SRC' instead of ambiguous
(or inconsistent with cp -v and mv -v) `SRC -> DEST.'
1995-12-19 04:30:32 +00:00
Jim Meyering
2ef6cb6073 . 1995-12-19 04:25:24 +00:00
Jim Meyering
4db03fe797 . 1995-12-19 03:46:25 +00:00
Jim Meyering
8506a6bc2a (noinst_LIBRARIES): Define this, not plain LIBRARIES. 1995-12-17 22:28:45 +00:00
Jim Meyering
8303c90f14 . 1995-12-15 15:40:40 +00:00
Jim Meyering
a530d04879 . 1995-12-15 15:38:09 +00:00
Jim Meyering
4a99368c87 new version from FSF 1995-12-15 15:36:02 +00:00
Jim Meyering
46faa9979f new version from FSF 1995-12-15 15:35:15 +00:00
Jim Meyering
c038102c6a Apply the usual REL_ALLOC patch. 1995-12-15 15:34:07 +00:00
Jim Meyering
23cfe44342 new, from FSF 1995-12-15 15:33:36 +00:00
Jim Meyering
b3d7a51157 Remove trailing white space. 1995-12-15 15:31:09 +00:00
Jim Meyering
23f91764bc Include config.h. 1995-12-15 15:18:43 +00:00
Jim Meyering
2ab1921d24 Update from latest. 1995-12-15 15:12:58 +00:00
Jim Meyering
1c2d713cab . 1995-12-15 04:52:36 +00:00
Jim Meyering
395224e372 . 1995-12-15 03:40:06 +00:00
Jim Meyering
43cdd09d2d (main): Use xstrtol instead of atoi. 1995-12-15 03:34:34 +00:00
Jim Meyering
de6c7a9b78 (nl): Change --first-page to --starting-line-number. 1995-12-15 03:25:59 +00:00
Jim Meyering
7d7530446c . 1995-12-15 03:20:50 +00:00
Jim Meyering
208fa17ad0 (main): Use xstrtol instead of atoi. 1995-12-15 03:20:40 +00:00
Jim Meyering
5a1b7d267a (main): Use xstrtol instead of atoi.
Rename misleading --first-page=N option to --starting-line-number=N.
(usage): Update.
1995-12-15 03:20:18 +00:00
Jim Meyering
1bcceb8ba4 (main): Use xstrtol instead of atoi.
(fold_file): Make a couple locals `int', not size_t, and cast
fwrite's arg3 to size_t.
1995-12-15 03:19:51 +00:00
Jim Meyering
e0bcf6c00d . 1995-12-09 04:06:38 +00:00
Jim Meyering
0a5f63aee2 . 1995-12-09 04:00:17 +00:00
Jim Meyering
2008517b36 . 1995-12-09 02:52:17 +00:00
Jim Meyering
517bef6ccd . 1995-12-08 22:44:18 +00:00
Jim Meyering
e2db29a312 . 1995-12-08 22:39:38 +00:00
Jim Meyering
a3fa97f5e3 . 1995-12-08 20:19:49 +00:00
Jim Meyering
7fc45bccbd . 1995-12-08 20:18:40 +00:00
Jim Meyering
7d3a280b7a Add copyright. 1995-12-08 04:50:48 +00:00
Jim Meyering
be60b8e319 . 1995-12-07 23:42:31 +00:00
Jim Meyering
4090d52520 . 1995-12-06 23:40:00 +00:00
Jim Meyering
1f88c647cd [!WITH_REGEX]: Include rx.h. 1995-12-06 23:39:26 +00:00
Jim Meyering
08b596b409 fix typos. From Karl Heuer. 1995-12-06 23:26:20 +00:00
Jim Meyering
e625640bd0 (main): Diagnose improper form of arguments to -k, then fail. 1995-12-05 23:50:43 +00:00
Jim Meyering
a6a2dbc63c (main): Diagnose improper form of arguments to -k, then fail.. 1995-12-05 23:50:18 +00:00
Jim Meyering
5c3c1931dd (rm): Work around SunOS 4 bug whereby lstat doesn't fail
when given a zero-length file name argument.  Reported by
Mark Calabretta <mcalabre@atnf.csiro.au>.
1995-12-05 23:39:06 +00:00
Jim Meyering
d75c1aaea1 . 1995-12-05 23:38:40 +00:00
Jim Meyering
f1a905664b . 1995-12-05 17:54:59 +00:00
Jim Meyering
5cf455d736 (numcompare): Properly handle all cases in which signs differ. From Karl Heuer. 1995-12-05 17:53:39 +00:00
Jim Meyering
8ef322d66f (bsd_sum_file): Remove misleading comment. From Karl Heuer. 1995-12-05 15:53:31 +00:00
Jim Meyering
1d5b09348e . 1995-12-04 16:29:54 +00:00
Jim Meyering
5782ca8976 Update to look like the one from textutils. 1995-12-03 04:36:25 +00:00
Jim Meyering
623ce837c7 make like the one in textutils 1995-12-02 04:29:17 +00:00
Jim Meyering
73f21f7813 . 1995-12-01 07:40:46 +00:00
Jim Meyering
a8377ab773 . 1995-12-01 07:38:16 +00:00
Jim Meyering
5106e930d1 Exercise bug re comparing `-' and integers. 1995-12-01 07:32:12 +00:00
Jim Meyering
74b4707ea6 treat `-' as if it were zero. Reported by Ross Alexander
<r.alexander@auckland.ac.nz>.
1995-12-01 07:03:47 +00:00
Jim Meyering
99b8fcfb0d . 1995-11-30 21:00:06 +00:00
Jim Meyering
5df13c9b0a . 1995-11-30 20:59:37 +00:00
Jim Meyering
5eeef11a3b standardizing... 1995-11-30 20:26:33 +00:00
Jim Meyering
cfbca54a71 . 1995-11-30 20:08:07 +00:00
Jim Meyering
f0f6a9c44e . 1995-11-30 20:06:49 +00:00
Jim Meyering
cc1a9180a7 . 1995-11-30 20:06:11 +00:00
Jim Meyering
155639bf0f Lots of new tests -- related to -k2,2 bug and non-functional -b and `b'. 1995-11-30 20:06:06 +00:00
Jim Meyering
c0f51577fd . 1995-11-30 19:42:58 +00:00
Jim Meyering
efac765819 . 1995-11-30 04:34:22 +00:00
Jim Meyering
1c7a2ac60f . 1995-11-30 04:34:06 +00:00
Jim Meyering
f4b094e098 . 1995-11-30 04:32:31 +00:00
Jim Meyering
e984b74461 . 1995-11-30 04:28:27 +00:00
Jim Meyering
c1e61448b3 . 1995-11-30 03:51:59 +00:00
Jim Meyering
2f077ef41f (limfield): Remove field_start junk.
Don't try to trim trailing blanks here -- it's not possible
because we don't know where the field begins.
Properly distinguish between cases where TAB character is specified
and when the default is used.
(trim_trailing_blanks): New function.
(findlines): Call it.
(keycompare): Likewise.
1995-11-29 22:51:04 +00:00
Jim Meyering
cfc48b6ee9 [_]: Define it. 1995-11-29 19:47:42 +00:00
Jim Meyering
073c4cb543 Mark all translatable strings using po-mode.el. 1995-11-29 19:24:52 +00:00
Jim Meyering
8bacb0720c Mark all translatable strings using po-mode.el. 1995-11-29 19:23:30 +00:00
Jim Meyering
da8c36f53f (begfield): Replace unnecessary loop with if-else.
(limfield): Fix bug that made field specs like -k1.5 return a
pointer into LINE beyond the first field.
Rewrite to properly ignore trailing blanks.
Replace unnecessary loop with if-else.
(main): Don't decrement T2 corresponding to `x' in field specs like -ku.v,w.x.
1995-11-28 20:07:17 +00:00
Jim Meyering
83cf5efca9 Tests for bug reported by Roger Peel" <R.Peel@ee.surrey.ac.uk> 1995-11-28 16:52:49 +00:00
Jim Meyering
4d9669b8d9 . 1995-11-27 14:25:39 +00:00
Jim Meyering
18573f3eb2 (usage): Clarify description of --no-dereferences. 1995-11-27 05:46:24 +00:00
Jim Meyering
57ec0f45c9 s/non-zero/nonzero/g 1995-11-27 05:34:31 +00:00
Jim Meyering
a7830ac93b . 1995-11-27 05:29:44 +00:00
Jim Meyering
488bd9911e . 1995-11-27 03:11:36 +00:00
Jim Meyering
7956c15081 s/non-zero/nonzero/g 1995-11-27 03:09:18 +00:00
Jim Meyering
0402200daf Clarify usage. From Karl Berry. 1995-11-26 22:09:43 +00:00
Jim Meyering
dc0708fa82 . 1995-11-26 21:51:42 +00:00
Jim Meyering
7b9ad5a22f [!UINT_MAX]: Define.
[!INT_MAX]: Define.
Include xstrtoul.h.
(string_to_number): Remove function.
(check_for_offset): Use xstrtoul instead of string_to_number.
(parse_repeat_count): Likewise.
(parse_patterns): Likewise.
(main): Likewise.
1995-11-26 21:49:53 +00:00
Jim Meyering
c4e9f56745 . 1995-11-24 05:29:28 +00:00
Jim Meyering
b69a467146 . 1995-11-23 05:17:50 +00:00
Jim Meyering
75cce0c815 . 1995-11-18 20:19:17 +00:00
Jim Meyering
546754d2e9 . 1995-11-18 18:17:42 +00:00
Jim Meyering
e8f8b7a82d Remove autodep junk. 1995-11-18 06:36:47 +00:00
Jim Meyering
c54a604289 Indent cpp directives. 1995-11-18 06:17:07 +00:00
Jim Meyering
f52e14c576 . 1995-11-17 03:41:20 +00:00
Jim Meyering
a0aef26c06 . 1995-11-17 03:29:26 +00:00
Jim Meyering
4d4a6210f7 Remove obsolete FIXME. 1995-11-16 07:39:44 +00:00
Jim Meyering
a5ad9a2579 . 1995-11-16 07:32:45 +00:00
Jim Meyering
79d6ddd36a Fix up description of md5sum --check. 1995-11-16 06:18:17 +00:00
Jim Meyering
18da62e303 . 1995-11-15 23:41:08 +00:00
Jim Meyering
77469b714b (*format_address): Tweak dcl. 1995-11-15 22:16:30 +00:00
Jim Meyering
1fbac54162 [__P]: Don't define it here. 1995-11-15 22:12:59 +00:00
Jim Meyering
cf14c509f3 Use __P. 1995-11-15 21:59:55 +00:00
Jim Meyering
02bde8d334 . 1995-11-15 21:59:20 +00:00
Jim Meyering
e99f534046 . 1995-11-15 21:58:58 +00:00
Jim Meyering
aeac9910cb . 1995-11-15 21:48:06 +00:00
Jim Meyering
f84513b43e (sort, -g): Document it.
(join, new `0' format): Likewise.
1995-11-15 21:47:44 +00:00
Jim Meyering
34fc818d7e Add support for sorting numbers in scientific notation.
Include xstrtod.h.
(struct keyfield): Add field: general_numeric.
(usage): Describe -g option.
(general_numcompare): New function.
(keycompare): Use new comparison function when general_numeric
flag is set.
(set_ordering): Honor `g' flag.
(main): Initialize and use new field.
From Marcus Daniels <marcus@sysc.pdx.edu>.
1995-11-15 21:42:47 +00:00
Jim Meyering
f1e1eb58be Break long lines. 1995-11-15 15:45:28 +00:00
Jim Meyering
3d6c17e94f Indent. 1995-11-15 15:04:51 +00:00
Jim Meyering
ef3e297950 . 1995-11-15 05:40:11 +00:00
Jim Meyering
5cf3719e7b (cleanup): Don't exit.
(cleanup_fatal): New function.  Call cleanup, then exit.
(sighandler): New function.
(cleanup_fatal): Renamed from cleanup.  Call cleanup, then exit.
Update callers.
(tac_stdin): Set up sighandler as signal handler, not `cleanup'.
1995-11-15 05:39:58 +00:00
Jim Meyering
b36e366ef4 (cleanup): Don't exit.
(cleanup_fatal): New functoin.  Call cleanup, then exit.
(interrupt_handler): Rewrite to reset default signal handler
then repost caught signal.
(xmalloc, xrealloc, read_input, write_to_file, handle_line_error,
process_line_count, process_regexp, create_output_file, close_output_file):
Call cleanup_fatal, not cleanup.
Add const attribute to lots of parameters.
1995-11-15 05:32:28 +00:00
Jim Meyering
c2b86aabe0 . 1995-11-11 22:09:47 +00:00
Jim Meyering
849a1c46cf (skip): Cast fseek's offset argument to `long'.
Erik Bennett <bennett@cvo.oneworld.com> reported that this is
necessary on BSDI systems.  And if offset doesn't fit in a long,
then try using lseek instead.
1995-11-11 22:08:16 +00:00
Jim Meyering
7c863aef95 . 1995-11-11 21:46:41 +00:00
Jim Meyering
cc7705fe6f (xmalloc): Declare static.
(xrealloc): Likewise.
1995-11-11 21:46:32 +00:00
Jim Meyering
e97b60d16a . 1995-11-11 14:36:06 +00:00
Jim Meyering
1b1382a3a9 (cleanup): Add signal number parameter.
Update callers.
1995-11-11 14:35:27 +00:00
Jim Meyering
ff0e048521 . 1995-11-11 14:22:33 +00:00
Jim Meyering
0af7afd19f . 1995-11-11 14:21:24 +00:00
Jim Meyering
24aec7f87f (main): Don't die when dev/ino of input and output are
the same and the file descriptors correspond to stdin and stdout.
This is necessary on at least Digital UNIX (aka OSF1) 3.2C.
Otherwise, running `cat << X > $$' would fail with `cat: -: input
file is output file'.  From Jarkko Hietaniemi <jhi@epsilon.hut.fi>.
1995-11-11 14:21:15 +00:00
Jim Meyering
acb7c4ee48 Add __P in dcl of format_address function. 1995-11-11 03:28:38 +00:00
Jim Meyering
5796c221a1 (usage): Clarify meaning of --spaces. 1995-11-11 03:27:15 +00:00
Jim Meyering
dde28b7ffe Don't include error.h here. 1995-11-10 15:20:00 +00:00
Jim Meyering
dfa21e5966 . 1995-11-10 15:15:38 +00:00
Jim Meyering
8014db4d68 Protect prototyped forward dcls with __P. 1995-11-10 14:56:21 +00:00
Jim Meyering
c6394074a8 (parse_ls_color): Use strcpy to initialize 3-character array.
Automatic aggregate initialization isn't portable.
1995-11-10 14:54:08 +00:00
Jim Meyering
83ce0dcba6 Remove fwd dcls. 1995-11-10 14:48:57 +00:00
Jim Meyering
9a69ea769a Don't protoize dcl of basename. 1995-11-10 14:48:03 +00:00
Jim Meyering
3044600151 Don't protoize dcl of basename. 1995-11-10 14:47:09 +00:00
Jim Meyering
da6d91f64b Don't protoize dcls of getpwnam and getgrnam. 1995-11-10 14:45:31 +00:00
Jim Meyering
c6ca8a1528 Remove bogus __P junk on xstat dcl. 1995-11-10 14:44:37 +00:00
Jim Meyering
8108bc26d6 Don't protoize fwd dcl of dirname. 1995-11-10 14:43:31 +00:00
Jim Meyering
908b4d6cb9 . 1995-11-10 14:42:39 +00:00
Jim Meyering
0683df4bf8 Protoize and add const attribute to parameters. 1995-11-10 14:42:08 +00:00
Jim Meyering
05907fc584 Include error.h. 1995-11-10 14:41:20 +00:00
Jim Meyering
ca56751421 Remove prototypes for stat, lstat. 1995-11-10 14:22:07 +00:00
Jim Meyering
dd084ce340 [__P]: Define it. 1995-11-10 12:56:15 +00:00
Jim Meyering
92278a462b . 1995-11-10 05:28:05 +00:00
Jim Meyering
ca56be1e3e . 1995-11-10 05:27:29 +00:00
Jim Meyering
09f8e7fb03 (main): Move to the end.
Remove fwd dcls.
1995-11-10 03:16:16 +00:00
Jim Meyering
c2e9e7a31b (main): Move to the end.
Remove fwd dcls.
1995-11-10 03:14:41 +00:00
Jim Meyering
49f397e6e7 Rearrange functions to obviate forward dcls.
Remove forward dcls.
1995-11-09 23:52:40 +00:00
Jim Meyering
6161f25abc (main): Move to the end.
Remove fwd dcls.
1995-11-09 23:49:53 +00:00
Jim Meyering
0898b54377 (main): Move to the end.
Remove fwd dcls.
1995-11-09 23:49:02 +00:00
Jim Meyering
6f1c4b7a75 Protect prototypes with __P. 1995-11-09 23:47:52 +00:00
Jim Meyering
b7b00aad08 Protect prototypes with __P. 1995-11-09 23:41:10 +00:00
Jim Meyering
ec2a94a410 (main): Move to the end.
Remove most fwd dcls.
1995-11-09 23:31:16 +00:00
Jim Meyering
4796ddfe36 (main): Move to the end.
Remove most fwd dcls.
1995-11-09 23:27:55 +00:00
Jim Meyering
31856b16c3 indent. 1995-11-09 23:27:32 +00:00
Jim Meyering
6732422b97 (main): Move to the end.
Remove most fwd dcls.
1995-11-09 23:26:17 +00:00
Jim Meyering
2b3ce6fab9 Move main to the end.
Remove fwd dcls.
1995-11-09 23:16:13 +00:00
Jim Meyering
b951477c80 (translate_charset): Make parameter `const'. 1995-11-09 23:02:27 +00:00
Jim Meyering
0bf332a016 (struct pathstack): Move dcl to precede prototypes. 1995-11-09 23:00:32 +00:00
Jim Meyering
3e12088cf0 (enum filetype): Move dcl to precede prototypes.
(struct fileinfo): Likewise.
Add const attribute to some parameters.
1995-11-09 23:00:14 +00:00
Jim Meyering
c0d94c89ec Protoize. 1995-11-09 17:02:23 +00:00
Jim Meyering
dd3a088973 . 1995-11-08 05:55:55 +00:00
Jim Meyering
5c15113c49 . 1995-11-08 05:54:16 +00:00
Jim Meyering
553eb65acd (usage): Clarify descriptions of ignpar and ignbrk.
From Theodore Ts'o and Ulrich Windl.
1995-11-08 05:54:07 +00:00
Jim Meyering
0c43179cf9 Remove trailing white space. 1995-11-08 05:51:11 +00:00
Jim Meyering
b031f89b29 Clarify descriptions of ignpar and ignbrk.
From Theodore Ts'o and Ulrich Windl.
1995-11-08 05:50:51 +00:00
Jim Meyering
b7df779b8b New option: --verbose.
(main): Recognize it.
(usage): Document it.
From Marty Leisner <leisner@sdsp.mc.xerox.com>.
1995-11-07 04:56:08 +00:00
Jim Meyering
96ed803f48 . 1995-11-07 04:55:16 +00:00
Jim Meyering
fd798dd6fe From FSF. 1995-11-06 17:06:24 +00:00
Jim Meyering
dd8b68966f . 1995-11-06 16:24:07 +00:00
Jim Meyering
72ce8c67c5 (usage): Remove last sentence. It is redundant. 1995-11-06 14:01:46 +00:00
Jim Meyering
22132a47aa [__P]: Define. Use it in prototyped forward decls. 1995-11-06 05:06:25 +00:00
Jim Meyering
0705aa7388 (store_columns): Remove spurious 2nd argument in call to read_line. 1995-11-06 05:01:16 +00:00
Jim Meyering
762769cf3b Protoize. 1995-11-06 04:58:56 +00:00
Jim Meyering
82eae6c9b5 (join): Protoize. Somehow, protoize missed this one. 1995-11-05 16:58:15 +00:00
Jim Meyering
86f04e3bb3 . 1995-11-05 13:16:57 +00:00
Jim Meyering
ce5f4177bc Protect prototypes with __P. 1995-11-05 13:16:24 +00:00
Jim Meyering
48f3bca87e Move prototypes after struct declarations.
Remove prototypes for xmalloc, xrealloc.
(new_control_record): Cast arg 1 to realloc.
1995-11-05 13:12:54 +00:00
Jim Meyering
adf0ec7008 Protoize. 1995-11-05 13:02:44 +00:00
Jim Meyering
5b4dde5a7b [__P]: Test PROTOTYPES, not __STDC__.
Protoize.
1995-11-05 12:59:52 +00:00
Jim Meyering
2224409994 (close_output_file): Set output_stream to NULL so we don't recurse
endlessly between this function and cleanup.
1995-11-05 05:51:53 +00:00
Jim Meyering
30d11429a9 (unquote): Add casts to avoid signed char* from/to char* warnings. 1995-11-05 05:48:57 +00:00
Jim Meyering
c4176dd559 . 1995-11-03 20:03:44 +00:00
Jim Meyering
47d5042d1e . 1995-11-03 20:03:18 +00:00
Jim Meyering
6df632b672 New version from glibc. 1995-11-03 20:02:00 +00:00
Jim Meyering
6875b205d6 (remove_file, remove_dir): Use euidaccess instead of euidaccess_stat.Likewise. 1995-11-03 20:01:13 +00:00
Jim Meyering
47306242ec (do_move): Use euidaccess instead of euidaccess_stat.Likewise. 1995-11-03 20:00:24 +00:00
Jim Meyering
83780d95f0 (copy): Use euidaccess instead of euidaccess_stat. 1995-11-03 19:59:44 +00:00
Jim Meyering
5b804afa6a New version from glibc. 1995-11-03 19:56:08 +00:00
Jim Meyering
83b9d5e9ef Add `const' attribute to some parameters. 1995-11-02 17:11:51 +00:00
Jim Meyering
a2b0b9846d . 1995-11-02 17:11:17 +00:00
Jim Meyering
a0ad16498b . 1995-11-02 17:11:04 +00:00
Jim Meyering
aa084c8407 Protoize. 1995-11-02 17:08:24 +00:00
Jim Meyering
ac821ab1ef Reorder functions to obviate forward dcls.
Remove forward dcls.
1995-11-02 17:06:52 +00:00
Jim Meyering
6e146d4216 (isdigits, convint): Remove these.
(main): Use xstrtol instead.
1995-10-31 12:52:29 +00:00
Jim Meyering
e4a96fff58 . 1995-10-31 12:52:14 +00:00
Jim Meyering
aa6cde5ca1 Add `const' attribute to some parameters. 1995-10-31 12:39:18 +00:00
Jim Meyering
05a5e42609 protoize. 1995-10-31 12:36:43 +00:00
Jim Meyering
11a013bf87 Reorder functions to obviate forward dcls.
Remove forward dcls.
1995-10-31 12:34:48 +00:00
Jim Meyering
de4de17bc5 (usage, next_line_num, main): Protoize. 1995-10-31 02:22:23 +00:00
Jim Meyering
b0302bb3a6 Add `const' attribute to some parameters. 1995-10-31 02:21:37 +00:00
Jim Meyering
334f8dcbb7 Add `const' attribute to some parameters. 1995-10-31 02:21:13 +00:00
Jim Meyering
47eaf4a1e8 Protoize. 1995-10-30 21:01:35 +00:00
Jim Meyering
1e30b2f8c4 Reorder functions to obviate forward dcls.
Remove forward dcls.
1995-10-30 21:00:36 +00:00
Jim Meyering
84df8be864 (eaccess_stat): Make static. 1995-10-30 18:00:05 +00:00
Jim Meyering
f05befc26c (copy): Update one of the calls to eaccess_stat to use 3 arguments. Ugh! 1995-10-30 17:53:48 +00:00
Jim Meyering
96e22ecc78 . 1995-10-29 20:44:54 +00:00
Jim Meyering
9eb195d6a5 . 1995-10-29 20:44:14 +00:00
Jim Meyering
40f0f4d2e8 (xwrite): Give output buffer parameter const attribute.
(output): Likewise for both parameters.
(tac): Likewise for file name parameter.
(tac_file): Likewise.
1995-10-29 20:38:01 +00:00
Jim Meyering
4fa07774d6 protoize. 1995-10-29 20:35:11 +00:00
Jim Meyering
7567c84e76 Reorder functions to obviate forward dcls.
Remove forward dcls.
1995-10-29 20:33:04 +00:00
Jim Meyering
a87c771012 (bsd_sum_file): Give file name parameter const attribute.
(sysv_sum_file): Likewise.
1995-10-29 20:24:53 +00:00
Jim Meyering
a2535fc95f Protoize. 1995-10-29 20:20:08 +00:00
Jim Meyering
d2aaf842b4 (main): Move function body to end of file.
Remove forward dcls.
1995-10-29 20:19:26 +00:00
Jim Meyering
13e93efe91 (nl_file): Give parameter const attribute.
Protoize.
1995-10-29 20:15:54 +00:00
Jim Meyering
af1033c63c Reorder functions to obviate forward dcls.
Remove forward dcls.
1995-10-29 20:12:32 +00:00
Jim Meyering
768f92072f (main): Move function body to end of file.
Remove forward dcls and protoize.
1995-10-29 20:05:29 +00:00
Jim Meyering
8b92864e1d Rename --file to --reference.
Leave --file as an alias, for now.  It will be removed later.
(usage): Update, but don't mention --file.
1995-10-29 19:29:19 +00:00
Jim Meyering
d97d668b69 . 1995-10-29 19:28:59 +00:00
Jim Meyering
5d1c0a2af5 . 1995-10-29 19:21:08 +00:00
Jim Meyering
b1c9ce6621 [TEST_STANDALONE]: Define. 1995-10-29 19:20:36 +00:00
Jim Meyering
aec547d764 . 1995-10-29 19:20:12 +00:00
Jim Meyering
185c59d3bd (mostlyclean): Remove *.info. 1995-10-29 14:26:48 +00:00
Jim Meyering
f1c5cfd5f2 (distclean): Remove .deps. 1995-10-29 14:23:11 +00:00
Jim Meyering
c848009e29 . 1995-10-29 14:22:15 +00:00
Jim Meyering
a0d766c204 . 1995-10-29 14:20:13 +00:00
Jim Meyering
c1f248d670 (INCLUDE, COMPILE): New variables.
(.c.o): Rewrite to be more like src/Makefile.in.
Add line that (--with-autodeps) will include mkdep-Makefile.
1995-10-29 12:14:37 +00:00
Jim Meyering
9b1d63b4a3 . 1995-10-28 21:07:18 +00:00
Jim Meyering
c7262bbe86 *** empty log message *** 1995-10-28 21:04:08 +00:00
Jim Meyering
008028896b . 1995-10-28 21:02:57 +00:00
Jim Meyering
c5716550a6 (md5_check): Use the same message format when the single file has a
read error or checksum mismatch as when there are more.
Write diagnostic to stderr, not stdout.
1995-10-28 21:01:01 +00:00
Jim Meyering
b43f5fb25b . 1995-10-28 05:55:34 +00:00
Jim Meyering
013277d331 New option --reference=FILE (-r FILE) analogous to the
like-named touch option.
(main): Recognize it and give diagnostic for misuse.
(usage): Describe briefly.
From Franc,ois Pinard.

(batch_convert): Close input stream also when it's not stdin.
(main): Reorganize to do option-consistency checks before all else.
1995-10-28 05:52:24 +00:00
Jim Meyering
09eedba01f . 1995-10-28 05:51:44 +00:00
Jim Meyering
ca59b76b50 (batch_convert): Close input stream also when it's not stdin. 1995-10-27 15:12:31 +00:00
Jim Meyering
b9485b8d52 (main): Use xfopen, not xtmpopen to open final output file. 1995-10-26 13:20:25 +00:00
Jim Meyering
66b9285a6f (xtmpfopen): New function -- for opening temp files.
Use it instead of xfopen.
1995-10-26 13:19:10 +00:00
Jim Meyering
470e773e76 . 1995-10-26 05:14:53 +00:00
Jim Meyering
039942bfc1 (xfopen): Rewrite using open/fdopen in order to set
proper permissions on temporary files.  Reported by Erik Corry
(erik@kroete2.freinet.de).
1995-10-26 05:14:41 +00:00
Jim Meyering
a94e341d85 . 1995-10-24 04:24:06 +00:00
Jim Meyering
db98ca11cf . 1995-10-24 04:17:33 +00:00
Jim Meyering
22a5274de9 . 1995-10-21 12:52:05 +00:00
Jim Meyering
2ee6cf8ea0 . 1995-10-21 12:50:56 +00:00
Jim Meyering
baf81e4974 . 1995-10-20 04:29:00 +00:00
Jim Meyering
bda4a5e5b7 (BEGIN_STATE): Use INT_MAX - 1 so as not to interfere with large repeat counts.
(struct E_string): New struct.

(find_closing_delim): Take E_string arg rather than char* and length.
(find_bracketed_repeat): Likewise.
(star_digits_closebracket): New function.

(append_char_class): No longer give diagnostic.
(append_equiv_class): No longer give diagnostic.
(build_spec_list): Give them here instead, allowing things like [:*][:upper:]
that got errors before.
Take E_string arg rather than char*.
Convert switch stmts into if-then so as to use ES_MATCH.
1995-10-20 04:26:56 +00:00
Jim Meyering
0598102472 . 1995-10-19 22:40:10 +00:00
Jim Meyering
4aba8a55f2 . 1995-10-19 22:39:16 +00:00
Jim Meyering
6f6a35a9a1 Indent cpp directives. 1995-10-19 22:38:39 +00:00
Jim Meyering
d691ea7ebc (build_spec_list): Propagate interface change.
(parse_str): Likewise.
1995-10-19 15:42:45 +00:00
Jim Meyering
ca63ca90ab (struct E_string): Define.
(unquote): Convert string to E_string instead of overwriting input.
Backslash-escaped non-special characters are marked as quoted in E_string.
(build_spec_list): Convert outer switch stmt to an if-stmt.
(parse_str): Update sole caller of unquote.
1995-10-19 15:33:33 +00:00
Jim Meyering
43dd57eba9 New version from FSF. 1995-10-19 14:21:35 +00:00
Jim Meyering
6dd358e12d Break lines longer than 79-80 chars. 1995-10-19 13:29:34 +00:00
Jim Meyering
c73aa6b629 . 1995-10-19 04:10:45 +00:00
Jim Meyering
63b348b3a9 Use HAVE_SYS_WAIT_H, not _POSIX_VERSION in conditional
inclusion of sys/wait.h.
[endgrent]: Test !HAVE_ENDGRENT rather than _POSIX_SOURCE.
[endpwent]: Test !HAVE_ENDPWENT rather than _POSIX_SOURCE.
1995-10-18 22:05:29 +00:00
Jim Meyering
6181f175e3 Use HAVE_SYS_IOCTL_H, rather than !_POSIX_SOURCE || _AIX. 1995-10-18 22:05:06 +00:00
Jim Meyering
5a52e61271 (duplicate_entry): Always return 0 if !D_INO_IN_DIRENT, rather than
if _POSIX_SOURCE
1995-10-18 17:02:07 +00:00
Jim Meyering
e74c290ac7 . 1995-10-18 16:33:52 +00:00
Jim Meyering
5ea57c875d . 1995-10-18 16:28:14 +00:00
Jim Meyering
492b177ca5 (main): Fail if the same file system type was both selected and excluded. 1995-10-18 16:11:58 +00:00
Jim Meyering
daa976fff6 [endgrent]: Test !HAVE_ENDGRENT rather than _POSIX_SOURCE. 1995-10-18 16:08:13 +00:00
Jim Meyering
871d176f15 [endpwent]: Test !HAVE_ENDPWENT rather than _POSIX_SOURCE.
[endgrent]: Remove unused definition.
1995-10-18 16:07:44 +00:00
Jim Meyering
fc2e23b1ad [HAVE_ENDGRENT]: Define away endgrent.
[HAVE_ENDPWENT]: Define away endpwent.
1995-10-18 15:59:12 +00:00
Jim Meyering
1cde2ceb5c Use _POSIX_VERSION, not _POSIX_SOURCE. 1995-10-18 15:57:50 +00:00
Jim Meyering
539457f1ae Merge latest change from FSF. 1995-10-18 14:31:14 +00:00
Jim Meyering
b6ff24fb7f Get latest from FSF. 1995-10-18 14:29:16 +00:00
Jim Meyering
da20dc044a . 1995-10-18 03:48:29 +00:00
Jim Meyering
a42c7fe2d1 Prootize. 1995-10-18 03:45:44 +00:00
Jim Meyering
b792f7aa0e Add `const' attribute to dcls of lots of formals. 1995-10-17 14:01:00 +00:00
Jim Meyering
9242af95a3 Protoize. 1995-10-17 13:49:32 +00:00
Jim Meyering
9583179c1b Protoize. 1995-10-17 13:47:48 +00:00
Jim Meyering
d9dee002e6 Reorder functions to obviate forward dcls. Remove forward dcls. 1995-10-17 13:43:00 +00:00
Jim Meyering
434b809272 Reorder functions to obviate forward dcls. Remove forward dcls. 1995-10-17 13:39:44 +00:00
Jim Meyering
4feb3b1e06 Protoize. Reorder functions to obviate forward dcls. Remove forward dcls. 1995-10-17 13:35:26 +00:00
Jim Meyering
14390d1fed Protoize. Reorder functions to obviate forward dcls.
Remove forward dcls.
1995-10-17 13:13:19 +00:00
Jim Meyering
8831ffbec4 Protoize.
Reorder functions to obviate forward dcls.
Remove forward dcls.
1995-10-16 21:30:25 +00:00
Jim Meyering
45d4def5e4 Move struct dcls to precede dcls of file-scope variables.
(monthtab, keyhead): Separate variable dcls from type dcls.
1995-10-16 14:45:09 +00:00
Jim Meyering
b9c1393e5f (usage): Move function definition to precede uses and
remove remove forward dcl.
Protoize and add `const' attribute to dcls of lots of formals.
1995-10-16 14:38:11 +00:00
Jim Meyering
c5bf4b6c9c . 1995-10-14 01:39:01 +00:00
Jim Meyering
3ac64eda17 (prjoin): Handle case in which file spec is 0.
(add_field): Update assertions.
(decode_field_spec): For S == "0", set file spec to zero and don't modify
*FIELD_INDEX.  Otherwise, *FIELD_INDEX gets the zero-based index.
1995-10-13 17:22:58 +00:00
Jim Meyering
148f37c34e Add tests to exercize -o 0. 1995-10-13 17:16:48 +00:00
Jim Meyering
9845d179b3 (prjoin): Rewrite loop that iterates over field specs. 1995-10-13 13:16:34 +00:00
Jim Meyering
11b87d29cc (add_field_list): Allow SPACE and TAB as well as `,' as list item separators. 1995-10-12 21:42:52 +00:00
Jim Meyering
bc7210e563 Remove bogus FIXME. 1995-10-12 04:08:35 +00:00
Jim Meyering
e1ab53f969 . 1995-10-09 13:59:55 +00:00
Jim Meyering
790196a645 . 1995-10-09 13:59:25 +00:00
Jim Meyering
b5c8c81d4d Indent cpp directives to reflect nesting. 1995-10-09 03:48:08 +00:00
Jim Meyering
91a709b210 Modified from glibc copy. 1995-10-09 03:46:41 +00:00
Jim Meyering
5e25ee19e4 (SOURCES): Add strpbrk.c..
Remove bcopy.c.
1995-10-09 03:42:21 +00:00
Jim Meyering
70390f60ec . 1995-10-09 03:42:11 +00:00
Jim Meyering
c22889019c . 1995-10-08 04:02:09 +00:00
Jim Meyering
06ea91f2f3 (main): Close input files. 1995-10-08 04:02:00 +00:00
Jim Meyering
3c7699600f Add alloca junk. 1995-10-08 03:38:09 +00:00
Jim Meyering
c8c90bb532 . 1995-10-08 03:30:22 +00:00
Jim Meyering
6f63d53e1b (add_field): No longer return a value.
(decode_field_spec): New function.
(add_field_list): Rewrite to be more strict about what is accepted.
Before, `,1.2' was accepted as valid.
(main): Use xstrtol instead atoi.
Combine nearly identical -a and -v cases.
1995-10-08 03:28:21 +00:00
Jim Meyering
cd1dbbcfc1 . 1995-10-06 19:23:31 +00:00
Jim Meyering
4bbadbb14a . 1995-10-06 02:55:44 +00:00
Jim Meyering
cc61df7131 Include limits.h.
[!INT_MAX]: Define it.
1995-10-06 02:55:14 +00:00
Jim Meyering
965c0bf39d [!HAVE_UTIME_H]: Don't declare struct utimbuf here.
[!HAVE_STRUCT_UTIMBUF]: Declare struct utimbuf here instead.
1995-10-06 02:53:42 +00:00
Jim Meyering
6fc3c211ec . 1995-10-06 02:51:04 +00:00
Jim Meyering
c25dcdd843 (read_filesystem_list): Cast -1 to dev_t before assignment. 1995-10-05 14:14:45 +00:00
Jim Meyering
e387fd1471 (show_point): Cast -2 to dev_t before assignment. 1995-10-05 14:12:29 +00:00
Jim Meyering
1c7bc6028a protoize 1995-10-04 21:21:23 +00:00
Jim Meyering
74f061de82 Remove forward dcl of usage. 1995-10-04 21:20:40 +00:00
Jim Meyering
47b91b8948 (usage): Move to precede all other functions. 1995-10-04 21:19:28 +00:00
Jim Meyering
2d73c959cc (main): Report `too few/many non-option arguments' then print --help
output rather than just the latter.
Properly interpret obsolescent usage like `join -o 2.1 2.1 2.2'.
(usage): Describe POSIX -1, -2 options and deprecate -j* ones
1995-10-04 21:17:43 +00:00
Jim Meyering
9a17340b10 . 1995-10-04 03:46:43 +00:00
Jim Meyering
a9de4d485a Test SA_INTERRUPT, not _POSIX_VERSION,
to determine whether `sigaction' functions are available.
Reported by Paul Nevai <nevai@ops.mps.ohio-state.edu>.
Fix suggested by Karl Berry.
1995-10-04 03:46:35 +00:00
Jim Meyering
111cb717e8 (set_fields): Use memset (not open coded loop) to initialize array. 1995-10-03 20:28:44 +00:00
Jim Meyering
6a45f61547 Convert a lot of int' types to unsigned int' to avoid warnings from
`gcc -Wall' about comparing signed and unsigned types.
1995-10-03 20:21:32 +00:00
Jim Meyering
026d10d369 (main): Declare counter, N_STRINGS, to be an integral type, not `char'. 1995-10-03 20:18:39 +00:00
Jim Meyering
d832bf77eb Correct typos, mostly from Jens Schweikhardt. 1995-10-03 19:05:47 +00:00
Jim Meyering
de97a7099c .c 1995-10-01 22:50:25 +00:00
Jim Meyering
1d15980fb6 Remove trailing whitespace. 1995-10-01 22:49:07 +00:00
Jim Meyering
b3303ba072 Declare stat, xstat. 1995-10-01 22:40:11 +00:00
Jim Meyering
eddb25aa26 Declare stat, xstat. 1995-10-01 20:17:25 +00:00
Jim Meyering
40c6966137 (SOURCES): Add strtoul. 1995-10-01 19:02:29 +00:00
Jim Meyering
4de6eab547 (get_fs_usage) [STATFS_TRUNCATES_BLOCK_COUNTS]: Copy untruncated block
counts from f_spare array into proper members of struct statfs.
From Eirik Fuller (eirik@netapp.com);
1995-10-01 18:23:29 +00:00
Jim Meyering
caa2df2274 . 1995-09-29 04:50:31 +00:00
Jim Meyering
4c8c0b69ba . 1995-09-29 04:49:08 +00:00
Jim Meyering
527d04d44b (dired_dump_obstack): Don't generate any output if the obstack is empty.
(main): Always initialize and dump subdired_obstack, not just if -R.
`ls -lDR dir dir2' was using uninitialized subdired_obstack.
Reported by Samuli K{rkk{inen <hskarkka@snakemail.hut.fi>.
1995-09-29 04:09:22 +00:00
Jim Meyering
9a12d05216 (decode_one_format): Remove spurious semicolon. 1995-09-27 15:58:18 +00:00
Jim Meyering
77c46a6b42 . 1995-09-27 04:06:28 +00:00
Jim Meyering
744393f0f4 (show_point): Ignore mtab entries with either
nonexistent mount points or with inconsistent device number.
From Eirik Fuller <eirik@synopsys.com>.
1995-09-26 04:18:55 +00:00
Jim Meyering
6f200d7982 . 1995-09-25 04:14:36 +00:00
Jim Meyering
12e85d31e2 Protoize. 1995-09-24 13:36:13 +00:00
Jim Meyering
17821cc15e [REL_ALLOC]: #ifdef-out dcls of unused variables. 1995-09-23 20:55:02 +00:00
Jim Meyering
0bcd6e68a9 . 1995-09-23 20:46:22 +00:00
Jim Meyering
528390fa58 (print_kth): Change order of args in compare, and reverse sense of comparison
(Hence, no semantic change).
1995-09-23 20:42:52 +00:00
Jim Meyering
a719a87508 Merge in changes for ConvexOS 11.0. 1995-09-23 20:28:39 +00:00
Jim Meyering
a1fa4eff25 New version from FSF. 1995-09-23 20:28:10 +00:00
Jim Meyering
f344b7fab6 (md5_check): Distinguish between open/read failure and checksum mismatch. 1995-09-23 20:22:05 +00:00
Jim Meyering
eca98f76ac . 1995-09-23 20:21:22 +00:00
Jim Meyering
f30618bac7 . 1995-09-23 20:09:52 +00:00
Jim Meyering
dc4a18b537 . 1995-09-23 19:56:32 +00:00
Jim Meyering
9801e9cde1 Update to reflect changes in md5sum.c.
Add FIXME with Karl's comm suggestion.
1995-09-21 18:17:14 +00:00
Jim Meyering
1b16c152bd (main): Reverse order of check' and compute sums' blocks in if-else
chain to make it a little more readable.
1995-09-20 12:47:37 +00:00
Jim Meyering
3ed71a2fdd . 1995-09-19 14:30:59 +00:00
Jim Meyering
0e15d57a89 Rewrite confusing comment. 1995-09-19 12:59:49 +00:00
Jim Meyering
c253d247ca (checkfp): Rearrange loop to avoid duplicate test.
Move a couple dcls from function scope into inner block.
1995-09-19 12:50:34 +00:00
Jim Meyering
656fac3d80 . 1995-09-19 12:48:46 +00:00
Jim Meyering
dde2c138e9 Protoize. 1995-09-18 12:44:47 +00:00
Jim Meyering
7823351d6b (main, usage): Remove -h, -s, -v short options.
Rename --verbose to --warn, --quiet to --status.
(main): Handle --help and --version using parse_long_options.
(md5_check): Check ferror.
1995-09-18 12:36:12 +00:00
Jim Meyering
b23b6bbcf7 (tempname): Replace `16' with a more readable expansion.
Make sure that SEQ never exceeds 99999.
1995-09-14 13:31:52 +00:00
Jim Meyering
800e219a2d (sort): Rename local: ntemp -> n_temp_files, to avoid confusion
with another local, ntmp.
1995-09-14 13:09:27 +00:00
Jim Meyering
ecf0d31b72 Fix typo in comment. 1995-09-13 13:15:35 +00:00
Jim Meyering
c3f476d467 . 1995-08-11 06:26:39 +00:00
Jim Meyering
7f3e86b27b . 1995-08-11 06:26:12 +00:00
Jim Meyering
b0453a43c0 (main) [handling --string option]: Don't output nonstandard `b' binary flag. 1995-08-10 21:11:24 +00:00
Jim Meyering
b30b152bb7 . 1995-08-09 05:33:24 +00:00
Jim Meyering
a030007908 (my_strtol): Remove function.
(main): Use xstrtol instead.
1995-08-09 05:33:19 +00:00
Jim Meyering
10c5aeabc5 Include config.h.
Define bcopy to memcpy if possible.
1995-08-09 05:15:31 +00:00
Jim Meyering
9c5f82a7f1 Indent cpp directives. 1995-08-09 05:14:06 +00:00
Jim Meyering
7bbe6cbe82 . 1995-08-09 04:21:48 +00:00
Jim Meyering
b014a71007 (main): Fail if either --verbose or --quiet is specified
when not verifying checksums.
1995-08-09 04:21:14 +00:00
Jim Meyering
36c29006f8 . 1995-08-09 04:17:53 +00:00
Jim Meyering
59e80c1a0a . 1995-08-09 04:17:27 +00:00
Jim Meyering
e4dc3d6d36 . 1995-08-09 04:14:52 +00:00
Jim Meyering
a6fdb5b75d Include system.h. 1995-08-09 03:57:17 +00:00
Jim Meyering
26574d5284 (md5_check): Fail if no valid line is found.
Don't use the word `fail' unless there were failures --
say `all N tests passed.'
1995-08-09 02:50:09 +00:00
Jim Meyering
c02722d395 work on updating md5sum 1995-08-08 05:37:39 +00:00
Jim Meyering
b3d74743a8 . 1995-08-08 04:59:01 +00:00
Jim Meyering
f03f8dcc44 (mergefps) [lint]: Initialize SAVEALLOC to avoid spurious
compiler warning.  From Ulrich Drepper.
1995-08-08 04:58:46 +00:00
Jim Meyering
a5656326f0 (read_line) [lint]: Initialize CHARS to avoid spurious
compiler warning.  From Ulrich Drepper.
1995-08-08 04:58:23 +00:00
Jim Meyering
f0556f3517 Annotate localizable strings with _(...). From Franc,ois. 1995-08-08 04:37:34 +00:00
Jim Meyering
6b853ebe01 . 1995-08-08 04:31:02 +00:00
Jim Meyering
d0e2b9c466 Declare xmalloc, xrealloc rather than including xalloc.h. 1995-08-07 22:21:03 +00:00
Jim Meyering
a94a8dd402 . 1995-08-07 16:09:10 +00:00
Jim Meyering
7c342fe2a1 Add FIXME comments. 1995-08-07 16:07:28 +00:00
Jim Meyering
9c3f1711e2 (is_number): Rename from isnumber. 1995-08-07 16:06:43 +00:00
Jim Meyering
0347634ad3 . 1995-08-07 14:57:56 +00:00
Jim Meyering
92c50e7f52 Annotate localizable strings with _(...). From Franc,ois. 1995-08-07 14:57:29 +00:00
Jim Meyering
22ebf9c6ac Sort examples. 1995-08-06 20:02:27 +00:00
Jim Meyering
5fa76547cf . 1995-08-06 04:54:08 +00:00
Jim Meyering
e29f6ae24d . 1995-08-06 04:52:09 +00:00
Jim Meyering
00dadad79c (validate): Remove const attribute from formal #1.
It may be modified.
1995-08-05 05:09:21 +00:00
Jim Meyering
767768457c (__P): No longer define this. It's not used. 1995-08-05 04:58:31 +00:00
Jim Meyering
a468aa55b6 . 1995-08-05 04:22:16 +00:00
Jim Meyering
cbc82e5cc3 Protoize. 1995-08-05 03:36:29 +00:00
Jim Meyering
b0aa8e6985 Protoize. 1995-08-05 03:19:56 +00:00
Jim Meyering
c3f2e69471 (isnumber): Rename to is_number.
(parse_user_spec): Rename uses, too.
1995-08-05 03:13:16 +00:00
Jim Meyering
86c9719f0a . 1995-08-05 03:11:30 +00:00
Jim Meyering
be22aff966 (save_cwd, restore_cwd, free_cwd): Remove functions.
New versions have been broken out into save-cwd.c.
(du_files): Adapt to handle status code returned by new versions
of save_cwd and restore_cwd.
(count_entry): Likewise.
1995-08-05 03:10:27 +00:00
Jim Meyering
0159470d3d (decode_switches): Set SORT_TYPE. Before, ls -c was sorting
by name, rather than change time.  Reported by Ken Estes
(m-ke0082@sparky.cs.nyu.edu).
1995-08-05 03:09:41 +00:00
Jim Meyering
2adeb32b35 (SOURCES, OBJECTS, DISTFILES): Update for new files, save-cwd.[ch]. 1995-08-05 03:08:09 +00:00
Jim Meyering
351cf87351 (isnumber): Rename to is_number to avoid conflict with
FreeBSD 2.0.5 macro definition.  Reported by David O'Brien
(obrien@sea.legent.com).
1995-08-05 03:06:41 +00:00
Jim Meyering
3139de9726 . 1995-08-04 15:23:25 +00:00
Jim Meyering
b4a47508d4 (SOURCES, OBJECTS, DISTFILES): Update for new files. 1995-08-04 15:15:24 +00:00
Jim Meyering
f7860d6172 . 1995-08-04 15:09:12 +00:00
Jim Meyering
f6b3413fcc (_getopt_internal) [lint]: Initialize INDFOUND to
avoid warning from gcc.
1995-08-04 14:30:19 +00:00
Jim Meyering
e799d19df8 . 1995-08-03 16:44:17 +00:00
Jim Meyering
b1ab76f3e4 . 1995-08-02 04:26:31 +00:00
Jim Meyering
ccb00b7ef9 . 1995-07-30 23:58:28 +00:00
Jim Meyering
ac37278a41 . 1995-07-30 23:58:06 +00:00
Jim Meyering
fc88df7458 (md5_check): Use getline instead of fgets. 1995-07-30 23:57:03 +00:00
Jim Meyering
11ec25d3ce New version -- now derived from the line in libc. 1995-07-30 18:42:09 +00:00
Jim Meyering
4aa1e2f2e8 Get new copy from FSF. 1995-07-30 05:30:04 +00:00
Jim Meyering
ea4cda6907 [memcpy]: Define to bcopy if needed.
(md5_buffer): Explicitely cast SWAP expressions to unsigned
to avoid warning.
1995-07-30 05:12:30 +00:00
Jim Meyering
ba477b681a Add parens to clarify ?: expression. 1995-07-30 05:03:26 +00:00
Jim Meyering
f2fc6e4cad (check): Print `disorder on...' message on standard error, not stdout.
This is a minor concession to POSIX which says `no output shall be produced'.
(main): Fix -k so it works. -k 2,3 was being treated like -k 2.
Reported by Marcus Daniels <marcus@sysc.pdx.edu>.
1995-07-30 05:02:37 +00:00
Jim Meyering
6473e3638f . 1995-07-27 20:22:29 +00:00
Jim Meyering
7e93c0f64b Initial revision 1995-07-27 14:43:01 +00:00
Jim Meyering
1126d3b93e remove trailing blanks 1995-07-27 14:15:09 +00:00
Jim Meyering
c02e97e2c5 . 1995-07-27 04:04:18 +00:00
Jim Meyering
f7ccdd300d . 1995-07-27 03:57:20 +00:00
Jim Meyering
8904d4a45c Remove spurious space. 1995-07-27 03:57:10 +00:00
Jim Meyering
8c17f50aea (tail_bytes) [from_start]: For regular files, seek
relative to the initial input file pointer position, not
necessarily from the beginning of the file.
[!from_start]: Don't back up past the initial position of the
input file pointer.
(tail_lines): Call file_lines only if FD refers to a regular file
with its file pointer positioned at beginning of file.  Otherwise,
call pipe_lines.  This is a kludge.  Once there's a decent test
suite, fix this properly.
Before, (echo 1; echo 2) > k; sh -c 'read x; tail' < k
would output both lines of the input file even though the first had
already been read.  Reported by John Roll (john@panic.harvard.edu).
1995-07-27 03:56:35 +00:00
Jim Meyering
28e28e6d74 (have_read_stdin): New global variable.
(md5_file, md5_check): Set it.
(main): Use it.

[OPENOPTS]: Depend explicitly on BINARY.
(md5_file): Take a new parameter, MD5_RESULT, and no longer
generate output.
(md5_check): Invoke md5_file instead of calling fopen directly.
When giving a diagnostic for a line with invalid format, also report
the line number.
(main): Generate output after a successful md5_file call.
[in many places]: Upon detection of an error, rather than exiting
immediately, issue a diagnostic, note that an error occurred and
exit later.
1995-07-27 03:45:11 +00:00
Jim Meyering
7732d5d7cf (main): When too few arguments are given, don't just
issue the usage message; also report why.
1995-07-25 04:50:04 +00:00
Jim Meyering
5f33b78417 [_LIBC || STDC_HEADERS] (TOLOWER): Define to tolower. 1995-07-25 02:48:00 +00:00
Jim Meyering
6abd6fdd72 (md5_check): New function -- extracted from main. 1995-07-22 05:16:40 +00:00
Jim Meyering
0e7bce124f reformat comment 1995-07-21 06:27:39 +00:00
Jim Meyering
35eda3509e . 1995-07-21 06:23:11 +00:00
Jim Meyering
58b1195eb4 (md5_file): New function -- extracted from main.
(main): Call the new function instead of doing all that in an if stmt.
Always use "%s" format rather than raw filename as format argument
in printf-style functions like error.  Otherwise, filenames containing
e.g. `%s' lose.
Remove all traces of `old format'.  There is only one format now.
The compatible one.
1995-07-21 06:18:58 +00:00
Jim Meyering
bb79abc8a3 (md5_stream): Update prototype.
[__P]: Define macro.
1995-07-21 04:48:03 +00:00
Jim Meyering
574cc98b23 (md5_stream): Check for read failure and return
indication of success rather than second argument.
1995-07-21 04:46:50 +00:00
Jim Meyering
855741c7cb Use EXIT_FAILURE and EXIT_SUCCESS.
(main): Report an error if md5_stream fails.  Otherwise, running
`md5sum dir-on-mounted-filesystem' always reported the checksum
for an empty file.  Now it gets the `is a directory' error.
Greg McGary reported that the released version got stuck in an
infinite loop with such arguments.
1995-07-21 04:45:40 +00:00
Jim Meyering
d58bdcd4fa (split_3): Accept only old format.
Properly handle file names with leading and trailing white space.
1995-07-20 21:09:57 +00:00
Jim Meyering
1ae54a6140 more comment tweaks 1995-07-20 19:22:28 +00:00
Jim Meyering
db566dba37 Correct typo in Copyright.
Reformat paragraph so line with new FSF address fits in 80 columns.
1995-07-20 19:13:23 +00:00
Jim Meyering
3d699e8ee0 (usage): Move it to precede all other functions.
Fiddle comments.
1995-07-20 19:10:08 +00:00
Jim Meyering
e20e0ba392 New version from Drepper. 1995-07-20 19:08:08 +00:00
Jim Meyering
dfe3d8837e . 1995-07-20 17:52:49 +00:00
Jim Meyering
e59ec88ea2 . 1995-07-16 23:43:17 +00:00
Jim Meyering
66c43ec708 . 1995-07-16 23:41:17 +00:00
Jim Meyering
e692090b89 . 1995-07-16 23:39:51 +00:00
Jim Meyering
1e74962c8a Add #else block after #ifdef VMS.
(main): Rename local variable.
Add FIXME: allow newlines in filenames.
Detect and report failed fclose calls on stdout and checkfile_stream.
1995-07-16 05:47:55 +00:00
Jim Meyering
14aaf3eab3 (build_spec_list): Declare CLOSING_DELIM_IDX and CLOSING_BRACKET_IDX to
be of type size_t, not int.
(main): Declare NR and CHARS_READ to be of type long, not int.
1995-07-16 05:39:09 +00:00
Jim Meyering
adfa243b0d (unqote): Comment out unreachable break stmts.
(append_range): Declare FIRST and LAST parameters to be unsigned int,
not size_t.
(find_closing_delim): Clean up interface, separating boolean success
indicator and index.
(find_bracketed_repeat): Likewise.
(build_spec_list): Adapt to use new interfaces.
1995-07-12 03:13:40 +00:00
Jim Meyering
37ba8d9867 (main): Comment out unreachable break stmt. 1995-07-12 03:06:49 +00:00
Jim Meyering
c20ee98ac8 (dump): Convert to use smaller -- but seemingly equivalent -- patch. 1995-07-12 03:06:03 +00:00
Jim Meyering
21aa588967 Reorder functions so main is last, so no forward dcls are needed. 1995-07-12 03:01:33 +00:00
Jim Meyering
ba34723398 (tail): Explicitly cast to long the N_UNITS argumennt in
call to tail_lines.  Otherwise, NetBSD lost because N_UNITS (of type
off_t, a 64-bit type on NetBSD) wasn't converted to the target type,
long.  Reported by Dan Hagerty (hag@gnu.ai.it.edu).
1995-07-12 02:59:44 +00:00
Jim Meyering
51c3164ba3 (main): Add UCHAR casts. 1995-07-09 17:06:41 +00:00
Jim Meyering
307526e92d . 1995-07-09 16:42:40 +00:00
Jim Meyering
6dfad5e900 (main): When using obsolescent +pos -pos syntax, allow
omission of field spec only when character offset is specified.
Otherwise, -. +. would be accepted.
1995-07-09 16:42:31 +00:00
Jim Meyering
ccfb7f032d (main): Allow field spec, M, to be omitted in +M.N or -M.N
position specification.  Omitting M is equivalent to specifying `0'
for M.  From Rick Sladkey (jrs@world.std.com).
1995-07-09 02:25:11 +00:00
Jim Meyering
bb5590f7b6 . 1995-07-07 04:46:18 +00:00
Jim Meyering
67718aff76 (dump): Correct loop-termination criterion.
Before, running `printf 1234| ./od --width=4 --read-bytes=4'
printed output for 8 bytes -- the last four were garbage.
This happened only when the dump limit, N, was specified (with
--read-bytes=N) and N was a multiple of bytes_per_block
(usually 16, but 4 in this example).  From Andreas Schwab.
1995-07-07 04:46:03 +00:00
Jim Meyering
b9d3dc4101 Remove trailing white space. 1995-07-06 16:07:07 +00:00
Jim Meyering
20b6a5b40a (od): Remove space beteen -w and optional argument. 1995-07-06 16:06:32 +00:00
Jim Meyering
72d4155c90 . 1995-07-03 03:12:54 +00:00
Jim Meyering
e7c2d62889 . 1995-07-03 03:11:05 +00:00
Jim Meyering
c8e05ecd8d (split_3): Rewrite to parse Plumb/Lankester format as well.
(main): Write (de facto) standard Plumb/Lankester format.
New option: --quiet.
Check option no longer takes an argument.
When checking, exit status reflects success.
1995-07-03 03:10:59 +00:00
Jim Meyering
9c8e5123bd Remove unused dcl of isnumber. 1995-06-25 01:46:32 +00:00
Jim Meyering
9a5882ba80 (parse_group): Use xstrtoul instead of isnumber; the latter would
silently overflow, accepting a group id larger than INT_MAX.
(isnumber): Remove now-unused static function.
(change_file_group) [MAXUID]: Give a more descriptive message
when numeric group id is larger than MAXUID.
1995-06-25 01:44:35 +00:00
Jim Meyering
7981e85eb3 merge with 1.12a 1995-06-24 22:02:25 +00:00
Jim Meyering
1d7e1a535b . 1995-06-24 21:34:02 +00:00
Jim Meyering
4610e33cb2 Don't conditionalize use of "inline". Autoconf takes care of defining
it away for compilers that don't grok it.
1995-06-24 21:33:52 +00:00
Jim Meyering
9cda676546 . 1995-06-24 21:22:11 +00:00
Jim Meyering
f5ff11c61d . 1995-06-24 21:17:13 +00:00
Jim Meyering
86671a4ed0 Undefine min and/or max before defining to avoid redefinition warning
on systems.
1995-06-24 21:10:12 +00:00
Jim Meyering
5cd7a18539 (read_input): Rename paramater MAX to MAX_N_BYTES. To avoid potential
conflict with max macro from some system's header files and bad pre-ANSI
compilers.
1995-06-24 21:07:55 +00:00
Jim Meyering
4b366ceed5 [uint32]: When testing for 32-bit arithmetic type,
also check `unsigned long', as a concession to systems with
int's smaller than 32 bits.
1995-06-24 20:53:17 +00:00
Jim Meyering
eb5665733a (usage): Fix typo. 1995-06-24 20:38:52 +00:00
Jim Meyering
ec8d1fce62 (main): Include program name in --version output. 1995-06-22 18:43:14 +00:00
Jim Meyering
4afe3f334a [join]: Redefine. Otherwise, systems (Unicos for one) with
headers that have a different prototype for `join' get an error.
1995-06-22 04:03:33 +00:00
Jim Meyering
b27934a727 . 1995-06-22 04:00:26 +00:00
Jim Meyering
e7d420aabb [word]: Redefine. Otherwise, systems (Unicos for one) with
headers that define `word' to be a type get syntax errors because
of the variable by the same name.
1995-06-22 03:59:55 +00:00
Jim Meyering
3f76720636 (interrupt_handler): Declare to have a single integer
parameter.  Otherwise, some compilers failed with a type mismatch
error in sa_handler assignment.
1995-06-22 03:59:27 +00:00
Jim Meyering
3fba1e486e (main): Remove spurious colon in getopt spec string.
From Ken Pizzini <kenp@spry.com>.
1995-06-22 03:58:21 +00:00
Jim Meyering
59f93bf56c (md5_file): Initialize two elements of LEN portably,
rather than with ANSI aggregate initialization.  Reported by
Edzer Pebesma <Edzer.Pebesma@rivm.nl>.
1995-06-20 12:00:55 +00:00
Jim Meyering
6ebaf82426 merge with 1.12 1995-06-18 19:33:31 +00:00
Jim Meyering
d96ba2d153 . 1995-06-18 14:24:56 +00:00
Jim Meyering
2adaaa8521 . 1995-06-18 14:21:58 +00:00
Jim Meyering
755cdcee27 (process_buffer): Copy values from struct into
individual local variables before performing computation on them,
then copy results back into returned struct.  Solely for better
optimization by compilers that can't keep struct members in
registers.  From Ulrich Drepper.
1995-06-18 14:21:50 +00:00
Jim Meyering
643a49ea6c . 1995-06-16 04:25:05 +00:00
Jim Meyering
583e66e5b0 . 1995-06-16 04:21:08 +00:00
Jim Meyering
769f82b90b . 1995-06-16 04:15:25 +00:00
Jim Meyering
19ffe3f16e (split_3): Unprotoize.
(hex_digits): Unprotoize.
(main): Interpret `no file args' as request to read from stdin.
(usage): Reflect that change.
1995-06-16 04:13:36 +00:00
Jim Meyering
66196f8fd7 Half-assed patch from Karl -- probably need to change file name' to filename'. 1995-06-16 03:59:41 +00:00
Jim Meyering
820cd5c090 . 1995-06-16 03:26:56 +00:00
Jim Meyering
cdfc0cf26f Remove unnecessary uses of `defined' in #if* tests.
Don't use #elif.  Some older compilers don't grok it.
(split_3): New function to parse out sum, flag, and filename
when reading check file.
(hex_digits): Remove length parameter since string parameter is
now nul-terminated.
(main): Don't allocate separate arrays for filename and sum
when checking.  Get pointers into line buffer with split_3 instead
of using sscanf.
1995-06-16 03:14:19 +00:00
Jim Meyering
aab046d29b Don't include values.h.
[__P]: Undefine it.

[UNIX || unix]: Also test __UNIX__, __unix__,
and _POSIX_VERSION.  Reported by Arne H. Juul.
1995-06-15 18:44:48 +00:00
Jim Meyering
ad1b9f0851 . 1995-06-15 18:44:27 +00:00
Jim Meyering
f9f17d4b0f merge with 1.11.5b 1995-06-15 16:46:34 +00:00
Jim Meyering
33969b2c90 patch from drepper 1995-06-15 15:02:01 +00:00
Jim Meyering
88b9522242 Alloca fix for ConvexOS-11.0. 1995-06-15 14:55:26 +00:00
Jim Meyering
2907e4e4f1 Use void* alloca, not char*. The latter lost on convexOS. 1995-06-15 03:57:49 +00:00
Jim Meyering
84876e7e9e md5sum docs from Ulrich. 1995-06-15 03:43:52 +00:00
Jim Meyering
8f6e9e8827 (main): Rename char binary' to type_flag to avoid confusion with int binary'. 1995-06-15 03:18:13 +00:00
Jim Meyering
9387b92371 Don't use #elif. Some old C compilers don't recognize it.
(hex_digits): New function.
(result): Give ctx parameter the `const' attribute.
(usage): Rewrite to make it clearer that there are three modes.
(main): Process all options before generating any output.
In particular, collect all --string options rather than operating
on them as they are encountered.

Allow --check=-.  Before it tried to open the file named `-'.

Detect bogus input when --check'ing: non-hex, non-[tb] flag.

Map to lower case all hex digits read from check file.
1995-06-15 03:15:37 +00:00
Jim Meyering
a04bfe9cbf . 1995-06-14 03:44:16 +00:00
Jim Meyering
f7c77084b4 . 1995-06-14 02:24:18 +00:00
Jim Meyering
60437a80ca [NDEBUG]: Define it to disable assertions.
(is_char_class_member): Set a variable in each branch of switch stmt
and return that value after the switch (rather than returning directly
from every branch).
(unquote): More int->size_t changes.
(build_spec_list): More int->size_t changes.
Be very careful about comparison now that variables are unsigned:
Use i + 2 < len rather than i < len - 2.  The latter failed for len < 2.
1995-06-14 02:23:48 +00:00
Jim Meyering
891c9b5cc7 . 1995-06-13 04:46:19 +00:00
Jim Meyering
1aa5954b42 (xfclose): Don't try to flush stdin, only stdout.
Otherwise, at least Ultrix-4.3's fflush would return EOF.
Reported by Jim Blandy (jimb@cyclic.com).
1995-06-13 04:46:12 +00:00
Jim Meyering
46a1fec4a5 . 1995-06-13 04:33:45 +00:00
Jim Meyering
ca73f85acf [struct Spec_list] (indefinite_repeat_element): New member.
Use size_t rather than int or unsigned long where reasonable.
(get_spec_status): Make interface cleaner.
(get_s1_spec_status): New function.
(get_s2_spec_status): New function.
(validate): Use new functions.
1995-06-13 04:08:59 +00:00
Jim Meyering
da78e2df64 Indent some things.
(long_options): Add NULL entry.  From Uli.
Touch up some comments.
(process_buffer): Bracket definition of OP with do...while(0) so stmts can be
semicolon terminated.
1995-06-13 04:02:22 +00:00
Jim Meyering
bcee3d43ca (non_neg_strtol): Don't compare signed and unsigned. 1995-06-12 18:28:24 +00:00
Jim Meyering
afe762e4e6 [!__GNUC__]: Define INLINE to /* empty */. 1995-06-12 14:42:41 +00:00
Jim Meyering
5b45da2a71 . 1995-06-12 05:27:12 +00:00
Jim Meyering
bb789f462c . 1995-06-12 05:25:04 +00:00
Jim Meyering
a14d08e891 Remove now-obsolete comment and leading space. 1995-06-12 05:09:57 +00:00
Jim Meyering
81ca3a8b6c Remove now-obsolete comment and leading space. 1995-06-12 05:08:16 +00:00
Jim Meyering
fd9df74e75 . 1995-06-11 19:56:29 +00:00
Jim Meyering
c502988b26 Use invalid', not illegal' in error message. 1995-06-11 19:54:49 +00:00
Jim Meyering
1d1094a69e Remove trailing white space. 1995-06-11 19:37:03 +00:00
Jim Meyering
8ddb66cff4 [SWAP]: Parenthesize uses of macro argument.
Don't use autoconf macros that require running test programs.
1995-06-11 06:16:17 +00:00
Jim Meyering
3763a4f24e From Ulrich Drepper. 1995-06-11 06:04:15 +00:00
Jim Meyering
c3754d6f21 (look_up_char_class, append_char_class, append_equiv_class): Use const
attribute when appropriate.
1995-06-11 05:40:05 +00:00
Jim Meyering
a2e52e58b1 (Convert): Use 2037 as threshold, not 1999.
Otherwise years after 1999 are treated as invalid.
From Andreas Schwab.
1995-06-07 18:10:17 +00:00
Jim Meyering
85bf8c2e1c merge with 1.11.5 1995-06-01 14:12:51 +00:00
Jim Meyering
f97e625d3d merge with 1.11.4b 1995-05-29 05:33:13 +00:00
Jim Meyering
9584732376 (add_field_list): Compute max once for each call to add_field. 1995-05-28 20:12:24 +00:00
Jim Meyering
0a73924f60 . 1995-05-28 20:11:38 +00:00
Jim Meyering
d1a5552fbe . 1995-05-28 19:51:25 +00:00
Jim Meyering
e1c9600ae7 . 1995-05-28 19:48:40 +00:00
Jim Meyering
88daaaf385 (main): Call make_blank after *all* argument processing.
Get rid of blank1, blank2.  Just use uni_blank instead.
1995-05-28 19:46:04 +00:00
Jim Meyering
5c08b11b30 Overhaul so -a1 and -a2 (as used in cnews) work. 1995-05-28 18:01:54 +00:00
Jim Meyering
22e09d7c8e Add tests. 1995-05-28 17:58:16 +00:00
Jim Meyering
0dfe7fe96e Correct a test. 1995-05-28 15:33:00 +00:00
Jim Meyering
4657b1e9ec (main): Remove dcl of and statements that set now-unused variable. 1995-05-28 02:04:55 +00:00
Jim Meyering
4fb3e0f061 merge with 1.11.4a 1995-05-28 01:55:00 +00:00
Jim Meyering
a528bd5d9f [!STDC_HEADERS && HAVE_MEMORY_H]: Include memory.h.
Without this, SunOS doesn't get type for memchr.
Reported by Kaveh Ghazi.
1995-05-27 11:41:00 +00:00
Jim Meyering
4662661e71 . 1995-05-27 11:39:15 +00:00
Jim Meyering
4d00132265 Remove trailing white space. 1995-05-26 15:08:55 +00:00
Jim Meyering
0be7c19204 Remove trailing white space. 1995-05-26 14:15:37 +00:00
Jim Meyering
ae3864618a . 1995-05-25 05:10:03 +00:00
Jim Meyering
1bca766a5d [struct control]: Change type of `repeat' member to unsigned
long to avoid conversion warning.
1995-05-25 05:09:50 +00:00
Jim Meyering
a660862d4c (tail_lines): Change one more long' to off_t'.
Otherwise, tail didn't work on NetBSD.  From by Arne H. Juul.
1995-05-25 05:09:00 +00:00
Jim Meyering
871da9a196 merge with 1.11.3 1995-05-25 05:02:37 +00:00
Jim Meyering
e4326d5926 . 1995-05-22 04:43:42 +00:00
Jim Meyering
ec651d2263 (__strtol): Remove prototype altogether.
Move inclusion of xstrtol.h back so that it follows system headers.
1995-05-22 04:43:36 +00:00
Jim Meyering
0895e4a7c4 . 1995-05-22 04:32:53 +00:00
Jim Meyering
ee79446888 (usage): Add one or two lines of descriptive text. 1995-05-22 04:30:18 +00:00
Jim Meyering
d0da35f3d2 . 1995-05-21 18:46:56 +00:00
Jim Meyering
b8a56f0503 . 1995-05-21 18:46:33 +00:00
Jim Meyering
f001fccf74 . 1995-05-21 18:46:11 +00:00
Jim Meyering
9451f098d6 . 1995-05-21 12:32:03 +00:00
Jim Meyering
a42221d051 (install-exec, install-exec): New targets. From Karl Berry.
(maintainer-clean): Renamed from realclean per GNU Standards.
1995-05-21 12:27:45 +00:00
Jim Meyering
f76df4e179 . 1995-05-21 12:23:15 +00:00
Jim Meyering
937f55f61f merge with 1.11.2 1995-05-21 11:57:14 +00:00
Jim Meyering
7f9311c20e merge with 1.11.1b 1995-05-21 11:44:22 +00:00
Jim Meyering
37a6bc3abf merge with 1.11.1a 1995-05-20 13:28:24 +00:00
Jim Meyering
e364481ca4 . 1995-05-20 12:36:49 +00:00
Jim Meyering
4b54af76ea . 1995-05-20 12:09:05 +00:00
Jim Meyering
e8db76575a (look_up_char_class): Take a string length argument.
Use strncmp, not strcmp and verify that string lengths are the same.
(append_char_class): Update caller.
From Andreas Schwab.
1995-05-20 12:08:35 +00:00
Jim Meyering
9918713e5b (next_file_name): Move dcls of file-scope variables into this function.
Don't rely on arithmetic being two's complement.
1995-05-20 11:52:36 +00:00
Jim Meyering
4c9e84124c [CLOSED, ENDLIST]: Don't cast constants to FILE pointers.
Instead, declare two FILE structs and use their addresses.
1995-05-20 11:47:31 +00:00
Jim Meyering
0753cff4a1 (usage): Tweak wording. 1995-05-20 11:41:13 +00:00
Jim Meyering
3bfa2eb8bb Remove backquote. 1995-05-19 16:49:33 +00:00
Jim Meyering
c253f9ba51 (record_line_starts): Remove set-but-not-used, file-scope variable. 1995-05-19 15:59:40 +00:00
Jim Meyering
1fffbc7472 No longer include safe-l?stat.h. 1995-05-19 15:23:18 +00:00
Jim Meyering
a693d752bc Oops. Test $tr, not `tr' from PATH. 1995-05-18 18:20:57 +00:00
Jim Meyering
a547f02ddf Test [:lower:] to [:upper:] and vice versa. 1995-05-18 18:20:12 +00:00
Jim Meyering
c9c8ba714c Save error output in t*.err. 1995-05-16 17:19:46 +00:00
Jim Meyering
be7c86dfd2 . 1995-05-16 17:19:32 +00:00
Jim Meyering
68681fe067 Remove spurious space for missing arg2. 1995-05-16 17:14:11 +00:00
Jim Meyering
6a3f88500f Always print message at end, not just upon failure. 1995-05-16 17:13:39 +00:00
Jim Meyering
b03da97486 . 1995-05-15 16:43:39 +00:00
Jim Meyering
0dc531502b . 1995-05-15 06:00:33 +00:00
Jim Meyering
635b1b5b6e (usage): Add one- and two-line descriptions to --help output.
From Karl.
1995-05-15 04:53:56 +00:00
Jim Meyering
2c74d574d3 . 1995-05-13 18:35:36 +00:00
Jim Meyering
7cdc7a0bd9 (usage): Include one- or two-line synopsis in --help output.
From Karl Berry.
1995-05-13 18:34:54 +00:00
Jim Meyering
e8be969ec8 . 1995-05-13 14:05:46 +00:00
Jim Meyering
56c8261d7e (maintainer-clean): Rename from realclean.
(.PHONY): New dependencies.
[.c.o]: Remove -I. since safe-l?stat.h is no longer used.
1995-05-13 13:55:56 +00:00
Jim Meyering
fe6756d42e . 1995-05-13 13:39:07 +00:00
Jim Meyering
c093a8e789 (make_path): Use stat, not SAFE_STAT.
Use strchr, not index.  Adjust defines accordingly.
1995-05-13 13:30:10 +00:00
Jim Meyering
7ce06ceca7 (parse_user_spec): Use strchr, not index.
[!HAVE_STRING_H]: Define strchr in terms of index, not the other way around.
1995-05-13 13:25:42 +00:00
Jim Meyering
8a7a1fda12 (rmdir): Use stat, not safe_stat. 1995-05-13 13:20:19 +00:00
Jim Meyering
eec5824b1a (rename): Use stat, not safe_stat.
(rename): Compare src and dest inode numbers rather than src
inode and dest *dev* when determining whether src and dest refer
to the same file.  From marc@math.cornell.edu (Marc Parmet).
1995-05-13 13:19:07 +00:00
Jim Meyering
b3fc4e375f (mkdir): Use stat, not safe_stat. 1995-05-13 13:13:04 +00:00
Jim Meyering
5a69bc6e5f Undef __P before defining.
Guard definition with simpler `#if __STDC__'.
1995-05-13 13:10:38 +00:00
Jim Meyering
e8bfedbcd4 (isdir): Usage stat, not safe_stat. 1995-05-13 13:07:54 +00:00
Jim Meyering
627abb8251 (statfs): Use stat, not safe_stat. 1995-05-13 13:06:46 +00:00
Jim Meyering
4198f93479 (eaccess_stat): Make statp and path arguments const.
(euidaccess): Make statp argument const.  Use stat, not safe_stat.
1995-05-13 13:05:35 +00:00
Jim Meyering
26abb25bd0 Remove unnecessary definitions for r?index.
Update definitions for ISDIGIT.
1995-05-13 13:02:08 +00:00
Jim Meyering
d931bb8005 Remove safe-l?stat.[ch]in and related rules. 1995-05-13 12:57:46 +00:00
Jim Meyering
e5be6fdf8a (argmatch): Include sys/types.h and declare length argument with type size_t. 1995-05-13 12:55:49 +00:00
Jim Meyering
143415e6b8 (basename): Make arg const. 1995-05-13 12:52:57 +00:00
Jim Meyering
99ce9e9832 Use stat (lstat), not safe_stat (safe_lstat). 1995-05-13 12:48:33 +00:00
Jim Meyering
466ecc5db8 maintainer-clean, PHONY, ... 1995-05-13 12:22:27 +00:00
Jim Meyering
274e5f86b5 Use l?stat, not safe_l?stat. 1995-05-13 02:31:46 +00:00
Jim Meyering
31faa61270 (usage): Remove duplicate descriptions of --help and --version.
From Karl Berry.
1995-05-13 02:26:18 +00:00
Jim Meyering
7108d098ae (movefile): Remove a single trailing slash from destdir before concatenating
with `/' and filename for `ok to overwrite...' message.
1995-05-13 02:21:40 +00:00
Jim Meyering
63c91c859f Test tr in $PATH, not ./tr. 1995-05-12 02:11:06 +00:00
Jim Meyering
01eb16e339 merge with 1.11.1 1995-05-11 14:06:53 +00:00
Jim Meyering
821c7fe59e merge with 1.11.g 1995-05-10 14:22:19 +00:00
Jim Meyering
344458e890 . 1995-05-07 18:37:14 +00:00
Jim Meyering
b0aa499bb2 . 1995-05-05 14:58:59 +00:00
Jim Meyering
6ebd309cb8 (save_stdin): Don't hard-code /tmp.
[DEFAULT_TMPDIR]: Use this instead.
1995-05-05 05:09:58 +00:00
Jim Meyering
151f4af0da . 1995-05-05 05:03:56 +00:00
Jim Meyering
a5da850f3f (main): Use stat, not safe_stat. The latter was unnecessary. 1995-05-05 05:03:50 +00:00
Jim Meyering
21657d3c67 . 1995-05-05 04:37:58 +00:00
Jim Meyering
04c2f73f6f Patch from Mike to fix handling of +x.yn. 1995-05-05 04:37:21 +00:00
Jim Meyering
f45ff2cfaf Don't hard-code /tmp.
[DEFAULT_TMPDIR]: Use this instead.
1995-05-05 04:16:12 +00:00
Jim Meyering
6cd5abb0c4 . 1995-05-02 04:04:39 +00:00
Jim Meyering
70b90a6f9d (quote_filename): Never return NULL when quoting filenames
as C-strings.  --quote-name was quoting only strings containing
at least one C-quotable character.  Reported by David J. MacKenzie.
1995-05-02 04:04:32 +00:00
Jim Meyering
6d94a2954d (usage): Fix per kb's suggestions. 1995-04-30 12:57:50 +00:00
Jim Meyering
843193374f Use __-protected versions of format' and printf' only with gcc-2.7 and later. 1995-04-27 17:04:23 +00:00
Jim Meyering
732fb15b45 merge with 1.11.f 1995-04-27 06:06:46 +00:00
Jim Meyering
00c3a48bd7 (REGEX_FREE): Add back the `while (0)' hack
Put back ifdefs to protect unnecessary decl.
1995-04-27 05:23:35 +00:00
Jim Meyering
1fa0e4dfd6 Latest from RMS. 1995-04-27 04:54:07 +00:00
Jim Meyering
7008c3aa9d . 1995-04-27 04:51:57 +00:00
Jim Meyering
14755ac891 (EMACS_INT): Define it to int. (BIG KLUDGE) 1995-04-26 17:19:13 +00:00
Jim Meyering
9c5392e4af (REGEX_FREE): Define to `while (0) /* empty */' rather than nothing.
Otherwise, some uses got warnings about empty if-clause.

Declare failure_stack_ptr only #ifdef REL_ALLOC.
1995-04-26 17:18:27 +00:00
Jim Meyering
fd3bfce0cc New version from FSF. 1995-04-26 17:02:38 +00:00
Jim Meyering
a3edacb315 (tempname): AND-off high bits of pid so that its decimal
string representation is no longer than five digits.
From Hans Verkuil (hans@wyst.hobby.nl)
1995-04-26 16:12:01 +00:00
Jim Meyering
062c5a1fd0 . 1995-04-25 05:40:06 +00:00
Jim Meyering
1b51c7e73b Protect format and printf with __*__. 1995-04-24 16:25:29 +00:00
Jim Meyering
af8e117d0d Fix mostly per Franc,ois' suggestions. 1995-04-22 05:54:18 +00:00
Jim Meyering
a87015327e Update and add copyright. 1995-04-21 17:29:15 +00:00
Jim Meyering
775493dedd . 1995-04-21 06:24:54 +00:00
Jim Meyering
27f19ab42b . 1995-04-21 04:22:00 +00:00
Jim Meyering
586c892910 (add_tabstop): Give correct size when reallocating tab_list buffer.
From Geoff Odhner (geoff@franklin.com).
1995-04-21 04:12:33 +00:00
Jim Meyering
f9834f6bee . 1995-04-19 03:58:38 +00:00
Jim Meyering
5e1b1dabb2 . 1995-04-15 13:15:02 +00:00
Jim Meyering
93b95d2b78 (next_file_name): Don't reuse X as an index.
Declare new variable I instead.
1995-04-14 04:29:41 +00:00
Jim Meyering
73daf89227 (write_block): Declare index I as unsigned int, not int.
(get_lcm): Likewise.
(dump_strings): Likewise.
(main): Likewise.
(dump): Cast BYTES_PER_BLOCK to off_t in MIN expression.
(dump_strings): Declare bufsize to be of type size_t, not int.
1995-04-14 04:27:46 +00:00
Jim Meyering
9f888b86b8 Remove block of redundant comments describing options.
(usage): Remove reference to -l option.  It's not valid.
1995-04-14 04:23:22 +00:00
Jim Meyering
364c21f831 . 1995-04-04 21:19:44 +00:00
Jim Meyering
d71f5443c9 . 1995-04-03 13:53:18 +00:00
Jim Meyering
1beb8c40f3 . 1995-04-03 13:52:54 +00:00
Jim Meyering
09dec6f72f (fold_file): Declare offset_out size_t. 1995-03-25 21:09:34 +00:00
Jim Meyering
42357adff5 (set_fields): Declare index unsigned. 1995-03-25 21:08:36 +00:00
Jim Meyering
ebaf614a13 Declare as unsigned int' all variables that were just unsigned'.
(make_filename): Change type of arg to unsigned int.
(split_file): Change type of indices to unsigned int.
1995-03-24 23:40:41 +00:00
Jim Meyering
80fab638f1 merge with 1.11.e 1995-03-21 03:50:10 +00:00
Jim Meyering
5ddea12690 . 1995-03-21 03:45:22 +00:00
Jim Meyering
107da866a6 (usage): Add ellipsis after `[OPTION]'.
Use FILE, not deprecated PATH.  From Karl Berry.
1995-03-21 03:45:15 +00:00
Jim Meyering
88650610c1 . 1995-03-21 01:58:18 +00:00
Jim Meyering
c70ee3bf4a merge with 1.11.d 1995-03-21 01:43:35 +00:00
Jim Meyering
429a8df30a . 1995-03-20 15:10:37 +00:00
Jim Meyering
f371bb0b80 sync from FSF 1995-03-20 15:09:56 +00:00
Jim Meyering
4b72e436e6 . 1995-03-20 14:26:41 +00:00
Jim Meyering
6ac40b721e version.texi: Put only version number in VERSION definition. 1995-03-17 04:07:19 +00:00
Jim Meyering
16c1678f6d . 1995-03-17 04:05:46 +00:00
Jim Meyering
b94687cecb Detect when -N argument is too large to fit in an off_t. 1995-03-16 21:54:02 +00:00
Jim Meyering
4976b0c0c2 . 1995-03-12 18:31:55 +00:00
Jim Meyering
cb715fe584 . 1995-03-12 18:21:38 +00:00
Jim Meyering
858157b65b . 1995-03-12 18:12:18 +00:00
Jim Meyering
f8b678f7c8 Better but-reporting instructions.
wc tweak: lines->newlines.
1995-03-12 18:07:15 +00:00
Jim Meyering
e71dcd4c81 Undef __P before defining it. 1995-03-12 18:06:08 +00:00
Jim Meyering
ae50e4b6fc . 1995-03-12 18:00:33 +00:00
Jim Meyering
91f5d65874 Make source const. 1995-03-12 15:26:36 +00:00
Jim Meyering
e677aefec1 Update from glibc. 1995-03-12 15:26:09 +00:00
Jim Meyering
1423198343 add 1995 to Copyright dates 1995-03-10 04:15:06 +00:00
Jim Meyering
0d6850348c add 1995 to Copyright dates 1995-03-09 22:33:05 +00:00
Jim Meyering
eba8aab7f2 add 1995 to Copyright dates 1995-03-09 22:20:59 +00:00
Jim Meyering
c2c77cdc0f . 1995-03-06 14:20:34 +00:00
Jim Meyering
d307cc738a from Karl Berry 1995-03-06 14:11:41 +00:00
Jim Meyering
6e811f30ac (SET_REGS_MATCHED): Enclose if-stmt in `do {...} while(0)'
instead of using trailing `else' -- otherwise, gcc -Wall complains
of `empty body in an else-statement'.
1995-02-28 13:54:33 +00:00
Jim Meyering
40f6e92067 (wc): oops. Add missing dcl of stats. 1995-02-28 12:50:35 +00:00
Jim Meyering
b53cae8492 Always include system headers, but define-away any putenv prototype. 1995-02-28 12:08:03 +00:00
Jim Meyering
861ff7f26c Remove sys-dependent cruft and define-away getopt in system headers
instead.
1995-02-28 12:06:57 +00:00
Jim Meyering
9ac5e4ef97 (color_indicator[0]): Add missing `['. 1995-02-27 16:37:54 +00:00
Jim Meyering
2b4f9ff609 . 1995-02-27 14:54:45 +00:00
Jim Meyering
7cdef7f19f . 1995-02-27 14:51:30 +00:00
Jim Meyering
e9c2895a55 (userid_compare): K&R'ify function definition. 1995-02-27 14:47:40 +00:00
Jim Meyering
30d09ddbed (correct_password): Use memset instead of bzero. 1995-02-27 14:09:10 +00:00
Jim Meyering
617dbb12c2 (main, set_window_size): Use memset instead of bzero. 1995-02-27 14:07:58 +00:00
Jim Meyering
5d49fcbeaa Remove \n's from error format strings.
(main): Let `seq 1 1' work.
Invoke usage always with 1 when failing.
1995-02-27 14:05:43 +00:00
Jim Meyering
788bd6716f (docolon): Use memset instead of bzero. 1995-02-27 06:01:27 +00:00
Jim Meyering
829c226954 (batch_convert): Remove any trailing newline from offending
line before including it in the `invalid date' error from `date -f'.
Reported by Franc,ois Pinard.
1995-02-27 06:00:14 +00:00
Jim Meyering
06b585059b (wc): Put back test for S_ISREG. On some systems lseek returns zero for
non-regular files (esp ttys on SunOS) even when it fails.
1995-02-27 00:07:35 +00:00
Jim Meyering
0988b76df5 . 1995-02-26 19:05:34 +00:00
Jim Meyering
8467987e4b . 1995-02-26 05:09:04 +00:00
Jim Meyering
5f40ddc1a1 . 1995-02-24 04:31:04 +00:00
Jim Meyering
6812f61900 (restore_cwd): Test whether fchdir return value is non-zero, not negative.
Be consistent!
1995-02-23 21:14:12 +00:00
Jim Meyering
aeebbd038c (save_cwd) [!HAVE_FCHDIR]: Avoid a core dump via abort() which occurred
because cwd->desc was uninitialed.
(restore_cwd) [!HAVE_FCHDIR]: Remove unnecessary redefinition of fchdir.
Both from Bruno Haible.
1995-02-23 21:12:11 +00:00
Jim Meyering
875eafd489 (count_entry): Fix bug in polarity of safe-stat status test. 1995-02-21 05:19:03 +00:00
Jim Meyering
03daea30a6 (save_cwd, restore_cwd): New functions.
(main): Use them instead of in-line versions.
(count_entry): Use them here instead of relying on chdir ("..") --
but only when necessary.  Before, with --dereference (-L),
traversing a symlink caused failure because chdir ("..") didn't
work as expected.  Reported by Bruno Haible.
1995-02-21 05:01:08 +00:00
Jim Meyering
44416660ae update from FSF 1995-02-16 20:25:54 +00:00
Jim Meyering
695dd11003 (wc): Fix off-by-one error when counting lines. 1995-02-16 00:10:49 +00:00
Jim Meyering
e1453c467f . 1995-02-11 14:15:09 +00:00
Jim Meyering
a40b092725 (SOURCES): Add memcmp.c, memcpy.c, and memset.c. 1995-02-11 14:11:36 +00:00
Jim Meyering
b4994dc3fe . 1995-02-11 14:02:02 +00:00
Jim Meyering
4ef39a33cb (copy): Use memset, not bzero.
(copy_simple): Use memcpy, not bcopy.
1995-02-11 13:58:11 +00:00
Jim Meyering
b743f8afc3 Remove index/rindex and bcmp/bcopy/bzero references.
Separate errno declaration from STDC_HEADERS.
1995-02-11 13:53:39 +00:00
Jim Meyering
f299c4e0f6 . 1995-02-11 13:36:02 +00:00
Jim Meyering
79c16924de Fix example in comment. 1995-02-11 13:21:46 +00:00
Jim Meyering
a3d2e589ed (wc): Eliminate fstat call -- using lseek is sufficient.
Detect/handle case in which CURR position > EOF.
1995-02-10 05:53:54 +00:00
Jim Meyering
15d9f70d1a (wc): Handle separately the cases in which words need
not be counted.  Suggested by Karl Heuer.
(wc): Use memchr.c instead.
1995-02-10 05:34:27 +00:00
Jim Meyering
d131ddcf1f (wc): Add a separate loop for counting only lines or lines and bytes.
From Karl Heuer.
1995-02-09 17:15:17 +00:00
Jim Meyering
05d1bec3e5 (wc): Don't overcount the number of bytes when reading from
a regular file on stdin with file pointer not at BOF.  From Karl Heuer.
1995-02-09 17:05:43 +00:00
Jim Meyering
b968f43e95 . 1995-01-29 05:34:15 +00:00
Jim Meyering
5695b2f051 (parse_old_offset): Use strchr, not index. 1995-01-29 05:33:05 +00:00
Jim Meyering
faed18c267 (extract_regexp): Use strrchr, not rindex. 1995-01-29 05:32:10 +00:00
Jim Meyering
8c3911c2b4 . 1995-01-28 14:07:41 +00:00
Jim Meyering
a6f7c6d0c7 . 1995-01-28 13:23:10 +00:00
Jim Meyering
6be15c9af0 (substr): Don't allocate a byte for trailing NUL in result
since the result needn't be NUL-terminated.  Don't NUL terminate it.
1995-01-28 13:22:53 +00:00
Jim Meyering
7fc638a948 (pipe_lines, pipe_bytes): Use memcpy instead of bcopy. 1995-01-28 13:22:25 +00:00
Jim Meyering
3cd9e1dd23 (append_equiv_class): Use memcpy instead of bcopy.
(card_of_complement, set_initialize): Use memset, not bzero.
1995-01-28 13:15:35 +00:00
Jim Meyering
af7e99c091 (tac): Use memmove instead of bcopy.
(output): Use memcpy instead of bcopy.
1995-01-28 13:09:42 +00:00
Jim Meyering
9646d48630 (main): Use memset, not bzero.
(line_bytes_split): Use memmove instead of bcopy.
1995-01-28 13:06:29 +00:00
Jim Meyering
849868e342 (checkfp, mergefps): Use memcpy instead of bcopy.
(fillbuf): Use memmove instead of bcopy.
1995-01-28 13:04:27 +00:00
Jim Meyering
197bc3fd5a (decode_format_string): Use memmove instead of bcopy.
[EQUAL_BLOCKS]: Use memcmp, not bcmp.
(dump): Use memset, not bzero.
1995-01-28 13:02:44 +00:00
Jim Meyering
392dd54529 (fold_file): Use memmove instead of bcopy. 1995-01-28 13:00:10 +00:00
Jim Meyering
3794d3b8ad . 1995-01-28 04:58:03 +00:00
Jim Meyering
42a6a38712 (isopen, isclose, isperiod): Use strchr, not index.
(flush_paragraph): Use memmove instead of bcopy.
1995-01-28 04:57:45 +00:00
Jim Meyering
45f162ad7a (load_buffer): Use memcpy rather than bcopy. 1995-01-28 04:47:03 +00:00
Jim Meyering
9a915d886e (cat): Use memmove rather than bcopy. 1995-01-28 04:45:19 +00:00
Jim Meyering
1976546062 . 1995-01-27 19:32:16 +00:00
Jim Meyering
fedcb63136 (get_fs_usage, statfs): Use safe_read, and safe_stat rather than
bare read and stat.
1995-01-27 17:20:54 +00:00
Jim Meyering
7ccb88fbc5 Declare errno if it's not defined.
Rename SAFE_STAT to safe_stat.
1995-01-27 17:16:56 +00:00
Jim Meyering
0fd3803567 Declare errno if it's not defined. 1995-01-27 17:16:19 +00:00
Jim Meyering
b284f343cb (DEFS): Remove -Dlint.
(DISTFILES): Add error.h.
1995-01-27 17:09:18 +00:00
Jim Meyering
5dabd0cdec Rename SAFE_STAT to safe_stat. 1995-01-27 17:07:36 +00:00
Jim Meyering
fbf807583e Rename SAFE_STAT to safe_stat. 1995-01-27 17:05:42 +00:00
Jim Meyering
e6e3d524da Rename SAFE_STAT to safe_stat. 1995-01-27 17:05:11 +00:00
Jim Meyering
69f39255bc Rename SAFE_STAT and SAFE_LSTAT to lower case names. 1995-01-27 17:03:21 +00:00
Jim Meyering
b4cde80810 . 1995-01-27 15:35:17 +00:00
Jim Meyering
85bb215ab8 (basename): Use strrchr, not rindex.
[!STDC_HEADERS && !HAVE_STRING_H]: Define strrchr to rindex.
1995-01-27 15:23:48 +00:00
Jim Meyering
b38a5a7a17 . 1995-01-27 15:01:25 +00:00
Jim Meyering
4ecaaf1fa7 . 1995-01-27 15:00:54 +00:00
Jim Meyering
428920f8fc . 1995-01-27 14:41:51 +00:00
Jim Meyering
4e2a9fa5f2 . 1995-01-27 05:39:25 +00:00
Jim Meyering
1a41e74d32 . 1995-01-27 05:37:03 +00:00
Jim Meyering
66444bdafb Remove/rewrite some comments. 1995-01-27 05:36:14 +00:00
Jim Meyering
b554fee401 . 1995-01-27 05:22:23 +00:00
Jim Meyering
293530a4c8 . 1995-01-25 04:32:58 +00:00
Jim Meyering
8b285f6be9 * fmt.c (copy_rest): Replace ||' with &&'. Before, a paragraph
not followed by a newline would be followed by data copied from
uninitialized storage.  Repeat by `printf abc|fmt|od -ac'.
Reported by Franc,ois Pinard.
1995-01-25 04:32:15 +00:00
Jim Meyering
851162a0da Rename macros with FP_ prefix. Use FLOAT_ instead.
AIX-2.2.1 declares a typedef, FP_DOUBLE, that conflicted.
Be careful to use off_t instead of explicit `unsigned long'.
Otherwise, systems like 4.4BSD lose on calls to fseek that
expect off_t (which is long long on that system).
(parse_old_offset): Use xstrtoul
(main): Likewise.
1995-01-25 04:19:46 +00:00
Jim Meyering
41fc246374 Don't use legal' when you mean valid'. 1995-01-17 13:57:22 +00:00
Jim Meyering
cfaf788606 Fix typo: seperator -> separator. 1995-01-12 05:03:08 +00:00
Jim Meyering
98b530a36d Remove FIXMEs.
(get_width_format): Use stub function if not all of the needed math
functions are available.  From Ulrich.
(main): Give reason for failure.
1995-01-08 20:20:19 +00:00
Jim Meyering
9485d96553 See log in textutils/lib/. 1995-01-08 19:33:34 +00:00
Jim Meyering
f30ca710d9 . 1995-01-08 19:30:12 +00:00
Jim Meyering
4ad4a00de4 Add some FIXME comments. 1994-12-31 18:38:23 +00:00
Jim Meyering
81f671740e Include "system.h".
Don't explicitly include headers that it includes.
Use error, not `fprintf (stderr'.
1994-12-31 18:32:47 +00:00
Jim Meyering
d6b36e21cb Minor indentation change.
(usage): Change wording a little.
1994-12-31 18:17:34 +00:00
Jim Meyering
47d3dc6fc3 From Ulrich Drepper. 1994-12-31 18:04:40 +00:00
Jim Meyering
d4ba41692f . 1994-12-31 17:56:47 +00:00
Jim Meyering
a872332ad9 . 1994-12-31 17:55:01 +00:00
Jim Meyering
e8bb8dff6a . 1994-12-31 17:54:33 +00:00
Jim Meyering
e0c2f72ee5 . 1994-12-31 17:53:04 +00:00
Jim Meyering
60d3ac3f15 . 1994-12-31 17:51:57 +00:00
Jim Meyering
e50ceb339f still checking 1994-12-31 17:46:31 +00:00
Jim Meyering
6a8f231a9c checking whether cvs lock works 1994-12-31 17:43:19 +00:00
Jim Meyering
029da0400b (print_factors): Increase size of FACTOR array to 128. 1994-12-31 17:39:22 +00:00
Jim Meyering
3de797b535 Indent.
Add deactivated assertions.
1994-12-31 17:33:56 +00:00
Jim Meyering
14842c9a59 Use readtoken. 1994-12-31 15:28:51 +00:00
Jim Meyering
652d4c6cd6 . 1994-12-27 13:39:54 +00:00
Jim Meyering
59097c0922 Include "error.h" rather than simply declaring `void error ();'. 1994-12-27 13:36:22 +00:00
Jim Meyering
dcb4b37240 * dd.c (skip): Use safe_read instead of read.
(copy): Use full_write instead of write.
	From Bruno Haible.
1994-12-27 13:12:52 +00:00
Jim Meyering
410e779e8d * sync.c (main): Make error message accurate. 1994-12-27 13:08:05 +00:00
Jim Meyering
d7cd6fb738 Write file name instead of filename. 1994-12-27 05:28:58 +00:00
Jim Meyering
ca39edc494 . 1994-12-27 02:50:40 +00:00
Jim Meyering
2ea2c7bf78 [member]: Use strchr instead of index. 1994-12-27 02:47:50 +00:00
Jim Meyering
b772193f4b . 1994-12-27 02:46:10 +00:00
Jim Meyering
c84154eb28 * test.c (term): Running `./test \( a -o b' got a seg fault.
From Klaus.Reichl@aut.alcatel.at.
1994-12-27 00:33:03 +00:00
Jim Meyering
72bb9e6307 Rearrange to accept a user-specified set of suffix chars (must be
a subset of master list), each with a hard-coded value.
1994-12-22 05:10:32 +00:00
Jim Meyering
7c141b258d (main): Update xstrtol calls to be consistent with new decl. 1994-12-22 05:08:40 +00:00
Jim Meyering
2999aefb84 . 1994-12-20 05:26:56 +00:00
Jim Meyering
a9f1783e20 * src/*.c: Include "error.h" instead of simply declaring
`void error ();'.
1994-12-20 05:26:44 +00:00
Jim Meyering
6bb619d33c Begin overhaul. 1994-12-20 05:24:13 +00:00
Jim Meyering
0477175963 . 1994-12-20 05:10:42 +00:00
Jim Meyering
eaa5cc3f91 . 1994-12-20 05:05:55 +00:00
Jim Meyering
735c6a9adc (test_stat, binary_operator): Use safe_stat instead of SAFE_STAT.
(unary_operator): Use safe_lstat instead of SAFE_LSTAT.
1994-12-20 04:51:10 +00:00
Jim Meyering
6d59e126b5 (print_entry): Use safe_stat instead of SAFE_STAT. 1994-12-20 04:50:25 +00:00
Jim Meyering
bb705c7c3e (dir_ok): Use safe_stat instead of SAFE_STAT. 1994-12-20 04:49:55 +00:00
Jim Meyering
398dbbb832 (numerous functions): Give char* filename arguments the const attribute. 1994-12-20 04:27:35 +00:00
Jim Meyering
90a33c19fe . 1994-12-20 04:23:49 +00:00
Jim Meyering
3205d087e2 . 1994-12-20 04:17:23 +00:00
Jim Meyering
a09358fc2c . 1994-12-20 04:15:30 +00:00
Jim Meyering
c5811b6a26 (main): Use safe_stat, not SAFE_STAT. 1994-12-20 04:03:28 +00:00
Jim Meyering
73d8d0a43f Include "error.h" instead of simply declaring `void error ();'.
(main): Don't advance optarg past leading sign -- otherwise, we'd
be making tail accept invalid options like `-+1'.
(tail_file): Fix call to error with %s in format, but no corresponding argument.
1994-12-16 05:45:57 +00:00
Jim Meyering
7323b7d9f2 Include "error.h" instead of simply declaring `void error ();'. 1994-12-16 05:42:47 +00:00
Jim Meyering
8d6c6946dd Include "error.h" instead of simply declaring `void error ();'. 1994-12-16 05:41:05 +00:00
Jim Meyering
029fcaa913 (main): Use %lu, not %d for unsigned long.
(my_strtoul, uint_fatal_error): Remove functions.  Use xstrtoul
and STRTOL_FATAL_ERROR instead.
1994-12-16 05:32:30 +00:00
Jim Meyering
bebb9b3286 (main): Move to end.
(factor, do_stdin): Declare static.
1994-12-13 05:42:44 +00:00
Jim Meyering
3ae9a27c25 (docolon): Zero out re_buffer and re_regs before using them.
From H.J. Lu <hjl@nynexst.com>.
1994-12-13 04:42:23 +00:00
Jim Meyering
0050411112 . 1994-12-12 17:49:55 +00:00
Jim Meyering
5bfdd91cdf . 1994-12-12 00:00:28 +00:00
Jim Meyering
88442ad885 sort.c (main): Fix interpretation of field offsets when specified
via -k option.  They were being interpreted as zero-indexed.
POSIX says they are 1-based indices.
(keycompare): Don't ignore characters at the end of words
when otherwise they compare equal.  Both from Rik Faith
<faith@cs.unc.edu>.
1994-12-12 00:00:22 +00:00
Jim Meyering
f46511eb69 * (<most functions>): Change the type of n_units/n_lines/n_bytes
to off_t because n_bytes is used as the option to fseek and off_t may
be long long (e.g. on BSD4.4).  The only place where a 32-bit limit is
imposed is in the string-to-integer converstion of xstrtol.
(main): Use xstrtol instead of manual string to integer conversion.
1994-12-11 23:53:54 +00:00
Jim Meyering
cfa6527373 . 1994-12-11 23:44:07 +00:00
Jim Meyering
0e168c7d03 (get_format_width, get_format_prec): Use ISDIGIT instead of
comparisons against '0' and '9'.
1994-12-11 23:43:21 +00:00
Jim Meyering
9c5d0aa7a6 [ULONGMAX]: Define it.
[LONGMAX]: Define in terms of ULONGMAX instead of as a 32-bit constant.
1994-12-11 23:31:12 +00:00
Jim Meyering
5b66c03ac0 . 1994-12-11 23:13:08 +00:00
Jim Meyering
5dd4159e77 (safe_read): Get this function from gcc's cccp.c. 1994-12-10 22:00:12 +00:00
Jim Meyering
b3d3591aed . 1994-12-10 06:04:53 +00:00
Jim Meyering
fb5c9e690f . 1994-12-10 05:48:14 +00:00
Jim Meyering
e737fe145f . 1994-12-10 05:46:18 +00:00
Jim Meyering
abdf594b85 No longer include <ctype.h>.
[isascii, ISDIGIT]: Remove definitions.
1994-12-10 05:45:52 +00:00
Jim Meyering
33c44e1d1b No longer include <ctype.h>.
Remove IS* macros.
1994-12-10 05:45:02 +00:00
Jim Meyering
ec27c85596 No longer include <ctype.h>. 1994-12-10 05:43:18 +00:00
Jim Meyering
36a504f605 (copy, make_path_private): Use strr?chr instead of r?index. 1994-12-10 05:41:52 +00:00
Jim Meyering
c95989d148 (parse_conversion, scan_args): Use strr?chr instead of r?index. 1994-12-10 05:41:16 +00:00
Jim Meyering
06f4d47a29 (remove_parents): Use strr?chr instead of r?index. 1994-12-10 05:39:59 +00:00
Jim Meyering
7f58bbba88 * [!HAVE_STRING_H]: Define strchr to index and strrchr to
rindex instead of the other way around.
* Include <ctype.h> and define IS* macros.
1994-12-10 05:25:15 +00:00
Jim Meyering
651ccf648d No longer include <ctype.h>. 1994-12-10 05:21:29 +00:00
Jim Meyering
2a242b8989 New chapter by Arnold Robbins via Karl. 1994-12-07 14:17:04 +00:00
Jim Meyering
f445de3b86 . 1994-12-04 21:15:54 +00:00
Jim Meyering
12042b2fa2 Use strr?chr instead of r?index. 1994-12-04 21:15:46 +00:00
Jim Meyering
06084cb7e8 Get putenv.c from /copies (derived from glibc).
Hack it to work with SGI's __environ junk.
1994-12-04 21:08:50 +00:00
Jim Meyering
96dd28efa2 . 1994-12-04 20:56:35 +00:00
Jim Meyering
3b0ea78aef . 1994-12-04 20:55:30 +00:00
Jim Meyering
be4a8a192a . 1994-12-04 20:53:43 +00:00
Jim Meyering
fec974e60e (DISTFILES): Add getdate.texi. 1994-12-04 20:52:46 +00:00
Jim Meyering
5150ebf157 Mods from Karl to include getdate.texi. 1994-12-04 20:50:57 +00:00
Jim Meyering
9a102f76c8 . 1994-12-04 20:48:11 +00:00
Jim Meyering
1d6dc36be9 (du_files): Handle very low-probability fchdir failure (when errno != 0
&& errno != EINVAL).
1994-12-03 20:38:20 +00:00
Jim Meyering
9f715b2bdb (du_files): Variable name changes. 1994-12-03 20:29:28 +00:00
Jim Meyering
103e83b65e (du_files): Work around SunOS restriction that fchdir doesn't work when
accounting is enabled -- modelled after djm's find.c mods.
1994-12-03 20:26:33 +00:00
Jim Meyering
f55a29ab93 (checkfp): Initialize keybeg and keylim fields.
Before, this command
  perl -e 'print join ("\n", (1..513)), "\n";'|sort -cs -n
failed on SunOS 4 systems.  From Robert H. de Vries <robert@and.nl>.
1994-12-02 16:54:56 +00:00
Jim Meyering
97f9755aeb (xfclose): Report failed fflush. Otherwise, failed write to stdout
could be missed because of subsequent clearerr.
(main): Include filename in a couple error messages.
Add missing %s in an error format string.
1994-12-02 16:49:47 +00:00
Jim Meyering
f2fc6e9054 name changes: number->n_lines|n_bytes 1994-11-30 20:54:21 +00:00
Jim Meyering
04b546bdb9 Make some globals static' and/or const'.
(LEN_STR_PAIR): New macro.
(decode_switches): Only ignore invalid TABSET value instead of dying.
(parse_ls_color): Use error, not fprintf.
(print_type_indicator): Remove dcls of two unused variables.
1994-11-28 06:00:56 +00:00
Jim Meyering
f214bd45dc indent 1994-11-28 04:38:27 +00:00
Jim Meyering
f021d0ca05 (indent): Use TABs only when doing so replaces at least two spaces. 1994-11-28 04:32:07 +00:00
Jim Meyering
c65e1fe89f `colorize' patch from Drepper. 1994-11-28 04:25:31 +00:00
Jim Meyering
7f2c21525b . 1994-11-21 14:23:15 +00:00
Jim Meyering
5fce52076e (list_entries): Delete. Split in two actually...
(list_entries_users, list_entries_who, userid_compare): New functions.
(list_entries_users): Sort the user names.  Reported by
Michael I Bushnell.
Topologically sort the functions and remove fwd declarations.
1994-11-18 05:15:04 +00:00
Jim Meyering
42c03d3135 . 1994-11-17 17:37:22 +00:00
Jim Meyering
fdfd720ec4 (output): Use STDOUT_FILENO instead of `1' in xwrite call. 1994-11-17 12:49:38 +00:00
Jim Meyering
53c46c67ac (dump_remainder): Flush standard output just before
sleeping so that `tail -f' will output partial lines sooner.
This applies only when following the end of a single file.
From Leonard N. Zubkoff <lnz@dandelion.com>.

(file_lines, pipe_lines, pipe_bytes, start_bytes, start_lines, dump_remainder):
Use STDOUT_FILENO instead of `1' in XWRITE calls.
1994-11-17 12:49:10 +00:00
Jim Meyering
13e79f4f72 Include <getopt.h> instead of "getopt.h". 1994-11-16 13:19:25 +00:00
Jim Meyering
67af2936fa (tempname): Merge two very similar sprintf stmts into one. 1994-11-16 13:16:53 +00:00
Jim Meyering
5d9de33889 Use BUFSIZ instead of BUFSIZE. 1994-11-16 13:13:07 +00:00
Jim Meyering
5356de1df7 Rewriting to help it pass a reasonable suite of tests. 1994-11-16 13:10:34 +00:00
Jim Meyering
c85cac33ab Declare DELIM to be `int' rather than unsigned char. 1994-11-16 13:09:13 +00:00
Jim Meyering
b4a1e5cb83 . 1994-11-16 13:06:45 +00:00
Jim Meyering
c35f55124b . 1994-11-16 13:05:38 +00:00
Jim Meyering
005bf81461 . 1994-11-14 22:31:47 +00:00
Jim Meyering
6b558ed117 (my_strtol): New function.
(main): Use it instead of atoi to convert argument strings to
major and minor device numbers.  Now, mknod diagnoses invalid
device numbers and accepts octal and hexadecimal as well as
decimal string arguments.  Ralf Lammers
<rlammers@physik.uni-osnabrueck.de> suggested that mknod accept
hex device numbers for compatibility with HPUX's mknod program.
1994-11-11 16:14:19 +00:00
Jim Meyering
b81d2117e2 (SOURCES): Add strtol.c. 1994-11-11 16:10:16 +00:00
Jim Meyering
34406025e5 . 1994-11-09 20:16:23 +00:00
Jim Meyering
75d902ef01 . 1994-11-08 22:40:52 +00:00
Jim Meyering
da098ddd8a . 1994-11-07 12:55:05 +00:00
Jim Meyering
cb4c5aaf0a Initial revision 1994-11-07 12:47:50 +00:00
Jim Meyering
8761507929 . 1994-11-07 05:38:19 +00:00
Jim Meyering
ba2a317029 . 1994-11-07 05:37:05 +00:00
Jim Meyering
c47ec4af2a Add test names. 1994-11-07 04:36:41 +00:00
Jim Meyering
1f875effab Add -w and clean up. 1994-11-07 04:36:07 +00:00
Jim Meyering
4c722a96ba merge with 1.12 1994-11-06 17:51:23 +00:00
Jim Meyering
c67fdb5c94 merge with 1.11 1994-11-06 17:47:32 +00:00
Jim Meyering
398d617cc9 merge with 1.10 1994-11-06 17:42:51 +00:00
Jim Meyering
0683ef74d1 Initial revision 1994-11-06 17:40:20 +00:00
Jim Meyering
4f89d5bcfa merge with 1.12 1994-11-05 14:17:55 +00:00
Jim Meyering
9bfdace83a merge with 3.10 1994-11-05 13:37:38 +00:00
Jim Meyering
fad3ef71a4 merge with 3.9u1 1994-11-04 16:50:04 +00:00
Jim Meyering
c21a3a4ec6 merge with 1.9.1k1 1994-11-04 16:43:33 +00:00
Jim Meyering
05bcdf4d41 . 1994-11-04 14:48:40 +00:00
Jim Meyering
cda4ac2e91 . 1994-11-04 14:15:12 +00:00
Jim Meyering
8de255ea61 Change _P to __P. 1994-11-04 14:04:43 +00:00
Jim Meyering
4b579f1836 . 1994-11-04 14:04:03 +00:00
Jim Meyering
8edc08d48e Include makepath.h.
Add an argument: PRESERVE_EXISTING.
Declare char* arguments const.
1994-11-04 06:05:34 +00:00
Jim Meyering
3b99cd3ae3 . 1994-11-04 06:04:42 +00:00
Jim Meyering
0ccaadc62c Include <limits.h> before system.h because limits.h on
some systems undefines PATH_MAX, whereas system.h includes pathmax.h
which sets PATH_MAX.  From Kaveh Ghazi.
1994-11-04 06:04:02 +00:00
Jim Meyering
aebff608dc (make_path_private): Rename function from make_path to avoid confusion.
(do_copy): Update caller.
1994-11-04 06:03:25 +00:00
Jim Meyering
0e1e2d8069 (DISTFILES): Add makepath.h.
(makepath.o): Depend on it.
1994-11-04 06:02:21 +00:00
Jim Meyering
7cced49416 Update calls to make_path. 1994-11-04 06:00:41 +00:00
Jim Meyering
70fe5e3261 . 1994-11-03 22:32:35 +00:00
Jim Meyering
b808409fe7 (rwx): Use S_IRUSR, S_IWUSR, S_IXUSR instead of obsolete
S_IREAD, S_IWRITE, S_IEXEC.
Make sure the former three are defined.
1994-11-03 22:03:54 +00:00
Jim Meyering
17a29b6eea Define S_IXUSR, S_IXGRP, and S_IXOTH in terms of _IEXEC if they're not
already defined.  Reported by Daniel Hagerty <hag@gnu.ai.mit.edu>.
1994-11-03 22:03:16 +00:00
Jim Meyering
8d447abdbf merge with 3.9t3 1994-11-03 04:34:05 +00:00
Jim Meyering
1423156a9c merge with 1.9.1j2 1994-11-03 04:33:52 +00:00
Jim Meyering
40f3df0acd merge with 1.9.1j2 1994-11-03 04:33:22 +00:00
Jim Meyering
4e253268e1 merge with 1.10x1 1994-11-03 00:58:25 +00:00
Jim Meyering
21229f21b4 . 1994-11-02 23:55:02 +00:00
Jim Meyering
995c18ba28 . 1994-11-02 05:24:13 +00:00
Jim Meyering
c6411b91f5 (cat): Conditionalize test for errno == ENOSYS. It's not
defined on some Next and Alliant systems.  From Kaveh Ghazi.
1994-11-02 05:21:37 +00:00
Jim Meyering
346a1b2351 (cut_bytes): Print at least a newline for every line of input.
(cut_fields): Print a newline even for lines whose only selected
field is empty.  But print nothing when using -s without -f1.
And print nothing for empty input.  Reported by
Richard_Sharman@software.mitel.com.
1994-11-02 05:04:17 +00:00
Jim Meyering
32340b45e7 (XWRITE): Guard against calling xwrite with n_bytes == 0. 1994-11-01 22:38:11 +00:00
Jim Meyering
7a5462a0b7 (XWRITE): Allow n_bytes to be zero in assertion. Otherwise `tail /dev/null'
gets failed assertion.
1994-11-01 22:21:23 +00:00
Jim Meyering
ca83b5d174 merge with 3.9t2 1994-11-01 14:57:56 +00:00
Jim Meyering
7a1813fe39 merge with 3.9t2 1994-11-01 14:57:28 +00:00
Jim Meyering
e877a26079 Initial revision 1994-11-01 14:50:16 +00:00
Jim Meyering
a175b4affb . 1994-10-31 14:03:58 +00:00
Jim Meyering
159929688d . 1994-10-31 12:55:27 +00:00
Jim Meyering
5b4430b4d2 merge with 1.9.1j 1994-10-31 04:38:31 +00:00
Jim Meyering
67e2c217d6 . 1994-10-31 04:15:31 +00:00
Jim Meyering
c2f3b72b93 merge with 1.9.1i1 1994-10-30 13:56:10 +00:00
Jim Meyering
2654c2012b merge with 1.9.1i 1994-10-30 05:28:15 +00:00
Jim Meyering
21b82f43b9 . 1994-10-29 05:06:43 +00:00
Jim Meyering
1fd77b2ddf . 1994-10-29 04:49:55 +00:00
Jim Meyering
2ef20008e8 . 1994-10-28 18:32:31 +00:00
Jim Meyering
c0119ac534 . 1994-10-28 17:03:06 +00:00
Jim Meyering
1cd8c36e4d merge with 3.9t 1994-10-27 23:36:15 +00:00
Jim Meyering
2e9d555f8c . 1994-10-27 13:45:55 +00:00
Jim Meyering
f6b8bdc529 merge with 3.9s 1994-10-27 13:43:59 +00:00
Jim Meyering
0c9fb4050b merge with 1.10x 1994-10-27 13:39:39 +00:00
Jim Meyering
2ba9e70e52 merge with 3.9q 1994-10-27 05:02:28 +00:00
Jim Meyering
51244615e9 merge with 3.9q 1994-10-27 05:02:05 +00:00
Jim Meyering
c0c7ee9ab1 merge with 1.10w 1994-10-27 04:47:39 +00:00
Jim Meyering
4c8adc4821 . 1994-10-27 04:18:00 +00:00
Jim Meyering
9f7d860db2 merge with 1.10u 1994-10-24 20:07:32 +00:00
Jim Meyering
4cc84a6164 . 1994-10-21 13:37:48 +00:00
Jim Meyering
b902a4439e merge with 1.10t 1994-10-21 05:25:03 +00:00
Jim Meyering
aa3d6d01e8 . 1994-10-20 16:22:32 +00:00
Jim Meyering
154bd660bb merge with 3.9p 1994-10-20 16:16:39 +00:00
Jim Meyering
adeff820d3 Initial revision 1994-10-20 16:10:00 +00:00
Jim Meyering
3bdb536a55 . 1994-10-20 15:29:38 +00:00
Jim Meyering
5868a8d57c . 1994-10-20 14:57:33 +00:00
Jim Meyering
550968ec92 . 1994-10-20 14:48:51 +00:00
Jim Meyering
9f167c85b0 . 1994-10-20 04:42:43 +00:00
Jim Meyering
544baf5482 merge with 1.9.1h 1994-10-19 03:39:33 +00:00
Jim Meyering
6a76abbf9c . 1994-10-19 02:45:36 +00:00
Jim Meyering
131aa77dd9 . 1994-10-18 23:23:44 +00:00
Jim Meyering
3e9cafcf42 merge with 1.10s 1994-10-18 23:23:04 +00:00
Jim Meyering
ee2f172106 . 1994-10-18 22:55:26 +00:00
Jim Meyering
f9fea3cd18 . 1994-10-17 14:19:50 +00:00
Jim Meyering
ed41665d78 . 1994-10-17 14:03:27 +00:00
Jim Meyering
d8843f4b6e . 1994-10-17 14:01:44 +00:00
Jim Meyering
f45f10b17d . 1994-10-17 13:24:35 +00:00
Jim Meyering
ff18f4c072 . 1994-10-15 02:40:27 +00:00
Jim Meyering
4157d2bf7f . 1994-10-13 04:03:24 +00:00
Jim Meyering
977995573d merge with 3.9n 1994-10-13 02:57:52 +00:00
Jim Meyering
3593b80a51 merge with 1.10r 1994-10-13 02:16:01 +00:00
Jim Meyering
d3a7a3d262 . 1994-10-11 01:56:53 +00:00
Jim Meyering
d3d49453a4 . 1994-10-10 01:17:52 +00:00
Jim Meyering
ec7c19de56 . 1994-10-09 05:24:31 +00:00
Jim Meyering
a41f5ad96e . 1994-10-09 05:06:10 +00:00
Jim Meyering
eb57e662fc . 1994-10-09 05:03:54 +00:00
Jim Meyering
c0723b4189 merge with 3.9k 1994-10-08 17:26:58 +00:00
Jim Meyering
e8670c071b merge with 3.9j 1994-10-08 16:56:34 +00:00
Jim Meyering
09b0c4ab6e . 1994-10-08 16:39:30 +00:00
Jim Meyering
deef174caa . 1994-10-08 16:38:01 +00:00
Jim Meyering
35adb7c5be . 1994-10-08 14:52:10 +00:00
Jim Meyering
f827615b89 merge with 3.9i 1994-10-08 04:54:06 +00:00
Jim Meyering
09d7d195be merge with 3.9i 1994-10-08 02:42:43 +00:00
Jim Meyering
4b8534f940 . 1994-10-08 02:05:20 +00:00
Jim Meyering
7354f66153 . 1994-10-08 02:04:47 +00:00
Jim Meyering
9c9b761562 . 1994-10-08 00:58:41 +00:00
Jim Meyering
d72ab4ffe7 . 1994-10-08 00:56:50 +00:00
Jim Meyering
d734172c73 merge with 1.10q 1994-10-08 00:40:55 +00:00
Jim Meyering
5a31cea3d4 . 1994-10-08 00:34:54 +00:00
Jim Meyering
0eb406c7e6 . 1994-10-07 23:46:47 +00:00
Jim Meyering
94d327a68a . 1994-10-07 01:19:51 +00:00
Jim Meyering
33a89ddba5 . 1994-10-05 00:43:46 +00:00
Jim Meyering
83577ddb4d . 1994-10-03 03:01:32 +00:00
Jim Meyering
c9b696a6bd merge with 1.9.1g 1994-10-02 23:01:05 +00:00
Jim Meyering
b2e7f0596a Initial revision 1994-10-02 22:50:11 +00:00
Jim Meyering
3994e55f58 . 1994-10-02 22:11:44 +00:00
Jim Meyering
7079da8b5a . 1994-10-02 22:10:57 +00:00
Jim Meyering
d9a92fd81c . 1994-10-02 21:12:44 +00:00
Jim Meyering
f1ce35a10c merge with 3.9h 1994-10-02 05:43:03 +00:00
Jim Meyering
c543c4b10c merge with 3.9h 1994-10-02 05:42:43 +00:00
Jim Meyering
ff6263f4f9 Initial revision 1994-10-02 05:35:52 +00:00
Jim Meyering
f17c045d21 . 1994-10-02 02:09:38 +00:00
Jim Meyering
b055972c6b . 1994-10-01 18:06:39 +00:00
Jim Meyering
bc60940ea9 merge with 1.10p 1994-10-01 13:06:03 +00:00
Jim Meyering
11020daf89 merge with 1.10n5 1994-10-01 04:48:44 +00:00
Jim Meyering
e9bbe5be67 merge with 1.10n4 1994-10-01 04:37:18 +00:00
Jim Meyering
fe1ad4509c . 1994-10-01 04:15:13 +00:00
Jim Meyering
ea89a760d8 . 1994-10-01 04:14:50 +00:00
Jim Meyering
ec90359f34 . 1994-10-01 02:52:05 +00:00
Jim Meyering
c8131583ac Update from Karl. 1994-10-01 02:22:07 +00:00
Jim Meyering
10c7a38d84 . 1994-09-30 00:50:23 +00:00
Jim Meyering
7413391dae test 1994-09-30 00:50:13 +00:00
Jim Meyering
eed9880cdd . 1994-09-30 00:05:41 +00:00
Jim Meyering
dccf44af32 . 1994-09-29 23:47:37 +00:00
Jim Meyering
3c28751b48 merge with 1.10n3 1994-09-29 17:57:49 +00:00
Jim Meyering
31d95cf0ca . 1994-09-29 16:19:18 +00:00
Jim Meyering
8a693e3070 . 1994-09-29 16:18:55 +00:00
Jim Meyering
5cfcf6dc93 remove ansidecl junk 1994-09-28 01:19:14 +00:00
Jim Meyering
0a0800fe25 merge with 1.10n2 1994-09-27 22:02:00 +00:00
Jim Meyering
e13a0b7f49 merge with 1.10n1 1994-09-27 20:52:02 +00:00
Jim Meyering
d67dbfcf80 . 1994-09-27 04:43:08 +00:00
Jim Meyering
552cc77dcf . 1994-09-26 23:58:40 +00:00
Jim Meyering
08b0b0fe95 . 1994-09-25 16:30:49 +00:00
Jim Meyering
7d3aa65903 . 1994-09-25 13:19:17 +00:00
Jim Meyering
649d081fee merge with 1.10n 1994-09-25 03:12:38 +00:00
Jim Meyering
4bac19f0bf . 1994-09-25 02:25:20 +00:00
Jim Meyering
c09c590616 . 1994-09-25 01:56:42 +00:00
Jim Meyering
451fa3013e . 1994-09-25 01:25:18 +00:00
Jim Meyering
1ba691350b merge with 1.10m 1994-09-24 19:12:46 +00:00
Jim Meyering
4e2b49d717 . 1994-09-24 16:33:21 +00:00
Jim Meyering
c312500094 . 1994-09-24 16:31:57 +00:00
Jim Meyering
b659452519 . 1994-09-24 16:31:27 +00:00
Jim Meyering
67c493ed67 (main): Cast string literal to (char*). 1994-09-24 16:28:52 +00:00
Jim Meyering
bfb7a14ab7 Use RELEASE_DATE instead of hard-coded date. 1994-09-24 16:23:59 +00:00
Jim Meyering
cbee99cebe (read_utmp): New variable: size to avoid type warnings. 1994-09-24 16:18:11 +00:00
Jim Meyering
3d74506f21 (main, tee): More const dcls and casting. 1994-09-24 16:17:54 +00:00
Jim Meyering
d26f6b1796 (wrapf): Declare first argument const char *. 1994-09-24 16:17:35 +00:00
Jim Meyering
553cabb1d1 (main): Cast string literal to (char*). 1994-09-24 16:16:17 +00:00
Jim Meyering
fed388a533 Don't include <ctype.h> or define IS* macros since system.h now does that. 1994-09-24 15:20:51 +00:00
Jim Meyering
fd16a39c69 (main): Revamp option processing to detect options like `--7' manually
and pass the rest off to getopt_long.
(isinteger): Use ISDIGIT.
1994-09-24 15:20:21 +00:00
Jim Meyering
43545372ed Enumerate (Yuck!) the --1 .. --20 long options 1994-09-24 12:50:59 +00:00
Jim Meyering
00aa944946 (main): Make sure s is not NULL before dereferencing it. 1994-09-24 00:41:27 +00:00
Jim Meyering
f0ea13bbe9 merge with 1.10l 1994-09-19 01:39:58 +00:00
Jim Meyering
2ab8e21d5d merge with 1.10k 1994-09-18 00:42:41 +00:00
Jim Meyering
fe106be46b . 1994-09-18 00:28:34 +00:00
Jim Meyering
73b9e4b762 merge with 1.10j 1994-09-17 02:46:48 +00:00
Jim Meyering
920c0db5c0 . 1994-09-17 02:19:11 +00:00
Jim Meyering
e1b35181ba . 1994-09-17 01:58:43 +00:00
Jim Meyering
b4baf84d32 . 1994-09-17 00:17:25 +00:00
Jim Meyering
1401f3e3f9 . 1994-09-15 23:09:36 +00:00
Jim Meyering
ec13d92b20 . 1994-09-12 17:35:58 +00:00
Jim Meyering
00dceaff2e merge with 1.10i 1994-09-08 04:48:40 +00:00
Jim Meyering
556b9f622f . 1994-09-06 13:13:41 +00:00
Jim Meyering
b58bc13bee . 1994-09-05 02:19:59 +00:00
Jim Meyering
4e0d869f9a . 1994-09-04 04:18:24 +00:00
Jim Meyering
83e202ca50 . 1994-09-04 04:05:45 +00:00
Jim Meyering
d7e6b36faa . 1994-09-04 03:56:21 +00:00
Jim Meyering
b8b4c48285 . 1994-09-03 18:04:35 +00:00
Jim Meyering
6c0ec66614 . 1994-09-03 17:54:55 +00:00
Jim Meyering
af52175661 . 1994-09-03 04:27:02 +00:00
Jim Meyering
de8c62d0f0 merge with 1.10h 1994-09-01 23:20:29 +00:00
Jim Meyering
52b4bf84e7 . 1994-08-27 21:34:13 +00:00
Jim Meyering
fe4becacb4 . 1994-08-27 21:26:52 +00:00
Jim Meyering
e1a2cd7e46 . 1994-08-27 21:23:07 +00:00
Jim Meyering
94172d0764 . 1994-08-27 21:04:53 +00:00
Jim Meyering
6d3aa2169e . 1994-08-27 20:55:59 +00:00
Jim Meyering
4fb9a0a740 . 1994-08-27 20:32:40 +00:00
Jim Meyering
326b01a327 . 1994-08-25 13:28:58 +00:00
Jim Meyering
da13561d3d merge with 3.9f 1994-08-19 22:42:59 +00:00
Jim Meyering
8a5d6318e7 merge with 1.10g 1994-08-19 22:42:22 +00:00
Jim Meyering
109d16cbce . 1994-08-19 17:05:18 +00:00
Jim Meyering
cb6cf9485c . 1994-08-19 17:01:45 +00:00
Jim Meyering
257b028a06 . 1994-08-19 13:50:42 +00:00
Jim Meyering
86ba2b2bdf . 1994-08-19 13:36:37 +00:00
Jim Meyering
e50688802c . 1994-08-19 13:13:48 +00:00
Jim Meyering
1763c83a50 . 1994-08-19 12:45:55 +00:00
Jim Meyering
e1640b71fa . 1994-08-03 15:28:30 +00:00
Jim Meyering
b946e9ee2e . 1994-08-03 15:21:03 +00:00
Jim Meyering
a8778c2665 merge with 3.9e 1994-07-30 18:59:12 +00:00
Jim Meyering
32bd426778 . 1994-07-30 16:34:17 +00:00
Jim Meyering
a272d8b0c6 . 1994-07-30 16:17:45 +00:00
Jim Meyering
15ddd652be . 1994-07-30 16:12:44 +00:00
Jim Meyering
2c4f4e60d8 . 1994-07-30 16:10:22 +00:00
Jim Meyering
2399435ba4 . 1994-07-30 14:17:26 +00:00
Jim Meyering
2ac5b86618 . 1994-07-30 14:15:54 +00:00
Jim Meyering
aa60b32c1c . 1994-07-30 13:18:39 +00:00
Jim Meyering
be7d4a230e Use SAFE_STAT instead of stat to avoid unnecessary failure
on systems for which stat can return EINTR.
1994-07-30 13:13:52 +00:00
Jim Meyering
a1d3a7aee6 . 1994-07-30 13:12:40 +00:00
Jim Meyering
f1f85daaed . 1994-07-30 12:10:53 +00:00
Jim Meyering
88494fb8f3 . 1994-07-30 12:05:32 +00:00
Jim Meyering
2e3cc9b7b9 merge with 1.10f 1994-07-26 04:06:18 +00:00
Jim Meyering
7b5a41383b . 1994-07-26 03:44:37 +00:00
Jim Meyering
6cab708162 (group_member): Remove function and all its baggage. 1994-07-23 04:43:56 +00:00
Jim Meyering
340d9cec31 . 1994-07-23 04:42:46 +00:00
Jim Meyering
eebb80a187 (unary_operator): (-u, -g): Return false if S_ISUID,S_ISGID etc aren't defined. 1994-07-23 03:58:31 +00:00
Jim Meyering
fc0bbac463 * who.c (print_entry): Use SAFE_STAT. 1994-07-22 17:19:23 +00:00
Jim Meyering
754e4abb56 * test.c (test_stat, binary_operator, unary_operator): Use SAFE_STAT and
SAFE_LSTAT.
1994-07-22 17:18:46 +00:00
Jim Meyering
7314448bef * pathchk.c (dir_ok): Use SAFE_STAT. 1994-07-22 17:17:25 +00:00
Jim Meyering
dd46047168 (substr): Allocate len+1 bytes (not just len) to leave room for trailing NUL. 1994-07-13 15:45:24 +00:00
Jim Meyering
35b631eb04 . 1994-07-13 15:35:56 +00:00
Jim Meyering
545ac40616 . 1994-07-13 14:17:38 +00:00
Jim Meyering
d2205a42a1 merge with 1.10e 1994-07-13 14:11:38 +00:00
Jim Meyering
e577b09b46 . 1994-07-12 13:21:49 +00:00
Jim Meyering
53cd09b3bc merge with 1.10d 1994-07-05 02:22:12 +00:00
Jim Meyering
792d894bd9 . 1994-07-03 17:46:37 +00:00
Jim Meyering
363b712c93 . 1994-07-03 13:18:31 +00:00
Jim Meyering
763968d428 . 1994-07-03 12:48:38 +00:00
Jim Meyering
f980ff966d (main): Initialize cwd_only in first two statements, rather than as part
of the declaration.  The latter evoked an error from /bin/cc of HPUX 9.01.
1994-07-02 04:25:04 +00:00
Jim Meyering
926b8285be merge with 3.9d 1994-07-01 19:51:39 +00:00
Jim Meyering
59c6679733 Initial revision 1994-07-01 19:46:42 +00:00
Jim Meyering
414e5b1d06 . 1994-07-01 18:42:52 +00:00
Jim Meyering
c1920a67e2 . 1994-07-01 18:06:49 +00:00
Jim Meyering
5c92a5735d . 1994-07-01 17:59:34 +00:00
Jim Meyering
4eb8e70031 . 1994-07-01 16:53:29 +00:00
Jim Meyering
a32610143c (main): Change #ifdef TESTING to TEST. 1994-07-01 15:23:47 +00:00
Jim Meyering
844a6c1a11 Include alloca directives.
Replace 3 lines with V_STRDUP equivalent.
1994-07-01 14:04:23 +00:00
Jim Meyering
9e01db73f9 Rewrite. 1994-07-01 13:58:06 +00:00
Jim Meyering
8dedd7864d . 1994-07-01 13:47:06 +00:00
Jim Meyering
11023e1493 . 1994-07-01 13:46:42 +00:00
Jim Meyering
1cf80189ac . 1994-06-30 14:41:20 +00:00
Jim Meyering
1525e2cb30 . 1994-06-30 14:33:41 +00:00
Jim Meyering
6b1785ed05 merge with 1.10c + local build mods 1994-06-22 14:40:59 +00:00
Jim Meyering
d62acd19e9 . 1994-06-22 14:11:23 +00:00
Jim Meyering
7a3fb2d7ad . 1994-06-20 14:14:34 +00:00
Jim Meyering
3a3b00cc54 . 1994-06-20 13:24:14 +00:00
Jim Meyering
0d3ba947f3 merge with 1.10b + local build mods 1994-06-19 04:52:50 +00:00
Jim Meyering
2bdde50d3f . 1994-06-19 04:27:52 +00:00
Jim Meyering
a3ad002027 (count_entry): Print "/" instead of "". 1994-06-18 21:04:00 +00:00
Jim Meyering
33fec67464 . 1994-06-02 18:11:26 +00:00
Jim Meyering
cb9d9f0f71 merge with 1.10a + local build mods 1994-05-30 13:37:52 +00:00
Jim Meyering
e3360a98c2 merge with 1.10a + local build mods 1994-05-30 00:06:15 +00:00
Jim Meyering
f277d830bb . 1994-05-29 19:50:31 +00:00
Jim Meyering
cf1d805fec (test_syntax_error, beyond): add __attribute__ ((noreturn)) 1994-05-20 15:56:47 +00:00
Jim Meyering
b98b0e107f merge with 1.10 + local build mods 1994-05-20 13:50:43 +00:00
Jim Meyering
a0f30b3f2c merge with 1.9.4l + local build mods 1994-05-14 16:09:51 +00:00
Jim Meyering
8b21a5c229 merge with 1.9.4k 1994-05-13 15:49:16 +00:00
Jim Meyering
2d981879d6 . 1994-05-13 14:24:15 +00:00
Jim Meyering
6874eb8797 . 1994-05-13 14:21:20 +00:00
Jim Meyering
323e95c8b3 . 1994-05-13 13:57:20 +00:00
Jim Meyering
af6e86c537 . 1994-05-13 13:44:07 +00:00
Jim Meyering
1f53ad0803 . 1994-05-08 16:42:40 +00:00
Jim Meyering
31c8ce9ef8 . 1994-05-08 16:16:03 +00:00
Jim Meyering
a99f319d12 merge with 1.9.1f 1994-05-06 18:39:32 +00:00
Jim Meyering
758d3a260d . 1994-05-06 15:37:56 +00:00
Jim Meyering
556cdce5c8 . 1994-05-06 15:28:01 +00:00
Jim Meyering
3118577120 . 1994-05-02 04:26:07 +00:00
Jim Meyering
bd3061bed9 merge with 1.9.4j 1994-05-01 16:23:17 +00:00
Jim Meyering
92434b0b67 . 1994-05-01 13:28:12 +00:00
Jim Meyering
2812688dfc . 1994-04-29 22:26:57 +00:00
Jim Meyering
23441bf2ab merge with 1.9.4i 1994-04-28 18:43:36 +00:00
Jim Meyering
d90d17e378 Initial revision 1994-04-28 18:39:34 +00:00
Jim Meyering
f770080426 . 1994-04-28 16:53:41 +00:00
Jim Meyering
07474b189d . 1994-04-27 17:33:22 +00:00
Jim Meyering
4fe59aa3b9 merge with 1.9.4h 1994-04-25 19:08:47 +00:00
Jim Meyering
085c609f77 merge with 1.9.4g 1994-04-25 18:34:37 +00:00
Jim Meyering
36f920112b . 1994-04-25 17:01:36 +00:00
Jim Meyering
256a906698 merge with 1.9.4f 1994-04-25 16:34:49 +00:00
Jim Meyering
7c68f857d0 Revert 1.14-1.16 changes that removed difftm and modified get_date. 1994-04-24 12:48:45 +00:00
Jim Meyering
e628e7bb9e . 1994-04-20 00:23:45 +00:00
Jim Meyering
33955663ad merge with 1.9.4e 1994-04-19 13:40:42 +00:00
Jim Meyering
e614cf3cbb . 1994-04-19 02:30:46 +00:00
Jim Meyering
f1e3280296 . 1994-04-19 00:45:54 +00:00
Jim Meyering
85274fb910 (main): Give a reason for failure when given no
non-option arguments, rather than just the pointer to --help.
1994-04-16 01:36:40 +00:00
Jim Meyering
b26bc02086 . 1994-04-16 01:22:56 +00:00
Jim Meyering
85842e28eb . 1994-04-13 17:12:17 +00:00
Jim Meyering
baaac7ac25 . 1994-04-13 15:26:17 +00:00
Jim Meyering
7960ad7d8b . 1994-04-11 22:22:23 +00:00
Jim Meyering
abbc6f5242 . 1994-04-11 22:03:06 +00:00
Jim Meyering
9bc0437bab merge with 1.9.4d 1994-04-04 22:19:22 +00:00
Jim Meyering
196ad04add . 1994-03-30 13:51:09 +00:00
Jim Meyering
de330273f1 (prline): Remove unused function. 1994-03-28 14:22:52 +00:00
Jim Meyering
2c2e515911 indent 1994-03-28 14:21:26 +00:00
Jim Meyering
23ae451acb merge with 1.9.1e 1994-03-26 00:19:13 +00:00
Jim Meyering
88049ac444 . 1994-03-25 23:42:14 +00:00
Jim Meyering
8bf5a6ed18 . 1994-03-25 23:38:00 +00:00
Jim Meyering
8bcd22c510 . 1994-03-25 23:17:21 +00:00
Jim Meyering
eaf35aca32 merge with 1.9.4c 1994-03-25 17:22:11 +00:00
Jim Meyering
91bfcc7c16 merge with 1.9.4b 1994-03-23 16:56:16 +00:00
Jim Meyering
945f1c9781 (adjust_blocks): Code it as a function again. 1994-03-16 14:47:59 +00:00
Jim Meyering
239d98e18d . 1994-03-16 14:32:26 +00:00
Jim Meyering
3e13a5f6dc . 1994-03-14 18:47:31 +00:00
Jim Meyering
bd25077b16 . 1994-03-14 18:41:13 +00:00
Jim Meyering
f2b1a05bff . 1994-03-14 16:24:52 +00:00
Jim Meyering
cbd7649260 . 1994-03-14 14:54:14 +00:00
Jim Meyering
77e63b2236 merge with 1.9.4a 1994-03-08 16:01:14 +00:00
Jim Meyering
dde7c39a92 . 1994-03-08 15:31:04 +00:00
Jim Meyering
d7fbc5eaba . 1994-03-08 15:30:19 +00:00
Jim Meyering
31b899e2e1 merge with 1.9.4 1994-02-20 17:01:44 +00:00
Jim Meyering
01b914a12e merge with 1.9.3 1994-02-19 19:49:02 +00:00
Jim Meyering
695581bf65 * stty.c (main): Use getopt only to recognize long options.
Hand code the loop to detect -a, -g, -ag and -ga.  Using getopt
to detect the short options loses (because we have to ignore
unrecognized options and we are allowing GNU getopt to permute)
because e.g. `-tabs' is interpreted as a group of options, one of
which is `-a'.  Before, running `stty -tabs echo' gave this error:
 stty: when specifying an output style, modes may not be set
Reported by Arne H. Juul.
1994-02-16 23:36:41 +00:00
Jim Meyering
4923c48619 . 1994-02-16 23:36:20 +00:00
Jim Meyering
c6f59f7abe . 1994-02-14 21:19:12 +00:00
Jim Meyering
e4aba2047a . 1994-02-13 20:27:08 +00:00
Jim Meyering
fd69d39c66 . 1994-02-13 20:03:47 +00:00
Jim Meyering
026dac4594 (main): Change optind' to k'. 1994-02-13 20:02:41 +00:00
Jim Meyering
86af3d8f1b (main): Use parse_long_options.
Rework option handling so stty no longer ignores arguments.
1994-02-13 19:59:52 +00:00
Jim Meyering
1731098e4d (set_window_size): Patch from Rick Sladkey. 1994-02-13 19:58:25 +00:00
Jim Meyering
380435c33b merge with 1.9.2j 1994-02-13 16:39:44 +00:00
Jim Meyering
9935449e9d merge with 1.9.2i 1994-02-12 17:23:44 +00:00
Jim Meyering
4caa3d07cf merge with 1.9.2g 1994-02-10 19:14:24 +00:00
Jim Meyering
589f6b1c17 CIBAUD hack for SunOS 4.1.x 1994-02-10 18:30:08 +00:00
Jim Meyering
a751e87562 . 1994-02-10 14:59:01 +00:00
Jim Meyering
75a474834b . 1994-02-01 14:11:50 +00:00
Jim Meyering
525ecdfbe1 . 1994-02-01 14:01:26 +00:00
Jim Meyering
7b3845a4a5 . 1994-01-29 19:06:23 +00:00
Jim Meyering
200b442ee4 . 1994-01-29 18:31:36 +00:00
Jim Meyering
ad82404564 . 1994-01-26 19:19:14 +00:00
Jim Meyering
d5dc4b055f . 1994-01-26 18:58:08 +00:00
Jim Meyering
c6756ec787 . 1994-01-26 18:51:44 +00:00
Jim Meyering
f1adf86d09 merge with 3.9c 1994-01-26 18:46:41 +00:00
Jim Meyering
63e9766256 . 1994-01-26 18:22:44 +00:00
Jim Meyering
35b0248480 . 1994-01-26 18:20:04 +00:00
Jim Meyering
5629153f1e . 1994-01-26 18:19:10 +00:00
Jim Meyering
2b16e3652c . 1994-01-26 17:48:15 +00:00
Jim Meyering
ac736f7cdc . 1994-01-26 16:08:35 +00:00
Jim Meyering
370edcd71f merge with 1.9.2e 1994-01-24 20:46:23 +00:00
Jim Meyering
a63a148116 Revert last change -- timing showed 10% speedup w/o stream I/O. 1994-01-11 05:52:05 +00:00
Jim Meyering
cd7ed8b383 Use fwrite insted of write. 1994-01-11 05:50:45 +00:00
Jim Meyering
1fc09c536b merge with 1.9.1c 1994-01-09 19:20:32 +00:00
Jim Meyering
07cd9a8d15 safe_read and full_write + join patch 1994-01-09 03:47:21 +00:00
Jim Meyering
4f90578a4f * who.c (print_entry): Prepend `/dev/' only if ut_line is not
already an absolute filename.  Just to be safe.
1994-01-07 00:06:38 +00:00
Jim Meyering
5bed1ce3db merge with 1.9.2d 1994-01-03 06:22:54 +00:00
Jim Meyering
82a7098474 merge with 1.9.2c 1994-01-03 05:22:20 +00:00
Jim Meyering
2c921595f2 . 1993-12-29 06:16:08 +00:00
Jim Meyering
8067b6fb73 . 1993-12-29 06:13:37 +00:00
Jim Meyering
9a30fc037e . 1993-12-29 05:07:52 +00:00
Jim Meyering
39f2fdda08 merge with 1.9.2b 1993-12-29 04:40:30 +00:00
Jim Meyering
3ffdef958d . 1993-12-28 23:46:12 +00:00
Jim Meyering
0f5e2eba7c . 1993-12-28 23:22:03 +00:00
Jim Meyering
704a7eba4a who.c 1993-12-28 21:18:17 +00:00
Jim Meyering
2db44d14e4 merge with 1.9.1b 1993-12-23 19:11:21 +00:00
Jim Meyering
5fbc4e2384 merge with 1.9.2a 1993-12-23 00:38:35 +00:00
Jim Meyering
d7daf7444e . 1993-12-23 00:08:23 +00:00
Jim Meyering
797585985f . 1993-12-22 22:41:00 +00:00
Jim Meyering
9883bf7280 . 1993-12-22 22:15:29 +00:00
Jim Meyering
7061c33d7b (set_fields): Convert ranges like 3-5,6- into 3-.
Before, this was off-by-two and converted 3-5,4-, but not 3-5,5-
1993-12-19 06:20:51 +00:00
Jim Meyering
0311e952db merge with 1.9.1a 1993-12-17 23:51:12 +00:00
Jim Meyering
f4c0b38042 merge with 3.9b 1993-12-17 23:12:34 +00:00
Jim Meyering
22110bde07 merge with 1.9.2 1993-12-02 18:31:46 +00:00
Jim Meyering
a8e2420def merge with 1.9.1c 1993-11-30 16:07:29 +00:00
Jim Meyering
4ebaf0fd9c merge with 1.9.1b 1993-11-30 15:51:34 +00:00
Jim Meyering
80d70870f5 * (main): If an adjustment is specified, but no command is
given, give a diagnostic in addition to the usage message.
(isinteger): Accept a leading `+'.
1993-11-27 21:59:45 +00:00
Jim Meyering
3ea7d72957 Redefine TIOCGWINSZ to TCGETS for Solaris. 1993-11-27 00:05:27 +00:00
Jim Meyering
22ba8f3323 merge with 1.9.1a 1993-11-20 17:00:37 +00:00
Jim Meyering
700f99c873 utmpx changes 1993-11-20 06:00:00 +00:00
Jim Meyering
76b0654112 merge with 1.9.1 1993-11-16 14:38:08 +00:00
Jim Meyering
bef401e8dc fix typo in comment 1993-11-15 16:05:00 +00:00
Jim Meyering
8c26c6bbba merge with 1.9.1 1993-11-15 15:58:21 +00:00
Jim Meyering
c75156c7c8 merge with 1.9.1 1993-11-15 15:57:55 +00:00
Jim Meyering
4bce07bc25 merge with 1.9a 1993-11-15 14:32:17 +00:00
Jim Meyering
39fd5971dd merge with 1.9 1993-11-10 06:05:02 +00:00
Jim Meyering
a1b9bc9a42 merge with 1.9 1993-11-09 13:21:32 +00:00
Jim Meyering
2d0c47b8aa merge with 1.9 1993-11-07 06:09:50 +00:00
Jim Meyering
56deeee42b merge with 1.8.1b 1993-11-02 22:10:58 +00:00
Jim Meyering
693e5c427a merge with 1.8.1k 1993-11-02 20:26:05 +00:00
Jim Meyering
c7ebcc8326 merge with 1.8.1a 1993-10-30 15:57:46 +00:00
Jim Meyering
01e9d7611a merge with 1.8.1 1993-10-28 04:34:57 +00:00
Jim Meyering
5f5fe4ae6d merge with 3.9a 1993-10-27 16:30:36 +00:00
Jim Meyering
ce4dbc8513 merge with 3.9a 1993-10-26 23:39:04 +00:00
Jim Meyering
f5da03589e merge with 1.8i 1993-10-26 01:19:12 +00:00
Jim Meyering
d7c526e66d merge with 1.8.1i 1993-10-26 00:11:14 +00:00
Jim Meyering
cfe240bbd8 merge with 1.8.1h 1993-10-24 21:30:08 +00:00
Jim Meyering
3bc2827212 merge with 1.8h 1993-10-24 20:00:39 +00:00
Jim Meyering
6d920eca0c merge with 1.8g 1993-10-24 19:04:12 +00:00
Jim Meyering
cd908e158d merge with 1.8f 1993-10-23 16:06:33 +00:00
Jim Meyering
b869639f46 merge with 1.8d+ 1993-10-23 15:37:19 +00:00
Jim Meyering
d1df8c198d merge with 1.8d 1993-10-21 22:08:53 +00:00
Jim Meyering
df1e389479 merge with 1.8c 1993-10-21 17:19:34 +00:00
Jim Meyering
193e68abd4 merge with 3.9 1993-10-21 14:48:03 +00:00
Jim Meyering
0f8257073a * memchr.c (memchr): Do the 32-bit assignment only if !LONG_64_BITS.
In the 64-bit assignment, be careful to cast the shift operand to
long.
Abort if sizeof (unsigned long) > 8.
1993-10-21 00:10:34 +00:00
Jim Meyering
e9220f5117 * [MAX]: Macro renamed from max and moved to top of file.
* (bytes_to_octal_digits): New static array.
* (get_format_flags): Combine '+' and ' ' cases of switch stmt.
Return count if for loop terminates.  Otherwise --suffix=%- would lose.
* (get_format_width): Use `bytes_to_octal_digits' instead of just 11.
* (get_format_prec): Make sure is_negative is defined before used.
* (get_format_conv_type): Give a different error message if there
is no conversion specifier.
Test ISPRINT (ch) instead of `ch < '~' && ch > ' ''.
* (max_out): Use `%%' rather than `%' in format string.
1993-10-20 02:17:05 +00:00
Jim Meyering
c24cb37374 Remove register keyword (replace with `int' in two cases). 1993-10-20 02:09:45 +00:00
Jim Meyering
4a18680233 patch from rfg 1993-10-20 02:08:24 +00:00
Jim Meyering
723d3d528d merge with 3.8.4k 1993-10-19 00:00:06 +00:00
Jim Meyering
712ac6d5a0 add newline back, but only for --help output 1993-10-18 03:22:20 +00:00
Jim Meyering
47ff7adaa2 Change fprintf (stdout' to printf ('. 1993-10-18 03:11:02 +00:00
Jim Meyering
ce559ec2e5 remove extra newline in usage message 1993-10-18 03:03:07 +00:00
Jim Meyering
53c1f3e4c6 [member]: Don't cast index() to an int. That is wrong on systems with 64-bit
pointers.
1993-10-18 02:50:21 +00:00
Jim Meyering
64b0b993f6 merge with 3.8.4h 1993-10-18 02:17:58 +00:00
Jim Meyering
214c19a8b3 merge with 3.8.4g 1993-10-17 22:43:10 +00:00
Jim Meyering
1958250cc6 [!NINDIR]: Define BSIZE only if it's not already defined. 1993-10-17 22:31:39 +00:00
Jim Meyering
fa7a1e19e2 merge with 1.8.1g 1993-10-17 03:57:04 +00:00
Jim Meyering
6e1a4cca68 merge with 1.8b 1993-10-17 02:57:45 +00:00
Jim Meyering
c2b140693b merge with 3.8.4f 1993-10-16 22:55:37 +00:00
Jim Meyering
6a06c02f21 (main): When argc == 1, don't try to xmalloc (0). 1993-10-16 14:47:43 +00:00
Jim Meyering
20905f2c93 merge with 3.8.4e 1993-10-13 22:30:38 +00:00
Jim Meyering
7691d2fba0 merge with 3.8.4c 1993-10-12 20:24:09 +00:00
Jim Meyering
ff6b97e13e merge with 1.8.1e 1993-10-12 20:13:45 +00:00
Jim Meyering
44c053f008 merge with 1.8.1d 1993-10-12 14:49:11 +00:00
Jim Meyering
9cfcec5b05 merge with 3.8.4b 1993-10-12 04:30:50 +00:00
Jim Meyering
d463bda066 merge with 1.8.1c 1993-10-12 02:42:06 +00:00
Jim Meyering
87fa23e641 merge with 1.8.1b 1993-10-12 01:52:24 +00:00
Jim Meyering
f12b53b2ce merge with 3.8.4 1993-10-09 20:49:07 +00:00
Jim Meyering
87372cd3ae merge with 3.8.3e 1993-10-09 20:44:16 +00:00
Jim Meyering
4ab2d8f53a merge with 3.8.3e 1993-10-09 20:43:31 +00:00
Jim Meyering
ae89477b9b merge with 3.8.3e 1993-10-09 20:43:10 +00:00
Jim Meyering
95f7eb6267 merge with 3.8.3d 1993-10-08 00:51:10 +00:00
Jim Meyering
d9d6720b77 merge with 3.8.3c 1993-10-07 00:41:21 +00:00
205 changed files with 60864 additions and 13349 deletions

222
ABOUT-NLS Normal file
View File

@@ -0,0 +1,222 @@
Notes on the GNU Translation Project
************************************
GNU is going international! The GNU Translation Project is a way to
get maintainers, translators, and users all together, so that GNU will
gradually become able to speak many languages. A few packages already
provide translations for their messages.
If you found this `ABOUT-NLS' file inside a GNU distribution, you
may assume that the distributed package does use GNU `gettext'
internally, itself available at your nearest GNU archive site. But you
do *not* need to install GNU `gettext' prior to configuring, installing
or using this package with messages translated.
Installers will find here some useful hints. These notes also
explain how users should proceed for getting the programs to use the
available translations. They tell how people wanting to contribute and
work at translations should contact the appropriate team.
When reporting bugs in the `intl/' directory or bugs which may be
related to internationalization, you should tell about the version of
`gettext' which is used. The information can be found in the
`intl/VERSION' file, in internationalized packages.
One advise in advance
=====================
If you want to exploit the full power of internationalization, you
should configure it using
./configure --with-included-gettext
to force usage of internationalizing routines provided within this
package, despite the existence of internationalizing capabilities in
the operating system where this package is being installed. So far, no
prior implementation provides as many useful features (such as locale
alias or message inheritance). It is also not possible to offer this
additional functionality on top of a `catgets' implementation. Future
versions of GNU `gettext' will very likely convey even more
functionality. So it might be a good idea to change to GNU `gettext'
as soon as possible.
INSTALL Matters
===============
Some GNU packages are "localizable" when properly installed; the
programs they contain can be made to speak your own native language.
Most such packages use GNU `gettext'. Other packages have their own
ways to internationalization, predating GNU `gettext'.
By default, this package will be installed to allow translation of
messages. It will automatically detect whether the system provides
usable `catgets' (if using this is selected by the installer) or
`gettext' functions. If neither is available, the GNU `gettext' own
library will be used. This library is wholly contained within this
package, usually in the `intl/' subdirectory, so prior installation of
the GNU `gettext' package is *not* required. Installers may use
special options at configuration time for changing the default
behaviour. The commands:
./configure --with-included-gettext
./configure --with-catgets
./configure --disable-nls
will respectively bypass any pre-existing `catgets' or `gettext' to use
the internationalizing routines provided within this package, enable
the use of the `catgets' functions (if found on the locale system), or
else, *totally* disable translation of messages.
When you already have GNU `gettext' installed on your system and run
configure without an option for your new package, `configure' will
probably detect the previously built and installed `libintl.a' file and
will decide to use this. This might be not what is desirable. You
should use the more recent version of the GNU `gettext' library. I.e.
if the file `intl/VERSION' shows that the library which comes with this
package is more recent, you should use
./configure --with-included-gettext
to prevent auto-detection.
By default the configuration process will not test for the `catgets'
function and therefore they will not be used. The reasons are already
given above: the emulation on top of `catgets' cannot provide all the
extensions provided by the GNU `gettext' library. If you nevertheless
want to use the `catgets' functions use
./configure --with-catgets
to enable the test for `catgets' (this causes no harm if `catgets' is
not available on your system). If you really select this option we
would like to hear about the reasons because we cannot think of any
good one ourself.
Internationalized packages have usually many `po/LL.po' files, where
LL gives an ISO 639 two-letter code identifying the language. Unless
translations have been forbidden at `configure' time by using the
`--disable-nls' switch, all available translations are installed
together with the package. However, the environment variable `LINGUAS'
may be set, prior to configuration, to limit the installed set.
`LINGUAS' should then contain a space separated list of two-letter
codes, stating which languages are allowed.
Using This Package
==================
As a user, if your language has been installed for this package, you
only have to set the `LANG' environment variable to the appropriate
ISO 639 `LL' two-letter code prior to using the programs in the
package. For example, let's suppose that you speak German. At the
shell prompt, merely execute `setenv LANG de' (in `csh'),
`export LANG; LANG=de' (in `sh') or `export LANG=de' (in `bash'). This
can be done from your `.login' or `.profile' file, once and for all.
An operating system might already offer message localization for
many of its programs, while other programs (whether GNU or not) have
been installed locally with the full capabilities of GNU `gettext'.
Just using `gettext' extended syntax for `LANG' would break proper
localization of already available operating system programs. In this
case, users should set both `LANGUAGE' and `LANG' variables in their
environment, as programs using GNU `gettext' give preference to
`LANGUAGE'. For example, some Swedish users would rather read
translations in German than English for when Swedish is not available.
This is easily accomplished by setting `LANGUAGE' to `sv:de' while
leaving `LANG' to `sv'.
Translating Teams
=================
For the GNU Translation Project to be a success, we need interested
people who like their own language and write it well, and who are also
able to synergize with other translators speaking the same language.
Each translation team has its own mailing list, courtesy of Linux
International. You may reach your translation team at the address
`LL@li.org', replacing LL by the two-letter ISO 639 code for your
language. Language codes are *not* the same as the country codes given
in ISO 3166. The following translation teams exist, as of May 1996:
Arabic `ar', Chinese `zh', Czech `cs', Danish `da', Dutch `nl',
English `en', Esperanto `eo', Finnish `fi', French `fr', German
`de', Greek `el', Hebrew `he', Hungarian `hu', Irish `ga', Italian
`it', Indonesian `id', Japanese `ja', Korean `ko', Latin `la',
Norwegian `no', Persian `fa', Polish `pl', Portuguese `pt',
Russian `ru', Slovenian `sl', Spanish `es', Swedish `sv', Telugu
`te', Turkish `tr' and Ukrainian `uk'.
For example, you may reach the Chinese translation team by writing to
`zh@li.org'.
If you'd like to volunteer to *work* at translating messages, you
should become a member of the translating team for your own language.
The subscribing address is *not* the same as the list itself, it has
`-request' appended. For example, speakers of Swedish can send a
message to `sv-request@li.org', having this message body:
subscribe
Keep in mind that team members are expected to participate
*actively* in translations, or at solving translational difficulties,
rather than merely lurking around. If your team does not exist yet and
you want to start one, or if you are unsure about what to do or how to
get started, please write to `gnu-translation@gnu.ai.mit.edu' to reach
the GNU coordinator for all translator teams.
The English team is special. It works at improving and uniformizing
the terminology used in GNU. Proven linguistic skill are praised more
than programming skill, here. For the time being, please avoid
subscribing to the English team unless explicitly invited to do so.
Available Packages
==================
Languages are not equally supported in all GNU packages. The
following matrix shows the current state of GNU internationalization,
as of May 1996. The matrix shows, in regard of each package, for which
languages PO files have been submitted to translation coordination.
cs de en es fi fr ja ko nl no pl pt sl sv
.-------------------------------------------.
bash | [] | 1
bison | [] | 1
clisp | [] [] [] | 3
cpio | [] | 1
diffutils | [] [] [] | 3
enscript | [] [] [] [] | 4
fileutils | [] [] [] [] | 4
findutils | [] [] | 2
flex | [] | 1
gcal | [] | 1
gettext | [] [] [] [] [] [] [] [] | 9
glibc | [] [] [] | 3
grep | [] [] [] [] [] [] | 6
hello | [] [] [] [] [] [] | 6
m4 | [] [] [] [] | 4
make | | 0
mkid | [] [] | 2
music | [] | 1
ptx | [] [] [] | 3
recode | [] [] [] [] [] | 5
sh-utils | [] [] | 2
sharutils | [] [] [] [] | 4
tar | [] [] [] [] [] [] [] | 7
textutils | [] [] [] [] | 4
wdiff | [] [] [] [] | 4
`-------------------------------------------'
cs de en es fi fr ja ko nl no pl pt sl sv
1 17 1 3 1 22 1 6 3 3 4 3 6 10 81
Some counters in the preceding matrix are higher than the number of
visible blocks let us expect. This is because a few extra PO files are
used for implementing regional variants of languages, or language
dialects.
For a PO file in the matrix above to be effective, the package to
which it applies should also have been internationalized and
distributed as such by its maintainer. There might be an observable
lag between the mere existence a PO file and its wide availability in a
GNU distribution.
If May 1996 seems to be old, you may fetch a more recent copy of
this `ABOUT-NLS' file on most GNU archive sites.

View File

@@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -304,8 +304,8 @@ the "copyright" line and a pointer to where the full notice is found.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Also add information on how to contact you by electronic and paper mail.

250
INSTALL
View File

@@ -1,111 +1,181 @@
This is a generic INSTALL file for utilities distributions.
If this package does not come with, e.g., installable documentation or
data files, please ignore the references to them below.
Basic Installation
==================
To compile this package:
These are generic installation instructions.
1. Configure the package for your system. In the directory that this
file is in, type `./configure'. If you're using `csh' on an old
version of System V, you might need to type `sh configure' instead to
prevent `csh' from trying to execute `configure' itself.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation, and
creates the Makefile(s) (one in each subdirectory of the source
directory). In some packages it creates a C header file containing
system-dependent definitions. It also creates a file `config.status'
that you can run in the future to recreate the current configuration.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
Running `configure' takes a minute or two. While it is running, it
prints some messages that tell what it is doing. If you don't want to
see the messages, run `configure' with its standard output redirected
to `/dev/null'; for example, `./configure >/dev/null'.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
To compile the package in a different directory from the one
containing the source code, you must use a version of make that
supports the VPATH variable, such as GNU make. `cd' to the directory
where you want the object files and executables to go and run
`configure'. `configure' automatically checks for the source code in
the directory that `configure' is in and in `..'. If for some reason
`configure' is not in the source code directory that you are
configuring, then it will report that it can't find the source code.
In that case, run `configure' with the option `--srcdir=DIR', where
DIR is the directory that contains the source code.
The simplest way to compile this package is:
By default, `make install' will install the package's files in
/usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify
an installation prefix other than /usr/local by giving `configure' the
option `--prefix=PATH'. Alternately, you can do so by giving a value
for the `prefix' variable when you run `make', e.g.,
make prefix=/usr/gnu
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If
you give `configure' the option `--exec_prefix=PATH' or set the
`make' variable `exec_prefix' to PATH, the package will use PATH as
the prefix for installing programs and libraries. Data files and
documentation will still use the regular prefix. Normally, all files
are installed using the regular prefix.
Running `configure' takes a while. While running, it prints some
messages telling which features it is checking for.
You can tell `configure' to figure out the configuration for your
system, and record it in `config.status', without actually configuring
the package (creating `Makefile's and perhaps a configuration header
file). To do this, give `configure' the `--no-create' option. Later,
you can run `./config.status' to actually configure the package. This
option is useful mainly in `Makefile' rules for updating `config.status'
and `Makefile'. You can also give `config.status' the `--recheck'
option, which makes it re-run `configure' with the same arguments you
used before. This is useful if you change `configure'.
2. Type `make' to compile the package.
`configure' ignores any other arguments that you give it.
3. Optionally, type `make check' to run any self-tests that come with
the package.
If your system requires unusual options for compilation or linking
that `configure' doesn't know about, you can give `configure' initial
values for some variables by setting them in the environment. In
Bourne-compatible shells, you can do that on the command line like
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
The `make' variables that you might want to override with environment
variables when running `configure' are:
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
(For these variables, any value given in the environment overrides the
value that `configure' would choose:)
CC C compiler program.
Default is `cc', or `gcc' if `gcc' is in your PATH.
INSTALL Program to use to install files.
Default is `install' if you have it, `cp' otherwise.
Compiling For Multiple Architectures
====================================
(For these variables, any value given in the environment is added to
the value that `configure' chooses:)
DEFS Configuration options, in the form `-Dfoo -Dbar ...'
LIBS Libraries to link with, in the form `-lfoo -lbar ...'
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you need to do unusual things to compile the package, we encourage
you to figure out how `configure' could check whether to do them, and
mail diffs or instructions to the address given in the README so we
can include them in the next release.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
2. Type `make' to compile the package. If you want, you can override
the `make' variables CFLAGS and LDFLAGS like this:
Installation Names
==================
make CFLAGS=-O2 LDFLAGS=-s
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
3. If the package comes with self-tests and you want to run them,
type `make check'. If you're not sure whether there are any, try it;
if `make' responds with something like
make: *** No way to make target `check'. Stop.
then the package does not come with self-tests.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
4. Type `make install' to install programs, data files, and
documentation.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
5. You can remove the program binaries and object files from the
source directory by typing `make clean'. To also remove the
Makefile(s), the header file containing system-dependent definitions
(if the package uses one), and `config.status' (all the files that
`configure' created), type `make distclean'.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made.
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
The file `configure.in' is used as a template to create `configure' by
a program called `autoconf'. You will only need it if you want to
regenerate `configure' using a newer version of `autoconf'.

20
doc/.cvsignore Normal file
View File

@@ -0,0 +1,20 @@
Makefile
fileutils.info
version.texi
fileutils.info*
fileutils.log
fileutils.dvi
fileutils.aux
fileutils.toc
fileutils.cp
fileutils.fn
fileutils.vr
fileutils.tp
fileutils.ky
fileutils.pg
fileutils.cm
fileutils.fl
fileutils.op
fileutils.cps
stamp-vti
version.texi

6
doc/Makefile.am Normal file
View File

@@ -0,0 +1,6 @@
## Process this file with automake to produce Makefile.in
info_TEXINFOS = fileutils.texi
# FIXME: remove texinfo.tex when automake has been fixed to include it
# automatically
EXTRA_DIST = perm.texi getdate.texi texinfo.tex

209
doc/Makefile.in Normal file
View File

@@ -0,0 +1,209 @@
# Makefile.in generated automatically by automake 1.0 from Makefile.am
# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
SHELL = /bin/sh
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
info_TEXINFOS = fileutils.texi
# FIXME: remove texinfo.tex when automake has been fixed to include it
# automatically
EXTRA_DIST = perm.texi getdate.texi texinfo.tex
mkinstalldirs = $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
MAKEINFO = makeinfo
TEXI2DVI = texi2dvi
INFOS = fileutils.info*
INFO_DEPS = fileutils.info
DVIS = fileutils.dvi
TEXINFOS = fileutils.texi
DIST_COMMON = Makefile.am Makefile.in mdate-sh stamp-vti version.texi
PACKAGE = @PACKAGE@
VERSION = @VERSION@
DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
$(TEXINFOS) $(INFOS) $(MANS) $(EXTRA_DIST) $(DATA)
DEP_DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
$(TEXINFOS) $(INFO_DEPS) $(MANS) $(EXTRA_DIST) $(DATA)
TAR = tar
default: all
$(srcdir)/Makefile.in: @MAINT@Makefile.am $(top_srcdir)/configure.in
cd $(top_srcdir) && automake $(subdir)/Makefile
Makefile: $(top_builddir)/config.status Makefile.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
version.texi: @MAINT@stamp-vti
stamp-vti: fileutils.texi $(top_srcdir)/configure.in
echo "@set UPDATED `cd $(srcdir) \
&& $(SHELL) ./mdate-sh fileutils.texi`" > vti.tmp
echo "@set EDITION $(VERSION)" >> vti.tmp
echo "@set VERSION $(VERSION)" >> vti.tmp
if cmp -s vti.tmp $(srcdir)/version.texi; then \
rm vti.tmp; \
else \
mv vti.tmp $(srcdir)/version.texi; \
fi
echo timestamp > $(srcdir)/stamp-vti
mostlyclean-vti:
rm -f vti.tmp
clean-vti:
distclean-vti:
maintainer-clean-vti:
@MAINT@rm -f stamp-vti version.texi
fileutils.info: fileutils.texi version.texi
.texi.info:
$(MAKEINFO) -I$(srcdir) $< -o $(srcdir)/$@
.texi.dvi:
TEXINPUTS=$(srcdir):$$TEXINPUTS $(TEXI2DVI) $<
install-info: $(INFO_DEPS)
$(mkinstalldirs) $(infodir)
for file in $(INFO_DEPS); do \
for ifile in `cd $(srcdir) && echo $$file*`; do \
$(INSTALL_DATA) $(srcdir)/$$ifile $(infodir)/$$ifile; \
done; \
done
uninstall-info:
cd $(srcdir) && for file in *.info*; do \
rm -f $(infodir)/$$file; \
done
mostlyclean-info:
rm -f fileutils.aux fileutils.cp fileutils.cps fileutils.dvi \
fileutils.fn fileutils.fns fileutils.ky fileutils.log \
fileutils.pg fileutils.toc fileutils.tp fileutils.vr \
fileutils.op
clean-info:
distclean-info:
maintainer-clean-info:
rm -f $(INFOS)
tags: TAGS
TAGS:
subdir = doc
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
distdir: $(DEP_DISTFILES)
@for file in `cd $(srcdir) && echo $(DISTFILES)`; do \
test -f $(distdir)/$$file \
|| ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $(srcdir)/$$file $(distdir)/$$file; \
done
info: $(INFO_DEPS)
dvi: $(DVIS)
check: all
installcheck:
install-exec:
install-data: install-info
install: install-exec install-data all
@:
uninstall: uninstall-info
all: $(INFO_DEPS) Makefile
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
installdirs:
$(mkinstalldirs) $(infodir)
mostlyclean-generic:
test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic:
test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
rm -f Makefile $(DISTCLEANFILES)
rm -f config.cache config.log $(CONFIG_HEADER) stamp-h
maintainer-clean-generic:
test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-vti mostlyclean-info mostlyclean-generic
clean: clean-vti clean-info clean-generic mostlyclean
distclean: distclean-vti distclean-info distclean-generic clean
rm -f config.status
maintainer-clean: maintainer-clean-vti maintainer-clean-info \
maintainer-clean-generic distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
.PHONY: default mostlyclean-vti distclean-vti clean-vti \
maintainer-clean-vti install-info uninstall-info mostlyclean-info \
distclean-info clean-info maintainer-clean-info tags distdir info dvi \
check installcheck install-exec install-data install uninstall all \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
.SUFFIXES:
.SUFFIXES: .texi .info .dvi
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

484
doc/getdate.texi Normal file
View File

@@ -0,0 +1,484 @@
@ifinfo
@set Francois Franc,ois
@end ifinfo
@tex
@set Francois Fran\noexpand\ptexc cois
@end tex
@node Date input formats
@chapter Date input formats
@cindex date input formats
@findex getdate
This section describes the textual date representations that GNU
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 Unix
@cindex epoch, for Unix
Although the date syntax here can represent any possible time since zero
A.D., computer integers are not big enough for such a (comparatively)
long time. The earliest date semantically allowed on Unix systems is
midnight, 1 January 1970 UCT.
@menu
* General date syntax:: Common rules.
* Calendar date item:: 19 Dec 1994.
* Time of day item:: 9:20pm.
* Timezone item:: EST, DST, BST, UCT, AHST, ...
* Day of week item:: Monday and others.
* Relative item in date strings:: next tuesday, 2 years ago.
* Pure numbers in date strings:: 19931219, 1440.
* Authors of getdate:: Bellovin, Salz, Berets, et al.
@end menu
@node General date syntax
@section General date syntax
@cindex general date syntax
@cindex items in date strings
A @dfn{date} is a string, possibly empty, containing many items
separated by whitespace. The whitespace may be omitted when no
ambiguity arises. The empty string means the beginning of today (i.e.,
midnight). Order of the items is immaterial. A date string may contain
many flavors of items:
@itemize @bullet
@item calendar date items
@item time of the day items
@item time zone items
@item day of the week items
@item relative items
@item pure numbers.
@end itemize
@noindent We describe each of these item types in turn, below.
@cindex numbers, written-out
@cindex ordinal numbers
@findex first @r{in date strings}
@findex next @r{in date strings}
@findex last @r{in date strings}
A few numbers may be written out in words in most contexts. This is
most useful for specifying day of the week items or relative items (see
below). Here is the list: @samp{first} for 1, @samp{next} for 2,
@samp{third} for 3, @samp{fourth} for 4, @samp{fifth} for 5,
@samp{sixth} for 6, @samp{seventh} for 7, @samp{eighth} for 8,
@samp{ninth} for 9, @samp{tenth} for 10, @samp{eleventh} for 11 and
@samp{twelfth} for 12. Also, @samp{last} means exactly @math{-1}.
@cindex months, written-out
When a month is written this way, it is still considered to be written
numerically, instead of being ``spelled in full''; this changes the
allowed strings.
@cindex case, ignored in dates
@cindex comments, in dates
Alphabetic case is completely ignored in dates. Comments may be introduced
between round parentheses, as long as included parentheses are properly
nested. Hyphens not followed by a digit are currently ignored. Leading
zeros on numbers are ignored.
@node Calendar date item
@section Calendar date item
@cindex calendar date item
A @dfn{calendar date item} specifies a day of the year. It is
specified differently, depending on whether the month is specified
numerically or literally. All these strings specify the same calendar date:
@example
1970-09-17 # ISO 8601.
70-9-17 # This century assumed by default.
70-09-17 # Leading zeros are ignored.
9/17/72 # Common U.S. writing.
24 September 1972
24 Sept 72 # September has a special abbreviation.
24 Sep 72 # Three-letter abbreviations always allowed.
Sep 24, 1972
24-sep-72
24sep72
@end example
The year can also be omitted. In this case, the last specified year is
used, or the current year if none. For example:
@example
9/17
sep 17
@end example
Here are the rules.
@cindex ISO 8601 date format
@cindex date format, ISO 8601
For numeric months, the ISO 8601 format
@samp{@var{year}-@var{month}-@var{day}} is allowed, where @var{year} is
any positive number, @var{month} is a number between 01 and 12, and
@var{day} is a number between 01 and 31. A leading zero must be present
if a number is less than ten. If @var{year} is less than 100, then 1900
is added to it to force a date in this century. The construct
@samp{@var{month}/@var{day}/@var{year}}, popular in the United States,
is accepted. Also @samp{@var{month}/@var{day}}, omitting the year.
@cindex month names in date strings
@cindex abbreviations for months
Literal months may be spelled out in full: @samp{January},
@samp{February}, @samp{March}, @samp{April}, @samp{May}, @samp{June},
@samp{July}, @samp{August}, @samp{September}, @samp{October},
@samp{November} or @samp{December}. Literal months may be abbreviated
to their first three letters, possibly followed by an abbreviating dot.
It is also permitted to write @samp{Sept} instead of @samp{September}.
When months are written literally, the calendar date may be given as any
of the following:
@example
@var{day} @var{month} @var{year}
@var{day} @var{month}
@var{month} @var{day} @var{year}
@var{day}-@var{month}-@var{year}
@end example
Or, omitting the year:
@example
@var{month} @var{day}
@end example
@node Time of day item
@section Time of day item
@cindex time of day item
A @dfn{time of day item} in date strings specifies the time on a given
day. Here are some examples, all of which represent the same time:
@example
20:02:0
20:02
8:02pm
20:02-0500 # In EST (Eastern U.S. Standard Time).
@end example
More generally, the time of the day may be given as
@samp{@var{hour}:@var{minute}:@var{second}}, where @var{hour} is
a number between 0 and 23, @var{minute} is a number between 0 and
59, and @var{second} is a number between 0 and 59. Alternatively,
@samp{:@var{second}} can be omitted, in which case it is taken to
be zero.
@findex am @r{in date strings}
@findex pm @r{in date strings}
@findex midnight @r{in date strings}
@findex noon @r{in date strings}
If the time is followed by @samp{am} or @samp{pm} (or @samp{a.m.}
or @samp{p.m.}), @var{hour} is restricted to run from 1 to 12, and
@samp{:@var{minute}} may be omitted (taken to be zero). @samp{am}
indicates the first half of the day, @samp{pm} indicates the second
half of the day. In this notation, 12 is the predecessor of 1:
midnight is @samp{12am} while noon is @samp{12pm}.
@cindex timezone correction
@cindex minutes, timezone correction by
The time may alternatively be followed by a timezone correction,
expressed as @samp{@var{s}@var{hh}@var{mm}}, where @var{s} is @samp{+}
or @samp{-}, @var{hh} is a number of zone hours and @var{mm} is a number
of zone minutes. When a timezone correction is given this way, it
forces interpretation of the time in UTC, overriding any previous
specification for the timezone or the local timezone. The @var{minute}
part of the time of the day may not be elided when a timezone correction
is used. This is the only way to specify a timezone correction by
fractional parts of an hour.
Either @samp{am}/@samp{pm} or a timezone correction may be specified,
but not both.
@node Timezone item
@section Timezone item
@cindex timezone item
A @dfn{timezone item} specifies an international timezone, indicated by
a small set of letters. Any included period is ignored. Military
timezone designations use a single letter. Currently, only integral
zone hours may be represented in a timezone item. See the previous
section for a finer control over the timezone correction.
Here are many non-daylight-savings-time timezones, indexed by the zone
hour value.
@table @asis
@item +000
@cindex Greenwich Mean Time
@cindex Universal Coordinated Time
@cindex Western European Time
@samp{GMT} for Greenwich Mean, @samp{UT} or @samp{UTC} for Universal
(Coordinated), @samp{WET} for Western European and @samp{Z} for
militaries.
@item +100
@cindex West African Time
@samp{WAT} for West Africa and
@samp{A} for militaries.
@item +200
@cindex Azores Time
@samp{AT} for Azores and @samp{B} for militaries.
@item +300
@samp{C} for militaries.
@item +400
@cindex Atlantic Standard Time
@samp{AST} for Atlantic Standard and @samp{D} for militaries.
@item +500
@cindex Eastern Standard Time
@samp{E} for militaries and @samp{EST} for Eastern Standard.
@item +600
@cindex Central Standard Time
@samp{CST} for Central Standard and @samp{F} for militaries.
@item +700
@cindex Mountain Standard Time
@samp{G} for militaries and @samp{MST} for Mountain Standard.
@item +800
@cindex Pacific Standard Time
@samp{H} for militaries and @samp{PST} for Pacific Standard.
@item +900
@cindex Yukon Standard Time
@samp{I} for militaries and @samp{YST} for Yukon Standard.
@item +1000
@cindex Alaska-Hawaii Time
@cindex Central Alaska Time
@cindex Hawaii Standard Time
@samp{AHST} for Alaska-Hawaii Standard, @samp{CAT} for Central Alaska,
@samp{HST} for Hawaii Standard and @samp{K} for militaries.
@item +1100
@cindex Nome Standard Time
@samp{L} for militaries and @samp{NT} for Nome.
@item +1200
@cindex International Date Line West
@samp{IDLW} for International Date Line West and @samp{M} for
militaries.
@item -100
@cindex Central European Time
@cindex Middle European Time
@cindex Middle European Winter Time
@cindex French Winter Time
@cindex Swedish Winter Time
@samp{CET} for Central European, @samp{FWT} for French Winter,
@samp{MET} for Middle European, @samp{MEWT} for Middle European
Winter, @samp{N} for militaries and @samp{SWT} for Swedish Winter.
@item -200
@cindex Eastern European Time
@cindex USSR Zone
@samp{EET} for Eastern European, USSR Zone 1 and @samp{O} for militaries.
@item -300
@cindex Baghdad Time
@samp{BT} for Baghdad, USSR Zone 2 and @samp{P} for militaries.
@item -400
@samp{Q} for militaries and @samp{ZP4} for USSR Zone 3.
@item -500
@samp{R} for militaries and @samp{ZP5} for USSR Zone 4.
@item -600
@samp{S} for militaries and @samp{ZP6} for USSR Zone 5.
@item -700
@cindex West Australian Standard Time
@samp{T} for militaries and @samp{WAST} for West Australian Standard.
@item -800
@cindex China Coast Time
@samp{CCT} for China Coast, USSR Zone 7 and @samp{U} for militaries.
@item -900
@cindex Japan Standard Time
@samp{JST} for Japan Standard, USSR Zone 8 and @samp{V} for militaries.
@item -1000
@cindex East Australian Standard Time
@cindex Guam Standard Time
@samp{EAST} for East Australian Standard, @samp{GST} for Guam
Standard, USSR Zone 9 and @samp{W} for militaries.
@item -1100
@samp{X} for militaries.
@item -1200
@cindex International Date Line East
@cindex New Zealand Standard Time
@samp{IDLE} for International Date Line East, @samp{NZST} for
New Zealand Standard, @samp{NZT} for New Zealand and @samp{Y} for
militaries.
@end table
@cindex daylight savings time
Here are many DST timezones, indexed by the zone hour value. Also, by
following a non-DST timezone by the string @samp{DST} in a separate word
(that is, separated by some whitespace), the corresponding DST timezone
may be specified.
@table @asis
@item 0
@samp{BST} for British Summer.
@item +400
@samp{ADT} for Atlantic Daylight.
@item +500
@samp{EDT} for Eastern Daylight.
@item +600
@samp{CDT} for Central Daylight.
@item +700
@samp{MDT} for Mountain Daylight.
@item +800
@samp{PDT} for Pacific Daylight.
@item +900
@samp{YDT} for Yukon Daylight.
@item +1000
@samp{HDT} for Hawaii Daylight.
@item -100
@samp{MEST} for Middle European Summer, @samp{MESZ} for Middle European
Summer, @samp{SST} for Swedish Summer and @samp{FST} for French Summer.
@item -700
@samp{WADT} for West Australian Daylight.
@item -1000
@samp{EADT} for Eastern Australian Daylight.
@item -1200
@samp{NZDT} for New Zealand Daylight.
@end table
@node Day of week item
@section Day of week item
@cindex day of week item
The explicit mention of a day of the week will forward the date
(only if necessary) to reach that day of the week in the future.
Days of the week may be spelled out in full: @samp{Sunday},
@samp{Monday}, @samp{Tuesday}, @samp{Wednesday}, @samp{Thursday},
@samp{Friday} or @samp{Saturday}. Days may be abbreviated to their
first three letters, optionally followed by a period. The special
abbreviations @samp{Tues} for @samp{Tuesday}, @samp{Wednes} for
@samp{Wednesday} and @samp{Thur} or @samp{Thurs} for @samp{Thursday} are
also allowed.
@findex next @var{day}
@findex last @var{day}
A number may precede a day of the week item to move forward
supplementary weeks. It is best used in expression like @samp{third
monday}. In this context, @samp{last @var{day}} or @samp{next
@var{day}} is also acceptable; they move one week before or after
the day that @var{day} by itself would represent.
A comma following a day of the week item is ignored.
@node Relative item in date strings
@section Relative item in date strings
@cindex relative items in date strings
@cindex displacement of dates
@dfn{Relative items} adjust a date (or the current date if none) forward
or backward. The effects of relative items accumulate. Here are some
examples:
@example
1 year
1 year ago
3 years
2 days
@end example
@findex year @r{in date strings}
@findex month @r{in date strings}
@findex fortnight @r{in date strings}
@findex week @r{in date strings}
@findex day @r{in date strings}
@findex hour @r{in date strings}
@findex minute @r{in date strings}
The unit of time displacement may be selected by the string @samp{year}
or @samp{month} for moving by whole years or months. These are fuzzy
units, as years and months are not all of equal duration. More precise
units are @samp{fortnight} which is worth 14 days, @samp{week} worth 7
days, @samp{day} worth 24 hours, @samp{hour} worth 60 minutes,
@samp{minute} or @samp{min} worth 60 seconds, and @samp{second} or
@samp{sec} worth one second. An @samp{s} suffix on these units is
accepted and ignored.
@findex ago @r{in date strings}
The unit of time may be preceded by a multiplier, given as an optionally
signed number. Unsigned numbers are taken as positively signed. No
number at all implies 1 for a multiplier. Following a relative item by
the string @samp{ago} is equivalent to preceding the unit by a
multiplicator with value @math{-1}.
@findex day @r{in date strings}
@findex tomorrow @r{in date strings}
@findex yesterday @r{in date strings}
The string @samp{tomorrow} is worth one day in the future (equivalent
to @samp{day}), the string @samp{yesterday} is worth
one day in the past (equivalent to @samp{day ago}).
@findex now @r{in date strings}
@findex today @r{in date strings}
@findex this @r{in date strings}
The strings @samp{now} or @samp{today} are relative items corresponding
to zero-valued time displacement, these strings come from the fact
a zero-valued time displacement represents the current time when not
otherwise change by previous items. They may be used to stress other
items, like in @samp{12:00 today}. The string @samp{this} also has
the meaning of a zero-valued time displacement, but is preferred in
date strings like @samp{this thursday}.
When a relative item makes the resulting date to cross the boundary
between DST and non-DST (or vice-versa), the hour is adjusted according
to the local time.
@node Pure numbers in date strings
@section Pure numbers in date strings
@cindex pure numbers in date strings
The precise intepretation of a pure decimal number is dependent of
the context in the date string.
If the decimal number is of the form @var{yyyy}@var{mm}@var{dd} and no
other calendar date item (@pxref{Calendar date item}) appears before it
in the date string, then @var{yyyy} is read as the year, @var{mm} as the
month number and @var{dd} as the day of the month, for the specified
calendar date.
If the decimal number is of the form @var{hh}@var{mm} and no other time
of day item appears before it in the date string, then @var{hh} is read
as the hour of the day and @var{mm} as the minute of the hour, for the
specified time of the day. @var{mm} can also be omitted.
If both a calendar date and a time of day appear to the left of a number
in the date string, but no relative item, then the number overrides the
year.
@node Authors of getdate
@section Authors of @code{getdate}
@cindex authors of @code{getdate}
@cindex Bellovin, Steven M.
@cindex Salz, Rich
@cindex Berets, Jim
@cindex MacKenzie, David
@cindex Meyering, Jim
@code{getdate} was originally implemented by Steven M. Bellovin
(@samp{smb@@research.att.com}) while at the University of North Carolina
at Chapel Hill. The code was later tweaked by a couple of people on
Usenet, then completely overhauled by Rich $alz (@samp{rsalz@@bbn.com})
and Jim Berets (@samp{jberets@@bbn.com}) in August, 1990. Various
revisions for the GNU system were made by David MacKenzie, Jim Meyering,
and others.
@cindex Pinard, F.
@cindex Berry, K.
This chapter was originally produced by @value{Francois} Pinard
(@samp{pinard@@iro.umontreal.ca}) from the @file{getdate.y} source code,
and then edited by K.@: Berry (@samp{kb@@cs.umb.edu}).

92
doc/mdate-sh Executable file
View File

@@ -0,0 +1,92 @@
#!/bin/sh
# mdate-sh - get modification time of a file and pretty-print it
# Copyright (C) 1995 Software Foundation, Inc.
# Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
#
# 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.
# Prevent date giving response in another language.
LANG=C
export LANG
LC_ALL=C
export LC_ALL
LC_TIME=C
export LC_TIME
# Get the extended ls output of the file.
if ls -L /dev/null 1>/dev/null 2>&1; then
set - `ls -L -l $1`
else
set - `ls -l $1`
fi
# The month is at least the fourth argument.
# (3 shifts here, the next inside the loop)
shift
shift
shift
# Find the month. Next argument is day, followed by the year or time.
month=
until test $month
do
shift
case $1 in
Jan) month=January; nummonth=1;;
Feb) month=February; nummonth=2;;
Mar) month=March; nummonth=3;;
Apr) month=April; nummonth=4;;
May) month=May; nummonth=5;;
Jun) month=June; nummonth=6;;
Jul) month=July; nummonth=7;;
Aug) month=August; nummonth=8;;
Sep) month=September; nummonth=9;;
Oct) month=October; nummonth=10;;
Nov) month=November; nummonth=11;;
Dec) month=December; nummonth=12;;
esac
done
day=$2
# Here we have to deal with the problem that the ls output gives either
# the time of day or the year.
case $3 in
*:*) set `date`; eval year=\$$#
case $2 in
Jan) nummonthtod=1;;
Feb) nummonthtod=2;;
Mar) nummonthtod=3;;
Apr) nummonthtod=4;;
May) nummonthtod=5;;
Jun) nummonthtod=6;;
Jul) nummonthtod=7;;
Aug) nummonthtod=8;;
Sep) nummonthtod=9;;
Oct) nummonthtod=10;;
Nov) nummonthtod=11;;
Dec) nummonthtod=12;;
esac
# For the first six month of the year the time notation can also
# be used for file modified in the last year.
if (expr $nummonth \> $nummonthtod) > /dev/null;
then
year=`expr $year - 1`
fi
;;
*) year=$3;;
esac
# The result.
echo $day $month $year

478
doc/perm.texi Normal file
View File

@@ -0,0 +1,478 @@
Each file has a set of @dfn{permissions} that control the kinds of
access that users have to that file. The permissions for a file are
also called its @dfn{access mode}. They can be represented either in
symbolic form or as an octal number.
@menu
* Mode Structure:: Structure of file permissions.
* Symbolic Modes:: Mnemonic permissions representation.
* Numeric Modes:: Permissions as octal numbers.
@end menu
@node Mode Structure
@section Structure of File Permissions
There are three kinds of permissions that a user can have for a file:
@enumerate
@item
@cindex read permission
permission to read the file. For directories, this means permission to
list the contents of the directory.
@item
@cindex write permission
permission to write to (change) the file. For directories, this means
permission to create and remove files in the directory.
@item
@cindex execute permission
permission to execute the file (run it as a program). For directories,
this means permission to access files in the directory.
@end enumerate
There are three categories of users who may have different permissions
to perform any of the above operations on a file:
@enumerate
@item
the file's owner;
@item
other users who are in the file's group;
@item
everyone else.
@end enumerate
@cindex owner, default
@cindex group owner, default
Files are given an owner and group when they are created. Usually the
owner is the current user and the group is the group of the directory
the file is in, but this varies with the operating system, the
filesystem the file is created on, and the way the file is created. You
can change the owner and group of a file by using the @code{chown} and
@code{chgrp} commands.
In addition to the three sets of three permissions listed above, a
file's permissions have three special components, which affect only
executable files (programs) and, on some systems, directories:
@enumerate
@item
@cindex setuid
set the process's effective user ID to that of the file upon execution
(called the @dfn{setuid bit}). No effect on directories.
@item
@cindex setgid
set the process's effective group ID to that of the file upon execution
(called the @dfn{setgid bit}). For directories on some systems, put
files created in the directory into the same group as the directory, no
matter what group the user who creates them is in.
@item
@cindex sticky
@cindex swap space, saving text image in
@cindex text image, saving in swap space
@cindex append-only directories
save the program's text image on the swap device so it will load more
quickly when run (called the @dfn{sticky bit}). For directories on some
systems, prevent users from removing files that they do not own in the
directory; this is called making the directory @dfn{append-only}.
@end enumerate
@node Symbolic Modes
@section Symbolic Modes
@cindex symbolic modes
@dfn{Symbolic modes} represent changes to files' permissions as
operations on single-character symbols. They allow you to modify either
all or selected parts of files' permissions, optionally based on
their previous values, and perhaps on the current @code{umask} as well
(@pxref{Umask and Protection}).
The format of symbolic modes is:
@example
@r{[}ugoa@dots{}@r{][[}+-=@r{][}rwxXstugo@dots{}@r{]}@dots{}@r{][},@dots{}@r{]}
@end example
The following sections describe the operators and other details of
symbolic modes.
@menu
* Setting Permissions:: Basic operations on permissions.
* Copying Permissions:: Copying existing permissions.
* Changing Special Permissions:: Special permissions.
* Conditional Executability:: Conditionally affecting executability.
* Multiple Changes:: Making multiple changes.
* Umask and Protection:: The effect of the umask.
@end menu
@node Setting Permissions
@subsection Setting Permissions
The basic symbolic operations on a file's permissions are adding,
removing, and setting the permission that certain users have to read,
write, and execute the file. These operations have the following
format:
@example
@var{users} @var{operation} @var{permissions}
@end example
@noindent
The spaces between the three parts above are shown for readability only;
symbolic modes can not contain spaces.
The @var{users} part tells which users' access to the file is changed.
It consists of one or more of the following letters (or it can be empty;
@pxref{Umask and Protection}, for a description of what happens then). When
more than one of these letters is given, the order that they are in does
not matter.
@table @code
@item u
@cindex owner of file, permissions for
the user who owns the file;
@item g
@cindex group, permissions for
other users who are in the file's group;
@item o
@cindex other permissions
all other users;
@item a
all users; the same as @samp{ugo}.
@end table
The @var{operation} part tells how to change the affected users' access
to the file, and is one of the following symbols:
@table @code
@item +
@cindex adding permissions
to add the @var{permissions} to whatever permissions the @var{users}
already have for the file;
@item -
@cindex removing permissions
@cindex subtracting permissions
to remove the @var{permissions} from whatever permissions the
@var{users} already have for the file;
@item =
@cindex setting permissions
to make the @var{permissions} the only permissions that the @var{users}
have for the file.
@end table
The @var{permissions} part tells what kind of access to the file should
be changed; it is zero or more of the following letters. As with the
@var{users} part, the order does not matter when more than one letter is
given. Omitting the @var{permissions} part is useful only with the
@samp{=} operation, where it gives the specified @var{users} no access
at all to the file.
@table @code
@item r
@cindex read permission, symbolic
the permission the @var{users} have to read the file;
@item w
@cindex write permission, symbolic
the permission the @var{users} have to write to the file;
@item x
@cindex execute permission, symbolic
the permission the @var{users} have to execute the file.
@end table
For example, to give everyone permission to read and write a file,
but not to execute it, use:
@example
a=rw
@end example
To remove write permission for from all users other than the file's
owner, use:
@example
go-w
@end example
@noindent
The above command does not affect the access that the owner of
the file has to it, nor does it affect whether other users can
read or execute the file.
To give everyone except a file's owner no permission to do anything with
that file, use the mode below. Other users could still remove the file,
if they have write permission on the directory it is in.
@example
go=
@end example
@noindent
Another way to specify the same thing is:
@example
og-rxw
@end example
@node Copying Permissions
@subsection Copying Existing Permissions
@cindex copying existing permissions
@cindex permissions, copying existing
You can base a file's permissions on its existing permissions. To do
this, instead of using @samp{r}, @samp{w}, or @samp{x} after the
operator, you use the letter @samp{u}, @samp{g}, or @samp{o}. For
example, the mode
@example
o+g
@end example
@noindent
adds the permissions for users who are in a file's group to the
permissions that other users have for the file. Thus, if the file
started out as mode 664 (@samp{rw-rw-r--}), the above mode would change
it to mode 666 (@samp{rw-rw-rw-}). If the file had started out as mode
741 (@samp{rwxr----x}), the above mode would change it to mode 745
(@samp{rwxr--r-x}). The @samp{-} and @samp{=} operations work
analogously.
@node Changing Special Permissions
@subsection Changing Special Permissions
@cindex changing special permissions
In addition to changing a file's read, write, and execute permissions,
you can change its special permissions. @xref{Mode Structure}, for a
summary of these permissions.
To change a file's permission to set the user ID on execution, use
@samp{u} in the @var{users} part of the symbolic mode and
@samp{s} in the @var{permissions} part.
To change a file's permission to set the group ID on execution, use
@samp{g} in the @var{users} part of the symbolic mode and
@samp{s} in the @var{permissions} part.
To change a file's permission to stay permanently on the swap device,
use @samp{o} in the @var{users} part of the symbolic mode and
@samp{t} in the @var{permissions} part.
For example, to add set user ID permission to a program,
you can use the mode:
@example
u+s
@end example
To remove both set user ID and set group ID permission from
it, you can use the mode:
@example
ug-s
@end example
To cause a program to be saved on the swap device, you can use
the mode:
@example
o+t
@end example
Remember that the special permissions only affect files that are
executable, plus, on some systems, directories (on which they have
different meanings; @pxref{Mode Structure}). Using @samp{a}
in the @var{users} part of a symbolic mode does not cause the special
permissions to be affected; thus,
@example
a+s
@end example
@noindent
has @emph{no effect}. You must use @samp{u}, @samp{g}, and @samp{o}
explicitly to affect the special permissions. Also, the
combinations @samp{u+t}, @samp{g+t}, and @samp{o+s} have no effect.
The @samp{=} operator is not very useful with special permissions; for
example, the mode:
@example
o=t
@end example
@noindent
does cause the file to be saved on the swap device, but it also
removes all read, write, and execute permissions that users not in the
file's group might have had for it.
@node Conditional Executability
@subsection Conditional Executability
@cindex conditional executability
There is one more special type of symbolic permission: if you use
@samp{X} instead of @samp{x}, execute permission is affected only if the
file already had execute permission or is a directory. It affects
directories' execute permission even if they did not initially have any
execute permissions set.
For example, this mode:
@example
a+X
@end example
@noindent
gives all users permission to execute files (or search directories) if
anyone could before.
@node Multiple Changes
@subsection Making Multiple Changes
@cindex multiple changes to permissions
The format of symbolic modes is actually more complex than described
above (@pxref{Setting Permissions}). It provides two ways to make
multiple changes to files' permissions.
The first way is to specify multiple @var{operation} and
@var{permissions} parts after a @var{users} part in the symbolic mode.
For example, the mode:
@example
og+rX-w
@end example
@noindent
gives users other than the owner of the file read permission and, if
it is a directory or if someone already had execute permission
to it, gives them execute permission; and it also denies them write
permission to it file. It does not affect the permission that the
owner of the file has for it. The above mode is equivalent to
the two modes:
@example
og+rX
og-w
@end example
The second way to make multiple changes is to specify more than one
simple symbolic mode, separated by commas. For example, the mode:
@example
a+r,go-w
@end example
@noindent
gives everyone permission to read the file and removes write
permission on it for all users except its owner. Another example:
@example
u=rwx,g=rx,o=
@end example
@noindent
sets all of the non-special permissions for the file explicitly. (It
gives users who are not in the file's group no permission at all for
it.)
The two methods can be combined. The mode:
@example
a+r,g+x-w
@end example
@noindent
gives all users permission to read the file, and gives users who are in
the file's group permission to execute it, as well, but not permission
to write to it. The above mode could be written in several different
ways; another is:
@example
u+r,g+rx,o+r,g-w
@end example
@node Umask and Protection
@subsection The Umask and Protection
@cindex umask and modes
@cindex modes and umask
If the @var{users} part of a symbolic mode is omitted, it defaults to
@samp{a} (affect all users), except that any permissions that are
@emph{set} in the system variable @code{umask} are @emph{not affected}.
The value of @code{umask} can be set using the
@code{umask} command. Its default value varies from system to system.
@cindex giving away permissions
Omitting the @var{users} part of a symbolic mode is generally not useful
with operations other than @samp{+}. It is useful with @samp{+} because
it allows you to use @code{umask} as an easily customizable protection
against giving away more permission to files than you intended to.
As an example, if @code{umask} has the value 2, which removes write
permission for users who are not in the file's group, then the mode:
@example
+w
@end example
@noindent
adds permission to write to the file to its owner and to other users who
are in the file's group, but @emph{not} to other users. In contrast,
the mode:
@example
a+w
@end example
@noindent
ignores @code{umask}, and @emph{does} give write permission for
the file to all users.
@node Numeric Modes
@section Numeric Modes
@cindex numeric modes
@cindex file permissions, numeric
@cindex octal numbers for file modes
File permissions are stored internally as 16 bit integers. As an
alternative to giving a symbolic mode, you can give an octal (base 8)
number that corresponds to the internal representation of the new mode.
This number is always interpreted in octal; you do not have to add a
leading 0, as you do in C. Mode 0055 is the same as mode 55.
A numeric mode is usually shorter than the corresponding symbolic
mode, but it is limited in that it can not take into account a file's
previous permissions; it can only set them absolutely.
The permissions granted to the user, to other users in the file's group,
and to other users not in the file's group are each stored as three
bits, which are represented as one octal digit. The three special
permissions are also each stored as one bit, and they are as a group
represented as another octal digit. Here is how the bits are arranged
in the 16 bit integer, starting with the lowest valued bit:
@example
Value in Corresponding
Mode Permission
Other users not in the file's group:
1 Execute
2 Write
4 Read
Other users in the file's group:
10 Execute
20 Write
40 Read
The file's owner:
100 Execute
200 Write
400 Read
Special permissions:
1000 Save text image on swap device
2000 Set group ID on execution
4000 Set user ID on execution
@end example
For example, numeric mode 4755 corresponds to symbolic mode
@samp{u=rwxs,go=rx}, and numeric mode 664 corresponds to symbolic mode
@samp{ug=rw,o=r}. Numeric mode 0 corresponds to symbolic mode
@samp{ugo=}.

3015
doc/sh-utils.texi Normal file

File diff suppressed because it is too large Load Diff

4558
doc/texinfo.tex Normal file

File diff suppressed because it is too large Load Diff

3326
doc/textutils.texi Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,9 @@
Makefile
getdate.c
posixtm.c
safe-stat.h
safe-stat.c
safe-lstat.c
safe-lstat.h
getdate.tab.c
.deps

43
lib/Makefile.am Normal file
View File

@@ -0,0 +1,43 @@
## Process this file with automake to produce Makefile.in
noinst_LIBRARIES = fu
EXTRA_DIST = alloca.c basename.c euidaccess.c fnmatch.c fsusage.c \
ftruncate.c getdate.y getopt.c getopt1.c group-member.c \
memcmp.c memcpy.c memset.c \
mkdir.c mktime.c mountlist.c posixtm.y rename.c rmdir.c \
stpcpy.c strcasecmp.c strdup.c strndup.c strstr.c strtol.c strtoul.c
INCLUDES = -I.. -I$(srcdir)
fu_SOURCES = getdate.c getline.c posixtm.c argmatch.c backupfile.c \
dirname.c error.c fileblocks.c filemode.c \
full-write.c getversion.c idcache.c \
isdir.c long-options.c makepath.c modechange.c obstack.c \
safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
fu_LIBADD = @LIBOBJS@ @ALLOCA@
noinst_HEADERS = argmatch.h backupfile.h error.h fnmatch.h fsusage.h \
getline.h getopt.h group-member.h long-options.h makepath.h modechange.h \
mountlist.h obstack.h pathmax.h save-cwd.h xstrtol.h xstrtoul.h
BUILT_SOURCES = getdate.c posixtm.c
# Since this directory contains two parsers, we have to be careful to avoid
# running two $(YACC)s during parallel makes. See below.
getdate.c: @MAINT@getdate.y
@echo expect 10 shift/reduce conflicts
$(YACC) $(srcdir)/getdate.y
mv y.tab.c getdate.c
# Make the rename atomic, in case sed is interrupted and later rerun.
# The artificial dependency on getdate.c keeps the two parsers from being
# built in parallel. Enforcing this little bit of sequentiality lets
# everyone (even those without bison) still run mostly parallel builds.
posixtm.c: @MAINT@posixtm.y getdate.c
$(YACC) $(srcdir)/posixtm.y
mv y.tab.c posixtm.tab.c
sed -e 's/yy/zz/g' posixtm.tab.c > tposixtm.c
mv tposixtm.c posixtm.c
rm -f posixtm.tab.c

View File

@@ -1,91 +1,285 @@
# Makefile for library files used by GNU fileutils.
# Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
# Makefile.in generated automatically by automake 1.0 from Makefile.am
# 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.
# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
SHELL = /bin/sh
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
noinst_LIBRARIES = fu
EXTRA_DIST = alloca.c basename.c euidaccess.c fnmatch.c fsusage.c \
ftruncate.c getdate.y getopt.c getopt1.c group-member.c \
memcmp.c memcpy.c memset.c \
mkdir.c mktime.c mountlist.c posixtm.y rename.c rmdir.c \
stpcpy.c strcasecmp.c strdup.c strndup.c strstr.c strtol.c strtoul.c
INCLUDES = -I.. -I$(srcdir)
fu_SOURCES = getdate.c getline.c posixtm.c argmatch.c backupfile.c \
dirname.c error.c fileblocks.c filemode.c \
full-write.c getversion.c idcache.c \
isdir.c long-options.c makepath.c modechange.c obstack.c \
safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
fu_LIBADD = @LIBOBJS@ @ALLOCA@
noinst_HEADERS = argmatch.h backupfile.h error.h fnmatch.h fsusage.h \
getline.h getopt.h group-member.h long-options.h makepath.h modechange.h \
mountlist.h obstack.h pathmax.h save-cwd.h xstrtol.h xstrtoul.h
BUILT_SOURCES = getdate.c posixtm.c
mkinstalldirs = $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
LIBRARIES = $(noinst_LIBRARIES)
noinst_LIBFILES = libfu.a
CC = @CC@
LEX = @LEX@
YACC = @YACC@
DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(LDFLAGS) -o $@
fu_OBJECTS = getdate.o getline.o posixtm.o argmatch.o backupfile.o \
dirname.o error.o fileblocks.o filemode.o full-write.o getversion.o \
idcache.o isdir.o long-options.o makepath.o modechange.o obstack.o \
safe-read.o save-cwd.o savedir.o stripslash.o userspec.o xgetcwd.o \
xmalloc.o xstrdup.o xstrtol.o xstrtoul.o yesno.o
EXTRA_fu_SOURCES =
LIBFILES = libfu.a
AR = ar
RANLIB = @RANLIB@
DEFS = @DEFS@
CFLAGS = @CFLAGS@
HEADERS = $(noinst_HEADERS)
SOURCES = getdate.y posixtm.y \
argmatch.c backupfile.c basename.c dirname.c eaccess.c \
error.c filemode.c fsusage.c getopt.c getopt1.c \
getversion.c idcache.c isdir.c makepath.c \
modechange.c mountlist.c savedir.c \
stripslash.c xgetcwd.c xmalloc.c xstrdup.c userspec.c yesno.c \
fileblocks.c fnmatch.c ftruncate.c mkdir.c mktime.c rename.c stpcpy.c \
strdup.c strstr.c alloca.c
DIST_COMMON = Makefile.am Makefile.in
OBJECTS = getdate.o posixtm.o \
argmatch.o backupfile.o basename.o dirname.o eaccess.o \
error.o filemode.o getopt.o getopt1.o \
getversion.o idcache.o isdir.o makepath.o \
modechange.o savedir.o \
stripslash.o xgetcwd.o xmalloc.o xstrdup.o userspec.o yesno.o \
@LIBOBJS@ @ALLOCA@
DISTFILES = Makefile.in backupfile.h getopt.h modechange.h \
fnmatch.h fsusage.h mountlist.h pathmax.h system.h $(SOURCES)
PACKAGE = @PACKAGE@
VERSION = @VERSION@
all: libfu.a
DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
$(TEXINFOS) $(INFOS) $(MANS) $(EXTRA_DIST) $(DATA)
DEP_DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
$(TEXINFOS) $(INFO_DEPS) $(MANS) $(EXTRA_DIST) $(DATA)
TAR = tar
DEP_FILES = $(srcdir)/.deps/alloca.P $(srcdir)/.deps/argmatch.P \
$(srcdir)/.deps/backupfile.P $(srcdir)/.deps/dirname.P \
$(srcdir)/.deps/error.P $(srcdir)/.deps/fileblocks.P \
$(srcdir)/.deps/filemode.P $(srcdir)/.deps/fnmatch.P \
$(srcdir)/.deps/fsusage.P $(srcdir)/.deps/ftruncate.P \
$(srcdir)/.deps/full-write.P $(srcdir)/.deps/getdate.P \
$(srcdir)/.deps/getline.P $(srcdir)/.deps/getopt.P \
$(srcdir)/.deps/getopt1.P $(srcdir)/.deps/getversion.P \
$(srcdir)/.deps/idcache.P $(srcdir)/.deps/isdir.P \
$(srcdir)/.deps/long-options.P $(srcdir)/.deps/makepath.P \
$(srcdir)/.deps/modechange.P $(srcdir)/.deps/mountlist.P \
$(srcdir)/.deps/obstack.P $(srcdir)/.deps/posixtm.P \
$(srcdir)/.deps/safe-read.P $(srcdir)/.deps/save-cwd.P \
$(srcdir)/.deps/savedir.P $(srcdir)/.deps/stripslash.P \
$(srcdir)/.deps/userspec.P $(srcdir)/.deps/xgetcwd.P \
$(srcdir)/.deps/xmalloc.P $(srcdir)/.deps/xstrdup.P \
$(srcdir)/.deps/xstrtol.P $(srcdir)/.deps/xstrtoul.P \
$(srcdir)/.deps/yesno.P
SOURCES = $(fu_SOURCES)
OBJECTS = $(fu_OBJECTS)
default: all
$(srcdir)/Makefile.in: @MAINT@Makefile.am $(top_srcdir)/configure.in
cd $(top_srcdir) && automake $(subdir)/Makefile
Makefile: $(top_builddir)/config.status Makefile.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
mostlyclean-noinstLIBRARIES:
clean-noinstLIBRARIES:
rm -f $(noinst_LIBFILES)
distclean-noinstLIBRARIES:
maintainer-clean-noinstLIBRARIES:
.c.o:
$(CC) -c $(CPPFLAGS) $(DEFS) -I.. -I$(srcdir) $(CFLAGS) $<
$(COMPILE) $<
install: all
mostlyclean-compile:
rm -f *.o core
uninstall:
clean-compile:
TAGS: $(SOURCES)
etags $(SOURCES)
distclean-compile:
rm -f *.tab.c
check:
maintainer-clean-compile:
$(fu_OBJECTS): ../config.h
clean:
rm -f *.a *.o
libfu.a: $(fu_OBJECTS) $(fu_LIBADD)
rm -f libfu.a
$(AR) cru libfu.a $(fu_OBJECTS) $(fu_LIBADD)
$(RANLIB) libfu.a
mostlyclean: clean
ID: $(HEADERS) $(SOURCES)
here=`pwd` && cd $(srcdir) && mkid -f$$here/ID $(SOURCES) $(HEADERS)
distclean: clean
rm -f Makefile *.tab.c getdate.c *posixtm.c
tags: TAGS
realclean: distclean
rm -f TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES)
here=`pwd` && cd $(srcdir) && etags $(ETAGS_ARGS) $(SOURCES) $(HEADERS) -o $$here/TAGS
dist:
for file in $(DISTFILES); do \
ln $$file ../`cat ../.fname`/lib \
|| cp -p $$file ../`cat ../.fname`/lib; \
mostlyclean-tags:
clean-tags:
distclean-tags:
rm -f TAGS ID
maintainer-clean-tags:
subdir = lib
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
distdir: $(DEP_DISTFILES)
@for file in `cd $(srcdir) && echo $(DISTFILES)`; do \
test -f $(distdir)/$$file \
|| ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $(srcdir)/$$file $(distdir)/$$file; \
done
libfu.a: $(OBJECTS)
rm -f $@
$(AR) cr $@ $(OBJECTS)
-$(RANLIB) $@
# This fragment is probably only useful for maintainers. It relies on
# GNU make and gcc. It is only included in the generated Makefile.in
# if `automake' is not passed the `--include-deps' flag.
MKDEP = gcc -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-include $(srcdir)/.deps/.P
$(srcdir)/.deps/.P: $(BUILT_SOURCES)
cd $(srcdir) && test -d .deps || mkdir .deps
echo > $@
-include $(DEP_FILES)
$(DEP_FILES): $(srcdir)/.deps/.P
$(srcdir)/.deps/%.P: $(srcdir)/%.c
@echo "mkdeps $< > $@"
@re=`echo 's,^$(srcdir)//*,,g;s, $(srcdir)//*, ,g' | sed 's,\.,\\\\.,g'`; \
$(MKDEP) $< | sed "$$re" > $@-tmp
@if test -n "$o"; then \
sed 's/\.o:/$$o:/' $@-tmp > $@; \
rm $@-tmp; \
else \
mv $@-tmp $@; \
fi
# End of maintainer-only section
info:
dvi:
check: all
installcheck:
install-exec:
install-data:
install: install-exec install-data all
@:
uninstall:
all: $(LIBFILES) $(HEADERS) Makefile
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
installdirs:
mostlyclean-generic:
test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic:
test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
rm -f Makefile $(DISTCLEANFILES)
rm -f config.cache config.log $(CONFIG_HEADER) stamp-h
maintainer-clean-generic:
test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \
mostlyclean-tags mostlyclean-generic
clean: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
mostlyclean
distclean: distclean-noinstLIBRARIES distclean-compile distclean-tags \
distclean-generic clean
rm -f config.status
maintainer-clean: maintainer-clean-noinstLIBRARIES \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-generic distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
.PHONY: default mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
clean-tags maintainer-clean-tags distdir info dvi check installcheck \
install-exec install-data install uninstall all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Since this directory contains two parsers, we have to be careful to avoid
# running two $(YACC)s during parallel makes. See below.
getdate.c: getdate.y
@echo expect 9 shift/reduce conflicts
getdate.c: @MAINT@getdate.y
@echo expect 10 shift/reduce conflicts
$(YACC) $(srcdir)/getdate.y
mv y.tab.c getdate.c
@@ -93,21 +287,15 @@ getdate.c: getdate.y
# The artificial dependency on getdate.c keeps the two parsers from being
# built in parallel. Enforcing this little bit of sequentiality lets
# everyone (even those without bison) still run mostly parallel builds.
posixtm.c: posixtm.y getdate.c
posixtm.c: @MAINT@posixtm.y getdate.c
$(YACC) $(srcdir)/posixtm.y
mv y.tab.c posixtm.tab.c
sed -e 's/yy/zz/g' posixtm.tab.c > tposixtm.c
mv tposixtm.c posixtm.c
rm -f posixtm.tab.c
.SUFFIXES:
.SUFFIXES: .c .o
backupfile.o getversion.o: backupfile.h
fnmatch.o: fnmatch.h
fsusage.o: fsusage.h
getopt1.o: getopt.h
modechange.o: modechange.h
mountlist.o: mountlist.h
xgetcwd.o: pathmax.h
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -17,6 +17,12 @@
/* Written by David MacKenzie <djm@ai.mit.edu> */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <stdio.h>
#ifdef STDC_HEADERS
#include <string.h>
@@ -31,16 +37,16 @@ extern char *program_name;
int
argmatch (arg, optlist)
char *arg;
char **optlist;
const char *arg;
const char *const *optlist;
{
int i; /* Temporary index in OPTLIST. */
int arglen; /* Length of ARG. */
size_t arglen; /* Length of ARG. */
int matchind = -1; /* Index of first nonexact match. */
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
arglen = strlen (arg);
/* Test all elements for either exact match or abbreviated matches. */
for (i = 0; optlist[i]; i++)
{
@@ -70,8 +76,8 @@ argmatch (arg, optlist)
void
invalid_arg (kind, value, problem)
char *kind;
char *value;
const char *kind;
const char *value;
int problem;
{
fprintf (stderr, "%s: ", program_name);

18
lib/argmatch.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef ARGMATCH_H
#define ARGMATCH_H 1
#ifndef __P
# if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
# define __P(args) args
# else
# define __P(args) ()
# endif /* GCC. */
#endif /* Not __P. */
int
argmatch __P ((const char *arg, const char *const *optlist));
void
invalid_arg __P ((const char *kind, const char *value, int problem));
#endif /* ARGMATCH_H */

View File

@@ -19,68 +19,56 @@
Some algorithms adapted from GNU Emacs. */
#ifdef HAVE_CONFIG_H
#if defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I will use ./config.h rather than /config.h
(which it would do because it found this file in ). */
#include <config.h>
#else
#include "config.h"
#endif
# include <config.h>
#endif
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include "backupfile.h"
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#include <string.h>
#ifndef index
#define index strchr
#endif
#ifndef rindex
#define rindex strrchr
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#else
#include <strings.h>
# include <strings.h>
#endif
#if defined(DIRENT) || defined(_POSIX_VERSION)
#include <dirent.h>
#define NLENGTH(direct) (strlen((direct)->d_name))
#else /* not (DIRENT or _POSIX_VERSION) */
#define dirent direct
#define NLENGTH(direct) ((direct)->d_namlen)
#ifdef SYSNDIR
#include <sys/ndir.h>
#endif /* SYSNDIR */
#ifdef SYSDIR
#include <sys/dir.h>
#endif /* SYSDIR */
#ifdef NDIR
#include <ndir.h>
#endif /* NDIR */
#endif /* DIRENT or _POSIX_VERSION */
#ifdef HAVE_DIRENT_H
# include <dirent.h>
# define NLENGTH(direct) (strlen((direct)->d_name))
#else /* not HAVE_DIRENT_H */
# define dirent direct
# define NLENGTH(direct) ((direct)->d_namlen)
# ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H
# include <ndir.h>
# endif /* HAVE_NDIR_H */
#endif /* HAVE_DIRENT_H */
#ifdef VOID_CLOSEDIR
#ifdef CLOSEDIR_VOID
/* Fake a return value. */
#define CLOSEDIR(d) (closedir (d), 0)
# define CLOSEDIR(d) (closedir (d), 0)
#else
#define CLOSEDIR(d) closedir (d)
# define CLOSEDIR(d) closedir (d)
#endif
#ifdef STDC_HEADERS
#include <stdlib.h>
# include <stdlib.h>
#else
char *malloc ();
#endif
#if !defined (isascii) || defined (STDC_HEADERS)
#undef isascii
#define isascii(c) 1
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
#else
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
#define ISDIGIT(c) (isascii ((unsigned char ) c) \
#define ISDIGIT(c) (IN_CTYPE_DOMAIN ((unsigned char) (c)) \
&& isdigit ((unsigned char) (c)))
#if defined (HAVE_UNISTD_H)
@@ -90,9 +78,9 @@ char *malloc ();
#if defined (_POSIX_VERSION)
/* POSIX does not require that the d_ino field be present, and some
systems do not provide it. */
#define REAL_DIR_ENTRY(dp) 1
# define REAL_DIR_ENTRY(dp) 1
#else
#define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0)
# define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0)
#endif
/* Which type of backup file names are generated. */
@@ -117,7 +105,7 @@ static int version_number ();
char *
find_backup_file_name (file)
char *file;
const char *file;
{
char *dir;
char *base_versions;
@@ -149,18 +137,19 @@ find_backup_file_name (file)
static int
max_backup_version (file, dir)
char *file, *dir;
const char *file;
const char *dir;
{
DIR *dirp;
struct dirent *dp;
int highest_version;
int this_version;
int file_name_length;
size_t file_name_length;
dirp = opendir (dir);
if (!dirp)
return 0;
highest_version = 0;
file_name_length = strlen (file);
@@ -168,7 +157,7 @@ max_backup_version (file, dir)
{
if (!REAL_DIR_ENTRY (dp) || NLENGTH (dp) <= file_name_length)
continue;
this_version = version_number (file, dp->d_name, file_name_length);
if (this_version > highest_version)
highest_version = this_version;
@@ -183,7 +172,7 @@ max_backup_version (file, dir)
static char *
make_version_name (file, version)
char *file;
const char *file;
int version;
{
char *backup_name;
@@ -201,13 +190,13 @@ make_version_name (file, version)
static int
version_number (base, backup, base_length)
char *base;
char *backup;
const char *base;
const char *backup;
int base_length;
{
int version;
char *p;
const char *p;
version = 0;
if (!strncmp (base, backup, base_length) && ISDIGIT (backup[base_length]))
{
@@ -224,7 +213,8 @@ version_number (base, backup, base_length)
static char *
concat (str1, str2)
char *str1, *str2;
const char *str1;
const char *str2;
{
char *newstr;
int str1_length = strlen (str1);

View File

@@ -36,7 +36,7 @@ extern enum backup_type backup_type;
extern char *simple_backup_suffix;
#ifdef __STDC__
char *find_backup_file_name (char *file);
char *find_backup_file_name (const char *file);
#else
char *find_backup_file_name ();
#endif

View File

@@ -15,21 +15,24 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#if defined(USG) || defined(STDC_HEADERS)
#include <string.h>
#define rindex strrchr
#else
#include <strings.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* Return NAME with any leading path stripped off. */
/* Return NAME with any leading path stripped off.
Don't use strrchr/rindex. */
char *
basename (name)
char *name;
const char *name;
{
char *base;
const char *base = name;
base = rindex (name, '/');
return base ? base + 1 : name;
while (*name)
{
if (*name == '/')
base = name + 1;
++name;
}
return (char *) base;
}

80
lib/canon-host.c Normal file
View File

@@ -0,0 +1,80 @@
/* Host name canonicalization
Copyright (C) 1995 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
/* Returns the canonical hostname associated with HOST (allocated in a static
buffer), or 0 if it can't be determined. */
char *
canon_host (host)
char *host;
{
#ifdef HAVE_GETHOSTBYNAME
struct hostent *he = gethostbyname (host);
if (he)
{
#ifdef HAVE_GETHOSTBYADDR
char *addr = 0;
/* Try and get an ascii version of the numeric host address. */
switch (he->h_addrtype)
{
#ifdef HAVE_INET_NTOA
case AF_INET:
addr = inet_ntoa (*(struct in_addr *) he->h_addr);
break;
#endif /* HAVE_INET_NTOA */
}
if (addr && strcmp (he->h_name, addr) == 0)
/* gethostbyname() cheated! Lookup the host name via the address
this time to get the actual host name. */
he = gethostbyaddr (he->h_addr, he->h_length, he->h_addrtype);
#endif /* HAVE_GETHOSTBYADDR */
if (he)
return (char *) (he->h_name);
}
#endif /* HAVE_GETHOSTBYNAME */
return 0;
}

View File

@@ -16,14 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#if defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I will use ./config.h rather than /config.h
(which it would do because it found this file in ). */
#include <config.h>
#else
#include "config.h"
#endif
#endif
#ifdef STDC_HEADERS
@@ -33,11 +26,11 @@ char *malloc ();
#endif
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#include <string.h>
#ifndef rindex
#define rindex strrchr
#endif
#else
#include <strings.h>
#ifndef strrchr
#define strrchr rindex
#endif
#endif
/* Return the leading directories part of PATH,
@@ -53,7 +46,7 @@ dirname (path)
char *slash;
int length; /* Length of result, not including NUL. */
slash = rindex (path, '/');
slash = strrchr (path, '/');
if (slash == 0)
{
/* File is in the current directory. */
@@ -68,7 +61,7 @@ dirname (path)
length = slash - path + 1;
}
newpath = malloc (length + 1);
newpath = (char *) malloc (length + 1);
if (newpath == 0)
return 0;
strncpy (newpath, path, length);

View File

@@ -1,54 +1,81 @@
/* error.c -- error handler for noninteractive utilities
Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
Copyright (C) 1990, 91, 92, 93, 94, 95, 96 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 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.
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., 675 Mass Ave, Cambridge, MA 02139, 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. */
/* Written by David MacKenzie. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#ifdef HAVE_VPRINTF
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
# if __STDC__
# include <stdarg.h>
# define VA_START(args, lastarg) va_start(args, lastarg)
# else
# include <varargs.h>
# define VA_START(args, lastarg) va_start(args)
# endif
#else
# define va_alist a1, a2, a3, a4, a5, a6, a7, a8
# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
#endif
#if __STDC__
#include <stdarg.h>
#define VA_START(args, lastarg) va_start(args, lastarg)
#else /* !__STDC__ */
#include <varargs.h>
#define VA_START(args, lastarg) va_start(args)
#endif /* !__STDC__ */
#else /* !HAVE_VPRINTF */
#ifdef HAVE_DOPRNT
#define va_alist args
#define va_dcl int args;
#else /* !HAVE_DOPRNT */
#define va_alist a1, a2, a3, a4, a5, a6, a7, a8
#define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
#endif /* !HAVE_DOPRNT */
#endif /* !HAVE_VPRINTF */
#ifdef STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#else /* !STDC_HEADERS */
#if STDC_HEADERS || _LIBC
# include <stdlib.h>
# include <string.h>
#else
void exit ();
#endif /* !STDC_HEADERS */
#endif
#ifndef HAVE_STRERROR
#ifndef _
# define _(String) String
#endif
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
function without parameters instead. */
void (*error_print_progname) (
#if __STDC__ - 0
void
#endif
);
/* This variable is incremented each time `error' is called. */
unsigned int error_message_count;
#ifdef _LIBC
/* In the GNU C library, there is a predefined variable for this. */
# define program_name program_invocation_name
# include <errno.h>
#else
/* The calling program should define program_name and set it to the
name of the executing program. */
extern char *program_name;
# if HAVE_STRERROR
# ifndef strerror /* On some systems, strerror is a macro */
char *strerror ();
# endif
# else
static char *
private_strerror (errnum)
int errnum;
@@ -58,44 +85,122 @@ private_strerror (errnum)
if (errnum > 0 && errnum <= sys_nerr)
return sys_errlist[errnum];
return "Unknown system error";
return _("Unknown system error");
}
#define strerror private_strerror
#endif /* !HAVE_STRERROR */
# define strerror private_strerror
# endif /* HAVE_STRERROR */
#endif /* _LIBC */
/* Print the program name and error message MESSAGE, which is a printf-style
format string with optional args.
If ERRNUM is nonzero, print its corresponding system error message.
Exit with status STATUS if it is nonzero. */
/* VARARGS */
void
#if defined (HAVE_VPRINTF) && __STDC__
error (int status, int errnum, char *message, ...)
#else /* !HAVE_VPRINTF or !__STDC__ */
#if defined(VA_START) && __STDC__
error (int status, int errnum, const char *message, ...)
#else
error (status, errnum, message, va_alist)
int status;
int errnum;
char *message;
va_dcl
#endif /* !HAVE_VPRINTF or !__STDC__ */
#endif
{
extern char *program_name;
#ifdef HAVE_VPRINTF
#ifdef VA_START
va_list args;
#endif /* HAVE_VPRINTF */
#endif
fprintf (stderr, "%s: ", program_name);
#ifdef HAVE_VPRINTF
if (error_print_progname)
(*error_print_progname) ();
else
{
fflush (stdout);
fprintf (stderr, "%s: ", program_name);
}
#ifdef VA_START
VA_START (args, message);
# if HAVE_VPRINTF || _LIBC
vfprintf (stderr, message, args);
# else
_doprnt (message, args, stderr);
# endif
va_end (args);
#else /* !HAVE_VPRINTF */
#ifdef HAVE_DOPRNT
_doprnt (message, &args, stderr);
#else /* !HAVE_DOPRNT */
#else
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
#endif /* !HAVE_DOPRNT */
#endif /* !HAVE_VPRINTF */
#endif
++error_message_count;
if (errnum)
fprintf (stderr, ": %s", strerror (errnum));
putc ('\n', stderr);
fflush (stderr);
if (status)
exit (status);
}
/* Sometimes we want to have at most one error per line. This
variable controls whether this mode is selected or not. */
int error_one_per_line;
void
#if defined(VA_START) && __STDC__
error_at_line (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message, ...)
#else
error_at_line (status, errnum, file_name, line_number, message, va_alist)
int status;
int errnum;
const char *file_name;
unsigned int line_number;
char *message;
va_dcl
#endif
{
#ifdef VA_START
va_list args;
#endif
if (error_one_per_line)
{
static const char *old_file_name;
static unsigned int old_line_number;
if (old_line_number == line_number &&
(file_name == old_file_name || !strcmp (old_file_name, file_name)))
/* Simply return and print nothing. */
return;
old_file_name = file_name;
old_line_number = line_number;
}
if (error_print_progname)
(*error_print_progname) ();
else
{
fflush (stdout);
fprintf (stderr, "%s:", program_name);
}
if (file_name != NULL)
fprintf (stderr, "%s:%d: ", file_name, line_number);
#ifdef VA_START
VA_START (args, message);
# if HAVE_VPRINTF || _LIBC
vfprintf (stderr, message, args);
# else
_doprnt (message, args, stderr);
# endif
va_end (args);
#else
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
#endif
++error_message_count;
if (errnum)
fprintf (stderr, ": %s", strerror (errnum));
putc ('\n', stderr);

65
lib/error.h Normal file
View File

@@ -0,0 +1,65 @@
/* error.h -- declaration for error-reporting function
Copyright (C) 1995, 1996 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 _error_h_
#define _error_h_
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __format__ format
# define __printf__ printf
# endif
#endif
#if defined (__STDC__) && __STDC__
/* Print a message with `fprintf (stderr, FORMAT, ...)';
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
extern void error (int status, int errnum, const char *format, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
extern void error_at_line (int status, int errnum, const char *fname,
unsigned int lineno, const char *format, ...)
__attribute__ ((__format__ (__printf__, 5, 6)));
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
function without parameters instead. */
extern void (*error_print_progname) (void);
#else
void error ();
void error_at_line ();
extern void (*error_print_progname) ();
#endif
/* This variable is incremented each time `error' is called. */
extern unsigned int error_message_count;
/* Sometimes we want to have at most one error per line. This
variable controls whether this mode is selected or not. */
extern int error_one_per_line;
#endif /* _error_h_ */

182
lib/euidaccess.c Normal file
View File

@@ -0,0 +1,182 @@
/* euidaccess -- check if effective user id can access file
Copyright (C) 1990, 1991, 1995 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/* Written by David MacKenzie and Torbjorn Granlund.
Adapted for GNU C library by Roland McGrath. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef S_IEXEC
# ifndef S_IXUSR
# define S_IXUSR S_IEXEC
# endif
# ifndef S_IXGRP
# define S_IXGRP (S_IEXEC >> 3)
# endif
# ifndef S_IXOTH
# define S_IXOTH (S_IEXEC >> 6)
# endif
#endif /* S_IEXEC */
#if defined (HAVE_UNISTD_H) || defined (_LIBC)
# include <unistd.h>
#endif
#ifdef _POSIX_VERSION
# include <limits.h>
# if !defined(NGROUPS_MAX) || NGROUPS_MAX < 1
# undef NGROUPS_MAX
# define NGROUPS_MAX sysconf (_SC_NGROUPS_MAX)
# endif /* NGROUPS_MAX */
#else /* not _POSIX_VERSION */
uid_t getuid ();
gid_t getgid ();
uid_t geteuid ();
gid_t getegid ();
# include <sys/param.h>
# if !defined(NGROUPS_MAX) && defined(NGROUPS)
# define NGROUPS_MAX NGROUPS
# endif /* not NGROUPS_MAX and NGROUPS */
#endif /* not POSIX_VERSION */
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#if defined(EACCES) && !defined(EACCESS)
# define EACCESS EACCES
#endif
#ifndef F_OK
# define F_OK 0
# define X_OK 1
# define W_OK 2
# define R_OK 4
#endif
#if !defined (S_IROTH) && defined (R_OK)
# define S_IROTH R_OK
#endif
#if !defined (S_IWOTH) && defined (W_OK)
# define S_IWOTH W_OK
#endif
#if !defined (S_IXOTH) && defined (X_OK)
# define S_IXOTH X_OK
#endif
#ifdef _LIBC
# define group_member __group_member
#else
/* The user's real user id. */
static uid_t uid;
/* The user's real group id. */
static gid_t gid;
/* The user's effective user id. */
static uid_t euid;
/* The user's effective group id. */
static gid_t egid;
/* Nonzero if UID, GID, EUID, and EGID have valid values. */
static int have_ids = 0;
# ifdef HAVE_GETGROUPS
int group_member ();
# else
# define group_member(gid) 0
# endif
#endif
/* Return 0 if the user has permission of type MODE on file PATH;
otherwise, return -1 and set `errno' to EACCESS.
Like access, except that it uses the effective user and group
id's instead of the real ones, and it does not check for read-only
filesystem, text busy, etc. */
int
euidaccess (path, mode)
const char *path;
int mode;
{
struct stat stats;
int granted;
#ifdef _LIBC
uid_t uid = getuid (), euid = geteuid ();
gid_t gid = getgid (), egid = getegid ();
#else
if (have_ids == 0)
{
have_ids = 1;
uid = getuid ();
gid = getgid ();
euid = geteuid ();
egid = getegid ();
}
#endif
if (uid == euid && gid == egid)
/* If we are not set-uid or set-gid, access does the same. */
return access (path, mode);
if (stat (path, &stats))
return -1;
mode &= (X_OK | W_OK | R_OK); /* Clear any bogus bits. */
#if R_OK != S_IROTH || W_OK != S_IWOTH || X_OK != S_IXOTH
?error Oops, portability assumptions incorrect.
#endif
if (mode == F_OK)
return 0; /* The file exists. */
/* The super-user can read and write any file, and execute any file
that anyone can execute. */
if (euid == 0 && ((mode & X_OK) == 0
|| (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))))
return 0;
if (euid == stats.st_uid)
granted = (unsigned) (stats.st_mode & (mode << 6)) >> 6;
else if (egid == stats.st_gid || group_member (stats.st_gid))
granted = (unsigned) (stats.st_mode & (mode << 3)) >> 3;
else
granted = (stats.st_mode & mode);
if (granted == mode)
return 0;
errno = EACCESS;
return -1;
}

View File

@@ -17,21 +17,27 @@
/* Written by Brian L. Matthews, blm@6sceng.UUCP. */
#if !defined (HAVE_ST_BLOCKS) && !defined(_POSIX_SOURCE)
#include <sys/types.h>
#include <sys/param.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef NINDIR
#if !defined (HAVE_ST_BLOCKS) && !defined(_POSIX_VERSION)
# include <sys/types.h>
# include <sys/param.h>
# ifndef NINDIR
/* Some SysV's, like Irix, seem to lack these. Hope they're correct. */
/* Size of a indirect block, in bytes. */
#define BSIZE 1024
# ifndef BSIZE
# define BSIZE 1024
# endif
/* Number of inode pointers per indirect block. */
#define NINDIR (BSIZE/sizeof(daddr_t))
#endif /* !NINDIR */
# define NINDIR (BSIZE/sizeof(daddr_t))
# endif /* !NINDIR */
/* Number of direct block addresses in an inode. */
#define NDIR 10
# define NDIR 10
/* Return the number of 512-byte blocks in a file of SIZE bytes. */
@@ -57,4 +63,8 @@ st_blocks (size)
return datablks + indrblks;
}
#else
/* This declaration is solely to ensure that after preprocessing
this file is never empty. */
extern int textutils_fileblocks_unused;
#endif

View File

@@ -1,5 +1,5 @@
/* filemode.c -- make a string describing file modes
Copyright (C) 1985, 1990 Free Software Foundation, Inc.
Copyright (C) 1985, 1990, 1993 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,36 +15,70 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifndef S_IREAD
#define S_IREAD S_IRUSR
#define S_IWRITE S_IWUSR
#define S_IEXEC S_IXUSR
#if !S_IRUSR
# if S_IREAD
# define S_IRUSR S_IREAD
# else
# define S_IRUSR 00400
# endif
#endif
#ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */
#define mode_t unsigned short
#if !S_IWUSR
# if S_IWRITE
# define S_IWUSR S_IWRITE
# else
# define S_IWUSR 00200
# endif
#endif
#if !S_IXUSR
# if S_IEXEC
# define S_IXUSR S_IEXEC
# else
# define S_IXUSR 00100
# endif
#endif
#ifdef STAT_MACROS_BROKEN
#undef S_ISBLK
#undef S_ISCHR
#undef S_ISDIR
#undef S_ISFIFO
#undef S_ISLNK
#undef S_ISMPB
#undef S_ISMPC
#undef S_ISNWK
#undef S_ISREG
#undef S_ISSOCK
#endif /* STAT_MACROS_BROKEN. */
#if !defined(S_ISBLK) && defined(S_IFBLK)
#define S_ISBLK(m) (((m) & S_IFMT) == 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)
#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)
#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)
#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)
#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)
#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)
#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)
@@ -111,7 +145,7 @@ mode_string (mode, str)
unsigned short mode;
char *str;
{
str[0] = ftypelet (mode);
str[0] = ftypelet ((long) mode);
rwx ((mode & 0700) << 0, &str[1]);
rwx ((mode & 0070) << 3, &str[4]);
rwx ((mode & 0007) << 6, &str[7]);
@@ -132,7 +166,7 @@ mode_string (mode, str)
static char
ftypelet (bits)
mode_t bits;
long bits;
{
#ifdef S_ISBLK
if (S_ISBLK (bits))
@@ -175,9 +209,9 @@ rwx (bits, chars)
unsigned short bits;
char *chars;
{
chars[0] = (bits & S_IREAD) ? 'r' : '-';
chars[1] = (bits & S_IWRITE) ? 'w' : '-';
chars[2] = (bits & S_IEXEC) ? 'x' : '-';
chars[0] = (bits & S_IRUSR) ? 'r' : '-';
chars[1] = (bits & S_IWUSR) ? 'w' : '-';
chars[2] = (bits & S_IXUSR) ? 'x' : '-';
}
/* Set the 's' and 't' flags in file attributes string CHARS,

View File

@@ -1,19 +1,21 @@
/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
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 library is distributed in the hope that it will be useful,
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
Library General Public License for more details.
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 Library General Public
License along with this library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -35,7 +37,7 @@ Cambridge, MA 02139, USA. */
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
#ifndef errno
extern int errno;
#endif

View File

@@ -16,66 +16,64 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#if defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I will use ./config.h rather than /config.h
(which it would do because it found this file in ). */
#include <config.h>
#else
#include "config.h"
#endif
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include "fsusage.h"
int statfs ();
#if defined (STATFS_OSF1) /* DEC Alpha running OSF/1 */
# include <sys/mount.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if defined(STAT_STATFS2_BSIZE) && !defined(_IBMR2) /* 4.3BSD, SunOS 4, HP-UX, AIX PS/2. */
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#ifdef STAT_STATFS2_FSIZE /* 4.4BSD. */
#include <sys/mount.h>
#if defined(HAVE_SYS_FILSYS_H) && !defined(_CRAY)
#include <sys/filsys.h> /* SVR2. */
#endif
#ifdef STAT_STATFS2_FS_DATA /* Ultrix. */
#include <sys/param.h>
#include <sys/mount.h>
#endif
#ifdef STAT_READ /* SVR2. */
#include <sys/param.h>
#include <sys/filsys.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#if defined(STAT_STATFS4) || (defined(_AIX) && defined(_IBMR2)) /* SVR3, Dynix, Irix, AIX RS6000. */
#ifdef HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif
#if defined(_AIX) && defined(_I386) /* AIX PS/2. */
#include <sys/stat.h>
#ifdef HAVE_DUSTAT_H /* AIX PS/2. */
#include <sys/dustat.h>
#endif
#ifdef STAT_STATVFS /* SVR4. */
#ifdef HAVE_SYS_STATVFS_H /* SVR4. */
#include <sys/statvfs.h>
int statvfs ();
#endif
int safe_read ();
/* Return the number of TOSIZE-byte blocks used by
BLOCKS FROMSIZE-byte blocks, rounding away from zero. */
BLOCKS FROMSIZE-byte blocks, rounding away from zero.
TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */
static long
adjust_blocks (blocks, fromsize, tosize)
long blocks;
int fromsize, tosize;
{
if (tosize <= 0)
abort ();
if (fromsize <= 0)
return -1;
if (fromsize == tosize) /* E.g., from 512 to 512. */
return blocks;
else if (fromsize > tosize) /* E.g., from 2048 to 512. */
@@ -92,31 +90,32 @@ adjust_blocks (blocks, fromsize, tosize)
int
get_fs_usage (path, disk, fsp)
char *path, *disk;
const char *path;
const char *disk;
struct fs_usage *fsp;
{
#if defined (STATFS_OSF1)
#if defined (STAT_STATFS3_OSF1)
struct statfs fsd;
if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
return (-1);
#define convert_blocks(b) adjust_blocks ((b),fsd.f_fsize, 512)
#endif /* STATFS_OSF1 */
return -1;
#define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_fsize, 512)
#endif /* STAT_STATFS3_OSF1 */
#ifdef STAT_STATFS2_FS_DATA /* Ultrix. */
struct fs_data fsd;
if (statfs (path, &fsd) != 1)
return -1;
#define convert_blocks(b) adjust_blocks ((b), 1024, 512)
fsp->fsu_blocks = convert_blocks (fsd.fd_req.btot);
fsp->fsu_bfree = convert_blocks (fsd.fd_req.bfree);
fsp->fsu_bavail = convert_blocks (fsd.fd_req.bfreen);
#define CONVERT_BLOCKS(b) adjust_blocks ((b), 1024, 512)
fsp->fsu_blocks = CONVERT_BLOCKS (fsd.fd_req.btot);
fsp->fsu_bfree = CONVERT_BLOCKS (fsd.fd_req.bfree);
fsp->fsu_bavail = CONVERT_BLOCKS (fsd.fd_req.bfreen);
fsp->fsu_files = fsd.fd_req.gtot;
fsp->fsu_ffree = fsd.fd_req.gfree;
#endif
#ifdef STAT_READ /* SVR2. */
#ifdef STAT_READ_FILSYS /* SVR2. */
#ifndef SUPERBOFF
#define SUPERBOFF (SUPERB * 512)
#endif
@@ -127,16 +126,16 @@ get_fs_usage (path, disk, fsp)
if (fd < 0)
return -1;
lseek (fd, (long) SUPERBOFF, 0);
if (read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
if (safe_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
{
close (fd);
return -1;
}
close (fd);
#define convert_blocks(b) adjust_blocks ((b), (fsd.s_type == Fs2b ? 1024 : 512), 512)
fsp->fsu_blocks = convert_blocks (fsd.s_fsize);
fsp->fsu_bfree = convert_blocks (fsd.s_tfree);
fsp->fsu_bavail = convert_blocks (fsd.s_tfree);
#define CONVERT_BLOCKS(b) adjust_blocks ((b), (fsd.s_type == Fs2b ? 1024 : 512), 512)
fsp->fsu_blocks = CONVERT_BLOCKS (fsd.s_fsize);
fsp->fsu_bfree = CONVERT_BLOCKS (fsd.s_tfree);
fsp->fsu_bavail = CONVERT_BLOCKS (fsd.s_tfree);
fsp->fsu_files = (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1);
fsp->fsu_ffree = fsd.s_tinode;
#endif
@@ -146,7 +145,22 @@ get_fs_usage (path, disk, fsp)
if (statfs (path, &fsd) < 0)
return -1;
#define convert_blocks(b) adjust_blocks ((b), fsd.f_bsize, 512)
#ifdef STATFS_TRUNCATES_BLOCK_COUNTS
/* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the
struct statfs are truncated to 2GB. These conditions detect that
truncation, presumably without botching the 4.1.1 case, in which
the values are not truncated. The correct counts are stored in
undocumented spare fields. */
if (fsd.f_blocks == 0x1fffff && fsd.f_spare[0] > 0)
{
fsd.f_blocks = fsd.f_spare[0];
fsd.f_bfree = fsd.f_spare[1];
fsd.f_bavail = fsd.f_spare[2];
}
#endif /* STATFS_TRUNCATES_BLOCK_COUNTS */
#define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_bsize, 512)
#endif
#ifdef STAT_STATFS2_FSIZE /* 4.4BSD. */
@@ -154,10 +168,10 @@ get_fs_usage (path, disk, fsp)
if (statfs (path, &fsd) < 0)
return -1;
#define convert_blocks(b) adjust_blocks ((b), fsd.f_fsize, 512)
#define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_fsize, 512)
#endif
#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix. */
#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX. */
struct statfs fsd;
if (statfs (path, &fsd, sizeof fsd, 0) < 0)
@@ -165,12 +179,16 @@ get_fs_usage (path, disk, fsp)
/* Empirically, the block counts on most SVR3 and SVR3-derived
systems seem to always be in terms of 512-byte blocks,
no matter what value f_bsize has. */
#define convert_blocks(b) (b)
#ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx. */
#ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */
#define f_bavail f_bfree
#endif
#endif
# if _AIX
# define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_bsize, 512)
# else
# define CONVERT_BLOCKS(b) (b)
# ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx. */
# ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */
# define f_bavail f_bfree
# endif
# endif
# endif
#endif
#ifdef STAT_STATVFS /* SVR4. */
@@ -179,14 +197,14 @@ get_fs_usage (path, disk, fsp)
if (statvfs (path, &fsd) < 0)
return -1;
/* f_frsize isn't guaranteed to be supported. */
#define convert_blocks(b) \
#define CONVERT_BLOCKS(b) \
adjust_blocks ((b), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512)
#endif
#if !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ) /* !Ultrix && !SVR2. */
fsp->fsu_blocks = convert_blocks (fsd.f_blocks);
fsp->fsu_bfree = convert_blocks (fsd.f_bfree);
fsp->fsu_bavail = convert_blocks (fsd.f_bavail);
#if !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS) /* !Ultrix && !SVR2. */
fsp->fsu_blocks = CONVERT_BLOCKS (fsd.f_blocks);
fsp->fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree);
fsp->fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail);
fsp->fsu_files = fsd.f_files;
fsp->fsu_ffree = fsd.f_ffree;
#endif

View File

@@ -25,8 +25,13 @@ struct fs_usage
long fsu_ffree; /* Free file nodes. */
};
#if __STDC__
int get_fs_usage (char *path, char *disk, struct fs_usage *fsp);
#ifndef __P
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
#define __P(args) args
#else
int get_fs_usage ();
#endif
#define __P(args) ()
#endif /* GCC. */
#endif /* Not __P. */
int get_fs_usage __P ((const char *path, const char *disk,
struct fs_usage *fsp));

View File

@@ -1,10 +1,15 @@
/* ftruncate emulations that work on some System V's.
This file is in the public domain. */
This file is in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
#ifdef F_CHSIZE
int
ftruncate (fd, length)
int fd;
@@ -12,14 +17,17 @@ ftruncate (fd, length)
{
return fcntl (fd, F_CHSIZE, length);
}
#else
#else /* not F_CHSIZE */
#ifdef F_FREESP
/* The following function was written by
kucharsk@Solbourne.com (William Kucharski) */
/* By William Kucharski <kucharsk@netcom.com>. */
#include <sys/stat.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
int
ftruncate (fd, length)
@@ -44,23 +52,28 @@ ftruncate (fd, length)
}
else
{
/* Truncate length. */
fl.l_whence = 0;
fl.l_len = 0;
fl.l_start = length;
fl.l_type = F_WRLCK; /* Write lock on file space. */
fl.l_type = F_WRLCK; /* write lock on file space */
/* This relies on the *undocumented* F_FREESP argument to fcntl,
which truncates the file so that it ends at the position
indicated by fl.l_start. Will minor miracles never cease? */
/* This relies on the UNDOCUMENTED F_FREESP argument to
fcntl, which truncates the file so that it ends at the
position indicated by fl.l_start.
Will minor miracles never cease? */
if (fcntl (fd, F_FREESP, &fl) < 0)
return -1;
}
return 0;
}
#else
#else /* not F_CHSIZE nor F_FREESP */
#ifdef HAVE_CHSIZE
int
ftruncate (fd, length)
int fd;
@@ -68,5 +81,23 @@ ftruncate (fd, length)
{
return chsize (fd, length);
}
#else /* not F_CHSIZE nor F_FREESP nor HAVE_CHSIZE */
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#endif
int
ftruncate (fd, length)
int fd;
off_t length;
{
errno = EIO;
return -1;
}
#endif /* not HAVE_CHSIZE */
#endif /* not F_FREESP */
#endif /* not F_CHSIZE */

64
lib/full-write.c Normal file
View File

@@ -0,0 +1,64 @@
/* full-write.c -- an interface to write that retries after interrupts
Copyright (C) 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
Copied largely from GNU C's cccp.c.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
#ifndef errno
extern int errno;
#endif
/* Write LEN bytes at PTR to descriptor DESC, retrying if interrupted.
Return LEN upon success, write's (negative) error code otherwise. */
int
full_write (desc, ptr, len)
int desc;
char *ptr;
size_t len;
{
int total_written;
total_written = 0;
while (len > 0)
{
int written = write (desc, ptr, len);
if (written < 0)
{
#ifdef EINTR
if (errno == EINTR)
continue;
#endif
return written;
}
total_written += written;
ptr += written;
len -= written;
}
return total_written;
}

File diff suppressed because it is too large Load Diff

155
lib/getline.c Normal file
View File

@@ -0,0 +1,155 @@
/* getline.c -- Replacement for GNU C library function getline
Copyright (C) 1993, 1996 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 of the
License, 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 Jan Brittenson, bson@gnu.ai.mit.edu. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
/* The `getdelim' function is only declared if there following symbol
is defined. */
#define _GNU_SOURCE 1
#include <stdio.h>
#include <sys/types.h>
#if defined __GNU_LIBRARY__ && defined HAVE_GETDELIM
int
getline (lineptr, n, stream)
char **lineptr;
size_t *n;
FILE *stream;
{
return getdelim (lineptr, n, '\n', stream);
}
#else /* ! have getdelim */
#define NDEBUG
#include <assert.h>
#if STDC_HEADERS
# include <stdlib.h>
#else
char *malloc (), *realloc ();
#endif
/* Always add at least this many bytes when extending the buffer. */
#define MIN_CHUNK 64
/* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR
+ OFFSET (and null-terminate it). *LINEPTR is a pointer returned from
malloc (or NULL), pointing to *N characters of space. It is realloc'd
as necessary. Return the number of characters read (not including the
null terminator), or -1 on error or EOF. */
int
getstr (lineptr, n, stream, terminator, offset)
char **lineptr;
size_t *n;
FILE *stream;
char terminator;
size_t offset;
{
int nchars_avail; /* Allocated but unused chars in *LINEPTR. */
char *read_pos; /* Where we're reading into *LINEPTR. */
int ret;
if (!lineptr || !n || !stream)
return -1;
if (!*lineptr)
{
*n = MIN_CHUNK;
*lineptr = malloc (*n);
if (!*lineptr)
return -1;
}
nchars_avail = *n - offset;
read_pos = *lineptr + offset;
for (;;)
{
register int c = getc (stream);
/* We always want at least one char left in the buffer, since we
always (unless we get an error while reading the first char)
NUL-terminate the line buffer. */
assert(*n - nchars_avail == read_pos - *lineptr);
if (nchars_avail < 2)
{
if (*n > MIN_CHUNK)
*n *= 2;
else
*n += MIN_CHUNK;
nchars_avail = *n + *lineptr - read_pos;
*lineptr = realloc (*lineptr, *n);
if (!*lineptr)
return -1;
read_pos = *n - nchars_avail + *lineptr;
assert(*n - nchars_avail == read_pos - *lineptr);
}
if (c == EOF || ferror (stream))
{
/* Return partial line, if any. */
if (read_pos == *lineptr)
return -1;
else
break;
}
*read_pos++ = c;
nchars_avail--;
if (c == terminator)
/* Return the line. */
break;
}
/* Done - NUL terminate and return the number of chars read. */
*read_pos = '\0';
ret = read_pos - (*lineptr + offset);
return ret;
}
int
getline (lineptr, n, stream)
char **lineptr;
size_t *n;
FILE *stream;
{
return getstr (lineptr, n, stream, '\n', 0);
}
int
getdelim (lineptr, n, delimiter, stream)
char **lineptr;
size_t *n;
int delimiter;
FILE *stream;
{
return getstr (lineptr, n, stream, delimiter, 0);
}
#endif

36
lib/getline.h Normal file
View File

@@ -0,0 +1,36 @@
/* Copyright (C) 1995 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 _getline_h_
#define _getline_h_ 1
#include <stdio.h>
#ifndef PARAMS
# if defined (__GNUC__) || __STDC__
# define PARAMS(args) args
# else
# define PARAMS(args) ()
# endif /* GCC. */
#endif /* Not PARAMS. */
int
getline PARAMS ((char **_lineptr, size_t *_n, FILE *_stream));
int
getdelim PARAMS ((char **_lineptr, size_t *_n, int _delimiter, FILE *_stream));
#endif

967
lib/getloadavg.c Normal file
View File

@@ -0,0 +1,967 @@
/* Get the system load averages.
Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995
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. */
/* Compile-time symbols that this file uses:
FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
KERNEL_FILE Pathname of the kernel to nlist.
LDAV_CVT() Scale the load average from the kernel.
Returns a double.
LDAV_SYMBOL Name of kernel symbol giving load average.
LOAD_AVE_TYPE Type of the load average array in the kernel.
Must be defined unless one of
apollo, DGUX, NeXT, or UMAX is defined;
otherwise, no load average is available.
NLIST_STRUCT Include nlist.h, not a.out.h, and
the nlist n_name element is a pointer,
not an array.
NLIST_NAME_UNION struct nlist has an n_un member, not n_name.
LINUX_LDAV_FILE [__linux__]: File containing load averages.
Specific system predefines this file uses, aside from setting
default values if not emacs:
apollo
BSD Real BSD, not just BSD-like.
convex
DGUX
eunice UNIX emulator under VMS.
hpux
NeXT
sgi
sequent Sequent Dynix 3.x.x (BSD)
_SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV)
sony_news NEWS-OS (works at least for 4.1C)
UMAX
UMAX4_3
VMS
__linux__ Linux: assumes /proc filesystem mounted.
Support from Michael K. Johnson.
__NetBSD__ NetBSD: assumes /kern filesystem mounted.
In addition, to avoid nesting many #ifdefs, we internally set
LDAV_DONE to indicate that the load average has been computed.
We also #define LDAV_PRIVILEGED if a program will require
special installation to be able to call getloadavg. */
/* This should always be first. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
/* Both the Emacs and non-Emacs sections want this. Some
configuration files' definitions for the LOAD_AVE_CVT macro (like
sparc.h's) use macros like FSCALE, defined here. */
#ifdef unix
#include <sys/param.h>
#endif
/* Exclude all the code except the test program at the end
if the system has its own `getloadavg' function.
The declaration of `errno' is needed by the test program
as well as the function itself, so it comes first. */
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#ifndef HAVE_GETLOADAVG
/* The existing Emacs configuration files define a macro called
LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and
returns the load average multiplied by 100. What we actually want
is a macro called LDAV_CVT, which returns the load average as an
unmultiplied double.
For backwards compatibility, we'll define LDAV_CVT in terms of
LOAD_AVE_CVT, but future machine config files should just define
LDAV_CVT directly. */
#if !defined(LDAV_CVT) && defined(LOAD_AVE_CVT)
#define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0)
#endif
#if !defined (BSD) && defined (ultrix)
/* Ultrix behaves like BSD on Vaxen. */
#define BSD
#endif
#ifdef NeXT
/* NeXT in the 2.{0,1,2} releases defines BSD in <sys/param.h>, which
conflicts with the definition understood in this file, that this
really is BSD. */
#undef BSD
/* NeXT defines FSCALE in <sys/param.h>. However, we take FSCALE being
defined to mean that the nlist method should be used, which is not true. */
#undef FSCALE
#endif
/* Set values that are different from the defaults, which are
set a little farther down with #ifndef. */
/* Some shorthands. */
#if defined (HPUX) && !defined (hpux)
#define hpux
#endif
#if defined(hp300) && !defined(hpux)
#define MORE_BSD
#endif
#if defined(ultrix) && defined(mips)
#define decstation
#endif
#if (defined(sun) || defined(__sun)) && defined(SVR4)
#define SUNOS_5
#endif
#if defined (__osf__) && (defined (__alpha) || defined (__alpha__))
#define OSF_ALPHA
#include <sys/table.h>
#endif
#if defined (__osf__) && (defined (mips) || defined (__mips__))
#define OSF_MIPS
#include <sys/table.h>
#endif
/* UTek's /bin/cc on the 4300 has no architecture specific cpp define by
default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>. Combine
that with a couple of other things and we'll have a unique match. */
#if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES)
#define tek4300 /* Define by emacs, but not by other users. */
#endif
/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */
#ifndef LOAD_AVE_TYPE
#ifdef MORE_BSD
#define LOAD_AVE_TYPE long
#endif
#if defined(sun) || defined(__sun)
#define LOAD_AVE_TYPE long
#endif
#ifdef decstation
#define LOAD_AVE_TYPE long
#endif
#ifdef _SEQUENT_
#define LOAD_AVE_TYPE long
#endif
#ifdef sgi
#define LOAD_AVE_TYPE long
#endif
#ifdef SVR4
#define LOAD_AVE_TYPE long
#endif
#ifdef sony_news
#define LOAD_AVE_TYPE long
#endif
#ifdef sequent
#define LOAD_AVE_TYPE long
#endif
#ifdef OSF_ALPHA
#define LOAD_AVE_TYPE long
#endif
#if defined (ardent) && defined (titan)
#define LOAD_AVE_TYPE long
#endif
#ifdef tek4300
#define LOAD_AVE_TYPE long
#endif
#if defined(alliant) && defined(i860) /* Alliant FX/2800 */
#define LOAD_AVE_TYPE long
#endif
#ifdef _AIX
#define LOAD_AVE_TYPE long
#endif
#ifdef convex
#define LOAD_AVE_TYPE double
#ifndef LDAV_CVT
#define LDAV_CVT(n) (n)
#endif
#endif
#endif /* No LOAD_AVE_TYPE. */
#ifdef OSF_ALPHA
/* <sys/param.h> defines an incorrect value for FSCALE on Alpha OSF/1,
according to ghazi@noc.rutgers.edu. */
#undef FSCALE
#define FSCALE 1024.0
#endif
#if defined(alliant) && defined(i860) /* Alliant FX/2800 */
/* <sys/param.h> defines an incorrect value for FSCALE on an
Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */
#undef FSCALE
#define FSCALE 100.0
#endif
#ifndef FSCALE
/* SunOS and some others define FSCALE in sys/param.h. */
#ifdef MORE_BSD
#define FSCALE 2048.0
#endif
#if defined(MIPS) || defined(SVR4) || defined(decstation)
#define FSCALE 256
#endif
#if defined (sgi) || defined (sequent)
/* Sometimes both MIPS and sgi are defined, so FSCALE was just defined
above under #ifdef MIPS. But we want the sgi value. */
#undef FSCALE
#define FSCALE 1000.0
#endif
#if defined (ardent) && defined (titan)
#define FSCALE 65536.0
#endif
#ifdef tek4300
#define FSCALE 100.0
#endif
#ifdef _AIX
#define FSCALE 65536.0
#endif
#endif /* Not FSCALE. */
#if !defined (LDAV_CVT) && defined (FSCALE)
#define LDAV_CVT(n) (((double) (n)) / FSCALE)
#endif
/* VAX C can't handle multi-line #ifs, or lines longer that 256 characters. */
#ifndef NLIST_STRUCT
#ifdef MORE_BSD
#define NLIST_STRUCT
#endif
#if defined(sun) || defined(__sun)
#define NLIST_STRUCT
#endif
#ifdef decstation
#define NLIST_STRUCT
#endif
#ifdef hpux
#define NLIST_STRUCT
#endif
#if defined (_SEQUENT_) || defined (sequent)
#define NLIST_STRUCT
#endif
#ifdef sgi
#define NLIST_STRUCT
#endif
#ifdef SVR4
#define NLIST_STRUCT
#endif
#ifdef sony_news
#define NLIST_STRUCT
#endif
#ifdef OSF_ALPHA
#define NLIST_STRUCT
#endif
#if defined (ardent) && defined (titan)
#define NLIST_STRUCT
#endif
#ifdef tek4300
#define NLIST_STRUCT
#endif
#ifdef butterfly
#define NLIST_STRUCT
#endif
#if defined(alliant) && defined(i860) /* Alliant FX/2800 */
#define NLIST_STRUCT
#endif
#ifdef _AIX
#define NLIST_STRUCT
#endif
#endif /* defined (NLIST_STRUCT) */
#if defined(sgi) || (defined(mips) && !defined(BSD))
#define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31))
#endif
#if !defined (KERNEL_FILE) && defined (sequent)
#define KERNEL_FILE "/dynix"
#endif
#if !defined (KERNEL_FILE) && defined (hpux)
#define KERNEL_FILE "/hp-ux"
#endif
#if !defined(KERNEL_FILE) && (defined(_SEQUENT_) || defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || defined(SVR4) || (defined (ardent) && defined (titan)))
#define KERNEL_FILE "/unix"
#endif
#if !defined (LDAV_SYMBOL) && defined (alliant)
#define LDAV_SYMBOL "_Loadavg"
#endif
#if !defined(LDAV_SYMBOL) && ((defined(hpux) && !defined(hp9000s300)) || defined(_SEQUENT_) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX))
#define LDAV_SYMBOL "avenrun"
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>
/* LOAD_AVE_TYPE should only get defined if we're going to use the
nlist method. */
#if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL))
#define LOAD_AVE_TYPE double
#endif
#ifdef LOAD_AVE_TYPE
#ifndef VMS
#ifndef NLIST_STRUCT
#include <a.out.h>
#else /* NLIST_STRUCT */
#include <nlist.h>
#endif /* NLIST_STRUCT */
#ifdef SUNOS_5
#include <fcntl.h>
#include <kvm.h>
#endif
#ifndef KERNEL_FILE
#define KERNEL_FILE "/vmunix"
#endif /* KERNEL_FILE */
#ifndef LDAV_SYMBOL
#define LDAV_SYMBOL "_avenrun"
#endif /* LDAV_SYMBOL */
#else /* VMS */
#ifndef eunice
#include <iodef.h>
#include <descrip.h>
#else /* eunice */
#include <vms/iodef.h>
#endif /* eunice */
#endif /* VMS */
#ifndef LDAV_CVT
#define LDAV_CVT(n) ((double) (n))
#endif /* !LDAV_CVT */
#endif /* LOAD_AVE_TYPE */
#ifdef NeXT
#ifdef HAVE_MACH_MACH_H
#include <mach/mach.h>
#else
#include <mach.h>
#endif
#endif /* NeXT */
#ifdef sgi
#include <sys/sysmp.h>
#endif /* sgi */
#ifdef UMAX
#include <stdio.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/syscall.h>
#ifdef UMAX_43
#include <machine/cpu.h>
#include <inq_stats/statistics.h>
#include <inq_stats/sysstats.h>
#include <inq_stats/cpustats.h>
#include <inq_stats/procstats.h>
#else /* Not UMAX_43. */
#include <sys/sysdefs.h>
#include <sys/statistics.h>
#include <sys/sysstats.h>
#include <sys/cpudefs.h>
#include <sys/cpustats.h>
#include <sys/procstats.h>
#endif /* Not UMAX_43. */
#endif /* UMAX */
#ifdef DGUX
#include <sys/dg_sys_info.h>
#endif
#if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
#include <fcntl.h>
#else
#include <sys/file.h>
#endif
/* Avoid static vars inside a function since in HPUX they dump as pure. */
#ifdef NeXT
static processor_set_t default_set;
static int getloadavg_initialized;
#endif /* NeXT */
#ifdef UMAX
static unsigned int cpus = 0;
static unsigned int samples;
#endif /* UMAX */
#ifdef DGUX
static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
#endif /* DGUX */
#ifdef LOAD_AVE_TYPE
/* File descriptor open to /dev/kmem or VMS load ave driver. */
static int channel;
/* Nonzero iff channel is valid. */
static int getloadavg_initialized;
/* Offset in kmem to seek to read load average, or 0 means invalid. */
static long offset;
#if !defined(VMS) && !defined(sgi)
static struct nlist nl[2];
#endif /* Not VMS or sgi */
#ifdef SUNOS_5
static kvm_t *kd;
#endif /* SUNOS_5 */
#endif /* LOAD_AVE_TYPE */
/* Put the 1 minute, 5 minute and 15 minute load averages
into the first NELEM elements of LOADAVG.
Return the number written (never more than 3, but may be less than NELEM),
or -1 if an error occurred. */
int
getloadavg (loadavg, nelem)
double loadavg[];
int nelem;
{
int elem = 0; /* Return value. */
#ifdef NO_GET_LOAD_AVG
#define LDAV_DONE
/* Set errno to zero to indicate that there was no particular error;
this function just can't work at all on this system. */
errno = 0;
elem = -1;
#endif
#if !defined (LDAV_DONE) && defined (__linux__)
#define LDAV_DONE
#undef LOAD_AVE_TYPE
#ifndef LINUX_LDAV_FILE
#define LINUX_LDAV_FILE "/proc/loadavg"
#endif
char ldavgbuf[40];
double load_ave[3];
int fd, count;
fd = open (LINUX_LDAV_FILE, O_RDONLY);
if (fd == -1)
return -1;
count = read (fd, ldavgbuf, 40);
(void) close (fd);
if (count <= 0)
return -1;
count = sscanf (ldavgbuf, "%lf %lf %lf",
&load_ave[0], &load_ave[1], &load_ave[2]);
if (count < 1)
return -1;
for (elem = 0; elem < nelem && elem < count; elem++)
loadavg[elem] = load_ave[elem];
return elem;
#endif /* __linux__ */
#if !defined (LDAV_DONE) && defined (__NetBSD__)
#define LDAV_DONE
#undef LOAD_AVE_TYPE
#ifndef NETBSD_LDAV_FILE
#define NETBSD_LDAV_FILE "/kern/loadavg"
#endif
unsigned long int load_ave[3], scale;
int count;
FILE *fp;
fp = fopen (NETBSD_LDAV_FILE, "r");
if (fp == NULL)
return -1;
count = fscanf (fp, "%lu %lu %lu %lu\n",
&load_ave[0], &load_ave[1], &load_ave[2],
&scale);
(void) fclose (fp);
if (count != 4)
return -1;
for (elem = 0; elem < nelem; elem++)
loadavg[elem] = (double) load_ave[elem] / (double) scale;
return elem;
#endif /* __NetBSD__ */
#if !defined (LDAV_DONE) && defined (NeXT)
#define LDAV_DONE
/* The NeXT code was adapted from iscreen 3.2. */
host_t host;
struct processor_set_basic_info info;
unsigned info_count;
/* We only know how to get the 1-minute average for this system,
so even if the caller asks for more than 1, we only return 1. */
if (!getloadavg_initialized)
{
if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS)
getloadavg_initialized = 1;
}
if (getloadavg_initialized)
{
info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
(processor_set_info_t) &info, &info_count)
!= KERN_SUCCESS)
getloadavg_initialized = 0;
else
{
if (nelem > 0)
loadavg[elem++] = (double) info.load_average / LOAD_SCALE;
}
}
if (!getloadavg_initialized)
return -1;
#endif /* NeXT */
#if !defined (LDAV_DONE) && defined (UMAX)
#define LDAV_DONE
/* UMAX 4.2, which runs on the Encore Multimax multiprocessor, does not
have a /dev/kmem. Information about the workings of the running kernel
can be gathered with inq_stats system calls.
We only know how to get the 1-minute average for this system. */
struct proc_summary proc_sum_data;
struct stat_descr proc_info;
double load;
register unsigned int i, j;
if (cpus == 0)
{
register unsigned int c, i;
struct cpu_config conf;
struct stat_descr desc;
desc.sd_next = 0;
desc.sd_subsys = SUBSYS_CPU;
desc.sd_type = CPUTYPE_CONFIG;
desc.sd_addr = (char *) &conf;
desc.sd_size = sizeof conf;
if (inq_stats (1, &desc))
return -1;
c = 0;
for (i = 0; i < conf.config_maxclass; ++i)
{
struct class_stats stats;
bzero ((char *) &stats, sizeof stats);
desc.sd_type = CPUTYPE_CLASS;
desc.sd_objid = i;
desc.sd_addr = (char *) &stats;
desc.sd_size = sizeof stats;
if (inq_stats (1, &desc))
return -1;
c += stats.class_numcpus;
}
cpus = c;
samples = cpus < 2 ? 3 : (2 * cpus / 3);
}
proc_info.sd_next = 0;
proc_info.sd_subsys = SUBSYS_PROC;
proc_info.sd_type = PROCTYPE_SUMMARY;
proc_info.sd_addr = (char *) &proc_sum_data;
proc_info.sd_size = sizeof (struct proc_summary);
proc_info.sd_sizeused = 0;
if (inq_stats (1, &proc_info) != 0)
return -1;
load = proc_sum_data.ps_nrunnable;
j = 0;
for (i = samples - 1; i > 0; --i)
{
load += proc_sum_data.ps_nrun[j];
if (j++ == PS_NRUNSIZE)
j = 0;
}
if (nelem > 0)
loadavg[elem++] = load / samples / cpus;
#endif /* UMAX */
#if !defined (LDAV_DONE) && defined (DGUX)
#define LDAV_DONE
/* This call can return -1 for an error, but with good args
it's not supposed to fail. The first argument is for no
apparent reason of type `long int *'. */
dg_sys_info ((long int *) &load_info,
DG_SYS_INFO_LOAD_INFO_TYPE,
DG_SYS_INFO_LOAD_VERSION_0);
if (nelem > 0)
loadavg[elem++] = load_info.one_minute;
if (nelem > 1)
loadavg[elem++] = load_info.five_minute;
if (nelem > 2)
loadavg[elem++] = load_info.fifteen_minute;
#endif /* DGUX */
#if !defined (LDAV_DONE) && defined (apollo)
#define LDAV_DONE
/* Apollo code from lisch@mentorg.com (Ray Lischner).
This system call is not documented. The load average is obtained as
three long integers, for the load average over the past minute,
five minutes, and fifteen minutes. Each value is a scaled integer,
with 16 bits of integer part and 16 bits of fraction part.
I'm not sure which operating system first supported this system call,
but I know that SR10.2 supports it. */
extern void proc1_$get_loadav ();
unsigned long load_ave[3];
proc1_$get_loadav (load_ave);
if (nelem > 0)
loadavg[elem++] = load_ave[0] / 65536.0;
if (nelem > 1)
loadavg[elem++] = load_ave[1] / 65536.0;
if (nelem > 2)
loadavg[elem++] = load_ave[2] / 65536.0;
#endif /* apollo */
#if !defined (LDAV_DONE) && defined (OSF_MIPS)
#define LDAV_DONE
struct tbl_loadavg load_ave;
table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave));
loadavg[elem++]
= (load_ave.tl_lscale == 0
? load_ave.tl_avenrun.d[0]
: (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale));
#endif /* OSF_MIPS */
#if !defined (LDAV_DONE) && defined(MSDOS)
#define LDAV_DONE
/* A faithful emulation is going to have to be saved for a rainy day. */
for ( ; elem < nelem; elem++)
{
loadavg[elem] = 0.0;
}
#endif /* MSDOS */
#if !defined (LDAV_DONE) && defined (OSF_ALPHA)
#define LDAV_DONE
struct tbl_loadavg load_ave;
table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave));
for (elem = 0; elem < nelem; elem++)
loadavg[elem]
= (load_ave.tl_lscale == 0
? load_ave.tl_avenrun.d[elem]
: (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
#endif /* OSF_ALPHA */
#if !defined (LDAV_DONE) && defined (VMS)
/* VMS specific code -- read from the Load Ave driver. */
LOAD_AVE_TYPE load_ave[3];
static int getloadavg_initialized = 0;
#ifdef eunice
struct
{
int dsc$w_length;
char *dsc$a_pointer;
} descriptor;
#endif
/* Ensure that there is a channel open to the load ave device. */
if (!getloadavg_initialized)
{
/* Attempt to open the channel. */
#ifdef eunice
descriptor.dsc$w_length = 18;
descriptor.dsc$a_pointer = "$$VMS_LOAD_AVERAGE";
#else
$DESCRIPTOR (descriptor, "LAV0:");
#endif
if (sys$assign (&descriptor, &channel, 0, 0) & 1)
getloadavg_initialized = 1;
}
/* Read the load average vector. */
if (getloadavg_initialized
&& !(sys$qiow (0, channel, IO$_READVBLK, 0, 0, 0,
load_ave, 12, 0, 0, 0, 0) & 1))
{
sys$dassgn (channel);
getloadavg_initialized = 0;
}
if (!getloadavg_initialized)
return -1;
#endif /* VMS */
#if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE) && !defined(VMS)
/* UNIX-specific code -- read the average from /dev/kmem. */
#define LDAV_PRIVILEGED /* This code requires special installation. */
LOAD_AVE_TYPE load_ave[3];
/* Get the address of LDAV_SYMBOL. */
if (offset == 0)
{
#ifndef sgi
#ifndef NLIST_STRUCT
strcpy (nl[0].n_name, LDAV_SYMBOL);
strcpy (nl[1].n_name, "");
#else /* NLIST_STRUCT */
#ifdef NLIST_NAME_UNION
nl[0].n_un.n_name = LDAV_SYMBOL;
nl[1].n_un.n_name = 0;
#else /* not NLIST_NAME_UNION */
nl[0].n_name = LDAV_SYMBOL;
nl[1].n_name = 0;
#endif /* not NLIST_NAME_UNION */
#endif /* NLIST_STRUCT */
#ifndef SUNOS_5
if (
#if !(defined (_AIX) && !defined (ps2))
nlist (KERNEL_FILE, nl)
#else /* _AIX */
knlist (nl, 1, sizeof (nl[0]))
#endif
>= 0)
/* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i. */
{
#ifdef FIXUP_KERNEL_SYMBOL_ADDR
FIXUP_KERNEL_SYMBOL_ADDR (nl);
#endif
offset = nl[0].n_value;
}
#endif /* !SUNOS_5 */
#else /* sgi */
int ldav_off;
ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
if (ldav_off != -1)
offset = (long) ldav_off & 0x7fffffff;
#endif /* sgi */
}
/* Make sure we have /dev/kmem open. */
if (!getloadavg_initialized)
{
#ifndef SUNOS_5
channel = open ("/dev/kmem", 0);
if (channel >= 0)
{
/* Set the channel to close on exec, so it does not
litter any child's descriptor table. */
#ifdef FD_SETFD
#ifndef FD_CLOEXEC
#define FD_CLOEXEC 1
#endif
(void) fcntl (channel, F_SETFD, FD_CLOEXEC);
#endif
getloadavg_initialized = 1;
}
#else /* SUNOS_5 */
/* We pass 0 for the kernel, corefile, and swapfile names
to use the currently running kernel. */
kd = kvm_open (0, 0, 0, O_RDONLY, 0);
if (kd != 0)
{
/* nlist the currently running kernel. */
kvm_nlist (kd, nl);
offset = nl[0].n_value;
getloadavg_initialized = 1;
}
#endif /* SUNOS_5 */
}
/* If we can, get the load average values. */
if (offset && getloadavg_initialized)
{
/* Try to read the load. */
#ifndef SUNOS_5
if (lseek (channel, offset, 0) == -1L
|| read (channel, (char *) load_ave, sizeof (load_ave))
!= sizeof (load_ave))
{
close (channel);
getloadavg_initialized = 0;
}
#else /* SUNOS_5 */
if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
!= sizeof (load_ave))
{
kvm_close (kd);
getloadavg_initialized = 0;
}
#endif /* SUNOS_5 */
}
if (offset == 0 || !getloadavg_initialized)
return -1;
#endif /* LOAD_AVE_TYPE and not VMS */
#if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS. */
if (nelem > 0)
loadavg[elem++] = LDAV_CVT (load_ave[0]);
if (nelem > 1)
loadavg[elem++] = LDAV_CVT (load_ave[1]);
if (nelem > 2)
loadavg[elem++] = LDAV_CVT (load_ave[2]);
#define LDAV_DONE
#endif /* !LDAV_DONE && LOAD_AVE_TYPE */
#ifdef LDAV_DONE
return elem;
#else
/* Set errno to zero to indicate that there was no particular error;
this function just can't work at all on this system. */
errno = 0;
return -1;
#endif
}
#endif /* ! HAVE_GETLOADAVG */
#ifdef TEST
void
main (argc, argv)
int argc;
char **argv;
{
int naptime = 0;
if (argc > 1)
naptime = atoi (argv[1]);
while (1)
{
double avg[3];
int loads;
errno = 0; /* Don't be misled if it doesn't set errno. */
loads = getloadavg (avg, 3);
if (loads == -1)
{
perror ("Error getting load average");
exit (1);
}
if (loads > 0)
printf ("1-minute: %f ", avg[0]);
if (loads > 1)
printf ("5-minute: %f ", avg[1]);
if (loads > 2)
printf ("15-minute: %f ", avg[2]);
if (loads > 0)
putchar ('\n');
if (naptime == 0)
break;
sleep (naptime);
}
exit (0);
}
#endif /* TEST */

View File

@@ -3,7 +3,7 @@
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
before changing it!
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
@@ -20,18 +20,17 @@
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#if defined (emacs) || defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because it found this file in $srcdir). */
#include <config.h>
#else
#include "config.h"
#endif
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
Ditto for AIX 3.2 and <stdlib.h>. */
#ifndef _NO_PROTO
#define _NO_PROTO
#endif
#ifndef __STDC__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#if !defined (__STDC__) || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
@@ -39,11 +38,6 @@
#endif
#endif
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
#ifndef _NO_PROTO
#define _NO_PROTO
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
@@ -65,10 +59,16 @@
#include <stdlib.h>
#endif /* GNU C library. */
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
long-named option. Because this is not POSIX.2 compliant, it is
being phased out. */
/* #define GETOPT_COMPAT */
#ifndef _
/* This is for other GNU distributions with internationalized messages.
When compiling libc, the _ macro is predefined. */
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
# define _(msgid) gettext (msgid)
#else
# define _(msgid) (msgid)
#endif
#endif
/* This version of `getopt' appears to the caller like standard Unix `getopt'
but it behaves differently for the user, since it allows the user
@@ -92,7 +92,7 @@
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
char *optarg = 0;
char *optarg = NULL;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
@@ -162,6 +162,9 @@ static enum
{
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
} ordering;
/* Value of POSIXLY_CORRECT environment variable. */
static char *posixly_correct;
#ifdef __GNU_LIBRARY__
/* We want to avoid inclusion of string.h with non-GNU libraries
@@ -192,19 +195,18 @@ my_index (str, chr)
}
/* If using GCC, we can safely declare strlen this way.
If not using GCC, it is ok not to declare it.
(Supposedly there are some machines where it might get a warning,
but changing this conditional to __STDC__ is too risky.) */
If not using GCC, it is ok not to declare it. */
#ifdef __GNUC__
#ifdef IN_GCC
#include "gstddef.h"
#else
#include <stddef.h>
#endif
extern size_t strlen (const char *);
#endif
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
That was relevant to code that was here before. */
#if !defined (__STDC__) || !__STDC__
/* gcc with -traditional declares the built-in strlen to return int,
and has done so at least since version 2.4.5. -- rms. */
extern int strlen (const char *);
#endif /* not __STDC__ */
#endif /* __GNUC__ */
#endif /* GNU C library. */
#endif /* not __GNU_LIBRARY__ */
/* Handle permutation of arguments. */
@@ -279,6 +281,42 @@ exchange (argv)
first_nonopt += (optind - last_nonopt);
last_nonopt = optind;
}
/* Initialize the internal data when the first call is made. */
static const char *
_getopt_initialize (optstring)
const char *optstring;
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
non-option ARGV-elements is empty. */
first_nonopt = last_nonopt = optind = 1;
nextchar = NULL;
posixly_correct = getenv ("POSIXLY_CORRECT");
/* Determine how to handle the ordering of options and nonoptions. */
if (optstring[0] == '-')
{
ordering = RETURN_IN_ORDER;
++optstring;
}
else if (optstring[0] == '+')
{
ordering = REQUIRE_ORDER;
++optstring;
}
else if (posixly_correct != NULL)
ordering = REQUIRE_ORDER;
else
ordering = PERMUTE;
return optstring;
}
/* Scan elements of ARGV (whose length is ARGC) for option characters
given in OPTSTRING.
@@ -345,41 +383,18 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
int *longind;
int long_only;
{
int option_index;
optarg = 0;
/* Initialize the internal data when the first call is made.
Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
non-option ARGV-elements is empty. */
optarg = NULL;
if (optind == 0)
{
first_nonopt = last_nonopt = optind = 1;
nextchar = NULL;
/* Determine how to handle the ordering of options and nonoptions. */
if (optstring[0] == '-')
{
ordering = RETURN_IN_ORDER;
++optstring;
}
else if (optstring[0] == '+')
{
ordering = REQUIRE_ORDER;
++optstring;
}
else if (getenv ("POSIXLY_CORRECT") != NULL)
ordering = REQUIRE_ORDER;
else
ordering = PERMUTE;
optstring = _getopt_initialize (optstring);
optind = 1; /* Don't scan ARGV[0], the program name. */
}
if (nextchar == NULL || *nextchar == '\0')
{
/* Advance to the next ARGV-element. */
if (ordering == PERMUTE)
{
/* If we have just processed some options following some non-options,
@@ -390,21 +405,16 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else if (last_nonopt != optind)
first_nonopt = optind;
/* Now skip any additional non-options
/* Skip any additional non-options
and extend the range of non-options previously skipped. */
while (optind < argc
&& (argv[optind][0] != '-' || argv[optind][1] == '\0')
#ifdef GETOPT_COMPAT
&& (longopts == NULL
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
#endif /* GETOPT_COMPAT */
)
&& (argv[optind][0] != '-' || argv[optind][1] == '\0'))
optind++;
last_nonopt = optind;
}
/* Special ARGV-element `--' means premature end of options.
/* The special ARGV-element `--' means premature end of options.
Skip it like a null option,
then exchange with previous non-options as if it were an option,
then skip everything else like a non-option. */
@@ -437,12 +447,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
/* If we have come to a non-option and did not permute it,
either stop the scan or describe it to the caller and pass it by. */
if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
#ifdef GETOPT_COMPAT
&& (longopts == NULL
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
#endif /* GETOPT_COMPAT */
)
if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
{
if (ordering == REQUIRE_ORDER)
return EOF;
@@ -451,36 +456,53 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
}
/* We have found another option-ARGV-element.
Start decoding its characters. */
Skip the initial punctuation. */
nextchar = (argv[optind] + 1
+ (longopts != NULL && argv[optind][1] == '-'));
}
/* Decode the current option-ARGV-element. */
/* Check whether the ARGV-element is a long option.
If long_only and the ARGV-element has the form "-f", where f is
a valid short option, don't consider it an abbreviated form of
a long option that starts with f. Otherwise there would be no
way to give the -f short option.
On the other hand, if there's a long option "fubar" and
the ARGV-element is "-fu", do consider that an abbreviation of
the long option, just like "--fu", and not "-f" with arg "u".
This distinction seems to be the most useful approach. */
if (longopts != NULL
&& ((argv[optind][0] == '-'
&& (argv[optind][1] == '-' || long_only))
#ifdef GETOPT_COMPAT
|| argv[optind][0] == '+'
#endif /* GETOPT_COMPAT */
))
&& (argv[optind][1] == '-'
|| (long_only && (argv[optind][2]
|| !my_index (optstring, argv[optind][1])))))
{
char *nameend;
const struct option *p;
char *s = nextchar;
const struct option *pfound = NULL;
int exact = 0;
int ambig = 0;
const struct option *pfound = NULL;
int indfound;
int option_index;
while (*s && *s != '=')
s++;
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
/* Do nothing. */ ;
/* Test all options for either exact match or abbreviated matches. */
for (p = longopts, option_index = 0; p->name;
p++, option_index++)
if (!strncmp (p->name, nextchar, s - nextchar))
#ifdef lint
indfound = 0; /* Avoid spurious compiler warning. */
#endif
/* Test all long options for either exact match
or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, nextchar, nameend - nextchar))
{
if (s - nextchar == strlen (p->name))
if (nameend - nextchar == strlen (p->name))
{
/* Exact match found. */
pfound = p;
@@ -495,14 +517,14 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
indfound = option_index;
}
else
/* Second nonexact match found. */
/* Second or later nonexact match found. */
ambig = 1;
}
if (ambig && !exact)
{
if (opterr)
fprintf (stderr, "%s: option `%s' is ambiguous\n",
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
@@ -513,27 +535,26 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
option_index = indfound;
optind++;
if (*s)
if (*nameend)
{
/* Don't test has_arg with >, because some C compilers don't
allow it to be used on enums. */
if (pfound->has_arg)
optarg = s + 1;
optarg = nameend + 1;
else
{
if (opterr)
{
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
"%s: option `--%s' doesn't allow an argument\n",
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
"%s: option `%c%s' doesn't allow an argument\n",
argv[0], argv[optind - 1][0], pfound->name);
}
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
_("%s: option `--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
_("%s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
nextchar += strlen (nextchar);
return '?';
}
@@ -545,8 +566,9 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else
{
if (opterr)
fprintf (stderr, "%s: option `%s' requires an argument\n",
argv[0], argv[optind - 1]);
fprintf (stderr,
_("%s: option `%s' requires an argument\n"),
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
return optstring[0] == ':' ? ':' : '?';
}
@@ -561,25 +583,23 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
}
return pfound->val;
}
/* Can't find it as a long option. If this is not getopt_long_only,
or the option starts with '--' or is not a valid short
option, then it's an error.
Otherwise interpret it as a short option. */
if (!long_only || argv[optind][1] == '-'
#ifdef GETOPT_COMPAT
|| argv[optind][0] == '+'
#endif /* GETOPT_COMPAT */
|| my_index (optstring, *nextchar) == NULL)
{
if (opterr)
{
if (argv[optind][1] == '-')
/* --option */
fprintf (stderr, "%s: unrecognized option `--%s'\n",
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
argv[0], nextchar);
else
/* +option or -option */
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
argv[0], argv[optind][0], nextchar);
}
nextchar = (char *) "";
@@ -588,7 +608,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
}
}
/* Look at and handle the next option-character. */
/* Look at and handle the next short option-character. */
{
char c = *nextchar++;
@@ -602,16 +622,13 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (opterr)
{
#if 0
if (c < 040 || c >= 0177)
fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
if (posixly_correct)
/* 1003.2 specifies the format of this message. */
fprintf (stderr, _("%s: illegal option -- %c\n"),
argv[0], c);
else
fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
#else
/* 1003.2 specifies the format of this message. */
fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
#endif
fprintf (stderr, _("%s: invalid option -- %c\n"),
argv[0], c);
}
optopt = c;
return '?';
@@ -627,7 +644,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
optind++;
}
else
optarg = 0;
optarg = NULL;
nextchar = NULL;
}
else
@@ -644,14 +661,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (opterr)
{
#if 0
fprintf (stderr, "%s: option `-%c' requires an argument\n",
argv[0], c);
#else
/* 1003.2 specifies the format of this message. */
fprintf (stderr, "%s: option requires an argument -- %c\n",
argv[0], c);
#endif
fprintf (stderr,
_("%s: option requires an argument -- %c\n"),
argv[0], c);
}
optopt = c;
if (optstring[0] == ':')

View File

@@ -1,5 +1,5 @@
/* Declarations for getopt.
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
Copyright (C) 1989, 90, 91, 92, 93, 94 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
@@ -76,7 +76,7 @@ extern int optopt;
struct option
{
#if __STDC__
#if defined (__STDC__) && __STDC__
const char *name;
#else
char *name;
@@ -94,15 +94,15 @@ struct option
#define required_argument 1
#define optional_argument 2
#if __STDC__
#if defined(__GNU_LIBRARY__)
#if defined (__STDC__) && __STDC__
#ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
extern int getopt ();
#endif /* not __GNU_LIBRARY__ */
#endif /* __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only (int argc, char *const *argv,
@@ -120,7 +120,7 @@ extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
#endif /* not __STDC__ */
#endif /* __STDC__ */
#ifdef __cplusplus
}

View File

@@ -1,5 +1,5 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
@@ -17,19 +17,12 @@
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#if defined (emacs) || defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because it found this file in $srcdir). */
#include <config.h>
#else
#include "config.h"
#endif
#endif
#include "getopt.h"
#ifndef __STDC__
#if !defined (__STDC__) || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const

View File

@@ -17,36 +17,25 @@
/* Written by David MacKenzie. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <stdio.h> /* grp.h on alpha OSF1 V2.0 uses "FILE *". */
#include <grp.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/* Even though SunOS 4, Ultrix 4, and 386BSD are mostly POSIX.1 compliant,
their getgroups system call (except in the `System V' environment, which
is troublesome in other ways) fills in an array of int, not gid_t
(which is `short' on those systems). We do the same, for consistency.
Kludge, kludge. */
#ifdef _POSIX_VERSION
#if !defined(sun) && !defined(ultrix) && !defined(__386BSD__)
#define GETGROUPS_T gid_t
#else /* sun or ultrix or 386BSD */
#define GETGROUPS_T int
#endif /* sun or ultrix or 386BSD */
#else /* not _POSIX_VERSION */
#define GETGROUPS_T int
#endif /* not _POSIX_VERSION */
/* setgrent, getgrent, and endgrent are not specified by POSIX.1,
so header files might not declare them.
If you don't have them at all, we can't implement this function.
You lose! */
struct group *getgrent ();
#if defined(USG) || defined(STDC_HEADERS)
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#include <string.h>
#else
#include <strings.h>

View File

@@ -17,6 +17,10 @@
/* Written by David MacKenzie <djm@gnu.ai.mit.edu> */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef SHELLS_FILE
/* File containing a list of nonrestricted shells, one per line. */
#define SHELLS_FILE "/etc/shells"
@@ -32,6 +36,8 @@ char *malloc ();
char *realloc ();
#endif
char *xstrdup ();
static int readname ();
/* List of shells to use if the shells file is missing. */
@@ -54,6 +60,8 @@ static char *line = NULL;
static int line_size = 0;
/* Return an entry from the shells file, ignoring comment lines.
If the file doesn't exist, use the list in DEFAULT_SHELLS (above).
In any case, the returned string is in memory allocated through malloc.
Return NULL if there are no more entries. */
char *
@@ -63,7 +71,7 @@ getusershell ()
{
if (default_shells[default_index])
/* Not at the end of the list yet. */
return default_shells[default_index++];
return xstrdup (default_shells[default_index++]);
return NULL;
}
@@ -74,7 +82,7 @@ getusershell ()
{
/* No shells file. Use the default list. */
default_index = 1;
return default_shells[0];
return xstrdup (default_shells[0]);
}
}

151
lib/group-member.c Normal file
View File

@@ -0,0 +1,151 @@
/* group-member.c -- determine whether group id is in calling user's group list
Copyright (C) 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "group-member.h"
char *xmalloc ();
char *xrealloc ();
struct group_info
{
int n_groups;
GETGROUPS_T *group;
};
#ifdef HAVE_GETGROUPS
static void
free_group_info (g)
struct group_info *g;
{
free (g->group);
free (g);
}
static struct group_info *
get_group_info ()
{
int n_groups;
int n_group_slots;
struct group_info *gi;
GETGROUPS_T *group;
/* getgroups () returns the number of elements that it was able to
place into the array. We simply continue to call getgroups ()
until the number of elements placed into the array is smaller than
the physical size of the array. */
group = NULL;
n_groups = 0;
n_group_slots = 0;
while (n_groups == n_group_slots)
{
n_group_slots += 64;
group = (GETGROUPS_T *) xrealloc (group,
n_group_slots * sizeof (GETGROUPS_T));
n_groups = getgroups (n_group_slots, group);
}
/* In case of error, the user loses. */
if (n_groups < 0)
{
free (group);
return NULL;
}
gi = (struct group_info *) xmalloc (sizeof (*gi));
gi->n_groups = n_groups;
gi->group = group;
return gi;
}
#endif /* not HAVE_GETGROUPS */
/* Return non-zero if GID is one that we have in our groups list.
If there is no getgroups function, return non-zero if GID matches
either of the current or effective group IDs. */
int
group_member (gid)
gid_t gid;
{
#ifndef HAVE_GETGROUPS
return ((gid == getgid ()) || (gid == getegid ()));
#else
int i;
int found;
struct group_info *gi;
gi = get_group_info ();
if (gi == NULL)
return 0;
/* Search through the list looking for GID. */
found = 0;
for (i = 0; i < gi->n_groups; i++)
{
if (gid == gi->group[i])
{
found = 1;
break;
}
}
free_group_info (gi);
return found;
#endif /* HAVE_GETGROUPS */
}
#ifdef TEST
char *program_name;
int
main (int argc, char** argv)
{
int i;
program_name = argv[0];
for (i=1; i<argc; i++)
{
gid_t gid;
gid = atoi (argv[i]);
printf ("%d: %s\n", gid, group_member (gid) ? "yes" : "no");
}
exit (0);
}
#endif /* TEST */

7
lib/group-member.h Normal file
View File

@@ -0,0 +1,7 @@
#ifndef _group_member_h_
#define _group_member_h_ 1
int
group_member ();
#endif /* _group_member_h_ */

View File

@@ -15,11 +15,19 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
#endif /* STAT_MACROS_BROKEN. */
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
/* If PATH is an existing directory or symbolic link to a directory,

View File

@@ -13,7 +13,7 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* A `struct linebuffer' holds a line of text. */
@@ -24,19 +24,20 @@ struct linebuffer
char *buffer;
};
#ifdef __STDC__
#undef __P
#if defined (__STDC__) && __STDC__
#define __P(x) x
#else
#define __P(x) ()
#endif
/* Initialize linebuffer LINEBUFFER for use. */
void initbuffer (struct linebuffer *linebuffer);
void initbuffer __P ((struct linebuffer *linebuffer));
/* Read an arbitrarily long line of text from STREAM into LINEBUFFER.
Remove any newline. Does not null terminate.
Return LINEBUFFER, except at end of file return 0. */
struct linebuffer *readline (struct linebuffer *linebuffer, FILE *stream);
struct linebuffer *readline __P ((struct linebuffer *linebuffer, FILE *stream));
/* Free linebuffer LINEBUFFER and its data, all allocated with malloc. */
void freebuffer (struct linebuffer *);
#else
void initbuffer ();
struct linebuffer *readline ();
void freebuffer ();
#endif
void freebuffer __P ((struct linebuffer *));

79
lib/long-options.c Normal file
View File

@@ -0,0 +1,79 @@
/* Utility to accept --help and --version options as unobtrusively as possible.
Copyright (C) 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Jim Meyering (meyering@comco.com) */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <getopt.h>
#include "long-options.h"
static struct option const long_options[] =
{
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
/* Process long options --help and --version, but only if argc == 2.
Be careful not to gobble up `--'. */
void
parse_long_options (argc, argv, command_name, version_string, usage)
int argc;
char **argv;
const char *command_name;
const char *version_string;
void (*usage)();
{
int c;
int saved_opterr;
int saved_optind;
saved_opterr = opterr;
saved_optind = optind;
/* Don't print an error message for unrecognized options. */
opterr = 0;
if (argc == 2
&& (c = getopt_long (argc, argv, "+", long_options, (int *) 0)) != EOF)
{
switch (c)
{
case 'h':
(*usage) (0);
case 'v':
printf ("%s - %s\n", command_name, version_string);
exit (0);
default:
/* Don't process any other long-named options. */
break;
}
}
/* Restore previous value. */
opterr = saved_opterr;
/* Restore optind in case it has advanced past a leading `--'. */
optind = saved_optind;
}

10
lib/long-options.h Normal file
View File

@@ -0,0 +1,10 @@
#undef __P
#if defined (__STDC__) && __STDC__
#define __P(args) args
#else
#define __P(args) ()
#endif
void
parse_long_options __P ((int _argc, char **_argv, const char *_command_name,
const char *_version_string, void (*_usage) (int)));

View File

@@ -19,14 +19,7 @@
Jim Meyering <meyering@cs.utexas.edu>. */
#ifdef HAVE_CONFIG_H
#if defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I will use ./config.h rather than /config.h
(which it would do because it found this file in ). */
#include <config.h>
#else
#include "config.h"
#endif
#endif
#ifdef __GNUC__
@@ -43,17 +36,6 @@ char *alloca ();
#endif
#endif
#ifdef HAVE_CONFIG_H
#if defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I will use ./config.h rather than /config.h
(which it would do because it found this file in ). */
#include <config.h>
#else
#include "config.h"
#endif
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -61,11 +43,9 @@ char *alloca ();
#include <unistd.h>
#endif
#ifdef STAT_MACROS_BROKEN
#ifdef S_ISDIR
#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
#endif
#endif /* STAT_MACROS_BROKEN. */
#endif /* STAT_MACROS_BROKEN. */
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
@@ -79,17 +59,17 @@ char *alloca ();
#include <errno.h>
#endif
#ifndef STDC_HEADERS
#ifndef errno
extern int errno;
#endif
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#include <string.h>
#ifndef index
#define index strchr
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#else
#include <strings.h>
# include <strings.h>
# ifndef strchr
# define strchr index
# endif
#endif
#ifdef __MSDOS__
@@ -97,38 +77,57 @@ typedef int uid_t;
typedef int gid_t;
#endif
#include "makepath.h"
void error ();
/* Ensure that the directory ARGPATH exists.
Remove any trailing slashes from ARGPATH before calling this function.
Make any leading directories that don't already exist, with
Create any leading directories that don't already exist, with
permissions PARENT_MODE.
If the last element of ARGPATH does not exist, create it as
a new directory with permissions MODE.
If OWNER and GROUP are non-negative, make them the UID and GID of
created directories.
If OWNER and GROUP are non-negative, use them to set the UID and GID of
any created directories.
If VERBOSE_FMT_STRING is nonzero, use it as a printf format
string for printing a message after successfully making a directory,
with the name of the directory that was just made as an argument.
If PRESERVE_EXISTING is non-zero and ARGPATH is an existing directory,
then do not attempt to set its permissions and ownership.
Return 0 if ARGPATH exists as a directory with the proper
ownership and permissions when done, otherwise 1. */
#if __STDC__
int
make_path (argpath, mode, parent_mode, owner, group, verbose_fmt_string)
char *argpath;
make_path (const char *argpath,
int mode,
int parent_mode,
uid_t owner,
gid_t group,
int preserve_existing,
const char *verbose_fmt_string)
#else
int
make_path (argpath, mode, parent_mode, owner, group, preserve_existing,
verbose_fmt_string)
const char *argpath;
int mode;
int parent_mode;
uid_t owner;
gid_t group;
char *verbose_fmt_string;
int preserve_existing;
const char *verbose_fmt_string;
#endif
{
char *dirpath; /* A copy we can scribble NULs on. */
struct stat stats;
int retval = 0;
int oldmask = umask (0);
/* FIXME: move this alloca and strcpy into the if-block.
Set dirpath to argpath in the else-block. */
dirpath = (char *) alloca (strlen (argpath) + 1);
strcpy (dirpath, argpath);
@@ -163,14 +162,14 @@ make_path (argpath, mode, parent_mode, owner, group, verbose_fmt_string)
slash = dirpath;
while (*slash == '/')
slash++;
while ((slash = index (slash, '/')))
while ((slash = strchr (slash, '/')))
{
*slash = '\0';
if (stat (dirpath, &stats))
{
if (mkdir (dirpath, tmp_mode))
{
error (0, errno, "cannot make directory `%s'", dirpath);
error (0, errno, "cannot create directory `%s'", dirpath);
umask (oldmask);
return 1;
}
@@ -215,11 +214,14 @@ make_path (argpath, mode, parent_mode, owner, group, verbose_fmt_string)
}
/* We're done making leading directories.
Make the final component of the path. */
Create the final component of the path. */
if (mkdir (dirpath, mode))
/* The path could end in "/." or contain "/..", so test
if we really have to create the directory. */
if (stat (dirpath, &stats) && mkdir (dirpath, mode))
{
error (0, errno, "cannot make directory `%s'", dirpath);
error (0, errno, "cannot create directory `%s'", dirpath);
umask (oldmask);
return 1;
}
@@ -269,26 +271,29 @@ make_path (argpath, mode, parent_mode, owner, group, verbose_fmt_string)
return 1;
}
/* chown must precede chmod because on some systems,
chown clears the set[ug]id bits for non-superusers,
resulting in incorrect permissions.
On System V, users can give away files with chown and then not
be able to chmod them. So don't give files away. */
if (!preserve_existing)
{
/* chown must precede chmod because on some systems,
chown clears the set[ug]id bits for non-superusers,
resulting in incorrect permissions.
On System V, users can give away files with chown and then not
be able to chmod them. So don't give files away. */
if (owner != (uid_t) -1 && group != (gid_t) -1
&& chown (dirpath, owner, group)
if (owner != (uid_t) -1 && group != (gid_t) -1
&& chown (dirpath, owner, group)
#ifdef AFS
&& errno != EPERM
&& errno != EPERM
#endif
)
{
error (0, errno, "%s", dirpath);
retval = 1;
}
if (chmod (dirpath, mode))
{
error (0, errno, "%s", dirpath);
retval = 1;
)
{
error (0, errno, "%s", dirpath);
retval = 1;
}
if (chmod (dirpath, mode))
{
error (0, errno, "%s", dirpath);
retval = 1;
}
}
}

15
lib/makepath.h Normal file
View File

@@ -0,0 +1,15 @@
#if __STDC__
#undef __P
#define __P(args) args
#else
#define __P(args) ()
#endif
int
make_path __P ((const char *_argpath,
int _mode,
int _parent_mode,
uid_t _owner,
gid_t _group,
int _preserve_existing,
const char *_verbose_fmt_string));

366
lib/md5.c Normal file
View File

@@ -0,0 +1,366 @@
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
according to the definition of MD5 in RFC 1321 from April 1992.
Copyright (C) 1995 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#include "md5.h"
#ifdef WORDS_BIGENDIAN
# define SWAP(n) \
(((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
#else
# define SWAP(n) (n)
#endif
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
void
md5_init_ctx (ctx)
struct md5_ctx *ctx;
{
ctx->A = 0x67452301;
ctx->B = 0xefcdab89;
ctx->C = 0x98badcfe;
ctx->D = 0x10325476;
}
/* Put result from CTX in first 16 bytes following RESBUF. The result must
be in little endian byte order. */
void *
md5_read_ctx (ctx, resbuf)
const struct md5_ctx *ctx;
void *resbuf;
{
((md5_uint32 *) resbuf)[0] = SWAP (ctx->A);
((md5_uint32 *) resbuf)[1] = SWAP (ctx->B);
((md5_uint32 *) resbuf)[2] = SWAP (ctx->C);
((md5_uint32 *) resbuf)[3] = SWAP (ctx->D);
return resbuf;
}
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
int
md5_stream (stream, resblock)
FILE *stream;
void *resblock;
{
/* Important: BLOCKSIZE must be a multiple of 64. */
#define BLOCKSIZE 4096
struct md5_ctx ctx;
md5_uint32 len[2];
char buffer[BLOCKSIZE + 72];
size_t pad, sum;
/* Initialize the computation context. */
md5_init_ctx (&ctx);
len[0] = 0;
len[1] = 0;
/* Iterate over full file contents. */
while (1)
{
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
computation function processes the whole buffer so that with the
next round of the loop another block can be read. */
size_t n;
sum = 0;
/* Read block. Take care for partial reads. */
do
{
n = fread (buffer, 1, BLOCKSIZE - sum, stream);
sum += n;
}
while (sum < BLOCKSIZE && n != 0);
if (n == 0 && ferror (stream))
return 1;
/* RFC 1321 specifies the possible length of the file up to 2^64 bits.
Here we only compute the number of bytes. Do a double word
increment. */
len[0] += sum;
if (len[0] < sum)
++len[1];
/* If end of file is reached, end the loop. */
if (n == 0)
break;
/* Process buffer with BLOCKSIZE bytes. Note that
BLOCKSIZE % 64 == 0
*/
md5_process_block (buffer, BLOCKSIZE, &ctx);
}
/* We can copy 64 byte because the buffer is always big enough. FILLBUF
contains the needed bits. */
memcpy (&buffer[sum], fillbuf, 64);
/* Compute amount of padding bytes needed. Alignment is done to
(N + PAD) % 64 == 56
There is always at least one byte padded. I.e. even the alignment
is correctly aligned 64 padding bytes are added. */
pad = sum & 63;
pad = pad >= 56 ? 64 + 56 - pad : 56 - pad;
/* Put the 64-bit file length in *bits* at the end of the buffer. */
*(md5_uint32 *) &buffer[sum + pad] = SWAP (len[0] << 3);
*(md5_uint32 *) &buffer[sum + pad + 4] = SWAP ((len[1] << 3)
| (len[0] >> 29));
/* Process last bytes. */
md5_process_block (buffer, sum + pad + 8, &ctx);
/* Construct result in desired memory. */
md5_read_ctx (&ctx, resblock);
return 0;
}
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
void *
md5_buffer (buffer, len, resblock)
const char *buffer;
size_t len;
void *resblock;
{
struct md5_ctx ctx;
char restbuf[64 + 72];
size_t blocks = len & ~63;
size_t pad, rest;
/* Initialize the computation context. */
md5_init_ctx (&ctx);
/* Process whole buffer but last len % 64 bytes. */
md5_process_block (buffer, blocks, &ctx);
/* REST bytes are not processed yet. */
rest = len - blocks;
/* Copy to own buffer. */
memcpy (restbuf, &buffer[blocks], rest);
/* Append needed fill bytes at end of buffer. We can copy 64 byte
because the buffer is always big enough. */
memcpy (&restbuf[rest], fillbuf, 64);
/* PAD bytes are used for padding to correct alignment. Note that
always at least one byte is padded. */
pad = rest >= 56 ? 64 + 56 - rest : 56 - rest;
/* Put length of buffer in *bits* in last eight bytes. */
*(md5_uint32 *) &restbuf[rest + pad] = (md5_uint32) SWAP (len << 3);
*(md5_uint32 *) &restbuf[rest + pad + 4] = (md5_uint32) SWAP (len >> 29);
/* Process last bytes. */
md5_process_block (restbuf, rest + pad + 8, &ctx);
/* Put result in desired memory area. */
return md5_read_ctx (&ctx, resblock);
}
/* These are the four functions used in the four steps of the MD5 algorithm
and defined in the RFC 1321. The first function is a little bit optimized
(as found in Colin Plumbs public domain implementation). */
/* #define FF(b, c, d) ((b & c) | (~b & d)) */
#define FF(b, c, d) (d ^ (b & (c ^ d)))
#define FG(b, c, d) FF (d, b, c)
#define FH(b, c, d) (b ^ c ^ d)
#define FI(b, c, d) (c ^ (b | ~d))
/* Process LEN bytes of BUFFER, accumulating context into CTX.
It is assumed that LEN % 64 == 0. */
void
md5_process_block (buffer, len, ctx)
const void *buffer;
size_t len;
struct md5_ctx *ctx;
{
md5_uint32 correct_words[16];
const md5_uint32 *words = buffer;
size_t nwords = len / sizeof (md5_uint32);
const md5_uint32 *endp = words + nwords;
md5_uint32 A = ctx->A;
md5_uint32 B = ctx->B;
md5_uint32 C = ctx->C;
md5_uint32 D = ctx->D;
/* Process all bytes in the buffer with 64 bytes in each round of
the loop. */
while (words < endp)
{
md5_uint32 *cwp = correct_words;
md5_uint32 A_save = A;
md5_uint32 B_save = B;
md5_uint32 C_save = C;
md5_uint32 D_save = D;
/* First round: using the given function, the context and a constant
the next context is computed. Because the algorithms processing
unit is a 32-bit word and it is determined to work on words in
little endian byte order we perhaps have to change the byte order
before the computation. To reduce the work for the next steps
we store the swapped words in the array CORRECT_WORDS. */
#define OP(a, b, c, d, s, T) \
do \
{ \
a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \
++words; \
CYCLIC (a, s); \
a += b; \
} \
while (0)
/* It is unfortunate that C does not provide an operator for
cyclic rotation. Hope the C compiler is smart enough. */
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
/* Before we start, one word to the strange constants.
They are defined in RFC 1321 as
T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
*/
/* Round 1. */
OP (A, B, C, D, 7, 0xd76aa478);
OP (D, A, B, C, 12, 0xe8c7b756);
OP (C, D, A, B, 17, 0x242070db);
OP (B, C, D, A, 22, 0xc1bdceee);
OP (A, B, C, D, 7, 0xf57c0faf);
OP (D, A, B, C, 12, 0x4787c62a);
OP (C, D, A, B, 17, 0xa8304613);
OP (B, C, D, A, 22, 0xfd469501);
OP (A, B, C, D, 7, 0x698098d8);
OP (D, A, B, C, 12, 0x8b44f7af);
OP (C, D, A, B, 17, 0xffff5bb1);
OP (B, C, D, A, 22, 0x895cd7be);
OP (A, B, C, D, 7, 0x6b901122);
OP (D, A, B, C, 12, 0xfd987193);
OP (C, D, A, B, 17, 0xa679438e);
OP (B, C, D, A, 22, 0x49b40821);
/* For the second to fourth round we have the possibly swapped words
in CORRECT_WORDS. Redefine the macro to take an additional first
argument specifying the function to use. */
#undef OP
#define OP(f, a, b, c, d, k, s, T) \
do \
{ \
a += f (b, c, d) + correct_words[k] + T; \
CYCLIC (a, s); \
a += b; \
} \
while (0)
/* Round 2. */
OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
OP (FG, D, A, B, C, 6, 9, 0xc040b340);
OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
OP (FG, D, A, B, C, 10, 9, 0x02441453);
OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
/* Round 3. */
OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
OP (FH, D, A, B, C, 8, 11, 0x8771f681);
OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
OP (FH, B, C, D, A, 6, 23, 0x04881d05);
OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
/* Round 4. */
OP (FI, A, B, C, D, 0, 6, 0xf4292244);
OP (FI, D, A, B, C, 7, 10, 0x432aff97);
OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
OP (FI, C, D, A, B, 6, 15, 0xa3014314);
OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
/* Add the starting values of the context. */
A += A_save;
B += B_save;
C += C_save;
D += D_save;
}
/* Put checksum in context given as argument. */
ctx->A = A;
ctx->B = B;
ctx->C = C;
ctx->D = D;
}

115
lib/md5.h Normal file
View File

@@ -0,0 +1,115 @@
/* md5.h - Declaration of functions and data types used for MD5 sum
computing library functions.
Copyright (C) 1995 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 _MD5_H
#define _MD5_H
#include <stdio.h>
#if defined HAVE_LIMITS_H || _LIBC
# include <limits.h>
#endif
/* The following contortions are an attempt to use the C preprocessor
to determine an unsigned integral type that is 32 bits wide. An
alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
doing that would require that the configure script compile and *run*
the resulting executable. Locally running cross-compiled executables
is usually not possible. */
#if defined __STDC__ && __STDC__
# define UINT_MAX_32_BITS 4294967295U
#else
# define UINT_MAX_32_BITS 0xFFFFFFFF
#endif
/* If UINT_MAX isn't defined, assume it's a 32-bit type.
This should be valid for all systems GNU cares about because
that doesn't include 16-bit systems, and only modern systems
(that certainly have <limits.h>) have 64+-bit integral types. */
#ifndef UINT_MAX
# define UINT_MAX UINT_MAX_32_BITS
#endif
#if UINT_MAX == UINT_MAX_32_BITS
typedef unsigned int md5_uint32;
#else
# if USHRT_MAX == UINT_MAX_32_BITS
typedef unsigned short md5_uint32;
# else
# if ULONG_MAX == UINT_MAX_32_BITS
typedef unsigned long md5_uint32;
# else
/* The following line is intended to evoke an error.
Using #error is not portable enough. */
"Cannot determine unsigned 32-bit data type."
# endif
# endif
#endif
#undef __P
#if defined (__STDC__) && __STDC__
#define __P(x) x
#else
#define __P(x) ()
#endif
/* Structure to save state of computation between the single steps. */
struct md5_ctx
{
md5_uint32 A;
md5_uint32 B;
md5_uint32 C;
md5_uint32 D;
};
/*
* The following three functions are build up the low level used in
* the functions `md5_stream' and `md5_buffer'.
*/
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
void md5_init_ctx __P ((struct md5_ctx *ctx));
/* Starting with the result of former calls of this function (or the
initialzation function update the context for the next LEN bytes
starting at BUFFER.
It is necessary that LEN is a multiple of 64!!! */
void md5_process_block __P ((const void *buffer, size_t len,
struct md5_ctx *ctx));
/* Put result from CTX in first 16 bytes following RESBUF. The result is
always in little endian byte order, so that a byte-wise output yields
to the wanted ASCII representation of the message digest. */
void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
int md5_stream __P ((FILE *stream, void *resblock));
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
#endif

61
lib/memcasecmp.c Normal file
View File

@@ -0,0 +1,61 @@
/* Case-insensitive buffer comparator.
Copyright (C) 1996 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Jim Meyering (meyering@na-net.ornl.gov) */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <ctype.h>
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
#define IN_CTYPE_DOMAIN(c) 1
#else
#define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
#if _LIBC || STDC_HEADERS
# define TOLOWER(c) tolower (c)
#else
# define TOLOWER(c) (ISUPPER (c) ? tolower (c) : (c))
#endif
#include "memcasecmp.h"
/* Like memcmp, but ignore differences in case. */
int
memcasecmp (vs1, vs2, n)
const void *vs1;
const void *vs2;
size_t n;
{
unsigned int i;
unsigned char *s1 = (unsigned char *) vs1;
unsigned char *s2 = (unsigned char *) vs2;
for (i = 0; i < n; i++)
{
unsigned char u1 = *s1++;
unsigned char u2 = *s2++;
if (TOLOWER (u1) != TOLOWER (u2))
return TOLOWER (u1) - TOLOWER (u2);
}
return 0;
}

9
lib/memcasecmp.h Normal file
View File

@@ -0,0 +1,9 @@
#undef __P
#if defined (__STDC__) && __STDC__
# define __P(args) args
#else
# define __P(args) ()
#endif
int
memcasecmp __P((const void *vs1, const void *vs2, size_t n));

View File

@@ -1,70 +1,113 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
/* Copyright (C) 1991, 1993 Free Software Foundation, Inc.
Based on strlen implemention by Torbjorn Granlund (tege@sics.se),
with help from Dan Sahlin (dan@sics.se) and
commentary by Jim Blandy (jimb@ai.mit.edu);
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
and implemented by Roland McGrath (roland@ai.mit.edu).
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
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.
The GNU C Library is distributed in the hope that it will be useful,
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
Library General Public License for more details.
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 Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#undef __ptr_t
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
# define __ptr_t void *
#else /* Not C++ or ANSI C. */
# define __ptr_t char *
#endif /* C++ or ANSI C. */
#if defined (_LIBC)
# include <string.h>
#endif
#if defined (HAVE_LIMITS_H) || defined (_LIBC)
# include <limits.h>
#endif
#define LONG_MAX_32_BITS 2147483647
#ifndef LONG_MAX
#define LONG_MAX LONG_MAX_32_BITS
#endif
#include <sys/types.h>
/* Search no more than N bytes of S for C. */
char *
memchr(s, c, n)
unsigned char * s ;
int c ;
unsigned n;
__ptr_t
memchr (s, c, n)
const __ptr_t s;
int c;
size_t n;
{
unsigned char *char_ptr;
unsigned long int *longword_ptr;
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
unsigned long int longword, magic_bits, charmask;
c = (unsigned char) c;
/* Handle the first few characters by reading one character at a time.
Do this until CHAR_PTR is aligned on a 4-byte border. */
for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr & 3) != 0;
Do this until CHAR_PTR is aligned on a longword boundary. */
for (char_ptr = (const unsigned char *) s;
n > 0 && ((unsigned long int) char_ptr
& (sizeof (longword) - 1)) != 0;
--n, ++char_ptr)
if (*char_ptr == c)
return (char *) char_ptr;
return (__ptr_t) char_ptr;
/* All these elucidatory comments refer to 4-byte longwords,
but the theory applies equally well to 8-byte longwords. */
longword_ptr = (unsigned long int *) char_ptr;
/* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
the "holes." Note that there is a hole just to the left of
each byte, with an extra at the end:
bits: 01111110 11111110 11111110 11111111
bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
The 1-bits make sure that carries propagate to the next 0-bit.
The 0-bits provide holes for carries to fall into. */
if (sizeof (longword) != 4 && sizeof (longword) != 8)
abort ();
#if LONG_MAX <= LONG_MAX_32_BITS
magic_bits = 0x7efefeff;
#else
magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff;
#endif
/* Set up a longword, each of whose bytes is C. */
charmask = c | (c << 8);
charmask |= charmask << 16;
#if LONG_MAX > LONG_MAX_32_BITS
charmask |= charmask << 32;
#endif
/* Instead of the traditional loop which tests each character,
we will test a longword at a time. The tricky part is testing
if *any of the four* bytes in the longword in question are zero. */
while (n >= 4)
while (n >= sizeof (longword))
{
/* We tentatively exit the loop if adding MAGIC_BITS to
LONGWORD fails to change any of the hole bits of LONGWORD.
@@ -104,10 +147,10 @@ memchr(s, c, n)
/* Add MAGIC_BITS to LONGWORD. */
if ((((longword + magic_bits)
/* Set those bits that were unchanged by the addition. */
^ ~longword)
/* Look at only the hole bits. If any of the hole bits
are unchanged, most likely one of the bytes was a
zero. */
@@ -116,27 +159,37 @@ memchr(s, c, n)
/* Which of the bytes was C? If none of them were, it was
a misfire; continue the search. */
unsigned char *cp = ( unsigned char *) (longword_ptr - 1);
const unsigned char *cp = (const unsigned char *) (longword_ptr - 1);
if (cp[0] == c)
return (char *) cp;
return (__ptr_t) cp;
if (cp[1] == c)
return (char *) &cp[1];
return (__ptr_t) &cp[1];
if (cp[2] == c)
return (char *) &cp[2];
return (__ptr_t) &cp[2];
if (cp[3] == c)
return (char *) &cp[3];
return (__ptr_t) &cp[3];
#if LONG_MAX > 2147483647
if (cp[4] == c)
return (__ptr_t) &cp[4];
if (cp[5] == c)
return (__ptr_t) &cp[5];
if (cp[6] == c)
return (__ptr_t) &cp[6];
if (cp[7] == c)
return (__ptr_t) &cp[7];
#endif
}
n -= 4;
n -= sizeof (longword);
}
char_ptr = ( unsigned char *) longword_ptr;
char_ptr = (const unsigned char *) longword_ptr;
while (n-- > 0)
{
if (*char_ptr == c)
return (char *) char_ptr;
return (__ptr_t) char_ptr;
else
++char_ptr;
}

366
lib/memcmp.c Normal file
View File

@@ -0,0 +1,366 @@
/* Copyright (C) 1991, 1993 Free Software Foundation, Inc.
Contributed by Torbjorn Granlund (tege@sics.se).
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#undef __ptr_t
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
#define __ptr_t void *
#else /* Not C++ or ANSI C. */
#undef const
#define const
#define __ptr_t char *
#endif /* C++ or ANSI C. */
#if defined (HAVE_STRING_H) || defined (_LIBC)
#include <string.h>
#endif
#ifdef _LIBC
#include <memcopy.h>
#else /* Not in the GNU C library. */
#include <sys/types.h>
/* Type to use for aligned memory operations.
This should normally be the biggest type supported by a single load
and store. Must be an unsigned type. */
#define op_t unsigned long int
#define OPSIZ (sizeof(op_t))
/* Threshold value for when to enter the unrolled loops. */
#define OP_T_THRES 16
/* Type to use for unaligned operations. */
typedef unsigned char byte;
#ifndef WORDS_BIGENDIAN
#define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
#else
#define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2)))
#endif
#endif /* In the GNU C library. */
#ifdef WORDS_BIGENDIAN
#define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1)
#else
#define CMP_LT_OR_GT(a, b) memcmp_bytes ((a), (b))
#endif
/* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */
/* The strategy of this memcmp is:
1. Compare bytes until one of the block pointers is aligned.
2. Compare using memcmp_common_alignment or
memcmp_not_common_alignment, regarding the alignment of the other
block after the initial byte operations. The maximum number of
full words (of type op_t) are compared in this way.
3. Compare the few remaining bytes. */
#ifndef WORDS_BIGENDIAN
/* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine.
A and B are known to be different.
This is needed only on little-endian machines. */
#ifdef __GNUC__
__inline
#endif
static int
memcmp_bytes (a, b)
op_t a, b;
{
long int srcp1 = (long int) &a;
long int srcp2 = (long int) &b;
op_t a0, b0;
do
{
a0 = ((byte *) srcp1)[0];
b0 = ((byte *) srcp2)[0];
srcp1 += 1;
srcp2 += 1;
}
while (a0 == b0);
return a0 - b0;
}
#endif
/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
memory operations on `op_t's. */
#ifdef __GNUC__
__inline
#endif
static int
memcmp_common_alignment (srcp1, srcp2, len)
long int srcp1;
long int srcp2;
size_t len;
{
op_t a0, a1;
op_t b0, b1;
switch (len % 4)
{
case 2:
a0 = ((op_t *) srcp1)[0];
b0 = ((op_t *) srcp2)[0];
srcp1 -= 2 * OPSIZ;
srcp2 -= 2 * OPSIZ;
len += 2;
goto do1;
case 3:
a1 = ((op_t *) srcp1)[0];
b1 = ((op_t *) srcp2)[0];
srcp1 -= OPSIZ;
srcp2 -= OPSIZ;
len += 1;
goto do2;
case 0:
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
return 0;
a0 = ((op_t *) srcp1)[0];
b0 = ((op_t *) srcp2)[0];
goto do3;
case 1:
a1 = ((op_t *) srcp1)[0];
b1 = ((op_t *) srcp2)[0];
srcp1 += OPSIZ;
srcp2 += OPSIZ;
len -= 1;
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
goto do0;
/* Fall through. */
}
do
{
a0 = ((op_t *) srcp1)[0];
b0 = ((op_t *) srcp2)[0];
if (a1 != b1)
return CMP_LT_OR_GT (a1, b1);
do3:
a1 = ((op_t *) srcp1)[1];
b1 = ((op_t *) srcp2)[1];
if (a0 != b0)
return CMP_LT_OR_GT (a0, b0);
do2:
a0 = ((op_t *) srcp1)[2];
b0 = ((op_t *) srcp2)[2];
if (a1 != b1)
return CMP_LT_OR_GT (a1, b1);
do1:
a1 = ((op_t *) srcp1)[3];
b1 = ((op_t *) srcp2)[3];
if (a0 != b0)
return CMP_LT_OR_GT (a0, b0);
srcp1 += 4 * OPSIZ;
srcp2 += 4 * OPSIZ;
len -= 4;
}
while (len != 0);
/* This is the right position for do0. Please don't move
it into the loop. */
do0:
if (a1 != b1)
return CMP_LT_OR_GT (a1, b1);
return 0;
}
/* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
`op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory
operations on `op_t', but SRCP1 *should be unaligned*. */
#ifdef __GNUC__
__inline
#endif
static int
memcmp_not_common_alignment (srcp1, srcp2, len)
long int srcp1;
long int srcp2;
size_t len;
{
op_t a0, a1, a2, a3;
op_t b0, b1, b2, b3;
op_t x;
int shl, shr;
/* Calculate how to shift a word read at the memory operation
aligned srcp1 to make it aligned for comparison. */
shl = 8 * (srcp1 % OPSIZ);
shr = 8 * OPSIZ - shl;
/* Make SRCP1 aligned by rounding it down to the beginning of the `op_t'
it points in the middle of. */
srcp1 &= -OPSIZ;
switch (len % 4)
{
case 2:
a1 = ((op_t *) srcp1)[0];
a2 = ((op_t *) srcp1)[1];
b2 = ((op_t *) srcp2)[0];
srcp1 -= 1 * OPSIZ;
srcp2 -= 2 * OPSIZ;
len += 2;
goto do1;
case 3:
a0 = ((op_t *) srcp1)[0];
a1 = ((op_t *) srcp1)[1];
b1 = ((op_t *) srcp2)[0];
srcp2 -= 1 * OPSIZ;
len += 1;
goto do2;
case 0:
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
return 0;
a3 = ((op_t *) srcp1)[0];
a0 = ((op_t *) srcp1)[1];
b0 = ((op_t *) srcp2)[0];
srcp1 += 1 * OPSIZ;
goto do3;
case 1:
a2 = ((op_t *) srcp1)[0];
a3 = ((op_t *) srcp1)[1];
b3 = ((op_t *) srcp2)[0];
srcp1 += 2 * OPSIZ;
srcp2 += 1 * OPSIZ;
len -= 1;
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
goto do0;
/* Fall through. */
}
do
{
a0 = ((op_t *) srcp1)[0];
b0 = ((op_t *) srcp2)[0];
x = MERGE(a2, shl, a3, shr);
if (x != b3)
return CMP_LT_OR_GT (x, b3);
do3:
a1 = ((op_t *) srcp1)[1];
b1 = ((op_t *) srcp2)[1];
x = MERGE(a3, shl, a0, shr);
if (x != b0)
return CMP_LT_OR_GT (x, b0);
do2:
a2 = ((op_t *) srcp1)[2];
b2 = ((op_t *) srcp2)[2];
x = MERGE(a0, shl, a1, shr);
if (x != b1)
return CMP_LT_OR_GT (x, b1);
do1:
a3 = ((op_t *) srcp1)[3];
b3 = ((op_t *) srcp2)[3];
x = MERGE(a1, shl, a2, shr);
if (x != b2)
return CMP_LT_OR_GT (x, b2);
srcp1 += 4 * OPSIZ;
srcp2 += 4 * OPSIZ;
len -= 4;
}
while (len != 0);
/* This is the right position for do0. Please don't move
it into the loop. */
do0:
x = MERGE(a2, shl, a3, shr);
if (x != b3)
return CMP_LT_OR_GT (x, b3);
return 0;
}
int
memcmp (s1, s2, len)
const __ptr_t s1;
const __ptr_t s2;
size_t len;
{
op_t a0;
op_t b0;
long int srcp1 = (long int) s1;
long int srcp2 = (long int) s2;
op_t res;
if (len >= OP_T_THRES)
{
/* There are at least some bytes to compare. No need to test
for LEN == 0 in this alignment loop. */
while (srcp2 % OPSIZ != 0)
{
a0 = ((byte *) srcp1)[0];
b0 = ((byte *) srcp2)[0];
srcp1 += 1;
srcp2 += 1;
res = a0 - b0;
if (res != 0)
return res;
len -= 1;
}
/* SRCP2 is now aligned for memory operations on `op_t'.
SRCP1 alignment determines if we can do a simple,
aligned compare or need to shuffle bits. */
if (srcp1 % OPSIZ == 0)
res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ);
else
res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ);
if (res != 0)
return res;
/* Number of bytes remaining in the interval [0..OPSIZ-1]. */
srcp1 += len & -OPSIZ;
srcp2 += len & -OPSIZ;
len %= OPSIZ;
}
/* There are just a few bytes to compare. Use byte memory operations. */
while (len != 0)
{
a0 = ((byte *) srcp1)[0];
b0 = ((byte *) srcp2)[0];
srcp1 += 1;
srcp2 += 1;
res = a0 - b0;
if (res != 0)
return res;
len -= 1;
}
return 0;
}

16
lib/memcpy.c Normal file
View File

@@ -0,0 +1,16 @@
/* Copy LEN bytes starting at SRCADDR to DESTADDR. Result undefined
if the source overlaps with the destination.
Return DESTADDR. */
char *
memcpy (destaddr, srcaddr, len)
char *destaddr;
const char *srcaddr;
int len;
{
char *dest = destaddr;
while (len-- > 0)
*destaddr++ = *srcaddr++;
return dest;
}

24
lib/memmove.c Normal file
View File

@@ -0,0 +1,24 @@
/* memmove.c -- copy memory.
Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate.
In the public domain.
By David MacKenzie <djm@gnu.ai.mit.edu>. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
void
memmove (dest, source, length)
char *dest;
const char *source;
unsigned length;
{
if (source < dest)
/* Moving from low mem to hi mem; start at end. */
for (source += length, dest += length; length; --length)
*--dest = *--source;
else if (source != dest)
/* Moving from hi mem to low mem; start at beginning. */
for (; length; --length)
*dest++ = *source++;
}

View File

@@ -1,4 +1,4 @@
/* mkrmdir.c -- BSD compatible directory functions for System V
/* mkdir.c -- BSD compatible make directory function for System V
Copyright (C) 1988, 1990 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -15,14 +15,26 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#ifndef STDC_HEADERS
#ifndef errno
extern int errno;
#endif
/* mkdir and rmdir adapted from GNU tar. */
#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
#endif
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
/* mkdir adapted from GNU tar. */
/* Make directory DPATH, with permission mode DMODE.
@@ -57,7 +69,7 @@ mkdir (dpath, dmode)
switch (cpid)
{
case -1: /* Cannot fork. */
return -1; /* errno is set already. */
return -1; /* errno is already set. */
case 0: /* Child process. */
/* Cheap hack to set mode of new directory. Since this child
@@ -70,56 +82,16 @@ mkdir (dpath, dmode)
_exit (1);
default: /* Parent process. */
while (wait (&status) != cpid) /* Wait for kid to finish. */
/* Wait for kid to finish. */
while (wait (&status) != cpid)
/* Do nothing. */ ;
if (status & 0xFFFF)
{
errno = EIO; /* /bin/mkdir failed. */
/* /bin/mkdir failed. */
errno = EIO;
return -1;
}
return chmod (dpath, dmode);
}
}
/* Remove directory DPATH.
Return 0 if successful, -1 if not. */
int
rmdir (dpath)
char *dpath;
{
int cpid, status;
struct stat statbuf;
if (stat (dpath, &statbuf) != 0)
return -1; /* stat set errno. */
if ((statbuf.st_mode & S_IFMT) != S_IFDIR)
{
errno = ENOTDIR;
return -1;
}
cpid = fork ();
switch (cpid)
{
case -1: /* Cannot fork. */
return -1; /* errno is set already. */
case 0: /* Child process. */
execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
_exit (1);
default: /* Parent process. */
while (wait (&status) != cpid) /* Wait for kid to finish. */
/* Do nothing. */ ;
if (status & 0xFFFF)
{
errno = EIO; /* /bin/rmdir failed. */
return -1;
}
return 0;
}
}

View File

@@ -1,4 +1,6 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
/* Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
Contributed by Paul Eggert (eggert@twinsun.com).
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,209 +18,391 @@ License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <sys/types.h>
#include <errno.h>
#ifndef STDC_HEADERS
extern int errno;
#endif
#ifdef TM_IN_SYS_TIME
#include <sys/time.h>
#else
#include <time.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#else
#define LONG_MAX (~(1 << (sizeof (long) * 8 - 1)))
#define LONG_MIN (-LONG_MAX - 1)
#define INT_MAX (~(1 << (sizeof (int) * 8 - 1)))
#define INT_MIN (-INT_MAX - 1)
/* Define this to have a standalone program to test this implementation of
mktime. */
/* #define DEBUG 1 */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef NULL
#define NULL 0
/* Assume that leap seconds are possible, unless told otherwise.
If the host has a `zic' command with a `-L leapsecondfilename' option,
then it supports leap seconds; otherwise it probably doesn't. */
#ifndef LEAP_SECONDS_POSSIBLE
#define LEAP_SECONDS_POSSIBLE 1
#endif
#include <sys/types.h> /* Some systems define `time_t' here. */
#include <time.h>
#if __STDC__ || __GNU_LIBRARY__ || STDC_HEADERS
#include <limits.h>
#endif
#if DEBUG
#include <stdio.h>
#if __STDC__ || __GNU_LIBRARY__ || STDC_HEADERS
#include <stdlib.h>
#endif
/* Make it work even if the system's libc has its own mktime routine. */
#define mktime my_mktime
#endif /* DEBUG */
#ifndef __P
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
#define __P(args) args
#else
#define __P(args) ()
#endif /* GCC. */
#endif /* Not __P. */
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
#ifndef INT_MIN
#define INT_MIN (~0 << (sizeof (int) * CHAR_BIT - 1))
#endif
#ifndef INT_MAX
#define INT_MAX (~0 - INT_MIN)
#endif
#ifndef TIME_T_MIN
#define TIME_T_MIN (0 < (time_t) -1 ? (time_t) 0 \
: ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))
#endif
#ifndef TIME_T_MAX
#define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN)
#endif
#define TM_YEAR_BASE 1900
#define EPOCH_YEAR 1970
#ifndef __isleap
/* Nonzero if YEAR is a leap year (every 4 years,
except every 100th isn't, and every 1000th is). */
except every 100th isn't, and every 400th is). */
#define __isleap(year) \
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 1000 == 0))
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
#endif
/* How many days are in each month. */
static unsigned short int __mon_lengths[2][12] =
/* How many days come before each month (0-12). */
const unsigned short int __mon_yday[2][13] =
{
/* Normal years. */
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
/* Leap years. */
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
};
static time_t ydhms_tm_diff __P ((int, int, int, int, int, const struct tm *));
time_t __mktime_internal __P ((struct tm *,
struct tm *(*) (const time_t *, struct tm *),
time_t *));
#if ! HAVE_LOCALTIME_R && ! defined (localtime_r)
#ifdef _LIBC
#define localtime_r __localtime_r
#else
/* Approximate localtime_r as best we can in its absence. */
#define localtime_r my_localtime_r
static struct tm *localtime_r __P ((const time_t *, struct tm *));
static struct tm *
localtime_r (t, tp)
const time_t *t;
struct tm *tp;
{
/* Normal years. */
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
/* Leap years. */
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
#define invalid() return (time_t) -1
/* Return the `time_t' representation of TP and normalizes TP.
Return (time_t) -1 if TP is not representable as a `time_t'.
Note that 31 Dec 1969 23:59:59 is not representable
because it is represented as (time_t) -1. */
time_t
mktime(tp)
register struct tm *tp;
{
static struct tm min, max;
static char init = 0;
register time_t result;
register time_t t;
register int i;
register unsigned short *l;
register struct tm *new;
time_t end;
if (tp == NULL)
{
errno = EINVAL;
invalid();
}
if (!init)
{
init = 1;
end = (time_t) LONG_MIN;
new = gmtime(&end);
if (new != NULL)
min = *new;
else
min.tm_sec = min.tm_min = min.tm_hour =
min.tm_mday = min.tm_mon = min.tm_year = INT_MIN;
end = (time_t) LONG_MAX;
new = gmtime(&end);
if (new != NULL)
max = *new;
else
max.tm_sec = max.tm_min = max.tm_hour =
max.tm_mday = max.tm_mon = max.tm_year = INT_MAX;
}
/* Make all the elements of TP that we pay attention to
be within the ranges of reasonable values for those things. */
#define normalize(elt, min, max, nextelt) \
while (tp->elt < min) \
{ \
--tp->nextelt; \
tp->elt += max + 1; \
} \
while (tp->elt > max) \
{ \
++tp->nextelt; \
tp->elt -= max + 1; \
}
normalize (tm_sec, 0, 59, tm_min);
normalize (tm_min, 0, 59, tm_hour);
normalize (tm_hour, 0, 24, tm_mday);
/* Normalize the month first so we can use
it to figure the range for the day. */
normalize (tm_mon, 0, 11, tm_year);
normalize (tm_mday, 1, __mon_lengths[__isleap (tp->tm_year)][tp->tm_mon],
tm_mon);
/* Normalize the month again, since normalizing
the day may have pushed it out of range. */
normalize (tm_mon, 0, 11, tm_year);
/* Normalize the day again, because normalizing
the month may have changed the range. */
normalize (tm_mday, 1, __mon_lengths[__isleap (tp->tm_year)][tp->tm_mon],
tm_mon);
/* Check for out-of-range values. */
#define lowhigh(field, minmax, cmp) (tp->field cmp minmax.field)
#define low(field) lowhigh(field, min, <)
#define high(field) lowhigh(field, max, >)
#define oor(field) (low(field) || high(field))
#define lowbound(field) (tp->field == min.field)
#define highbound(field) (tp->field == max.field)
if (oor(tm_year))
invalid();
else if (lowbound(tm_year))
{
if (low(tm_mon))
invalid();
else if (lowbound(tm_mon))
{
if (low(tm_mday))
invalid();
else if (lowbound(tm_mday))
{
if (low(tm_hour))
invalid();
else if (lowbound(tm_hour))
{
if (low(tm_min))
invalid();
else if (lowbound(tm_min))
{
if (low(tm_sec))
invalid();
}
}
}
}
}
else if (highbound(tm_year))
{
if (high(tm_mon))
invalid();
else if (highbound(tm_mon))
{
if (high(tm_mday))
invalid();
else if (highbound(tm_mday))
{
if (high(tm_hour))
invalid();
else if (highbound(tm_hour))
{
if (high(tm_min))
invalid();
else if (highbound(tm_min))
{
if (high(tm_sec))
invalid();
}
}
}
}
}
t = 0;
for (i = 1970; i > 1900 + tp->tm_year; --i)
t -= __isleap(i) ? 366 : 365;
for (i = 1970; i < 1900 + tp->tm_year; ++i)
t += __isleap(i) ? 366 : 365;
l = __mon_lengths[__isleap(1900 + tp->tm_year)];
for (i = 0; i < tp->tm_mon; ++i)
t += l[i];
t += tp->tm_mday - 1;
result = ((t * 60 * 60 * 24) +
(tp->tm_hour * 60 * 60) +
(tp->tm_min * 60) +
tp->tm_sec);
end = result;
#if 0 /* This code breaks it, on SunOS anyway. */
if (tp->tm_isdst < 0)
new = localtime(&end);
else
#endif
new = gmtime(&end);
if (new == NULL)
invalid();
new->tm_isdst = tp->tm_isdst;
*tp = *new;
return result;
struct tm *l = localtime (t);
if (! l)
return 0;
*tp = *l;
return tp;
}
#endif /* ! _LIBC */
#endif /* ! HAVE_LOCALTIME_R && ! defined (localtime_r) */
/* Yield the difference between (YEAR-YDAY HOUR:MIN:SEC) and (*TP),
measured in seconds, ignoring leap seconds.
YEAR uses the same numbering as TM->tm_year.
All values are in range, except possibly YEAR.
If overflow occurs, yield the low order bits of the correct answer. */
static time_t
ydhms_tm_diff (year, yday, hour, min, sec, tp)
int year, yday, hour, min, sec;
const struct tm *tp;
{
time_t ay = year + (time_t) (TM_YEAR_BASE - 1);
time_t by = tp->tm_year + (time_t) (TM_YEAR_BASE - 1);
time_t intervening_leap_days =
(ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
time_t years = ay - by;
time_t days = (365 * years + intervening_leap_days
+ (yday - tp->tm_yday));
return (60 * (60 * (24 * days + (hour - tp->tm_hour))
+ (min - tp->tm_min))
+ (sec - tp->tm_sec));
}
/* Convert *TP to a time_t value. */
time_t
mktime (tp)
struct tm *tp;
{
static time_t localtime_offset;
return __mktime_internal (tp, localtime_r, &localtime_offset);
}
/* Convert *TP to a time_t value, inverting
the monotonic and mostly-unit-linear conversion function CONVERT.
Use *OFFSET to keep track of a guess at the offset of the result,
compared to what the result would be for UTC without leap seconds.
If *OFFSET's guess is correct, only one CONVERT call is needed. */
time_t
__mktime_internal (tp, convert, offset)
struct tm *tp;
struct tm *(*convert) __P ((const time_t *, struct tm *));
time_t *offset;
{
time_t t, dt, t0;
struct tm tm;
/* The maximum number of probes (calls to CONVERT) should be enough
to handle any combinations of time zone rule changes, solar time,
and leap seconds. Posix.1 prohibits leap seconds, but some hosts
have them anyway. */
int remaining_probes = 4;
/* Time requested. Copy it in case CONVERT modifies *TP; this can
occur if TP is localtime's returned value and CONVERT is localtime. */
int sec = tp->tm_sec;
int min = tp->tm_min;
int hour = tp->tm_hour;
int mday = tp->tm_mday;
int mon = tp->tm_mon;
int year_requested = tp->tm_year;
int isdst = tp->tm_isdst;
/* Ensure that mon is in range, and set year accordingly. */
int mon_remainder = mon % 12;
int negative_mon_remainder = mon_remainder < 0;
int mon_years = mon / 12 - negative_mon_remainder;
int year = year_requested + mon_years;
/* The other values need not be in range:
the remaining code handles minor overflows correctly,
assuming int and time_t arithmetic wraps around.
Major overflows are caught at the end. */
/* Calculate day of year from year, month, and day of month.
The result need not be in range. */
int yday = ((__mon_yday[__isleap (year + TM_YEAR_BASE)]
[mon_remainder + 12 * negative_mon_remainder])
+ mday - 1);
#if LEAP_SECONDS_POSSIBLE
/* Handle out-of-range seconds specially,
since ydhms_tm_diff assumes every minute has 60 seconds. */
int sec_requested = sec;
if (sec < 0)
sec = 0;
if (59 < sec)
sec = 59;
#endif
/* Invert CONVERT by probing. First assume the same offset as last time.
Then repeatedly use the error to improve the guess. */
tm.tm_year = EPOCH_YEAR - TM_YEAR_BASE;
tm.tm_yday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
t0 = ydhms_tm_diff (year, yday, hour, min, sec, &tm);
for (t = t0 + *offset;
(dt = ydhms_tm_diff (year, yday, hour, min, sec, (*convert) (&t, &tm)));
t += dt)
if (--remaining_probes == 0)
return -1;
/* Check whether tm.tm_isdst has the requested value, if any. */
if (0 <= isdst && 0 <= tm.tm_isdst)
{
int dst_diff = (isdst != 0) - (tm.tm_isdst != 0);
if (dst_diff)
{
/* Move two hours in the direction indicated by the disagreement,
probe some more, and switch to a new time if found.
The largest known fallback due to daylight savings is two hours:
once, in Newfoundland, 1988-10-30 02:00 -> 00:00. */
time_t ot = t - 2 * 60 * 60 * dst_diff;
while (--remaining_probes != 0)
{
struct tm otm;
if (! (dt = ydhms_tm_diff (year, yday, hour, min, sec,
(*convert) (&ot, &otm))))
{
t = ot;
tm = otm;
break;
}
if ((ot += dt) == t)
break; /* Avoid a redundant probe. */
}
}
}
*offset = t - t0;
#if LEAP_SECONDS_POSSIBLE
if (sec_requested != tm.tm_sec)
{
/* Adjust time to reflect the tm_sec requested, not the normalized value.
Also, repair any damage from a false match due to a leap second. */
t += sec_requested - sec + (sec == 0 && tm.tm_sec == 60);
(*convert) (&t, &tm);
}
#endif
if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3)
{
/* time_t isn't large enough to rule out overflows in ydhms_tm_diff,
so check for major overflows. A gross check suffices,
since if t has overflowed, it is off by a multiple of
TIME_T_MAX - TIME_T_MIN + 1. So ignore any component of
the difference that is bounded by a small value. */
double dyear = (double) year_requested + mon_years - tm.tm_year;
double dday = 366 * dyear + mday;
double dsec = 60 * (60 * (24 * dday + hour) + min) + sec_requested;
if (TIME_T_MAX / 3 - TIME_T_MIN / 3 < (dsec < 0 ? - dsec : dsec))
return -1;
}
*tp = tm;
return t;
}
#ifdef weak_alias
weak_alias (mktime, timelocal)
#endif
#if DEBUG
static int
not_equal_tm (a, b)
struct tm *a;
struct tm *b;
{
return ((a->tm_sec ^ b->tm_sec)
| (a->tm_min ^ b->tm_min)
| (a->tm_hour ^ b->tm_hour)
| (a->tm_mday ^ b->tm_mday)
| (a->tm_mon ^ b->tm_mon)
| (a->tm_year ^ b->tm_year)
| (a->tm_mday ^ b->tm_mday)
| (a->tm_yday ^ b->tm_yday)
| (a->tm_isdst ^ b->tm_isdst));
}
static void
print_tm (tp)
struct tm *tp;
{
printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d",
tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
tp->tm_hour, tp->tm_min, tp->tm_sec,
tp->tm_yday, tp->tm_wday, tp->tm_isdst);
}
static int
check_result (tk, tmk, tl, tml)
time_t tk;
struct tm tmk;
time_t tl;
struct tm tml;
{
if (tk != tl || not_equal_tm (&tmk, &tml))
{
printf ("mktime (");
print_tm (&tmk);
printf (")\nyields (");
print_tm (&tml);
printf (") == %ld, should be %ld\n", (long) tl, (long) tk);
return 1;
}
return 0;
}
int
main (argc, argv)
int argc;
char **argv;
{
int status = 0;
struct tm tm, tmk, tml;
time_t tk, tl;
char trailer;
if ((argc == 3 || argc == 4)
&& (sscanf (argv[1], "%d-%d-%d%c",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
== 3)
&& (sscanf (argv[2], "%d:%d:%d%c",
&tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
== 3))
{
tm.tm_year -= TM_YEAR_BASE;
tm.tm_mon--;
tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]);
tmk = tm;
tl = mktime (&tmk);
tml = *localtime (&tl);
printf ("mktime returns %ld == ", (long) tl);
print_tm (&tmk);
printf ("\n");
status = check_result (tl, tmk, tl, tml);
}
else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0))
{
time_t from = atol (argv[1]);
time_t by = atol (argv[2]);
time_t to = atol (argv[3]);
if (argc == 4)
for (tl = from; tl <= to; tl += by)
{
tml = *localtime (&tl);
tmk = tml;
tk = mktime (&tmk);
status |= check_result (tk, tmk, tl, tml);
}
else
for (tl = from; tl <= to; tl += by)
{
/* Null benchmark. */
tml = *localtime (&tl);
tmk = tml;
tk = tl;
status |= check_result (tk, tmk, tl, tml);
}
}
else
printf ("Usage:\
\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\
\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\
\t%s FROM BY TO - # Do not test those values (for benchmark).\n",
argv[0], argv[0], argv[0]);
return status;
}
#endif /* DEBUG */
/*
Local Variables:
compile-command: "gcc -DDEBUG=1 -Wall -O -g mktime.c -o mktime"
End:
*/

View File

@@ -24,6 +24,10 @@
changing the mode of many files, this probably results in a
performance gain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include "modechange.h"
@@ -38,7 +42,11 @@ char *malloc ();
#define NULL 0
#endif
#ifndef S_ISDIR
#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
#endif /* STAT_MACROS_BROKEN. */
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
@@ -64,7 +72,7 @@ static int oatoi ();
struct mode_change *
mode_compile (mode_string, masked_ops)
register char *mode_string;
const char *mode_string;
unsigned masked_ops;
{
struct mode_change *head; /* First element of the linked list. */
@@ -95,6 +103,9 @@ mode_compile (mode_string, masked_ops)
umask (umask_value); /* Restore the old value. */
head = NULL;
#ifdef lint
change = NULL;
#endif
--mode_string;
/* One loop iteration for each "ugoa...=+-rwxXstugo...[=+-rwxXstugo...]". */
@@ -233,7 +244,7 @@ invalid:
unsigned short
mode_adjust (oldmode, changes)
unsigned oldmode;
register struct mode_change *changes;
const struct mode_change *changes;
{
unsigned short newmode; /* The adjusted mode and one operand. */
unsigned short value; /* The other operand. */

View File

@@ -44,12 +44,14 @@ struct mode_change
#define MODE_INVALID (struct mode_change *) 0
#define MODE_MEMORY_EXHAUSTED (struct mode_change *) 1
#ifdef __STDC__
struct mode_change *mode_compile (char *, unsigned);
unsigned short mode_adjust (unsigned, struct mode_change *);
void mode_free (struct mode_change *);
#ifndef __P
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
#define __P(args) args
#else
struct mode_change *mode_compile ();
unsigned short mode_adjust ();
void mode_free ();
#endif
#define __P(args) ()
#endif /* GCC. */
#endif /* Not __P. */
struct mode_change *mode_compile __P ((const char *, unsigned));
unsigned short mode_adjust __P ((unsigned, const struct mode_change *));
void mode_free __P ((struct mode_change *));

View File

@@ -15,6 +15,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#include "mountlist.h"
@@ -24,7 +28,7 @@
#else
void free ();
#endif
#if defined(USG) || defined(STDC_HEADERS)
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#include <string.h>
#else
#include <strings.h>
@@ -36,6 +40,15 @@ char *xrealloc ();
char *xstrdup ();
void error ();
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */
# include <sys/mount.h>
# include <sys/fs_types.h>
#endif /* MOUNTED_GETFSSTAT */
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
#include <mntent.h>
#if !defined(MOUNTED)
@@ -53,7 +66,6 @@ void error ();
#endif
#ifdef MOUNTED_GETMNT /* Ultrix. */
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/fs_types.h>
#endif
@@ -68,6 +80,10 @@ void error ();
#include <sys/statfs.h>
#endif
#ifdef MOUNTED_LISTMNTENT
#include <mntent.h>
#endif
#ifdef MOUNTED_GETMNTENT2 /* SVR4. */
#include <sys/mnttab.h>
#endif
@@ -77,6 +93,12 @@ void error ();
#include <sys/vfs.h>
#endif
#ifdef DOLPHIN
/* So special that it's not worth putting this in autoconf. */
#undef MOUNTED_FREAD_FSTYP
#define MOUNTED_GETMNTTBL
#endif
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
/* Return the value of the hexadecimal number represented by CP.
No prefix (like '0x') or suffix (like 'h') is expected to be
@@ -87,7 +109,7 @@ xatoi (cp)
char *cp;
{
int val;
val = 0;
while (*cp)
{
@@ -105,7 +127,7 @@ xatoi (cp)
}
#endif /* MOUNTED_GETMNTENT1. */
#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
#if defined (MOUNTED_GETMNTINFO) && !defined (__NetBSD__)
static char *
fstype_to_string (t)
short t;
@@ -116,8 +138,10 @@ fstype_to_string (t)
return "ufs";
case MOUNT_NFS:
return "nfs";
#ifdef MOUNT_PC
case MOUNT_PC:
return "pc";
#endif
#ifdef MOUNT_MFS
case MOUNT_MFS:
return "mfs";
@@ -175,6 +199,36 @@ read_filesystem_list (need_fs_type, all_fs)
me->me_next = NULL;
mount_list = mtail = me;
#ifdef MOUNTED_LISTMNTENT
{
struct tabmntent *mntlist, *p;
struct mntent *mnt;
struct mount_entry *me;
/* the third and fourth arguments could be used to filter mounts,
but Crays doesn't seem to have any mounts that we want to
remove. Specifically, automount create normal NFS mounts.
*/
if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
return NULL;
p = mntlist;
while(p){
mnt = p->ment;
me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
me->me_devname = xstrdup(mnt->mnt_fsname);
me->me_mountdir = xstrdup(mnt->mnt_dir);
me->me_type = xstrdup(mnt->mnt_type);
me->me_dev = -1;
me->me_next = NULL;
mtail->me_next = me;
mtail = me;
p = p->next;
}
freemntlist(mntlist);
}
#endif
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
{
struct mntent *mnt;
@@ -205,7 +259,7 @@ read_filesystem_list (need_fs_type, all_fs)
me->me_dev = xatoi (devopt + 4);
}
else
me->me_dev = -1; /* Magic; means not known yet. */
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
@@ -231,8 +285,12 @@ read_filesystem_list (need_fs_type, all_fs)
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (fsp->f_mntfromname);
me->me_mountdir = xstrdup (fsp->f_mntonname);
#ifdef __NetBSD__
me->me_type = xstrdup (fsp->f_fstypename);
#else
me->me_type = fstype_to_string (fsp->f_type);
me->me_dev = -1; /* Magic; means not known yet. */
#endif
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
@@ -268,6 +326,43 @@ read_filesystem_list (need_fs_type, all_fs)
}
#endif /* MOUNTED_GETMNT. */
#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */
{
int numsys, counter, bufsize;
struct statfs *stats;
numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
if (numsys < 0)
return (NULL);
bufsize = (1 + numsys) * sizeof (struct statfs);
stats = (struct statfs *)xmalloc (bufsize);
numsys = getfsstat (stats, bufsize, MNT_WAIT);
if (numsys < 0)
{
free (stats);
return (NULL);
}
for (counter = 0; counter < numsys; counter++)
{
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (stats[counter].f_mntfromname);
me->me_mountdir = xstrdup (stats[counter].f_mntonname);
me->me_type = mnt_names[stats[counter].f_type];
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
}
free (stats);
}
#endif /* MOUNTED_GETFSSTAT */
#if defined (MOUNTED_FREAD) || defined (MOUNTED_FREAD_FSTYP) /* SVR[23]. */
{
struct mnttab mnt;
@@ -289,7 +384,7 @@ read_filesystem_list (need_fs_type, all_fs)
strcpy (me->me_devname + 5, mnt.mt_dev);
#endif
me->me_mountdir = xstrdup (mnt.mt_filsys);
me->me_dev = -1; /* Magic; means not known yet. */
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_type = "";
#ifdef GETFSTYP /* SVR3. */
if (need_fs_type)
@@ -314,6 +409,26 @@ read_filesystem_list (need_fs_type, all_fs)
}
#endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */
#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes it's own way */
{
struct mntent **mnttbl=getmnttbl(),**ent;
for (ent=mnttbl;*ent;ent++)
{
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup ( (*ent)->mt_resource);
me->me_mountdir = xstrdup( (*ent)->mt_directory);
me->me_type = xstrdup ((*ent)->mt_fstype);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
}
endmnttbl();
}
#endif
#ifdef MOUNTED_GETMNTENT2 /* SVR4. */
{
struct mnttab mnt;
@@ -331,7 +446,7 @@ read_filesystem_list (need_fs_type, all_fs)
me->me_devname = xstrdup (mnt.mnt_special);
me->me_mountdir = xstrdup (mnt.mnt_mountp);
me->me_type = xstrdup (mnt.mnt_fstype);
me->me_dev = -1; /* Magic; means not known yet. */
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
@@ -378,12 +493,12 @@ read_filesystem_list (need_fs_type, all_fs)
}
else
{
me->me_devname = xstrdup (thisent +
me->me_devname = xstrdup (thisent +
vmp->vmt_data[VMT_OBJECT].vmt_off);
}
me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
me->me_dev = -1; /* vmt_fsid might be the info we want. */
me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */
me->me_next = NULL;
/* Add to the linked list. */

485
lib/obstack.c Normal file
View File

@@ -0,0 +1,485 @@
/* obstack.c - subroutines used implicitly by object stack macros
Copyright (C) 1988, 89, 90, 91, 92, 93, 94 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "obstack.h"
/* This is just to get __GNU_LIBRARY__ defined. */
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. 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__)
#ifdef __STDC__
#define POINTER void *
#else
#define POINTER char *
#endif
/* Determine default alignment. */
struct fooalign {char x; double d;};
#define DEFAULT_ALIGNMENT \
((PTR_INT_TYPE) ((char *)&((struct fooalign *) 0)->d - (char *)0))
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
But in fact it might be less smart and round addresses to as much as
DEFAULT_ROUNDING. So we prepare for it to do that. */
union fooround {long x; double d;};
#define DEFAULT_ROUNDING (sizeof (union fooround))
/* When we copy a long block of data, this is the unit to do it with.
On some machines, copying successive ints does not work;
in such a case, redefine COPYING_UNIT to `long' (if that works)
or `char' as a last resort. */
#ifndef COPYING_UNIT
#define COPYING_UNIT int
#endif
/* The non-GNU-C macros copy the obstack into this global variable
to avoid multiple evaluation. */
struct obstack *_obstack;
/* Define a macro that either calls functions with the traditional malloc/free
calling interface, or calls functions with the mmalloc/mfree interface
(that adds an extra first argument), based on the state of use_extra_arg.
For free, do not use ?:, since some compilers, like the MIPS compilers,
do not allow (expr) ? void : void. */
#define CALL_CHUNKFUN(h, size) \
(((h) -> use_extra_arg) \
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
: (*(h)->chunkfun) ((size)))
#define CALL_FREEFUN(h, old_chunk) \
do { \
if ((h) -> use_extra_arg) \
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
else \
(*(h)->freefun) ((old_chunk)); \
} while (0)
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
Objects start on multiples of ALIGNMENT (0 means use default).
CHUNKFUN is the function to use to allocate chunks,
and FREEFUN the function to free them.
Return nonzero if successful, zero if out of memory.
To recover from an out of memory error,
free up some memory, then call this again. */
int
_obstack_begin (h, size, alignment, chunkfun, freefun)
struct obstack *h;
int size;
int alignment;
POINTER (*chunkfun) ();
void (*freefun) ();
{
register struct _obstack_chunk* chunk; /* points to new chunk */
if (alignment == 0)
alignment = DEFAULT_ALIGNMENT;
if (size == 0)
/* Default size is what GNU malloc can fit in a 4096-byte block. */
{
/* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
Use the values for range checking, because if range checking is off,
the extra bytes won't be missed terribly, but if range checking is on
and we used a larger request, a whole extra 4096 bytes would be
allocated.
These number are irrelevant to the new GNU malloc. I suspect it is
less sensitive to the size of the request. */
int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
+ 4 + DEFAULT_ROUNDING - 1)
& ~(DEFAULT_ROUNDING - 1));
size = 4096 - extra;
}
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
h->freefun = freefun;
h->chunk_size = size;
h->alignment_mask = alignment - 1;
h->use_extra_arg = 0;
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
if (!chunk)
{
h->alloc_failed = 1;
return 0;
}
h->alloc_failed = 0;
h->next_free = h->object_base = chunk->contents;
h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size;
chunk->prev = 0;
/* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0;
return 1;
}
int
_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
struct obstack *h;
int size;
int alignment;
POINTER (*chunkfun) ();
void (*freefun) ();
POINTER arg;
{
register struct _obstack_chunk* chunk; /* points to new chunk */
if (alignment == 0)
alignment = DEFAULT_ALIGNMENT;
if (size == 0)
/* Default size is what GNU malloc can fit in a 4096-byte block. */
{
/* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
Use the values for range checking, because if range checking is off,
the extra bytes won't be missed terribly, but if range checking is on
and we used a larger request, a whole extra 4096 bytes would be
allocated.
These number are irrelevant to the new GNU malloc. I suspect it is
less sensitive to the size of the request. */
int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
+ 4 + DEFAULT_ROUNDING - 1)
& ~(DEFAULT_ROUNDING - 1));
size = 4096 - extra;
}
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
h->freefun = freefun;
h->chunk_size = size;
h->alignment_mask = alignment - 1;
h->extra_arg = arg;
h->use_extra_arg = 1;
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
if (!chunk)
{
h->alloc_failed = 1;
return 0;
}
h->alloc_failed = 0;
h->next_free = h->object_base = chunk->contents;
h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size;
chunk->prev = 0;
/* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0;
return 1;
}
/* Allocate a new current chunk for the obstack *H
on the assumption that LENGTH bytes need to be added
to the current object, or a new object of length LENGTH allocated.
Copies any partial object from the end of the old chunk
to the beginning of the new one. */
void
_obstack_newchunk (h, length)
struct obstack *h;
int length;
{
register struct _obstack_chunk* old_chunk = h->chunk;
register struct _obstack_chunk* new_chunk;
register long new_size;
register int obj_size = h->next_free - h->object_base;
register int i;
int already;
/* Compute size for new chunk. */
new_size = (obj_size + length) + (obj_size >> 3) + 100;
if (new_size < h->chunk_size)
new_size = h->chunk_size;
/* Allocate and initialize the new chunk. */
new_chunk = CALL_CHUNKFUN (h, new_size);
if (!new_chunk)
{
h->alloc_failed = 1;
return;
}
h->alloc_failed = 0;
h->chunk = new_chunk;
new_chunk->prev = old_chunk;
new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
/* Move the existing object to the new chunk.
Word at a time is fast and is safe if the object
is sufficiently aligned. */
if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
{
for (i = obj_size / sizeof (COPYING_UNIT) - 1;
i >= 0; i--)
((COPYING_UNIT *)new_chunk->contents)[i]
= ((COPYING_UNIT *)h->object_base)[i];
/* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
but that can cross a page boundary on a machine
which does not do strict alignment for COPYING_UNITS. */
already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
}
else
already = 0;
/* Copy remaining bytes one by one. */
for (i = already; i < obj_size; i++)
new_chunk->contents[i] = h->object_base[i];
/* If the object just copied was the only data in OLD_CHUNK,
free that chunk and remove it from the chain.
But not if that chunk might contain an empty object. */
if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
{
new_chunk->prev = old_chunk->prev;
CALL_FREEFUN (h, old_chunk);
}
h->object_base = new_chunk->contents;
h->next_free = h->object_base + obj_size;
/* The new chunk certainly contains no empty object yet. */
h->maybe_empty_object = 0;
}
/* Return nonzero if object OBJ has been allocated from obstack H.
This is here for debugging.
If you use it in a program, you are probably losing. */
#ifdef __STDC__
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
obstack.h because it is just for debugging. */
int _obstack_allocated_p (struct obstack *h, POINTER obj);
#endif
int
_obstack_allocated_p (h, obj)
struct obstack *h;
POINTER obj;
{
register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
register struct _obstack_chunk* plp; /* point to previous chunk if any */
lp = (h)->chunk;
/* We use >= rather than > since the object cannot be exactly at
the beginning of the chunk but might be an empty object exactly
at the end of an adjacent chunk. */
while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj))
{
plp = lp->prev;
lp = plp;
}
return lp != 0;
}
/* Free objects in obstack H, including OBJ and everything allocate
more recently than OBJ. If OBJ is zero, free everything in H. */
#undef obstack_free
/* This function has two names with identical definitions.
This is the first one, called from non-ANSI code. */
void
_obstack_free (h, obj)
struct obstack *h;
POINTER obj;
{
register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
register struct _obstack_chunk* plp; /* point to previous chunk if any */
lp = h->chunk;
/* We use >= because there cannot be an object at the beginning of a chunk.
But there can be an empty object at that address
at the end of another chunk. */
while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj))
{
plp = lp->prev;
CALL_FREEFUN (h, lp);
lp = plp;
/* If we switch chunks, we can't tell whether the new current
chunk contains an empty object, so assume that it may. */
h->maybe_empty_object = 1;
}
if (lp)
{
h->object_base = h->next_free = (char *)(obj);
h->chunk_limit = lp->limit;
h->chunk = lp;
}
else if (obj != 0)
/* obj is not in any of the chunks! */
abort ();
}
/* This function is used from ANSI code. */
void
obstack_free (h, obj)
struct obstack *h;
POINTER obj;
{
register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
register struct _obstack_chunk* plp; /* point to previous chunk if any */
lp = h->chunk;
/* We use >= because there cannot be an object at the beginning of a chunk.
But there can be an empty object at that address
at the end of another chunk. */
while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj))
{
plp = lp->prev;
CALL_FREEFUN (h, lp);
lp = plp;
/* If we switch chunks, we can't tell whether the new current
chunk contains an empty object, so assume that it may. */
h->maybe_empty_object = 1;
}
if (lp)
{
h->object_base = h->next_free = (char *)(obj);
h->chunk_limit = lp->limit;
h->chunk = lp;
}
else if (obj != 0)
/* obj is not in any of the chunks! */
abort ();
}
#if 0
/* These are now turned off because the applications do not use it
and it uses bcopy via obstack_grow, which causes trouble on sysV. */
/* Now define the functional versions of the obstack macros.
Define them to simply use the corresponding macros to do the job. */
#ifdef __STDC__
/* These function definitions do not work with non-ANSI preprocessors;
they won't pass through the macro names in parentheses. */
/* The function names appear in parentheses in order to prevent
the macro-definitions of the names from being expanded there. */
POINTER (obstack_base) (obstack)
struct obstack *obstack;
{
return obstack_base (obstack);
}
POINTER (obstack_next_free) (obstack)
struct obstack *obstack;
{
return obstack_next_free (obstack);
}
int (obstack_object_size) (obstack)
struct obstack *obstack;
{
return obstack_object_size (obstack);
}
int (obstack_room) (obstack)
struct obstack *obstack;
{
return obstack_room (obstack);
}
void (obstack_grow) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
obstack_grow (obstack, pointer, length);
}
void (obstack_grow0) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
obstack_grow0 (obstack, pointer, length);
}
void (obstack_1grow) (obstack, character)
struct obstack *obstack;
int character;
{
obstack_1grow (obstack, character);
}
void (obstack_blank) (obstack, length)
struct obstack *obstack;
int length;
{
obstack_blank (obstack, length);
}
void (obstack_1grow_fast) (obstack, character)
struct obstack *obstack;
int character;
{
obstack_1grow_fast (obstack, character);
}
void (obstack_blank_fast) (obstack, length)
struct obstack *obstack;
int length;
{
obstack_blank_fast (obstack, length);
}
POINTER (obstack_finish) (obstack)
struct obstack *obstack;
{
return obstack_finish (obstack);
}
POINTER (obstack_alloc) (obstack, length)
struct obstack *obstack;
int length;
{
return obstack_alloc (obstack, length);
}
POINTER (obstack_copy) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
return obstack_copy (obstack, pointer, length);
}
POINTER (obstack_copy0) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
return obstack_copy0 (obstack, pointer, length);
}
#endif /* __STDC__ */
#endif /* 0 */
#endif /* _LIBC or not __GNU_LIBRARY__. */

529
lib/obstack.h Normal file
View File

@@ -0,0 +1,529 @@
/* obstack.h - object stack macros
Copyright (C) 1988, 89, 90, 91, 92, 93, 94 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Summary:
All the apparent functions defined here are macros. The idea
is that you would use these pre-tested macros to solve a
very specific set of problems, and they would run fast.
Caution: no side-effects in arguments please!! They may be
evaluated MANY times!!
These macros operate a stack of objects. Each object starts life
small, and may grow to maturity. (Consider building a word syllable
by syllable.) An object can move while it is growing. Once it has
been "finished" it never changes address again. So the "top of the
stack" is typically an immature growing object, while the rest of the
stack is of mature, fixed size and fixed address objects.
These routines grab large chunks of memory, using a function you
supply, called `obstack_chunk_alloc'. On occasion, they free chunks,
by calling `obstack_chunk_free'. You must define them and declare
them before using any obstack macros.
Each independent stack is represented by a `struct obstack'.
Each of the obstack macros expects a pointer to such a structure
as the first argument.
One motivation for this package is the problem of growing char strings
in symbol tables. Unless you are "fascist pig with a read-only mind"
--Gosper's immortal quote from HAKMEM item 154, out of context--you
would not like to put any arbitrary upper limit on the length of your
symbols.
In practice this often means you will build many short symbols and a
few long symbols. At the time you are reading a symbol you don't know
how long it is. One traditional method is to read a symbol into a
buffer, realloc()ating the buffer every time you try to read a symbol
that is longer than the buffer. This is beaut, but you still will
want to copy the symbol from the buffer to a more permanent
symbol-table entry say about half the time.
With obstacks, you can work differently. Use one obstack for all symbol
names. As you read a symbol, grow the name in the obstack gradually.
When the name is complete, finalize it. Then, if the symbol exists already,
free the newly read name.
The way we do this is to take a large chunk, allocating memory from
low addresses. When you want to build a symbol in the chunk you just
add chars above the current "high water mark" in the chunk. When you
have finished adding chars, because you got to the end of the symbol,
you know how long the chars are, and you can create a new object.
Mostly the chars will not burst over the highest address of the chunk,
because you would typically expect a chunk to be (say) 100 times as
long as an average object.
In case that isn't clear, when we have enough chars to make up
the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
so we just point to it where it lies. No moving of chars is
needed and this is the second win: potentially long strings need
never be explicitly shuffled. Once an object is formed, it does not
change its address during its lifetime.
When the chars burst over a chunk boundary, we allocate a larger
chunk, and then copy the partly formed object from the end of the old
chunk to the beginning of the new larger chunk. We then carry on
accreting characters to the end of the object as we normally would.
A special macro is provided to add a single char at a time to a
growing object. This allows the use of register variables, which
break the ordinary 'growth' macro.
Summary:
We allocate large chunks.
We carve out one object at a time from the current chunk.
Once carved, an object never moves.
We are free to append data of any size to the currently
growing object.
Exactly one object is growing in an obstack at any one time.
You can run one obstack per control block.
You may have as many control blocks as you dare.
Because of the way we do it, you can `unwind' an obstack
back to a previous state. (You may remove objects much
as you would with a stack.)
*/
/* Don't do the contents of this file more than once. */
#ifndef __OBSTACK_H__
#define __OBSTACK_H__
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
/* We use subtraction of (char *)0 instead of casting to int
because on word-addressable machines a simple cast to int
may ignore the byte-within-word field of the pointer. */
#ifndef __PTR_TO_INT
#define __PTR_TO_INT(P) ((P) - (char *)0)
#endif
#ifndef __INT_TO_PTR
#define __INT_TO_PTR(P) ((P) + (char *)0)
#endif
/* We need the type of the resulting object. In ANSI C it is ptrdiff_t
but in traditional C it is usually long. If we are in ANSI C and
don't already have ptrdiff_t get it. */
#if defined (__STDC__) && __STDC__ && ! defined (offsetof)
#if defined (__GNUC__) && defined (IN_GCC)
/* On Next machine, the system's stddef.h screws up if included
after we have defined just ptrdiff_t, so include all of stddef.h.
Otherwise, define just ptrdiff_t, which is all we need. */
#ifndef __NeXT__
#define __need_ptrdiff_t
#endif
#endif
#include <stddef.h>
#endif
#if defined (__STDC__) && __STDC__
#define PTR_INT_TYPE ptrdiff_t
#else
#define PTR_INT_TYPE long
#endif
#if HAVE_STRING_H || STDC_HEADERS
# include <string.h>
# ifndef bcopy
# define bcopy(s, d, n) memcpy ((d), (s), (n))
# endif
#else /* HAVE_STRING_H || STDC_HEADERS */
# include <strings.h>
#endif /* not (HAVE_STRING_H || STDC_HEADERS) */
struct _obstack_chunk /* Lives at front of each chunk. */
{
char *limit; /* 1 past end of this chunk */
struct _obstack_chunk *prev; /* address of prior chunk or NULL */
char contents[4]; /* objects begin here */
};
struct obstack /* control current object in current chunk */
{
long chunk_size; /* preferred size to allocate chunks in */
struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */
char *object_base; /* address of object we are building */
char *next_free; /* where to add next char to current object */
char *chunk_limit; /* address of char after current chunk */
PTR_INT_TYPE temp; /* Temporary for some macros. */
int alignment_mask; /* Mask of alignment for each object. */
struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */
void (*freefun) (); /* User's function to free a chunk. */
char *extra_arg; /* first arg for chunk alloc/dealloc funcs */
unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */
unsigned maybe_empty_object:1;/* There is a possibility that the current
chunk contains a zero-length object. This
prevents freeing the chunk if we allocate
a bigger chunk to replace it. */
unsigned alloc_failed:1; /* chunk alloc func returned 0 */
};
/* Declare the external functions we use; they are in obstack.c. */
#if defined (__STDC__) && __STDC__
extern void _obstack_newchunk (struct obstack *, int);
extern void _obstack_free (struct obstack *, void *);
extern int _obstack_begin (struct obstack *, int, int,
void *(*) (), void (*) ());
extern int _obstack_begin_1 (struct obstack *, int, int,
void *(*) (), void (*) (), void *);
#else
extern void _obstack_newchunk ();
extern void _obstack_free ();
extern int _obstack_begin ();
extern int _obstack_begin_1 ();
#endif
#if defined (__STDC__) && __STDC__
/* Do the function-declarations after the structs
but before defining the macros. */
void obstack_init (struct obstack *obstack);
void * obstack_alloc (struct obstack *obstack, int size);
void * obstack_copy (struct obstack *obstack, void *address, int size);
void * obstack_copy0 (struct obstack *obstack, void *address, int size);
void obstack_free (struct obstack *obstack, void *block);
void obstack_blank (struct obstack *obstack, int size);
void obstack_grow (struct obstack *obstack, void *data, int size);
void obstack_grow0 (struct obstack *obstack, void *data, int size);
void obstack_1grow (struct obstack *obstack, int data_char);
void obstack_ptr_grow (struct obstack *obstack, void *data);
void obstack_int_grow (struct obstack *obstack, int data);
void * obstack_finish (struct obstack *obstack);
int obstack_object_size (struct obstack *obstack);
int obstack_room (struct obstack *obstack);
void obstack_1grow_fast (struct obstack *obstack, int data_char);
void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
void obstack_int_grow_fast (struct obstack *obstack, int data);
void obstack_blank_fast (struct obstack *obstack, int size);
void * obstack_base (struct obstack *obstack);
void * obstack_next_free (struct obstack *obstack);
int obstack_alignment_mask (struct obstack *obstack);
int obstack_chunk_size (struct obstack *obstack);
#endif /* __STDC__ */
/* Non-ANSI C cannot really support alternative functions for these macros,
so we do not declare them. */
/* Pointer to beginning of object being allocated or to be allocated next.
Note that this might not be the final address of the object
because a new chunk might be needed to hold the final size. */
#define obstack_base(h) ((h)->alloc_failed ? 0 : (h)->object_base)
/* Size for allocating ordinary chunks. */
#define obstack_chunk_size(h) ((h)->chunk_size)
/* Pointer to next byte not yet allocated in current chunk. */
#define obstack_next_free(h) ((h)->alloc_failed ? 0 : (h)->next_free)
/* Mask specifying low bits that should be clear in address of an object. */
#define obstack_alignment_mask(h) ((h)->alignment_mask)
#define obstack_init(h) \
_obstack_begin ((h), 0, 0, \
(void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
#define obstack_begin(h, size) \
_obstack_begin ((h), (size), 0, \
(void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
_obstack_begin ((h), (size), (alignment), \
(void *(*) ()) (chunkfun), (void (*) ()) (freefun))
#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
_obstack_begin_1 ((h), (size), (alignment), \
(void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg))
#define obstack_chunkfun(h, newchunkfun) \
((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
#define obstack_freefun(h, newfreefun) \
((h) -> freefun = (void (*)()) (newfreefun))
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
#define obstack_blank_fast(h,n) ((h)->next_free += (n))
#if defined (__GNUC__) && defined (__STDC__)
/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
does not implement __extension__. But that compiler doesn't define
__GNUC_MINOR__. */
#if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
#define __extension__
#endif
/* For GNU C, if not -traditional,
we can define these macros to compute all args only once
without using a global variable.
Also, we can avoid using the `temp' slot, to make faster code. */
#define obstack_object_size(OBSTACK) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
__o->alloc_failed ? 0 : \
(unsigned) (__o->next_free - __o->object_base); })
#define obstack_room(OBSTACK) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
(unsigned) (__o->chunk_limit - __o->next_free); })
#define obstack_grow(OBSTACK,where,length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
if (__o->next_free + __len > __o->chunk_limit) \
_obstack_newchunk (__o, __len); \
if (!__o->alloc_failed) \
{ \
bcopy ((char *) (where), __o->next_free, __len); \
__o->next_free += __len; \
} \
(void) 0; })
#define obstack_grow0(OBSTACK,where,length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
if (__o->next_free + __len + 1 > __o->chunk_limit) \
_obstack_newchunk (__o, __len + 1); \
if (!__o->alloc_failed) \
{ \
bcopy ((char *) (where), __o->next_free, __len); \
__o->next_free += __len; \
*(__o->next_free)++ = 0; \
} \
(void) 0; })
#define obstack_1grow(OBSTACK,datum) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
if (__o->next_free + 1 > __o->chunk_limit) \
_obstack_newchunk (__o, 1); \
if (!__o->alloc_failed) \
*(__o->next_free)++ = (datum); \
(void) 0; })
/* These assume that the obstack alignment is good enough for pointers or ints,
and that the data added so far to the current object
shares that much alignment. */
#define obstack_ptr_grow(OBSTACK,datum) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
_obstack_newchunk (__o, sizeof (void *)); \
if (!__o->alloc_failed) \
*((void **)__o->next_free)++ = ((void *)datum); \
(void) 0; })
#define obstack_int_grow(OBSTACK,datum) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
if (__o->next_free + sizeof (int) > __o->chunk_limit) \
_obstack_newchunk (__o, sizeof (int)); \
if (!__o->alloc_failed) \
*((int *)__o->next_free)++ = ((int)datum); \
(void) 0; })
#define obstack_ptr_grow_fast(h,aptr) (*((void **)(h)->next_free)++ = (void *)aptr)
#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint)
#define obstack_blank(OBSTACK,length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
if (__o->chunk_limit - __o->next_free < __len) \
_obstack_newchunk (__o, __len); \
if (!__o->alloc_failed) \
__o->next_free += __len; \
(void) 0; })
#define obstack_alloc(OBSTACK,length) \
__extension__ \
({ struct obstack *__h = (OBSTACK); \
obstack_blank (__h, (length)); \
obstack_finish (__h); })
#define obstack_copy(OBSTACK,where,length) \
__extension__ \
({ struct obstack *__h = (OBSTACK); \
obstack_grow (__h, (where), (length)); \
obstack_finish (__h); })
#define obstack_copy0(OBSTACK,where,length) \
__extension__ \
({ struct obstack *__h = (OBSTACK); \
obstack_grow0 (__h, (where), (length)); \
obstack_finish (__h); })
/* The local variable is named __o1 to avoid a name conflict
when obstack_blank is called. */
#define obstack_finish(OBSTACK) \
__extension__ \
({ struct obstack *__o1 = (OBSTACK); \
void *value; \
if (__o1->alloc_failed) \
value = 0; \
else \
{ \
value = (void *) __o1->object_base; \
if (__o1->next_free == value) \
__o1->maybe_empty_object = 1; \
__o1->next_free \
= __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
& ~ (__o1->alignment_mask)); \
if (__o1->next_free - (char *)__o1->chunk \
> __o1->chunk_limit - (char *)__o1->chunk) \
__o1->next_free = __o1->chunk_limit; \
__o1->object_base = __o1->next_free; \
} \
value; })
#define obstack_free(OBSTACK, OBJ) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
void *__obj = (OBJ); \
if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
__o->next_free = __o->object_base = __obj; \
else (obstack_free) (__o, __obj); })
#else /* not __GNUC__ or not __STDC__ */
#define obstack_object_size(h) \
(unsigned) ((h)->alloc_failed ? 0 : (h)->next_free - (h)->object_base)
#define obstack_room(h) \
(unsigned) ((h)->chunk_limit - (h)->next_free)
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
so that we can avoid having void expressions
in the arms of the conditional expression.
Casting the third operand to void was tried before,
but some compilers won't accept it. */
#define obstack_grow(h,where,length) \
( (h)->temp = (length), \
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
((h)->alloc_failed ? 0 : \
(bcopy ((char *) (where), (h)->next_free, (h)->temp), \
(h)->next_free += (h)->temp)))
#define obstack_grow0(h,where,length) \
( (h)->temp = (length), \
(((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
((h)->alloc_failed ? 0 : \
(bcopy ((char *) (where), (h)->next_free, (h)->temp), \
(h)->next_free += (h)->temp, \
*((h)->next_free)++ = 0)))
#define obstack_1grow(h,datum) \
( (((h)->next_free + 1 > (h)->chunk_limit) \
? (_obstack_newchunk ((h), 1), 0) : 0), \
((h)->alloc_failed ? 0 : \
(*((h)->next_free)++ = (datum))))
#define obstack_ptr_grow(h,datum) \
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
((h)->alloc_failed ? 0 : \
(*((char **)(((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *)datum))))
#define obstack_int_grow(h,datum) \
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
((h)->alloc_failed ? 0 : \
(*((int *)(((h)->next_free+=sizeof(int))-sizeof(int))) = ((int)datum))))
#define obstack_ptr_grow_fast(h,aptr) (*((char **)(h)->next_free)++ = (char *)aptr)
#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint)
#define obstack_blank(h,length) \
( (h)->temp = (length), \
(((h)->chunk_limit - (h)->next_free < (h)->temp) \
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
((h)->alloc_failed ? 0 : \
((h)->next_free += (h)->temp)))
#define obstack_alloc(h,length) \
(obstack_blank ((h), (length)), obstack_finish ((h)))
#define obstack_copy(h,where,length) \
(obstack_grow ((h), (where), (length)), obstack_finish ((h)))
#define obstack_copy0(h,where,length) \
(obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
#define obstack_finish(h) \
( (h)->alloc_failed ? 0 : \
(((h)->next_free == (h)->object_base \
? (((h)->maybe_empty_object = 1), 0) \
: 0), \
(h)->temp = __PTR_TO_INT ((h)->object_base), \
(h)->next_free \
= __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
& ~ ((h)->alignment_mask)), \
(((h)->next_free - (char *)(h)->chunk \
> (h)->chunk_limit - (char *)(h)->chunk) \
? ((h)->next_free = (h)->chunk_limit) : 0), \
(h)->object_base = (h)->next_free, \
__INT_TO_PTR ((h)->temp)))
#if defined (__STDC__) && __STDC__
#define obstack_free(h,obj) \
( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
? (int) ((h)->next_free = (h)->object_base \
= (h)->temp + (char *) (h)->chunk) \
: (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
#else
#define obstack_free(h,obj) \
( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
? (int) ((h)->next_free = (h)->object_base \
= (h)->temp + (char *) (h)->chunk) \
: (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
#endif
#endif /* not __GNUC__ or not __STDC__ */
#endif /* not __OBSTACK_H__ */

53
lib/pathmax.h Normal file
View File

@@ -0,0 +1,53 @@
/* Define PATH_MAX somehow. Requires sys/types.h.
Copyright (C) 1992 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _PATHMAX_H
#define _PATHMAX_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define
PATH_MAX but might cause redefinition warnings when sys/param.h is
later included (as on MORE/BSD 4.3). */
#if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && !defined(__GNUC__))
#include <limits.h>
#endif
#ifndef _POSIX_PATH_MAX
#define _POSIX_PATH_MAX 255
#endif
#if !defined(PATH_MAX) && defined(_PC_PATH_MAX)
#define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX))
#endif
/* Don't include sys/param.h if it already has been. */
#if defined(HAVE_SYS_PARAM_H) && !defined(PATH_MAX) && !defined(MAXPATHLEN)
#include <sys/param.h>
#endif
#if !defined(PATH_MAX) && defined(MAXPATHLEN)
#define PATH_MAX MAXPATHLEN
#endif
#ifndef PATH_MAX
#define PATH_MAX _POSIX_PATH_MAX
#endif
#endif /* _PATHMAX_H */

978
lib/posixtm.c Normal file
View File

@@ -0,0 +1,978 @@
/* A Bison parser, made from ./posixtm.y with Bison version GNU Bison version 1.22
*/
#define YYBISON 1 /* Identify Bison output. */
#define DIGIT 258
#line 19 "./posixtm.y"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* The following block of alloca-related preprocessor directives is here
solely to allow compilation by non GNU-C compilers of the C parser
produced from this file by old versions of bison. Newer versions of
bison include a block similar to this one in bison.simple. */
#ifdef __GNUC__
#define alloca __builtin_alloca
#else
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#else
#ifdef _AIX
#pragma alloca
#else
void *alloca ();
#endif
#endif
#endif
#include <stdio.h>
#include <sys/types.h>
#ifdef TM_IN_SYS_TIME
#include <sys/time.h>
#else
#include <time.h>
#endif
/* Some old versions of bison generate parsers that use bcopy.
That loses on systems that don't provide the function, so we have
to redefine it here. */
#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
#define bcopy(from, to, len) memcpy ((to), (from), (len))
#endif
#define YYDEBUG 1
/* Lexical analyzer's current scan position in the input string. */
static char *curpos;
/* The return value. */
static struct tm t;
time_t mktime ();
#define zzparse posixtime_zzparse
static int zzlex ();
static int zzerror ();
#ifndef YYLTYPE
typedef
struct zzltype
{
int timestamp;
int first_line;
int first_column;
int last_line;
int last_column;
char *text;
}
zzltype;
#define YYLTYPE zzltype
#endif
#ifndef YYSTYPE
#define YYSTYPE int
#endif
#include <stdio.h>
#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif
#define YYFINAL 15
#define YYFLAG -32768
#define YYNTBASE 5
#define YYTRANSLATE(x) ((unsigned)(x) <= 258 ? zztranslate[x] : 9)
static const char zztranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 4, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 1, 2, 3
};
#if YYDEBUG != 0
static const short zzprhs[] = { 0,
0, 7, 9, 12, 13, 14, 17
};
static const short zzrhs[] = { 8,
8, 8, 8, 6, 7, 0, 8, 0, 8, 8,
0, 0, 0, 4, 8, 0, 3, 3, 0
};
#endif
#if YYDEBUG != 0
static const short zzrline[] = { 0,
78, 107, 114, 121, 132, 135, 144
};
static const char * const zztname[] = { "$","error","$illegal.","DIGIT","'.'",
"date","year","seconds","digitpair",""
};
#endif
static const short zzr1[] = { 0,
5, 6, 6, 6, 7, 7, 8
};
static const short zzr2[] = { 0,
6, 1, 2, 0, 0, 2, 2
};
static const short zzdefact[] = { 0,
0, 0, 7, 0, 0, 4, 5, 2, 0, 1,
3, 6, 0, 0, 0
};
static const short zzdefgoto[] = { 13,
7, 10, 2
};
static const short zzpact[] = { 2,
5, 2,-32768, 2, 2, 2, -3, 2, 2,-32768,
-32768,-32768, 9, 10,-32768
};
static const short zzpgoto[] = {-32768,
-32768,-32768, -2
};
#define YYLAST 10
static const short zztable[] = { 4,
9, 5, 6, 8, 1, 11, 12, 3, 14, 15
};
static const short zzcheck[] = { 2,
4, 4, 5, 6, 3, 8, 9, 3, 0, 0
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "/usr/local/lib/bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C. */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
#pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc. */
#endif /* not GNU C. */
#endif /* alloca not defined. */
/* This is the parser code that is written into each bison parser
when the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
as one case of the switch. */
#define zzerrok (zzerrstatus = 0)
#define zzclearin (zzchar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT return(0)
#define YYABORT return(1)
#define YYERROR goto zzerrlab1
/* Like YYERROR except do call zzerror.
This remains here temporarily to ease the
transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto zzerrlab
#define YYRECOVERING() (!!zzerrstatus)
#define YYBACKUP(token, value) \
do \
if (zzchar == YYEMPTY && zzlen == 1) \
{ zzchar = (token), zzlval = (value); \
zzchar1 = YYTRANSLATE (zzchar); \
YYPOPSTACK; \
goto zzbackup; \
} \
else \
{ zzerror ("syntax error: cannot back up"); YYERROR; } \
while (0)
#define YYTERROR 1
#define YYERRCODE 256
#ifndef YYPURE
#define YYLEX zzlex()
#endif
#ifdef YYPURE
#ifdef YYLSP_NEEDED
#define YYLEX zzlex(&zzlval, &zzlloc)
#else
#define YYLEX zzlex(&zzlval)
#endif
#endif
/* If nonreentrant, generate the variables here */
#ifndef YYPURE
int zzchar; /* the lookahead symbol */
YYSTYPE zzlval; /* the semantic value of the */
/* lookahead symbol */
#ifdef YYLSP_NEEDED
YYLTYPE zzlloc; /* location data for the lookahead */
/* symbol */
#endif
int zznerrs; /* number of parse errors so far */
#endif /* not YYPURE */
#if YYDEBUG != 0
int zzdebug; /* nonzero means print parse trace */
/* Since this is uninitialized, it does not stop multiple parsers
from coexisting. */
#endif
/* YYINITDEPTH indicates the initial size of the parser's stacks */
#ifndef YYINITDEPTH
#define YYINITDEPTH 200
#endif
/* YYMAXDEPTH is the maximum size the stacks can grow to
(effective only if the built-in stack extension method is used). */
#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
/* Prevent warning if -Wstrict-prototypes. */
#ifdef __GNUC__
int zzparse (void);
#endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#define __zz_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__zz_bcopy (from, to, count)
char *from;
char *to;
int count;
{
register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
*t++ = *f++;
}
#else /* __cplusplus */
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__zz_bcopy (char *from, char *to, int count)
{
register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
*t++ = *f++;
}
#endif
#endif
#line 184 "/usr/local/lib/bison.simple"
int
zzparse()
{
register int zzstate;
register int zzn;
register short *zzssp;
register YYSTYPE *zzvsp;
int zzerrstatus; /* number of tokens to shift before error messages enabled */
int zzchar1 = 0; /* lookahead token as an internal (translated) token number */
short zzssa[YYINITDEPTH]; /* the state stack */
YYSTYPE zzvsa[YYINITDEPTH]; /* the semantic value stack */
short *zzss = zzssa; /* refer to the stacks thru separate pointers */
YYSTYPE *zzvs = zzvsa; /* to allow zzoverflow to reallocate them elsewhere */
#ifdef YYLSP_NEEDED
YYLTYPE zzlsa[YYINITDEPTH]; /* the location stack */
YYLTYPE *zzls = zzlsa;
YYLTYPE *zzlsp;
#define YYPOPSTACK (zzvsp--, zzssp--, zzlsp--)
#else
#define YYPOPSTACK (zzvsp--, zzssp--)
#endif
int zzstacksize = YYINITDEPTH;
#ifdef YYPURE
int zzchar;
YYSTYPE zzlval;
int zznerrs;
#ifdef YYLSP_NEEDED
YYLTYPE zzlloc;
#endif
#endif
YYSTYPE zzval; /* the variable used to return */
/* semantic values from the action */
/* routines */
int zzlen;
#if YYDEBUG != 0
if (zzdebug)
fprintf(stderr, "Starting parse\n");
#endif
zzstate = 0;
zzerrstatus = 0;
zznerrs = 0;
zzchar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
zzssp = zzss - 1;
zzvsp = zzvs;
#ifdef YYLSP_NEEDED
zzlsp = zzls;
#endif
/* Push a new state, which is found in zzstate . */
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks. */
zznewstate:
*++zzssp = zzstate;
if (zzssp >= zzss + zzstacksize - 1)
{
/* Give user a chance to reallocate the stack */
/* Use copies of these so that the &'s don't force the real ones into memory. */
YYSTYPE *zzvs1 = zzvs;
short *zzss1 = zzss;
#ifdef YYLSP_NEEDED
YYLTYPE *zzls1 = zzls;
#endif
/* Get the current used size of the three stacks, in elements. */
int size = zzssp - zzss + 1;
#ifdef zzoverflow
/* Each stack pointer address is followed by the size of
the data in use in that stack, in bytes. */
#ifdef YYLSP_NEEDED
/* This used to be a conditional around just the two extra args,
but that might be undefined if zzoverflow is a macro. */
zzoverflow("parser stack overflow",
&zzss1, size * sizeof (*zzssp),
&zzvs1, size * sizeof (*zzvsp),
&zzls1, size * sizeof (*zzlsp),
&zzstacksize);
#else
zzoverflow("parser stack overflow",
&zzss1, size * sizeof (*zzssp),
&zzvs1, size * sizeof (*zzvsp),
&zzstacksize);
#endif
zzss = zzss1; zzvs = zzvs1;
#ifdef YYLSP_NEEDED
zzls = zzls1;
#endif
#else /* no zzoverflow */
/* Extend the stack our own way. */
if (zzstacksize >= YYMAXDEPTH)
{
zzerror("parser stack overflow");
return 2;
}
zzstacksize *= 2;
if (zzstacksize > YYMAXDEPTH)
zzstacksize = YYMAXDEPTH;
zzss = (short *) alloca (zzstacksize * sizeof (*zzssp));
__zz_bcopy ((char *)zzss1, (char *)zzss, size * sizeof (*zzssp));
zzvs = (YYSTYPE *) alloca (zzstacksize * sizeof (*zzvsp));
__zz_bcopy ((char *)zzvs1, (char *)zzvs, size * sizeof (*zzvsp));
#ifdef YYLSP_NEEDED
zzls = (YYLTYPE *) alloca (zzstacksize * sizeof (*zzlsp));
__zz_bcopy ((char *)zzls1, (char *)zzls, size * sizeof (*zzlsp));
#endif
#endif /* no zzoverflow */
zzssp = zzss + size - 1;
zzvsp = zzvs + size - 1;
#ifdef YYLSP_NEEDED
zzlsp = zzls + size - 1;
#endif
#if YYDEBUG != 0
if (zzdebug)
fprintf(stderr, "Stack size increased to %d\n", zzstacksize);
#endif
if (zzssp >= zzss + zzstacksize - 1)
YYABORT;
}
#if YYDEBUG != 0
if (zzdebug)
fprintf(stderr, "Entering state %d\n", zzstate);
#endif
goto zzbackup;
zzbackup:
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
/* zzresume: */
/* First try to decide what to do without reference to lookahead token. */
zzn = zzpact[zzstate];
if (zzn == YYFLAG)
goto zzdefault;
/* Not known => get a lookahead token if don't already have one. */
/* zzchar is either YYEMPTY or YYEOF
or a valid token in external form. */
if (zzchar == YYEMPTY)
{
#if YYDEBUG != 0
if (zzdebug)
fprintf(stderr, "Reading a token: ");
#endif
zzchar = YYLEX;
}
/* Convert token to internal form (in zzchar1) for indexing tables with */
if (zzchar <= 0) /* This means end of input. */
{
zzchar1 = 0;
zzchar = YYEOF; /* Don't call YYLEX any more */
#if YYDEBUG != 0
if (zzdebug)
fprintf(stderr, "Now at end of input.\n");
#endif
}
else
{
zzchar1 = YYTRANSLATE(zzchar);
#if YYDEBUG != 0
if (zzdebug)
{
fprintf (stderr, "Next token is %d (%s", zzchar, zztname[zzchar1]);
/* Give the individual parser a way to print the precise meaning
of a token, for further debugging info. */
#ifdef YYPRINT
YYPRINT (stderr, zzchar, zzlval);
#endif
fprintf (stderr, ")\n");
}
#endif
}
zzn += zzchar1;
if (zzn < 0 || zzn > YYLAST || zzcheck[zzn] != zzchar1)
goto zzdefault;
zzn = zztable[zzn];
/* zzn is what to do for this token type in this state.
Negative => reduce, -zzn is rule number.
Positive => shift, zzn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (zzn < 0)
{
if (zzn == YYFLAG)
goto zzerrlab;
zzn = -zzn;
goto zzreduce;
}
else if (zzn == 0)
goto zzerrlab;
if (zzn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
#if YYDEBUG != 0
if (zzdebug)
fprintf(stderr, "Shifting token %d (%s), ", zzchar, zztname[zzchar1]);
#endif
/* Discard the token being shifted unless it is eof. */
if (zzchar != YYEOF)
zzchar = YYEMPTY;
*++zzvsp = zzlval;
#ifdef YYLSP_NEEDED
*++zzlsp = zzlloc;
#endif
/* count tokens shifted since error; after three, turn off error status. */
if (zzerrstatus) zzerrstatus--;
zzstate = zzn;
goto zznewstate;
/* Do the default action for the current state. */
zzdefault:
zzn = zzdefact[zzstate];
if (zzn == 0)
goto zzerrlab;
/* Do a reduction. zzn is the number of a rule to reduce with. */
zzreduce:
zzlen = zzr2[zzn];
if (zzlen > 0)
zzval = zzvsp[1-zzlen]; /* implement default value of the action */
#if YYDEBUG != 0
if (zzdebug)
{
int i;
fprintf (stderr, "Reducing via rule %d (line %d), ",
zzn, zzrline[zzn]);
/* Print the symbols being reduced, and their result. */
for (i = zzprhs[zzn]; zzrhs[i] > 0; i++)
fprintf (stderr, "%s ", zztname[zzrhs[i]]);
fprintf (stderr, " -> %s\n", zztname[zzr1[zzn]]);
}
#endif
switch (zzn) {
case 1:
#line 84 "./posixtm.y"
{
if (zzvsp[-5] >= 1 && zzvsp[-5] <= 12)
t.tm_mon = zzvsp[-5] - 1;
else {
YYABORT;
}
if (zzvsp[-4] >= 1 && zzvsp[-4] <= 31)
t.tm_mday = zzvsp[-4];
else {
YYABORT;
}
if (zzvsp[-3] >= 0 && zzvsp[-3] <= 23)
t.tm_hour = zzvsp[-3];
else {
YYABORT;
}
if (zzvsp[-2] >= 0 && zzvsp[-2] <= 59)
t.tm_min = zzvsp[-2];
else {
YYABORT;
}
;
break;}
case 2:
#line 107 "./posixtm.y"
{
t.tm_year = zzvsp[0];
/* Deduce the century based on the year.
See POSIX.2 section 4.63.3. */
if (zzvsp[0] <= 68)
t.tm_year += 100;
;
break;}
case 3:
#line 114 "./posixtm.y"
{
t.tm_year = zzvsp[-1] * 100 + zzvsp[0];
if (t.tm_year < 1900) {
YYABORT;
} else
t.tm_year -= 1900;
;
break;}
case 4:
#line 121 "./posixtm.y"
{
time_t now;
struct tm *tmp;
/* Use current year. */
time (&now);
tmp = localtime (&now);
t.tm_year = tmp->tm_year;
;
break;}
case 5:
#line 132 "./posixtm.y"
{
t.tm_sec = 0;
;
break;}
case 6:
#line 135 "./posixtm.y"
{
if (zzvsp[0] >= 0 && zzvsp[0] <= 61)
t.tm_sec = zzvsp[0];
else {
YYABORT;
}
;
break;}
case 7:
#line 144 "./posixtm.y"
{
zzval = zzvsp[-1] * 10 + zzvsp[0];
;
break;}
}
/* the action file gets copied in in place of this dollarsign */
#line 465 "/usr/local/lib/bison.simple"
zzvsp -= zzlen;
zzssp -= zzlen;
#ifdef YYLSP_NEEDED
zzlsp -= zzlen;
#endif
#if YYDEBUG != 0
if (zzdebug)
{
short *ssp1 = zzss - 1;
fprintf (stderr, "state stack now");
while (ssp1 != zzssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
*++zzvsp = zzval;
#ifdef YYLSP_NEEDED
zzlsp++;
if (zzlen == 0)
{
zzlsp->first_line = zzlloc.first_line;
zzlsp->first_column = zzlloc.first_column;
zzlsp->last_line = (zzlsp-1)->last_line;
zzlsp->last_column = (zzlsp-1)->last_column;
zzlsp->text = 0;
}
else
{
zzlsp->last_line = (zzlsp+zzlen-1)->last_line;
zzlsp->last_column = (zzlsp+zzlen-1)->last_column;
}
#endif
/* Now "shift" the result of the reduction.
Determine what state that goes to,
based on the state we popped back to
and the rule number reduced by. */
zzn = zzr1[zzn];
zzstate = zzpgoto[zzn - YYNTBASE] + *zzssp;
if (zzstate >= 0 && zzstate <= YYLAST && zzcheck[zzstate] == *zzssp)
zzstate = zztable[zzstate];
else
zzstate = zzdefgoto[zzn - YYNTBASE];
goto zznewstate;
zzerrlab: /* here on detecting error */
if (! zzerrstatus)
/* If not already recovering from an error, report this error. */
{
++zznerrs;
#ifdef YYERROR_VERBOSE
zzn = zzpact[zzstate];
if (zzn > YYFLAG && zzn < YYLAST)
{
int size = 0;
char *msg;
int x, count;
count = 0;
/* Start X at -zzn if nec to avoid negative indexes in zzcheck. */
for (x = (zzn < 0 ? -zzn : 0);
x < (sizeof(zztname) / sizeof(char *)); x++)
if (zzcheck[x + zzn] == x)
size += strlen(zztname[x]) + 15, count++;
msg = (char *) malloc(size + 15);
if (msg != 0)
{
strcpy(msg, "parse error");
if (count < 5)
{
count = 0;
for (x = (zzn < 0 ? -zzn : 0);
x < (sizeof(zztname) / sizeof(char *)); x++)
if (zzcheck[x + zzn] == x)
{
strcat(msg, count == 0 ? ", expecting `" : " or `");
strcat(msg, zztname[x]);
strcat(msg, "'");
count++;
}
}
zzerror(msg);
free(msg);
}
else
zzerror ("parse error; also virtual memory exceeded");
}
else
#endif /* YYERROR_VERBOSE */
zzerror("parse error");
}
goto zzerrlab1;
zzerrlab1: /* here on error raised explicitly by an action */
if (zzerrstatus == 3)
{
/* if just tried and failed to reuse lookahead token after an error, discard it. */
/* return failure if at end of input */
if (zzchar == YYEOF)
YYABORT;
#if YYDEBUG != 0
if (zzdebug)
fprintf(stderr, "Discarding token %d (%s).\n", zzchar, zztname[zzchar1]);
#endif
zzchar = YYEMPTY;
}
/* Else will try to reuse lookahead token
after shifting the error token. */
zzerrstatus = 3; /* Each real token shifted decrements this */
goto zzerrhandle;
zzerrdefault: /* current state does not do anything special for the error token. */
#if 0
/* This is wrong; only states that explicitly want error tokens
should shift them. */
zzn = zzdefact[zzstate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
if (zzn) goto zzdefault;
#endif
zzerrpop: /* pop the current state because it cannot handle the error token */
if (zzssp == zzss) YYABORT;
zzvsp--;
zzstate = *--zzssp;
#ifdef YYLSP_NEEDED
zzlsp--;
#endif
#if YYDEBUG != 0
if (zzdebug)
{
short *ssp1 = zzss - 1;
fprintf (stderr, "Error: state stack now");
while (ssp1 != zzssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
zzerrhandle:
zzn = zzpact[zzstate];
if (zzn == YYFLAG)
goto zzerrdefault;
zzn += YYTERROR;
if (zzn < 0 || zzn > YYLAST || zzcheck[zzn] != YYTERROR)
goto zzerrdefault;
zzn = zztable[zzn];
if (zzn < 0)
{
if (zzn == YYFLAG)
goto zzerrpop;
zzn = -zzn;
goto zzreduce;
}
else if (zzn == 0)
goto zzerrpop;
if (zzn == YYFINAL)
YYACCEPT;
#if YYDEBUG != 0
if (zzdebug)
fprintf(stderr, "Shifting error token, ");
#endif
*++zzvsp = zzlval;
#ifdef YYLSP_NEEDED
*++zzlsp = zzlloc;
#endif
zzstate = zzn;
goto zznewstate;
}
#line 148 "./posixtm.y"
static int
zzlex ()
{
char ch = *curpos++;
if (ch >= '0' && ch <= '9')
{
zzlval = ch - '0';
return DIGIT;
}
else if (ch == '.' || ch == 0)
return ch;
else
return '?'; /* Cause an error. */
}
static int
zzerror ()
{
return 0;
}
/* Parse a POSIX-style date and return it, or (time_t)-1 for an error. */
time_t
posixtime (s)
char *s;
{
curpos = s;
/* Let mktime decide whether it is daylight savings time. */
t.tm_isdst = -1;
if (zzparse ())
return (time_t)-1;
else
return mktime (&t);
}
/* Parse a POSIX-style date and return it, or NULL for an error. */
struct tm *
posixtm (s)
char *s;
{
if (posixtime (s) == -1)
return NULL;
return &t;
}

View File

@@ -1,64 +1,65 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
/* Copyright (C) 1991, 1994 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
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
Library General Public License for more details.
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 Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <sys/types.h>
#include <errno.h>
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* Define-away any (possibly conflicting) prototype of putenv.
Many systems omit the `const' attribute on the argument. */
#define putenv _sys_putenv
#if defined (__GNU_LIBRARY__) || defined (HAVE_STDLIB_H)
#include <stdlib.h>
#endif /* GNU C library. */
#ifndef STDC_HEADERS
extern int errno;
#endif
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#if defined (__GNU_LIBRARY__) || defined (HAVE_STRING_H)
#include <string.h>
#ifndef index
#define index strchr
#endif
#ifndef bcopy
#define bcopy(s, d, n) memcpy((d), (s), (n))
#endif
#else
#include <strings.h>
#endif
#ifdef HAVE_UNISTD_H
#if defined (__GNU_LIBRARY__) || defined (HAVE_UNISTD_H)
#include <unistd.h>
#endif
#ifndef NULL
#define NULL 0
#undef putenv
#if !defined (__GNU_LIBRARY__) && !defined (HAVE_STRCHR)
#define strchr index
#endif
#if !defined (__GNU_LIBRARY__) && !defined (HAVE_MEMCPY)
#define memcpy(d,s,n) bcopy ((s), (d), (n))
#endif
#if HAVE_GNU_LD
#define environ __environ
#else
extern char **environ;
#endif
/* Put STRING, which is of the form "NAME=VALUE", in the environment. */
int
putenv (string)
const char *string;
{
char *name_end = index (string, '=');
const char *const name_end = strchr (string, '=');
register size_t size;
register char **ep;
@@ -93,11 +94,12 @@ putenv (string)
char **new_environ = (char **) malloc ((size + 2) * sizeof (char *));
if (new_environ == NULL)
return -1;
(void) bcopy ((char *) environ, (char *) new_environ, size * sizeof (char *));
(void) memcpy ((void *) new_environ, (void *) environ,
size * sizeof (char *));
new_environ[size] = (char *) string;
new_environ[size + 1] = NULL;
if (last_environ != NULL)
free ((char *) last_environ);
free ((void *) last_environ);
last_environ = new_environ;
environ = new_environ;
}

223
lib/readtokens.c Normal file
View File

@@ -0,0 +1,223 @@
/* readtokens.c -- Functions for reading tokens from an input stream.
Copyright (C) 1990-1991 Jim Meyering.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
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., 675 Mass Ave, Cambridge, MA 02139, USA.
Written by Jim Meyering. */
/* This almost supercedes xreadline stuff -- using delim="\n"
gives the same functionality, except that these functions
would never return empty lines.
To Do:
- To allow '\0' as a delimiter, I will have to change
interfaces to permit specification of delimiter-string
length.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
#if defined (STDC_HEADERS) || defined(HAVE_STRING_H)
#include <string.h>
/* An ANSI string.h and pre-ANSI memory.h might conflict. */
#if !defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
#include <memory.h>
#endif /* not STDC_HEADERS and HAVE_MEMORY_H */
#else /* not STDC_HEADERS and not HAVE_STRING_H */
#include <strings.h>
/* memory.h and strings.h conflict on some systems. */
#endif /* not STDC_HEADERS and not HAVE_STRING_H */
#include "readtokens.h"
void *xmalloc ();
void *xrealloc ();
#define STREQ(a,b) ((a) == (b) || ((a) && (b) && *(a) == *(b) \
&& strcmp(a, b) == 0))
/* Initialize a tokenbuffer. */
void
init_tokenbuffer (tokenbuffer)
token_buffer *tokenbuffer;
{
tokenbuffer->size = INITIAL_TOKEN_LENGTH;
tokenbuffer->buffer = ((char *) xmalloc (INITIAL_TOKEN_LENGTH));
}
/* Read a token from `stream' into `tokenbuffer'.
Upon return, the token is in tokenbuffer->buffer and
has a trailing '\0' instead of the original delimiter.
The function value is the length of the token not including
the final '\0'. When EOF is reached (i.e. on the call
after the last token is read), -1 is returned and tokenbuffer
isn't modified.
This function will work properly on lines containing NUL bytes
and on files that aren't newline-terminated. */
long
readtoken (stream, delim, n_delim, tokenbuffer)
FILE *stream;
const char *delim;
int n_delim;
token_buffer *tokenbuffer;
{
char *p;
int c, i, n;
static const char *saved_delim = NULL;
static char isdelim[256];
int same_delimiters;
if (delim == NULL && saved_delim == NULL)
abort ();
same_delimiters = 0;
if (delim != saved_delim && saved_delim != NULL)
{
same_delimiters = 1;
for (i = 0; i < n_delim; i++)
{
if (delim[i] != saved_delim[i])
{
same_delimiters = 0;
break;
}
}
}
if (!same_delimiters)
{
const char *t;
saved_delim = delim;
for (i = 0; i < sizeof (isdelim); i++)
isdelim[i] = 0;
for (t = delim; *t; t++)
isdelim[(unsigned int) *t] = 1;
}
p = tokenbuffer->buffer;
n = tokenbuffer->size;
i = 0;
/* FIXME: don't fool with this caching BS. Use strchr instead. */
/* skip over any leading delimiters */
for (c = getc (stream); c >= 0 && isdelim[c]; c = getc (stream))
{
/* empty */
}
for (;;)
{
if (i >= n)
{
n = 3 * (n / 2 + 1);
p = xrealloc (p, (unsigned int) n);
}
if (c < 0)
{
if (i == 0)
return (-1);
p[i] = 0;
break;
}
if (isdelim[c])
{
p[i] = 0;
break;
}
p[i++] = c;
c = getc (stream);
}
tokenbuffer->buffer = p;
tokenbuffer->size = n;
return (i);
}
/* Return a NULL-terminated array of pointers to tokens
read from `stream.' The number of tokens is returned
as the value of the function.
All storage is obtained through calls to malloc();
%%% Question: is it worth it to do a single
%%% realloc() of `tokens' just before returning? */
int
readtokens (stream, projected_n_tokens, delim, n_delim,
tokens_out, token_lengths)
FILE *stream;
int projected_n_tokens;
const char *delim;
int n_delim;
char ***tokens_out;
long **token_lengths;
{
token_buffer tb, *token = &tb;
int token_length;
char **tokens;
long *lengths;
int sz;
int n_tokens;
n_tokens = 0;
if (projected_n_tokens > 0)
projected_n_tokens++; /* add one for trailing NULL pointer */
else
projected_n_tokens = 64;
sz = projected_n_tokens;
tokens = (char **) xmalloc (sz * sizeof (char *));
lengths = (long *) xmalloc (sz * sizeof (long));
init_tokenbuffer (token);
for (;;)
{
char *tmp;
token_length = readtoken (stream, delim, n_delim, token);
if (n_tokens >= sz)
{
sz *= 2;
tokens = (char **) xrealloc (tokens, sz * sizeof (char *));
lengths = (long *) xrealloc (lengths, sz * sizeof (long));
}
if (token_length < 0)
{
/* don't increment n_tokens for NULL entry */
tokens[n_tokens] = NULL;
lengths[n_tokens] = -1;
break;
}
tmp = (char *) xmalloc ((token_length + 1) * sizeof (char));
lengths[n_tokens] = token_length;
tokens[n_tokens] = strncpy (tmp, token->buffer,
(unsigned) (token_length + 1));
n_tokens++;
}
free (token->buffer);
*tokens_out = tokens;
if (token_lengths != NULL)
*token_lengths = lengths;
return n_tokens;
}

36
lib/readtokens.h Normal file
View File

@@ -0,0 +1,36 @@
#ifndef H_READTOKENS_H
#define H_READTOKENS_H
#ifndef INITIAL_TOKEN_LENGTH
#define INITIAL_TOKEN_LENGTH 20
#endif
#ifndef TOKENBUFFER_DEFINED
#define TOKENBUFFER_DEFINED
struct tokenbuffer
{
long size;
char *buffer;
};
typedef struct tokenbuffer token_buffer;
#endif /* not TOKENBUFFER_DEFINED */
#undef __P
#if defined (__STDC__) && __STDC__
#define __P(x) x
#else
#define __P(x) ()
#endif
void init_tokenbuffer __P ((token_buffer *tokenbuffer));
long
readtoken __P ((FILE *stream, const char *delim, int n_delim,
token_buffer *tokenbuffer));
int
readtokens __P ((FILE *stream, int projected_n_tokens,
const char *delim, int n_delim,
char ***tokens_out, long **token_lengths));
#endif /* not H_READTOKENS_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/* Definitions for data structures and routines for the regular
expression library, version 0.11.
expression library, version 0.12.
Copyright (C) 1985, 89, 90, 91, 92 Free Software Foundation, Inc.
Copyright (C) 1985, 89, 90, 91, 92, 93, 95 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,7 +20,15 @@
#ifndef __REGEXP_LIBRARY_H__
#define __REGEXP_LIBRARY_H__
/* POSIX says that <sys/types.h> must be included before <regex.h>. */
/* POSIX says that <sys/types.h> must be included (by the caller) before
<regex.h>. */
#if !defined (_POSIX_C_SOURCE) && !defined (_POSIX_SOURCE) && defined (VMS)
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
should be there. */
#include <stddef.h>
#endif
/* The following bits are used to determine the regexp syntax we
recognize. The set/not-set meanings are chosen so that Emacs syntax
@@ -122,6 +130,10 @@ typedef unsigned reg_syntax_t;
If not set, then an unmatched ) is invalid. */
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
/* If this bit is set, succeed as soon as we match the whole pattern,
without further backtracking. */
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
/* This global variable defines the particular regexp syntax to use (for
some interfaces). When a regexp is compiled, the syntax used is
stored in the pattern buffer, so changing this does not affect
@@ -137,7 +149,7 @@ extern reg_syntax_t re_syntax_options;
#define RE_SYNTAX_AWK \
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
| RE_NO_BK_VAR | RE_NO_EMPTY_RANGES \
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
| RE_UNMATCHED_RIGHT_PAREN_ORD)
#define RE_SYNTAX_POSIX_AWK \
@@ -157,6 +169,9 @@ extern reg_syntax_t re_syntax_options;
#define RE_SYNTAX_POSIX_EGREP \
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
/* Syntax bits common to both basic and extended POSIX regex syntax. */
@@ -264,6 +279,10 @@ typedef enum
compiled, the `re_nsub' field is available. All other fields are
private to the regex routines. */
#ifndef RE_TRANSLATE_TYPE
#define RE_TRANSLATE_TYPE char *
#endif
struct re_pattern_buffer
{
/* [[[begin pattern_buffer]]] */
@@ -290,7 +309,7 @@ struct re_pattern_buffer
comparing them, or zero for no translation. The translation
is applied to a pattern when it is compiled and to a string
when it is matched. */
char *translate;
RE_TRANSLATE_TYPE translate;
/* Number of subexpressions found by the compiler. */
size_t re_nsub;
@@ -311,12 +330,12 @@ struct re_pattern_buffer
#define REGS_FIXED 2
unsigned regs_allocated : 2;
/* Set to zero when regex_compile compiles a pattern; set to one
by re_compile_fastmap when it updates the fastmap, if any. */
/* Set to zero when `regex_compile' compiles a pattern; set to one
by `re_compile_fastmap' if it updates the fastmap. */
unsigned fastmap_accurate : 1;
/* If set, regexec reports only success or failure and does not
return anything in pmatch. */
/* If set, `re_match_2' does not return information about
subexpressions. */
unsigned no_sub : 1;
/* If set, a beginning-of-line anchor doesn't match at the
@@ -333,11 +352,6 @@ struct re_pattern_buffer
};
typedef struct re_pattern_buffer regex_t;
/* search.c (search_buffer) in Emacs needs this one opcode value. It is
defined both in `regex.c' and here. */
#define RE_EXACTN_VALUE 1
/* Type for byte offsets within the string. POSIX mandates this. */
typedef int regoff_t;
@@ -376,19 +390,17 @@ typedef struct
prototype (if we are ANSI), and once without (if we aren't) -- we
use the following macro to declare argument types. This
unfortunately clutters up the declarations a bit, but I think it's
worth it.
We also have to undo `const' if we are not ANSI and if it hasn't
previously being taken care of. */
worth it. */
#if __STDC__
#define _RE_ARGS(args) args
#else
#else /* not __STDC__ */
#define _RE_ARGS(args) ()
#ifndef const
#define const
#endif
#endif
#endif /* not __STDC__ */
/* Sets the current default syntax to SYNTAX, and return the old syntax.
You can also simply assign to the `re_syntax_options' variable. */
@@ -456,9 +468,11 @@ extern void re_set_registers
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
unsigned num_regs, regoff_t *starts, regoff_t *ends));
#ifdef _REGEX_RE_COMP
/* 4.2 bsd compatibility. */
extern char *re_comp _RE_ARGS ((const char *));
extern int re_exec _RE_ARGS ((const char *));
#endif
/* POSIX compatibility. */
extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags));

View File

@@ -15,15 +15,23 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#ifndef STDC_HEADERS
#ifndef errno
extern int errno;
#endif
#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
#endif /* STAT_MACROS_BROKEN. */
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
/* Rename file FROM to file TO.
@@ -34,14 +42,30 @@ rename (from, to)
char *from;
char *to;
{
struct stat from_stats;
struct stat from_stats, to_stats;
int pid, status;
if (stat (from, &from_stats))
return -1;
if (unlink (to) && errno != ENOENT)
return -1;
/* Be careful not to unlink `from' if it happens to be equal to `to' or
(on filesystems that silently truncate filenames after 14 characters)
if `from' and `to' share the significant characters. */
if (stat (to, &to_stats))
{
if (errno != ENOENT)
return -1;
}
else
{
if ((from_stats.st_dev == to_stats.st_dev)
&& (from_stats.st_ino == to_stats.st_ino))
/* `from' and `to' designate the same file on that filesystem. */
return 0;
if (unlink (to) && errno != ENOENT)
return -1;
}
if (S_ISDIR (from_stats.st_mode))
{

86
lib/rmdir.c Normal file
View File

@@ -0,0 +1,86 @@
/* rmdir.c -- BSD compatible remove directory function for System V
Copyright (C) 1988, 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
#endif
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
/* rmdir adapted from GNU tar. */
/* Remove directory DPATH.
Return 0 if successful, -1 if not. */
int
rmdir (dpath)
char *dpath;
{
int cpid, status;
struct stat statbuf;
if (stat (dpath, &statbuf) != 0)
return -1; /* errno already set */
if (!S_ISDIR (statbuf.st_mode))
{
errno = ENOTDIR;
return -1;
}
cpid = fork ();
switch (cpid)
{
case -1: /* cannot fork */
return -1; /* errno already set */
case 0: /* child process */
execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
_exit (1);
default: /* parent process */
/* Wait for kid to finish. */
while (wait (&status) != cpid)
/* Do nothing. */ ;
if (status & 0xFFFF)
{
/* /bin/rmdir failed. */
errno = EIO;
return -1;
}
return 0;
}
}

7190
lib/rx.c Normal file

File diff suppressed because it is too large Load Diff

3732
lib/rx.h Normal file

File diff suppressed because it is too large Load Diff

60
lib/safe-read.c Normal file
View File

@@ -0,0 +1,60 @@
/* safe-read.c -- an interface to read that retries after interrupts
Copyright (C) 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
#ifndef errno
extern int errno;
#endif
/* Read LEN bytes at PTR from descriptor DESC, retrying if interrupted.
Return the actual number of bytes read, zero for EOF, or negative
for an error. */
int
safe_read (desc, ptr, len)
int desc;
char *ptr;
int len;
{
int n_chars;
if (len <= 0)
return len;
#ifdef EINTR
do
{
n_chars = read (desc, ptr, len);
}
while (n_chars < 0 && errno == EINTR);
#else
n_chars = read (desc, ptr, len);
#endif
return n_chars;
}

155
lib/save-cwd.c Normal file
View File

@@ -0,0 +1,155 @@
/* save-cwd.c -- Save and restore current working directory.
Copyright (C) 1995 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Written by Jim Meyering <meyering@na-net.ornl.gov>. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#else
# include <sys/file.h>
#endif
#include <errno.h>
# ifndef errno
extern int errno;
#endif
#include "save-cwd.h"
#include "error.h"
char *xgetcwd __P((void));
/* Record the location of the current working directory in CWD so that
the program may change to other directories and later use restore_cwd
to return to the recorded location. This function may allocate
space using malloc (via xgetcwd) or leave a file descriptor open;
use free_cwd to perform the necessary free or close. Upon failure,
no memory is allocated, any locally opened file descriptors are
closed; return non-zero -- in that case, free_cwd need not be
called, but doing so is ok. Otherwise, return zero. */
int
save_cwd (cwd)
struct saved_cwd *cwd;
{
static int have_working_fchdir = 1;
cwd->desc = -1;
cwd->name = NULL;
if (have_working_fchdir)
{
#ifdef HAVE_FCHDIR
cwd->desc = open (".", O_RDONLY);
if (cwd->desc < 0)
{
error (0, errno, "cannot open current directory");
return 1;
}
# if __sun__ || sun
/* On SunOS 4, fchdir returns EINVAL if accounting is enabled,
so we have to fall back to chdir. */
if (fchdir (cwd->desc))
{
if (errno == EINVAL)
{
close (cwd->desc);
cwd->desc = -1;
have_working_fchdir = 0;
}
else
{
error (0, errno, "current directory");
close (cwd->desc);
cwd->desc = -1;
return 1;
}
}
# endif /* __sun__ || sun */
#else
#define fchdir(x) (abort (), 0)
have_working_fchdir = 0;
#endif
}
if (!have_working_fchdir)
{
cwd->name = xgetcwd ();
if (cwd->name == NULL)
{
error (0, errno, "cannot get current directory");
return 1;
}
}
return 0;
}
/* Change to recorded location, CWD, in directory hierarchy.
If "saved working directory", NULL))
*/
int
restore_cwd (cwd, dest, from)
const struct saved_cwd *cwd;
const char *dest;
const char *from;
{
int fail = 0;
if (cwd->desc >= 0)
{
if (fchdir (cwd->desc))
{
error (0, errno, "cannot return to %s%s%s",
(dest ? dest : "saved working directory"),
(from ? " from " : ""),
(from ? from : ""));
fail = 1;
}
}
else if (chdir (cwd->name) < 0)
{
error (0, errno, "%s", cwd->name);
fail = 1;
}
return fail;
}
void
free_cwd (cwd)
struct saved_cwd *cwd;
{
if (cwd->desc >= 0)
close (cwd->desc);
if (cwd->name)
free (cwd->name);
}

23
lib/save-cwd.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef SAVE_CWD_H
#define SAVE_CWD_H 1
struct saved_cwd
{
int desc;
char *name;
};
#ifndef __P
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
#define __P(args) args
#else
#define __P(args) ()
#endif /* GCC. */
#endif /* Not __P. */
int save_cwd __P((struct saved_cwd *cwd));
int restore_cwd __P((const struct saved_cwd *cwd, const char *dest,
const char *from));
void free_cwd __P((struct saved_cwd *cwd));
#endif /* SAVE_CWD_H */

View File

@@ -15,30 +15,36 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Written by David MacKenzie <djm@ai.mit.edu>. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#ifdef DIRENT
#include <dirent.h>
#ifdef direct
#undef direct
#endif
#define direct dirent
#define NLENGTH(direct) (strlen((direct)->d_name))
#else
#define NLENGTH(direct) ((direct)->d_namlen)
#ifdef USG
#ifdef SYSNDIR
#include <sys/ndir.h>
#else
#include <ndir.h>
#endif
#else
#include <sys/dir.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef VOID_CLOSEDIR
#if HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
# define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen
# if HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif
# if HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif
# if HAVE_NDIR_H
# include <ndir.h>
# endif
#endif
#ifdef CLOSEDIR_VOID
/* Fake a return value. */
#define CLOSEDIR(d) (closedir (d), 0)
#else
@@ -51,10 +57,10 @@
#else
char *malloc ();
char *realloc ();
#endif
#ifndef NULL
#define NULL 0
#endif
#endif
char *stpcpy ();
@@ -71,7 +77,7 @@ savedir (dir, name_size)
unsigned name_size;
{
DIR *dirp;
struct direct *dp;
struct dirent *dp;
char *name_space;
char *namep;
@@ -94,7 +100,7 @@ savedir (dir, name_size)
|| (dp->d_name[1] != '\0'
&& (dp->d_name[1] != '.' || dp->d_name[2] != '\0')))
{
unsigned size_needed = (namep - name_space) + NLENGTH (dp) + 2;
unsigned size_needed = (namep - name_space) + NAMLEN (dp) + 2;
if (size_needed > name_size)
{

129
lib/setenv.c Normal file
View File

@@ -0,0 +1,129 @@
/* Copyright (C) 1992, 1995 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. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <errno.h>
#if _LIBC || HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if _LIBC || HAVE_STRING_H
#include <string.h>
#endif
#if _LIBC || HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifndef HAVE_GNU_LD
#define __environ environ
#endif
int
setenv (name, value, replace)
const char *name;
const char *value;
int replace;
{
register char **ep;
register size_t size;
const size_t namelen = strlen (name);
const size_t vallen = strlen (value) + 1;
size = 0;
for (ep = __environ; *ep != NULL; ++ep)
if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
break;
else
++size;
if (*ep == NULL)
{
static char **last_environ;
char **new_environ;
if (__environ == last_environ)
/* We allocated this space; we can extend it. */
new_environ = (char **) realloc (last_environ,
(size + 2) * sizeof (char *));
else
new_environ = (char **) malloc ((size + 2) * sizeof (char *));
if (new_environ == NULL)
return -1;
new_environ[size] = malloc (namelen + 1 + vallen);
if (new_environ[size] == NULL)
{
free ((char *) new_environ);
errno = ENOMEM;
return -1;
}
if (__environ != last_environ)
memcpy ((char *) new_environ, (char *) __environ,
size * sizeof (char *));
memcpy (new_environ[size], name, namelen);
new_environ[size][namelen] = '=';
memcpy (&new_environ[size][namelen + 1], value, vallen);
new_environ[size + 1] = NULL;
last_environ = __environ = new_environ;
}
else if (replace)
{
size_t len = strlen (*ep);
if (len + 1 < namelen + 1 + vallen)
{
/* The existing string is too short; malloc a new one. */
char *new = malloc (namelen + 1 + vallen);
if (new == NULL)
return -1;
*ep = new;
}
memcpy (*ep, name, namelen);
(*ep)[namelen] = '=';
memcpy (&(*ep)[namelen + 1], value, vallen);
}
return 0;
}
void
unsetenv (name)
const char *name;
{
const size_t len = strlen (name);
char **ep;
for (ep = __environ; *ep; ++ep)
if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
{
/* Found it. Remove this pointer by moving later ones back. */
char **dp = ep;
do
dp[0] = dp[1];
while (*dp++);
/* Continue the loop in case NAME appears again. */
}
}

17
lib/setenv.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef SETENV_H
#define SETENV_H 1
#undef __P
#if defined (__STDC__) && __STDC__
#define __P(x) x
#else
#define __P(x) ()
#endif
int
setenv __P ((const char *name, const char *value, int replace));
void
unsetenv __P ((const char *name));
#endif /* SETENV_H */

View File

@@ -15,16 +15,18 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Copy SOURCE into DEST, stopping after copying the first '\0', and
return a pointer to the '\0' at the end of DEST;
in other words, return DEST + strlen (SOURCE). */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
char *
stpcpy (dest, source)
stpcpy (dest, src)
char *dest;
char *source;
const char *src;
{
while ((*dest++ = *source++) != '\0')
while ((*dest++ = *src++) != '\0')
/* Do nothing. */ ;
return dest - 1;
}

View File

@@ -1,22 +1,31 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
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.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
char *index ();
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#ifndef strchr
#define strchr index
#endif
#endif
/* Return the length of the maximum inital segment of S
which contains no characters from REJECT. */
@@ -28,7 +37,7 @@ strcspn (s, reject)
register int count = 0;
while (*s != '\0')
if (index (reject, *s++) == 0)
if (strchr (reject, *s++) == 0)
++count;
else
return count;

View File

@@ -1,430 +1,453 @@
/* strftime - custom formatting of date and/or time
Copyright (C) 1989, 1991, 1992 Free Software Foundation, Inc.
/* Copyright (C) 1991, 92, 93, 94, 95, 96 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.
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 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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
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.
/* Note: this version of strftime lacks locale support,
but it is standalone.
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. */
Performs `%' substitutions similar to those in printf. Except
where noted, substituted fields have a fixed size; numeric fields are
padded if necessary. Padding is with zeros by default; for fields
that display a single number, padding can be changed or inhibited by
following the `%' with one of the modifiers described below. Unknown
field specifiers are copied as normal characters. All other
characters are copied to the output without change.
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
Supports a superset of the ANSI C field specifiers.
#ifdef _LIBC
# define HAVE_LIMITS_H 1
# define HAVE_MBLEN 1
# define HAVE_TM_ZONE 1
# define STDC_HEADERS 1
# include <ansidecl.h>
# include "../locale/localeinfo.h"
#endif
Literal character fields:
% %
n newline
t tab
#include <stdio.h>
#include <sys/types.h> /* Some systems define `time_t' here. */
Numeric modifiers (a nonstandard extension):
- do not pad the field
_ pad the field with spaces
Time fields:
%H hour (00..23)
%I hour (01..12)
%k hour ( 0..23)
%l hour ( 1..12)
%M minute (00..59)
%p locale's AM or PM
%r time, 12-hour (hh:mm:ss [AP]M)
%R time, 24-hour (hh:mm)
%S second (00..61)
%T time, 24-hour (hh:mm:ss)
%X locale's time representation (%H:%M:%S)
%Z time zone (EDT), or nothing if no time zone is determinable
Date fields:
%a locale's abbreviated weekday name (Sun..Sat)
%A locale's full weekday name, variable length (Sunday..Saturday)
%b locale's abbreviated month name (Jan..Dec)
%B locale's full month name, variable length (January..December)
%c locale's date and time (Sat Nov 04 12:02:33 EST 1989)
%C century (00..99)
%d day of month (01..31)
%e day of month ( 1..31)
%D date (mm/dd/yy)
%h same as %b
%j day of year (001..366)
%m month (01..12)
%U week number of year with Sunday as first day of week (00..53)
%w day of week (0..6)
%W week number of year with Monday as first day of week (00..53)
%x locale's date representation (mm/dd/yy)
%y last two digits of year (00..99)
%Y year (1970...)
David MacKenzie <djm@gnu.ai.mit.edu> */
#include <sys/types.h>
#if defined(TM_IN_SYS_TIME) || (!defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME))
#include <sys/time.h>
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
#include <time.h>
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#if defined(HAVE_TZNAME)
extern char *tzname[2];
#if HAVE_MBLEN
# include <ctype.h>
#endif
/* Types of padding for numbers in date and time. */
enum padding
{
none, blank, zero
};
static char const* const days[] =
{
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
};
static char const * const months[] =
{
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
/* Add character C to STRING and increment LENGTH,
unless LENGTH would exceed MAX. */
#define add_char(c) \
do \
{ \
if (length + 1 <= max) \
string[length++] = (c); \
} \
while (0)
/* Add a 2 digit number to STRING, padding if specified.
Return the number of characters added, up to MAX. */
static int
add_num2 (string, num, max, pad)
char *string;
int num;
int max;
enum padding pad;
{
int top = num / 10;
int length = 0;
if (top == 0 && pad == blank)
add_char (' ');
else if (top != 0 || pad == zero)
add_char (top + '0');
add_char (num % 10 + '0');
return length;
}
/* Add a 3 digit number to STRING, padding if specified.
Return the number of characters added, up to MAX. */
static int
add_num3 (string, num, max, pad)
char *string;
int num;
int max;
enum padding pad;
{
int top = num / 100;
int mid = (num - top * 100) / 10;
int length = 0;
if (top == 0 && pad == blank)
add_char (' ');
else if (top != 0 || pad == zero)
add_char (top + '0');
if (mid == 0 && top == 0 && pad == blank)
add_char (' ');
else if (mid != 0 || top != 0 || pad == zero)
add_char (mid + '0');
add_char (num % 10 + '0');
return length;
}
/* Like strncpy except return the number of characters copied. */
static int
add_str (to, from, max)
char *to;
char *from;
int max;
{
int i;
for (i = 0; from[i] && i <= max; ++i)
to[i] = from[i];
return i;
}
/* Return the week in the year of the time in TM, with the weeks
starting on Sundays. */
static int
sun_week (tm)
struct tm *tm;
{
int dl;
/* Set `dl' to the day in the year of the last day of the week previous
to the one containing the day specified in TM. If the day specified
in TM is in the first week of the year, `dl' will be negative or 0.
Otherwise, calculate the number of complete weeks before our week
(dl / 7) and add any partial week at the start of the year (dl % 7). */
dl = tm->tm_yday - tm->tm_wday;
return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0);
}
/* Return the week in the year of the time in TM, with the weeks
starting on Mondays. */
static int
mon_week (tm)
struct tm *tm;
{
int dl, wday;
if (tm->tm_wday == 0)
wday = 6;
else
wday = tm->tm_wday - 1;
dl = tm->tm_yday - wday;
return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0);
}
#if !defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME)
char *
zone_name (tp)
struct tm *tp;
{
char *timezone ();
struct timeval tv;
struct timezone tz;
gettimeofday (&tv, &tz);
return timezone (tz.tz_minuteswest, tp->tm_isdst);
}
#if HAVE_LIMITS_H
# include <limits.h>
#endif
/* Format the time given in TM according to FORMAT, and put the
results in STRING.
Return the number of characters (not including terminating null)
that were put into STRING, or 0 if the length would have
exceeded MAX. */
#if STDC_HEADERS
# include <stddef.h>
# include <stdlib.h>
# include <string.h>
#else
# define memcpy(d, s, n) bcopy (s, d, n)
#endif
#ifndef __P
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
#define __P(args) args
#else
#define __P(args) ()
#endif /* GCC. */
#endif /* Not __P. */
#ifndef PTR
#ifdef __STDC__
#define PTR void *
#else
#define PTR char *
#endif
#endif
static unsigned int week __P((const struct tm *const, int, int));
#define add(n, f) \
do \
{ \
i += (n); \
if (i >= maxsize) \
return 0; \
else \
if (p) \
{ \
f; \
p += (n); \
} \
} while (0)
#define cpy(n, s) add((n), memcpy((PTR) p, (PTR) (s), (n)))
#ifdef _LIBC
#define fmt(n, args) add((n), if (sprintf args != (n)) return 0)
#else
#define fmt(n, args) add((n), sprintf args; if (strlen (p) != (n)) return 0)
#endif
/* Return the week in the year specified by TP,
with weeks starting on STARTING_DAY. */
#ifdef __GNUC__
inline
#endif
static unsigned int
week (tp, starting_day, max_preceding)
const struct tm *const tp;
int starting_day;
int max_preceding;
{
int wday, dl, base;
wday = tp->tm_wday - starting_day;
if (wday < 0)
wday += 7;
/* Set DL to the day in the year of the first day of the week
containing the day specified in TP. */
dl = tp->tm_yday - wday;
/* For the computation following ISO 8601:1988 we set the number of
the week containing January 1st to 1 if this week has more than
MAX_PRECEDING days in the new year. For ISO 8601 this number is
3, for the other representation it is 7 (i.e., not to be
fulfilled). */
base = ((dl + 7) % 7) > max_preceding ? 1 : 0;
/* If DL is negative we compute the result as 0 unless we have to
compute it according ISO 8601. In this case we have to return 53
or 1 if the week containing January 1st has less than 4 days in
the new year or not. If DL is not negative we calculate the
number of complete weeks for our week (DL / 7) plus 1 (because
only for DL < 0 we are in week 0/53 and plus the number of the
first week computed in the last step. */
return dl < 0 ? (dl < -max_preceding ? 53 : base)
: base + 1 + dl / 7;
}
#ifndef _NL_CURRENT
static char const weekday_name[][10] =
{
"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"
};
static char const month_name[][10] =
{
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
#endif
/* Write information from TP into S according to the format
string FORMAT, writing no more that MAXSIZE characters
(including the terminating '\0') and returning number of
characters written. If S is NULL, nothing will be written
anywhere, so to determine how many characters would be
written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */
size_t
strftime (string, max, format, tm)
char *string;
size_t max;
const char *format;
const struct tm *tm;
strftime (s, maxsize, format, tp)
char *s;
size_t maxsize;
const char *format;
register const struct tm *tp;
{
enum padding pad; /* Type of padding to apply. */
size_t length = 0; /* Characters put in STRING so far. */
int hour12 = tp->tm_hour;
#ifdef _NL_CURRENT
const char *const a_wkday = _NL_CURRENT (LC_TIME, ABDAY_1 + tp->tm_wday);
const char *const f_wkday = _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday);
const char *const a_month = _NL_CURRENT (LC_TIME, ABMON_1 + tp->tm_mon);
const char *const f_month = _NL_CURRENT (LC_TIME, MON_1 + tp->tm_mon);
const char *const ampm = _NL_CURRENT (LC_TIME,
hour12 > 11 ? PM_STR : AM_STR);
size_t aw_len = strlen(a_wkday);
size_t am_len = strlen(a_month);
size_t ap_len = strlen (ampm);
#else
const char *const f_wkday = weekday_name[tp->tm_wday];
const char *const f_month = month_name[tp->tm_mon];
const char *const a_wkday = f_wkday;
const char *const a_month = f_month;
const char *const ampm = "AMPM" + 2 * (hour12 > 11);
size_t aw_len = 3;
size_t am_len = 3;
size_t ap_len = 2;
#endif
size_t wkday_len = strlen(f_wkday);
size_t month_len = strlen(f_month);
const unsigned int y_week0 = week (tp, 0, 7);
const unsigned int y_week1 = week (tp, 1, 7);
const unsigned int y_week2 = week (tp, 1, 3);
const char *zone;
size_t zonelen;
register size_t i = 0;
register char *p = s;
register const char *f;
char number_fmt[5];
for (; *format && length < max; ++format)
/* Initialize the buffer we will use for the sprintf format for numbers. */
number_fmt[0] = '%';
zone = 0;
#if HAVE_TM_ZONE
zone = (const char *) tp->tm_zone;
#endif
#if HAVE_TZNAME
if (!(zone && *zone) && tp->tm_isdst >= 0)
zone = tzname[tp->tm_isdst];
#endif
if (!(zone && *zone))
zone = "???";
zonelen = strlen (zone);
if (hour12 > 12)
hour12 -= 12;
else
if (hour12 == 0) hour12 = 12;
for (f = format; *f != '\0'; ++f)
{
if (*format != '%')
add_char (*format);
else
enum { pad_zero, pad_space, pad_none } pad; /* Padding for number. */
unsigned int maxdigits; /* Max digits for numeric format. */
unsigned int number_value; /* Numeric value to be printed. */
const char *subfmt;
#if HAVE_MBLEN
if (!isascii(*f))
{
++format;
/* Modifiers: */
if (*format == '-')
/* Non-ASCII, may be a multibyte. */
int len = mblen(f, strlen(f));
if (len > 0)
{
pad = none;
++format;
}
else if (*format == '_')
{
pad = blank;
++format;
}
else
pad = zero;
switch (*format)
{
/* Literal character fields: */
case 0:
case '%':
add_char ('%');
break;
case 'n':
add_char ('\n');
break;
case 't':
add_char ('\t');
break;
default:
add_char (*format);
break;
/* Time fields: */
case 'H':
case 'k':
length +=
add_num2 (&string[length], tm->tm_hour, max - length,
*format == 'H' ? pad : blank);
break;
case 'I':
case 'l':
{
int hour12;
if (tm->tm_hour == 0)
hour12 = 12;
else if (tm->tm_hour > 12)
hour12 = tm->tm_hour - 12;
else
hour12 = tm->tm_hour;
length +=
add_num2 (&string[length], hour12, max - length,
*format == 'I' ? pad : blank);
}
break;
case 'M':
length +=
add_num2 (&string[length], tm->tm_min, max - length, pad);
break;
case 'p':
if (tm->tm_hour < 12)
add_char ('A');
else
add_char ('P');
add_char ('M');
break;
case 'r':
length +=
strftime (&string[length], max - length, "%I:%M:%S %p", tm);
break;
case 'R':
length +=
strftime (&string[length], max - length, "%H:%M", tm);
break;
case 'S':
length +=
add_num2 (&string[length], tm->tm_sec, max - length, pad);
break;
case 'T':
length +=
strftime (&string[length], max - length, "%H:%M:%S", tm);
break;
case 'X':
length +=
strftime (&string[length], max - length, "%H:%M:%S", tm);
break;
case 'Z':
#ifdef HAVE_TM_ZONE
length += add_str (&string[length], tm->tm_zone, max - length);
#else
#ifdef HAVE_TZNAME
if (tm->tm_isdst && tzname[1] && *tzname[1])
length += add_str (&string[length], tzname[1], max - length);
else
length += add_str (&string[length], tzname[0], max - length);
#else
length += add_str (&string[length], zone_name (tm), max - length);
#endif
#endif
break;
/* Date fields: */
case 'a':
add_char (days[tm->tm_wday][0]);
add_char (days[tm->tm_wday][1]);
add_char (days[tm->tm_wday][2]);
break;
case 'A':
length +=
add_str (&string[length], days[tm->tm_wday], max - length);
break;
case 'b':
case 'h':
add_char (months[tm->tm_mon][0]);
add_char (months[tm->tm_mon][1]);
add_char (months[tm->tm_mon][2]);
break;
case 'B':
length +=
add_str (&string[length], months[tm->tm_mon], max - length);
break;
case 'c':
length +=
strftime (&string[length], max - length,
"%a %b %d %H:%M:%S %Z %Y", tm);
break;
case 'C':
length +=
add_num2 (&string[length], (tm->tm_year + 1900) / 100,
max - length, pad);
break;
case 'd':
length +=
add_num2 (&string[length], tm->tm_mday, max - length, pad);
break;
case 'e':
length +=
add_num2 (&string[length], tm->tm_mday, max - length, blank);
break;
case 'D':
length +=
strftime (&string[length], max - length, "%m/%d/%y", tm);
break;
case 'j':
length +=
add_num3 (&string[length], tm->tm_yday + 1, max - length, pad);
break;
case 'm':
length +=
add_num2 (&string[length], tm->tm_mon + 1, max - length, pad);
break;
case 'U':
length +=
add_num2 (&string[length], sun_week (tm), max - length, pad);
break;
case 'w':
add_char (tm->tm_wday + '0');
break;
case 'W':
length +=
add_num2 (&string[length], mon_week (tm), max - length, pad);
break;
case 'x':
length +=
strftime (&string[length], max - length, "%m/%d/%y", tm);
break;
case 'y':
length +=
add_num2 (&string[length], tm->tm_year % 100,
max - length, pad);
break;
case 'Y':
add_char ((tm->tm_year + 1900) / 1000 + '0');
length +=
add_num3 (&string[length],
(1900 + tm->tm_year) % 1000, max - length, zero);
break;
cpy(len, f);
continue;
}
}
#endif
if (*f != '%')
{
add(1, *p = *f);
continue;
}
/* Check for flags that can modify a number format. */
++f;
switch (*f)
{
case '_':
pad = pad_space;
++f;
break;
case '-':
pad = pad_none;
++f;
break;
default:
pad = pad_zero;
break;
}
/* Now do the specified format. */
switch (*f)
{
case '\0':
case '%':
add(1, *p = *f);
break;
case 'a':
cpy(aw_len, a_wkday);
break;
case 'A':
cpy(wkday_len, f_wkday);
break;
case 'b':
case 'h': /* GNU extension. */
cpy(am_len, a_month);
break;
case 'B':
cpy(month_len, f_month);
break;
case 'c':
#ifdef _NL_CURRENT
subfmt = _NL_CURRENT (LC_TIME, D_T_FMT);
#else
subfmt = "%a %b %d %H:%M:%S %Z %Y";
#endif
subformat:
{
size_t len = strftime (p, maxsize - i, subfmt, tp);
if (len == 0 && *subfmt)
return 0;
add(len, );
}
break;
#define DO_NUMBER(digits, value) \
maxdigits = digits; number_value = value; goto do_number
#define DO_NUMBER_NOPAD(digits, value) \
maxdigits = digits; number_value = value; goto do_number_nopad
case 'C':
DO_NUMBER (2, (1900 + tp->tm_year) / 100);
case 'x':
#ifdef _NL_CURRENT
subfmt = _NL_CURRENT (LC_TIME, D_FMT);
goto subformat;
#endif
/* Fall through. */
case 'D': /* GNU extension. */
subfmt = "%m/%d/%y";
goto subformat;
case 'd':
DO_NUMBER (2, tp->tm_mday);
case 'e': /* GNU extension: %d, but blank-padded. */
DO_NUMBER_NOPAD (2, tp->tm_mday);
/* All numeric formats set MAXDIGITS and NUMBER_VALUE and then
jump to one of these two labels. */
do_number_nopad:
/* Force `-' flag. */
pad = pad_none;
do_number:
{
/* Format the number according to the PAD flag. */
register char *nf = &number_fmt[1];
int printed;
switch (pad)
{
case pad_zero:
*nf++ = '0';
case pad_space:
*nf++ = '0' + maxdigits;
case pad_none:
*nf++ = 'u';
*nf = '\0';
}
#ifdef _LIBC
add (maxdigits, printed = sprintf (p, number_fmt, number_value));
#else
add (maxdigits, sprintf (p, number_fmt, number_value);
printed = strlen (p));
#endif
break;
}
case 'H':
DO_NUMBER (2, tp->tm_hour);
case 'I':
DO_NUMBER (2, hour12);
case 'k': /* GNU extension. */
DO_NUMBER_NOPAD (2, tp->tm_hour);
case 'l': /* GNU extension. */
DO_NUMBER_NOPAD (2, hour12);
case 'j':
DO_NUMBER (3, 1 + tp->tm_yday);
case 'M':
DO_NUMBER (2, tp->tm_min);
case 'm':
DO_NUMBER (2, tp->tm_mon + 1);
case 'n': /* GNU extension. */
add (1, *p = '\n');
break;
case 'p':
cpy(ap_len, ampm);
break;
case 'R': /* GNU extension. */
subfmt = "%H:%M";
goto subformat;
case 'r': /* GNU extension. */
subfmt = "%I:%M:%S %p";
goto subformat;
case 'S':
DO_NUMBER (2, tp->tm_sec);
case 'X':
#ifdef _NL_CURRENT
subfmt = _NL_CURRENT (LC_TIME, T_FMT);
goto subformat;
#endif
/* Fall through. */
case 'T': /* GNU extenstion. */
subfmt = "%H:%M:%S";
goto subformat;
case 't': /* GNU extenstion. */
add (1, *p = '\t');
break;
case 'U':
DO_NUMBER (2, y_week0);
case 'V':
DO_NUMBER (2, y_week2);
case 'W':
DO_NUMBER (2, y_week1);
case 'w':
DO_NUMBER (2, tp->tm_wday);
case 'Y':
DO_NUMBER (4, 1900 + tp->tm_year);
case 'y':
DO_NUMBER (2, tp->tm_year % 100);
case 'Z':
cpy(zonelen, zone);
break;
default:
/* Bad format. */
break;
}
}
add_char (0);
return length - 1;
if (p)
*p = '\0';
return i;
}

49
lib/strndup.c Normal file
View File

@@ -0,0 +1,49 @@
/* Copyright (C) 1996 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <sys/types.h>
#ifdef STDC_HEADERS
# include <string.h>
# include <stdlib.h>
#else
char *malloc ();
#endif
/* Duplicate S, returning an identical malloc'd string. */
char *
strndup (s, n)
const char *s;
size_t n;
{
char *new = malloc (n + 1);
if (new == NULL)
return NULL;
memcpy (new, s, n);
new[n] = '\0';
return new;
}

39
lib/strpbrk.c Normal file
View File

@@ -0,0 +1,39 @@
/* Copyright (C) 1991, 1994 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
/* Find the first ocurrence in S of any character in ACCEPT. */
char *
strpbrk (s, accept)
register const char *s;
register const char *accept;
{
while (*s != '\0')
{
const char *a = accept;
while (*a != '\0')
if (*a++ == *s)
return (char *) s;
++s;
}
return 0;
}

View File

@@ -1,41 +1,46 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
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.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#include <ctype.h>
#include <math.h>
#if STDC_HEADERS
#ifdef HAVE_FLOAT_H
#include <float.h>
#else
#define DBL_MAX 1.7976931348623159e+308
#define DBL_MIN 2.2250738585072010e-308
#endif
#if STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#else
#define NULL 0
#define DBL_MAX 1.7976931348623159e+308
#define DBL_MIN 2.2250738585072010e-308
extern int errno;
#endif
#ifndef HUGE_VAL
#define HUGE_VAL HUGE
#endif
#if !__STDC__
#define const
#endif
/* Convert NPTR to a double. If ENDPTR is not NULL, a pointer to the

View File

@@ -1,93 +1,222 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
/* Copyright (C) 1991, 92, 94, 95, 96 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
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.
The GNU C Library is distributed in the hope that it will be useful,
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
Library General Public License for more details.
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 Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, 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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef _LIBC
# define USE_NUMBER_GROUPING
# define STDC_HEADERS
# define HAVE_LIMITS_H
#endif
#include <ctype.h>
#include <errno.h>
#if HAVE_LIMITS_H
#include <limits.h>
#endif
#ifndef ULONG_MAX
#define LONG_MAX (~(1 << (sizeof (long) * 8 - 1)))
#define LONG_MIN (-LONG_MAX-1)
#define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
#endif
#if STDC_HEADERS
#include <stddef.h>
#include <stdlib.h>
#else
#define NULL 0
#ifndef errno
extern int errno;
#endif
#if !__STDC__
#define const
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#ifndef UNSIGNED
#define UNSIGNED 0
#ifdef STDC_HEADERS
# include <stddef.h>
# include <stdlib.h>
#else
# ifndef NULL
# define NULL 0
# endif
#endif
#ifdef USE_NUMBER_GROUPING
# include "../locale/localeinfo.h"
#endif
/* Nonzero if we are defining `strtoul' or `strtouq', operating on
unsigned integers. */
#ifndef UNSIGNED
# define UNSIGNED 0
# define INT LONG int
#else
# define INT unsigned LONG int
#endif
/* Determine the name. */
#if UNSIGNED
# ifdef USE_WIDE_CHAR
# ifdef QUAD
# define strtol wcstouq
# else
# define strtol wcstoul
# endif
# else
# ifdef QUAD
# define strtol strtouq
# else
# define strtol strtoul
# endif
# endif
#else
# ifdef USE_WIDE_CHAR
# ifdef QUAD
# define strtol wcstoq
# else
# define strtol wcstol
# endif
# else
# ifdef QUAD
# define strtol strtoq
# endif
# endif
#endif
/* If QUAD is defined, we are defining `strtoq' or `strtouq',
operating on `long long int's. */
#ifdef QUAD
# define LONG long long
# undef LONG_MIN
# define LONG_MIN LONG_LONG_MIN
# undef LONG_MAX
# define LONG_MAX LONG_LONG_MAX
# undef ULONG_MAX
# define ULONG_MAX ULONG_LONG_MAX
# if __GNUC__ == 2 && __GNUC_MINOR__ < 7
/* Work around gcc bug with using this constant. */
static const unsigned long long int maxquad = ULONG_LONG_MAX;
# undef ULONG_MAX
# define ULONG_MAX maxquad
# endif
#else
# define LONG long
#ifndef ULONG_MAX
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
#endif
#ifndef LONG_MAX
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
#endif
#endif
#ifdef USE_WIDE_CHAR
# include <wchar.h>
# include <wctype.h>
# define L_(ch) L##ch
# define UCHAR_TYPE wint_t
# define STRING_TYPE wchar_t
# define ISSPACE(ch) iswspace (ch)
# define ISALPHA(ch) iswalpha (ch)
# define TOUPPER(ch) towupper (ch)
#else
# define L_(ch) ch
# define UCHAR_TYPE unsigned char
# define STRING_TYPE char
# define ISSPACE(ch) isspace (ch)
# define ISALPHA(ch) isalpha (ch)
# define TOUPPER(ch) toupper (ch)
#endif
#ifdef __STDC__
# define INTERNAL(x) INTERNAL1(x)
# define INTERNAL1(x) __##x##_internal
# define WEAKNAME(x) WEAKNAME1(x)
# define WEAKNAME1(x) __##x
#else
# define INTERNAL(x) __/**/x/**/_internal
# define WEAKNAME(x) __/**/x
#endif
#ifdef USE_NUMBER_GROUPING
/* This file defines a function to check for correct grouping. */
# include "grouping.h"
#endif
/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
If BASE is 0 the base is determined by the presence of a leading
zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
If BASE is < 2 or > 36, it is reset to 10.
If ENDPTR is not NULL, a pointer to the character after the last
one converted is stored in *ENDPTR. */
#if UNSIGNED
unsigned long int
#define strtol strtoul
#else
long int
#endif
strtol (nptr, endptr, base)
const char *nptr;
char **endptr;
INT
INTERNAL (strtol) (nptr, endptr, base, group)
const STRING_TYPE *nptr;
STRING_TYPE **endptr;
int base;
int group;
{
int negative;
register unsigned long int cutoff;
register unsigned LONG int cutoff;
register unsigned int cutlim;
register unsigned long int i;
register const char *s;
register unsigned char c;
const char *save;
register unsigned LONG int i;
register const STRING_TYPE *s;
register UCHAR_TYPE c;
const STRING_TYPE *save, *end;
int overflow;
#ifdef USE_NUMBER_GROUPING
/* The thousands character of the current locale. */
wchar_t thousands;
/* The numeric grouping specification of the current locale,
in the format described in <locale.h>. */
const char *grouping;
if (group)
{
grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
if (*grouping <= 0 || *grouping == CHAR_MAX)
grouping = NULL;
else
{
/* Figure out the thousands separator character. */
if (mbtowc (&thousands, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP),
strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0)
thousands = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP);
if (thousands == L'\0')
grouping = NULL;
}
}
else
grouping = NULL;
#endif
if (base < 0 || base == 1 || base > 36)
base = 10;
s = nptr;
save = s = nptr;
/* Skip white space. */
while (isspace (*s))
while (ISSPACE (*s))
++s;
if (*s == '\0')
if (*s == L_('\0'))
goto noconv;
/* Check for a sign. */
if (*s == '-')
if (*s == L_('-'))
{
negative = 1;
++s;
}
else if (*s == '+')
else if (*s == L_('+'))
{
negative = 0;
++s;
@@ -95,40 +224,58 @@ strtol (nptr, endptr, base)
else
negative = 0;
if (base == 16 && s[0] == '0' && toupper (s[1]) == 'X')
if (base == 16 && s[0] == L_('0') && TOUPPER (s[1]) == L_('X'))
s += 2;
/* If BASE is zero, figure it out ourselves. */
if (base == 0)
{
if (*s == '0')
{
if (toupper (s[1]) == 'X')
{
s += 2;
base = 16;
}
else
base = 8;
}
else
base = 10;
}
if (*s == L_('0'))
{
if (TOUPPER (s[1]) == L_('X'))
{
s += 2;
base = 16;
}
else
base = 8;
}
else
base = 10;
/* Save the pointer so we can check later if anything happened. */
save = s;
cutoff = ULONG_MAX / (unsigned long int) base;
cutlim = ULONG_MAX % (unsigned long int) base;
#ifdef USE_NUMBER_GROUPING
if (group)
{
/* Find the end of the digit string and check its grouping. */
end = s;
for (c = *end; c != L_('\0'); c = *++end)
if (c != thousands && (c < L_('0') || c > L_('9'))
&& (!ISALPHA (c) || TOUPPER (c) - L_('A') + 10 >= base))
break;
if (*s == thousands)
end = s;
else
end = correctly_grouped_prefix (s, end, thousands, grouping);
}
else
#endif
end = NULL;
cutoff = ULONG_MAX / (unsigned LONG int) base;
cutlim = ULONG_MAX % (unsigned LONG int) base;
overflow = 0;
i = 0;
for (c = *s; c != '\0'; c = *++s)
for (c = *s; c != L_('\0'); c = *++s)
{
if (isdigit (c))
c -= '0';
else if (isalpha (c))
c = toupper (c) - 'A' + 10;
if (s == end)
break;
if (c >= L_('0') && c <= L_('9'))
c -= L_('0');
else if (ISALPHA (c))
c = TOUPPER (c) - L_('A') + 10;
else
break;
if (c >= base)
@@ -138,7 +285,7 @@ strtol (nptr, endptr, base)
overflow = 1;
else
{
i *= (unsigned long int) base;
i *= (unsigned LONG int) base;
i += c;
}
}
@@ -150,20 +297,22 @@ strtol (nptr, endptr, base)
/* Store in ENDPTR the address of one character
past the last character we converted. */
if (endptr != NULL)
*endptr = (char *) s;
*endptr = (STRING_TYPE *) s;
#if !UNSIGNED
#if !UNSIGNED
/* Check for a value that is within the range of
`unsigned long int', but outside the range of `long int'. */
if (i > (negative ?
- (unsigned long int) LONG_MIN : (unsigned long int) LONG_MAX))
`unsigned LONG int', but outside the range of `LONG int'. */
if (overflow == 0
&& i > (negative
? -((unsigned LONG int) (LONG_MIN + 1)) + 1
: (unsigned LONG int) LONG_MAX))
overflow = 1;
#endif
if (overflow)
{
errno = ERANGE;
#if UNSIGNED
#if UNSIGNED
return ULONG_MAX;
#else
return negative ? LONG_MIN : LONG_MAX;
@@ -171,11 +320,43 @@ strtol (nptr, endptr, base)
}
/* Return the result of the appropriate sign. */
return (negative ? - i : i);
return (negative ? -i : i);
noconv:;
/* There was no number to convert. */
noconv:
/* We must handle a special case here: the base is 0 or 16 and the
first two characters and '0' and 'x', but the rest are no
hexadecimal digits. This is no error case. We return 0 and
ENDPTR points to the `x`. */
if (endptr != NULL)
*endptr = (char *) nptr;
if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
&& save[-2] == L_('0'))
*endptr = (STRING_TYPE *) &save[-1];
else
/* There was no number to convert. */
*endptr = (STRING_TYPE *) nptr;
return 0L;
}
/* External user entry point. */
#undef __P
#if defined (__STDC__) && __STDC__
#define __P(args) args
#else
#define __P(args) ()
#endif
/* Prototype. */
INT strtol __P ((const STRING_TYPE *nptr, STRING_TYPE **endptr,
int base));
INT
strtol (nptr, endptr, base)
const STRING_TYPE *nptr;
STRING_TYPE **endptr;
int base;
{
return INTERNAL (strtol) (nptr, endptr, base, 0);
}

View File

@@ -18,14 +18,21 @@
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#ifdef HAVE_CONFIG_H
#if defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I will use ./config.h rather than /config.h
(which it would do because it found this file in ). */
#include <config.h>
#else
#include "config.h"
#endif
#ifdef __GNUC__
# define alloca __builtin_alloca
#else
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef _AIX
#pragma alloca
# else
char *alloca ();
# endif
# endif
#endif
#include <stdio.h>
@@ -33,23 +40,21 @@
#include <pwd.h>
#include <grp.h>
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#include <string.h>
#ifndef index
#define index strchr
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#else
#include <strings.h>
# include <strings.h>
# ifndef strchr
# define strchr index
# endif
#endif
#ifdef STDC_HEADERS
#include <stdlib.h>
#else
char *malloc ();
# include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
# include <unistd.h>
#endif
#ifndef _POSIX_VERSION
@@ -58,15 +63,42 @@ struct group *getgrnam ();
struct group *getgrgid ();
#endif
#ifdef _POSIX_SOURCE
#define endpwent()
#define endgrent()
#ifndef HAVE_ENDGRENT
# define endgrent() ((void) 0)
#endif
#ifndef HAVE_ENDPWENT
# define endpwent() ((void) 0)
#endif
/* Perform the equivalent of the statement `dest = strdup (src);',
but obtaining storage via alloca instead of from the heap. */
#define V_STRDUP(dest, src) \
do \
{ \
int _len = strlen ((src)); \
(dest) = (char *) alloca (_len + 1); \
strcpy (dest, src); \
} \
while (0)
#define isdigit(c) ((c) >= '0' && (c) <= '9')
char *strdup ();
static int isnumber ();
/* Return nonzero if STR represents an unsigned decimal integer,
otherwise return 0. */
static int
is_number (str)
const char *str;
{
for (; *str; str++)
if (!isdigit (*str))
return 0;
return 1;
}
/* Extract from NAME, which has the form "[user][:.][group]",
a USERNAME, UID U, GROUPNAME, and GID G.
@@ -77,115 +109,172 @@ static int isnumber ();
USERNAME and GROUPNAME will be in newly malloc'd memory.
Either one might be NULL instead, indicating that it was not
given and the corresponding numeric ID was left unchanged.
Might write NULs into NAME.
Return NULL if successful, a static error message string if not. */
char *
parse_user_spec (name, uid, gid, username, groupname)
char *name;
const char *
parse_user_spec (spec_arg, uid, gid, username_arg, groupname_arg)
const char *spec_arg;
uid_t *uid;
gid_t *gid;
char **username, **groupname;
char **username_arg, **groupname_arg;
{
static char *tired = "virtual memory exhausted";
static const char *tired = "virtual memory exhausted";
const char *error_msg;
char *spec; /* A copy we can write on. */
struct passwd *pwd;
struct group *grp;
char *cp;
int use_login_group = 0;
char *g, *u, *separator;
char *groupname;
*username = *groupname = NULL;
error_msg = NULL;
*username_arg = *groupname_arg = NULL;
groupname = NULL;
/* Check whether a group is given. */
cp = index (name, ':');
if (cp == NULL)
cp = index (name, '.');
if (cp != NULL)
V_STRDUP (spec, spec_arg);
/* Find the separator if there is one. */
separator = strchr (spec, ':');
if (separator == NULL)
separator = strchr (spec, '.');
/* Replace separator with a NUL. */
if (separator != NULL)
*separator = '\0';
/* Set U and G to non-zero length strings corresponding to user and
group specifiers or to NULL. */
u = (*spec == '\0' ? NULL : spec);
g = (separator == NULL || *(separator + 1) == '\0'
? NULL
: separator + 1);
if (u == NULL && g == NULL)
return "can not omit both user and group";
if (u != NULL)
{
*cp++ = '\0';
if (*cp == '\0')
pwd = getpwnam (u);
if (pwd == NULL)
{
if (cp == name + 1)
/* Neither user nor group given, just "." or ":". */
return "can not omit both user and group";
if (!is_number (u))
error_msg = "invalid user";
else
/* "user.". */
use_login_group = 1;
{
int use_login_group;
use_login_group = (separator != NULL && g == NULL);
if (use_login_group)
error_msg = "cannot get the login group of a numeric UID";
else
*uid = atoi (u);
}
}
else
{
/* Explicit group. */
*groupname = strdup (cp);
if (*groupname == NULL)
return tired;
grp = getgrnam (cp);
if (grp == NULL)
*uid = pwd->pw_uid;
if (g == NULL && separator != NULL)
{
if (!isnumber (cp))
return "invalid group";
*gid = atoi (cp);
/* A separator was given, but a group was not specified,
so get the login group. */
*gid = pwd->pw_gid;
grp = getgrgid (pwd->pw_gid);
if (grp == NULL)
{
/* This is enough room to hold the unsigned decimal
representation of any 32-bit quantity and the trailing
zero byte. */
char uint_buf[21];
sprintf (uint_buf, "%u", (unsigned) (pwd->pw_gid));
V_STRDUP (groupname, uint_buf);
}
else
{
V_STRDUP (groupname, grp->gr_name);
}
endgrent ();
}
else
*gid = grp->gr_gid;
endgrent (); /* Save a file descriptor. */
}
endpwent ();
}
/* Parse the user name, now that any group has been removed. */
if (name[0] == '\0')
/* No user name was given, just a group. */
return NULL;
*username = strdup (name);
if (*username == NULL)
return tired;
pwd = getpwnam (name);
if (pwd == NULL)
if (g != NULL && error_msg == NULL)
{
if (!isnumber (name))
return "invalid user";
if (use_login_group)
return "cannot get the login group of a numeric UID";
*uid = atoi (name);
}
else
{
*uid = pwd->pw_uid;
if (use_login_group)
/* Explicit group. */
grp = getgrnam (g);
if (grp == NULL)
{
*gid = pwd->pw_gid;
grp = getgrgid (pwd->pw_gid);
if (grp == NULL)
{
*groupname = malloc (15);
if (*groupname == NULL)
return tired;
sprintf (*groupname, "%u", pwd->pw_gid);
}
if (!is_number (g))
error_msg = "invalid group";
else
*gid = atoi (g);
}
else
*gid = grp->gr_gid;
endgrent (); /* Save a file descriptor. */
if (error_msg == NULL)
V_STRDUP (groupname, g);
}
if (error_msg == NULL)
{
if (u != NULL)
{
*username_arg = strdup (u);
if (*username_arg == NULL)
error_msg = tired;
}
if (groupname != NULL && error_msg == NULL)
{
*groupname_arg = strdup (groupname);
if (*groupname_arg == NULL)
{
*groupname = strdup (grp->gr_name);
if (*groupname == NULL)
return tired;
if (*username_arg != NULL)
{
free (*username_arg);
*username_arg = NULL;
}
error_msg = tired;
}
endgrent ();
}
}
endpwent ();
return NULL;
return error_msg;
}
/* Return nonzero if STR represents an unsigned decimal integer,
otherwise return 0. */
#ifdef TEST
static int
isnumber (str)
char *str;
#define NULL_CHECK(s) ((s) == NULL ? "(null)" : (s))
int
main (int argc, char **argv)
{
for (; *str; str++)
if (!isdigit (*str))
return 0;
return 1;
int i;
for (i = 1; i < argc; i++)
{
const char *e;
char *username, *groupname;
uid_t uid;
gid_t gid;
char *tmp;
tmp = strdup (argv[i]);
e = parse_user_spec (tmp, &uid, &gid, &username, &groupname);
free (tmp);
printf ("%s: %u %u %s %s %s\n",
argv[i],
(unsigned int) uid,
(unsigned int) gid,
NULL_CHECK (username),
NULL_CHECK (groupname),
NULL_CHECK (e));
}
exit (0);
}
#endif

85
lib/xgetcwd.c Normal file
View File

@@ -0,0 +1,85 @@
/* xgetcwd.c -- return current directory with unlimited length
Copyright (C) 1992 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Written by David MacKenzie, djm@gnu.ai.mit.edu. */
#ifdef HAVE_CONFIG_H
#if defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because it found this file in $srcdir). */
#include <config.h>
#else
#include "config.h"
#endif
#endif
#include <stdio.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#include <sys/types.h>
#include "pathmax.h"
#if !defined(_POSIX_VERSION) && !defined(HAVE_GETCWD)
char *getwd ();
#define getcwd(buf, max) getwd (buf)
#else
char *getcwd ();
#endif
/* Amount to increase buffer size by in each try. */
#define PATH_INCR 32
char *xmalloc ();
char *xrealloc ();
void free ();
/* Return the current directory, newly allocated, arbitrarily long.
Return NULL and set errno on error. */
char *
xgetcwd ()
{
char *cwd;
char *ret;
unsigned path_max;
errno = 0;
path_max = (unsigned) PATH_MAX;
path_max += 2; /* The getcwd docs say to do this. */
cwd = xmalloc (path_max);
errno = 0;
while ((ret = getcwd (cwd, path_max)) == NULL && errno == ERANGE)
{
path_max += PATH_INCR;
cwd = xrealloc (cwd, path_max);
errno = 0;
}
if (ret == NULL)
{
int save_errno = errno;
free (cwd);
errno = save_errno;
return NULL;
}
return cwd;
}

54
lib/xgethostname.c Normal file
View File

@@ -0,0 +1,54 @@
/* xgethostname.c -- return current hostname with unlimited length
Copyright (C) 1992 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Written by Jim Meyering, meyering@comco.com */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
int gethostname ();
char *xmalloc ();
char *xrealloc ();
#ifndef INITIAL_HOSTNAME_LENGTH
#define INITIAL_HOSTNAME_LENGTH 33
#endif
char *
xgethostname ()
{
char *hostname;
size_t size;
int err;
size = INITIAL_HOSTNAME_LENGTH;
hostname = xmalloc (size);
while (1)
{
hostname[size - 1] = '\0';
err = gethostname (hostname, size);
if (err == 0 && hostname[size - 1] == '\0')
break;
size *= 2;
hostname = xrealloc (hostname, size);
}
return hostname;
}

View File

@@ -1,5 +1,5 @@
/* xmalloc.c -- malloc with out of memory checking
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
Copyright (C) 1990, 91, 92, 93, 94 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,51 +15,89 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef STDC_HEADERS
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#if __STDC__
#define VOID void
#else
#define VOID char
#endif
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#else
char *malloc ();
char *realloc ();
VOID *malloc ();
VOID *realloc ();
void free ();
#endif
/* This is for other GNU distributions with internationalized messages.
The GNU C Library itself does not yet support such messages. */
#if HAVE_LIBINTL_H
# include <libintl.h>
#else
# define gettext(msgid) (msgid)
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
/* Exit value when the requested amount of memory is not available.
The caller may set it to some other value. */
int xmalloc_exit_failure = EXIT_FAILURE;
#if __STDC__ && (HAVE_VPRINTF || HAVE_DOPRNT)
void error (int, int, const char *, ...);
#else
void error ();
#endif
static VOID *
fixup_null_alloc (n)
size_t n;
{
VOID *p;
p = 0;
if (n == 0)
p = malloc ((size_t) 1);
if (p == 0)
error (xmalloc_exit_failure, 0, gettext ("Memory exhausted"));
return p;
}
/* Allocate N bytes of memory dynamically, with error checking. */
char *
VOID *
xmalloc (n)
unsigned n;
size_t n;
{
char *p;
VOID *p;
p = malloc (n);
if (p == 0)
/* Must exit with 2 for `cmp'. */
error (2, 0, "virtual memory exhausted");
p = fixup_null_alloc (n);
return p;
}
/* Change the size of an allocated block of memory P to N bytes,
with error checking.
If P is NULL, run xmalloc.
If N is 0, run free and return NULL. */
If P is NULL, run xmalloc. */
char *
VOID *
xrealloc (p, n)
char *p;
unsigned n;
VOID *p;
size_t n;
{
if (p == 0)
return xmalloc (n);
if (n == 0)
{
free (p);
return 0;
}
p = realloc (p, n);
if (p == 0)
/* Must exit with 2 for `cmp'. */
error (2, 0, "virtual memory exhausted");
p = fixup_null_alloc (n);
return p;
}

71
lib/xstrtod.c Normal file
View File

@@ -0,0 +1,71 @@
/* xstrtod.c - error-checking interface to strtod
Copyright (C) 1996 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 Jim Meyering. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef STDC_HEADERS
#include <stdlib.h>
#else
double strtod ();
#endif
#include <errno.h>
#include <stdio.h>
#include <limits.h>
#include "xstrtod.h"
/* An interface to strtod that encapsulates all the error checking
one should usually perform. Like strtod, but upon successful
conversion put the result in *RESULT and return zero. Return
non-zero and don't modify *RESULT upon any failure. */
int
xstrtod (str, ptr, result)
const char *str;
const char **ptr;
double *result;
{
double val;
char *terminator;
int fail;
fail = 0;
errno = 0;
val = strtod (str, &terminator);
/* Having a non-zero terminator is an error only when PTR is NULL. */
if (terminator == str || (ptr == NULL && *terminator != '\0'))
fail = 1;
else
{
/* Allow underflow (in which case strtod returns zero),
but flag overflow as an error. */
if (val != 0.0 && errno == ERANGE)
fail = 1;
}
if (ptr != NULL)
*ptr = terminator;
*result = val;
return fail;
}

15
lib/xstrtod.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef XSTRTOD_H
#define XSTRTOD_H 1
#ifndef __P
# if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
# define __P(args) args
# else
# define __P(args) ()
# endif /* GCC. */
#endif /* Not __P. */
int
xstrtod __P ((const char *str, const char **ptr, double *result));
#endif /* XSTRTOD_H */

175
lib/xstrtol.c Normal file
View File

@@ -0,0 +1,175 @@
/* A more useful interface to strtol.
Copyright (C) 1995, 1996 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. */
/* Jim Meyering (meyering@na-net.ornl.gov) */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
# ifndef strchr
# define strchr index
# endif
#endif
#define NDEBUG
#include <assert.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#if HAVE_LIMITS_H
# include <limits.h>
#endif
#ifndef ULONG_MAX
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
#endif
#ifndef LONG_MAX
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
#endif
#include "xstrtol.h"
#define BKM_SCALE(x, scale_factor, error_return) \
do \
{ \
if ((x) > (double) __ZLONG_MAX / (scale_factor)) \
return (error_return); \
(x) *= (scale_factor); \
} \
while (0)
__unsigned long int __strtol ();
/* FIXME: comment. */
strtol_error
__xstrtol (s, ptr, base, val, valid_suffixes)
const char *s;
char **ptr;
int base;
__unsigned long int *val;
const char *valid_suffixes;
{
char *t_ptr;
char **p;
__unsigned long int tmp;
assert (0 <= base && base <= 36);
p = (ptr ? ptr : &t_ptr);
errno = 0;
tmp = __strtol (s, p, base);
if (errno != 0)
return LONGINT_OVERFLOW;
if (*p == s)
return LONGINT_INVALID;
if (!valid_suffixes)
{
if (**p == '\0')
{
*val = tmp;
return LONGINT_OK;
}
else
return LONGINT_INVALID_SUFFIX_CHAR;
}
if (**p != '\0' && strchr (valid_suffixes, **p))
{
switch (**p)
{
case 'b':
BKM_SCALE (tmp, 512, LONGINT_OVERFLOW);
++(*p);
break;
case 'c':
++(*p);
break;
case 'B':
case 'k':
BKM_SCALE (tmp, 1024, LONGINT_OVERFLOW);
++(*p);
break;
case 'm':
BKM_SCALE (tmp, 1024 * 1024, LONGINT_OVERFLOW);
++(*p);
break;
case 'w':
BKM_SCALE (tmp, 2, LONGINT_OVERFLOW);
++(*p);
break;
default:
return LONGINT_INVALID_SUFFIX_CHAR;
break;
}
}
*val = tmp;
return LONGINT_OK;
}
#ifdef TESTING_XSTRTO
#include <stdio.h>
#include "error.h"
char *program_name;
int
main (int argc, char** argv)
{
strtol_error s_err;
int i;
program_name = argv[0];
for (i=1; i<argc; i++)
{
char *p;
__unsigned long int val;
s_err = __xstrtol (argv[i], &p, 0, &val, "bckmw");
if (s_err == LONGINT_OK)
{
printf ("%s->%lu (%s)\n", argv[i], val, p);
}
else
{
STRTOL_FATAL_ERROR (argv[i], "arg", s_err);
}
}
exit (0);
}
#endif /* TESTING_XSTRTO */

66
lib/xstrtol.h Normal file
View File

@@ -0,0 +1,66 @@
#ifndef _xstrtol_h_
#define _xstrtol_h_ 1
#if STRING_TO_UNSIGNED
# define __xstrtol xstrtoul
# define __strtol strtoul
# define __unsigned unsigned
# define __ZLONG_MAX ULONG_MAX
#else
# define __xstrtol xstrtol
# define __strtol strtol
# define __unsigned /* empty */
# define __ZLONG_MAX LONG_MAX
#endif
#undef __P
#if defined (__STDC__) && __STDC__
#define __P(x) x
#else
#define __P(x) ()
#endif
enum strtol_error
{
LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW
};
typedef enum strtol_error strtol_error;
strtol_error
__xstrtol __P ((const char *s, char **ptr, int base,
__unsigned long int *val, const char *valid_suffixes));
#define _STRTOL_ERROR(exit_code, str, argument_type_string, err) \
do \
{ \
switch ((err)) \
{ \
case LONGINT_OK: \
abort (); \
\
case LONGINT_INVALID: \
error ((exit_code), 0, "invalid %s `%s'", \
(argument_type_string), (str)); \
break; \
\
case LONGINT_INVALID_SUFFIX_CHAR: \
error ((exit_code), 0, "invalid character following %s `%s'", \
(argument_type_string), (str)); \
break; \
\
case LONGINT_OVERFLOW: \
/* FIXME: make this message dependent on STRING_TO_UNSIGNED */\
error ((exit_code), 0, "%s `%s' larger than maximum long int",\
(argument_type_string), (str)); \
break; \
} \
} \
while (0)
#define STRTOL_FATAL_ERROR(str, argument_type_string, err) \
_STRTOL_ERROR (2, str, argument_type_string, err)
#define STRTOL_FAIL_WARN(str, argument_type_string, err) \
_STRTOL_ERROR (0, str, argument_type_string, err)
#endif /* _xstrtol_h_ */

2
lib/xstrtoul.c Normal file
View File

@@ -0,0 +1,2 @@
#define STRING_TO_UNSIGNED 1
#include "xstrtol.c"

7
lib/xstrtoul.h Normal file
View File

@@ -0,0 +1,7 @@
#ifndef _xstrtoul_h_
#define _xstrtoul_h_ 1
#define STRING_TO_UNSIGNED 1
#include "xstrtol.h"
#endif /* _xstrtoul_h_ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,92 @@
Changes in release 3.13:
* ls accepts new option --color[=WHEN] where WHEN is `always', `never',
or `auto'. --color=never is the default. --color is equivalent
to --color=always (documented only in --help message FIXME)
* new program: dircolors (not yet documented FIXME)
* ls allows 0 as argument to --tabsize (-T) option. Using --tabsize=0
inhibits the use of TAB characters for separating columns.
* you can create a backup of FILE with cp --force --backup FILE FILE. Before,
that command failed saying that ``FILE' and `FILE' are the same file'.
* uses automake-generated Makefile templates
* chown and chgrp accept new option --no-dereference (-h)
* ln -f FILE FILE fails with a diagnostic rather than silently removing FILE
* when building on systems that have getopt_long (like Linux), the system-
provided function will be used -- so executables may be a little smaller
* cp -p, and mv modify owner and/or group of symlinks on systems
(like Solaris) that provide the lchown system call.
* df no longer invokes the sync system call by default. You can use the
--sync option to make df invoke sync before getting file system sizes.
* internationalized diagnostic messages
* mkdir accepts new option: --verbose
* `cp file D/' uses the full file name `D/file' instead of `D//file'.
* cp --backup a~ a fails instead of silently destroying the source file
* df and du have new options --human-readable (-h) and --megabytes (-m).
* install now honors --backup (-b), --suffix=SUFFIX (-S SUFFIX), and
--version-control=WORD (-V WORD) options just as cp, ln, and mv do.
* ln --verbose output is less prone to misinterpretation
* ls -o works like -lG; for compatibility with other versions of ls
* cp has a new option to control creation of sparse files:
--sparse={auto,always,never}. --sparse=auto is the default.
* rm -rf '' behaves properly on SunOS 4 systems
* touch: rename long option name, --file, to --reference.
`touch --file' will continue to work a little longer.
* df fails if the same file system type is both selected and excluded.
* df works around SunOS statfs brokenness wrt filesystems larger than 2GB
* df better handles inconsistent mtab entries
* `ls -lDR dir dir2' works
* `ls -c' does what it's supposed to
* all programs include program name in --version output
* `ls --quote-name' works
* mv properly determines whether src and dest are the same file
Before, it could (though with very low probability) fail to do the move,
reporting that distinct source and destination are the same file.
* du --dereference (-L) works with directory symlinks
* du works on SunOS 4 systems even when accounting is enabled
* many programs that convert strings to integers now use strtol or strtoul
and detect overflow
User-visible changes in release 3.12:
* None.
User-visible changes in release 3.11:
* None.
User-visible changes in release 3.10:
* mkdir -p now ignores arguments that are existing directories. Before,
(contrary to POSIX spec) it would attempt to change ownership and/or
protections of existing directories listed on the command line. And
it would fail when such a directory was owned by another user.
* Fix bug in cp that made the commands `mkdir dir; touch foo; cp -P foo dir'
incorrectly change the permissions on directory, dir.
* df accepts a new option, --no-sync, that inhibits the default invocation
of the sync system call.
* ls accepts a new option, --dired, that makes emacs' dired mode more efficient
* skeletal texinfo documentation (mainly just the `invoking' nodes)
* ln accepts a new option: --no-dereference (-n). With this option,
if the destination command line argument is a symlink to a directory,
use that as the destination instead of the file in the directory.
* `ln -i no-such-file existing-file' gives a diagnostic and fails.
Before, if you responded `yes' to the prompt it would both remove
`existing-file' and fail to make a link.
* du no longer requires read access to all of the directory components
of the current working directory on systems with fchdir.
* touch -d 'date' is no longer off by one hour.
* New program: sync.
* Fix bug in cp that made the commands `ln -s . s; cp -rd s r' incorrectly
create `r' as a symlink instead of as a regular file.
* du's -S and -c options now work when used together.
Before, the grand total was always reported to be zero.
Major changes in release 3.9:
* --help gives a one-line description of each option and shows the
correspondence between short and long-named options.
* work around systems with BROKEN_STAT_MACROS
* work around problem where $(srcdir)/config.h was used instead of
../config.h -- this happened only when building in a subdirectory
and when config.h remained in $(srcdir) from a previous ./configure.
* GNU chmod treats symlinks the same way other vendor's versions do.
Now symlinks listed on the command line are processed (they were
ignored before); the permissions of the dereferenced files are
changed. Symlinks encountered in recursive traversals are still
ignored. This makes GNU chmod act more like e.g. Sun's.
* configure uses config.h, so DEFS won't exceed preprocessor limits of
some compilers on the number of symbols defined via -D.
* ls and cp can handle mount points on more systems
@@ -11,7 +99,7 @@ Major changes in release 3.9:
They used to succeed, ignoring the implicitly contradictory trailing slash.
Major changes in release 3.8:
* install isn't as likely to produce spurious errors
* install isn't as likely to produce spurious errors
* avoid redundant compilations for `dir' and `vdir';
* configure properly defines STAT_STATFS2_BSIZE on a Pyramid MIServer
running OSx 5.1
@@ -37,7 +125,7 @@ Major changes in release 3.5:
Major changes in release 3.4:
* cp -p and mv preserve setuid and setgid bits
* chown works on systems where sizeof(uid_t) != sizeof(int)
* chown works on systems where sizeof(uid_t) != sizeof(int)
or sizeof(uid) != sizeof(gid)
* catch errors from spurious slashes at ends of arguments

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