Compare commits

..

155 Commits

Author SHA1 Message Date
Jim Meyering
b32c1f0696 *** empty log message *** 1998-08-16 04:24:38 +00:00
Jim Meyering
94d7c5b58c *** empty log message *** 1998-08-16 04:23:22 +00:00
Jim Meyering
0cb7d9a409 . 1998-08-16 04:22:49 +00:00
Jim Meyering
81bb7f1df3 . 1998-08-16 03:56:27 +00:00
Jim Meyering
7fc3b4cf7d *** empty log message *** 1998-08-16 03:56:15 +00:00
Jim Meyering
cef050f076 Use the new AC_CHECK_TYPE(ssize_t, int) instead of jm_TYPE_SSIZE_T. 1998-08-16 03:55:49 +00:00
Jim Meyering
919b805380 . 1998-08-16 03:55:36 +00:00
Jim Meyering
0e48a577b5 . 1998-08-16 03:53:30 +00:00
Jim Meyering
b0ead8f2d6 *** empty log message *** 1998-08-16 03:20:13 +00:00
Jim Meyering
5614a7d282 (do_move): Fail upon attempt to move a directory into itself.
With prodding from Franois Pinard :-)
1998-08-16 03:09:56 +00:00
Jim Meyering
9c5fb99864 Update for changed behavior of mv. 1998-08-16 03:05:01 +00:00
Jim Meyering
1145211d6b fix typos 1998-08-16 01:44:40 +00:00
Jim Meyering
0c35411a4f *** empty log message *** 1998-08-16 01:38:38 +00:00
Jim Meyering
8bd9ea509e *** empty log message *** 1998-08-16 01:37:02 +00:00
Jim Meyering
bddb246b90 *** empty log message *** 1998-08-16 01:28:55 +00:00
Jim Meyering
e646635206 *** empty log message *** 1998-08-16 00:03:06 +00:00
Jim Meyering
ea9e600f58 *** empty log message *** 1998-08-15 23:59:12 +00:00
Jim Meyering
78c34dee50 *** empty log message *** 1998-08-15 23:58:05 +00:00
Jim Meyering
56949aaebd . 1998-08-15 23:55:00 +00:00
Jim Meyering
18d7d6b082 . 1998-08-15 23:53:59 +00:00
Jim Meyering
0cb75a1a07 *** empty log message *** 1998-08-15 23:53:07 +00:00
Jim Meyering
cc271ce8f3 *** empty log message *** 1998-08-15 23:52:39 +00:00
Jim Meyering
bf73df9811 *** empty log message *** 1998-08-15 23:51:58 +00:00
Jim Meyering
b07a5a108e *** empty log message *** 1998-08-15 23:43:37 +00:00
Jim Meyering
2db8ef7c55 . 1998-08-15 23:29:09 +00:00
Jim Meyering
634ff11428 *** empty log message *** 1998-08-15 22:00:47 +00:00
Jim Meyering
c3b1ab8af1 *** empty log message *** 1998-08-15 21:57:55 +00:00
Jim Meyering
327a21114a *** empty log message *** 1998-08-15 21:57:17 +00:00
Jim Meyering
df91781926 *** empty log message *** 1998-08-15 21:54:10 +00:00
Jim Meyering
4431579378 *** empty log message *** 1998-08-15 21:52:09 +00:00
Jim Meyering
19afd110b3 *** empty log message *** 1998-08-15 21:51:44 +00:00
Jim Meyering
5b02046b20 *** empty log message *** 1998-08-15 21:41:49 +00:00
Jim Meyering
97a44fbdf0 *** empty log message *** 1998-08-15 21:40:06 +00:00
Jim Meyering
49d59ad66b *** empty log message *** 1998-08-15 21:39:17 +00:00
Jim Meyering
c2bbdeab6d *** empty log message *** 1998-08-15 21:38:08 +00:00
Jim Meyering
0d33861999 (copy_internal) [one-file-system]: Do copy mount point
directories (but none of their entries).  This makes
`cp --one-file-system' work the same way tar does.
From Marty Leisner.
1998-08-15 21:16:34 +00:00
Jim Meyering
9c38d004ec *** empty log message *** 1998-08-15 21:09:20 +00:00
Jim Meyering
a302182ac8 *** empty log message *** 1998-08-15 20:33:18 +00:00
Jim Meyering
6b0411ab47 *** empty log message *** 1998-08-15 20:23:33 +00:00
Jim Meyering
65ce4687f5 *** empty log message *** 1998-08-15 20:05:59 +00:00
Jim Meyering
363847ca74 *** empty log message *** 1998-08-15 19:55:35 +00:00
Jim Meyering
d223f01b43 *** empty log message *** 1998-08-15 19:50:54 +00:00
Jim Meyering
3a2b528573 *** empty log message *** 1998-08-15 19:30:32 +00:00
Jim Meyering
14717b8618 *** empty log message *** 1998-08-15 19:23:40 +00:00
Jim Meyering
dc8cd6e39a . 1998-08-15 18:40:41 +00:00
Jim Meyering
6db0107e71 *** empty log message *** 1998-08-15 18:39:45 +00:00
Jim Meyering
a6f74451d3 . 1998-08-15 18:39:38 +00:00
Jim Meyering
8d2302724c . 1998-08-15 18:38:04 +00:00
Jim Meyering
8fa35e89ca . 1998-08-15 18:37:55 +00:00
Jim Meyering
baad4b697c . 1998-08-15 18:37:36 +00:00
Jim Meyering
79d411ceba (qmark_funny_chars): Add comment from Paul eggert. 1998-08-15 16:43:13 +00:00
Jim Meyering
52070d3e4a *** empty log message *** 1998-08-15 14:48:36 +00:00
Jim Meyering
85cc6dedf8 *** empty log message *** 1998-08-15 14:47:50 +00:00
Jim Meyering
e3869f58ad (usage): Reformat a little. 1998-08-15 14:45:19 +00:00
Jim Meyering
c34fd6b4a7 (long_options): Add long names for all options.
(usage): Update help string.
(main): Handle the special options --pages and --columns.
1998-08-15 14:22:01 +00:00
Jim Meyering
63d64851b1 Add braces to suppress warning about ambiguous `else'. 1998-08-15 14:21:00 +00:00
Jim Meyering
d68269bb55 Add braces to suppress warning about ambiguous `else'. 1998-08-15 14:20:16 +00:00
Jim Meyering
2aa62088a3 Work around another bug in Ultrix4.3a's /bin/sh.
Reported by Christian von Roques.
1998-08-15 03:24:56 +00:00
Jim Meyering
f2d4fc8016 Avoid bug in Ultrix4.3a /bin/sh,
not initializing output redirection of : command.
1998-08-15 03:04:06 +00:00
Jim Meyering
bf57f4af46 Avoid bug in Ultrix4.3a /bin/sh,
not initializing output redirection of : command.
1998-08-15 03:03:44 +00:00
Jim Meyering
dc43a7bb60 *** empty log message *** 1998-08-15 03:01:44 +00:00
Jim Meyering
9d7c2d4f7d (read_filesystem_list) [MOUNTED_GETMNT]: Don't infloop on getmnt(2) returning 0.
Christian von Roques
1998-08-15 03:01:13 +00:00
Jim Meyering
888da5c359 *** empty log message *** 1998-08-14 14:14:07 +00:00
Jim Meyering
7b0caffd31 . 1998-08-14 14:09:05 +00:00
Jim Meyering
ed2a7b4e53 . 1998-08-13 18:08:14 +00:00
Jim Meyering
2a6a20ae20 . 1998-08-13 15:25:02 +00:00
Jim Meyering
1dce9a3295 . 1998-08-13 04:54:41 +00:00
Jim Meyering
f6da9983e4 *** empty log message *** 1998-08-13 04:12:33 +00:00
Jim Meyering
e6bc93f49a (DISTFILES): Remove ChangeLog. 1998-08-13 04:06:52 +00:00
Jim Meyering
88c0b8d630 Provide automake-style DESTDIR support.
From Johan Danielsson.
1998-08-13 04:01:46 +00:00
Jim Meyering
669ff7331b . 1998-08-13 02:11:10 +00:00
Jim Meyering
54667de765 . 1998-08-13 02:09:24 +00:00
Jim Meyering
736ea546d9 (noinst_HEADERS): Add filemode.h. 1998-08-13 02:07:54 +00:00
Jim Meyering
461aea548a Include filemode.h. 1998-08-13 02:06:41 +00:00
Jim Meyering
e31691fc1d Protoize. Tsort function definitions and remove prototypes of
static functions.
(mode_string): Remove prototype.
1998-08-13 02:05:56 +00:00
Jim Meyering
8e576e0036 . 1998-08-13 02:05:29 +00:00
Jim Meyering
b9fa91a205 (ftypelet): Add comments for Cray DMF support.
From Johan Danielsson.
1998-08-13 01:52:01 +00:00
Jim Meyering
ff438ee87f *** empty log message *** 1998-08-13 01:48:05 +00:00
Jim Meyering
34cd17408c . 1998-08-13 01:41:38 +00:00
Jim Meyering
138bad1512 add commented `diff -u' command 1998-08-12 17:14:34 +00:00
Jim Meyering
f0604f17d6 *** empty log message *** 1998-08-11 19:10:43 +00:00
Jim Meyering
3fce6c3270 . 1998-08-11 18:53:19 +00:00
Jim Meyering
ba36aa0602 *** empty log message *** 1998-08-11 18:40:21 +00:00
Jim Meyering
58a54666a7 *** empty log message *** 1998-08-11 18:17:01 +00:00
Jim Meyering
40178d3a77 *** empty log message *** 1998-08-11 17:35:57 +00:00
Jim Meyering
b9ca4fe720 . 1998-08-11 17:30:46 +00:00
Jim Meyering
c6afbb198c (rel-check): New rule. 1998-08-11 15:53:55 +00:00
Jim Meyering
c267424d7b automatically generate template for test release announcement 1998-08-11 15:23:01 +00:00
Jim Meyering
053a0e3a8e *** empty log message *** 1998-08-11 13:21:31 +00:00
Jim Meyering
39b1c602aa (usage): Correct description. Reported by John Murphy. 1998-08-11 13:16:24 +00:00
Jim Meyering
2df9108f70 *** empty log message *** 1998-08-11 13:16:11 +00:00
Jim Meyering
a2d2353f0d add comment from glibc version 1998-08-11 01:52:38 +00:00
Jim Meyering
6af7fe7bf9 *** empty log message *** 1998-08-09 20:08:27 +00:00
Jim Meyering
26abcd14d2 update from glibc 1998-08-07 12:54:51 +00:00
Jim Meyering
2fe9a639e5 *** empty log message *** 1998-08-03 03:03:29 +00:00
Jim Meyering
f1db42afed Ansideclify. 1998-08-03 03:03:11 +00:00
Jim Meyering
2d329c22c0 *** empty log message *** 1998-08-03 03:02:20 +00:00
Jim Meyering
c3db9f982a (readline): Return zero upon error as well as upon
end of file.  From James Youngman.
1998-08-03 03:02:04 +00:00
Jim Meyering
c01e767ceb . 1998-08-02 20:52:34 +00:00
Jim Meyering
0d16e71b07 . 1998-08-02 19:45:45 +00:00
Jim Meyering
2fcce776e8 . 1998-08-02 16:33:53 +00:00
Jim Meyering
bad1e4b2e1 *** empty log message *** 1998-08-02 16:33:45 +00:00
Jim Meyering
f5a228ae42 *** empty log message *** 1998-08-02 16:32:42 +00:00
Jim Meyering
a40eb86598 . 1998-08-02 16:25:14 +00:00
Jim Meyering
0136b885fe (re_protect): Add comment. 1998-08-02 16:24:41 +00:00
Jim Meyering
0f7ac75854 (ST_TIME_CMP_NS, ST_TIME_CMP, ATIME_CMP, CTIME_CMP, MTIME_CMP): New macros. 1998-08-02 16:24:13 +00:00
Jim Meyering
9fc5987250 (copy_internal): Compare time stamps with subsecond resolution if available. 1998-08-02 16:23:28 +00:00
Jim Meyering
e71d9696d7 (compare_ctime, rev_cmp_ctime, compare_mtime,
rev_cmp_mtime, compare_atime, rev_cmp_atime): Compare time
stamps with subsecond resolution if available.
1998-08-02 16:23:06 +00:00
Jim Meyering
6e1306ba8b (touch): Add comment. 1998-08-02 16:22:43 +00:00
Jim Meyering
a607901e48 (change_timestamps): Add comment. 1998-08-02 16:22:24 +00:00
Jim Meyering
01053400d0 *** empty log message *** 1998-08-02 16:20:50 +00:00
Jim Meyering
419b2d26fe Use hack to avoid having to put #undef HAVE_ST_MTIM in acconfig.h manually. 1998-08-02 16:20:39 +00:00
Jim Meyering
4ed33b3073 tweak indentation 1998-08-02 16:18:21 +00:00
Jim Meyering
ef9ee27d89 from Paul Eggert 1998-08-02 16:15:17 +00:00
Jim Meyering
277da1b998 *** empty log message *** 1998-08-02 04:16:01 +00:00
Jim Meyering
983b8c433c . 1998-08-01 15:48:56 +00:00
Jim Meyering
d5c69ef797 (my_setlocale): Guard definition within #ifdef ENABLE_NLS. 1998-08-01 15:47:26 +00:00
Jim Meyering
eb8ea6eac5 Avoid broken pipe message for tests that fail with usage errors. 1998-07-30 12:26:24 +00:00
Jim Meyering
da68f39411 * src/sort.c (usage): Add angle brackets to make `Report bugs...'
message consistent with all the rest.
1998-07-30 12:13:39 +00:00
Jim Meyering
2fcc1267b5 *** empty log message *** 1998-07-29 13:29:23 +00:00
Jim Meyering
4ead0cb8df (NEGATION_SIGN): Renamed from NEGATIVE_SIGN to avoid
clash with <langinfo.h>.  All uses changed.
From Andreas Schwab.
1998-07-29 13:29:10 +00:00
Jim Meyering
f96dc5e195 Avoid broken pipe for 'y' and 'z' tests.
From Andreas.
1998-07-29 13:27:28 +00:00
Jim Meyering
82e166ebbb *** empty log message *** 1998-07-29 04:01:45 +00:00
Jim Meyering
6a9aa3cf98 (show_all_fs):
Revert to boolean value; the old negative value is
now in show_local_fs.
(show_local_fs): New variable.
(show_dev): New args me_dummy and me_class.  Use show_local_fs
and boolean show_all_fs in combination with these new args
to decide whether to show a device.
(show_disk): Pass flags to show_dev.
(show_point): Use a non-dummy mount entry if possible.
(show_all_entries): Pass flags to show_dev.
(main): --local sets show_local_fs now.  Ask for file system types if
show_local_fs is nonzero, since ME_REMOTE might need them.

From Paul.
1998-07-29 04:01:29 +00:00
Jim Meyering
3cf7eece6f Remove duplicate include of <stdio.h>. 1998-07-29 04:00:36 +00:00
Jim Meyering
7dfff499c3 (struct mount_entry):
New members me_dummy, me_remote.
(read_filesystem_list): Remove all_fs argument.
(REMOTE_FS_TYPE): Remove.
(ME_DUMMY, ME_REMOTE): New macros.

From Paul.
1998-07-29 03:58:55 +00:00
Jim Meyering
52e2de5780 (read_filesystem_list): Remove all_fs
argument, but put the necessary information into the result so
that the caller can ignore filesystems that he's not
interested in.

From Paul.
1998-07-29 03:58:02 +00:00
Jim Meyering
c0d6757201 *** empty log message *** 1998-07-28 13:29:22 +00:00
Jim Meyering
3942f87ee3 *** empty log message *** 1998-07-28 13:20:20 +00:00
Jim Meyering
9d07c1872f Undef stat. 1998-07-28 13:15:58 +00:00
Jim Meyering
be388d139c *** empty log message *** 1998-07-27 14:25:10 +00:00
Jim Meyering
6e132bee5e Make copy create each destination file initially
with mode 0600 so strip will work, then apply specified mode.
Arne Henrik Juul reported that `./ginstall -s -c -m 555 dd /tmp' failed.
1998-07-27 13:39:36 +00:00
Jim Meyering
7d63d3c635 . 1998-07-27 13:38:42 +00:00
Jim Meyering
08d53c4c6a (TESTS_ENVIRONMENT): Set LS, MKDIR, and RM. 1998-07-27 13:27:45 +00:00
Jim Meyering
94edd792f7 use ls to check the permissions 1998-07-27 13:26:58 +00:00
Jim Meyering
5ab6986171 Test stripping an executable that eventually will be made unwritable. 1998-07-27 13:18:31 +00:00
Jim Meyering
25176dbdef *** empty log message *** 1998-07-26 21:48:37 +00:00
Jim Meyering
b49807bfb2 Convert some char* dcls to `unsigned char*' and remove a cast --
to placate irix4's cc.
1998-07-26 20:43:50 +00:00
Jim Meyering
d71367f33e (check_punctuation): Add cast to placate irix4's cc. Reported by Kaveh Ghazi. 1998-07-26 20:42:02 +00:00
Jim Meyering
bd85887daf (split_3): Add cast to placate irix4's cc. From Kaveh Ghazi. 1998-07-26 20:09:25 +00:00
Jim Meyering
82988e97cf (chown): Remove unused definition.
Reported by Kaveh Ghazi.
1998-07-26 04:13:57 +00:00
Jim Meyering
2b374ec2d9 . 1998-07-26 04:10:01 +00:00
Jim Meyering
3e3b8558d6 . 1998-07-26 04:06:55 +00:00
Jim Meyering
5c4cb177ef Add tests for new --output-delimiter option,
as well as for NUL input delimiter (--delimiter='').
1998-07-26 04:06:37 +00:00
Jim Meyering
71a3fc7989 . 1998-07-26 04:06:07 +00:00
Jim Meyering
5c9345dbd1 (cut_fields): Honor new --output-delimiter option.
(main): Fix handling of --delimiter='' (-d '').  Until now, it has
never worked as advertised.  I guess no one tried it.
1998-07-26 04:05:07 +00:00
Jim Meyering
287ddc8d05 *** empty log message *** 1998-07-26 03:59:27 +00:00
Jim Meyering
36ac5f1519 . 1998-07-26 02:59:37 +00:00
Jim Meyering
bde54af30f *** empty log message *** 1998-07-26 02:56:36 +00:00
Jim Meyering
cafbd3477a Add two tests. `sort -o no-file no-file' didn't fail. 1998-07-26 02:55:53 +00:00
Jim Meyering
165718775f (main): Stat all non-`-' input file files (and fail if a
stat fails) when an output file is specified by `-o' but doesn't exist.
1998-07-26 02:54:01 +00:00
Jim Meyering
f90d1551cb *** empty log message *** 1998-07-26 00:29:45 +00:00
Jim Meyering
613f0e187f (main): rmdir fails with EEXIST on some systems.
Handle that, so --ignore-fail-on-non-empty works.
(EEXIST): Define to zero if not defined.
(ENOTEMPTY): Likewise.
1998-07-26 00:29:30 +00:00
Jim Meyering
ca6da4ffce *** empty log message *** 1998-07-25 21:50:53 +00:00
Jim Meyering
ac517dbe89 Remove `diff' I'd put in for debugging.
Exit with the status from cmp.
1998-07-25 21:50:35 +00:00
81 changed files with 4527 additions and 556 deletions

View File

@@ -42,3 +42,39 @@ my-distcheck: dist
@echo "========================"; \
echo "$(distdir).tar.gz is ready for distribution"; \
echo "========================"
THIS_VERSION_REGEXP := $(shell echo $(VERSION)|sed 's/\./\\./g')
# FIXME: this works only for test releases.
PREV_VERSION := $(shell echo $(VERSION)|tr a-z Xa-y)
PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
v = Version
url = ftp://alpha.gnu.org/gnu/$(distdir).tar.gz
md5 = $(shell md5sum < $(distdir).tar.gz|sed 's/ -//')
rel-check:
tarz=/tmp/rel-check-tarz-$$$$; \
md5_tmp=/tmp/rel-check-md5-$$$$; \
set -e; \
trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
wget -q --output-document=$$tarz $(url); \
echo "$(md5) -" > $$md5_tmp; \
md5sum -c $$md5_tmp < $$tarz
announcement: NEWS ChangeLog $(distdir).tar.gz
@( \
echo Subject: $(distdir) released; \
echo; \
echo FIXME: put comments here; \
echo; \
echo " $(url)"; \
echo; \
echo "$(md5) $(distdir).tar.gz"; \
echo; \
echo NEWS:; \
sed -n "/$(THIS_VERSION_REGEXP)/,/$(PREV_VERSION_REGEXP)/p" NEWS \
| grep -v '^\['; \
echo; \
echo ChangeLog entries:; \
sed -n "/$v $(THIS_VERSION_REGEXP)/,/$v $(PREV_VERSION_REGEXP)/p" \
ChangeLog | grep -v '\* $v'; \
)

1
THANKS
View File

@@ -8,6 +8,7 @@ Bauke Jan Douma: bjdouma@xs4all.nl
Bengt Martensson: bengt@mathematik.uni-Bremen.de
Bjorn Helgaas: helgaas@rsn.hp.com
Charles Karney: karney@pppl.gov
Christian von Roques: roques@pond.sub.org
Dirk Lattermann: dlatt@t-online.de
Don Parsons: dparsons@synapse.kent.edu
Eirik Fuller: eirik@netcom.com

View File

@@ -18,7 +18,7 @@ libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
error.h exclude.h fnmatch.h fsusage.h \
error.h exclude.h filemode.h fnmatch.h fsusage.h \
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \

View File

@@ -107,7 +107,7 @@ libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
error.h exclude.h fnmatch.h fsusage.h \
error.h exclude.h filemode.h fnmatch.h fsusage.h \
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \

63
lib/bumpalloc.h Normal file
View File

@@ -0,0 +1,63 @@
/* BUMP_ALLOC macro - increase table allocation by one element.
Copyright (C) 1990, 1991, 1993, 1998 Free Software Foundation, Inc.
François Pinard <pinard@iro.umontreal.ca>, 1990.
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. */
/*-------------------------------------------------------------------------.
| Bump the allocation of the array pointed to by TABLE whenever required. |
| The table already has already COUNT elements in it, this macro ensure it |
| has enough space to accommodate at least one more element. Space is |
| allocated (2 ^ EXPONENT) elements at a time. Each element of the array |
| is of type TYPE. |
`-------------------------------------------------------------------------*/
/* Routines `xmalloc' and `xrealloc' are called to do the actual memory
management. This implies that the program will abort with an `Memory
exhausted!' error if any problem arise.
To work correctly, at least EXPONENT and TYPE should always be the
same for all uses of this macro for any given TABLE. A secure way to
achieve this is to never use this macro directly, but use it to define
other macros, which would then be TABLE-specific.
The first time through, COUNT is usually zero. Note that COUNT is not
updated by this macro, but it should be update elsewhere, later. This
is convenient, because it allows TABLE[COUNT] to refer to the new
element at the end. Once its construction is completed, COUNT++ will
record it in the table. Calling this macro several times in a row
without updating COUNT is a bad thing to do. */
#define BUMP_ALLOC(Table, Count, Exponent, Type) \
BUMP_ALLOC_WITH_SIZE ((Table), (Count), (Exponent), Type, sizeof (Type))
/* In cases `sizeof TYPE' would not always yield the correct value for
the size of each element entry, this macro accepts a supplementary
SIZE argument. The EXPONENT, TYPE and SIZE parameters should still
have the same value for all macro calls related to a specific TABLE. */
#define BUMP_ALLOC_WITH_SIZE(Table, Count, Exponent, Type, Size) \
do \
{ \
if (((Count) & (~(~0 << (Exponent)))) == 0) \
{ \
if ((Count) == 0) \
(Table) = (Type *) xmalloc ((1 << (Exponent)) * (Size)); \
else \
(Table) = (Type *) \
xrealloc ((Table), ((Count) + (1 << (Exponent))) * (Size)); \
} \
} \
while (0)

148
lib/diacrit.c Normal file
View File

@@ -0,0 +1,148 @@
/* Diacritics processing for a few character codes.
Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
François Pinard <pinard@iro.umontreal.ca>, 1988.
All this file is a temporary hack, waiting for locales in GNU.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "diacrit.h"
/* ISO 8859-1 Latin-1 code is used as the underlying character set. If
MSDOS is defined, IBM-PC's character set code is used instead. */
/*--------------------------------------------------------------------.
| For each alphabetic character, returns what it would be without its |
| possible diacritic symbol. |
`--------------------------------------------------------------------*/
const char diacrit_base[256] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', 0, 0, 0, 0, 0,
0, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', 0, 0, 0, 0, 0,
#ifdef MSDOS
'C', 'u', 'e', 'a', 'a', 'a', 'a', 'c',
'e', 'e', 'e', 'i', 'i', 'i', 'A', 'A',
'E', 'e', 'E', 'o', 'o', 'o', 'u', 'u',
'y', 'O', 'U', 0, 0, 0, 0, 0,
'a', 'i', 'o', 'u', 'n', 'N', 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
#else /* not MSDOS */
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'C',
'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I',
0, 'N', 'O', 'O', 'O', 'O', 'O', 0,
'O', 'U', 'U', 'U', 'U', 'Y', 0, 0,
'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c',
'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
0, 'n', 'o', 'o', 'o', 'o', 'o', 0,
'o', 'u', 'u', 'u', 'u', 'y', 0, 'y',
#endif /* not MSDOS */
};
/*------------------------------------------------------------------------.
| For each alphabetic character, returns a code of what its diacritic is, |
| according to the following codes: 1 (eE) over aA for latin diphtongs; 2 |
| (') acute accent; 3 (`) grave accent; 4 (^) circumflex accent; 5 (") |
| umlaut or diaraesis; 6 (~) tilda; 7 (,) cedilla; 8 (o) covering degree |
| symbol; 9 (|) slashed character. |
`------------------------------------------------------------------------*/
const char diacrit_diac[256] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 4, 0,
3, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 6, 0,
#ifdef MSDOS
7, 5, 2, 4, 5, 3, 8, 7,
4, 5, 3, 5, 4, 3, 5, 8,
2, 1, 1, 4, 5, 3, 4, 3,
5, 5, 5, 0, 0, 0, 0, 0,
2, 2, 2, 2, 6, 6, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
#else /* not MSDOS */
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
3, 2, 4, 6, 5, 8, 1, 7,
3, 2, 4, 5, 3, 2, 4, 5,
0, 6, 3, 2, 4, 6, 5, 0,
9, 3, 2, 4, 5, 2, 0, 0,
3, 2, 4, 6, 5, 8, 1, 7,
3, 2, 4, 5, 3, 2, 4, 5,
0, 6, 3, 2, 4, 6, 5, 0,
9, 3, 2, 4, 5, 2, 0, 0,
#endif /* not MSDOS */
};

16
lib/diacrit.h Normal file
View File

@@ -0,0 +1,16 @@
/* Diacritics processing for a few character codes.
Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
François Pinard <pinard@iro.umontreal.ca>, 1988.
All this file is a temporary hack, waiting for locales in GNU.
*/
extern const char diacrit_base[]; /* characters without diacritics */
extern const char diacrit_diac[]; /* diacritic code for each character */
/* Returns CHAR without its diacritic. CHAR is known to be alphabetic. */
#define tobase(Char) (diacrit_base[(unsigned char) (Char)])
/* Returns a diacritic code for CHAR. CHAR is known to be alphabetic. */
#define todiac(Char) (diacrit_diac[(unsigned char) (Char)])

View File

@@ -22,6 +22,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "filemode.h"
#if !S_IRUSR
# if S_IREAD
# define S_IRUSR S_IREAD
@@ -88,10 +90,132 @@
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
#endif
void mode_string ();
static char ftypelet ();
static void rwx ();
static void setst ();
/* Look at read, write, and execute bits in BITS and set
flags in CHARS accordingly. */
static void
rwx (short unsigned int bits, char *chars)
{
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,
according to the file mode BITS. */
static void
setst (short unsigned int bits, char *chars)
{
#ifdef S_ISUID
if (bits & S_ISUID)
{
if (chars[3] != 'x')
/* Set-uid, but not executable by owner. */
chars[3] = 'S';
else
chars[3] = 's';
}
#endif
#ifdef S_ISGID
if (bits & S_ISGID)
{
if (chars[6] != 'x')
/* Set-gid, but not executable by group. */
chars[6] = 'S';
else
chars[6] = 's';
}
#endif
#ifdef S_ISVTX
if (bits & S_ISVTX)
{
if (chars[9] != 'x')
/* Sticky, but not executable by others. */
chars[9] = 'T';
else
chars[9] = 't';
}
#endif
}
/* Return a character indicating the type of file described by
file mode BITS:
'd' for directories
'b' for block special files
'c' for character special files
'm' for multiplexor files
'M' for an off-line (regular) file
'l' for symbolic links
's' for sockets
'p' for fifos
'-' for regular files
'?' for any other file type. */
static char
ftypelet (long int bits)
{
#ifdef S_ISBLK
if (S_ISBLK (bits))
return 'b';
#endif
if (S_ISCHR (bits))
return 'c';
if (S_ISDIR (bits))
return 'd';
if (S_ISREG (bits))
return '-';
#ifdef S_ISFIFO
if (S_ISFIFO (bits))
return 'p';
#endif
#ifdef S_ISLNK
if (S_ISLNK (bits))
return 'l';
#endif
#ifdef S_ISSOCK
if (S_ISSOCK (bits))
return 's';
#endif
#ifdef S_ISMPC
if (S_ISMPC (bits))
return 'm';
#endif
#ifdef S_ISNWK
if (S_ISNWK (bits))
return 'n';
#endif
/* The following two tests are for Cray DMF (Data Migration
Facility), which is a HSM file system. A migrated file has a
`st_dm_mode' that is different from the normal `st_mode', so any
tests for migrated files should use the former. */
#ifdef S_ISOFD
if (S_ISOFD (bits))
/* off line, with data */
return 'M';
#endif
#ifdef S_ISOFL
/* off line, with no data */
if (S_ISOFL (bits))
return 'M';
#endif
return '?';
}
/* Like filemodestring, but only the relevant part of the `struct stat'
is given as an argument. */
void
mode_string (short unsigned int mode, char *str)
{
str[0] = ftypelet ((long) mode);
rwx ((mode & 0700) << 0, &str[1]);
rwx ((mode & 0070) << 3, &str[4]);
rwx ((mode & 0007) << 6, &str[7]);
setst (mode, str);
}
/* filemodestring - fill in string STR with an ls-style ASCII
representation of the st_mode field of file stats block STATP.
@@ -130,137 +254,7 @@ static void setst ();
'T' if the file is sticky but not executable. */
void
filemodestring (statp, str)
struct stat *statp;
char *str;
filemodestring (struct stat *statp, char *str)
{
mode_string (statp->st_mode, str);
}
/* Like filemodestring, but only the relevant part of the `struct stat'
is given as an argument. */
void
mode_string (mode, str)
unsigned short mode;
char *str;
{
str[0] = ftypelet ((long) mode);
rwx ((mode & 0700) << 0, &str[1]);
rwx ((mode & 0070) << 3, &str[4]);
rwx ((mode & 0007) << 6, &str[7]);
setst (mode, str);
}
/* Return a character indicating the type of file described by
file mode BITS:
'd' for directories
'b' for block special files
'c' for character special files
'm' for multiplexor files
'l' for symbolic links
's' for sockets
'p' for fifos
'-' for regular files
'?' for any other file type. */
static char
ftypelet (bits)
long bits;
{
#ifdef S_ISBLK
if (S_ISBLK (bits))
return 'b';
#endif
if (S_ISCHR (bits))
return 'c';
if (S_ISDIR (bits))
return 'd';
if (S_ISREG (bits))
return '-';
#ifdef S_ISFIFO
if (S_ISFIFO (bits))
return 'p';
#endif
#ifdef S_ISLNK
if (S_ISLNK (bits))
return 'l';
#endif
#ifdef S_ISSOCK
if (S_ISSOCK (bits))
return 's';
#endif
#ifdef S_ISMPC
if (S_ISMPC (bits))
return 'm';
#endif
#ifdef S_ISNWK
if (S_ISNWK (bits))
return 'n';
#endif
#ifdef S_ISOFD
/* Cray migrated dmf file. */
if (S_ISOFD (bits))
return 'M';
#endif
#ifdef S_ISOFL
/* Cray migrated dmf file. */
if (S_ISOFL (bits))
return 'M';
#endif
return '?';
}
/* Look at read, write, and execute bits in BITS and set
flags in CHARS accordingly. */
static void
rwx (bits, chars)
unsigned short bits;
char *chars;
{
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,
according to the file mode BITS. */
static void
setst (bits, chars)
unsigned short bits;
char *chars;
{
#ifdef S_ISUID
if (bits & S_ISUID)
{
if (chars[3] != 'x')
/* Set-uid, but not executable by owner. */
chars[3] = 'S';
else
chars[3] = 's';
}
#endif
#ifdef S_ISGID
if (bits & S_ISGID)
{
if (chars[6] != 'x')
/* Set-gid, but not executable by group. */
chars[6] = 'S';
else
chars[6] = 's';
}
#endif
#ifdef S_ISVTX
if (bits & S_ISVTX)
{
if (chars[9] != 'x')
/* Sticky, but not executable by others. */
chars[9] = 'T';
else
chars[9] = 't';
}
#endif
}

1
lib/filemode.h Normal file
View File

@@ -0,0 +1 @@
void mode_string (short unsigned int mode, char *str);

View File

@@ -1,5 +1,5 @@
/* linebuffer.c -- read arbitrarily long lines
Copyright (C) 1986, 1991 Free Software Foundation, Inc.
Copyright (C) 1986, 1991, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,11 +12,15 @@
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. */
/* Written by Richard Stallman. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include "linebuffer.h"
@@ -27,8 +31,7 @@ void free ();
/* Initialize linebuffer LINEBUFFER for use. */
void
initbuffer (linebuffer)
struct linebuffer *linebuffer;
initbuffer (struct linebuffer *linebuffer)
{
linebuffer->length = 0;
linebuffer->size = 200;
@@ -37,19 +40,18 @@ initbuffer (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. */
Return zero upon error or upon end of file.
Otherwise, return LINEBUFFER. */
struct linebuffer *
readline (linebuffer, stream)
struct linebuffer *linebuffer;
FILE *stream;
readline (struct linebuffer *linebuffer, FILE *stream)
{
int c;
char *buffer = linebuffer->buffer;
char *p = linebuffer->buffer;
char *end = buffer + linebuffer->size; /* Sentinel. */
if (feof (stream))
if (feof (stream) || ferror (stream))
{
linebuffer->length = 0;
return 0;
@@ -83,8 +85,7 @@ readline (linebuffer, stream)
/* Free linebuffer LINEBUFFER and its data, all allocated with malloc. */
void
freebuffer (linebuffer)
struct linebuffer *linebuffer;
freebuffer (struct linebuffer *linebuffer)
{
free (linebuffer->buffer);
free (linebuffer);

View File

@@ -281,13 +281,10 @@ fstype_to_string (int t)
/* Return a list of the currently mounted filesystems, or NULL on error.
Add each entry to the tail of the list so that they stay in order.
If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
the returned list are valid. Otherwise, they might not be.
If ALL_FS is positive, return all entries; if zero, omit entries
for filesystems that are automounter (dummy) entries; if negative,
also omit non-local filesystems. */
the returned list are valid. Otherwise, they might not be. */
struct mount_entry *
read_filesystem_list (int need_fs_type, int all_fs)
read_filesystem_list (int need_fs_type)
{
struct mount_entry *mount_list;
struct mount_entry *me;
@@ -308,12 +305,12 @@ read_filesystem_list (int need_fs_type, int all_fs)
return NULL;
for (p = mntlist; p; p = p->next) {
mnt = p->ment;
if (all_fs < 0 && REMOTE_FS_TYPE (mnt->mnt_type))
continue;
me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
me->me_devname = xstrdup(mnt->mnt_fsname);
me->me_mountdir = xstrdup(mnt->mnt_dir);
me->me_type = xstrdup(mnt->mnt_type);
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = -1;
*mtail = me;
mtail = &me->me_next;
@@ -335,16 +332,12 @@ read_filesystem_list (int need_fs_type, int all_fs)
while ((mnt = getmntent (fp)))
{
if (all_fs <= 0 && (!strcmp (mnt->mnt_type, "ignore")
|| !strcmp (mnt->mnt_type, "auto")))
continue;
if (all_fs < 0 && REMOTE_FS_TYPE (mnt->mnt_type))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (mnt->mnt_fsname);
me->me_mountdir = xstrdup (mnt->mnt_dir);
me->me_type = xstrdup (mnt->mnt_type);
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
devopt = strstr (mnt->mnt_opts, "dev=");
if (devopt)
{
@@ -377,13 +370,13 @@ read_filesystem_list (int need_fs_type, int all_fs)
for (; entries-- > 0; fsp++)
{
char *fs_type = fsp_to_string (fsp);
if (all_fs < 0 && REMOTE_FS_TYPE (fs_type))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (fsp->f_mntfromname);
me->me_mountdir = xstrdup (fsp->f_mntonname);
me->me_type = fs_type;
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
/* Add to the linked list. */
@@ -400,16 +393,15 @@ read_filesystem_list (int need_fs_type, int all_fs)
struct fs_data fsd;
while (errno = 0,
0 <= (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
(char *) 0)))
0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
(char *) 0)))
{
if (all_fs < 0 && REMOTE_FS_TYPE (gt_names[fsd.fd_req.fstype]))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (fsd.fd_req.devname);
me->me_mountdir = xstrdup (fsd.fd_req.path);
me->me_type = gt_names[fsd.fd_req.fstype];
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = fsd.fd_req.dev;
/* Add to the linked list. */
@@ -442,13 +434,12 @@ read_filesystem_list (int need_fs_type, int all_fs)
for (counter = 0; counter < numsys; counter++)
{
if (all_fs < 0 && REMOTE_FS_TYPE (mnt_names[stats[counter].f_type]))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (stats[counter].f_mntfromname);
me->me_mountdir = xstrdup (stats[counter].f_mntonname);
me->me_type = mnt_names[stats[counter].f_type];
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
/* Add to the linked list. */
@@ -472,24 +463,6 @@ read_filesystem_list (int need_fs_type, int all_fs)
while (fread (&mnt, sizeof mnt, 1, fp) > 0)
{
char *fs_type = "";
# ifdef GETFSTYP /* SVR3. */
if (need_fs_type || all_fs < 0)
{
struct statfs fsd;
char typebuf[FSTYPSZ];
if (statfs (mnt.mt_filsys, &fsd, sizeof fsd, 0) != -1
&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
{
if (all_fs < 0 && REMOTE_FS_TYPE (typebuf))
continue;
fs_type = xstrdup (typebuf);
}
}
# endif
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
# ifdef GETFSTYP /* SVR3. */
me->me_devname = xstrdup (mnt.mt_dev);
@@ -500,7 +473,20 @@ read_filesystem_list (int need_fs_type, int all_fs)
# endif
me->me_mountdir = xstrdup (mnt.mt_filsys);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_type = fs_type;
me->me_type = "";
# ifdef GETFSTYP /* SVR3. */
if (need_fs_type)
{
struct statfs fsd;
char typebuf[FSTYPSZ];
if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
me->me_type = xstrdup (typebuf);
}
# endif
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
/* Add to the linked list. */
*mtail = me;
@@ -525,13 +511,12 @@ read_filesystem_list (int need_fs_type, int all_fs)
struct mntent **mnttbl=getmnttbl(),**ent;
for (ent=mnttbl;*ent;ent++)
{
if (all_fs < 0 && REMOTE_FS_TYPE ((*ent)->mt_fstype))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup ( (*ent)->mt_resource);
me->me_mountdir = xstrdup( (*ent)->mt_directory);
me->me_type = xstrdup ((*ent)->mt_fstype);
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
/* Add to the linked list. */
@@ -587,17 +572,12 @@ read_filesystem_list (int need_fs_type, int all_fs)
{
while ((ret = getmntent (fp, &mnt)) == 0)
{
/* Don't show automounted filesystems twice on e.g., Solaris. */
if (all_fs <= 0 && MNT_IGNORE (&mnt))
continue;
if (all_fs < 0 && REMOTE_FS_TYPE (mnt.mnt_fstype))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (mnt.mnt_special);
me->me_mountdir = xstrdup (mnt.mnt_mountp);
me->me_type = xstrdup (mnt.mnt_fstype);
me->me_dummy = MNT_IGNORE (&mnt) != 0;
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
/* Add to the linked list. */
@@ -636,13 +616,12 @@ read_filesystem_list (int need_fs_type, int all_fs)
thisent += vmp->vmt_length)
{
vmp = (struct vmount *) thisent;
if (all_fs < 0 && vmp->vmt_flags & MNT_REMOTE)
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
if (vmp->vmt_flags & MNT_REMOTE)
{
char *host, *path;
me->me_remote = 1;
/* Prepend the remote pathname. */
host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
@@ -653,11 +632,13 @@ read_filesystem_list (int need_fs_type, int all_fs)
}
else
{
me->me_remote = 0;
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_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */
/* Add to the linked list. */

View File

@@ -22,6 +22,8 @@ struct mount_entry
char *me_mountdir; /* Mount point directory pathname. */
char *me_type; /* "nfs", "4.2", etc. */
dev_t me_dev; /* Device number of me_mountdir. */
unsigned int me_dummy : 1; /* Nonzero for dummy filesystems. */
unsigned int me_remote : 1; /* Nonzero for remote fileystems. */
struct mount_entry *me_next;
};
@@ -33,11 +35,13 @@ struct mount_entry
# endif
#endif
struct mount_entry *read_filesystem_list PARAMS ((int need_fs_type,
int all_fs));
struct mount_entry *read_filesystem_list PARAMS ((int need_fs_type));
/* In most environments, by default, a filesystem type is remote if it
begins with "nfs". This allows variants like "nfs3". */
#ifndef REMOTE_FS_TYPE
# define REMOTE_FS_TYPE(t) (!strncmp (t, "nfs", 3))
#ifndef ME_DUMMY
# define ME_DUMMY(fs_name, fs_type) \
(!strcmp (fs_type, "auto") || !strcmp (fs_type, "ignore"))
#endif
#ifndef ME_REMOTE
# define ME_REMOTE(fs_name, fs_type) (strchr (fs_name, ':') != 0)
#endif

View File

@@ -55,10 +55,36 @@
/* For platform which support the ISO C amendement 1 functionality we
support user defined character classes. */
#if WIDE_CHAR_SUPPORT
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
# include <wchar.h>
# include <wctype.h>
#endif
#ifdef _LIBC
/* We have to keep the namespace clean. */
# define regfree(preg) __regfree (preg)
# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
# define regerror(errcode, preg, errbuf, errbuf_size) \
__regerror(errcode, preg, errbuf, errbuf_size)
# define re_set_registers(bu, re, nu, st, en) \
__re_set_registers (bu, re, nu, st, en)
# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
__re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
# define re_match(bufp, string, size, pos, regs) \
__re_match (bufp, string, size, pos, regs)
# define re_search(bufp, string, size, startpos, range, regs) \
__re_search (bufp, string, size, startpos, range, regs)
# define re_compile_pattern(pattern, length, bufp) \
__re_compile_pattern (pattern, length, bufp)
# define re_set_syntax(syntax) __re_set_syntax (syntax)
# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
__re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
#define btowc __btowc
#endif
/* This is for other GNU distributions with internationalized messages. */
#if HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
@@ -110,8 +136,12 @@ char *realloc ();
# ifndef INHIBIT_STRING_HEADER
# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC
# include <string.h>
# if !defined bzero && !defined _LIBC
# define bzero(s, n) (memset (s, '\0', n), (s))
# ifndef bzero
# ifndef _LIBC
# define bzero(s, n) (memset (s, '\0', n), (s))
# else
# define bzero(s, n) __bzero (s, n)
# endif
# endif
# else
# include <strings.h>
@@ -195,7 +225,8 @@ init_syntax_once ()
STDC_HEADERS is defined, then autoconf has verified that the ctype
macros don't need to be guarded with references to isascii. ...
Defining isascii to 1 should let any compiler worth its salt
eliminate the && through constant folding." */
eliminate the && through constant folding."
Solaris defines some of these symbols so we must undefine them first. */
#undef ISASCII
#if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
@@ -971,6 +1002,9 @@ re_set_syntax (syntax)
#endif /* DEBUG */
return ret;
}
#ifdef _LIBC
weak_alias (__re_set_syntax, re_set_syntax)
#endif
/* This table gives an error message for each of the error codes listed
in regex.h. Obviously the order here has to be same as there.
@@ -1699,7 +1733,11 @@ typedef struct
# define CHAR_CLASS_MAX_LENGTH 256
# endif
# define IS_CHAR_CLASS(string) wctype (string)
# ifdef _LIBC
# define IS_CHAR_CLASS(string) __wctype (string)
# else
# define IS_CHAR_CLASS(string) wctype (string)
# endif
#else
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
@@ -2176,14 +2214,14 @@ regex_compile (pattern, size, syntax, bufp)
for (;;)
{
PATFETCH (c);
if (c == ':' || c == ']' || p == pend
if ((c == ':' && *p == ']') || p == pend
|| c1 == CHAR_CLASS_MAX_LENGTH)
break;
str[c1++] = c;
}
str[c1] = '\0';
/* If isn't a word bracketed by `[:' and:`]':
/* If isn't a word bracketed by `[:' and `:]':
undo the ending character, the letters, and leave
the leading `:' and `[' (but set bits for them). */
if (c == ':' && *p == ']')
@@ -2194,7 +2232,7 @@ regex_compile (pattern, size, syntax, bufp)
wctype_t wt;
int ch;
wt = wctype (str);
wt = IS_CHAR_CLASS (str);
if (wt == 0)
FREE_STACK_RETURN (REG_ECTYPE);
@@ -2206,8 +2244,13 @@ regex_compile (pattern, size, syntax, bufp)
for (ch = 0; ch < 1 << BYTEWIDTH; ++ch)
{
# ifdef _LIBC
if (__iswctype (__btowc (ch), wt))
SET_LIST_BIT (ch);
#else
if (iswctype (btowc (ch), wt))
SET_LIST_BIT (ch);
#endif
if (translate && (is_upper || is_lower)
&& (ISUPPER (ch) || ISLOWER (ch)))
@@ -2691,7 +2734,7 @@ regex_compile (pattern, size, syntax, bufp)
case 'w':
if (re_syntax_options & RE_NO_GNU_OPS)
if (syntax & RE_NO_GNU_OPS)
goto normal_char;
laststart = b;
BUF_PUSH (wordchar);
@@ -2699,7 +2742,7 @@ regex_compile (pattern, size, syntax, bufp)
case 'W':
if (re_syntax_options & RE_NO_GNU_OPS)
if (syntax & RE_NO_GNU_OPS)
goto normal_char;
laststart = b;
BUF_PUSH (notwordchar);
@@ -2707,37 +2750,37 @@ regex_compile (pattern, size, syntax, bufp)
case '<':
if (re_syntax_options & RE_NO_GNU_OPS)
if (syntax & RE_NO_GNU_OPS)
goto normal_char;
BUF_PUSH (wordbeg);
break;
case '>':
if (re_syntax_options & RE_NO_GNU_OPS)
if (syntax & RE_NO_GNU_OPS)
goto normal_char;
BUF_PUSH (wordend);
break;
case 'b':
if (re_syntax_options & RE_NO_GNU_OPS)
if (syntax & RE_NO_GNU_OPS)
goto normal_char;
BUF_PUSH (wordbound);
break;
case 'B':
if (re_syntax_options & RE_NO_GNU_OPS)
if (syntax & RE_NO_GNU_OPS)
goto normal_char;
BUF_PUSH (notwordbound);
break;
case '`':
if (re_syntax_options & RE_NO_GNU_OPS)
if (syntax & RE_NO_GNU_OPS)
goto normal_char;
BUF_PUSH (begbuf);
break;
case '\'':
if (re_syntax_options & RE_NO_GNU_OPS)
if (syntax & RE_NO_GNU_OPS)
goto normal_char;
BUF_PUSH (endbuf);
break;
@@ -3375,6 +3418,9 @@ re_compile_fastmap (bufp)
RESET_FAIL_STACK ();
return 0;
} /* re_compile_fastmap */
#ifdef _LIBC
weak_alias (__re_compile_fastmap, re_compile_fastmap)
#endif
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
@@ -3410,6 +3456,9 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
regs->start = regs->end = (regoff_t *) 0;
}
}
#ifdef _LIBC
weak_alias (__re_set_registers, re_set_registers)
#endif
/* Searching routines. */
@@ -3426,6 +3475,9 @@ re_search (bufp, string, size, startpos, range, regs)
return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
regs, size);
}
#ifdef _LIBC
weak_alias (__re_search, re_search)
#endif
/* Using the compiled pattern in BUFP->buffer, first tries to match the
@@ -3479,7 +3531,11 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
/* If the search isn't to be a backwards one, don't waste time in a
search for a pattern that must be anchored. */
if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0)
if (bufp->used > 0 && range > 0
&& ((re_opcode_t) bufp->buffer[0] == begbuf
/* `begline' is like `begbuf' if it cannot match at newlines. */
|| ((re_opcode_t) bufp->buffer[0] == begline
&& !bufp->newline_anchor)))
{
if (startpos > 0)
return -1;
@@ -3582,6 +3638,9 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
}
return -1;
} /* re_search_2 */
#ifdef _LIBC
weak_alias (__re_search_2, re_search_2)
#endif
/* This converts PTR, a pointer into one of the search strings `string1'
and `string2' into an offset from the beginning of that string. */
@@ -3683,6 +3742,9 @@ re_match (bufp, string, size, pos, regs)
# endif
return result;
}
# ifdef _LIBC
weak_alias (__re_match, re_match)
# endif
#endif /* not emacs */
static boolean group_match_null_string_p _RE_ARGS ((unsigned char **p,
@@ -3728,6 +3790,9 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
#endif
return result;
}
#ifdef _LIBC
weak_alias (__re_match_2, re_match_2)
#endif
/* This is a separate function so that we can force an alloca cleanup
afterwards. */
@@ -5421,6 +5486,9 @@ re_compile_pattern (pattern, length, bufp)
return NULL;
return gettext (re_error_msgid[(int) ret]);
}
#ifdef _LIBC
weak_alias (__re_compile_pattern, re_compile_pattern)
#endif
/* Entry points compatible with 4.2 BSD regex library. We don't define
them unless specifically requested. */
@@ -5453,12 +5521,12 @@ re_comp (s)
{
re_comp_buf.buffer = (unsigned char *) malloc (200);
if (re_comp_buf.buffer == NULL)
return gettext (re_error_msgid[(int) REG_ESPACE]);
return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
re_comp_buf.allocated = 200;
re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
if (re_comp_buf.fastmap == NULL)
return gettext (re_error_msgid[(int) REG_ESPACE]);
return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
}
/* Since `re_exec' always passes NULL for the `regs' argument, we
@@ -5591,6 +5659,9 @@ regcomp (preg, pattern, cflags)
return (int) ret;
}
#ifdef _LIBC
weak_alias (__regcomp, regcomp)
#endif
/* regexec searches for a given pattern, specified by PREG, in the
@@ -5667,6 +5738,9 @@ regexec (preg, string, nmatch, pmatch, eflags)
/* We want zero return to mean success, unlike `re_search'. */
return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
}
#ifdef _LIBC
weak_alias (__regexec, regexec)
#endif
/* Returns a message corresponding to an error code, ERRCODE, returned
@@ -5712,6 +5786,9 @@ regerror (errcode, preg, errbuf, errbuf_size)
return msg_size;
}
#ifdef _LIBC
weak_alias (__regerror, regerror)
#endif
/* Free dynamically allocated space used by PREG. */
@@ -5736,5 +5813,8 @@ regfree (preg)
free (preg->translate);
preg->translate = NULL;
}
#ifdef _LIBC
weak_alias (__regfree, regfree)
#endif
#endif /* not emacs */

View File

@@ -442,11 +442,15 @@ typedef struct
/* Sets the current default syntax to SYNTAX, and return the old syntax.
You can also simply assign to the `re_syntax_options' variable. */
extern reg_syntax_t __re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
/* Compile the regular expression PATTERN, with length LENGTH
and syntax given by the global `re_syntax_options', into the buffer
BUFFER. Return NULL if successful, and an error string if not. */
extern const char *__re_compile_pattern
_RE_ARGS ((const char *pattern, size_t length,
struct re_pattern_buffer *buffer));
extern const char *re_compile_pattern
_RE_ARGS ((const char *pattern, size_t length,
struct re_pattern_buffer *buffer));
@@ -455,6 +459,7 @@ extern const char *re_compile_pattern
/* Compile a fastmap for the compiled pattern in BUFFER; used to
accelerate searches. Return 0 if successful and -2 if was an
internal error. */
extern int __re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
@@ -463,6 +468,9 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
characters. Return the starting position of the match, -1 for no
match, or -2 for an internal error. Also return register
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
extern int __re_search
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
int length, int start, int range, struct re_registers *regs));
extern int re_search
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
int length, int start, int range, struct re_registers *regs));
@@ -470,6 +478,10 @@ extern int re_search
/* Like `re_search', but search in the concatenation of STRING1 and
STRING2. Also, stop searching at index START + STOP. */
extern int __re_search_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, int range, struct re_registers *regs, int stop));
extern int re_search_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
@@ -478,12 +490,19 @@ extern int re_search_2
/* Like `re_search', but return how many characters in STRING the regexp
in BUFFER matched, starting at position START. */
extern int __re_match
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
int length, int start, struct re_registers *regs));
extern int re_match
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
int length, int start, struct re_registers *regs));
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
extern int __re_match_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, struct re_registers *regs, int stop));
extern int re_match_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
@@ -502,6 +521,9 @@ extern int re_match_2
Unless this function is called, the first search or match using
PATTERN_BUFFER will allocate its own register data, without
freeing the old data. */
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));
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));
@@ -515,14 +537,25 @@ extern int re_exec _RE_ARGS ((const char *));
#endif
/* POSIX compatibility. */
extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags));
extern int regexec
_RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags));
extern size_t regerror
_RE_ARGS ((int errcode, const regex_t *preg, char *errbuf,
size_t errbuf_size));
extern void regfree _RE_ARGS ((regex_t *preg));
extern int __regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern,
int __cflags));
extern int regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern,
int __cflags));
extern int __regexec _RE_ARGS ((const regex_t *__preg,
const char *__string, size_t __nmatch,
regmatch_t __pmatch[], int __eflags));
extern int regexec _RE_ARGS ((const regex_t *__preg,
const char *__string, size_t __nmatch,
regmatch_t __pmatch[], int __eflags));
extern size_t __regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
char *__errbuf, size_t __errbuf_size));
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
char *__errbuf, size_t __errbuf_size));
extern void __regfree _RE_ARGS ((regex_t *__preg));
extern void regfree _RE_ARGS ((regex_t *__preg));
#ifdef __cplusplus

View File

@@ -21,6 +21,8 @@
# include <config.h>
#endif
/* Some pre-ANSI implementations (e.g. SunOS 4)
need stderr defined if assertion checking is enabled. */
#include <stdio.h>
#if STDC_HEADERS
@@ -36,12 +38,6 @@
# endif
#endif
/* Some pre-ANSI implementations (e.g. SunOS 4)
need stderr defined if assertion checking is enabled. */
#ifndef NDEBUG
# include <stdio.h>
#endif
#include <assert.h>
#include <errno.h>

View File

@@ -1,3 +1,27 @@
1998-08-15 Jim Meyering <meyering@ascend.com>
* ssize_t.m4 (jm_TYPE_SSIZE_T): Remove file.
* check-type.m4: New file. Replacement for AC_CHECK_TYPE.
* jm-macros.m4: Use the new AC_CHECK_TYPE(ssize_t, int)
instead of jm_TYPE_SSIZE_T.
1998-08-12 Jim Meyering <meyering@ascend.com>
* st_dm_mode.m4: New file. From Johan Danielsson.
1998-08-02 Jim Meyering <meyering@ascend.com>
* st_mtim.m4: Use hack to avoid having to put #undef HAVE_ST_MTIM
in acconfig.h manually.
1998-07-31 Paul Eggert <eggert@twinsun.com>
* st_mtim.m4: New file.
1998-07-28 Jim Meyering <meyering@ascend.com>
* utimes.m4: Undef stat.
1998-07-25 Jim Meyering <meyering@ascend.com>
* utime.m4 (jm_FUNC_UTIME): New file and macro.

View File

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

View File

@@ -89,14 +89,14 @@ VERSION = @VERSION@
YACC = @YACC@
l = @l@
EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 chown.m4 \
const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 fstypename.m4 getgroups.m4 \
getline.m4 getloadavg.m4 gettext.m4 inttypes_h.m4 isc-posix.m4 \
jm-glibc-io.m4 jm-macros.m4 jm-mktime.m4 jm-winsz1.m4 jm-winsz2.m4 \
lchown.m4 lcmessage.m4 lfs.m4 ls-mntd-fs.m4 lstat.m4 malloc.m4 memcmp.m4 \
perl.m4 prereq.m4 progtest.m4 putenv.m4 readdir.m4 realloc.m4 regex.m4 \
ssize_t.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4 utime.m4 \
utimes.m4
EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 check-type.m4 \
chown.m4 const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 fstypename.m4 \
getgroups.m4 getline.m4 getloadavg.m4 gettext.m4 inttypes_h.m4 \
isc-posix.m4 jm-glibc-io.m4 jm-macros.m4 jm-mktime.m4 jm-winsz1.m4 \
jm-winsz2.m4 lchown.m4 lcmessage.m4 lfs.m4 ls-mntd-fs.m4 lstat.m4 \
malloc.m4 memcmp.m4 perl.m4 prereq.m4 progtest.m4 putenv.m4 readdir.m4 \
realloc.m4 regex.m4 st_dm_mode.m4 st_mtim.m4 stat.m4 strftime.m4 \
uintmax_t.m4 uptime.m4 utimbuf.m4 utime.m4 utimes.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =

28
m4/check-type.m4 Normal file
View File

@@ -0,0 +1,28 @@
#serial 1
dnl Just like AC_CHECK_TYPE from autoconf-2.12, but also checks in unistd.h
dnl on systems that have it. Fujitsu UXP/V needs this for ssize_t.
undefine([AC_CHECK_TYPE])
dnl AC_CHECK_TYPE(TYPE, DEFAULT)
AC_DEFUN(AC_CHECK_TYPE,
[AC_REQUIRE([AC_HEADER_STDC])dnl
AC_CHECK_HEADERS(unistd.h)
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(ac_cv_type_$1,
[AC_EGREP_CPP(dnl
changequote(<<,>>)dnl
<<$1[^a-zA-Z_0-9]>>dnl
changequote([,]), [#include <sys/types.h>
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
AC_MSG_RESULT($ac_cv_type_$1)
if test $ac_cv_type_$1 = no; then
AC_DEFINE($1, $2)
fi
])

View File

@@ -11,7 +11,7 @@ AC_DEFUN(jm_MACROS,
AC_REQUIRE([jm_ASSERT])
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
AC_REQUIRE([jm_TYPE_SSIZE_T])
AC_CHECK_TYPE(ssize_t, int)
AC_REQUIRE([jm_STRUCT_UTIMBUF])
AC_REQUIRE([jm_STRUCT_DIRENT_D_TYPE])
AC_REQUIRE([jm_STRUCT_DIRENT_D_INO])

View File

@@ -1,19 +0,0 @@
#serial 1
dnl From Jim Meyering
# If ssize_t is not defined in sys/types.h, define it to `int'.
AC_DEFUN(jm_TYPE_SSIZE_T,
[AC_CACHE_CHECK(for ssize_t in sys/types.h, jm_ac_cv_type_ssize_t,
[
AC_EGREP_HEADER(ssize_t, sys/types.h,
jm_ac_cv_type_ssize_t=yes,
jm_ac_cv_type_ssize_t=no)
if test $jm_ac_cv_type_ssize_t = no; then
AC_DEFINE(ssize_t, int)
fi
]
)
]
)

25
m4/st_dm_mode.m4 Normal file
View File

@@ -0,0 +1,25 @@
# Define HAVE_ST_DM_MODE if struct stat has an st_dm_mode member.
AC_DEFUN(AC_STRUCT_ST_DM_MODE,
[AC_CACHE_CHECK([for st_dm_mode in struct stat], ac_cv_struct_st_dm_mode,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/stat.h>], [struct stat s; s.st_dm_mode;],
ac_cv_struct_st_dm_mode=yes,
ac_cv_struct_st_dm_mode=no)])
if test $ac_cv_struct_st_dm_mode = yes; then
if test x = y; then
# This code is deliberately never run via ./configure.
# FIXME: this is a hack to make autoheader put the corresponding
# HAVE_* undef for this symbol in config.h.in. This saves me the
# trouble of having to add the #undef in acconfig.h manually.
AC_CHECK_FUNCS(ST_DM_MODE)
fi
# Defining it this way (rather than via AC_DEFINE) short-circuits the
# autoheader check -- autoheader doesn't know it's already been taken
# care of by the hack above.
ac_kludge=HAVE_ST_DM_MODE
AC_DEFINE_UNQUOTED($ac_kludge)
fi
]
)

29
m4/st_mtim.m4 Normal file
View File

@@ -0,0 +1,29 @@
#serial 2
dnl From Paul Eggert.
# Define HAVE_ST_MTIM if struct stat has an st_mtim member.
AC_DEFUN(AC_STRUCT_ST_MTIM,
[AC_CACHE_CHECK([for st_mtim in struct stat], ac_cv_struct_st_mtim,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/stat.h>], [struct stat s; s.st_mtim;],
ac_cv_struct_st_mtim=yes,
ac_cv_struct_st_mtim=no)])
if test $ac_cv_struct_st_mtim = yes; then
if test x = y; then
# This code is deliberately never run via ./configure.
# FIXME: this is a hack to make autoheader put the corresponding
# HAVE_* undef for this symbol in config.h.in. This saves me the
# trouble of having to add the #undef in acconfig.h manually.
AC_CHECK_FUNCS(ST_MTIM)
fi
# Defining it this way (rather than via AC_DEFINE) short-circuits the
# autoheader check -- autoheader doesn't know it's already been taken
# care of by the hack above.
ac_kludge=HAVE_ST_MTIM
AC_DEFINE_UNQUOTED($ac_kludge)
fi
]
)

View File

@@ -1,18 +1,23 @@
#serial 1
#serial 2
dnl Shamelessly cloned from acspecific.m4's AC_FUNC_UTIME_NULL.
AC_DEFUN(jm_FUNC_UTIMES_NULL,
[AC_CACHE_CHECK(whether utimes accepts a null argument, ac_cv_func_utimes_null,
[rm -f conftestdata; > conftestdata
AC_TRY_RUN([#include <sys/types.h>
AC_TRY_RUN([
/* In case stat has been defined to rpl_stat, undef it here. */
#undef stat
#include <sys/types.h>
#include <sys/stat.h>
main() {
struct stat s, t;
exit(!(stat ("conftestdata", &s) == 0 && utimes("conftestdata", (long *)0) == 0
&& stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
&& t.st_mtime - s.st_mtime < 120));
}], ac_cv_func_utimes_null=yes, ac_cv_func_utimes_null=no,
}],
ac_cv_func_utimes_null=yes,
ac_cv_func_utimes_null=no,
ac_cv_func_utimes_null=no)
rm -f core core.* *.core])

View File

@@ -1,5 +1,137 @@
1998-08-15 Jim Meyering <meyering@ascend.com>
* Version 3.16u.
* Makefile.maint (announcement): New target.
* tests/mv/into-self: Update to reflect changed behavior of mv.
* src/mv.c (do_move): Fail upon attempt to move a directory into itself.
With prodding from François Pinard :-)
* tests/ls-2/Fetish.pm: New file
* tests/ls-2/run-test: New file
* src/copy.c (copy_internal) [one-file-system]: Do copy mount point
directories (but none of their entries). This makes `cp --archive
--one-file-system' use the same policy `tar --one-file-system' does.
From Marty Leisner.
* src/ls.c (qmark_funny_chars): Add comment from Paul eggert.
1998-08-14 Jim Meyering <meyering@ascend.com>
* tests/mv/setup: Work around another bug in Ultrix4.3a's /bin/sh.
Reported by Christian von Roques.
* configure.in (AC_OUTPUT): Add tests/ls-2/Makefile.
* tests/Makefile.am (SUBDIRS): Add ls-2.
* tests/ls-2: New directory
1998-08-14 Christian von Roques <roques@pond.sub.org>
* lib/mountlist.c (read_filesystem_list) [MOUNTED_GETMNT]: Don't
infloop on getmnt(2) returning 0.
* tests/cp/backup-is-src: Avoid bug in Ultrix4.3a /bin/sh,
not initializing output redirection of : command.
* tests/mv/backup-is-src: Likewise.
* tests/rm/i-1: Likewise.
1998-08-12 Jim Meyering <meyering@ascend.com>
* po/Makefile.in.in: Provide automake-style DESTDIR support.
From Johan Danielsson.
(DISTFILES): Remove ChangeLog.
po/ChangeLog: Remove empty file.
* configure.in (AC_STRUCT_ST_DM_MODE): Use it.
* src/ls.c: Include filemode.h.
* src/chmod.c: Likewise.
* lib/filemode.c (ftypelet): Add comments for Cray DMF support.
From Johan Danielsson.
Protoize. Tsort function definitions and remove prototypes of
static functions.
(mode_string): Remove prototype.
* lib/filemode.h (mode_string): New file.
* lib/Makefile.am (noinst_HEADERS): Add filemode.h.
1998-08-09 Jim Meyering <meyering@ascend.com>
* Version 3.16t.
1998-07-31 Paul Eggert <eggert@twinsun.com>
Add support for filesystems whose timestamps have better resolution
than 1 second (e.g. Solaris 2.6, recent Linux kernels).
* configure.in (AC_STRUCT_ST_MTIM): Add.
* src/copy.c (copy_internal): Compare time stamps with
subsecond resolution if available.
* src/ls.c (compare_ctime, rev_cmp_ctime, compare_mtime,
rev_cmp_mtime, compare_atime, rev_cmp_atime): Compare time
stamps with subsecond resolution if available.
* src/system.h: (ST_TIME_CMP_NS, ST_TIME_CMP, ATIME_CMP,
CTIME_CMP, MTIME_CMP): New macros.
1998-08-01 Jim Meyering <meyering@ascend.com>
* configure.in (ALL_LINGUAS): Add slovak (sk) and norwegian (no).
1998-07-28 Paul Eggert <eggert@twinsun.com>
* lib/mountlist.c (read_filesystem_list): Remove all_fs
argument, but put the necessary information into the result so
that the caller can ignore filesystems that he's not
interested in.
* lib/mountlist.h (struct mount_entry):
New members me_dummy, me_remote.
(read_filesystem_list): Remove all_fs argument.
(REMOTE_FS_TYPE): Remove.
(ME_DUMMY, ME_REMOTE): New macros.
* lib/xstrtol.c: Remove duplicate include of <stdio.h>.
* src/df.c (show_all_fs):
Revert to boolean value; the old negative value is
now in show_local_fs.
(show_local_fs): New variable.
(show_dev): New args me_dummy and me_class. Use show_local_fs
and boolean show_all_fs in combination with these new args
to decide whether to show a device.
(show_disk): Pass flags to show_dev.
(show_point): Use a non-dummy mount entry if possible.
(show_all_entries): Pass flags to show_dev.
(main): --local sets show_local_fs now. Ask for file system types if
show_local_fs is nonzero, since ME_REMOTE might need them.
1998-07-27 Jim Meyering <meyering@ascend.com>
* tests/install/Makefile.am (TESTS_ENVIRONMENT): Set LS, MKDIR, and RM.
* tests/install/basic-1: Add a test for this.
* src/install.c: Make copy create each destination file initially
with mode 0600 so strip will work, then apply specified mode.
Arne Henrik Juul reported that `./ginstall -s -c -m 555 dd /tmp' failed.
1998-07-25 Jim Meyering <meyering@ascend.com>
* src/mv.c (chown): Remove unused definition.
Reported by Kaveh Ghazi.
* src/rmdir.c (main): rmdir fails with EEXIST on some systems.
Handle that, so --ignore-fail-on-non-empty works.
(EEXIST): Define to zero if not defined.
(ENOTEMPTY): Likewise.
* tests/cp/same-file: Remove `diff' I'd put in for debugging.
Exit with the status from cmp.
* Version 3.16s.
* tests/cp/same-file: Skip three more unportable tests.

View File

@@ -1,4 +1,13 @@
Changes in release 3.17:
[3.16u]
* mv now fails (as it should) upon attempt to move a directory into itself
* `cp -a --one-file-system' now copies any mount point directories it
encounters on the selected file system.
[3.16t]
* cp (with --update) and ls compare time stamps with subsecond resolution when
available (e.g., on systems with recent Linux kernels and on Solaris 2.6).
* install once again does the -m-specified chmod *after* running strip
(this fixes another bug introduced in 3.16o)
[3.16s]
* df accept a new option --local (-l)
* touch works around a system-specific bug so it now affects existing,

View File

@@ -1,3 +1,7 @@
1998-08-11 Jim Meyering <meyering@ascend.com>
* src/uptime.c (usage): Correct description. Reported by John Murphy.
1998-07-16 Jim Meyering <meyering@ascend.com>
* lib/Makefile.am (noinst_HEADERS): Add lchown.h.

View File

@@ -1,8 +1,83 @@
1998-07-16 Jim Meyering <meyering@ascend.com>
1998-08-15 Jim Meyering <meyering@ascend.com>
* src/pr.c (usage): Reformat.
* src/ptx.c: Add braces to suppress warning about ambiguous `else'.
* lib/bumpalloc.h: Likewise.
1998-08-13 François Pinard <pinard@iro.umontreal.ca>
* src/ptx.c: New file.
* src/Makefile.am (bin_PROGRAMS): Add ptx.
* lib/bumpalloc.h, lib/diacrit.h, lib/diacrit.c: New files.
* lib/Makefile.am (libtu_a_SOURCES): Add diacrit.c.
(noinst_HEADERS): Add bumpalloc.h and diacrit.h.
1998-08-09 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* src/pr.c (long_options): Add long names for all options.
(usage): Update help string.
(main): Handle the special options --pages and --columns.
1998-08-02 Jim Meyering <meyering@ascend.com>
* lib/linebuffer.c (readline): Return zero upon error as well as upon
end of file. From James Youngman.
Ansideclify.
1998-08-01 Jim Meyering <meyering@ascend.com>
* src/sort.c (my_setlocale): Guard definition within #ifdef ENABLE_NLS.
From Manfred Hollstein.
1998-07-30 Jim Meyering <meyering@ascend.com>
* tests/cut/Test.pm: Avoid broken pipe message for tests that fail
with usage errors.
* src/sort.c (usage): Add angle brackets to make `Report bugs...'
message consistent with all the rest.
1998-07-28 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* tests/cut/Test.pm: Avoid broken pipe for 'y' and 'z' tests.
* src/sort.c (NEGATION_SIGN): Renamed from NEGATIVE_SIGN to avoid
clash with <langinfo.h>. All uses changed.
1998-07-26 Jim Meyering <meyering@ascend.com>
* intl/localealias.c (read_alias_file): Avoid mixing `char*' and
`unsigned char*' variables. Again for irix4.
Mostly from Kaveh Ghazi.
* src/join.c: Convert some char* dcls to `unsigned char*' and remove
a cast -- to placate irix4's cc.
* src/fmt.c (check_punctuation): Add cast to placate irix4's cc.
Reported by Kaveh Ghazi.
* src/md5sum.c (split_3): Add cast to placate irix4's cc.
From Kaveh Ghazi.
1998-07-25 Jim Meyering <meyering@ascend.com>
* Version 1.22f.
* src/chown.c: Include lchown.h.
* tests/cut/Test.pm: Add tests for new --output-delimiter option,
as well as for NUL input delimiter (--delimiter='').
* src/cut.c (cut_fields): Honor new --output-delimiter option.
(main): Fix handling of --delimiter='' (-d ''). Until now, it has
never worked as advertised. I guess no one tried it.
* tests/sort/Test.pm: Add two tests relating to this.
* src/sort.c (main): Stat all non-`-' input file files (and fail if a
stat fails) when an output file is specified by `-o' but doesn't exist.
Reported by Will Edgington.
* tests/sort/Test.pm: New tests of -o.
1998-07-16 Jim Meyering <meyering@ascend.com>
* lib/Makefile.am (noinst_HEADERS): Add lchown.h.
* lib/lchown.h: New file, just to define ENOSYS on systems that lack it.
* lib/lchown.c: Include lchown.h.

View File

@@ -1,5 +1,10 @@
Changes in release 1.23
[1.22g]
* pr accepts long option names (see `pr --help')
* new program: ptx (moved to this package from being its own distribution)
[1.22f]
* cut accepts new --output-delimiter=STR option
* `sort -o no-such-file no-such-file' now fails, as it should
* fix pr bug: pr -td didn't double space
* fix tac bug when using -b, -r, and -s SEPARATOR
* fix sort bug whereby using key-local `d' option would cause following

View File

@@ -26,7 +26,7 @@ subdir = po
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
MKINSTALLDIRS = @MKINSTALLDIRS@
CC = @CC@
GENCAT = @GENCAT@
@@ -46,7 +46,7 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
SOURCES = cat-id-tbl.c
POFILES = @POFILES@
GMOFILES = @GMOFILES@
DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(PACKAGE).pot \
DISTFILES = Makefile.in.in POTFILES.in $(PACKAGE).pot \
stamp-cat-id $(POFILES) $(GMOFILES) $(SOURCES)
POTFILES = \
@@ -110,17 +110,17 @@ install-exec:
install-data: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(datadir); \
if test -x "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(datadir); \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
fi
@catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
case "$$cat" in \
*.gmo) destdir=$(gnulocaledir);; \
*) destdir=$(localedir);; \
*.gmo) destdir=$(DESTDIR)$(gnulocaledir);; \
*) destdir=$(DESTDIR)$(localedir);; \
esac; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
dir=$$destdir/$$lang/LC_MESSAGES; \
@@ -152,13 +152,13 @@ install-data-yes: all
fi; \
done
if test "$(PACKAGE)" = "gettext"; then \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(gettextsrcdir); \
if test -x "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
fi; \
$(INSTALL_DATA) $(srcdir)/Makefile.in.in \
$(gettextsrcdir)/Makefile.in.in; \
$(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
else \
: ; \
fi
@@ -171,12 +171,12 @@ uninstall:
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
done
rm -f $(gettextsrcdir)/po-Makefile.in.in
rm -f $(DESTDIR)$(gettextsrcdir)/po-Makefile.in.in
check: all

View File

@@ -27,6 +27,7 @@
#include "closeout.h"
#include "error.h"
#include "savedir.h"
#include "filemode.h"
enum Change_status
{
@@ -47,7 +48,6 @@ enum Verbosity
V_off
};
void mode_string ();
void strip_trailing_slashes ();
static int change_dir_mode PARAMS ((const char *dir,

View File

@@ -381,10 +381,6 @@ copy_internal (const char *src_path, const char *dst_path,
return 1;
}
/* Are we crossing a file system boundary? */
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
return 0;
/* We wouldn't insert a node unless nlink > 1, except that we need to
find created files so as to not copy infinitely if a directory is
copied into itself. */
@@ -491,7 +487,7 @@ copy_internal (const char *src_path, const char *dst_path,
return 1;
}
if (x->update && src_sb.st_mtime <= dst_sb.st_mtime)
if (x->update && MTIME_CMP (src_sb, dst_sb) <= 0)
return 0;
}
@@ -661,6 +657,10 @@ copy_internal (const char *src_path, const char *dst_path,
if (x->verbose)
printf ("%s -> %s\n", src_path, dst_path);
/* Are we crossing a file system boundary? */
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
return 0;
}
/* Copy the contents of the directory. */
@@ -818,6 +818,10 @@ copy_internal (const char *src_path, const char *dst_path,
{
struct utimbuf utb;
/* There's currently no interface to set file timestamps with
better than 1-second resolution, so discard any fractional
part of the source timestamp. */
utb.actime = src_sb.st_atime;
utb.modtime = src_sb.st_mtime;

View File

@@ -233,6 +233,10 @@ re_protect (const char *const_dst_path, int src_offset,
{
struct utimbuf utb;
/* There's currently no interface to set file timestamps with
better than 1-second resolution, so discard any fractional
part of the source timestamp. */
utb.actime = src_sb.st_atime;
utb.modtime = src_sb.st_mtime;

View File

@@ -68,6 +68,8 @@
#include "system.h"
#include "error.h"
char *xstrdup ();
#define FATAL_ERROR(s) \
do \
{ \
@@ -156,6 +158,13 @@ static int suppress_non_delimited;
/* The delimeter character for field mode. */
static int delim;
/* The length of output_delimiter_string. */
static size_t output_delimiter_length;
/* The output field separator string. Defaults to the 1-character
string consisting of the input delimiter. */
static char *output_delimiter_string;
/* Nonzero if we have ever read standard input. */
static int have_read_stdin;
@@ -172,6 +181,7 @@ static struct option const longopts[] =
{"fields", required_argument, 0, 'f'},
{"delimiter", required_argument, 0, 'd'},
{"only-delimited", no_argument, 0, 's'},
{"output-delimiter", required_argument, 0, 14},
{"help", no_argument, &show_help, 1},
{"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
@@ -198,6 +208,8 @@ Print selected parts of lines from each FILE to standard output.\n\
-f, --fields=LIST output only these fields\n\
-n (ignored)\n\
-s, --only-delimited do not print lines not containing delimiters\n\
--output-delimiter=STRING use STRING as the output delimiter\n\
the default is to use the input delimiter\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
@@ -580,8 +592,8 @@ cut_fields (FILE *stream)
{
if (found_any_selected_field)
{
/* FIXME: use output delimiter here */
putchar (delim);
fwrite (output_delimiter_string, sizeof (char),
output_delimiter_length, stdout);
}
found_any_selected_field = 1;
@@ -677,6 +689,7 @@ int
main (int argc, char **argv)
{
int optc, exit_status = 0;
int delim_specified = 0;
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -723,6 +736,15 @@ main (int argc, char **argv)
if (optarg[0] != '\0' && optarg[1] != '\0')
FATAL_ERROR (_("the delimiter must be a single character"));
delim = optarg[0];
delim_specified = 1;
break;
case 14:
/* Interpret --output-delimiter='' to mean
`use the NUL byte as the delimiter.' */
output_delimiter_length = (optarg[0] == '\0'
? 1 : strlen (optarg));
output_delimiter_string = xstrdup (optarg);
break;
case 'n':
@@ -756,9 +778,18 @@ main (int argc, char **argv)
FATAL_ERROR (_("suppressing non-delimited lines makes sense\n\
\tonly when operating on fields"));
if (delim == '\0')
if (!delim_specified)
delim = '\t';
if (output_delimiter_string == NULL)
{
static char dummy[2];
dummy[0] = delim;
dummy[1] = '\0';
output_delimiter_string = dummy;
output_delimiter_length = 1;
}
if (optind == argc)
exit_status |= cut_file ("-");
else

View File

@@ -47,10 +47,13 @@ char *program_name;
/* If nonzero, show inode information. */
static int inode_format;
/* If positive, show all entries; if zero, omit size-zero entries and
automounter dummies; if negative, also omit non-local filesystems. */
/* If nonzero, show even filesystems with zero size or
uninteresting types. */
static int show_all_fs;
/* If nonzero, show only local filesystems. */
static int show_local_fs;
/* If nonzero, output data for each filesystem corresponding to a
command line argument -- even if it's a dummy (automounter) entry. */
static int show_listed_fs;
@@ -206,26 +209,31 @@ df_readable (uintmax_t n, char *buf,
filesystem on DISK.
If FSTYPE is non-NULL, it is the type of the filesystem on DISK.
If MOUNT_POINT is non-NULL, then DISK may be NULL -- certain systems may
not be able to produce statistics in this case. */
not be able to produce statistics in this case.
ME_DUMMY and ME_REMOTE are the mount entry flags. */
static void
show_dev (const char *disk, const char *mount_point, const char *fstype)
show_dev (const char *disk, const char *mount_point, const char *fstype,
int me_dummy, int me_remote)
{
struct fs_usage fsu;
const char *stat_file;
if (me_remote && show_local_fs)
return;
if (me_dummy && show_all_fs == 0 && !show_listed_fs)
return;
if (!selected_fstype (fstype) || excluded_fstype (fstype))
return;
/* If MOUNT_POINT is NULL, then the filesystem is not mounted, and this
program reports on the filesystem that the special file is on.
It would be better to report on the unmounted filesystem,
but statfs doesn't do that on most systems. */
stat_file = mount_point ? mount_point : disk;
if (show_all_fs < 0 && fstype && REMOTE_FS_TYPE (fstype))
return;
if (!selected_fstype (fstype) || excluded_fstype (fstype))
return;
if (get_fs_usage (stat_file, disk, &fsu))
{
error (0, errno, "%s", stat_file);
@@ -233,7 +241,7 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
return;
}
if (fsu.fsu_blocks == 0 && show_all_fs <= 0 && !show_listed_fs)
if (fsu.fsu_blocks == 0 && !show_all_fs && !show_listed_fs)
return;
if (! disk)
@@ -354,11 +362,12 @@ show_disk (const char *disk)
for (me = mount_list; me; me = me->me_next)
if (STREQ (disk, me->me_devname))
{
show_dev (me->me_devname, me->me_mountdir, me->me_type);
show_dev (me->me_devname, me->me_mountdir, me->me_type,
me->me_dummy, me->me_remote);
return;
}
/* No filesystem is mounted on DISK. */
show_dev (disk, (char *) NULL, (char *) NULL);
show_dev (disk, (char *) NULL, (char *) NULL, 0, 0);
}
/* Return the root mountpoint of the filesystem on which FILE exists, in
@@ -440,6 +449,7 @@ show_point (const char *point, const struct stat *statp)
{
struct stat disk_stats;
struct mount_entry *me;
struct mount_entry *matching_dummy = NULL;
for (me = mount_list; me; me = me->me_next)
{
@@ -462,11 +472,27 @@ show_point (const char *point, const struct stat *statp)
if (stat (me->me_mountdir, &disk_stats) != 0 ||
disk_stats.st_dev != me->me_dev)
continue;
show_dev (me->me_devname, me->me_mountdir, me->me_type);
/* Prefer non-dummy entries. */
if (me->me_dummy)
{
matching_dummy = me;
continue;
}
show_dev (me->me_devname, me->me_mountdir, me->me_type,
me->me_dummy, me->me_remote);
return;
}
}
if (matching_dummy)
{
show_dev (matching_dummy->me_devname, matching_dummy->me_mountdir,
matching_dummy->me_type, 1, matching_dummy->me_remote);
return;
}
/* We couldn't find the mount entry corresponding to POINT. Go ahead and
print as much info as we can; methods that require the device to be
present will fail at a later point. */
@@ -475,7 +501,7 @@ show_point (const char *point, const struct stat *statp)
char *mp = find_mount_point (point, statp);
if (mp)
{
show_dev (0, mp, 0);
show_dev (0, mp, 0, 0, 0);
free (mp);
}
else
@@ -504,7 +530,8 @@ show_all_entries (void)
struct mount_entry *me;
for (me = mount_list; me; me = me->me_next)
show_dev (me->me_devname, me->me_mountdir, me->me_type);
show_dev (me->me_devname, me->me_mountdir, me->me_type,
me->me_dummy, me->me_remote);
}
/* Add FSTYPE to the list of filesystem types to display. */
@@ -616,7 +643,7 @@ main (int argc, char **argv)
output_block_size = 1024;
break;
case 'l':
show_all_fs = -1;
show_local_fs = 1;
break;
case 'm':
output_block_size = 1024 * 1024;
@@ -715,8 +742,8 @@ main (int argc, char **argv)
mount_list =
read_filesystem_list ((fs_select_list != NULL
|| fs_exclude_list != NULL
|| print_type),
optind == argc ? show_all_fs : 1);
|| print_type
|| show_local_fs));
if (mount_list == NULL)
error (1, errno, _("cannot read table of mounted filesystems"));

View File

@@ -708,7 +708,7 @@ check_punctuation (register WORD *w)
{
const unsigned char *start, *finish;
start = w->text;
start = (unsigned char *) w->text;
finish = start + (w->length - 1);
w->paren = isopen (*start);
w->punct = ISPUNCT (*finish);

View File

@@ -135,7 +135,7 @@ enum backup_type get_version ();
int stat ();
static int change_timestamps PARAMS ((const char *from, const char *to));
static int change_attributes PARAMS ((const char *path, mode_t mode));
static int change_attributes PARAMS ((const char *path));
static int copy_file PARAMS ((const char *from, const char *to,
const struct cp_options *x));
static int install_file_to_path PARAMS ((const char *from, const char *to,
@@ -168,6 +168,10 @@ static char *group_name;
/* The group ID corresponding to `group_name'. */
static gid_t group_id;
/* The permissions to which the files will be set. The umask has
no effect. */
static mode_t mode = 0755;
/* If nonzero, strip executable files after copying them. */
static int strip_files;
@@ -218,8 +222,13 @@ cp_option_init (struct cp_options *x)
x->recursive = 0;
x->sparse_mode = SPARSE_AUTO;
x->symbolic_link = 0;
/* Create destination files initially writable so we can run strip on them.
Although GNU strip works fine on read-only files, some others
would fail. */
x->set_mode = 1;
x->mode = 0755;
x->mode = 0600;
x->umask_kill = 0;
x->update = 0;
x->verbose = 0;
@@ -337,7 +346,7 @@ main (int argc, char **argv)
error (1, 0, _("invalid mode `%s'"), symbolic_mode);
else if (change == MODE_MEMORY_EXHAUSTED)
error (1, 0, _("virtual memory exhausted"));
x.mode = mode_adjust (0, change);
mode = mode_adjust (0, change);
}
get_ids ();
@@ -348,7 +357,7 @@ main (int argc, char **argv)
for (i = 0; i < n_files; i++)
{
errors |=
make_path (file[i], x.mode, x.mode, owner_id, group_id, 0,
make_path (file[i], mode, mode, owner_id, group_id, 0,
(x.verbose ? "creating directory `%s'" : NULL));
}
}
@@ -414,7 +423,7 @@ install_file_to_path (const char *from, const char *to,
rules, it's not so bad. Maybe use something like this instead:
int parent_dir_mode = (mode | (S_IRUGO | S_IXUGO)) & (~SPECIAL_BITS);
*/
fail = make_path (dest_dir, x->mode, x->mode, owner_id, group_id, 0,
fail = make_path (dest_dir, mode, mode, owner_id, group_id, 0,
(x->verbose ? _("creating directory `%s'") : NULL));
}
else
@@ -439,7 +448,7 @@ install_file_in_file (const char *from, const char *to,
return 1;
if (strip_files)
strip (to);
if (change_attributes (to, x->mode))
if (change_attributes (to))
return 1;
if (x->preserve_timestamps)
return change_timestamps (from, to);
@@ -493,7 +502,7 @@ copy_file (const char *from, const char *to, const struct cp_options *x)
Return 0 if successful, 1 if not. */
static int
change_attributes (const char *path, mode_t mode)
change_attributes (const char *path)
{
int err = 0;
@@ -540,6 +549,11 @@ change_timestamps (const char *from, const char *to)
error (0, errno, "%s", from);
return 1;
}
/* There's currently no interface to set file timestamps with
better than 1-second resolution, so discard any fractional
part of the source timestamp. */
utb.actime = stb.st_atime;
utb.modtime = stb.st_mtime;
if (utime (to, &utb))

View File

@@ -61,15 +61,15 @@ struct outlist
/* A field of a line. */
struct field
{
const char *beg; /* First character in field. */
const unsigned char *beg; /* First character in field. */
size_t len; /* The length of the field. */
};
/* A line read from an input file. Newlines are not stored. */
struct line
{
char *beg; /* First character in line. */
char *lim; /* Character after last character in line. */
unsigned char *beg; /* First character in line. */
unsigned char *lim; /* Character after last character in line. */
int nfields; /* Number of elements in `fields'. */
int nfields_allocated; /* Number of elements in `fields'. */
struct field *fields;
@@ -171,7 +171,7 @@ separated by CHAR.\n\
}
static void
ADD_FIELD (struct line *line, const char *field, size_t len)
ADD_FIELD (struct line *line, const unsigned char *field, size_t len)
{
if (line->nfields >= line->nfields_allocated)
{
@@ -191,7 +191,8 @@ static void
xfields (struct line *line)
{
int i;
unsigned char *ptr, *lim;
unsigned char *ptr;
unsigned char *lim;
ptr = line->beg;
lim = line->lim;
@@ -229,8 +230,7 @@ xfields (struct line *line)
}
}
if ((char *) ptr > line->beg
&& ((tab && ISSPACE (ptr[-1])) || ptr[-1] == tab))
if (ptr > line->beg && ((tab && ISSPACE (ptr[-1])) || ptr[-1] == tab))
{
/* Add one more (empty) field because the last character of the
line was a delimiter. */
@@ -246,7 +246,7 @@ get_line (FILE *fp, struct line *line)
{
static int linesize = 80;
int c, i;
char *ptr;
unsigned char *ptr;
if (feof (fp))
return 0;
@@ -330,7 +330,9 @@ delseq (struct seq *seq)
static int
keycmp (struct line *line1, struct line *line2)
{
const char *beg1, *beg2; /* Start of field to compare in each file. */
/* Start of field to compare in each file. */
const unsigned char *beg1, *beg2;
int len1, len2; /* Length of fields to compare. */
int diff;

View File

@@ -72,6 +72,7 @@
#include "xstrtol.h"
#include "strverscmp.h"
#include "quotearg.h"
#include "filemode.h"
#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
@@ -132,8 +133,6 @@ struct bin_str
time_t time ();
#endif
void mode_string ();
char *getgroup ();
char *getuser ();
void strip_trailing_slashes ();
@@ -450,8 +449,15 @@ struct ignore_pattern
static struct ignore_pattern *ignore_patterns;
/* Nonzero means output nongraphic chars in file names as `?'. -q */
/* Nonzero means output nongraphic chars in file names as `?'.
(-q, --hide-control-chars)
qmark_funny_chars and the quoting style (-Q, --quoting-style=WORD) are
independent. The algorithm is: first, obey the quoting style to get a
string representing the file name; then, if qmark_funny_chars is set,
replace all nonprintable chars in that string with `?'. It's necessary
to replace nonprintable chars even in quoted strings, because we don't
want to mess up the terminal if control chars get sent to it, and some
quoting methods pass through control chars as-is. */
static int qmark_funny_chars;
/* Quoting options for file and dir name output. */
@@ -821,6 +827,7 @@ decode_switches (int argc, char **argv)
if (isatty (1))
{
format = many_per_line;
/* See description of qmark_funny_chars, above. */
qmark_funny_chars = 1;
}
else
@@ -1982,7 +1989,7 @@ sort_files (void)
static int
compare_ctime (const struct fileinfo *file1, const struct fileinfo *file2)
{
int diff = longdiff (file2->stat.st_ctime, file1->stat.st_ctime);
int diff = CTIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
return diff;
@@ -1991,7 +1998,7 @@ compare_ctime (const struct fileinfo *file1, const struct fileinfo *file2)
static int
rev_cmp_ctime (const struct fileinfo *file2, const struct fileinfo *file1)
{
int diff = longdiff (file2->stat.st_ctime, file1->stat.st_ctime);
int diff = CTIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
return diff;
@@ -2000,7 +2007,7 @@ rev_cmp_ctime (const struct fileinfo *file2, const struct fileinfo *file1)
static int
compare_mtime (const struct fileinfo *file1, const struct fileinfo *file2)
{
int diff = longdiff (file2->stat.st_mtime, file1->stat.st_mtime);
int diff = MTIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
return diff;
@@ -2009,7 +2016,7 @@ compare_mtime (const struct fileinfo *file1, const struct fileinfo *file2)
static int
rev_cmp_mtime (const struct fileinfo *file2, const struct fileinfo *file1)
{
int diff = longdiff (file2->stat.st_mtime, file1->stat.st_mtime);
int diff = MTIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
return diff;
@@ -2018,7 +2025,7 @@ rev_cmp_mtime (const struct fileinfo *file2, const struct fileinfo *file1)
static int
compare_atime (const struct fileinfo *file1, const struct fileinfo *file2)
{
int diff = longdiff (file2->stat.st_atime, file1->stat.st_atime);
int diff = ATIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
return diff;
@@ -2027,7 +2034,7 @@ compare_atime (const struct fileinfo *file1, const struct fileinfo *file2)
static int
rev_cmp_atime (const struct fileinfo *file2, const struct fileinfo *file1)
{
int diff = longdiff (file2->stat.st_atime, file1->stat.st_atime);
int diff = ATIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
return diff;
@@ -2183,6 +2190,7 @@ print_long_format (const struct fileinfo *f)
char *user_name;
#if HAVE_ST_DM_MODE
/* Cray DMF: look at the file's migrated, not real, status */
mode_string (f->stat.st_dm_mode, modebuf);
#else
mode_string (f->stat.st_mode, modebuf);

View File

@@ -152,7 +152,7 @@ split_3 (char *s, size_t s_len, unsigned char **u, int *binary, char **w)
++i;
filename_has_newline = 1;
}
*u = &s[i];
*u = (unsigned char *) &s[i];
/* The first field has to be the 32-character hexadecimal
representation of the message digest. If it is not followed

View File

@@ -56,10 +56,6 @@
#include "remove.h"
#include "error.h"
#if HAVE_LCHOWN
# define chown(PATH, OWNER, GROUP) lchown(PATH, OWNER, GROUP)
#endif
/* Initial number of entries in each hash table entry's table of inodes. */
#define INITIAL_HASH_MODULE 100
@@ -181,21 +177,34 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
}
fail = copy (source, dest, 0, x,
&copy_into_self, &rename_succeeded);
fail = copy (source, dest, 0, x, &copy_into_self, &rename_succeeded);
if (!fail)
{
const char *dir_to_remove;
if (copy_into_self)
{
/* Do *not* remove SOURCE if it is the same as or a parent
of DEST. Otherwise, mv would be removing the original
*and* the copy. */
/* In general, when copy returns with copy_into_self set, SOURCE is
the same as, or a parent of DEST. In this case we know it's a
parent. It doesn't make sense to move a directory into itself, and
besides in some situations doing so would give highly nonintuitive
results. Run this `mkdir b; touch a c; mv * b' in an empty
directory. Here's the result of running echo `find b -print`:
b b/a b/b b/b/a b/c. Notice that only file `a' was copied
into b/b. Handle this by giving a diagnostic, removing the
copied-into-self directory, DEST (`b/b' in the example),
and failing. */
dir_to_remove = dest;
error (0, 0,
_("cannot move `%s' to a subdirectory of itself, `%s'"),
source, dest);
}
else if (rename_succeeded)
{
/* No need to remove anything. SOURCE was successfully
renamed to DEST. */
dir_to_remove = NULL;
}
else
{
@@ -221,6 +230,11 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
This function used to resort to copying only when rename
failed and set errno to EXDEV. */
dir_to_remove = source;
}
if (dir_to_remove != NULL)
{
struct rm_options rm_options;
struct File_spec fs;
enum RM_status status;
@@ -230,7 +244,7 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
remove_init ();
fspec_init_file (&fs, source);
fspec_init_file (&fs, dir_to_remove);
status = rm (&fs, 1, &rm_options);
assert (VALID_STATUS (status));
if (status == RM_ERROR)
@@ -239,8 +253,11 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
remove_fini ();
if (fail)
error (0, errno, _("cannot remove `%s'"), source);
error (0, errno, _("cannot remove `%s'"), dir_to_remove);
}
if (copy_into_self)
fail = 1;
}
return fail;

View File

@@ -580,6 +580,27 @@ static struct option const long_options[] =
{"help", no_argument, &show_help, 1},
{"version", no_argument, &show_version, 1},
{"test", no_argument, &test_suite, 1},
{"pages", required_argument, NULL, 128},
{"columns", required_argument, NULL, 129},
{"across", no_argument, NULL, 'a'},
{"show-control-chars", no_argument, NULL, 'c'},
{"double-space", no_argument, NULL, 'd'},
{"expand-tabs", optional_argument, NULL, 'e'},
{"form-feed", no_argument, NULL, 'f'},
{"header", required_argument, NULL, 'h'},
{"output-tabs", optional_argument, NULL, 'i'},
{"join-lines", no_argument, NULL, 'j'},
{"length", required_argument, NULL, 'l'},
{"merge", no_argument, NULL, 'm'},
{"number-lines", optional_argument, NULL, 'n'},
{"first-line-number", required_argument, NULL, 'N'},
{"indent", required_argument, NULL, 'o'},
{"no-file-warnings", no_argument, NULL, 'r'},
{"separator", optional_argument, NULL, 's'},
{"omit-header", no_argument, NULL, 't'},
{"omit-pagination", no_argument, NULL, 'T'},
{"show-nonprinting", no_argument, NULL, 'v'},
{"width", required_argument, NULL, 'w'},
{0, 0, 0, 0}
};
@@ -722,6 +743,24 @@ main (int argc, char **argv)
case 0: /* getopt long option */
break;
case 128: /* --pages=FIRST_PAGE[:LAST_PAGE] */
first_last_page (optarg);
break;
case 129: /* --columns=COLUMN */
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
{
error (EXIT_FAILURE, 0,
_("`--columns=COLUMN' invalid number of columns: `%s'"),
optarg);
}
columns = (int) tmp_long;
break;
}
case 'a':
print_across_flag = TRUE;
storing_columns = FALSE;
@@ -2416,44 +2455,61 @@ Usage: %s [OPTION]... [FILE]...\n\
Paginate or columnate FILE(s) for printing.\n\
\n\
+FIRST_PAGE[:LAST_PAGE]\n\
--pages=FIRST_PAGE[:LAST_PAGE]\n\
begin [stop] printing with page FIRST_[LAST_]PAGE\n\
-COLUMN produce COLUMN-column output and print columns down,\n\
-COLUMN\n\
--columns=COLUMN produce COLUMN-column output and print columns down,\n\
unless -a is used. Balance number of lines in the\n\
columns on each page.\n\
-a print columns across rather than down, used together\n\
-a, --across print columns across rather than down, used together\n\
with -COLUMN\n\
-c use hat notation (^G) and octal backslash notation\n\
-d double space the output\n\
-e[CHAR[WIDTH]] expand input CHARs (TABs) to tab WIDTH (8)\n\
-F, -f use form feeds instead of newlines to separate pages\n\
-c, --show-control-chars\n\
use hat notation (^G) and octal backslash notation\n\
-d, --double-space\n\
double space the output\n\
-e, --expand-tabs[=CHAR[WIDTH]]\n\
expand input CHARs (TABs) to tab WIDTH (8)\n\
-F, -f, --form-feed\n\
use form feeds instead of newlines to separate pages\n\
(by a 3-line page header with -f or a 5-line header\n\
and trailer without -f)\n\
-h HEADER use a centered HEADER instead of filename in page headers\n\
-h, --header=HEADER\n\
use a centered HEADER instead of filename in page headers\n\
with long headers left-hand-side truncation may occur\n\
-h \"\" prints a blank line. Don't use -h\"\"\n\
-i[CHAR[WIDTH]] replace spaces with CHARs (TABs) to tab WIDTH (8)\n\
-j merge full lines, turns off -w line truncation, no column\n\
-i, --output-tabs[=CHAR[WIDTH]]\n\
replace spaces with CHARs (TABs) to tab WIDTH (8)\n\
-j, --join-lines merge full lines, turns off -w line truncation, no column\n\
alignment, -s[STRING] sets separators\n\
-l PAGE_LENGTH set the page length to PAGE_LENGTH (66) lines\n\
-l, --length PAGE_LENGTH\n\
set the page length to PAGE_LENGTH (66) lines\n\
(default number of lines of text 56, with -f 63)\n"));
printf (_("\
-m print all files in parallel, one in each column,\n\
-m, --merge print all files in parallel, one in each column,\n\
truncate lines, but join lines of full length with -j\n\
-n[SEP[DIGITS]] number lines, use DIGITS (5) digits, then SEP (TAB)\n\
-n, --number-lines[=SEP[DIGITS]]\n\
number lines, use DIGITS (5) digits, then SEP (TAB)\n\
default counting starts with 1st line of input file\n\
-N NUMBER start counting with NUMBER at 1st line of first\n\
-N, --first-line-number=NUMBER\n\
start counting with NUMBER at 1st line of first\n\
page printed (see +FIRST_PAGE)\n\
-o MARGIN offset each line with MARGIN spaces (do not affect -w)\n\
-r inhibit warning when a file cannot be opened\n\
-s[STRING] separate columns by an optional STRING, don't use\n\
-o, --indent=MARGIN\n\
offset each line with MARGIN spaces (do not affect -w)\n\
-r, --no-file-warnings\n\
inhibit warning when a file cannot be opened\n\
-s, --separator[=STRING]\n\
separate columns by an optional STRING, don't use\n\
-s \"STRING\", -s only: No separator used (same as -s\"\"),\n\
without -s: Default separator \'TAB\' with -j and \'space\'\n\
otherwise (same as -s\" \")\n\
-t inhibit page headers and trailers\n\
-T inhibit page headers and trailers, eliminate any page\n\
-t, --omit-header inhibit page headers and trailers\n\
-T, --omit-pagination\n\
inhibit page headers and trailers, eliminate any page\n\
layout by form feeds set in input files\n\
-v use octal backslash notation\n\
-w PAGE_WIDTH set page width to PAGE_WIDTH (72) columns, truncate\n\
-v, --show-nonprinting\n\
use octal backslash notation\n\
-w, --width=PAGE_WIDTH\n\
set page width to PAGE_WIDTH (72) columns, truncate\n\
lines (see also -j option)\n\
--help display this help and exit\n\
--version output version information and exit\n\

2223
src/ptx.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -31,6 +31,14 @@
#include "closeout.h"
#include "error.h"
#ifndef EEXIST
# define EEXIST 0
#endif
#ifndef ENOTEMPTY
# define ENOTEMPTY 0
#endif
void strip_trailing_slashes ();
/* The name this program was run with. */
@@ -199,14 +207,17 @@ main (int argc, char **argv)
if (fail)
{
if (!ignore_fail_on_non_empty || errno != ENOTEMPTY)
{
error (0, errno, "%s", dir);
errors = 1;
}
if (ignore_fail_on_non_empty
&& (errno == ENOTEMPTY || errno == EEXIST))
continue;
error (0, errno, "%s", dir);
errors = 1;
}
else if (empty_paths)
errors += remove_parents (dir);
{
errors += remove_parents (dir);
}
}
exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);

View File

@@ -61,7 +61,7 @@ char *xstrdup ();
#define FLOATING_POINT '.'
#define FLOATING_COMMA ','
#define NEGATIVE_SIGN '-'
#define NEGATION_SIGN '-'
#define NUMERIC_ZERO '0'
#ifdef ENABLE_NLS
@@ -307,7 +307,7 @@ for that key. If no key given, use the entire line as key. With no\n\
FILE, or when FILE is -, read standard input.\n\
")
, DEFAULT_TMPDIR);
puts (_("\nReport bugs to textutils-bugs@gnu.org"));
puts (_("\nReport bugs to <textutils-bugs@gnu.org>."));
}
/* Don't use EXIT_FAILURE here in case it is defined to be 1.
POSIX requires that sort return 1 IFF invoked with -c and
@@ -1132,7 +1132,7 @@ look_for_fraction (const char *s, const char *e)
}
/* skip blanks and signs */
while (blanks[UCHAR (*s)] || *s == NEGATIVE_SIGN)
while (blanks[UCHAR (*s)] || *s == NEGATION_SIGN)
s++;
/* groups = {}, n = 0 */
for (p = s; p < e; p++)
@@ -1205,12 +1205,12 @@ numcompare (register const char *a, register const char *b)
++b;
/* next character in a,b is non-blank */
if ((*a == NEGATIVE_SIGN || *b == NEGATIVE_SIGN) && *a != *b)
if ((*a == NEGATION_SIGN || *b == NEGATION_SIGN) && *a != *b)
{
/* a < 0, or b < 0, but not both */
if (*a == NEGATIVE_SIGN)
if (*a == NEGATION_SIGN)
ret_code = -1, ++a; /* a looks < b */
else if (*b == NEGATIVE_SIGN)
else if (*b == NEGATION_SIGN)
ret_code = 1, ++b; /* b looks < a */
/* bypass zeroes, decimal points, and thousand sep in a & b */
while (*a == NUMERIC_ZERO || (th_sep && *a == th_sep)
@@ -1237,7 +1237,7 @@ numcompare (register const char *a, register const char *b)
else
{
/* either both numbers are signed, or both are not-signed */
if (*a == NEGATIVE_SIGN)
if (*a == NEGATION_SIGN)
{
++a;
++b;
@@ -1306,12 +1306,12 @@ numcompare (register const char *a, register const char *b)
while (blanks[tmpb])
tmpb = UCHAR (*++b);
if (tmpa == NEGATIVE_SIGN)
if (tmpa == NEGATION_SIGN)
{
do
tmpa = UCHAR (*++a);
while (tmpa == NUMERIC_ZERO);
if (tmpb != NEGATIVE_SIGN)
if (tmpb != NEGATION_SIGN)
{
if (tmpa == decimal_point)
do
@@ -1360,7 +1360,7 @@ numcompare (register const char *a, register const char *b)
return tmpb - tmpa;
}
else if (tmpb == NEGATIVE_SIGN)
else if (tmpb == NEGATION_SIGN)
{
do
tmpb = UCHAR (*++b);
@@ -2280,7 +2280,9 @@ sort (char **files, int nfiles, FILE *ofp)
#endif
sortlines (lines.lines, lines.used, tmp);
if (feof (fp) && !nfiles && !n_temp_files && !buf.left)
tfp = ofp;
{
tfp = ofp;
}
else
{
++n_temp_files;
@@ -2427,7 +2429,7 @@ key_init (struct keyfield *key)
/* strdup and return the result of setlocale, but guard against a NULL
return value. If setlocale returns NULL, strdup FAIL_VAL instead. */
#if !defined __GLIBC__ || __GLIBC__ < 2
#if defined ENABLE_NLS && ( !defined __GLIBC__ || __GLIBC__ < 2 )
static inline char *
my_setlocale (const char *locale, const char *fail_val)
{
@@ -2857,49 +2859,73 @@ but lacks following character offset"));
for (i = 0; i < nfiles; ++i)
{
char buf[8192];
FILE *fp;
FILE *in_fp;
FILE *out_fp;
int cc;
if (S_ISREG (outstat.st_mode) && !STREQ (outfile, files[i]))
{
struct stat instat;
if ((!STREQ (files[i], "-")
? stat (files[i], &instat)
: fstat (STDIN_FILENO, &instat)) != 0)
if ((STREQ (files[i], "-")
? fstat (STDIN_FILENO, &instat)
: stat (files[i], &instat)) != 0)
{
error (0, errno, "%s", files[i]);
cleanup ();
exit (SORT_FAILURE);
}
if (S_ISREG (instat.st_mode)
&& (instat.st_ino != outstat.st_ino
|| instat.st_dev != outstat.st_dev))
if (S_ISREG (instat.st_mode) && !SAME_INODE (instat, outstat))
{
/* We know the files are distinct. */
continue;
}
}
fp = xfopen (files[i], "r");
in_fp = xfopen (files[i], "r");
tmp = tempname ();
ofp = xtmpfopen (tmp);
while ((cc = fread (buf, 1, sizeof buf, fp)) > 0)
write_bytes (buf, cc, ofp);
if (ferror (fp))
out_fp = xtmpfopen (tmp);
/* FIXME: maybe use copy.c(copy) here. */
while ((cc = fread (buf, 1, sizeof buf, in_fp)) > 0)
write_bytes (buf, cc, out_fp);
if (ferror (in_fp))
{
error (0, errno, "%s", files[i]);
cleanup ();
exit (SORT_FAILURE);
}
xfclose (ofp);
xfclose (fp);
xfclose (out_fp);
xfclose (in_fp);
files[i] = tmp;
}
ofp = xfopen (outfile, "w");
}
else
{
/* A non-`-' outfile was specified, but the file doesn't yet exist.
Before opening it for writing (thus creating it), make sure all
of the input files exist. Otherwise, creating the output file
could create an otherwise missing input file, making sort succeed
when it should fail. */
for (i = 0; i < nfiles; ++i)
{
struct stat sb;
if (STREQ (files[i], "-"))
continue;
if (stat (files[i], &sb))
{
error (0, errno, "%s", files[i]);
cleanup ();
exit (SORT_FAILURE);
}
}
ofp = xfopen (outfile, "w");
}
ofp = xfopen (outfile, "w");
}
else
ofp = stdout;
{
ofp = stdout;
}
if (mergeonly)
merge (files, nfiles, ofp);

View File

@@ -81,6 +81,17 @@
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
#endif
#ifdef HAVE_ST_MTIM
# define ST_TIME_CMP_NS(a, b, ns) ((a).ns < (b).ns ? -1 : (a).ns > (b).ns)
#else
# define ST_TIME_CMP_NS(a, b, ns) 0
#endif
#define ST_TIME_CMP(a, b, s, ns) \
((a).s < (b).s ? -1 : (a).s > (b).s ? 1 : ST_TIME_CMP_NS(a, b, ns))
#define ATIME_CMP(a, b) ST_TIME_CMP (a, b, st_atime, st_atim.tv_nsec)
#define CTIME_CMP(a, b) ST_TIME_CMP (a, b, st_ctime, st_ctim.tv_nsec)
#define MTIME_CMP(a, b) ST_TIME_CMP (a, b, st_mtime, st_mtim.tv_nsec)
#if !defined(HAVE_MKFIFO)
# define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
#endif

View File

@@ -175,6 +175,10 @@ touch (char *file)
{
struct utimbuf utb;
/* There's currently no interface to set file timestamps with
better than 1-second resolution, so discard any fractional
part of the source timestamp. */
if (use_ref)
{
utb.actime = ref_stats.st_atime;

View File

@@ -162,7 +162,9 @@ usage (int status)
{
printf (_("Usage: %s [OPTION]... [ FILE ]\n"), program_name);
printf (_("\
Output who is currently logged in according to FILE.\n\
Print the current time, the length of time the system has been up,\n\
the number of users on the system, and the average number of jobs\n\
in the run queue over the last 1, 5 and 15 minutes.\n\
If FILE is not specified, use %s. %s as FILE is common.\n\
\n\
--help display this help and exit\n\

View File

@@ -10,8 +10,8 @@ fi
framework_failure=0
$RM -f a a~ || framework_failure=1
: > a || framework_failure=1
echo a > a~ || framework_failure=1
echo a > a || framework_failure=1
echo a-tilde > a~ || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'

View File

@@ -51,6 +51,7 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do
case "$args" in *sl2*) ln -s foo sl2;; esac
(
(
# echo 1>&2 $CP $options $args
$CP $options $args 2>.err
echo $? $options
@@ -166,4 +167,8 @@ cat <<\EOF > $expected
EOF
cmp $expected $actual || diff -u $expected $actual 1>&2
# Uncomment this if you see a failure and want to try to diagnose it.
# diff -u $expected $actual 1>&2
cmp $expected $actual
exit $?

View File

@@ -8,13 +8,17 @@ maint_gen = 1.I 1.X 2.I 2.X 3.I 3.X 4.I 4.X 5.I 5.X 6.I 6.X 7.I 7.X 8.I 8.X \
i.X j.I j.X k.I k.X l.I l.X m.I m.X n.I n.X o.I o.X p.I p.X q.I q.X r.I r.X \
s.I s.X t.I t.X u.I u.X v.I v.X w.I w.X x.I x.X y.I y.X z.I z.X empty-fl.I \
empty-fl.X missing-fl.I missing-fl.X empty-bl.I empty-bl.X missing-bl.I \
missing-bl.X empty-f1.I empty-f1.X empty-f2.I empty-f2.X
missing-bl.X empty-f1.I empty-f1.X empty-f2.I empty-f2.X o-delim.I o-delim.X \
nul-idelim.I nul-idelim.X nul-odelim.I nul-odelim.X multichar-od.I \
multichar-od.X
run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
9.E a.O a.E b.O b.E c.O c.E d.O d.E e.O e.E f.O f.E g.O g.E h.O h.E i.O i.E \
j.O j.E k.O k.E l.O l.E m.O m.E n.O n.E o.O o.E p.O p.E q.O q.E r.O r.E s.O \
s.E t.O t.E u.O u.E v.O v.E w.O w.E x.O x.E y.O y.E z.O z.E empty-fl.O \
empty-fl.E missing-fl.O missing-fl.E empty-bl.O empty-bl.E missing-bl.O \
missing-bl.E empty-f1.O empty-f1.E empty-f2.O empty-f2.E
missing-bl.E empty-f1.O empty-f1.E empty-f2.O empty-f2.E o-delim.O o-delim.E \
nul-idelim.O nul-idelim.E nul-odelim.O nul-odelim.E multichar-od.O \
multichar-od.E
##test-files-end
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
@@ -94,13 +93,17 @@ maint_gen = 1.I 1.X 2.I 2.X 3.I 3.X 4.I 4.X 5.I 5.X 6.I 6.X 7.I 7.X 8.I 8.X \
i.X j.I j.X k.I k.X l.I l.X m.I m.X n.I n.X o.I o.X p.I p.X q.I q.X r.I r.X \
s.I s.X t.I t.X u.I u.X v.I v.X w.I w.X x.I x.X y.I y.X z.I z.X empty-fl.I \
empty-fl.X missing-fl.I missing-fl.X empty-bl.I empty-bl.X missing-bl.I \
missing-bl.X empty-f1.I empty-f1.X empty-f2.I empty-f2.X
missing-bl.X empty-f1.I empty-f1.X empty-f2.I empty-f2.X o-delim.I o-delim.X \
nul-idelim.I nul-idelim.X nul-odelim.I nul-odelim.X multichar-od.I \
multichar-od.X
run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
9.E a.O a.E b.O b.E c.O c.E d.O d.E e.O e.E f.O f.E g.O g.E h.O h.E i.O i.E \
j.O j.E k.O k.E l.O l.E m.O m.E n.O n.E o.O o.E p.O p.E q.O q.E r.O r.E s.O \
s.E t.O t.E u.O u.E v.O v.E w.O w.E x.O x.E y.O y.E z.O z.E empty-fl.O \
empty-fl.E missing-fl.O missing-fl.E empty-bl.O empty-bl.E missing-bl.O \
missing-bl.E empty-f1.O empty-f1.E empty-f2.O empty-f2.E
missing-bl.E empty-f1.O empty-f1.E empty-f2.O empty-f2.E o-delim.O o-delim.E \
nul-idelim.O nul-idelim.E nul-odelim.O nul-odelim.E multichar-od.O \
multichar-od.E
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests

View File

@@ -64,8 +64,22 @@ my @tv = (
['empty-f2', '-f2', "", "", 0],
['o-delim', '-d: -f2,3 --out=_', "a:b:c\n", "b_c\n", 0],
['nul-idelim', "-d '' -f2,3 --out=_", "a\0b\0c\n", "b_c\n", 0],
['nul-odelim', "-d: -f2,3 --out=", "a:b:c\n", "b\0c\n", 0],
['multichar-od', "-d: -f2,3 --out=_._", "a:b:c\n", "b_._c\n", 0],
);
# Don't use a pipe for failing tests. Otherwise, sometimes they
# fail so early they'd evoke the `Broken pipe' message.
my $t;
foreach $t (@tv)
{
my ($test_name, $flags, $in, $exp, $ret) = @$t;
$Test::input_via{$test_name} = {REDIR => 0, FILE => 0} if $ret;
}
sub test_vector
{
return @tv;

View File

@@ -1718,23 +1718,6 @@ else
esac
fi
test -s y.E || rm -f y.E
cat $srcdir/y.I | $xx -s -b4 > y.O 2> y.E
code=$?
if test $code != 1 ; then
$echo "Test y(|) failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp y.O $srcdir/y.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed y(|)"; fi ;;
1) $echo "Test y(|) failed: files y.O and $srcdir/y.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test y(|) may have failed." 1>&2;
$echo The command "cmp y.O $srcdir/y.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s y.E || rm -f y.E
$xx -s -b4 < $srcdir/y.I > y.O 2> y.E
code=$?
if test $code != 1 ; then
@@ -1769,23 +1752,6 @@ else
esac
fi
test -s z.E || rm -f z.E
cat $srcdir/z.I | $xx > z.O 2> z.E
code=$?
if test $code != 1 ; then
$echo "Test z(|) failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp z.O $srcdir/z.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed z(|)"; fi ;;
1) $echo "Test z(|) failed: files z.O and $srcdir/z.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test z(|) may have failed." 1>&2;
$echo The command "cmp z.O $srcdir/z.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s z.E || rm -f z.E
$xx < $srcdir/z.I > z.O 2> z.E
code=$?
if test $code != 1 ; then
@@ -1820,23 +1786,6 @@ else
esac
fi
test -s empty-fl.E || rm -f empty-fl.E
cat $srcdir/empty-fl.I | $xx -f '' > empty-fl.O 2> empty-fl.E
code=$?
if test $code != 1 ; then
$echo "Test empty-fl(|) failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp empty-fl.O $srcdir/empty-fl.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed empty-fl(|)"; fi ;;
1) $echo "Test empty-fl(|) failed: files empty-fl.O and $srcdir/empty-fl.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test empty-fl(|) may have failed." 1>&2;
$echo The command "cmp empty-fl.O $srcdir/empty-fl.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s empty-fl.E || rm -f empty-fl.E
$xx -f '' < $srcdir/empty-fl.I > empty-fl.O 2> empty-fl.E
code=$?
if test $code != 1 ; then
@@ -1871,23 +1820,6 @@ else
esac
fi
test -s missing-fl.E || rm -f missing-fl.E
cat $srcdir/missing-fl.I | $xx -f > missing-fl.O 2> missing-fl.E
code=$?
if test $code != 1 ; then
$echo "Test missing-fl(|) failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp missing-fl.O $srcdir/missing-fl.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed missing-fl(|)"; fi ;;
1) $echo "Test missing-fl(|) failed: files missing-fl.O and $srcdir/missing-fl.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test missing-fl(|) may have failed." 1>&2;
$echo The command "cmp missing-fl.O $srcdir/missing-fl.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s missing-fl.E || rm -f missing-fl.E
$xx -f < $srcdir/missing-fl.I > missing-fl.O 2> missing-fl.E
code=$?
if test $code != 1 ; then
@@ -1922,23 +1854,6 @@ else
esac
fi
test -s empty-bl.E || rm -f empty-bl.E
cat $srcdir/empty-bl.I | $xx -b '' > empty-bl.O 2> empty-bl.E
code=$?
if test $code != 1 ; then
$echo "Test empty-bl(|) failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp empty-bl.O $srcdir/empty-bl.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed empty-bl(|)"; fi ;;
1) $echo "Test empty-bl(|) failed: files empty-bl.O and $srcdir/empty-bl.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test empty-bl(|) may have failed." 1>&2;
$echo The command "cmp empty-bl.O $srcdir/empty-bl.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s empty-bl.E || rm -f empty-bl.E
$xx -b '' < $srcdir/empty-bl.I > empty-bl.O 2> empty-bl.E
code=$?
if test $code != 1 ; then
@@ -1973,23 +1888,6 @@ else
esac
fi
test -s missing-bl.E || rm -f missing-bl.E
cat $srcdir/missing-bl.I | $xx -b > missing-bl.O 2> missing-bl.E
code=$?
if test $code != 1 ; then
$echo "Test missing-bl(|) failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp missing-bl.O $srcdir/missing-bl.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed missing-bl(|)"; fi ;;
1) $echo "Test missing-bl(|) failed: files missing-bl.O and $srcdir/missing-bl.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test missing-bl(|) may have failed." 1>&2;
$echo The command "cmp missing-bl.O $srcdir/missing-bl.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s missing-bl.E || rm -f missing-bl.E
$xx -b < $srcdir/missing-bl.I > missing-bl.O 2> missing-bl.E
code=$?
if test $code != 1 ; then
@@ -2109,8 +2007,212 @@ else
esac
fi
test -s empty-f2.E || rm -f empty-f2.E
$xx -d: -f2,3 --out=_ $srcdir/o-delim.I > o-delim.O 2> o-delim.E
code=$?
if test $code != 0 ; then
$echo "Test o-delim(F) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp o-delim.O $srcdir/o-delim.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed o-delim(F)"; fi ;;
1) $echo "Test o-delim(F) failed: files o-delim.O and $srcdir/o-delim.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test o-delim(F) may have failed." 1>&2;
$echo The command "cmp o-delim.O $srcdir/o-delim.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s o-delim.E || rm -f o-delim.E
cat $srcdir/o-delim.I | $xx -d: -f2,3 --out=_ > o-delim.O 2> o-delim.E
code=$?
if test $code != 0 ; then
$echo "Test o-delim(|) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp o-delim.O $srcdir/o-delim.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed o-delim(|)"; fi ;;
1) $echo "Test o-delim(|) failed: files o-delim.O and $srcdir/o-delim.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test o-delim(|) may have failed." 1>&2;
$echo The command "cmp o-delim.O $srcdir/o-delim.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s o-delim.E || rm -f o-delim.E
$xx -d: -f2,3 --out=_ < $srcdir/o-delim.I > o-delim.O 2> o-delim.E
code=$?
if test $code != 0 ; then
$echo "Test o-delim(<) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp o-delim.O $srcdir/o-delim.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed o-delim(<)"; fi ;;
1) $echo "Test o-delim(<) failed: files o-delim.O and $srcdir/o-delim.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test o-delim(<) may have failed." 1>&2;
$echo The command "cmp o-delim.O $srcdir/o-delim.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s o-delim.E || rm -f o-delim.E
$xx -d '' -f2,3 --out=_ $srcdir/nul-idelim.I > nul-idelim.O 2> nul-idelim.E
code=$?
if test $code != 0 ; then
$echo "Test nul-idelim(F) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp nul-idelim.O $srcdir/nul-idelim.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed nul-idelim(F)"; fi ;;
1) $echo "Test nul-idelim(F) failed: files nul-idelim.O and $srcdir/nul-idelim.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test nul-idelim(F) may have failed." 1>&2;
$echo The command "cmp nul-idelim.O $srcdir/nul-idelim.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s nul-idelim.E || rm -f nul-idelim.E
cat $srcdir/nul-idelim.I | $xx -d '' -f2,3 --out=_ > nul-idelim.O 2> nul-idelim.E
code=$?
if test $code != 0 ; then
$echo "Test nul-idelim(|) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp nul-idelim.O $srcdir/nul-idelim.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed nul-idelim(|)"; fi ;;
1) $echo "Test nul-idelim(|) failed: files nul-idelim.O and $srcdir/nul-idelim.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test nul-idelim(|) may have failed." 1>&2;
$echo The command "cmp nul-idelim.O $srcdir/nul-idelim.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s nul-idelim.E || rm -f nul-idelim.E
$xx -d '' -f2,3 --out=_ < $srcdir/nul-idelim.I > nul-idelim.O 2> nul-idelim.E
code=$?
if test $code != 0 ; then
$echo "Test nul-idelim(<) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp nul-idelim.O $srcdir/nul-idelim.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed nul-idelim(<)"; fi ;;
1) $echo "Test nul-idelim(<) failed: files nul-idelim.O and $srcdir/nul-idelim.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test nul-idelim(<) may have failed." 1>&2;
$echo The command "cmp nul-idelim.O $srcdir/nul-idelim.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s nul-idelim.E || rm -f nul-idelim.E
$xx -d: -f2,3 --out= $srcdir/nul-odelim.I > nul-odelim.O 2> nul-odelim.E
code=$?
if test $code != 0 ; then
$echo "Test nul-odelim(F) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp nul-odelim.O $srcdir/nul-odelim.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed nul-odelim(F)"; fi ;;
1) $echo "Test nul-odelim(F) failed: files nul-odelim.O and $srcdir/nul-odelim.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test nul-odelim(F) may have failed." 1>&2;
$echo The command "cmp nul-odelim.O $srcdir/nul-odelim.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s nul-odelim.E || rm -f nul-odelim.E
cat $srcdir/nul-odelim.I | $xx -d: -f2,3 --out= > nul-odelim.O 2> nul-odelim.E
code=$?
if test $code != 0 ; then
$echo "Test nul-odelim(|) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp nul-odelim.O $srcdir/nul-odelim.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed nul-odelim(|)"; fi ;;
1) $echo "Test nul-odelim(|) failed: files nul-odelim.O and $srcdir/nul-odelim.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test nul-odelim(|) may have failed." 1>&2;
$echo The command "cmp nul-odelim.O $srcdir/nul-odelim.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s nul-odelim.E || rm -f nul-odelim.E
$xx -d: -f2,3 --out= < $srcdir/nul-odelim.I > nul-odelim.O 2> nul-odelim.E
code=$?
if test $code != 0 ; then
$echo "Test nul-odelim(<) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp nul-odelim.O $srcdir/nul-odelim.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed nul-odelim(<)"; fi ;;
1) $echo "Test nul-odelim(<) failed: files nul-odelim.O and $srcdir/nul-odelim.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test nul-odelim(<) may have failed." 1>&2;
$echo The command "cmp nul-odelim.O $srcdir/nul-odelim.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s nul-odelim.E || rm -f nul-odelim.E
$xx -d: -f2,3 --out=_._ $srcdir/multichar-od.I > multichar-od.O 2> multichar-od.E
code=$?
if test $code != 0 ; then
$echo "Test multichar-od(F) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp multichar-od.O $srcdir/multichar-od.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed multichar-od(F)"; fi ;;
1) $echo "Test multichar-od(F) failed: files multichar-od.O and $srcdir/multichar-od.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test multichar-od(F) may have failed." 1>&2;
$echo The command "cmp multichar-od.O $srcdir/multichar-od.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s multichar-od.E || rm -f multichar-od.E
cat $srcdir/multichar-od.I | $xx -d: -f2,3 --out=_._ > multichar-od.O 2> multichar-od.E
code=$?
if test $code != 0 ; then
$echo "Test multichar-od(|) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp multichar-od.O $srcdir/multichar-od.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed multichar-od(|)"; fi ;;
1) $echo "Test multichar-od(|) failed: files multichar-od.O and $srcdir/multichar-od.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test multichar-od(|) may have failed." 1>&2;
$echo The command "cmp multichar-od.O $srcdir/multichar-od.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s multichar-od.E || rm -f multichar-od.E
$xx -d: -f2,3 --out=_._ < $srcdir/multichar-od.I > multichar-od.O 2> multichar-od.E
code=$?
if test $code != 0 ; then
$echo "Test multichar-od(<) failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp multichar-od.O $srcdir/multichar-od.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed multichar-od(<)"; fi ;;
1) $echo "Test multichar-od(<) failed: files multichar-od.O and $srcdir/multichar-od.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test multichar-od(<) may have failed." 1>&2;
$echo The command "cmp multichar-od.O $srcdir/multichar-od.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s multichar-od.E || rm -f multichar-od.E
if test $errors = 0 ; then
$echo Passed all 123 tests. 1>&2
$echo Passed all 129 tests. 1>&2
else
$echo Failed $errors tests. 1>&2
fi

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A

View File

@@ -3,4 +3,8 @@ AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = basic-1
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = INSTALL=../../src/ginstall
TESTS_ENVIRONMENT = \
INSTALL=../../src/ginstall \
LS=../../src/ls \
MKDIR=../../src/mkdir \
RM=../../src/rm

View File

@@ -93,7 +93,11 @@ AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = basic-1
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = INSTALL=../../src/ginstall
TESTS_ENVIRONMENT = \
INSTALL=../../src/ginstall \
LS=../../src/ls \
MKDIR=../../src/mkdir \
RM=../../src/rm
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =

View File

@@ -3,6 +3,7 @@
: ${MKDIR=mkdir}
: ${RM=rm}
: ${INSTALL=install}
: ${LS=ls}
dir=dir
file=file
@@ -25,6 +26,17 @@ test -f $file || fail=1
# Make sure the dest file has been created.
test -f $dir/$file || fail=1
# This test would fail with 3.16s when using versions of strip that
# don't work on read-only files (the one from binutils works fine).
$INSTALL -s -c -m 555 ../../src/dd $dir || fail=1
# Make sure the dest file has been created.
test -f $dir/dd || fail=1
# ...and that the permissions are as requested.
set X `$LS -l $dir/dd`
shift
test "$1" = -r-xr-xr-x || fail=1
$RM -rf $dir $file
exit $fail

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A

1
tests/ls-2/.cvsignore Normal file
View File

@@ -0,0 +1 @@
Makefile

275
tests/ls-2/Fetish.pm Normal file
View File

@@ -0,0 +1,275 @@
package Fetish;
# This is a testing framework.
# In case you're wondering about the name, it comes from the
# names of the three packages: FIleutils, SH-utils, TExtutils.
require 5.003;
use strict;
use vars qw($VERSION @ISA @EXPORT);
use FileHandle;
use File::Compare qw(compare);
@ISA = qw(Exporter);
($VERSION = '$Revision: 1.9 $ ') =~ tr/[0-9].//cd;
@EXPORT = qw (run_tests);
my @Types = qw (IN OUT ERR EXIT);
my %Types = map {$_ => 1} @Types;
my %Zero_one_type = map {$_ => 1} qw (OUT ERR EXIT);
my $srcdir = $ENV{srcdir};
my $Global_count = 1;
# A file spec: a scalar or a reference to a single-keyed hash
# ================
# 'contents' contents only (file name is derived from test name)
# {filename => 'contents'} filename and contents
# {filename => undef} filename only -- $(srcdir)/filename must exist
#
# FIXME: If there is more than one input file, the you can't specify REDIRECT.
# PIPE is still ok.
#
# I/O spec: a hash ref with the following properties
# ================
# - one key/value pair
# - the key must be one of these strings: IN, OUT, ERR, EXIT
# - the value must be a file spec
# {OUT => 'data'} put data in a temp file and compare it to stdout from cmd
# {OUT => {'filename'=>undef}} compare contents of existing filename to
# stdout from cmd
# {OUT => {'filename'=>[$CTOR, $DTOR]}} $CTOR and $DTOR are references to
# functions, each which is passed the single argument `filename'.
# $CTOR must create `filename'.
# DTOR may be omitted in which case `sub{unlink @_[0]}' is used.
# FIXME: implement this
# Ditto for `ERR', but compare with stderr
# {EXIT => N} expect exit status of cmd to be N
#
# There may be many input file specs. File names from the input specs
# are concatenated in order on the command line.
# There may be at most one of the OUT-, ERR-, and EXIT-keyed specs.
# If the OUT-(or ERR)-keyed hash ref is omitted, then expect no output
# on stdout (or stderr).
# If the EXIT-keyed one is omitted, then expect the exit status to be zero.
# FIXME: Make sure that no junkfile is also listed as a
# non-junkfile (i.e. with undef for contents)
sub _shell_quote ($)
{
my ($string) = @_;
$string =~ s/\'/\'\\\'\'/g;
return "'$string'";
}
sub _create_file ($$$$)
{
my ($program_name, $test_name, $file_name, $data) = @_;
my $file;
if (defined $file_name)
{
$file = $file_name;
}
else
{
$file = "$test_name-$$.$Global_count";
++$Global_count;
}
# The test spec gave a string.
# Write it to a temp file and return tempfile name.
my $fh = new FileHandle "> $file";
die "$program_name: $file: $!\n" if ! $fh;
print $fh $data;
$fh->close || die "$program_name: $file: $!\n";
return $file;
}
# FIXME: cleanup on interrupt
# FIXME: extract `do_1_test' function
# FIXME: having to include $program_name here is an expedient kludge.
# Library code doesn't `die'.
sub run_tests ($$$$$)
{
my ($program_name, $prog, $t_spec, $save_temps, $verbose) = @_;
# Warn about empty t_spec.
# FIXME
# Remove all temp files upon interrupt.
# FIXME
# Verify that test names are distinct.
my $found_duplicate = 0;
my %seen;
my $t;
foreach $t (@$t_spec)
{
my $test_name = $t->[0];
if ($seen{$test_name})
{
warn "$program_name: $test_name: duplicate test name\n";
$found_duplicate = 1;
}
$seen{$test_name} = 1;
}
return 1 if $found_duplicate;
# FIXME check exit status
system ($prog, '--version');
my @junk_files;
my $fail = 0;
foreach $t (@$t_spec)
{
my $test_name = shift @$t;
my $expect = {};
# FIXME: maybe don't reset this.
$Global_count = 1;
my @args;
my $io_spec;
my %seen_type;
foreach $io_spec (@$t)
{
if (!ref $io_spec)
{
push @args, $io_spec;
next;
}
die "$program_name: $test_name: invalid test spec\n"
if ref $io_spec ne 'HASH';
my $n = keys %$io_spec;
die "$program_name: $test_name: spec has $n elements --"
. " expected 1\n"
if $n != 1;
my ($type, $val) = each %$io_spec;
die "$program_name: $test_name: invalid key `$type' in test spec\n"
if ! $Types{$type};
# Make sure there's no more than one of OUT, ERR, EXIT.
die "$program_name: $test_name: more than one $type spec\n"
if $Zero_one_type{$type} and $seen_type{$type}++;
if ($type eq 'EXIT')
{
die "$program_name: $test_name: invalid EXIT code\n"
if $val !~ /^\d+$/;
# FIXME: make sure $data is numeric
$expect->{EXIT} = $val;
next;
}
my $file_spec = $val;
my ($file_name, $contents);
if (!ref $file_spec)
{
($file_name, $contents) = (undef, $file_spec);
}
elsif (ref $file_spec eq 'HASH')
{
my $n = keys %$file_spec;
die "$program_name: $test_name: $type spec has $n elements --"
. " expected 1\n"
if $n != 1;
($file_name, $contents) = each %$file_spec;
}
else
{
die "$program_name: $test_name: invalid RHS in $type-spec\n"
}
my $is_junk_file = (! defined $file_name
|| ($type eq 'IN' && defined $contents));
my $file = _create_file ($program_name, $test_name,
$file_name, $contents);
if ($type eq 'IN')
{
push @args, _shell_quote $file;
}
else
{
$expect->{$type} = $file;
}
if ($is_junk_file)
{
push @junk_files, $file
}
else
{
# FIXME: put $srcdir in here somewhere
warn "$program_name: $test_name: specified file `$file' does"
. " not exist\n"
if ! -f "$srcdir/$file";
}
}
# Expect an exit status of zero if it's not specified.
$expect->{EXIT} ||= 0;
# Allow ERR to be omitted -- in that case, expect no error output.
my $eo;
foreach $eo (qw (OUT ERR))
{
if (!exists $expect->{$eo})
{
$expect->{$eo} = _create_file ($program_name, $test_name,
undef, '');
push @junk_files, $expect->{$eo};
}
}
# FIXME: Does it ever make sense to specify a filename *and* contents
# in OUT or ERR spec?
warn "$test_name...\n" if $verbose;
my %tmp;
$tmp{OUT} = "$test_name-out";
$tmp{ERR} = "$test_name-err";
push @junk_files, $tmp{OUT}, $tmp{ERR};
my @cmd = ($prog, @args, "> $tmp{OUT}", "2> $tmp{ERR}");
my $cmd_str = join ' ', @cmd;
warn "Running command: `$cmd_str'\n" if $verbose;
my $rc = 0xffff & system $cmd_str;
if ($rc == 0xff00)
{
warn "$program_name: test $test_name failed: command failed:\n"
. " `$cmd_str': $!\n";
$fail = 1;
next;
}
$rc >>= 8 if $rc > 0x80;
if ($expect->{EXIT} != $rc)
{
warn "$program_name: test $test_name failed: exit status mismatch:"
. " expected $expect->{EXIT}, got $rc\n";
$fail = 1;
next;
}
foreach $eo (qw (OUT ERR))
{
my $eo_lower = lc $eo;
if (compare ($expect->{$eo}, $tmp{$eo}))
{
warn "$program_name: test $test_name: std$eo_lower mismatch,"
. " comparing $expect->{$eo} and $tmp{$eo}\n";
$fail = 1;
}
}
}
# FIXME: maybe unlink files inside the big foreach loop?
unlink @junk_files if ! $save_temps;
return $fail;
}
## package return
1;

12
tests/ls-2/Makefile.am Normal file
View File

@@ -0,0 +1,12 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
EXTRA_DIST = $(TESTS) Fetish.pm quoting
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="@PERL@" \
PATH=../../src:$$PATH \
LS=ls
TESTS = run-test

221
tests/ls-2/Makefile.in Normal file
View File

@@ -0,0 +1,221 @@
# Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = /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
DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DF_PROG = @DF_PROG@
GENCAT = @GENCAT@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
LIBOBJS = @LIBOBJS@
MAKEINFO = @MAKEINFO@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
MVDIR_PROG = @MVDIR_PROG@
PACKAGE = @PACKAGE@
PERL = @PERL@
POFILES = @POFILES@
POSUB = @POSUB@
RANLIB = @RANLIB@
U = @U@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
YACC = @YACC@
l = @l@
EXTRA_DIST = $(TESTS) Fetish.pm quoting
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="@PERL@" \
PATH=../../src:$$PATH \
LS=ls
TESTS = run-test
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP = --best
all: Makefile
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnits tests/ls-2/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
tags: TAGS
TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = tests/ls-2
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnits tests/ls-2/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file; \
done
check-TESTS: $(TESTS)
@failed=0; all=0; \
srcdir=$(srcdir); export srcdir; \
for tst in $(TESTS); do \
if test -f $$tst; then dir=.; \
else dir="$(srcdir)"; fi; \
if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \
all=`expr $$all + 1`; \
echo "PASS: $$tst"; \
elif test $$? -ne 77; then \
all=`expr $$all + 1`; \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
fi; \
done; \
if test "$$failed" -eq 0; then \
banner="All $$all tests passed"; \
else \
banner="$$failed of $$all tests failed"; \
fi; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"; \
test "$$failed" -eq 0
info:
dvi:
check: all
$(MAKE) check-TESTS
installcheck:
install-exec:
@$(NORMAL_INSTALL)
install-data:
@$(NORMAL_INSTALL)
install: install-exec install-data all
@:
uninstall:
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' 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 stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-generic
clean: clean-generic mostlyclean
distclean: distclean-generic clean
-rm -f config.status
maintainer-clean: 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: tags distdir check-TESTS info dvi installcheck install-exec \
install-data install uninstall all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

31
tests/ls-2/Test.pm Normal file
View File

@@ -0,0 +1,31 @@
# -*-perl-*-
package Test;
require 5.002;
use strict;
# Always copy filename arguments from $srcdir to current directory
# before running ls on them. Otherwise, we'd have to factor out
# differences in $srcdir from the expected output.
$Test::copy_fileargs_default = 1;
sub test_vector
{
my @tv =
(
# test-name options input expected-output expected-return-code
#
['q-', '', {"q\a" => 'contents'}, "q\a\n", 0],
['q-N', '-N', {"q\a" => ''}, "q\a\n", 0],
['q-q', '-q', {"q\a" => ''}, "q?\n", 0],
['q-Q', '-Q', {"q\a" => ''}, "\"q\\a\"\n", 0],
['q-qs-lit', '--quoting=literal', {"q\a" => ''}, "q\a\n", 0],
['q-qs-sh', '--quoting=shell', {"q\a" => ''}, "q\a\n", 0],
['q-qs-sh-a', '--quoting=shell-always', {"q\a" => ''}, "'q\a'\n", 0],
['q-qs-c', '--quoting=c', {"q\a" => ''}, "\"q\\a\"\n", 0],
['q-qs-esc', '--quoting=escape', {"q\a" => ''}, "q\\a\n", 0],
);
return @tv;
}
1;

35
tests/ls-2/quoting Executable file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/perl -w
require 5.003;
use strict;
(my $program_name = $0) =~ s|.*/||;
# Make sure the tools use the expected locale.
$ENV{LANGUAGE} = 'C';
$ENV{LC_ALL} = 'C';
$ENV{LANG} = 'C';
my $q_bell = {IN => {"q\a" => ''}};
my @Tests =
(
# test-name options input expected-output
#
['q-', $q_bell, {OUT => "q\a\n"}, {EXIT => 0}],
['q-N', '-N', $q_bell, {OUT => "q\a\n"}, {ERR => ''}],
['q-q', '-q', $q_bell, {OUT => "q?\n"}],
['q-Q', '-Q', $q_bell, {OUT => "\"q\\a\"\n"}],
['q-lit-q', '--quoting=literal -q', $q_bell, {OUT => "q?\n"}],
['q-qs-lit', '--quoting=literal', $q_bell, {OUT => "q\a\n"}],
['q-qs-sh', '--quoting=shell', $q_bell, {OUT => "q\a\n"}],
['q-qs-sh-a', '--quoting=shell-always', $q_bell, {OUT => "'q\a'\n"}],
['q-qs-c', '--quoting=c', $q_bell, {OUT => "\"q\\a\"\n"}],
['q-qs-esc', '--quoting=escape', $q_bell, {OUT => "q\\a\n"}],
);
my $save_temps = 0;
my $verbose = $ENV{VERBOSE};
my $prog = $ENV{LS} || 'ls';
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
exit $fail;

13
tests/ls-2/run-test Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
: ${PERL=perl}
: ${srcdir=.}
case "$PERL" in
*'missing perl')
echo 1>&2 "$0: configure didn't find a usable version of Perl, so can't run this test"
exit 77
;;
esac
exec $PERL -w -I$srcdir -MFetish -- $srcdir/quoting

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A

View File

@@ -20,8 +20,8 @@ a2="$other_partition_tmpdir/a~"
framework_failure=0
$RM -f $a $a2 || framework_failure=1
: > $a || framework_failure=1
echo a > $a2 || framework_failure=1
echo a > $a || framework_failure=1
echo a2 > $a2 || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'

View File

@@ -1,4 +1,5 @@
#! /bin/sh
# Demonstrate how mv fails when it tries to move a directory into itself.
: ${MV=mv}
: ${MKDIR=mkdir}
@@ -20,13 +21,37 @@ if test $test_failure = 1; then
fi
fail=0
$MV $dir $file $dir || fail=1
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
# This mv command should fail.
$MV $dir $file $dir > out 2>&1 && fail=1
sed \
-e "s,$MV:,XXX:," \
-e "s,$dir,SRC," \
-e "s,$dir/$dir,DEST," \
out > out2
cat > exp <<\EOF
XXX: cannot move `SRC' to a subdirectory of itself, `DEST'
EOF
cmp out2 exp || fail=1
# Make sure the file is gone.
test -f $file && fail=1
# Make sure the directory is *not* gone.
test -d $dir/$dir/a/b || fail=1
# Make sure the directory is *not* moved.
test -d $dir || fail=1
test -d $dir/$dir && fail=1
# Make sure the file has been moved to the right place.
test -f $dir/$file || fail=1
$RM -rf $dir $file
$RM -rf $dir $file out out2 exp
exit $fail

View File

@@ -7,8 +7,12 @@
: ${DF=df}
: ${MKDIR=mkdir}
# Try these
: ${CANDIDATE_TMP_DIRS="$TMPDIR /tmp /var/tmp /usr/tmp $HOME"}
: ${CANDIDATE_TMP_DIRS=not_set}
# Work around a bug in the way Ultrix4.3a's /bin/sh handles multi-word
# variables set with ${VAR="VALUE"}
test "$CANDIDATE_TMP_DIRS" = not_set \
&& CANDIDATE_TMP_DIRS="$TMPDIR /tmp /var/tmp /usr/tmp $HOME"
other_partition_tmpdir=

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A

View File

@@ -15,7 +15,7 @@ tmp=$RM_TMPDIR/t-rm.$$
test_failure=0
mkdir $tmp || test_failure=1
: > $tmp/a || test_failure=1
echo > $tmp/a || test_failure=1
test -f $tmp/a || test_failure=1
if test $test_failure = 1; then

View File

@@ -19,7 +19,7 @@ n10b.X n11a.I n11a.X n11b.I n11b.X 01a.I 01a.X 02a.I 02a.X 02b.I 02b.X 02c.I \
15c.X 15d.I 15d.X 15e.I 15e.X 16a.I 16a.X 17.I 17.X 18a.I 18a.X 18b.I 18b.X \
18c.I 18c.X 18d.I 18d.X 18e.I 18e.X 19a.I 19a.X 19b.I 19b.X 20a.I 20a.X 21a.I \
21a.X 21b.I 21b.X 21c.I 21c.X 21d.I 21d.X 21e.I 21e.X 21f.I 21f.X 21g.I 21g.X \
22a.I 22a.X 22b.I 22b.X
22a.I 22a.X 22b.I 22b.X no-file1.X o-no-file1.X
run_gen = n1.O n1.E n2.O n2.E n3.O n3.E n4.O n4.E n5.O n5.E n6.O n6.E n7.O \
n7.E n8a.O n8a.E n8b.O n8b.E n9a.O n9a.E n9b.O n9b.E n10a.O n10a.E n10b.O \
n10b.E n11a.O n11a.E n11b.O n11b.E 01a.O 01a.E 02a.O 02a.E 02b.O 02b.E 02c.O \
@@ -36,7 +36,7 @@ n10b.E n11a.O n11a.E n11b.O n11b.E 01a.O 01a.E 02a.O 02a.E 02b.O 02b.E 02c.O \
15c.E 15d.O 15d.E 15e.O 15e.E 16a.O 16a.E 17.O 17.E 18a.O 18a.E 18b.O 18b.E \
18c.O 18c.E 18d.O 18d.E 18e.O 18e.E 19a.O 19a.E 19b.O 19b.E 20a.O 20a.E 21a.O \
21a.E 21b.O 21b.E 21c.O 21c.E 21d.O 21d.E 21e.O 21e.E 21f.O 21f.E 21g.O 21g.E \
22a.O 22a.E 22b.O 22b.E
22a.O 22a.E 22b.O 22b.E no-file1.O no-file1.E o-no-file1.O o-no-file1.E
##test-files-end
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
@@ -105,7 +104,7 @@ n10b.X n11a.I n11a.X n11b.I n11b.X 01a.I 01a.X 02a.I 02a.X 02b.I 02b.X 02c.I \
15c.X 15d.I 15d.X 15e.I 15e.X 16a.I 16a.X 17.I 17.X 18a.I 18a.X 18b.I 18b.X \
18c.I 18c.X 18d.I 18d.X 18e.I 18e.X 19a.I 19a.X 19b.I 19b.X 20a.I 20a.X 21a.I \
21a.X 21b.I 21b.X 21c.I 21c.X 21d.I 21d.X 21e.I 21e.X 21f.I 21f.X 21g.I 21g.X \
22a.I 22a.X 22b.I 22b.X
22a.I 22a.X 22b.I 22b.X no-file1.X o-no-file1.X
run_gen = n1.O n1.E n2.O n2.E n3.O n3.E n4.O n4.E n5.O n5.E n6.O n6.E n7.O \
n7.E n8a.O n8a.E n8b.O n8b.E n9a.O n9a.E n9b.O n9b.E n10a.O n10a.E n10b.O \
n10b.E n11a.O n11a.E n11b.O n11b.E 01a.O 01a.E 02a.O 02a.E 02b.O 02b.E 02c.O \
@@ -122,7 +121,7 @@ n10b.E n11a.O n11a.E n11b.O n11b.E 01a.O 01a.E 02a.O 02a.E 02b.O 02b.E 02c.O \
15c.E 15d.O 15d.E 15e.O 15e.E 16a.O 16a.E 17.O 17.E 18a.O 18a.E 18b.O 18b.E \
18c.O 18c.E 18d.O 18d.E 18e.O 18e.E 19a.O 19a.E 19b.O 19b.E 20a.O 20a.E 21a.O \
21a.E 21b.O 21b.E 21c.O 21c.E 21d.O 21d.E 21e.O 21e.E 21f.O 21f.E 21g.O 21g.E \
22a.O 22a.E 22b.O 22b.E
22a.O 22a.E 22b.O 22b.E no-file1.O no-file1.E o-no-file1.O o-no-file1.E
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests

View File

@@ -198,6 +198,11 @@ my @tv = (
["22a", '-k 2,2fd -k 1,1r', "3 b\n4 B\n", "4 B\n3 b\n", 0],
["22b", '-k 2,2d -k 1,1r', "3 b\n4 b\n", "4 b\n3 b\n", 0],
["no-file1", 'no-file', {}, '', 2],
# This test failed until 1.22f. Sort didn't give an error.
# From Will Edgington.
["o-no-file1", '-o no-such-file no-such-file', {}, '', 2],
);
sub test_vector

View File

@@ -1786,8 +1786,42 @@ else
esac
fi
test -s 22b.E || rm -f 22b.E
$xx no-file > no-file1.O 2> no-file1.E
code=$?
if test $code != 2 ; then
$echo "Test no-file1 failed: ../../src/sort return code $code differs from expected value 2" 1>&2
errors=`expr $errors + 1`
else
cmp no-file1.O $srcdir/no-file1.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed no-file1"; fi ;;
1) $echo "Test no-file1 failed: files no-file1.O and $srcdir/no-file1.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test no-file1 may have failed." 1>&2;
$echo The command "cmp no-file1.O $srcdir/no-file1.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s no-file1.E || rm -f no-file1.E
$xx -o no-such-file no-such-file > o-no-file1.O 2> o-no-file1.E
code=$?
if test $code != 2 ; then
$echo "Test o-no-file1 failed: ../../src/sort return code $code differs from expected value 2" 1>&2
errors=`expr $errors + 1`
else
cmp o-no-file1.O $srcdir/o-no-file1.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed o-no-file1"; fi ;;
1) $echo "Test o-no-file1 failed: files o-no-file1.O and $srcdir/o-no-file1.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test o-no-file1 may have failed." 1>&2;
$echo The command "cmp o-no-file1.O $srcdir/o-no-file1.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s o-no-file1.E || rm -f o-no-file1.E
if test $errors = 0 ; then
$echo Passed all 104 tests. 1>&2
$echo Passed all 106 tests. 1>&2
else
$echo Failed $errors tests. 1>&2
fi

65
tests/stty/basic-1 Executable file
View File

@@ -0,0 +1,65 @@
#! /bin/sh
# Make sure stty can parse most of its options.
: ${STTY=stty}
if test "$VERBOSE" = yes; then
set -x
$RM --version
fi
# The following list of reversible options was generated with
# grep -w REV stty.c|sed -n '/^ {"/{s//REV_/;s/".*/=1/;p;}'|fmt
REV_parenb=1 REV_parodd=1 REV_hupcl=1 REV_hup=1 REV_cstopb=1 REV_cread=1
REV_clocal=1 REV_crtscts=1 REV_ignbrk=1 REV_brkint=1 REV_ignpar=1
REV_parmrk=1 REV_inpck=1 REV_istrip=1 REV_inlcr=1 REV_igncr=1 REV_icrnl=1
REV_ixon=1 REV_ixoff=1 REV_tandem=1 REV_iuclc=1 REV_ixany=1 REV_imaxbel=1
REV_opost=1 REV_olcuc=1 REV_ocrnl=1 REV_onlcr=1 REV_onocr=1 REV_onlret=1
REV_ofill=1 REV_ofdel=1 REV_isig=1 REV_icanon=1 REV_iexten=1 REV_echo=1
REV_echoe=1 REV_crterase=1 REV_echok=1 REV_echonl=1 REV_noflsh=1
REV_xcase=1 REV_tostop=1 REV_echoprt=1 REV_prterase=1 REV_echoctl=1
REV_ctlecho=1 REV_echoke=1 REV_crtkill=1 REV_evenp=1 REV_parity=1
REV_oddp=1 REV_nl=1 REV_cooked=1 REV_raw=1 REV_pass8=1 REV_litout=1
REV_cbreak=1 REV_decctlq=1 REV_tabs=1 REV_lcase=1 REV_LCASE=1
saved_state=.saved-state
$STTY --save > $saved_state || exit 1
trap "status=$?; $STTY `cat $saved_state`; exit $status" 0 1 2 3 15
$STTY `cat $saved_state` || exit 1
# Build a list of all boolean options stty accepts on this system.
options=`stty -a|tail +2|tr ';' '\012'|sed '/ = /d;s/^ //'|tr -s ' -' '\012'`
# Take them one at a time, with and without the leading `-'.
for opt in $options; do
$STTY $opt || exit 1
rev=`eval echo "\\\$REV_$opt"`
if test -n "$rev"; then
$STTY -$opt || exit 1
fi
done
if test -n "$RUN_LONG_TESTS"; then
# Take them in pairs.
for opt1 in $options; do
echo .|tr -d '\012'
for opt2 in $options; do
$STTY $opt1 $opt2 || exit 1
rev1=`eval echo "\\\$REV_$opt1"`
rev2=`eval echo "\\\$REV_$opt2"`
if test -n "$rev1"; then
$STTY -$opt1 $opt2 || exit 1
fi
if test -n "$rev2"; then
$STTY $opt1 -$opt2 || exit 1
fi
if test "$rev1$rev2" = 11; then
$STTY -$opt1 -$opt2 || exit 1
fi
done
done
fi
exit 0

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A

View File

@@ -4,7 +4,6 @@
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A