mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
285 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3dcf7a4d23 | ||
|
|
eeeccb3d0f | ||
|
|
6fa5f12107 | ||
|
|
d99c479311 | ||
|
|
9f39fa8559 | ||
|
|
00f84872e4 | ||
|
|
a8fde98844 | ||
|
|
e412e5cb49 | ||
|
|
e65d0d0525 | ||
|
|
9b6538aa8d | ||
|
|
843a0f1a23 | ||
|
|
22fa69e27d | ||
|
|
c04cb1274c | ||
|
|
b102ed9ba6 | ||
|
|
9b4aa5e268 | ||
|
|
53191d01e2 | ||
|
|
26559b513d | ||
|
|
b498eb071d | ||
|
|
991a1d6de9 | ||
|
|
2827bb5704 | ||
|
|
d1df6ef183 | ||
|
|
e45c9a02a4 | ||
|
|
1f95a45099 | ||
|
|
143bfd67c9 | ||
|
|
0b47305caa | ||
|
|
25bbb44dbb | ||
|
|
25507a54f7 | ||
|
|
8e6a68e2fd | ||
|
|
5b86dc69d7 | ||
|
|
f31ea18146 | ||
|
|
8f7fae5972 | ||
|
|
e6d2d94794 | ||
|
|
fd53921a68 | ||
|
|
20d523bfa2 | ||
|
|
bd23509bef | ||
|
|
a4780e67f4 | ||
|
|
b581752137 | ||
|
|
558525592b | ||
|
|
ba5a1036f1 | ||
|
|
d16b4760d7 | ||
|
|
98aec338ef | ||
|
|
ebb9617fde | ||
|
|
c160afe902 | ||
|
|
cf0bb5e05d | ||
|
|
20dc2a6a61 | ||
|
|
1644e58905 | ||
|
|
55efc5f3ee | ||
|
|
93f6771e82 | ||
|
|
83244ba312 | ||
|
|
df2e983677 | ||
|
|
97d21865fb | ||
|
|
a4053c5291 | ||
|
|
85507b24f9 | ||
|
|
19a0b6be60 | ||
|
|
51b88670cb | ||
|
|
4f526d2d64 | ||
|
|
02c3dc9de8 | ||
|
|
8b638f994a | ||
|
|
5d71171e01 | ||
|
|
c763b485f5 | ||
|
|
0d61f144a3 | ||
|
|
826095ffad | ||
|
|
cb0d71399c | ||
|
|
59cec5af12 | ||
|
|
ce9c2c64de | ||
|
|
2b1e6636be | ||
|
|
8c4f28b124 | ||
|
|
0433f90e3d | ||
|
|
1c7d5b5847 | ||
|
|
6449370e9e | ||
|
|
ebfbdf9f0e | ||
|
|
2d10b7617b | ||
|
|
14cdeddbf3 | ||
|
|
2209d10f4c | ||
|
|
18332a65af | ||
|
|
17b18bfa6c | ||
|
|
eb1e30c213 | ||
|
|
d88c9f95e3 | ||
|
|
b50a4ae557 | ||
|
|
3a914fa76d | ||
|
|
224a69b56b | ||
|
|
9a2a8f0b3e | ||
|
|
3f1579c470 | ||
|
|
bba5a47651 | ||
|
|
ca4e48f822 | ||
|
|
3a8d16800c | ||
|
|
de13679b32 | ||
|
|
f7da3f1c10 | ||
|
|
9bde4fd426 | ||
|
|
359c48d5c6 | ||
|
|
74ba433a14 | ||
|
|
c980b0566a | ||
|
|
31896c21c6 | ||
|
|
773a88d33f | ||
|
|
cd78f85b0b | ||
|
|
2061cd8aa6 | ||
|
|
0c91ae335d | ||
|
|
0e40e9de57 | ||
|
|
0a3f944791 | ||
|
|
fa391362e1 | ||
|
|
8c243ff965 | ||
|
|
86cef85b36 | ||
|
|
65ba955988 | ||
|
|
dac5f12c6e | ||
|
|
26d3d090bd | ||
|
|
1eaacac312 | ||
|
|
5d0b158f4c | ||
|
|
982504452d | ||
|
|
48cae1e864 | ||
|
|
022889a457 | ||
|
|
adc62b5d9f | ||
|
|
1f4fcd083d | ||
|
|
9c8e4f6918 | ||
|
|
ed85df444a | ||
|
|
0dc4478f13 | ||
|
|
8ed84c3438 | ||
|
|
c55c0e7369 | ||
|
|
e3e9713fad | ||
|
|
6b8578af5e | ||
|
|
04d49874a2 | ||
|
|
18810ae65f | ||
|
|
d3dcb10f90 | ||
|
|
52b4d2a51a | ||
|
|
2b32399fdc | ||
|
|
44421c22a3 | ||
|
|
61a42e3743 | ||
|
|
60ca9e1599 | ||
|
|
0889381cbf | ||
|
|
1bdf77ad52 | ||
|
|
05a50b7848 | ||
|
|
2f61473e85 | ||
|
|
460ebb078e | ||
|
|
0d5508de13 | ||
|
|
ddf56e0440 | ||
|
|
2fbee63cc9 | ||
|
|
b27275c668 | ||
|
|
016f8c9998 | ||
|
|
10f3e12a0d | ||
|
|
83ae1bdd44 | ||
|
|
2a8f5104cd | ||
|
|
065f14f471 | ||
|
|
9a45c19667 | ||
|
|
f6240c49df | ||
|
|
b52a88607f | ||
|
|
f15842de47 | ||
|
|
c926d002b5 | ||
|
|
31b6c0489a | ||
|
|
a488f288a2 | ||
|
|
a7592cfcb2 | ||
|
|
3288ebb0d7 | ||
|
|
9934f50282 | ||
|
|
46d6df933e | ||
|
|
7b1967351c | ||
|
|
d01338eb3d | ||
|
|
a99c35b04d | ||
|
|
5e3a5ae519 | ||
|
|
1fd718e93c | ||
|
|
972967903d | ||
|
|
e0035fa4eb | ||
|
|
99be907838 | ||
|
|
1ead085826 | ||
|
|
695682d514 | ||
|
|
442d63051c | ||
|
|
7fc5292a29 | ||
|
|
cf5616a0aa | ||
|
|
13601dd3cf | ||
|
|
1ee192a9ff | ||
|
|
cbecb8cab8 | ||
|
|
fb992bae4c | ||
|
|
ac9e4915ad | ||
|
|
92465d59c6 | ||
|
|
921feefb12 | ||
|
|
0c65638b0f | ||
|
|
5c065bb0cb | ||
|
|
680afe6751 | ||
|
|
0fcf730104 | ||
|
|
f144582e17 | ||
|
|
9a913a2461 | ||
|
|
317d2c6384 | ||
|
|
292d68565a | ||
|
|
c352bb469d | ||
|
|
22a2a43021 | ||
|
|
4000c35ae3 | ||
|
|
99eccc3359 | ||
|
|
9965d234e5 | ||
|
|
a011b01af1 | ||
|
|
28fbe5a487 | ||
|
|
9b8023e69c | ||
|
|
b8497a3a7a | ||
|
|
c2e56e0de7 | ||
|
|
031e2fb5e9 | ||
|
|
e181802521 | ||
|
|
c58b5daa33 | ||
|
|
80325aca2d | ||
|
|
d3b5555f10 | ||
|
|
ca738e4414 | ||
|
|
21eb87e6ea | ||
|
|
7ef56a26fd | ||
|
|
aa2617b908 | ||
|
|
016958f2f0 | ||
|
|
1ce9d86c30 | ||
|
|
00b5a2db33 | ||
|
|
e34894bf3f | ||
|
|
b14e5c40b9 | ||
|
|
90f74735aa | ||
|
|
d6a62182f0 | ||
|
|
847ab6a518 | ||
|
|
b5b3690d06 | ||
|
|
57e2022b8d | ||
|
|
be6b4218e4 | ||
|
|
48a05a9ce9 | ||
|
|
fc3b301d4f | ||
|
|
c7e971bee0 | ||
|
|
b0312caf6f | ||
|
|
1c318d52de | ||
|
|
186b655094 | ||
|
|
8333cc3c0f | ||
|
|
c27c4a0957 | ||
|
|
a5e53ecc2c | ||
|
|
d5ab05998c | ||
|
|
a2be861b04 | ||
|
|
fbd87029cf | ||
|
|
3ece0355d5 | ||
|
|
1760ade090 | ||
|
|
ed017d44b2 | ||
|
|
8b09875b59 | ||
|
|
4e38e6a19c | ||
|
|
b3e779c090 | ||
|
|
17409787bb | ||
|
|
ac819e1044 | ||
|
|
36eb45201f | ||
|
|
b43255473f | ||
|
|
90a83264b9 | ||
|
|
43448b0493 | ||
|
|
854284f788 | ||
|
|
0e2ac2de24 | ||
|
|
03911ef780 | ||
|
|
32d4d0dd5e | ||
|
|
cfa2120e83 | ||
|
|
1c5e5d6277 | ||
|
|
41ec3548b0 | ||
|
|
5b27ec57b0 | ||
|
|
1e48b1fee5 | ||
|
|
5dc070cc86 | ||
|
|
b4ec994b26 | ||
|
|
2bf151cd93 | ||
|
|
153477479a | ||
|
|
fec0e89c20 | ||
|
|
407e8f0fdd | ||
|
|
461231f022 | ||
|
|
b705e9a9e7 | ||
|
|
b3677e5e38 | ||
|
|
cc0f637b6d | ||
|
|
7920f2c14a | ||
|
|
99f4994982 | ||
|
|
5afac2aee1 | ||
|
|
aa67daf63b | ||
|
|
f7a009c17c | ||
|
|
028e12ce3b | ||
|
|
f3f1ccfd87 | ||
|
|
08c38ab7cb | ||
|
|
d60e33e241 | ||
|
|
31a884dab7 | ||
|
|
74443830ea | ||
|
|
2ae61facc7 | ||
|
|
bb7fa1e932 | ||
|
|
16c8062085 | ||
|
|
17278118ee | ||
|
|
7f6fb43e7d | ||
|
|
ddc409b59e | ||
|
|
7eb3aab88b | ||
|
|
4fb3704c25 | ||
|
|
514b7fbc00 | ||
|
|
555c219d9e | ||
|
|
59964c164b | ||
|
|
7377f49ea8 | ||
|
|
969841cb77 | ||
|
|
c3e1fe230b | ||
|
|
1833a876ae | ||
|
|
0f5695bd59 | ||
|
|
42df6d7de2 | ||
|
|
9c0c57a1b4 | ||
|
|
a36f4cb451 | ||
|
|
ed0a1c9f94 | ||
|
|
f9da2d0e87 |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "gnulib"]
|
||||
path = gnulib
|
||||
url = git://git.sv.gnu.org/gnulib.git
|
||||
@@ -1 +1 @@
|
||||
6.12
|
||||
7.1
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
ChangeLog(-[0-9]+)?$
|
||||
^old/
|
||||
^src/c99-to-c98\.diff$
|
||||
^gl/.*
|
||||
1
.x-sc_po_check
Normal file
1
.x-sc_po_check
Normal file
@@ -0,0 +1 @@
|
||||
^gl/
|
||||
@@ -1,6 +1 @@
|
||||
ChangeLog
|
||||
^TODO$
|
||||
^lib/euidaccess-stat\.c$
|
||||
^maint\.mk$
|
||||
^doc/coreutils.texi$
|
||||
^tests/misc/stty-invalid$
|
||||
|
||||
4
.x-sc_prohibit_stat_st_blocks
Normal file
4
.x-sc_prohibit_stat_st_blocks
Normal file
@@ -0,0 +1,4 @@
|
||||
src/system.h
|
||||
tests/du/2g
|
||||
old/fileutils/ChangeLog-1997
|
||||
ChangeLog-2005
|
||||
@@ -1,2 +1 @@
|
||||
^src/system\.h
|
||||
ChangeLog
|
||||
|
||||
@@ -1,30 +1,9 @@
|
||||
^lib/at-func\.c$
|
||||
^lib/bcopy\.c$
|
||||
^lib/buffer-lcm\.c$
|
||||
^lib/c-strtold\.c$
|
||||
^lib/fnmatch_loop\.c$
|
||||
^lib/full-read\.c$
|
||||
^lib/imaxtostr\.c$
|
||||
^lib/mempcpy\.c$
|
||||
^lib/memset\.c$
|
||||
^lib/offtostr\.c$
|
||||
^lib/regcomp\.c$
|
||||
^lib/regex_internal\.c$
|
||||
^lib/regexec\.c$
|
||||
^lib/safe-write\.c$
|
||||
^lib/strtoll\.c$
|
||||
^lib/strtoul\.c$
|
||||
^lib/strtoull\.c$
|
||||
^lib/strtoumax\.c$
|
||||
^lib/umaxtostr\.c$
|
||||
^lib/xstrtold\.c$
|
||||
^lib/xstrtoul\.c$
|
||||
^src/false\.c$
|
||||
^src/lbracket\.c$
|
||||
^src/ls-dir\.c$
|
||||
^src/ls-ls\.c$
|
||||
^src/ls-vdir\.c$
|
||||
^src/rand-isaac\.c$
|
||||
^src/tac-pipe\.c$
|
||||
^src/uname-arch\.c$
|
||||
^src/uname-uname\.c$
|
||||
|
||||
9
.x-sc_require_config_h_first
Normal file
9
.x-sc_require_config_h_first
Normal file
@@ -0,0 +1,9 @@
|
||||
^lib/buffer-lcm\.c$
|
||||
^src/false\.c$
|
||||
^src/lbracket\.c$
|
||||
^src/ls-dir\.c$
|
||||
^src/ls-ls\.c$
|
||||
^src/ls-vdir\.c$
|
||||
^src/tac-pipe\.c$
|
||||
^src/uname-arch\.c$
|
||||
^src/uname-uname\.c$
|
||||
2
AUTHORS
2
AUTHORS
@@ -25,7 +25,7 @@ du: Torbjörn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
|
||||
echo: Brian Fox, Chet Ramey
|
||||
env: Richard Mlynarik, David MacKenzie
|
||||
expand: David MacKenzie
|
||||
expr: Mike Parker, James Youngman
|
||||
expr: Mike Parker, James Youngman, Paul Eggert
|
||||
factor: Paul Rubin
|
||||
false: Jim Meyering
|
||||
fmt: Ross Paterson
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2008-12-16 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
NB: ChangeLog files are no longer manually maintained.
|
||||
See HACKING for details.
|
||||
|
||||
2008-02-07 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
We *do* need two different version files.
|
||||
|
||||
72
HACKING
72
HACKING
@@ -32,9 +32,14 @@ inside your new coreutils/ directory:
|
||||
If you have made *no* changes:
|
||||
git pull
|
||||
|
||||
If you *have* made changes and committed them to "master", do this:
|
||||
git fetch
|
||||
git rebase origin
|
||||
If you *have* made changes and mistakenly committed them to "master",
|
||||
do the following to put your changes on a private branch, "br", and
|
||||
to restore master to its unmodified (relative-to-upstream) state:
|
||||
git checkout -b br
|
||||
git checkout master
|
||||
git reset --hard origin
|
||||
|
||||
Then "git pull" should work.
|
||||
|
||||
|
||||
*Before* you commit changes
|
||||
@@ -288,7 +293,9 @@ Nearly every significant change must be accompanied by a test suite
|
||||
addition that exercises it. If you fix a bug, add at least one test that
|
||||
fails without the patch, but that succeeds once your patch is applied.
|
||||
If you add a feature, add tests to exercise as much of the new code
|
||||
as possible.
|
||||
as possible. Note to run tests/misc/newtest in isolation you can do:
|
||||
|
||||
(cd tests && make check TESTS=misc/newtest VERBOSE=yes)
|
||||
|
||||
There are hundreds of tests in the tests/ directories. You can use
|
||||
tests/sample-test as a template, or one of the various Perl-based ones
|
||||
@@ -323,6 +330,10 @@ you'd use doc/Copyright/request-assign.future:
|
||||
|
||||
You may make assignments for up to four projects at a time.
|
||||
|
||||
In case you're wondering why we bother with all of this, read this:
|
||||
|
||||
http://www.gnu.org/licenses/why-assign.html
|
||||
|
||||
|
||||
Run "make syntax-check", or even "make distcheck"
|
||||
================================================
|
||||
@@ -345,6 +356,49 @@ With other files, there will be some existing differences.
|
||||
Try not to add any more.
|
||||
|
||||
|
||||
Avoid trailing white space
|
||||
==========================
|
||||
You may notice that the only trailing blanks in coreutils'
|
||||
version-controlled files are in a single directory: tests/pr,
|
||||
which contains expected output from various invocations of pr.
|
||||
|
||||
Do not add any more trailing blanks anywhere. While "make syntax-check"
|
||||
will alert you if you slip up, it's better to nip any problem in the
|
||||
bud, as you're typing. A good way to help you adapt to this rule is
|
||||
to configure your editor to highlight any offending characters in the
|
||||
files you edit. If you use Emacs, customize its font-lock mode (FIXME:
|
||||
provide more detail) or try one of its whitespace packages. This appears
|
||||
to be the one that will end up in emacs 23:
|
||||
|
||||
http://www.emacswiki.org/emacs/WhiteSpace
|
||||
|
||||
[that page says its version also works with emacs 21 and 22]
|
||||
If you use vim, add this to ~/.vimrc:
|
||||
|
||||
let c_space_errors=1
|
||||
highlight RedundantSpaces ctermbg=red guibg=red
|
||||
match RedundantSpaces /\s\+$\| \+\ze\t/
|
||||
|
||||
|
||||
Git can help too, by stopping you from committing any change that would
|
||||
add trailing blanks. The example pre-commit hook contains code to check
|
||||
for trailing whitespace and spaces before tabs; enable it by moving it
|
||||
to the right place and making sure it is executable:
|
||||
|
||||
mv .git/hooks/pre-commit.sample .git/hooks/pre-commit
|
||||
|
||||
With a repository created by git-1.5.6 or older, use this command:
|
||||
|
||||
chmod +x .git/hooks/pre-commit
|
||||
|
||||
To manually check for whitespace errors before committing, you can use
|
||||
|
||||
git diff --check
|
||||
|
||||
Git also has some settings to enable suitable internal whitespace checks.
|
||||
See the manpage for git-apply for details.
|
||||
|
||||
|
||||
-------------------------------------------
|
||||
|
||||
Miscellaneous useful git commands
|
||||
@@ -402,3 +456,13 @@ to generate HTML coverage reports. Follow these steps:
|
||||
|
||||
Then just open the index.html file (in the generated lcov-html directory)
|
||||
in your favorite web browser.
|
||||
|
||||
========================================================================
|
||||
Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the ``GNU Free
|
||||
Documentation License'' file as part of this distribution.
|
||||
|
||||
@@ -20,12 +20,13 @@ EXTRA_DIST = cfg.mk maint.mk \
|
||||
.prev-version THANKS-to-translators THANKStt.in \
|
||||
.version \
|
||||
.vg-suppressions \
|
||||
.x-po-check \
|
||||
.x-sc_GPL_version \
|
||||
.x-sc_file_system \
|
||||
.x-sc_obsolete_symbols \
|
||||
.x-sc_po_check \
|
||||
.x-sc_program_name \
|
||||
.x-sc_prohibit_atoi_atof \
|
||||
.x-sc_prohibit_stat_st_blocks \
|
||||
.x-sc_prohibit_strcmp \
|
||||
.x-sc_require_config_h \
|
||||
.x-sc_space_tab .x-sc_sun_os_names \
|
||||
@@ -101,8 +102,8 @@ MAINTAINERCLEANFILES = THANKS-to-translators
|
||||
THANKS-to-translators: po/LINGUAS THANKStt.in
|
||||
( \
|
||||
cat $(srcdir)/THANKStt.in; \
|
||||
for lang in `cat $(srcdir)/po/LINGUAS`; do \
|
||||
echo http://www.iro.umontreal.ca/contrib/po/HTML/team-$$lang.html; \
|
||||
for lang in `cat $(srcdir)/po/LINGUAS`; do \
|
||||
echo http://translationproject.org/team/$$lang.html; \
|
||||
done; \
|
||||
) > $@-tmp && mv $@-tmp $@
|
||||
|
||||
|
||||
121
NEWS
121
NEWS
@@ -1,5 +1,123 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 7.2 (2009-03-31) [stable]
|
||||
|
||||
** New features
|
||||
|
||||
pwd now accepts the options --logical (-L) and --physical (-P). For
|
||||
compatibility with existing scripts, -P is the default behavior
|
||||
unless POSIXLY_CORRECT is requested.
|
||||
|
||||
** Bug fixes
|
||||
|
||||
cat once again immediately outputs data it has processed.
|
||||
Previously it would have been buffered and only output if enough
|
||||
data was read, or on process exit.
|
||||
[bug introduced in coreutils-6.0]
|
||||
|
||||
comm's new --check-order option would fail to detect disorder on any pair
|
||||
of lines where one was a prefix of the other. For example, this would
|
||||
fail to report the disorder: printf 'Xb\nX\n'>k; comm --check-order k k
|
||||
[bug introduced in coreutils-7.0]
|
||||
|
||||
cp once again diagnoses the invalid "cp -rl dir dir" right away,
|
||||
rather than after creating a very deep dir/dir/dir/... hierarchy.
|
||||
The bug strikes only with both --recursive (-r, -R) and --link (-l).
|
||||
[bug introduced in coreutils-7.1]
|
||||
|
||||
ls --sort=version (-v) sorted names beginning with "." inconsistently.
|
||||
Now, names that start with "." are always listed before those that don't.
|
||||
|
||||
pr: fix the bug whereby --indent=N (-o) did not indent header lines
|
||||
[bug introduced in coreutils-6.9.90]
|
||||
|
||||
sort now handles specified key ends correctly.
|
||||
Previously -k1,1b would have caused leading space from field 2 to be
|
||||
included in the sort while -k2,3.0 would have not included field 3.
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
cp,mv,install,cat,split: now read and write a minimum of 32KiB
|
||||
at a time. This was seen to increase throughput. Up to 2 times
|
||||
when reading cached files on linux for example.
|
||||
|
||||
cp -a now tries to preserve extended attributes (xattr), but does not
|
||||
diagnose xattr-preservation failure. However, cp --preserve=all still does.
|
||||
|
||||
ls --color: hard link highlighting can be now disabled by changing the
|
||||
LS_COLORS environment variable. To disable it you can add something like
|
||||
this to your profile: eval `dircolors | sed s/hl=[^:]*:/hl=:/`
|
||||
|
||||
|
||||
* Noteworthy changes in release 7.1 (2009-02-21) [stable]
|
||||
|
||||
** New features
|
||||
|
||||
Add extended attribute support available on certain filesystems like ext2
|
||||
and XFS.
|
||||
cp: Tries to copy xattrs when --preserve=xattr or --preserve=all specified
|
||||
mv: Always tries to copy xattrs
|
||||
install: Never copies xattrs
|
||||
|
||||
cp and mv accept a new option, --no-clobber (-n): silently refrain
|
||||
from overwriting any existing destination file
|
||||
|
||||
dd accepts iflag=cio and oflag=cio to open the file in CIO (concurrent I/O)
|
||||
mode where this feature is available.
|
||||
|
||||
install accepts a new option, --compare (-C): compare each pair of source
|
||||
and destination files, and if the destination has identical content and
|
||||
any specified owner, group, permissions, and possibly SELinux context, then
|
||||
do not modify the destination at all.
|
||||
|
||||
ls --color now highlights hard linked files, too
|
||||
|
||||
stat -f recognizes the Lustre file system type
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chgrp, chmod, chown --silent (--quiet, -f) no longer print some diagnostics
|
||||
[bug introduced in coreutils-5.1]
|
||||
|
||||
cp uses much less memory in some situations
|
||||
|
||||
cp -a now correctly tries to preserve SELinux context (announced in 6.9.90),
|
||||
doesn't inform about failure, unlike with --preserve=all
|
||||
|
||||
du --files0-from=FILE no longer reads all of FILE into RAM before
|
||||
processing the first file name
|
||||
|
||||
seq 9223372036854775807 9223372036854775808 now prints only two numbers
|
||||
on systems with extended long double support and good library support.
|
||||
Even with this patch, on some systems, it still produces invalid output,
|
||||
from 3 to at least 1026 lines long. [bug introduced in coreutils-6.11]
|
||||
|
||||
seq -w now accounts for a decimal point added to the last number
|
||||
to correctly print all numbers to the same width.
|
||||
|
||||
wc --files0-from=FILE no longer reads all of FILE into RAM, before
|
||||
processing the first file name, unless the list of names is known
|
||||
to be small enough.
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
cp and mv: the --reply={yes,no,query} option has been removed.
|
||||
Using it has elicited a warning for the last three years.
|
||||
|
||||
dd: user specified offsets that are too big are handled better.
|
||||
Previously, erroneous parameters to skip and seek could result
|
||||
in redundant reading of the file with no warnings or errors.
|
||||
|
||||
du: -H (initially equivalent to --si) is now equivalent to
|
||||
--dereference-args, and thus works as POSIX requires
|
||||
|
||||
shred: now does 3 overwrite passes by default rather than 25.
|
||||
|
||||
ls -l now marks SELinux-only files with the less obtrusive '.',
|
||||
rather than '+'. A file with any other combination of MAC and ACL
|
||||
is still marked with a '+'.
|
||||
|
||||
|
||||
* Noteworthy changes in release 7.0 (2008-10-05) [beta]
|
||||
|
||||
** New programs
|
||||
@@ -2304,8 +2422,7 @@ packages, see ./old/*/NEWS.
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
|
||||
Foundation, Inc.
|
||||
Copyright (C) 2001-2009 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2 or
|
||||
|
||||
23
README
23
README
@@ -92,11 +92,15 @@ compiler, due to the use of declarations after non-declaration statements
|
||||
in several files in src/. There is code in configure to find and, if
|
||||
possible, enable an appropriate compiler. However, if configure doesn't
|
||||
find a C99 compiler, it continues nonetheless, and your build will fail.
|
||||
If that happens, simply apply the included patch using the following
|
||||
If that happens, simply[*] apply the included patch using the following
|
||||
command, and then run make again:
|
||||
|
||||
cd src && patch < c99-to-c89.diff
|
||||
|
||||
[*] however, as of coreutils-7.1, the "c99-to-c89.diff" file is no longer
|
||||
maintained, so even if the patches still apply, the result will be an
|
||||
incomplete conversion. It's been 10 years. Get a decent compiler! ;-)
|
||||
|
||||
|
||||
***********************
|
||||
HPUX 11.x build failure
|
||||
@@ -161,17 +165,13 @@ Reporting bugs:
|
||||
IMPORTANT: if you take the time to report a test failure,
|
||||
please be sure to include the output of running `make check'
|
||||
in verbose mode for each failing test. For example,
|
||||
if the test that fails is tests/mv/hard-link-1, then you
|
||||
would run this command:
|
||||
if the test that fails is tests/misc/df, then you would
|
||||
run this command:
|
||||
|
||||
env VERBOSE=yes make check -C tests/mv TESTS=hard-link-1 >> log 2>&1
|
||||
(cd tests && make check TESTS=misc/df VERBOSE=yes) >> log 2>&1
|
||||
|
||||
For some tests, you can get even more detail by including
|
||||
DEBUG=yes in the environment:
|
||||
|
||||
env DEBUG=yes VERBOSE=yes make check -C tests/mv TESTS=hard-link-1 >> log 2>&1
|
||||
|
||||
and then include the contents of the file `log' in your bug report.
|
||||
For some tests, you can get even more detail by adding DEBUG=yes.
|
||||
Then include the contents of the file `log' in your bug report.
|
||||
|
||||
***************************************
|
||||
|
||||
@@ -231,8 +231,7 @@ the address on the last line of --help output.
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 1998, 2002, 2003, 2004, 2005, 2006 Free Software
|
||||
Foundation, Inc.
|
||||
Copyright (C) 1998, 2002-2009 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2 or
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
These notes intend to help people working on the checked-out sources.
|
||||
These requirements do not apply when building from a distribution tarball.
|
||||
See also HACKING for more detailed coreutils contribution guidlines.
|
||||
|
||||
* Requirements
|
||||
|
||||
We've opted to keep only the highest-level sources in the GIT repository.
|
||||
This eases our maintenance burden, (fewer merges etc.), but imposes more
|
||||
requirements on anyone wishing to build from the just-checked-out sources.
|
||||
For example, you have to use the latest stable versions of the maintainer
|
||||
tools we depend upon, including:
|
||||
Specific tools and versions will be checked for and listed by the
|
||||
bootstrap script shown below, and will include:
|
||||
|
||||
- Automake <http://www.gnu.org/software/automake/>
|
||||
- Autoconf <http://www.gnu.org/software/autoconf/>
|
||||
@@ -22,41 +23,44 @@ tools we depend upon, including:
|
||||
- Rsync <http://samba.anu.edu.au/rsync/>
|
||||
- Tar <http://www.gnu.org/software/tar/>
|
||||
|
||||
Valgrind <http://valgrind.org/> is also highly recommended, if
|
||||
Valgrind supports your architecture.
|
||||
|
||||
Only building the initial full source tree will be a bit painful.
|
||||
Later, a plain `git pull && make' should be sufficient.
|
||||
|
||||
* LZMA
|
||||
- Valgrind
|
||||
|
||||
This package's build procedure uses LZMA to create a compressed
|
||||
Valgrind <http://valgrind.org/> is also highly recommended, if
|
||||
Valgrind supports your architecture. See also README-valgrind.
|
||||
|
||||
- XZ utils (successor to LZMA)
|
||||
|
||||
This package's build procedure uses XZ to create a compressed
|
||||
distribution tarball. Using this feature of Automake requires
|
||||
version 1.10.1 or newer, as well as the lzma program itself.
|
||||
Make sure you have the latest stable version of the LZMA Utils
|
||||
from <http://tukaani.org/lzma/>.
|
||||
version 1.10a or newer, as well as the xz program itself.
|
||||
Make sure you have the latest version of the XZ Utils from
|
||||
<http://tukaani.org/lzma/download>.
|
||||
|
||||
* First GIT checkout
|
||||
|
||||
You can get a copy of the source repository like this:
|
||||
|
||||
$ git clone git://git.sv.gnu.org/coreutils
|
||||
$ git clone git://git.sv.gnu.org/coreutils
|
||||
$ cd coreutils
|
||||
|
||||
The next step is to get other files needed to build, which are
|
||||
extracted from other source packages:
|
||||
The next step is to get and check other files needed to build,
|
||||
which are extracted from other source packages:
|
||||
|
||||
$ ./bootstrap
|
||||
$ ./bootstrap
|
||||
|
||||
And there you are! Just
|
||||
|
||||
$ ./configure
|
||||
$ make
|
||||
$ make check
|
||||
$ ./configure #[--enable-gcc-warnings]
|
||||
$ make
|
||||
$ make check
|
||||
|
||||
At this point, there should be no difference between your local copy,
|
||||
and the GIT master copy:
|
||||
|
||||
$ git diff
|
||||
$ git diff
|
||||
|
||||
should output no difference.
|
||||
|
||||
@@ -64,7 +68,7 @@ Enjoy!
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2009 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
|
||||
@@ -78,3 +82,7 @@ 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Local Variables:
|
||||
indent-tabs-mode: nil
|
||||
End:
|
||||
|
||||
32
README-prereq
Normal file
32
README-prereq
Normal file
@@ -0,0 +1,32 @@
|
||||
Detailed below are concrete examples for
|
||||
getting the prerequisites for particular systems.
|
||||
|
||||
- linux - fedora
|
||||
|
||||
This shows the steps for getting the required tools to build coreutils 7.0
|
||||
on a Fedora 8 system. We try to use official packages where possible.
|
||||
The 3 methods described for making these required packages available, should
|
||||
help clarify build requirements on any linux system at least.
|
||||
|
||||
1. Make sure offical distro git package is installed
|
||||
# yum install git
|
||||
|
||||
2. The distro autoconf is too old, but there is a newer one available
|
||||
so we rebuild that and make it available to the full system:
|
||||
# yum install emacs #autoconf build requires emacs (20MB)
|
||||
# rpmbuild --rebuild http://download.fedora.redhat.com/pub/fedora/linux/development/source/SRPMS/autoconf-2.63-1.fc10.src.rpm
|
||||
# rpm -Uvh /usr/src/redhat/RPMS/noarch/autoconf-2.63-1.fc8.noarch.rpm
|
||||
Note Autoconf 2.61a-341 or newer is needed to build automake-1.10a in step 3.
|
||||
Apply the same method to install the lzma package.
|
||||
[FIXME: mention xz when it's packaged]
|
||||
|
||||
3. The latest released automake (1.10.1) was not new enough, so we download
|
||||
and build automake-1.10a from its repository and make it available
|
||||
just to coreutils:
|
||||
# yum install help2man #required to build automake fully
|
||||
$ git clone git://git.sv.gnu.org/automake.git
|
||||
$ cd automake && ./configure --prefix=$HOME/coreutils/deps
|
||||
$ make install
|
||||
|
||||
Now we can build coreutils as described in README-hacking
|
||||
as long as $PATH starts with $HOME/coreutils/deps
|
||||
95
README-release
Normal file
95
README-release
Normal file
@@ -0,0 +1,95 @@
|
||||
Here are most of the steps we (maintainers) follow when making a release.
|
||||
|
||||
* start from a clean, up-to-date git directory.
|
||||
|
||||
git checkout master; git pull
|
||||
|
||||
* Run ./configure && make maintainer-clean
|
||||
|
||||
* Ensure that the desired versions of autoconf, automake, bison, etc.
|
||||
are in your PATH. See HACKING for the complete list.
|
||||
|
||||
* Ensure that you're on "master" with no uncommitted diffs.
|
||||
This should produce no output: git checkout master; git diff
|
||||
|
||||
* Make sure your local gnulib directory is up to date.
|
||||
|
||||
* Run bootstrap, (assuming your local copy of gnulib is in /gnulib):
|
||||
./bootstrap --gnulib-srcdir=/gnulib
|
||||
|
||||
FIXME: enable excluded programs like arch? to get their manual pages?
|
||||
|
||||
* Pre-release testing:
|
||||
On at least one SELinux-enabled (enforcing) and one non-SELinux system,
|
||||
run all tests, both root-only and regular.
|
||||
Run *all* non-root tests, including expensive and very expensive ones i.e.,
|
||||
run this: make check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
|
||||
|
||||
Run the root-only tests:
|
||||
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
|
||||
|
||||
* Run "make distcheck"
|
||||
|
||||
* Manually set the date, version number, and [stable/alpha/beta] on
|
||||
line 3 of NEWS, then do this:
|
||||
|
||||
v=7.1
|
||||
git commit -F <(printf 'version '$v'\n\n* NEWS: Record release date.\n') -a
|
||||
git tag -s -m "coreutils $v" v$v HEAD
|
||||
|
||||
* Run the following to create release tarballs. Your choice selects the
|
||||
corresponding upload-to destination in the emitted gnupload command.
|
||||
|
||||
# "TYPE" must be major, beta or alpha
|
||||
make TYPE
|
||||
|
||||
* Test the tarball. copy it to a few odd-ball systems and ensure that
|
||||
it builds and passes all tests.
|
||||
|
||||
* While that's happening, write the release announcement that you will
|
||||
soon post.
|
||||
|
||||
Once all the builds and tests have passed,
|
||||
|
||||
* Run the gnupload command suggested by your "XZ_OPT=-9e make major" run above.
|
||||
|
||||
* Wait a few minutes (maybe up to 30?) and then use the release URLs to
|
||||
download all tarball/signature pairs and use gpg --verify to ensure
|
||||
that they're all valid.
|
||||
|
||||
* Push the new tag:
|
||||
git push origin tag v<JUST_RELEASED_VERSION_NUMBER>
|
||||
|
||||
* Send the gpg-signed announcement mail, e.g.,
|
||||
To: info-gnu@gnu.org, coreutils-announce@gnu.org
|
||||
Cc: coordinator@translationproject.org, bug-coreutils@gnu.org
|
||||
Subject: coreutils-7.1 released [stable]
|
||||
|
||||
* Approve the announcement here:
|
||||
http://lists.gnu.org/mailman/admindb/coreutils-announce
|
||||
|
||||
* Announce it on Savannah, too:
|
||||
From here:
|
||||
https://savannah.gnu.org/projects/coreutils/
|
||||
click on the "submit news", then write something like the following:
|
||||
|
||||
The announcement is here:
|
||||
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/48
|
||||
|
||||
Then go here to approve it:
|
||||
https://savannah.gnu.org/news/approve.php?group=coreutils
|
||||
|
||||
* For non-alpha releases, update the on-line manual at
|
||||
|
||||
http://www.gnu.org/software/coreutils/manual/
|
||||
|
||||
Run `make web-manual', then copy the contents of doc/manual
|
||||
into a CVS checkout of the coreutils manual repository.
|
||||
Also edit coreutils.html (FIXME? why?) before doing a CVS commit.
|
||||
|
||||
CVS_RSH=ssh \
|
||||
cvs -d:ext:$USER@cvs.savannah.gnu.org:/web/coreutils co coreutils
|
||||
|
||||
Be sure to "cvs add -ko" any files that "cvs status" marks with "?".
|
||||
That is necessary whenever a new texinfo node is added. Each becomes
|
||||
a new file in html_node that must then be "cvs add"ed.
|
||||
34
THANKS
34
THANKS
@@ -10,6 +10,7 @@ the bug-report mailing list (as seen on last line of e.g., cp --help).
|
||||
A Costa agcosta@gis.net
|
||||
Aaron Hawley ashawley@uvm.edu
|
||||
Achim Blumensath blume@corona.oche.de
|
||||
Adam Jimerson vendion@charter.net
|
||||
Adam Klein aklein@debian.org
|
||||
Adrian Bunk bunk@stusta.de
|
||||
AIDA Shinra shinra@j10n.org
|
||||
@@ -21,6 +22,8 @@ Albert Hopkins ahopkins@dynacare.com
|
||||
Alberto Accomazzi alberto@cfa0.harvard.edu
|
||||
aldomel aldomel@ix.netcom.com
|
||||
Alen Muzinic zveki@fly.cc.fer.hr
|
||||
Alexander Nguyen vinh@seas.ucla.edu
|
||||
Alexander V. Lukyanov lav@netis.ru
|
||||
Allen Hewes allen@decisiv.net
|
||||
Axel Dörfler axeld@pinc-software.de
|
||||
Alexandre Duret-Lutz duret_g@epita.fr
|
||||
@@ -33,11 +36,12 @@ Andreas Frische andreasfrische@gmail.com
|
||||
Andreas Gruenbacher ag@bestbits.at
|
||||
Andreas Jaeger jaeger@gnu.org
|
||||
Andreas Luik luik@isa.de
|
||||
Andreas Schwab schwab@suse.de
|
||||
Andreas Schwab schwab@linux-m68k.org
|
||||
Andreas Stolcke stolcke@ICSI.Berkeley.EDU
|
||||
Andrei Gaponenko andr@triumf.ca
|
||||
Andres Soolo andres@soolo.matti.ee
|
||||
Andrew Burgess aab@cichlid.com
|
||||
Andrew Church achurch@achurch.org
|
||||
Andrew Dalke dalke@bioreason.com
|
||||
Andrew Fabbro andrew@fabbro.org
|
||||
Andrew Pham andpha@us.ibm.com
|
||||
@@ -58,6 +62,7 @@ Augey Mikus mikus@dqc.org
|
||||
Aurelien Jarno aurel32@debian.org
|
||||
Austin Donnelly Austin.Donnelly@cl.cam.ac.uk
|
||||
Axel Kittenberger Anshil@gmx.net
|
||||
Barry Kelly http://barrkel.blogspot.com/
|
||||
Bauke Jan Douma bjdouma@xs4all.nl
|
||||
Ben Elliston bje@air.net.au
|
||||
Ben Harris bjh21@netbsd.org
|
||||
@@ -79,11 +84,13 @@ Bob Proulx rwp@fc.hp.com
|
||||
Branden Robinson branden@necrotic.deadbeast.net
|
||||
Brendan O'Dea bod@compusol.com.au
|
||||
Brian Kimball bfk@footbag.org
|
||||
Brian M. Carlson sandals@crustytoothpaste.ath.cx
|
||||
Brian Silverman bsilverman@conceptxdesign.com
|
||||
Brian Youmans 3diff@gnu.org
|
||||
Bruce Korb bkorb@veritas.com
|
||||
Bruce Robertson brucer@theodolite.dyndns.org
|
||||
Bruno Haible haible@clisp.cons.org
|
||||
C de-Avillez hggdh2@gmail.com
|
||||
Carl Johnson carlj@cjlinux.home.org
|
||||
Carl Lowenstein cdl@mpl.UCSD.EDU
|
||||
Carl Roth roth@urs.us
|
||||
@@ -114,7 +121,7 @@ Cyril Bouthors cyril@bouthors.org
|
||||
Dale Scheetz dwarf@polaris.net
|
||||
Dameon G. Rogers dgr03@uark.edu
|
||||
Dan Hagerty hag@gnu.ai.it.edu
|
||||
Dan Jacobson http://www.geocities.com/jidani
|
||||
Dan Jacobson jidanni@jidanni.org
|
||||
Dan Pascu dan@services.iiruc.ro
|
||||
Daniel Bergstrom noa@melody.se
|
||||
Daniel Dunbar ddunbar@stanford.edu
|
||||
@@ -125,6 +132,7 @@ Darrel Francis d.francis@cheerful.com
|
||||
Darren Salt ds@youmustbejoking.demon.co.uk
|
||||
Dave Beckett dajobe@dajobe.org
|
||||
David Alan Gilbert gilbertd@treblig.org
|
||||
David Bartley dtbartle@csclub.uwaterloo.ca
|
||||
David Dyck dcd@tc.fluke.COM
|
||||
David Eisner cradle@umd.edu
|
||||
David Flynn dav@chess.plus.com
|
||||
@@ -132,6 +140,7 @@ David Godfrey dave@delta.demon.co.uk
|
||||
David Luyer david_luyer@pacific.net.au
|
||||
David Madore david.madore@ens.fr
|
||||
David Malone dwmalone@cnri.dit.ie
|
||||
Davide Canova kc.canova@gmail.com
|
||||
Dawson Engler engler@stanford.edu
|
||||
Dean Gaudet dean-savannah@arctic.org
|
||||
Deepak Goel deego@gnufans.org
|
||||
@@ -196,11 +205,13 @@ Geoff Whale geoffw@cse.unsw.EDU.AU
|
||||
Gerald Pfeifer gerald@pfeifer.com
|
||||
Gerhard Poul gpoul@gnu.org
|
||||
Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp
|
||||
Göran Uddeborg goeran@uddeborg.pp.se
|
||||
Glen Lenker glen.lenker@gmail.com
|
||||
Göran Uddeborg goeran@uddeborg.se
|
||||
Guochun Shi gshi@ncsa.uiuc.edu
|
||||
GOTO Masanori gotom@debian.or.jp
|
||||
Greg Louis glouis@dynamicro.on.ca
|
||||
Greg McGary gkm@gnu.org
|
||||
Greg Metcalfe metcalfegreg@qwest.net
|
||||
Greg Schafer gschafer@zip.com.au
|
||||
Greg Troxel gdt@bbn.com
|
||||
Greg Wooledge gawooledge@sherwin.com
|
||||
@@ -237,9 +248,10 @@ James Hunt jamesodhunt@hotmail.com
|
||||
James Ralston ralston@pobox.com
|
||||
James Sneeringer jvs@ocslink.com
|
||||
James Tanis jtt@soscorp.com
|
||||
James Youngman james+usenet@free-lunch.demon.co.uk
|
||||
James Youngman jay@gnu.org
|
||||
Jamie Lokier jamie@imbolc.ucc.ie
|
||||
Jamie McClelland jm@mayfirst.org
|
||||
Jan Engelhardt jengelh@medozas.de
|
||||
Jan Fedak J.Fedak@sh.cvut.cz
|
||||
Jan Moringen jan.moringen@uni-bielefeld.de
|
||||
Jan Nieuwenhuizen janneke@gnu.org
|
||||
@@ -281,6 +293,7 @@ Jon Peatfield J.S.Peatfield@damtp.cam.ac.uk
|
||||
Joost van Baal joostvb@xs4all.nl
|
||||
Jorge Stolfi stolfi@ic.unicamp.br
|
||||
Joseph S. Myers jsm28@cam.ac.uk
|
||||
Josh Triplett josh@freedesktop.org
|
||||
Joshua Hudson joshudson@gmail.com
|
||||
Josselin Mouette joss@debian.org
|
||||
Juan F. Codagnone juam@arnet.com.ar
|
||||
@@ -354,6 +367,7 @@ Mate Wierdl mw@moni.msci.memphis.edu
|
||||
Matej Vela mvela@public.srce.hr
|
||||
Matt Kraai kraai@ftbfs.org
|
||||
Matt Perry matt@primefactor.com
|
||||
Matt Pham mattvpham@gmail.com
|
||||
Matt Schalit mschalit@pacbell.net
|
||||
Matt Swift swift@alum.mit.edu
|
||||
Matthew Arnison maffew@cat.org.au
|
||||
@@ -367,6 +381,7 @@ Matthew Woehlke mw_triad@users.sourceforge.net
|
||||
Matthias Urlichs smurf@noris.de
|
||||
Matti Aarnio matti.aarnio@zmailer.org
|
||||
Mattias Wadenstein maswan@acc.umu.se
|
||||
Max Chang maxchang@ucla.edu
|
||||
Meelis Roos mroos@tartu.cyber.ee
|
||||
Michael michael@aplatform.com
|
||||
Michael ??? michael@roka.net
|
||||
@@ -390,6 +405,7 @@ Michal Politowski mpol@charybda.icm.edu.pl
|
||||
Michal Svec msvec@suse.cz
|
||||
Michel Robitaille robitail@IRO.UMontreal.CA
|
||||
Michiel Bacchiani bacchian@raven.bu.edu
|
||||
Mikael Magnusson mikachu@gmail.com
|
||||
Mike Castle dalgoda@ix.netcom.com
|
||||
Mike Coleman mkc@mathdogs.com
|
||||
Mike Jetzer mjetzer@mke.catalystwms.com
|
||||
@@ -403,11 +419,13 @@ Neal H Walfield neal@cs.uml.edu
|
||||
Neil Brown neilb@cse.unsw.edu.au
|
||||
Nelson H. F. Beebe beebe@math.utah.edu
|
||||
Nick Estes debian@nickstoys.com
|
||||
Nick Graham nick.d.graham@gmail.com
|
||||
Nick Lawes nlawes@silverplatter.com
|
||||
Nickolai Zeldovich nickolai@cs.stanford.edu
|
||||
Nicolas François nicolas.francois@centraliens.net
|
||||
Niklas Edmundsson nikke@acc.umu.se
|
||||
Nikola Milutinovic Nikola.Milutinovic@ev.co.yu
|
||||
Nima Nikzad nnikzad@ucla.edu
|
||||
Noah Friedman friedman@splode.com
|
||||
Noel Cragg noel@red-bean.com
|
||||
Norbert Kiesel nkiesel@tbdnetworks.com
|
||||
@@ -419,6 +437,7 @@ Oliver Kiddle okiddle@yahoo.co.uk
|
||||
Oskar Liljeblad osk@hem.passagen.se
|
||||
Pádraig Brady P@draigBrady.com
|
||||
Patrick Mauritz oxygene@studentenbude.ath.cx
|
||||
Paul D. Smith psmith@gnu.org
|
||||
Paul Eggert eggert@twinsun.com
|
||||
Paul Ghaleb paul.ghaleb@st.com
|
||||
Paul Jarc prj@po.cwru.edu
|
||||
@@ -440,6 +459,7 @@ Peter Moulder reiter@netspace.net.au
|
||||
Peter O'Gorman bug-coreutils@mlists.thewrittenword.com
|
||||
Peter Samuelson psamuels@sampo.creighton.edu
|
||||
Peter Seebach seebs@taniemarie.solon.com
|
||||
Petr Uzel petr.uzel@suse.cz
|
||||
Petter Reinholdtsen pere@hungry.com
|
||||
Phelippe Neveu pneveu@pcigeomatics.com
|
||||
Phil Richards phil.richards@vf.vodafone.co.uk
|
||||
@@ -479,6 +499,7 @@ Ross Alexander r.alexander@auckland.ac.nz
|
||||
Ross Paterson rap@doc.ic.ac.uk
|
||||
Ross Ridge rridge@calum.csclub.uwaterloo.ca
|
||||
Rudolf Kastl rkastl@redhat.com
|
||||
Sahil Amoli sahilamoli@gmail.com
|
||||
Sami Farin sfarin@ratol.fi
|
||||
Samuel Tardieu sam@rfc1149.net
|
||||
Samuel Thibault samuel.thibault@ens-lyon.org
|
||||
@@ -505,6 +526,7 @@ Steven G. Johnson stevenj@alum.mit.edu
|
||||
Steven Mocking ufo@quicknet.nl
|
||||
Steven P Watson steven@magelico.net
|
||||
Stuart Kemp skemp@peter.bmc.com
|
||||
Stuart Shelton stuart@shelton.me
|
||||
Sven Joachim svenjoac@gmx.de
|
||||
Szakacsits Szabolcs szaka@sienet.hu
|
||||
Tadayoshi Funaba tadf@kt.rim.or.jp
|
||||
@@ -525,6 +547,7 @@ Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu
|
||||
Tim Ryan Tim_Ryan@bnz.co.nz
|
||||
Tim Smithers mouse@dmouse.com.au
|
||||
Tim Waugh twaugh@redhat
|
||||
Tobias Stoeckmann tobias@bugol.de
|
||||
Toby Peterson toby@opendarwin.org
|
||||
Todd A. Jacobs tjacobs@codegnome.org
|
||||
Tom Haynes thomas@netapp.com
|
||||
@@ -541,6 +564,7 @@ Torbjorn Granlund tege@nada.kth.se
|
||||
Torbjorn Lindgren tl@funcom.no
|
||||
Torsten Landschoff torsten@pclab.ifg.uni-kiel.de
|
||||
Tristan Miller psychonaut@nothingisreal.com
|
||||
Tzvi Rotshtein tzvi.ro@gmail.com
|
||||
Ulrich Drepper drepper@gnu.org
|
||||
Ulrich Hermisson ulrich_hermisson@hotmail.com
|
||||
Urs Thuermann urs@isnogud.escape.de
|
||||
@@ -548,7 +572,9 @@ Uwe H. Steinfeld usteinfeld@gmx.net
|
||||
Vesselin Atanasov vesselin@bgnet.bg
|
||||
Vin Shelton acs@alumni.princeton.edu
|
||||
Vineet Chadha chadha@acis.ufl.edu
|
||||
Vitali Lovich vlovich@gmail.com
|
||||
Vitaly A. Ostanin vyt@altlinux.org
|
||||
Vito Caputo vcaputo@pengaru.com
|
||||
Vlada Macek tuttle@bbs.fsik.cvut.cz
|
||||
Volker Borchert bt@teknon.de
|
||||
Volker Paul vpaul@dohle.com
|
||||
|
||||
7
TODO
7
TODO
@@ -12,8 +12,6 @@ Modify chmod so that it does not change an inode's st_ctime
|
||||
Discussed more recently on <http://bugs.debian.org/497514>.
|
||||
|
||||
document the following in coreutils.texi:
|
||||
runcon
|
||||
chcon
|
||||
mktemp
|
||||
[
|
||||
pinky
|
||||
@@ -104,6 +102,9 @@ sort: Investigate better sorting algorithms; see Knuth vol. 3.
|
||||
5.3.1, who credits Lester Ford, Jr. and Selmer Johnson, American
|
||||
Mathematical Monthly 66 (1959), 387-389.
|
||||
|
||||
shred: Update shred as described here to conform to DoD 5220 rules:
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2007-05/msg00075.html
|
||||
|
||||
Remove suspicious uses of alloca (ones that may allocate more than
|
||||
about 4k)
|
||||
|
||||
@@ -170,7 +171,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2009 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
|
||||
|
||||
144
bootstrap
144
bootstrap
@@ -2,7 +2,7 @@
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
# Copyright (C) 2003-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2009 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
|
||||
@@ -52,6 +52,9 @@ Options:
|
||||
If the file $0.conf exists in the same directory as this script, its
|
||||
contents are read as shell variables to configure the bootstrap.
|
||||
|
||||
For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
|
||||
are honored.
|
||||
|
||||
Running without arguments will suffice in most cases.
|
||||
"
|
||||
}
|
||||
@@ -195,7 +198,7 @@ insert_sorted_if_absent() {
|
||||
file=$1
|
||||
str=$2
|
||||
test -f $file || touch $file
|
||||
echo "$str" | sort -u - $file | cmp -s - $file \
|
||||
echo "$str" | sort -u - $file | cmp - $file > /dev/null \
|
||||
|| echo "$str" | sort -u - $file -o $file \
|
||||
|| exit 1
|
||||
}
|
||||
@@ -222,6 +225,100 @@ if test ! -d $build_aux; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Note this deviates from the version comparison in automake
|
||||
# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
|
||||
# but this should suffice as we won't be specifying old
|
||||
# version formats or redundant trailing .0 in bootstrap.conf.
|
||||
# If we did want full compatibility then we should probably
|
||||
# use m4_version_compare from autoconf.
|
||||
sort_ver() { #sort -V is not generally available
|
||||
ver1="$1"
|
||||
ver2="$2"
|
||||
|
||||
#split on '.' and compare each component
|
||||
i=1
|
||||
while : ; do
|
||||
p1=$(echo "$ver1" | cut -d. -f$i)
|
||||
p2=$(echo "$ver2" | cut -d. -f$i)
|
||||
if [ ! "$p1" ]; then
|
||||
echo "$1 $2"
|
||||
break
|
||||
elif [ ! "$p2" ]; then
|
||||
echo "$2 $1"
|
||||
break
|
||||
elif [ ! "$p1" = "$p2" ]; then
|
||||
if [ "$p1" -gt "$p2" ] 2>/dev/null; then #numeric comparision
|
||||
echo "$2 $1"
|
||||
elif [ "$p2" -gt "$p1" ] 2>/dev/null; then #numeric comparision
|
||||
echo "$1 $2"
|
||||
else #numeric, then lexographic comparison
|
||||
lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
|
||||
if [ "$lp" = "$p2" ]; then
|
||||
echo "$1 $2"
|
||||
else
|
||||
echo "$2 $1"
|
||||
fi
|
||||
fi
|
||||
break
|
||||
fi
|
||||
i=$(($i+1))
|
||||
done
|
||||
}
|
||||
|
||||
get_version() {
|
||||
app=$1
|
||||
|
||||
$app --version >/dev/null 2>&1 || return 1
|
||||
|
||||
$app --version 2>&1 |
|
||||
sed -n 's/[^0-9.]*\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/p
|
||||
t done
|
||||
d
|
||||
:done
|
||||
q'
|
||||
}
|
||||
|
||||
check_versions() {
|
||||
ret=0
|
||||
|
||||
while read app req_ver; do
|
||||
# Honor $APP variables ($TAR, $AUTOCONF, etc.)
|
||||
appvar=`echo $app | tr '[a-z]' '[A-Z]'`
|
||||
test "$appvar" = TAR && appvar=AMTAR
|
||||
eval "app=\${$appvar-$app}"
|
||||
inst_ver=$(get_version $app)
|
||||
if [ ! "$inst_ver" ]; then
|
||||
echo "Error: '$app' not found" >&2
|
||||
ret=1
|
||||
elif [ ! "$req_ver" = "-" ]; then
|
||||
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
|
||||
if [ ! "$latest_ver" = "$inst_ver" ]; then
|
||||
echo "Error: '$app' version == $inst_ver is too old" >&2
|
||||
echo " '$app' version >= $req_ver is required" >&2
|
||||
ret=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
print_versions() {
|
||||
echo "Program Min_version"
|
||||
echo "----------------------"
|
||||
printf "$buildreq"
|
||||
echo "----------------------"
|
||||
#can't depend on column -t
|
||||
}
|
||||
|
||||
if ! printf "$buildreq" | check_versions; then
|
||||
test -f README-prereq &&
|
||||
echo "Please see README-prereq for notes on obtaining these prerequisite programs:" >&2
|
||||
echo
|
||||
print_versions
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$0: Bootstrapping from checked-out $package sources..."
|
||||
|
||||
# See if we can use gnulib's git-merge-changelog merge driver.
|
||||
@@ -245,7 +342,7 @@ cleanup_gnulib() {
|
||||
}
|
||||
|
||||
git_modules_config () {
|
||||
GIT_CONFIG_LOCAL=.gitmodules git config "$@"
|
||||
GIT_CONFIG=.gitmodules git config "$@"
|
||||
}
|
||||
|
||||
# Get gnulib files.
|
||||
@@ -262,7 +359,8 @@ case ${GNULIB_SRCDIR--} in
|
||||
|
||||
trap cleanup_gnulib 1 2 13 15
|
||||
|
||||
git clone --depth 2 git://git.sv.gnu.org/gnulib ||
|
||||
git clone --help|grep depth > /dev/null && depth='--depth 2' || depth=
|
||||
git clone $depth git://git.sv.gnu.org/gnulib ||
|
||||
cleanup_gnulib
|
||||
|
||||
trap - 1 2 13 15
|
||||
@@ -322,9 +420,9 @@ update_po_files() {
|
||||
cksum_file="$ref_po_dir/$po.s1"
|
||||
if ! test -f "$cksum_file" ||
|
||||
! test -f "$po_dir/$po.po" ||
|
||||
! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then
|
||||
! ${SHA1SUM-sha1sum} -c --status "$cksum_file" < "$new_po" > /dev/null; then
|
||||
echo "updated $po_dir/$po.po..."
|
||||
cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
|
||||
cp "$new_po" "$po_dir/$po.po" && ${SHA1SUM-sha1sum} < "$new_po" > "$cksum_file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -487,7 +585,7 @@ slurp() {
|
||||
if test $file = Makefile.am; then
|
||||
copied=$copied${sep}$gnulib_mk; sep=$nl
|
||||
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
|
||||
sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
|
||||
sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || {
|
||||
echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
|
||||
rm -f $dir/$gnulib_mk &&
|
||||
sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
|
||||
@@ -569,9 +667,9 @@ grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
|
||||
with_gettext=no
|
||||
|
||||
if test $with_gettext = yes; then
|
||||
echo "$0: (cd $bt2; autopoint) ..."
|
||||
echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
|
||||
cp configure.ac $bt2 &&
|
||||
(cd $bt2 && autopoint && rm configure.ac) &&
|
||||
(cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
|
||||
slurp $bt2 $bt || exit
|
||||
fi
|
||||
rm -fr $bt $bt2 || exit
|
||||
@@ -588,19 +686,33 @@ find "$m4_base" "$source_base" \
|
||||
-depth \( -name '*.m4' -o -name '*.[ch]' \) \
|
||||
-type l -xtype l -delete > /dev/null 2>&1
|
||||
|
||||
# Use automake's --silent-rules option, if possible.
|
||||
automake="${AUTOMAKE-automake} --add-missing --copy --force-missing"
|
||||
(${AUTOMAKE-automake} --help) 2>&1 \
|
||||
| grep -e '^ *--silent-rules' > /dev/null \
|
||||
&& automake="$automake --silent-rules"
|
||||
|
||||
# Reconfigure, getting other files.
|
||||
|
||||
for command in \
|
||||
libtool \
|
||||
'aclocal --force -I m4' \
|
||||
'autoconf --force' \
|
||||
'autoheader --force' \
|
||||
'automake --add-missing --copy --force-missing';
|
||||
"${ACLOCAL-aclocal} --force -I m4" \
|
||||
"${AUTOCONF-autoconf} --force" \
|
||||
"${AUTOHEADER-autoheader} --force" \
|
||||
"$automake"
|
||||
do
|
||||
if test "$command" = libtool; then
|
||||
grep '^[ ]*AM_PROG_LIBTOOL\>' configure.ac >/dev/null ||
|
||||
continue
|
||||
command='libtoolize -c -f'
|
||||
use_libtool=0
|
||||
# We'd like to use grep -E, to see if any of LT_INIT,
|
||||
# AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
|
||||
# but that's not portable enough (e.g., for Solaris).
|
||||
grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
|
||||
&& use_libtool=1
|
||||
grep '^[ ]*LT_INIT' configure.ac >/dev/null \
|
||||
&& use_libtool=1
|
||||
test $use_libtool = 0 \
|
||||
&& continue
|
||||
command="${LIBTOOLIZE-libtoolize} -c -f"
|
||||
fi
|
||||
echo "$0: $command ..."
|
||||
$command || exit
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bootstrap configuration.
|
||||
|
||||
# Copyright (C) 2006-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2009 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -16,11 +16,11 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
# We don't need these modules, even though gnulib-tool mistakenly
|
||||
# includes them because of gettext and fchdir dependencies.
|
||||
# We don't need these modules.
|
||||
avoided_gnulib_modules='
|
||||
--avoid=lock
|
||||
--avoid=canonicalize-lgpl
|
||||
--avoid=dummy
|
||||
--avoid=lock
|
||||
'
|
||||
|
||||
# These modules are obsolete and can probably be removed soon,
|
||||
@@ -34,7 +34,9 @@ obsolete_gnulib_modules='
|
||||
gnulib_modules="
|
||||
$avoided_gnulib_modules
|
||||
$obsolete_gnulib_modules
|
||||
acl alloca announce-gen argmatch assert
|
||||
acl alloca announce-gen argmatch
|
||||
argv-iter
|
||||
assert
|
||||
autobuild
|
||||
backupfile base64
|
||||
c-strcase c-strtod
|
||||
@@ -55,15 +57,21 @@ gnulib_modules="
|
||||
fsusage ftruncate
|
||||
ftello
|
||||
fts getdate getgroups gethrxtime
|
||||
gendocs
|
||||
getline getloadavg getndelim2 getopt getpagesize getpass-gnu
|
||||
gettext gettime gettimeofday getugroups getusershell
|
||||
git-version-gen
|
||||
gitlog-to-changelog
|
||||
gnu-make gnumakefile gnupload
|
||||
group-member hard-locale hash hash-pjw host-os human idcache
|
||||
ignore-value
|
||||
inttostr inttypes isapipe
|
||||
lchmod lchown lib-ignore linebuffer link-follow
|
||||
long-options lstat malloc mbswidth memcasecmp mempcpy
|
||||
long-options lstat malloc
|
||||
manywarnings
|
||||
mbrtowc
|
||||
mbswidth
|
||||
memcasecmp memcmp2 mempcpy
|
||||
memrchr mgetgroups
|
||||
mkancesdirs mkdir mkdir-p mkstemp mktime modechange
|
||||
mountlist mpsort obstack pathmax perl physmem
|
||||
@@ -84,9 +92,10 @@ gnulib_modules="
|
||||
safe-read same
|
||||
save-cwd savedir savewd
|
||||
selinux-at
|
||||
settime sig2str ssize_t stat-macros
|
||||
settime sig2str sigaction ssize_t stat-macros
|
||||
stat-time stdbool stdlib-safer stpcpy
|
||||
stpncpy
|
||||
strdup
|
||||
strftime
|
||||
strpbrk strtoimax strtoumax strverscmp sys_stat timespec tzset
|
||||
unicodeio unistd-safer unlink-busy unlinkdir unlocked-io
|
||||
@@ -95,9 +104,12 @@ gnulib_modules="
|
||||
userspec utimecmp utimens
|
||||
vasprintf-posix
|
||||
vc-list-files
|
||||
verify version-etc-fsf
|
||||
verify version-etc-fsf verror
|
||||
warnings
|
||||
wcwidth winsz-ioctl winsz-termios write-any-file
|
||||
xalloc xgetcwd xgethostname
|
||||
xalloc
|
||||
xfreopen
|
||||
xgetcwd xgethostname
|
||||
xmemcoll xnanosleep
|
||||
xprintf
|
||||
xprintf-posix
|
||||
@@ -110,17 +122,19 @@ EXTRA_LOCALE_CATEGORIES=LC_TIME
|
||||
|
||||
# Additional xgettext options to use. Use "\\\newline" to break lines.
|
||||
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||
--from-code=UTF-8\\\
|
||||
--flag=asprintf:2:c-format\\\
|
||||
--flag=asnprintf:3:c-format\\\
|
||||
--flag=asprintf:2:c-format\\\
|
||||
--flag=error:3:c-format\\\
|
||||
--flag=error_at_line:5:c-format\\\
|
||||
--flag=vasprintf:2:c-format\\\
|
||||
--flag=vasnprintf:3:c-format\\\
|
||||
--flag=vasprintf:2:c-format\\\
|
||||
--flag=verror:3:c-format\\\
|
||||
--flag=verror_at_line:5:c-format\\\
|
||||
--flag=wrapf:1:c-format\\\
|
||||
--flag=xasprintf:1:c-format\\\
|
||||
--flag=xfprintf:2:c-format\\\
|
||||
--flag=xprintf:1:c-format\\\
|
||||
--from-code=UTF-8\\\
|
||||
'
|
||||
|
||||
# Append these, since we use the propername module.
|
||||
@@ -160,5 +174,21 @@ fi
|
||||
|
||||
gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
|
||||
|
||||
# Build prerequisites
|
||||
buildreq="\
|
||||
autoconf 2.61
|
||||
automake 1.10a
|
||||
autopoint -
|
||||
bison -
|
||||
gettext -
|
||||
git 1.4.4
|
||||
gperf -
|
||||
gzip -
|
||||
makeinfo -
|
||||
perl 5.5
|
||||
rsync -
|
||||
tar -
|
||||
"
|
||||
|
||||
# Automake requires that ChangeLog exist.
|
||||
touch ChangeLog
|
||||
|
||||
@@ -213,8 +213,8 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
|
||||
for f in $(TEST_LOGS); \
|
||||
do \
|
||||
case $$(sed 1q $$f) in \
|
||||
SKIP:*|PASS:*|XFAIL:*);; \
|
||||
*) echo; cat $$f;; \
|
||||
SKIP:*|PASS:*|XFAIL:*);; \
|
||||
*) echo; cat $$f;; \
|
||||
esac; \
|
||||
done; \
|
||||
} >$(TEST_SUITE_LOG).tmp; \
|
||||
|
||||
156
cfg.mk
156
cfg.mk
@@ -1,5 +1,5 @@
|
||||
# Customize maint.mk -*- makefile -*-
|
||||
# Copyright (C) 2003-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2009 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -21,6 +21,9 @@ gnu_ftp_host-beta = alpha.gnu.org
|
||||
gnu_ftp_host-major = ftp.gnu.org
|
||||
gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
|
||||
|
||||
# Used in maint.mk's web-manual rule
|
||||
manual_title = Core GNU utilities
|
||||
|
||||
url_dir_list = \
|
||||
ftp://$(gnu_rel_host)/gnu/coreutils
|
||||
|
||||
@@ -42,4 +45,153 @@ gnulib_dir = /gnulib
|
||||
# Now that we have better (check.mk) tests, make this the default.
|
||||
export VERBOSE = yes
|
||||
|
||||
old_NEWS_hash = 95fc7a26fa253d57cabe4b058167a4f9 -
|
||||
old_NEWS_hash = fa6cba1740b3f385520c1b54d90859ca
|
||||
|
||||
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
|
||||
dd = $(srcdir)/src/dd.c
|
||||
sc_dd_O_FLAGS:
|
||||
@rm -f $@.1 $@.2
|
||||
@{ echo O_FULLBLOCK; perl -nle '/^ +\| (O_\w*)$$/ and print $$1' \
|
||||
$(dd); } | sort > $@.1
|
||||
@{ echo O_NOFOLLOW; perl -nle '/{"[a-z]+",\s*(O_\w+)},/ and print $$1' \
|
||||
$(dd); } | sort > $@.2
|
||||
@diff -u $@.1 $@.2 || diff=1 || diff=; \
|
||||
rm -f $@.1 $@.2; \
|
||||
test "$$diff" \
|
||||
&& { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Ensure that dd's definition of LONGEST_SYMBOL stays in sync
|
||||
# with the strings from the two affected variables.
|
||||
dd_c = $(srcdir)/src/dd.c
|
||||
sc_dd_max_sym_length:
|
||||
ifneq ($(wildcard $(dd_c)),)
|
||||
@len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
|
||||
sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
|
||||
|sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
|
||||
| wc --max-line-length); \
|
||||
max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
|
||||
|tr -d '"' | wc --max-line-length); \
|
||||
if test "$$len" = "$$max"; then :; else \
|
||||
echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
endif
|
||||
|
||||
# Many m4 macros names once began with `jm_'.
|
||||
# On 2004-04-13, they were all changed to start with gl_ instead.
|
||||
# Make sure that none are inadvertently reintroduced.
|
||||
sc_prohibit_jm_in_m4:
|
||||
@grep -nE 'jm_[A-Z]' \
|
||||
$$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
|
||||
{ echo '$(ME): do not use jm_ in m4 macro names' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Ensure that each root-requiring test is run via the "check-root" rule.
|
||||
sc_root_tests:
|
||||
@if test -d tests \
|
||||
&& grep check-root tests/Makefile.am>/dev/null 2>&1; then \
|
||||
t1=sc-root.expected; t2=sc-root.actual; \
|
||||
grep -nl '^require_root_$$' \
|
||||
$$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1; \
|
||||
sed -n '/^root_tests =[ ]*\\$$/,/[^\]$$/p' \
|
||||
$(srcdir)/tests/Makefile.am \
|
||||
| sed 's/^ *//;/^root_tests =/d' \
|
||||
| tr -s '\012\\' ' ' | fmt -1 | sort > $$t2; \
|
||||
diff -u $$t1 $$t2 || diff=1 || diff=; \
|
||||
rm -f $$t1 $$t2; \
|
||||
test "$$diff" \
|
||||
&& { echo 'tests/Makefile.am: missing check-root action'>&2; \
|
||||
exit 1; } || :; \
|
||||
fi
|
||||
|
||||
headers_with_interesting_macro_defs = \
|
||||
exit.h \
|
||||
fcntl_.h \
|
||||
fnmatch_.h \
|
||||
intprops.h \
|
||||
inttypes_.h \
|
||||
lchown.h \
|
||||
openat.h \
|
||||
stat-macros.h \
|
||||
stdint_.h
|
||||
|
||||
# Create a list of regular expressions matching the names
|
||||
# of macros that are guaranteed by parts of gnulib to be defined.
|
||||
.re-defmac:
|
||||
@(cd $(srcdir)/lib; \
|
||||
for f in $(headers_with_interesting_macro_defs); do \
|
||||
test -f $$f && \
|
||||
sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
|
||||
done; \
|
||||
) | sort -u \
|
||||
| grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
|
||||
| sed 's/^/^# *define /' \
|
||||
> $@-t
|
||||
@mv $@-t $@
|
||||
|
||||
# Don't define macros that we already get from gnulib header files.
|
||||
sc_always_defined_macros: .re-defmac
|
||||
@if test -f $(srcdir)/src/system.h; then \
|
||||
trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
|
||||
grep -f .re-defmac $$($(VC_LIST)) \
|
||||
&& { echo '$(ME): define the above via some gnulib .h file' \
|
||||
1>&2; exit 1; } || :; \
|
||||
fi
|
||||
|
||||
# Create a list of regular expressions matching the names
|
||||
# of files included from system.h. Exclude a couple.
|
||||
.re-list:
|
||||
@sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
|
||||
| grep -Ev 'sys/(param|file)\.h' \
|
||||
| sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
|
||||
> $@-t
|
||||
@mv $@-t $@
|
||||
|
||||
# Files in src/ should not include directly any of
|
||||
# the headers already included via system.h.
|
||||
sc_system_h_headers: .re-list
|
||||
@if test -f $(srcdir)/src/system.h; then \
|
||||
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
|
||||
grep -nE -f .re-list \
|
||||
$$($(VC_LIST) src | \
|
||||
grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
|
||||
&& { echo '$(ME): the above are already included via system.h'\
|
||||
1>&2; exit 1; } || :; \
|
||||
fi
|
||||
|
||||
sc_sun_os_names:
|
||||
@grep -nEi \
|
||||
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_tight_scope:
|
||||
@$(MAKE) -C src $@
|
||||
|
||||
# Perl-based tests used to exec perl from a #!/bin/sh script.
|
||||
# Now they all start with #!/usr/bin/perl and the portability
|
||||
# infrastructure is in tests/Makefile.am. Make sure no old-style
|
||||
# script sneaks back in.
|
||||
sc_no_exec_perl_coreutils:
|
||||
@if test -f $(srcdir)/tests/Coreutils.pm; then \
|
||||
grep '^exec *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) && \
|
||||
{ echo 1>&2 '$(ME): found anachronistic Perl-based tests'; \
|
||||
exit 1; } || :; \
|
||||
fi
|
||||
|
||||
# Ensure that date's --help output stays in sync with the info
|
||||
# documentation for GNU strftime. The only exception is %N,
|
||||
# which date accepts but GNU strftime does not.
|
||||
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
|
||||
sc_strftime_check:
|
||||
@if test -f $(srcdir)/src/date.c; then \
|
||||
grep '^ %. ' $(srcdir)/src/date.c | sort \
|
||||
| $(extract_char) > $@-src; \
|
||||
{ echo N; \
|
||||
info libc date calendar format | grep '^ `%.'\' \
|
||||
| $(extract_char); } | sort > $@-info; \
|
||||
diff -u $@-src $@-info || exit 1; \
|
||||
rm -f $@-src $@-info; \
|
||||
fi
|
||||
|
||||
140
configure.ac
140
configure.ac
@@ -1,7 +1,7 @@
|
||||
# -*- autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1991, 1993-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991, 1993-2009 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
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
dnl Written by Jim Meyering.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_PREREQ([2.61])
|
||||
|
||||
# Make inter-release version strings look like, e.g., v6.9-219-g58ddd, which
|
||||
# indicates that it is built from the 219th delta (in _some_ repository)
|
||||
@@ -27,12 +27,12 @@ AC_INIT([GNU coreutils],
|
||||
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
||||
[bug-coreutils@gnu.org])
|
||||
|
||||
AC_CONFIG_SRCDIR(src/ls.c)
|
||||
AC_CONFIG_SRCDIR([src/ls.c])
|
||||
|
||||
AC_CONFIG_AUX_DIR(build-aux)
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
|
||||
|
||||
AM_INIT_AUTOMAKE([1.10a dist-lzma])
|
||||
AM_INIT_AUTOMAKE([1.10a dist-xz])
|
||||
|
||||
AC_PROG_CC_STDC
|
||||
AM_PROG_CC_C_O
|
||||
@@ -44,20 +44,82 @@ gl_EARLY
|
||||
gl_INIT
|
||||
coreutils_MACROS
|
||||
|
||||
AC_ARG_ENABLE([gcc-warnings],
|
||||
[AS_HELP_STRING([--enable-gcc-warnings],
|
||||
[turn on lots of GCC warnings (for developers)])],
|
||||
[case $enableval in
|
||||
yes|no) ;;
|
||||
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
|
||||
esac
|
||||
gl_gcc_warnings=$enableval],
|
||||
[gl_gcc_warnings=no]
|
||||
)
|
||||
|
||||
if test "$gl_gcc_warnings" = yes; then
|
||||
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
|
||||
AC_SUBST([WERROR_CFLAGS])
|
||||
|
||||
# Add many warnings, except some...
|
||||
nw="$nw -Wdeclaration-after-statement" # too useful to forbid
|
||||
nw="$nw -Waggregate-return" # anachronistic
|
||||
nw="$nw -Wc++-compat" # We don't care about C++ compilers
|
||||
nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
|
||||
nw="$nw -Wtraditional" # Warns on #elif which we use often
|
||||
nw="$nw -Wcast-qual" # Too many warnings for now
|
||||
nw="$nw -Wconversion" # Too many warnings for now
|
||||
nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
|
||||
nw="$nw -Wsign-conversion" # Too many warnings for now
|
||||
nw="$nw -Wtraditional-conversion" # Too many warnings for now
|
||||
nw="$nw -Wunreachable-code" # Too many warnings for now
|
||||
nw="$nw -Wpadded" # Our structs are not padded
|
||||
nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
|
||||
nw="$nw -Wlogical-op" # any use of fwrite provokes this
|
||||
nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
|
||||
nw="$nw -Wvla" # warnings in gettext.h
|
||||
nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
|
||||
nw="$nw -Wswitch-enum" # Too many warnings for now
|
||||
nw="$nw -Wswitch-default" # Too many warnings for now
|
||||
# things I might fix soon:
|
||||
nw="$nw -Wfloat-equal" # sort.c, seq.c
|
||||
nw="$nw -Wmissing-format-attribute" # copy.c
|
||||
nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
|
||||
nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
|
||||
nw="$nw -Wstrict-overflow" # expr.c, pr.c, tr.c, factor.c
|
||||
# ?? -Wstrict-overflow
|
||||
|
||||
gl_MANYWARN_ALL_GCC([ws])
|
||||
gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
|
||||
for w in $ws; do
|
||||
gl_WARN_ADD([$w])
|
||||
done
|
||||
gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
|
||||
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
|
||||
gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now
|
||||
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
|
||||
gl_WARN_ADD([-fdiagnostics-show-option])
|
||||
|
||||
AC_SUBST([WARN_CFLAGS])
|
||||
|
||||
AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
|
||||
AC_DEFINE([_FORTIFY_SOURCE], [2],
|
||||
[enable compile-time and run-time bounds-checking, and some warnings])
|
||||
AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
|
||||
fi
|
||||
|
||||
AC_FUNC_FORK
|
||||
|
||||
optional_bin_progs=
|
||||
AC_CHECK_FUNCS(uname,
|
||||
AC_CHECK_FUNCS([uname],
|
||||
gl_ADD_PROG([optional_bin_progs], [uname]))
|
||||
AC_CHECK_FUNCS(chroot,
|
||||
AC_CHECK_FUNCS([chroot],
|
||||
gl_ADD_PROG([optional_bin_progs], [chroot]))
|
||||
AC_CHECK_FUNCS(gethostid,
|
||||
AC_CHECK_FUNCS([gethostid],
|
||||
gl_ADD_PROG([optional_bin_progs], [hostid]))
|
||||
|
||||
gl_WINSIZE_IN_PTEM
|
||||
|
||||
AC_MSG_CHECKING(whether localtime caches TZ)
|
||||
AC_CACHE_VAL(utils_cv_localtime_cache,
|
||||
AC_MSG_CHECKING([whether localtime caches TZ])
|
||||
AC_CACHE_VAL([utils_cv_localtime_cache],
|
||||
[if test x$ac_cv_func_tzset = xyes; then
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
|
||||
#if STDC_HEADERS
|
||||
@@ -98,22 +160,22 @@ else
|
||||
# since we can't invalidate the cache if we don't have tzset.
|
||||
utils_cv_localtime_cache=no
|
||||
fi])dnl
|
||||
AC_MSG_RESULT($utils_cv_localtime_cache)
|
||||
AC_MSG_RESULT([$utils_cv_localtime_cache])
|
||||
if test $utils_cv_localtime_cache = yes; then
|
||||
AC_DEFINE(LOCALTIME_CACHE, 1, [FIXME])
|
||||
AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
|
||||
fi
|
||||
|
||||
# SCO-ODT-3.0 is reported to need -los to link programs using initgroups
|
||||
AC_CHECK_FUNCS(initgroups)
|
||||
AC_CHECK_FUNCS([initgroups])
|
||||
if test $ac_cv_func_initgroups = no; then
|
||||
AC_CHECK_LIB(os, initgroups)
|
||||
AC_CHECK_LIB([os], [initgroups])
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(syslog)
|
||||
AC_CHECK_FUNCS([syslog])
|
||||
if test $ac_cv_func_syslog = no; then
|
||||
# syslog is not in the default libraries. See if it's in some other.
|
||||
for lib in bsd socket inet; do
|
||||
AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG, 1, [FIXME])
|
||||
AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
|
||||
LIBS="$LIBS -l$lib"; break])
|
||||
done
|
||||
fi
|
||||
@@ -147,29 +209,29 @@ AC_DEFUN([coreutils_DUMMY_1],
|
||||
])
|
||||
coreutils_DUMMY_1
|
||||
|
||||
AC_MSG_CHECKING(ut_host in struct utmp)
|
||||
AC_CACHE_VAL(su_cv_func_ut_host_in_utmp,
|
||||
AC_MSG_CHECKING([ut_host in struct utmp])
|
||||
AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||
#include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
|
||||
[su_cv_func_ut_host_in_utmp=yes],
|
||||
[su_cv_func_ut_host_in_utmp=no])])
|
||||
AC_MSG_RESULT($su_cv_func_ut_host_in_utmp)
|
||||
AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
|
||||
if test $su_cv_func_ut_host_in_utmp = yes; then
|
||||
have_ut_host=1
|
||||
AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
|
||||
AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
|
||||
fi
|
||||
|
||||
if test -z "$have_ut_host"; then
|
||||
AC_MSG_CHECKING(ut_host in struct utmpx)
|
||||
AC_CACHE_VAL(su_cv_func_ut_host_in_utmpx,
|
||||
AC_MSG_CHECKING([ut_host in struct utmpx])
|
||||
AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||
#include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
|
||||
[su_cv_func_ut_host_in_utmpx=yes],
|
||||
[su_cv_func_ut_host_in_utmpx=no])])
|
||||
AC_MSG_RESULT($su_cv_func_ut_host_in_utmpx)
|
||||
AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
|
||||
if test $su_cv_func_ut_host_in_utmpx = yes; then
|
||||
AC_DEFINE(HAVE_UTMPX_H, 1, [FIXME])
|
||||
AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
|
||||
AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
|
||||
AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -181,24 +243,24 @@ gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
|
||||
if test $ac_cv_sys_posix_termios = yes; then
|
||||
gl_ADD_PROG([optional_bin_progs], [stty])
|
||||
|
||||
AC_MSG_CHECKING(whether termios.h needs _XOPEN_SOURCE)
|
||||
AC_CACHE_VAL(su_cv_sys_termios_needs_xopen_source,
|
||||
[AC_EGREP_CPP(yes, [#include <termios.h>
|
||||
AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
|
||||
AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
|
||||
[AC_EGREP_CPP([yes], [#include <termios.h>
|
||||
#ifdef IUCLC
|
||||
yes
|
||||
#endif], su_cv_sys_termios_needs_xopen_source=no,
|
||||
AC_EGREP_CPP(yes, [#define _XOPEN_SOURCE
|
||||
AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
|
||||
#include <termios.h>
|
||||
#ifdef IUCLC
|
||||
yes
|
||||
#endif], su_cv_sys_termios_needs_xopen_source=yes,
|
||||
su_cv_sys_termios_needs_xopen_source=no))])
|
||||
AC_MSG_RESULT($su_cv_sys_termios_needs_xopen_source)
|
||||
AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
|
||||
test $su_cv_sys_termios_needs_xopen_source = yes &&
|
||||
AC_DEFINE(TERMIOS_NEEDS_XOPEN_SOURCE, 1, [FIXME])
|
||||
AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
|
||||
|
||||
AC_MSG_CHECKING(c_line in struct termios)
|
||||
AC_CACHE_VAL(su_cv_sys_c_line_in_termios,
|
||||
AC_MSG_CHECKING([c_line in struct termios])
|
||||
AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE
|
||||
#endif
|
||||
@@ -206,9 +268,9 @@ yes
|
||||
#include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
|
||||
[su_cv_sys_c_line_in_termios=yes],
|
||||
[su_cv_sys_c_line_in_termios=no])])
|
||||
AC_MSG_RESULT($su_cv_sys_c_line_in_termios)
|
||||
AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
|
||||
test $su_cv_sys_c_line_in_termios = yes \
|
||||
&& AC_DEFINE(HAVE_C_LINE, 1, [FIXME])
|
||||
&& AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
|
||||
fi
|
||||
|
||||
# FIXME: note that this macro appears above, too.
|
||||
@@ -219,8 +281,8 @@ gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
|
||||
|
||||
if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
|
||||
test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
|
||||
AC_MSG_CHECKING(TIOCGWINSZ in sys/pty.h)
|
||||
AC_CACHE_VAL(su_cv_sys_tiocgwinsz_in_sys_pty_h,
|
||||
AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
|
||||
AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||
#ifdef WINSIZE_IN_PTEM
|
||||
# include <sys/stream.h>
|
||||
@@ -231,10 +293,10 @@ if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
|
||||
#include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
|
||||
[su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
|
||||
[su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
|
||||
AC_MSG_RESULT($su_cv_sys_tiocgwinsz_in_sys_pty_h)
|
||||
AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
|
||||
|
||||
test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
|
||||
&& AC_DEFINE(GWINSZ_IN_SYS_PTY, 1,
|
||||
&& AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
|
||||
[Define if your system defines TIOCGWINSZ in sys/pty.h.])
|
||||
fi
|
||||
|
||||
|
||||
1
doc/.gitignore
vendored
1
doc/.gitignore
vendored
@@ -16,6 +16,7 @@ coreutils.toc
|
||||
coreutils.tp
|
||||
coreutils.vr
|
||||
fdl.texi
|
||||
gendocs_template
|
||||
getdate.texi
|
||||
stamp-vti
|
||||
version.texi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Make coreutils documentation. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 1995-1998, 2001-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1995-1998, 2001-2009 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
|
||||
@@ -29,10 +29,13 @@ EXTRA_DIST = perm.texi getdate.texi constants.texi fdl.texi
|
||||
# old systems.
|
||||
AM_MAKEINFOFLAGS = --no-split
|
||||
|
||||
constants.texi: $(top_srcdir)/src/tail.c
|
||||
constants.texi: $(top_srcdir)/src/tail.c $(top_srcdir)/src/shred.c
|
||||
LC_ALL=C \
|
||||
sed -n -e 's/^#define \(DEFAULT_MAX[_A-Z]*\) \(.*\)/@set \1 \2/p' \
|
||||
$(top_srcdir)/src/tail.c > t-$@
|
||||
LC_ALL=C \
|
||||
sed -n -e 's/.*\(DEFAULT_PASSES\)[ =]* \([0-9]*\).*/@set SHRED_\1 \2/p'\
|
||||
$(top_srcdir)/src/shred.c >> t-$@
|
||||
mv t-$@ $@
|
||||
|
||||
MAINTAINERCLEANFILES = constants.texi
|
||||
@@ -50,13 +53,14 @@ syntax_checks = \
|
||||
sc-avoid-timezone \
|
||||
sc-avoid-zeroes \
|
||||
sc-exponent-grouping \
|
||||
sc-lower-case-var \
|
||||
sc-use-small-caps-NUL
|
||||
|
||||
.PHONY: $(syntax_checks) check-texinfo
|
||||
|
||||
# List words/regexps here that should not appear in the texinfo documentation.
|
||||
check-texinfo: $(syntax_checks)
|
||||
fail=0; \
|
||||
@fail=0; \
|
||||
grep '@url{' $(srcdir)/*.texi && fail=1; \
|
||||
grep '\$$@"' $(srcdir)/*.texi && fail=1; \
|
||||
grep -n '[^[:punct:]]@footnote' $(srcdir)/*.texi && fail=1; \
|
||||
@@ -73,27 +77,45 @@ check-texinfo: $(syntax_checks)
|
||||
|
||||
# Use `time zone', not `timezone'.
|
||||
sc-avoid-timezone:
|
||||
$(EGREP) timezone $(srcdir)/*.texi && exit 1 || :
|
||||
@$(EGREP) timezone $(srcdir)/*.texi && exit 1 || :
|
||||
|
||||
# Check for insufficient exponent grouping, e.g.,
|
||||
# @math{2^64} should be @math{2^{64}}.
|
||||
sc-exponent-grouping:
|
||||
$(EGREP) '\{.*\^[0-9][0-9]' $(srcdir)/*.texi && exit 1 || :
|
||||
@$(EGREP) '\{.*\^[0-9][0-9]' $(srcdir)/*.texi && exit 1 || :
|
||||
|
||||
# E.g., use @sc{nul}, not NUL.
|
||||
sc-use-small-caps-NUL:
|
||||
$(EGREP) '$(_W)NUL$(W_)' $(srcdir)/*.texi && exit 1 || :
|
||||
@$(EGREP) '$(_W)NUL$(W_)' $(srcdir)/*.texi && exit 1 || :
|
||||
|
||||
# Say I/O, not IO.
|
||||
sc-avoid-io:
|
||||
$(EGREP) '$(_W)IO$(W_)' $(srcdir)/*.texi && exit 1 || :
|
||||
@$(EGREP) '$(_W)IO$(W_)' $(srcdir)/*.texi && exit 1 || :
|
||||
|
||||
# I prefer nonzero over non-zero.
|
||||
sc-avoid-non-zero:
|
||||
$(EGREP) non-zero $(srcdir)/*.texi && exit 1 || :
|
||||
@$(EGREP) non-zero $(srcdir)/*.texi && exit 1 || :
|
||||
|
||||
# Use `zeros', not `zeroes' (nothing wrong with `zeroes'. just be consistent).
|
||||
sc-avoid-zeroes:
|
||||
$(EGREP) -i '$(_W)zeroes$(W_)' $(srcdir)/*.texi && exit 1 || :
|
||||
@$(EGREP) -i '$(_W)zeroes$(W_)' $(srcdir)/*.texi && exit 1 || :
|
||||
|
||||
# ME = $(subdir)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
ME = doc/Makefile
|
||||
|
||||
# The quantity inside @var{...} should not contain upper case letters.
|
||||
# The leading backslash exemption is to permit in-macro uses like
|
||||
# @var{\varName\} where the upper case letter is part of a parameter name.
|
||||
find_upper_case_var = \
|
||||
'/\@var{/ or next; \
|
||||
while (/\@var{(.+?)}/g) \
|
||||
{ \
|
||||
$$v = $$1; \
|
||||
$$v =~ /[A-Z]/ && $$v !~ /^\\/ and (print "$$ARGV:$$.:$$_"), $$m = 1 \
|
||||
} \
|
||||
END {$$m and (warn "$(ME): do not use upper case in \@var{...}\n"), exit 1}'
|
||||
sc-lower-case-var:
|
||||
@$(PERL) -e 1 2> /dev/null && \
|
||||
$(PERL) -lne $(find_upper_case_var) $(srcdir)/*.texi
|
||||
|
||||
check: check-texinfo
|
||||
|
||||
1069
doc/coreutils.texi
1069
doc/coreutils.texi
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
||||
@c File mode bits
|
||||
|
||||
@c Copyright (C) 1994, 1996, 1999, 2000, 2001, 2003, 2004, 2005, 2006
|
||||
@c Copyright (C) 1994, 1996, 1999-2001, 2003-2006, 2008
|
||||
@c Free Software Foundation, Inc.
|
||||
|
||||
@c Permission is granted to copy, distribute and/or modify this document
|
||||
@c under the terms of the GNU Free Documentation License, Version 1.2 or
|
||||
@c under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
@c any later version published by the Free Software Foundation; with no
|
||||
@c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
@c Texts. A copy of the license is included in the ``GNU Free
|
||||
|
||||
117
gl/lib/argv-iter.c
Normal file
117
gl/lib/argv-iter.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/* Iterate over arguments from argv or --files0-from=FILE
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#include <config.h>
|
||||
#include "argv-iter.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct argv_iterator
|
||||
{
|
||||
/* Test FP to determine whether in read-mode or argv-mode. */
|
||||
/* file-mode: fp records position */
|
||||
FILE *fp;
|
||||
size_t item_idx;
|
||||
char *tok;
|
||||
size_t buf_len;
|
||||
|
||||
/* argv-mode: record just argv and current pointer */
|
||||
char **arg_list;
|
||||
char **p;
|
||||
};
|
||||
|
||||
struct argv_iterator *
|
||||
argv_iter_init_argv (char **argv)
|
||||
{
|
||||
struct argv_iterator *ai = malloc (sizeof *ai);
|
||||
if (!ai)
|
||||
return NULL;
|
||||
ai->fp = NULL;
|
||||
ai->arg_list = argv;
|
||||
ai->p = argv;
|
||||
return ai;
|
||||
}
|
||||
|
||||
/* Initialize to read from the stream, FP.
|
||||
The input is expected to contain a list of NUL-delimited tokens. */
|
||||
struct argv_iterator *
|
||||
argv_iter_init_stream (FILE *fp)
|
||||
{
|
||||
struct argv_iterator *ai = malloc (sizeof *ai);
|
||||
if (!ai)
|
||||
return NULL;
|
||||
ai->fp = fp;
|
||||
ai->tok = NULL;
|
||||
ai->buf_len = 0;
|
||||
|
||||
ai->item_idx = 0;
|
||||
ai->arg_list = NULL;
|
||||
return ai;
|
||||
}
|
||||
|
||||
char *
|
||||
argv_iter (struct argv_iterator *ai, enum argv_iter_err *err)
|
||||
{
|
||||
if (ai->fp)
|
||||
{
|
||||
ssize_t len = getdelim (&ai->tok, &ai->buf_len, '\0', ai->fp);
|
||||
if (len < 0)
|
||||
{
|
||||
*err = feof (ai->fp) ? AI_ERR_EOF : AI_ERR_READ;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*err = AI_ERR_OK;
|
||||
ai->item_idx++;
|
||||
return ai->tok;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*(ai->p) == NULL)
|
||||
{
|
||||
*err = AI_ERR_EOF;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
*err = AI_ERR_OK;
|
||||
return *(ai->p++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
argv_iter_n_args (struct argv_iterator const *ai)
|
||||
{
|
||||
return ai->fp ? ai->item_idx : ai->p - ai->arg_list;
|
||||
}
|
||||
|
||||
void
|
||||
argv_iter_free (struct argv_iterator *ai)
|
||||
{
|
||||
if (ai->fp)
|
||||
free (ai->tok);
|
||||
free (ai);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
47
gl/lib/argv-iter.h
Normal file
47
gl/lib/argv-iter.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* Iterate over arguments from argv or --files0-from=FILE
|
||||
Copyright (C) 2008-2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct argv_iterator;
|
||||
enum argv_iter_err;
|
||||
|
||||
#undef _ATTRIBUTE_NONNULL_
|
||||
#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__
|
||||
# define _ATTRIBUTE_NONNULL_(m) __attribute__ ((__nonnull__ (m)))
|
||||
#else
|
||||
# define _ATTRIBUTE_NONNULL_(m)
|
||||
#endif
|
||||
|
||||
enum argv_iter_err
|
||||
{
|
||||
AI_ERR_OK = 1,
|
||||
AI_ERR_EOF,
|
||||
AI_ERR_MEM,
|
||||
AI_ERR_READ
|
||||
};
|
||||
|
||||
struct argv_iterator *argv_iter_init_argv (char **argv)
|
||||
_ATTRIBUTE_NONNULL_ (1);
|
||||
struct argv_iterator *argv_iter_init_stream (FILE *fp)
|
||||
_ATTRIBUTE_NONNULL_ (1);
|
||||
char *argv_iter (struct argv_iterator *, enum argv_iter_err *)
|
||||
_ATTRIBUTE_NONNULL_ (1) _ATTRIBUTE_NONNULL_ (2);
|
||||
size_t argv_iter_n_args (struct argv_iterator const *)
|
||||
_ATTRIBUTE_NONNULL_ (1);
|
||||
void argv_iter_free (struct argv_iterator *)
|
||||
_ATTRIBUTE_NONNULL_ (1);
|
||||
@@ -1,6 +1,6 @@
|
||||
/* mgetgroups.c -- return a list of the groups a user is in
|
||||
|
||||
Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2009 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
|
||||
@@ -33,16 +33,16 @@
|
||||
#include "xalloc.h"
|
||||
|
||||
|
||||
static void *
|
||||
allocate_groupbuf (int size)
|
||||
static GETGROUPS_T *
|
||||
realloc_groupbuf (GETGROUPS_T *g, size_t num)
|
||||
{
|
||||
if (xalloc_oversized (size, sizeof (GETGROUPS_T)))
|
||||
if (xalloc_oversized (num, sizeof (*g)))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return malloc (size * sizeof (GETGROUPS_T));
|
||||
return realloc (g, num * sizeof (*g));
|
||||
}
|
||||
|
||||
/* Like getugroups, but store the result in malloc'd storage.
|
||||
@@ -65,45 +65,27 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
|
||||
performance characteristics.
|
||||
|
||||
In glibc 2.3.2, getgrouplist is buggy. If you pass a zero as the
|
||||
size of the output buffer, getgrouplist will still write to the
|
||||
length of the output buffer, getgrouplist will still write to the
|
||||
buffer. Contrary to what some versions of the getgrouplist
|
||||
manpage say, this doesn't happen with nonzero buffer sizes.
|
||||
Therefore our usage here just avoids a zero sized buffer. */
|
||||
if (username)
|
||||
{
|
||||
enum { N_GROUPS_INIT = 10 };
|
||||
GETGROUPS_T smallbuf[N_GROUPS_INIT];
|
||||
|
||||
max_n_groups = N_GROUPS_INIT;
|
||||
ng = getgrouplist (username, gid, smallbuf, &max_n_groups);
|
||||
|
||||
g = allocate_groupbuf (max_n_groups);
|
||||
g = realloc_groupbuf (NULL, max_n_groups);
|
||||
if (g == NULL)
|
||||
return -1;
|
||||
|
||||
if (max_n_groups <= N_GROUPS_INIT)
|
||||
{
|
||||
/* smallbuf was big enough, so we already have our data */
|
||||
memcpy (g, smallbuf, max_n_groups * sizeof *g);
|
||||
*groups = g;
|
||||
return max_n_groups;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
GETGROUPS_T *h;
|
||||
|
||||
/* getgrouplist updates max_n_groups to num required. */
|
||||
ng = getgrouplist (username, gid, g, &max_n_groups);
|
||||
if (0 <= ng)
|
||||
{
|
||||
*groups = g;
|
||||
return ng;
|
||||
}
|
||||
|
||||
/* When getgrouplist fails, it guarantees that
|
||||
max_n_groups reflects the new number of groups. */
|
||||
|
||||
if (xalloc_oversized (max_n_groups, sizeof *h)
|
||||
|| (h = realloc (g, max_n_groups * sizeof *h)) == NULL)
|
||||
if ((h = realloc_groupbuf (g, max_n_groups)) == NULL)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (g);
|
||||
@@ -111,6 +93,12 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
|
||||
return -1;
|
||||
}
|
||||
g = h;
|
||||
|
||||
if (0 <= ng)
|
||||
{
|
||||
*groups = g;
|
||||
return ng;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* else no username, so fall through and use getgroups. */
|
||||
@@ -125,7 +113,7 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
|
||||
if (max_n_groups < 0)
|
||||
max_n_groups = 5;
|
||||
|
||||
g = allocate_groupbuf (max_n_groups);
|
||||
g = realloc_groupbuf (NULL, max_n_groups);
|
||||
if (g == NULL)
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate buffers of random data.
|
||||
|
||||
Copyright (C) 2006, 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006, 2008-2009 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
|
||||
@@ -43,16 +43,6 @@
|
||||
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
#endif
|
||||
|
||||
#if _STRING_ARCH_unaligned
|
||||
# define ALIGNED_POINTER(ptr, type) true
|
||||
#else
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef SELINUX_CONTEXT_H
|
||||
# define SELINUX_CONTEXT_H
|
||||
|
||||
# include <errno.h>
|
||||
/* Some systems don't have ENOTSUP. */
|
||||
# ifndef ENOTSUP
|
||||
# ifdef ENOSYS
|
||||
# define ENOTSUP ENOSYS
|
||||
# else
|
||||
/* Some systems don't have ENOSYS either. */
|
||||
# define ENOTSUP EINVAL
|
||||
# endif
|
||||
# endif
|
||||
|
||||
typedef int context_t;
|
||||
static inline context_t context_new (char const *s)
|
||||
{ errno = ENOTSUP; return 0; }
|
||||
static inline char *context_str (context_t con)
|
||||
{ errno = ENOTSUP; return (void *) 0; }
|
||||
static inline void context_free (context_t c) {}
|
||||
|
||||
static inline int context_user_set (context_t sc, char const *s)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int context_role_set (context_t sc, char const *s)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int context_range_set (context_t sc, char const *s)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int context_type_set (context_t sc, char const *s)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
|
||||
#endif
|
||||
@@ -1,57 +0,0 @@
|
||||
#ifndef SELINUX_SELINUX_H
|
||||
# define SELINUX_SELINUX_H
|
||||
|
||||
# include <sys/types.h>
|
||||
# include <errno.h>
|
||||
/* Some systems don't have ENOTSUP. */
|
||||
# ifndef ENOTSUP
|
||||
# ifdef ENOSYS
|
||||
# define ENOTSUP ENOSYS
|
||||
# else
|
||||
/* Some systems don't have ENOSYS either. */
|
||||
# define ENOTSUP EINVAL
|
||||
# endif
|
||||
# endif
|
||||
|
||||
typedef unsigned short security_class_t;
|
||||
# define security_context_t char*
|
||||
# define is_selinux_enabled() 0
|
||||
|
||||
static inline int getcon (security_context_t *con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline void freecon (security_context_t con) {}
|
||||
|
||||
|
||||
static inline int getfscreatecon (security_context_t *con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int setfscreatecon (security_context_t con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int matchpathcon (char const *s, mode_t m,
|
||||
security_context_t *con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int getfilecon (char const *s, security_context_t *con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int lgetfilecon (char const *s, security_context_t *con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int setfilecon (char const *s, security_context_t con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int lsetfilecon (char const *s, security_context_t con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int fsetfilecon (int fd, security_context_t con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
|
||||
static inline int security_check_context (security_context_t con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int security_check_context_raw (security_context_t con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int setexeccon (security_context_t con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int security_compute_create (security_context_t scon,
|
||||
security_context_t tcon,
|
||||
security_class_t tclass,
|
||||
security_context_t *newcon)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline int matchpathcon_init_prefix (char const *path,
|
||||
char const *prefix)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/* openat-style fd-relative functions for SE Linux
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2009 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
|
||||
@@ -29,9 +29,6 @@
|
||||
#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
|
||||
#include "save-cwd.h"
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
|
||||
#include "openat-priv.h"
|
||||
|
||||
#define AT_FUNC_NAME getfileconat
|
||||
|
||||
41
gl/lib/xfreopen.c
Normal file
41
gl/lib/xfreopen.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/* a wrapper for frepoen
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
#include "xfreopen.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include "error.h"
|
||||
#include "exitfail.h"
|
||||
#include "quote.h"
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
|
||||
void
|
||||
xfreopen (char const *filename, char const *mode, FILE *fp)
|
||||
{
|
||||
if (!freopen (filename, mode, fp))
|
||||
{
|
||||
char const *f = (filename ? filename
|
||||
: (fp == stdin ? _("stdin")
|
||||
: (fp == stdout ? _("stdout")
|
||||
: (fp == stderr ? _("stderr")
|
||||
: _("unknown stream")))));
|
||||
error (exit_failure, errno, _("failed to reopen %s with mode %s"),
|
||||
quote_n (0, f), quote_n (1, mode));
|
||||
}
|
||||
}
|
||||
2
gl/lib/xfreopen.h
Normal file
2
gl/lib/xfreopen.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#include <stdio.h>
|
||||
void xfreopen (char const *filename, char const *mode, FILE *fp);
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
@@ -6,6 +6,6 @@ dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_MGETGROUPS],
|
||||
[
|
||||
AC_CHECK_FUNCS(getgrouplist)
|
||||
AC_CHECK_FUNCS([getgrouplist])
|
||||
AC_LIBOBJ([mgetgroups])
|
||||
])
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# serial 1 -*- Autoconf -*-
|
||||
# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
||||
# This file 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.
|
||||
|
||||
# From Jim Meyering
|
||||
# Provide <selinux/context.h>, if necessary.
|
||||
|
||||
AC_DEFUN([gl_HEADERS_SELINUX_CONTEXT_H],
|
||||
[
|
||||
# Check for <selinux/context.h>,
|
||||
AC_CHECK_HEADERS([selinux/context.h],
|
||||
[SELINUX_CONTEXT_H=],
|
||||
[SELINUX_CONTEXT_H=selinux/context.h])
|
||||
AC_SUBST([SELINUX_CONTEXT_H])
|
||||
])
|
||||
@@ -1,17 +0,0 @@
|
||||
# serial 1 -*- Autoconf -*-
|
||||
# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
||||
# This file 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.
|
||||
|
||||
# From Jim Meyering
|
||||
# Provide <selinux/selinux.h>, if necessary.
|
||||
|
||||
AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H],
|
||||
[
|
||||
# Check for <selinux/selinux.h>,
|
||||
AC_CHECK_HEADERS([selinux/selinux.h],
|
||||
[SELINUX_SELINUX_H=],
|
||||
[SELINUX_SELINUX_H=selinux/selinux.h])
|
||||
AC_SUBST([SELINUX_SELINUX_H])
|
||||
])
|
||||
24
gl/modules/argv-iter
Normal file
24
gl/modules/argv-iter
Normal file
@@ -0,0 +1,24 @@
|
||||
Description:
|
||||
iterate through argv or a --files0-from=-specified file
|
||||
|
||||
Files:
|
||||
lib/argv-iter.c
|
||||
lib/argv-iter.h
|
||||
|
||||
Depends-on:
|
||||
getdelim
|
||||
stdbool
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
lib_SOURCES += argv-iter.c argv-iter.h
|
||||
|
||||
Include:
|
||||
"argv-iter.h"
|
||||
|
||||
License
|
||||
GPL
|
||||
|
||||
Maintainer:
|
||||
Jim Meyering
|
||||
10
gl/modules/argv-iter-tests
Normal file
10
gl/modules/argv-iter-tests
Normal file
@@ -0,0 +1,10 @@
|
||||
Files:
|
||||
tests/test-argv-iter.c
|
||||
|
||||
Depends-on:
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
TESTS += test-argv-iter
|
||||
check_PROGRAMS += test-argv-iter
|
||||
@@ -1,16 +1,13 @@
|
||||
Index: modules/getloadavg
|
||||
===================================================================
|
||||
RCS file: /sources/gnulib/gnulib/modules/getloadavg,v
|
||||
retrieving revision 1.13
|
||||
diff -u -p -r1.13 getloadavg
|
||||
--- modules/getloadavg 22 Sep 2006 12:47:55 -0000 1.13
|
||||
+++ modules/getloadavg 23 Sep 2006 16:41:36 -0000
|
||||
@@ -14,7 +14,7 @@ stdbool
|
||||
diff --git a/modules/getloadavg b/modules/getloadavg
|
||||
index 2fbeb40..b79aaca 100644
|
||||
--- a/modules/getloadavg
|
||||
+++ b/modules/getloadavg
|
||||
@@ -16,7 +16,7 @@ stdbool
|
||||
fcntl-safer
|
||||
|
||||
configure.ac:
|
||||
-gl_GETLOADAVG([$gl_source_base])
|
||||
+gl_GETLOADAVG([lib])
|
||||
gl_STDLIB_MODULE_INDICATOR([getloadavg])
|
||||
|
||||
Makefile.am:
|
||||
|
||||
|
||||
@@ -13,12 +13,13 @@ configure.ac:
|
||||
# For runcon.
|
||||
AC_CHECK_HEADERS([selinux/flask.h])
|
||||
AC_LIBOBJ([selinux-at])
|
||||
ac_save_LIBS="$LIBS"
|
||||
AC_SEARCH_LIBS(setfilecon, selinux,
|
||||
gl_save_LIBS=$LIBS
|
||||
LIB_SELINUX=
|
||||
AC_SEARCH_LIBS([setfilecon], [selinux],
|
||||
[test "$ac_cv_search_setfilecon" = "none required" ||
|
||||
LIB_SELINUX=$ac_cv_search_setfilecon])
|
||||
AC_SUBST(LIB_SELINUX)
|
||||
LIBS="$ac_save_LIBS"
|
||||
LIBS=$gl_save_LIBS
|
||||
|
||||
Makefile.am:
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
Description:
|
||||
SELinux-related headers for systems that lack them.
|
||||
|
||||
Files:
|
||||
lib/se-context.in.h
|
||||
lib/se-selinux.in.h
|
||||
m4/selinux-context-h.m4
|
||||
m4/selinux-selinux-h.m4
|
||||
|
||||
Depends-on:
|
||||
|
||||
configure.ac:
|
||||
gl_HEADERS_SELINUX_SELINUX_H
|
||||
gl_HEADERS_SELINUX_CONTEXT_H
|
||||
|
||||
Makefile.am:
|
||||
lib_SOURCES += se-context.in.h se-selinux.in.h
|
||||
|
||||
BUILT_SOURCES += $(SELINUX_SELINUX_H)
|
||||
selinux/selinux.h: se-selinux.in.h
|
||||
mkdir -p selinux
|
||||
cp $(srcdir)/se-selinux.in.h $@-t
|
||||
chmod a-x $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t
|
||||
|
||||
BUILT_SOURCES += $(SELINUX_CONTEXT_H)
|
||||
selinux/context.h: se-context.in.h
|
||||
mkdir -p selinux
|
||||
cp $(srcdir)/se-context.in.h $@-t
|
||||
chmod a-x $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t
|
||||
MOSTLYCLEANDIRS += selinux
|
||||
|
||||
Include:
|
||||
#include <selinux/selinux.h>
|
||||
#include <selinux/context.h>
|
||||
|
||||
License:
|
||||
LGPL
|
||||
|
||||
Maintainer:
|
||||
Jim Meyering
|
||||
|
||||
# lib/selinux-at.c
|
||||
#
|
||||
# # For runcon.
|
||||
# AC_CHECK_HEADERS([selinux/flask.h])
|
||||
#
|
||||
# ac_save_LIBS="$LIBS"
|
||||
# AC_SEARCH_LIBS(setfilecon, selinux,
|
||||
# [test "$ac_cv_search_setfilecon" = "none required" ||
|
||||
# LIB_SELINUX=$ac_cv_search_setfilecon])
|
||||
# AC_SUBST(LIB_SELINUX)
|
||||
# LIBS="$ac_save_LIBS"
|
||||
25
gl/modules/xfreopen
Normal file
25
gl/modules/xfreopen
Normal file
@@ -0,0 +1,25 @@
|
||||
Description:
|
||||
a wrapper for frepoen
|
||||
|
||||
Files:
|
||||
lib/xfreopen.c
|
||||
lib/xfreopen.h
|
||||
|
||||
Depends-on:
|
||||
error
|
||||
exitfail
|
||||
quote
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
lib_SOURCES += xfreopen.c xfreopen.h
|
||||
|
||||
Include:
|
||||
"xfreopen.h"
|
||||
|
||||
License:
|
||||
LGPL
|
||||
|
||||
Maintainer:
|
||||
Jim Meyering
|
||||
120
gl/tests/test-argv-iter.c
Normal file
120
gl/tests/test-argv-iter.c
Normal file
@@ -0,0 +1,120 @@
|
||||
/* Test argv iterator
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
|
||||
#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
|
||||
#define ASSERT(expr) \
|
||||
do \
|
||||
{ \
|
||||
if (!(expr)) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
|
||||
fflush (stderr); \
|
||||
abort (); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#include "argv-iter.h"
|
||||
|
||||
static FILE *
|
||||
write_nul_delimited_argv (char **argv)
|
||||
{
|
||||
FILE *fp = tmpfile ();
|
||||
ASSERT (fp);
|
||||
while (*argv)
|
||||
{
|
||||
size_t len = strlen (*argv) + 1;
|
||||
ASSERT (fwrite (*argv, len, 1, fp) == 1);
|
||||
argv++;
|
||||
}
|
||||
ASSERT (fflush (fp) == 0);
|
||||
rewind (fp);
|
||||
return fp;
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
/* set_program_name (argv[0]); placate overzealous "syntax-check" test. */
|
||||
static char *av[][4] = {
|
||||
{NULL},
|
||||
{"1", NULL},
|
||||
{"1", "2", NULL},
|
||||
{"1", "2", "3", NULL}
|
||||
};
|
||||
|
||||
int use_stream;
|
||||
for (use_stream = 0; use_stream < 2; use_stream++)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < ARRAY_CARDINALITY (av); i++)
|
||||
{
|
||||
FILE *fp;
|
||||
struct argv_iterator *ai;
|
||||
size_t n_found = 0;
|
||||
if (use_stream)
|
||||
{
|
||||
/* Generate an identical list to be read via FP. */
|
||||
ASSERT ((fp = write_nul_delimited_argv (av[i])) != NULL);
|
||||
ai = argv_iter_init_stream (fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fp = NULL;
|
||||
ai = argv_iter_init_argv (av[i]);
|
||||
}
|
||||
ASSERT (ai);
|
||||
|
||||
while (1)
|
||||
{
|
||||
enum argv_iter_err ai_err;
|
||||
char *s = argv_iter (ai, &ai_err);
|
||||
ASSERT ((i == n_found) == (ai_err == AI_ERR_EOF));
|
||||
ASSERT ((s == NULL) ^ (ai_err == AI_ERR_OK));
|
||||
ASSERT (ai_err == AI_ERR_OK || ai_err == AI_ERR_EOF);
|
||||
if (ai_err == AI_ERR_OK)
|
||||
++n_found;
|
||||
if (ai_err == AI_ERR_EOF)
|
||||
break;
|
||||
/* In stream mode, the strings are equal, but
|
||||
in argv mode the actual pointers are equal. */
|
||||
ASSERT (use_stream
|
||||
? STREQ (s, av[i][n_found - 1])
|
||||
: s == av[i][n_found - 1]);
|
||||
}
|
||||
ASSERT (argv_iter_n_args (ai) == i);
|
||||
argv_iter_free (ai);
|
||||
if (fp)
|
||||
ASSERT (fclose (fp) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
1
gnulib
Submodule
1
gnulib
Submodule
Submodule gnulib added at 5a1286a9f8
@@ -1,6 +1,6 @@
|
||||
## Makefile for gnulib/lib -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 1995-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1995-2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
include gnulib.mk
|
||||
|
||||
AM_CFLAGS = $(WARNING_CFLAGS) $(WERROR_CFLAGS)
|
||||
AM_CFLAGS += $(WARN_CFLAGS) # $(WERROR_CFLAGS)
|
||||
|
||||
libcoreutils_a_SOURCES += \
|
||||
buffer-lcm.c buffer-lcm.h \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# boottime.m4 serial 3
|
||||
# boottime.m4 serial 4
|
||||
# Determine whether this system has infrastructure for obtaining the boot time.
|
||||
|
||||
# Copyright (C) 1996, 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996, 2000, 2002-2004, 2006, 2008 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -20,14 +20,14 @@
|
||||
* ----------------------------------------------------------
|
||||
AC_DEFUN([GNULIB_BOOT_TIME],
|
||||
[
|
||||
AC_CHECK_FUNCS(sysctl)
|
||||
AC_CHECK_HEADERS_ONCE(sys/param.h)
|
||||
AC_CHECK_HEADERS(sys/sysctl.h, [], [],
|
||||
AC_CHECK_FUNCS([sysctl])
|
||||
AC_CHECK_HEADERS_ONCE([sys/param.h])
|
||||
AC_CHECK_HEADERS([sys/sysctl.h], [], [],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
[#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif]])
|
||||
AC_CHECK_HEADERS_ONCE(utmp.h utmpx.h OS.h)
|
||||
AC_CHECK_HEADERS_ONCE([utmp.h utmpx.h OS.h])
|
||||
AC_CACHE_CHECK(
|
||||
[whether we can get the system boot time],
|
||||
[gnulib_cv_have_boot_time],
|
||||
@@ -57,8 +57,8 @@ AC_DEFUN([GNULIB_BOOT_TIME],
|
||||
please_tell_us_how_to_determine_boot_time_on_your_system
|
||||
#endif
|
||||
]])],
|
||||
gnulib_cv_have_boot_time=yes,
|
||||
gnulib_cv_have_boot_time=no)
|
||||
[gnulib_cv_have_boot_time=yes],
|
||||
[gnulib_cv_have_boot_time=no])
|
||||
])
|
||||
AS_IF([test $gnulib_cv_have_boot_time = yes], [$1], [$2])
|
||||
])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#serial 23
|
||||
#serial 24
|
||||
# Check declarations for this package.
|
||||
|
||||
dnl Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
|
||||
dnl Copyright (C) 1997-2001, 2003-2006, 2008
|
||||
dnl Free Software Foundation, Inc.
|
||||
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
@@ -16,7 +16,7 @@ AC_DEFUN([gl_CHECK_DECLS],
|
||||
[
|
||||
AC_REQUIRE([AC_HEADER_TIME])
|
||||
|
||||
AC_CHECK_HEADERS_ONCE(grp.h pwd.h)
|
||||
AC_CHECK_HEADERS_ONCE([grp.h pwd.h])
|
||||
headers='
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ AC_DEFUN([cu_GMP],
|
||||
[test "$ac_cv_search___gmpz_init" = "none required" ||
|
||||
{
|
||||
LIB_GMP=$ac_cv_search___gmpz_init
|
||||
AC_DEFINE([HAVE_GMP], 1,
|
||||
AC_DEFINE([HAVE_GMP], [1],
|
||||
[Define if you have GNU libgmp (or replacement)])
|
||||
}])
|
||||
LIBS=$cu_saved_libs
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#serial 107 -*- autoconf -*-
|
||||
#serial 109 -*- autoconf -*-
|
||||
|
||||
dnl Misc type-related macros for coreutils.
|
||||
|
||||
# Copyright (C) 1998, 2000-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998, 2000-2009 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
|
||||
@@ -22,7 +22,7 @@ dnl Misc type-related macros for coreutils.
|
||||
AC_DEFUN([coreutils_MACROS],
|
||||
[
|
||||
AM_MISSING_PROG(HELP2MAN, help2man)
|
||||
AC_SUBST(MAN)
|
||||
AC_SUBST([MAN])
|
||||
|
||||
dnl This macro actually runs replacement code. See isc-posix.m4.
|
||||
AC_REQUIRE([AC_ISC_POSIX])dnl
|
||||
@@ -36,15 +36,15 @@ AC_DEFUN([coreutils_MACROS],
|
||||
AC_REQUIRE([AC_FUNC_FSEEKO])
|
||||
|
||||
# By default, argmatch should fail calling usage (1).
|
||||
AC_DEFINE(ARGMATCH_DIE, [usage (1)],
|
||||
AC_DEFINE([ARGMATCH_DIE], [usage (1)],
|
||||
[Define to the function xargmatch calls on failures.])
|
||||
AC_DEFINE(ARGMATCH_DIE_DECL, [void usage ()],
|
||||
AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
|
||||
[Define to the declaration of the xargmatch failure function.])
|
||||
|
||||
# used by ls
|
||||
AC_REQUIRE([gl_CLOCK_TIME])
|
||||
# used by shred
|
||||
AC_CHECK_FUNCS_ONCE(directio)
|
||||
AC_CHECK_FUNCS_ONCE([directio])
|
||||
|
||||
# Used by install.c.
|
||||
AC_CHECK_FUNCS_ONCE([matchpathcon_init_prefix])
|
||||
@@ -79,7 +79,7 @@ AC_DEFUN([coreutils_MACROS],
|
||||
[test "$ac_cv_search_fdatasync" = "none required" ||
|
||||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
|
||||
AC_SUBST([LIB_FDATASYNC])
|
||||
AC_CHECK_FUNCS(fdatasync)
|
||||
AC_CHECK_FUNCS([fdatasync])
|
||||
LIBS=$coreutils_saved_libs
|
||||
|
||||
# Check whether libcap is usable -- for ls --color support
|
||||
@@ -88,8 +88,9 @@ AC_DEFUN([coreutils_MACROS],
|
||||
AC_MSG_WARN([libcap support disabled by user]),
|
||||
[AC_CHECK_LIB([cap], [cap_get_file],
|
||||
[AC_CHECK_HEADER([sys/capability.h],
|
||||
[LIB_CAP=-lcap AC_DEFINE([HAVE_CAP], 1, [libcap usability])],
|
||||
[AC_MSG_WARN([header sys/capability.h was not found, support for libcap will not be built])]
|
||||
[LIB_CAP=-lcap
|
||||
AC_DEFINE([HAVE_CAP], [1], [libcap usability])],
|
||||
[AC_MSG_WARN([header sys/capability.h was not found, support for libcap will not be built])]
|
||||
)],
|
||||
[AC_MSG_WARN([libcap library was not found or not usable, support for libcap will not be built])])
|
||||
])
|
||||
@@ -100,16 +101,16 @@ AC_DEFUN([coreutils_MACROS],
|
||||
# BeOS which has all the math functions in the normal runtime library
|
||||
# and doesn't have a separate math library.
|
||||
|
||||
AC_SUBST(SEQ_LIBM)
|
||||
AC_SUBST([SEQ_LIBM])
|
||||
ac_seq_body='
|
||||
static double x, y;
|
||||
x = floor (x);
|
||||
x = rint (x);
|
||||
x = modf (x, &y);'
|
||||
AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
|
||||
AC_TRY_LINK([#include <math.h>], [$ac_seq_body], ,
|
||||
[ac_seq_save_LIBS="$LIBS"
|
||||
LIBS="$LIBS -lm"
|
||||
AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
|
||||
AC_TRY_LINK([#include <math.h>], [$ac_seq_body], [SEQ_LIBM=-lm])
|
||||
LIBS="$ac_seq_save_LIBS"
|
||||
])
|
||||
|
||||
@@ -132,7 +133,7 @@ AC_DEFUN([gl_CHECK_ALL_HEADERS],
|
||||
syslog.h \
|
||||
termios.h \
|
||||
)
|
||||
AC_CHECK_HEADERS(sys/sysctl.h, [], [],
|
||||
AC_CHECK_HEADERS([sys/sysctl.h], [], [],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
[#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
@@ -153,7 +154,7 @@ AC_DEFUN([gl_CHECK_ALL_TYPES],
|
||||
AC_REQUIRE([AM_C_PROTOTYPES])
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_REQUIRE([AC_C_BIGENDIAN])
|
||||
AC_REQUIRE([gl_BIGENDIAN])
|
||||
AC_REQUIRE([AC_C_VOLATILE])
|
||||
AC_REQUIRE([AC_C_INLINE])
|
||||
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
|
||||
@@ -173,12 +174,12 @@ AC_DEFUN([gl_CHECK_ALL_TYPES],
|
||||
AC_REQUIRE([AC_TYPE_PID_T])
|
||||
AC_REQUIRE([AC_TYPE_SIZE_T])
|
||||
AC_REQUIRE([AC_TYPE_UID_T])
|
||||
AC_CHECK_TYPE(ino_t, unsigned long int)
|
||||
AC_CHECK_TYPE([ino_t], [unsigned long int])
|
||||
|
||||
dnl This relies on the fact that Autoconf's implementation of
|
||||
dnl AC_CHECK_TYPE checks includes unistd.h.
|
||||
AC_CHECK_TYPE(major_t, unsigned int)
|
||||
AC_CHECK_TYPE(minor_t, unsigned int)
|
||||
AC_CHECK_TYPE([major_t], [unsigned int])
|
||||
AC_CHECK_TYPE([minor_t], [unsigned int])
|
||||
|
||||
AC_REQUIRE([AC_HEADER_MAJOR])
|
||||
])
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#serial 10
|
||||
#serial 11
|
||||
|
||||
dnl Misc lib-related macros for coreutils.
|
||||
|
||||
# Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2004,
|
||||
# 2005, 2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1993-1997, 2000-2001, 2003-2006, 2008
|
||||
# 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
|
||||
@@ -24,20 +24,20 @@ AC_DEFUN([cu_LIB_CHECK],
|
||||
[
|
||||
|
||||
# Check for libypsec.a on Dolphin M88K machines.
|
||||
AC_CHECK_LIB(ypsec, main)
|
||||
AC_CHECK_LIB([ypsec], [main])
|
||||
|
||||
# m88k running dgux 5.4 needs this
|
||||
AC_CHECK_LIB(ldgc, main)
|
||||
AC_CHECK_LIB([ldgc], [main])
|
||||
|
||||
# The -lsun library is required for YP support on Irix-4.0.5 systems.
|
||||
# m88k/svr3 DolphinOS systems using YP need -lypsec for id.
|
||||
AC_SEARCH_LIBS(yp_match, [sun ypsec])
|
||||
AC_SEARCH_LIBS([yp_match], [sun ypsec])
|
||||
|
||||
# SysV needs -lsec, older versions of Linux need -lshadow for
|
||||
# shadow passwords. UnixWare 7 needs -lgen.
|
||||
AC_SEARCH_LIBS(getspnam, [shadow sec gen])
|
||||
AC_SEARCH_LIBS([getspnam], [shadow sec gen])
|
||||
|
||||
AC_CHECK_HEADERS(shadow.h)
|
||||
AC_CHECK_HEADERS([shadow.h])
|
||||
|
||||
# Requirements for su.c.
|
||||
shadow_includes="\
|
||||
@@ -47,14 +47,14 @@ $ac_includes_default
|
||||
#endif
|
||||
"
|
||||
AC_CHECK_MEMBERS([struct spwd.sp_pwdp],,,[$shadow_includes])
|
||||
AC_CHECK_FUNCS(getspnam)
|
||||
AC_CHECK_FUNCS([getspnam])
|
||||
|
||||
# SCO-ODT-3.0 is reported to need -lufc for crypt.
|
||||
# NetBSD needs -lcrypt for crypt.
|
||||
cu_saved_libs="$LIBS"
|
||||
AC_SEARCH_LIBS(crypt, [ufc crypt],
|
||||
AC_SEARCH_LIBS([crypt], [ufc crypt],
|
||||
[test "$ac_cv_search_crypt" = "none required" ||
|
||||
LIB_CRYPT="$ac_cv_search_crypt"])
|
||||
LIBS="$cu_saved_libs"
|
||||
AC_SUBST(LIB_CRYPT)
|
||||
AC_SUBST([LIB_CRYPT])
|
||||
])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 75
|
||||
#serial 76
|
||||
|
||||
dnl We use gl_ for non Autoconf macros.
|
||||
m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
|
||||
@@ -7,7 +7,7 @@ m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
|
||||
# directory of the coreutils package.
|
||||
|
||||
|
||||
# Copyright (C) 1998, 2000, 2001, 2003-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998, 2000, 2001, 2003-2009 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
|
||||
@@ -38,6 +38,7 @@ AC_DEFUN([gl_PREREQ],
|
||||
# handles that; see ../bootstrap.conf.
|
||||
AC_REQUIRE([gl_EUIDACCESS_STAT])
|
||||
AC_REQUIRE([gl_FD_REOPEN])
|
||||
AC_REQUIRE([gl_FUNC_XATTR])
|
||||
AC_REQUIRE([gl_FUNC_XFTS])
|
||||
AC_REQUIRE([gl_MEMXFRM])
|
||||
AC_REQUIRE([gl_STRINTCMP])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# stat-prog.m4 serial 5
|
||||
# stat-prog.m4 serial 6
|
||||
# Record the prerequisites of src/stat.c from the coreutils package.
|
||||
|
||||
# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2004, 2006, 2008 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
|
||||
@@ -68,7 +68,7 @@ AC_INCLUDES_DEFAULT
|
||||
[$statvfs_includes],
|
||||
[static statvfs s;
|
||||
return (s.s_fsid ^ 0) == 0;])],
|
||||
[AC_DEFINE([STRUCT_STATVFS_F_FSID_IS_INTEGER], 1,
|
||||
[AC_DEFINE([STRUCT_STATVFS_F_FSID_IS_INTEGER], [1],
|
||||
[Define to 1 if the f_fsid member of struct statvfs is an integer.])])
|
||||
else
|
||||
AC_CHECK_MEMBERS([struct statfs.f_namelen, struct statfs.f_type],,,
|
||||
@@ -79,7 +79,7 @@ AC_INCLUDES_DEFAULT
|
||||
[$statfs_includes],
|
||||
[static statfs s;
|
||||
return (s.s_fsid ^ 0) == 0;])],
|
||||
[AC_DEFINE([STRUCT_STATFS_F_FSID_IS_INTEGER], 1,
|
||||
[AC_DEFINE([STRUCT_STATFS_F_FSID_IS_INTEGER], [1],
|
||||
[Define to 1 if the f_fsid member of struct statfs is an integer.])])
|
||||
fi
|
||||
fi
|
||||
|
||||
36
m4/xattr.m4
Normal file
36
m4/xattr.m4
Normal file
@@ -0,0 +1,36 @@
|
||||
# xattr.m4 - check for Extended Attributes (Linux)
|
||||
|
||||
# Copyright (C) 2003, 2008-2009 Free Software Foundation, Inc.
|
||||
# This file 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.
|
||||
|
||||
# Originally written by Andreas Gruenbacher.
|
||||
# http://www.suse.de/~agruen/coreutils/5.91/coreutils-xattr.diff
|
||||
|
||||
AC_DEFUN([gl_FUNC_XATTR],
|
||||
[
|
||||
AC_ARG_ENABLE([xattr],
|
||||
AC_HELP_STRING([--disable-xattr],
|
||||
[do not support extended attributes]),
|
||||
[use_xattr=$enableval], [use_xattr=yes])
|
||||
|
||||
if test "$use_xattr" = "yes"; then
|
||||
AC_CHECK_HEADERS([attr/error_context.h attr/libattr.h])
|
||||
if test $ac_cv_header_attr_libattr_h = yes \
|
||||
&& test $ac_cv_header_attr_error_context_h = yes; then
|
||||
use_xattr=1
|
||||
else
|
||||
use_xattr=0
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([USE_XATTR], [$use_xattr],
|
||||
[Define if you want extended attribute support.])
|
||||
xattr_saved_LIBS=$LIBS
|
||||
AC_SEARCH_LIBS([attr_copy_file], [attr],
|
||||
[test "$ac_cv_search_attr_copy_file" = "none required" ||
|
||||
LIB_XATTR=$ac_cv_search_attr_copy_file])
|
||||
AC_CHECK_FUNCS([attr_copy_file])
|
||||
LIBS=$xattr_saved_LIBS
|
||||
AC_SUBST([LIB_XATTR])
|
||||
fi
|
||||
])
|
||||
492
maint.mk
492
maint.mk
@@ -2,7 +2,7 @@
|
||||
# This Makefile fragment tries to be general-purpose enough to be
|
||||
# used by at least coreutils, idutils, CPPI, Bison, and Autoconf.
|
||||
|
||||
## Copyright (C) 2001-2008 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2001-2009 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
|
||||
@@ -62,24 +62,25 @@ release_archive_dir ?= ../release
|
||||
# Doing it here saves us from having to set LC_ALL elsewhere in this file.
|
||||
export LC_ALL = C
|
||||
|
||||
|
||||
|
||||
## --------------- ##
|
||||
## Sanity checks. ##
|
||||
## --------------- ##
|
||||
|
||||
# Collect the names of rules starting with `sc_'.
|
||||
syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
|
||||
$(srcdir)/$(ME))
|
||||
$(srcdir)/$(ME) $(srcdir)/cfg.mk)
|
||||
.PHONY: $(syntax-check-rules)
|
||||
|
||||
local-checks-available = \
|
||||
po-check copyright-check m4-check author_mark_check \
|
||||
patch-check strftime-check $(syntax-check-rules) \
|
||||
makefile_path_separator_check \
|
||||
patch-check $(syntax-check-rules) \
|
||||
makefile-check check-AUTHORS
|
||||
.PHONY: $(local-checks-available)
|
||||
|
||||
# Arrange to print the name of each syntax-checking rule just before running it.
|
||||
$(syntax-check-rules): %: %.m
|
||||
$(patsubst %, %.m, $(syntax-check-rules)):
|
||||
@echo $(patsubst sc_%.m, %, $@)
|
||||
|
||||
local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available))
|
||||
|
||||
syntax-check: $(local-check)
|
||||
@@ -94,6 +95,21 @@ syntax-check: $(local-check)
|
||||
# exit 1; } || :
|
||||
# FIXME: don't allow `#include .strings\.h' anywhere
|
||||
|
||||
# By default, _prohibit_regexp does not ignore case.
|
||||
export ignore_case =
|
||||
_ignore_case = $$(test -n "$$ignore_case" && echo -i || :)
|
||||
|
||||
# There are many rules below that prohibit constructs in this package.
|
||||
# If the offending construct can be matched with a grep-E-style regexp,
|
||||
# use this macro. The shell variables "re" and "msg" must be defined.
|
||||
define _prohibit_regexp
|
||||
dummy=; : so we do not need a semicolon before each use \
|
||||
test "x$$re" != x || { echo '$(ME): re not defined' 1>&2; exit 1; }; \
|
||||
test "x$$msg" != x || { echo '$(ME): msg not defined' 1>&2; exit 1; };\
|
||||
grep $(_ignore_case) -nE "$$re" $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): '"$$msg" 1>&2; exit 1; } || :
|
||||
endef
|
||||
|
||||
sc_avoid_if_before_free:
|
||||
@$(srcdir)/build-aux/useless-if-before-free \
|
||||
$(useless_free_options) \
|
||||
@@ -102,47 +118,44 @@ sc_avoid_if_before_free:
|
||||
exit 1; } || :
|
||||
|
||||
sc_cast_of_argument_to_free:
|
||||
@grep -nE '\<free *\( *\(' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
|
||||
exit 1; } || :
|
||||
@re='\<free *\( *\(' msg='don'\''t cast free argument' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
sc_cast_of_x_alloc_return_value:
|
||||
@grep -nE '\*\) *x(m|c|re)alloc\>' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
|
||||
exit 1; } || :
|
||||
@re='\*\) *x(m|c|re)alloc\>' \
|
||||
msg='don'\''t cast x*alloc return value' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
sc_cast_of_alloca_return_value:
|
||||
@grep -nE '\*\) *alloca\>' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): don'\''t cast alloca return value' 1>&2; \
|
||||
exit 1; } || :
|
||||
@re='\*\) *alloca\>' msg='don'\''t cast alloca return value' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
sc_space_tab:
|
||||
@grep -n '[ ] ' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
|
||||
1>&2; exit 1; } || :
|
||||
@re='[ ] ' msg='found SPACE-TAB sequence; remove the SPACE' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Don't use *scanf or the old ato* functions in `real' code.
|
||||
# They provide no error checking mechanism.
|
||||
# Instead, use strto* functions.
|
||||
sc_prohibit_atoi_atof:
|
||||
@grep -nE '\<([fs]?scanf|ato([filq]|ll))\>' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): do not use *scan''f, ato''f, ato''i, ato''l, ato''ll, ato''q, or ss''canf' \
|
||||
1>&2; exit 1; } || :
|
||||
@re='\<([fs]?scanf|ato([filq]|ll)) *\(' \
|
||||
msg='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Use STREQ rather than comparing strcmp == 0, or != 0.
|
||||
sc_prohibit_strcmp:
|
||||
@grep -nE '! *str''cmp *\(|\<str''cmp *\([^)]+\) *==' \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
$$($(VC_LIST_EXCEPT)) \
|
||||
| grep -vE ':# *define STREQ\(' && \
|
||||
{ echo '$(ME): use STREQ in place of the above uses of str''cmp' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Using EXIT_SUCCESS as the first argument to error is misleading,
|
||||
# since when that parameter is 0, error does not exit. Use `0' instead.
|
||||
sc_error_exit_success:
|
||||
@grep -nF 'error (EXIT_SUCCESS,' \
|
||||
$$(find -type f -name '*.[chly]') && \
|
||||
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
|
||||
exit 1; } || :
|
||||
@grep -nE 'error \(EXIT_SUCCESS,' \
|
||||
$$($(VC_LIST_EXCEPT) | grep -E '\.[chly]$$') && \
|
||||
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; exit 1; } || :
|
||||
|
||||
# `FATAL:' should be fully upper-cased in error messages
|
||||
# `WARNING:' should be fully upper-cased, or fully lower-cased
|
||||
@@ -168,13 +181,12 @@ sc_error_message_period:
|
||||
exit 1; } || :
|
||||
|
||||
sc_file_system:
|
||||
@grep -ni 'file''system' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found use of "file''system";' \
|
||||
'rewrite to use "file system"' 1>&2; \
|
||||
exit 1; } || :
|
||||
@re=file''system ignore_case=1 \
|
||||
msg='found use of "file''system"; spell it "file system"' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Don't use cpp tests of this symbol. All code assumes config.h is included.
|
||||
sc_no_have_config_h:
|
||||
sc_prohibit_have_config_h:
|
||||
@grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found use of HAVE''_CONFIG_H; remove' \
|
||||
1>&2; exit 1; } || :
|
||||
@@ -190,6 +202,25 @@ sc_require_config_h:
|
||||
else :; \
|
||||
fi
|
||||
|
||||
# You must include <config.h> before including any other header file.
|
||||
sc_require_config_h_first:
|
||||
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
|
||||
fail=0; \
|
||||
for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do \
|
||||
grep '^# *include\>' $$i | sed 1q \
|
||||
| grep '^# *include <config\.h>' > /dev/null \
|
||||
|| { echo $$i; fail=1; }; \
|
||||
done; \
|
||||
test $$fail = 1 && \
|
||||
{ echo '$(ME): the above files include some other header' \
|
||||
'before <config.h>' 1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
|
||||
sc_prohibit_HAVE_MBRTOWC:
|
||||
@re='\bHAVE_MBRTOWC\b' msg="do not use $$re; it is always defined" \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# To use this "command" macro, you must first define two shell variables:
|
||||
# h: the header, enclosed in <> or ""
|
||||
# re: a regular expression that matches IFF something provided by $h is used.
|
||||
@@ -251,11 +282,53 @@ sc_prohibit_root_dev_ino_without_use:
|
||||
re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
|
||||
$(_header_without_use)
|
||||
|
||||
# Prohibit the inclusion of c-ctype.h without an actual use.
|
||||
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
|
||||
|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
|
||||
sc_prohibit_c_ctype_without_use:
|
||||
@h='[<"]c-ctype.h[">]' re='\<c_($(ctype_re)) *\(' $(_header_without_use)
|
||||
|
||||
_empty =
|
||||
_sp = $(_empty) $(_empty)
|
||||
# The following list was generated by running:
|
||||
# man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
|
||||
# | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
|
||||
_sig_functions = \
|
||||
bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \
|
||||
sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \
|
||||
siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \
|
||||
sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
|
||||
_sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions)))
|
||||
# The following were extracted from "man signal.h" manually.
|
||||
_sig_types_and_consts = \
|
||||
MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \
|
||||
SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \
|
||||
SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \
|
||||
SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \
|
||||
sigstack sigval stack_t ucontext_t
|
||||
# generated via this:
|
||||
# perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
|
||||
_sig_names = \
|
||||
SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \
|
||||
SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \
|
||||
SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \
|
||||
SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \
|
||||
SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \
|
||||
SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \
|
||||
SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \
|
||||
SIGXCPU SIGXFSZ
|
||||
_sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts)))
|
||||
|
||||
# Prohibit the inclusion of signal.h without an actual use.
|
||||
sc_prohibit_signal_without_use:
|
||||
@h='<signal.h>' \
|
||||
re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \
|
||||
$(_header_without_use)
|
||||
|
||||
sc_obsolete_symbols:
|
||||
@grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
|
||||
1>&2; exit 1; } || :
|
||||
@re='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
|
||||
msg='do not use HAVE''_FCNTL_H or O'_NDELAY \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
|
||||
|
||||
@@ -265,105 +338,6 @@ sc_changelog:
|
||||
{ echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Ensure that dd's definition of LONGEST_SYMBOL stays in sync
|
||||
# with the strings from the two affected variables.
|
||||
dd_c = $(srcdir)/src/dd.c
|
||||
sc_dd_max_sym_length:
|
||||
ifneq ($(wildcard $(dd_c)),)
|
||||
@len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
|
||||
sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
|
||||
|sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
|
||||
| wc --max-line-length); \
|
||||
max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
|
||||
|tr -d '"' | wc --max-line-length); \
|
||||
if test "$$len" = "$$max"; then :; else \
|
||||
echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
endif
|
||||
|
||||
# Many m4 macros names once began with `jm_'.
|
||||
# On 2004-04-13, they were all changed to start with gl_ instead.
|
||||
# Make sure that none are inadvertently reintroduced.
|
||||
sc_prohibit_jm_in_m4:
|
||||
@grep -nE 'jm_[A-Z]' \
|
||||
$$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
|
||||
{ echo '$(ME): do not use jm_ in m4 macro names' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Ensure that each root-requiring test is run via the "check-root" rule.
|
||||
sc_root_tests:
|
||||
@if test -d tests \
|
||||
&& grep check-root tests/Makefile.am>/dev/null 2>&1; then \
|
||||
t1=sc-root.expected; t2=sc-root.actual; \
|
||||
grep -nl '^require_root_$$' \
|
||||
$$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1; \
|
||||
sed -n '/^root_tests =[ ]*\\$$/,/[^\]$$/p' \
|
||||
$(srcdir)/tests/Makefile.am \
|
||||
| sed 's/^ *//;/^root_tests =/d' \
|
||||
| tr -s '\012\\' ' ' | fmt -1 | sort > $$t2; \
|
||||
diff -u $$t1 $$t2 || diff=1; \
|
||||
rm -f $$t1 $$t2; \
|
||||
test "$$diff" \
|
||||
&& { echo 'tests/Makefile.am: missing check-root action'>&2; \
|
||||
exit 1; } || :; \
|
||||
fi
|
||||
|
||||
headers_with_interesting_macro_defs = \
|
||||
exit.h \
|
||||
fcntl_.h \
|
||||
fnmatch_.h \
|
||||
intprops.h \
|
||||
inttypes_.h \
|
||||
lchown.h \
|
||||
openat.h \
|
||||
stat-macros.h \
|
||||
stdint_.h
|
||||
|
||||
# Create a list of regular expressions matching the names
|
||||
# of macros that are guaranteed by parts of gnulib to be defined.
|
||||
.re-defmac:
|
||||
@(cd $(srcdir)/lib; \
|
||||
for f in $(headers_with_interesting_macro_defs); do \
|
||||
test -f $$f && \
|
||||
sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
|
||||
done; \
|
||||
) | sort -u \
|
||||
| grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
|
||||
| sed 's/^/^# *define /' \
|
||||
> $@-t
|
||||
@mv $@-t $@
|
||||
|
||||
# Don't define macros that we already get from gnulib header files.
|
||||
sc_always_defined_macros: .re-defmac
|
||||
@if test -f $(srcdir)/src/system.h; then \
|
||||
trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
|
||||
grep -f .re-defmac $$($(VC_LIST)) \
|
||||
&& { echo '$(ME): define the above via some gnulib .h file' \
|
||||
1>&2; exit 1; } || :; \
|
||||
fi
|
||||
|
||||
# Create a list of regular expressions matching the names
|
||||
# of files included from system.h. Exclude a couple.
|
||||
.re-list:
|
||||
@sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
|
||||
| grep -Ev 'sys/(param|file)\.h' \
|
||||
| sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
|
||||
> $@-t
|
||||
@mv $@-t $@
|
||||
|
||||
# Files in src/ should not include directly any of
|
||||
# the headers already included via system.h.
|
||||
sc_system_h_headers: .re-list
|
||||
@if test -f $(srcdir)/src/system.h; then \
|
||||
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
|
||||
grep -nE -f .re-list \
|
||||
$$($(VC_LIST) src | \
|
||||
grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
|
||||
&& { echo '$(ME): the above are already included via system.h'\
|
||||
1>&2; exit 1; } || :; \
|
||||
fi
|
||||
|
||||
# Ensure that each .c file containing a "main" function also
|
||||
# calls set_program_name.
|
||||
sc_program_name:
|
||||
@@ -383,34 +357,24 @@ sc_require_test_exit_idiom:
|
||||
@if test -f $(srcdir)/tests/test-lib.sh; then \
|
||||
die=0; \
|
||||
for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \
|
||||
tail -n1 $$i | grep '^Exit \$$fail$$' > /dev/null \
|
||||
tail -n1 $$i | grep '^Exit \$$fail$$' > /dev/null \
|
||||
&& : || { die=1; echo $$i; } \
|
||||
done; \
|
||||
test $$die = 1 && \
|
||||
{ echo 1>&2 '$(ME): the final line in each of the above is not:'; \
|
||||
echo 1>&2 'Exit $$fail'; \
|
||||
echo 1>&2 'Exit $$fail'; \
|
||||
exit 1; } || :; \
|
||||
fi
|
||||
|
||||
sc_sun_os_names:
|
||||
@grep -nEi \
|
||||
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_the_the:
|
||||
@grep -ni '\<the ''the\>' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found use of "the ''the";' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_tight_scope:
|
||||
$(MAKE) -C src $@
|
||||
@re='\<the ''the\>' \
|
||||
ignore_case=1 msg='found use of "the ''the";' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
sc_trailing_blank:
|
||||
@grep -n '[ ]$$' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found trailing blank(s)' \
|
||||
1>&2; exit 1; } || :
|
||||
@re='[ ]$$' \
|
||||
msg='found trailing blank(s)' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Match lines like the following, but where there is only one space
|
||||
# between the options and the description:
|
||||
@@ -420,7 +384,7 @@ sc_two_space_separator_in_usage:
|
||||
@grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo "$(ME): help2man requires at least two spaces between"; \
|
||||
echo "$(ME): an option and its description"; \
|
||||
echo "$(ME): an option and its description"; \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Look for diagnostics that aren't marked for translation.
|
||||
@@ -441,30 +405,30 @@ sc_useless_cpp_parens:
|
||||
|
||||
# Require the latest GPL.
|
||||
sc_GPL_version:
|
||||
@grep -n 'either ''version [^3]' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || :
|
||||
@re='either ''version [^3]' msg='GPL vN, N!=3' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Perl-based tests used to exec perl from a #!/bin/sh script.
|
||||
# Now they all start with #!/usr/bin/perl and the portability
|
||||
# infrastructure is in tests/Makefile.am. Make sure no old-style
|
||||
# script sneaks back in.
|
||||
sc_no_exec_perl_coreutils:
|
||||
@if test -f $(srcdir)/tests/Coreutils.pm; then \
|
||||
grep '^exec *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) && \
|
||||
{ echo 1>&2 '$(ME): found anachronistic Perl-based tests'; \
|
||||
exit 1; } || :; \
|
||||
fi
|
||||
cvs_keywords = \
|
||||
Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
|
||||
|
||||
NEWS_hash = \
|
||||
$$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
|
||||
$(srcdir)/NEWS | md5sum -)
|
||||
sc_prohibit_cvs_keyword:
|
||||
@re='\$$($(cvs_keywords))\$$' \
|
||||
msg='do not use CVS keyword expansion' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Ensure that we don't accidentally insert an entry into an old NEWS block.
|
||||
sc_immutable_NEWS:
|
||||
@if test -f $(srcdir)/NEWS; then \
|
||||
test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
|
||||
{ echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
|
||||
fi
|
||||
# Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
|
||||
# This is a bit of a kludge, since it prevents use of the string
|
||||
# even in comments, but for now it does the job with no false positives.
|
||||
sc_prohibit_stat_st_blocks:
|
||||
@re='[.>]st_blocks' msg='do not use st_blocks; use ST_NBLOCKS' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Make sure we don't define any S_IS* macros in src/*.c files.
|
||||
# They're already defined via gnulib's sys/stat.h replacement.
|
||||
sc_prohibit_S_IS_definition:
|
||||
@re='^ *# *define *S_IS' \
|
||||
msg='do not define S_IS* macros; include <sys/stat.h>' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Each program that uses proper_name_utf8 must link with
|
||||
# one of the ICONV libraries.
|
||||
@@ -486,10 +450,9 @@ sc_proper_name_utf8_requires_ICONV:
|
||||
# Warn about "c0nst struct Foo const foo[]",
|
||||
# but not about "char const *const foo" or "#define const const".
|
||||
sc_redundant_const:
|
||||
@grep -E '\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo 1>&2 '$(ME): redundant "const" in declarations'; \
|
||||
exit 1; } || :
|
||||
@re='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
|
||||
msg='redundant "const" in declarations' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
sc_const_long_option:
|
||||
@grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
|
||||
@@ -497,6 +460,20 @@ sc_const_long_option:
|
||||
echo 1>&2 '$(ME): add "const" to the above declarations'; \
|
||||
exit 1; } || :
|
||||
|
||||
NEWS_hash = \
|
||||
$$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
|
||||
$(srcdir)/NEWS \
|
||||
| grep -v '^Copyright .*Free Software' \
|
||||
| md5sum - \
|
||||
| sed 's/ .*//')
|
||||
|
||||
# Ensure that we don't accidentally insert an entry into an old NEWS block.
|
||||
sc_immutable_NEWS:
|
||||
@if test -f $(srcdir)/NEWS; then \
|
||||
test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
|
||||
{ echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
|
||||
fi
|
||||
|
||||
# Update the hash stored above. Do this after each release and
|
||||
# for any corrections to old entries.
|
||||
update-NEWS-hash: NEWS
|
||||
@@ -529,21 +506,6 @@ patch-check:
|
||||
test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \
|
||||
test "$$msg" = ok
|
||||
|
||||
# Ensure that date's --help output stays in sync with the info
|
||||
# documentation for GNU strftime. The only exception is %N,
|
||||
# which date accepts but GNU strftime does not.
|
||||
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
|
||||
strftime-check:
|
||||
if test -f $(srcdir)/src/date.c; then \
|
||||
grep '^ %. ' $(srcdir)/src/date.c | sort \
|
||||
| $(extract_char) > $@-src; \
|
||||
{ echo N; \
|
||||
info libc date calendar format | grep '^ `%.'\' \
|
||||
| $(extract_char); } | sort > $@-info; \
|
||||
diff -u $@-src $@-info || exit 1; \
|
||||
rm -f $@-src $@-info; \
|
||||
fi
|
||||
|
||||
check-AUTHORS:
|
||||
$(MAKE) -C src $@
|
||||
|
||||
@@ -577,15 +539,27 @@ changelog-check:
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
m4-check:
|
||||
@grep -n 'AC_DEFUN([^[]' m4/*.m4 \
|
||||
&& { echo '$(ME): quote the first arg to AC_DEFUN' 1>&2; \
|
||||
sc_makefile_TAB_only_indentation:
|
||||
@grep -nE '^ [ ]{8}' \
|
||||
$$($(VC_LIST_EXCEPT) | grep -E 'akefile|\.mk$$') \
|
||||
&& { echo '$(ME): found TAB-8-space indentation' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_m4_quote_check:
|
||||
@grep -nE '(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
|
||||
$$($(VC_LIST_EXCEPT) | grep -E '(^configure\.ac|\.m4)$$') \
|
||||
&& { echo '$(ME): quote the first arg to AC_DEF*' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
fix_po_file_diag = \
|
||||
'you have changed the set of files with translatable diagnostics;\n\
|
||||
apply the above patch\n'
|
||||
|
||||
# Verify that all source files using _() are listed in po/POTFILES.in.
|
||||
po-check:
|
||||
@if test -f po/POTFILES.in; then \
|
||||
grep -E -v '^(#|$$)' po/POTFILES.in \
|
||||
po_file = po/POTFILES.in
|
||||
sc_po_check:
|
||||
@if test -f $(po_file); then \
|
||||
grep -E -v '^(#|$$)' $(po_file) \
|
||||
| grep -v '^src/false\.c$$' | sort > $@-1; \
|
||||
files=; \
|
||||
for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do \
|
||||
@@ -602,34 +576,25 @@ po-check:
|
||||
done; \
|
||||
grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
|
||||
| sort -u > $@-2; \
|
||||
diff -u $@-1 $@-2 || exit 1; \
|
||||
diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
|
||||
|| { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \
|
||||
rm -f $@-1 $@-2; \
|
||||
fi
|
||||
|
||||
# In a definition of #define AUTHORS "... and ..." where the RHS contains
|
||||
# the English word `and', the string must be marked with `N_ (...)' so that
|
||||
# gettext recognizes it as a string requiring translation.
|
||||
author_mark_check:
|
||||
@grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
|
||||
{ echo '$(ME): enclose the above strings in N_ (...)' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Sometimes it is useful to change the PATH environment variable
|
||||
# in Makefiles. When doing so, it's better not to use the Unix-centric
|
||||
# path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
|
||||
# It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
|
||||
# and there probably aren't many projects with so many Makefile.am files
|
||||
# that we'd have to worry about limits on command line length.
|
||||
msg = '$(ME): Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
|
||||
makefile_path_separator_check:
|
||||
@grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
|
||||
# path separator of `:', but rather the automake-provided `$(PATH_SEPARATOR)'.
|
||||
msg = '$(ME): Do not use `:'\'' above; use $$(PATH_SEPARATOR) instead'
|
||||
sc_makefile_path_separator_check:
|
||||
@grep -nE 'PATH[=].*:' \
|
||||
$$($(VC_LIST_EXCEPT) | grep -E 'akefile|\.mk$$') \
|
||||
&& { echo $(msg) 1>&2; exit 1; } || :
|
||||
|
||||
# Check that `make alpha' will not fail at the end of the process.
|
||||
writable-files:
|
||||
if test -d $(release_archive_dir); then :; else \
|
||||
for file in $(distdir).tar.gz \
|
||||
$(release_archive_dir)/$(distdir).tar.gz; do \
|
||||
$(release_archive_dir)/$(distdir).tar.gz; do \
|
||||
test -e $$file || continue; \
|
||||
test -w $$file \
|
||||
|| { echo ERROR: $$file is not writable; fail=1; }; \
|
||||
@@ -642,24 +607,24 @@ sample-test = tests/sample-test
|
||||
texi = doc/$(PACKAGE).texi
|
||||
# Make sure that the copyright date in $(v_etc_file) is up to date.
|
||||
# Do the same for the $(sample-test) and the main doc/.texi file.
|
||||
copyright-check:
|
||||
@if test -f $(v_etc_file); then \
|
||||
sc_copyright_check:
|
||||
@if test -f $(v_etc_file); then \
|
||||
grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
|
||||
>/dev/null \
|
||||
>/dev/null \
|
||||
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
|
||||
exit 1; }; \
|
||||
exit 1; }; \
|
||||
fi
|
||||
@if test -f $(sample-test); then \
|
||||
grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
|
||||
>/dev/null \
|
||||
@if test -f $(sample-test); then \
|
||||
grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
|
||||
>/dev/null \
|
||||
|| { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
|
||||
exit 1; }; \
|
||||
exit 1; }; \
|
||||
fi
|
||||
@if test -f $(texi); then \
|
||||
grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
|
||||
>/dev/null \
|
||||
|| { echo 'out of date copyright in $(texi); update it' 1>&2; \
|
||||
exit 1; }; \
|
||||
@if test -f $(texi); then \
|
||||
grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
|
||||
>/dev/null \
|
||||
|| { echo 'out of date copyright in $(texi); update it' 1>&2; \
|
||||
exit 1; }; \
|
||||
fi
|
||||
|
||||
vc-diff-check:
|
||||
@@ -683,7 +648,7 @@ maintainer-distcheck:
|
||||
# Don't make a distribution if checks fail.
|
||||
# Also, make sure the NEWS file is up-to-date.
|
||||
vc-dist: $(local-check) cvs-check maintainer-distcheck
|
||||
$(MAKE) dist
|
||||
XZ_OPT=-9ev $(MAKE) dist
|
||||
|
||||
# Use this to make sure we don't run these programs when building
|
||||
# from a virgin tgz file, below.
|
||||
@@ -737,12 +702,12 @@ taint-distcheck: $(DIST_ARCHIVES)
|
||||
|
||||
# Verify that a twisted use of --program-transform-name=PROGRAM works.
|
||||
define install-transform-check
|
||||
rm -rf $(pfx); \
|
||||
$(MAKE) program_transform_name='s/.*/zyx/' \
|
||||
echo running install-transform-check \
|
||||
&& rm -rf $(pfx) \
|
||||
&& $(MAKE) program_transform_name='s/.*/zyx/' \
|
||||
prefix=$(pfx) install \
|
||||
&& test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
|
||||
&& test "$$(echo $(pfx)/share/man/man1/*)" = \
|
||||
"$(pfx)/share/man/man1/zyx.1"
|
||||
&& test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
|
||||
endef
|
||||
|
||||
# Install, then verify that all binaries and man pages are in place.
|
||||
@@ -764,6 +729,35 @@ define my-instcheck
|
||||
}
|
||||
endef
|
||||
|
||||
define coreutils-path-check
|
||||
{ \
|
||||
if test -f $(srcdir)/src/true.c; then \
|
||||
fail=1; \
|
||||
mkdir $(bin) \
|
||||
&& ($(write_loser)) > $(bin)/loser \
|
||||
&& chmod a+x $(bin)/loser \
|
||||
&& for i in $(built_programs); do \
|
||||
case $$i in \
|
||||
rm|expr|basename|echo|sort|ls|tr);; \
|
||||
cat|dirname|mv|wc);; \
|
||||
*) ln $(bin)/loser $(bin)/$$i;; \
|
||||
esac; \
|
||||
done \
|
||||
&& ln -sf ../src/true $(bin)/false \
|
||||
&& PATH=`pwd`/$(bin)$(PATH_SEPARATOR)$$PATH \
|
||||
$(MAKE) -C tests check \
|
||||
&& { test -d gnulib-tests \
|
||||
&& $(MAKE) -C gnulib-tests check \
|
||||
|| :; } \
|
||||
&& rm -rf $(bin) \
|
||||
&& fail=0; \
|
||||
else \
|
||||
fail=0; \
|
||||
fi; \
|
||||
test $$fail = 1 && exit 1 || :; \
|
||||
}
|
||||
endef
|
||||
|
||||
# Use -Wformat -Werror to detect format-string/arg-list mismatches.
|
||||
# Also, check for shadowing problems with -Wshadow, and for pointer
|
||||
# arithmetic problems with -Wpointer-arith.
|
||||
@@ -789,22 +783,7 @@ my-distcheck: $(DIST_ARCHIVES) $(local-check)
|
||||
&& $(MAKE) dvi \
|
||||
&& $(install-transform-check) \
|
||||
&& $(my-instcheck) \
|
||||
&& mkdir $(bin) \
|
||||
&& ($(write_loser)) > $(bin)/loser \
|
||||
&& chmod a+x $(bin)/loser \
|
||||
&& for i in $(built_programs); do \
|
||||
case $$i in \
|
||||
rm|expr|basename|echo|sort|ls|tr);; \
|
||||
cat|dirname|mv|wc);; \
|
||||
*) ln $(bin)/loser $(bin)/$$i;; \
|
||||
esac; \
|
||||
done \
|
||||
&& ln -sf ../src/true $(bin)/false \
|
||||
&& PATH=`pwd`/$(bin):$$PATH $(MAKE) -C tests check \
|
||||
&& { test -d gnulib-tests \
|
||||
&& $(MAKE) -C gnulib-tests check \
|
||||
|| :; } \
|
||||
&& rm -rf $(bin) \
|
||||
&& $(coreutils-path-check) \
|
||||
&& $(MAKE) distclean
|
||||
(cd $(t) && mv $(distdir) $(distdir).old \
|
||||
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz
|
||||
@@ -840,6 +819,7 @@ announcement: NEWS ChangeLog $(rel-files)
|
||||
--news=NEWS \
|
||||
--bootstrap-tools=autoconf,automake,bison,gnulib \
|
||||
--gnulib-version=$(gnulib-version) \
|
||||
--no-print-checksums \
|
||||
$(addprefix --url-dir=, $(url_dir_list))
|
||||
|
||||
## ---------------- ##
|
||||
@@ -889,3 +869,13 @@ alpha beta major: $(local-check) writable-files
|
||||
perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS
|
||||
$(emit-commit-log) > .ci-msg
|
||||
$(VC) commit -F .ci-msg -a
|
||||
|
||||
.PHONY: web-manual
|
||||
web-manual:
|
||||
@test -z "$(manual_title)" \
|
||||
&& { echo define manual_title in cfg.mk 1>&2; exit 1; } || :
|
||||
@cd '$(srcdir)/doc'; \
|
||||
$(SHELL) ../build-aux/gendocs.sh -o '$(abs_builddir)/doc/manual' \
|
||||
--email $(PACKAGE_BUGREPORT) $(PACKAGE) \
|
||||
"$(PACKAGE_NAME) - $(manual_title)"
|
||||
@echo " *** Upload the doc/manual directory to web-cvs."
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Make coreutils man pages. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 2002-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2009 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
|
||||
@@ -132,6 +132,10 @@ who.1: $(common_dep) $(srcdir)/who.x ../src/who.c
|
||||
whoami.1: $(common_dep) $(srcdir)/whoami.x ../src/whoami.c
|
||||
yes.1: $(common_dep) $(srcdir)/yes.x ../src/yes.c
|
||||
|
||||
# This is required so that changes to e.g., emit_bug_reporting_address
|
||||
# provoke regeneration of all $(MAN) files.
|
||||
$(MAN): $(top_srcdir)/src/system.h
|
||||
|
||||
SUFFIXES = .x .1
|
||||
|
||||
# Ensure that help2man runs the ../src/ginstall binary as
|
||||
@@ -152,13 +156,13 @@ mapped_name = `echo $*|sed 's/^install$$/ginstall/; s/^test$$/[/'`
|
||||
*) \
|
||||
rm -f $@ \
|
||||
&& { echo "Updating man page $@"; \
|
||||
rm -rf $t; \
|
||||
mkdir $t; \
|
||||
(cd $t && $(LN_S) ../../src/$(mapped_name) $*); \
|
||||
$(PERL) -- $(srcdir)/help2man \
|
||||
--source='$(PACKAGE_STRING)' \
|
||||
--include=$(srcdir)/$*.x \
|
||||
--output=$t/$@ $t/$*; \
|
||||
rm -rf $t; \
|
||||
mkdir $t; \
|
||||
(cd $t && $(LN_S) ../../src/$(mapped_name) $*); \
|
||||
$(PERL) -- $(srcdir)/help2man \
|
||||
--source='$(PACKAGE_STRING)' \
|
||||
--include=$(srcdir)/$*.x \
|
||||
--output=$t/$@ $t/$*; \
|
||||
} \
|
||||
&& sed 's|$*\.td/||g' $t/$@ > $@ \
|
||||
&& rm -rf $t ;; \
|
||||
|
||||
2
man/du.x
2
man/du.x
@@ -19,7 +19,7 @@ will match any files whose names end in
|
||||
.BR .o .
|
||||
Therefore, the command
|
||||
.IP
|
||||
.B du --exclude='*.o'
|
||||
.B du --exclude=\(aq*.o\(aq
|
||||
.PP
|
||||
will skip all files and subdirectories ending in
|
||||
.BR .o
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# Generate a short man page from --help and --version output.
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -368,7 +368,7 @@ s/^\./\x80/mg;
|
||||
s/^'/\x81/mg;
|
||||
s/\\/\x82/g;
|
||||
|
||||
my $PAT_BUGS = _('Report +bugs|Email +bug +reports +to');
|
||||
my $PAT_BUGS = _('Report +(?:\w+ +)?bugs|Email +bug +reports +to');
|
||||
my $PAT_AUTHOR = _('Written +by');
|
||||
my $PAT_OPTIONS = _('Options');
|
||||
my $PAT_EXAMPLES = _('Examples');
|
||||
@@ -567,7 +567,7 @@ and
|
||||
.B %s
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info coreutils '%s invocation'
|
||||
.B info coreutils \(aq%s invocation\(aq
|
||||
.PP
|
||||
should give you access to the complete manual.
|
||||
EOT
|
||||
@@ -607,6 +607,9 @@ for my $sect (@pre, (grep ! /^($filter)$/o, @include), @post)
|
||||
# Convert some latin1 chars to troff equivalents
|
||||
s/\xa0/\\ /g; # non-breaking space
|
||||
|
||||
$sect eq 'REPORTING BUGS'
|
||||
and s/\n(.)/\n.br\n$1/g;
|
||||
|
||||
print;
|
||||
}
|
||||
}
|
||||
|
||||
2
man/id.x
2
man/id.x
@@ -1,4 +1,4 @@
|
||||
[NAME]
|
||||
id \- print user identity
|
||||
id \- print real and effective user and group IDs
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[NAME]
|
||||
truncate \- shrink or extend the size of a file to the specifed size
|
||||
truncate \- shrink or extend the size of a file to the specified size
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
|
||||
@@ -753,7 +753,7 @@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2 or
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the ``GNU Free
|
||||
|
||||
@@ -277,7 +277,7 @@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2 or
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the ``GNU Free
|
||||
|
||||
@@ -465,7 +465,7 @@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2006 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2 or
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the ``GNU Free
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# List of files which contain translatable strings.
|
||||
# Copyright (C) 1996-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2009 Free Software Foundation, Inc.
|
||||
|
||||
# These are nominally temporary...
|
||||
lib/argmatch.c
|
||||
@@ -22,8 +22,10 @@ lib/rpmatch.c
|
||||
lib/set-mode-acl.c
|
||||
lib/unicodeio.c
|
||||
lib/userspec.c
|
||||
lib/verror.c
|
||||
lib/version-etc.c
|
||||
lib/xalloc-die.c
|
||||
lib/xfreopen.c
|
||||
lib/xfts.c
|
||||
lib/xmemcoll.c
|
||||
lib/xmemxfrm.c
|
||||
@@ -61,6 +63,7 @@ src/factor.c
|
||||
src/false.c
|
||||
src/fmt.c
|
||||
src/fold.c
|
||||
src/getlimits.c
|
||||
src/group-list.c
|
||||
src/groups.c
|
||||
src/head.c
|
||||
|
||||
1
src/.gitignore
vendored
1
src/.gitignore
vendored
@@ -31,6 +31,7 @@ false
|
||||
fmt
|
||||
fold
|
||||
fs.h
|
||||
getlimits
|
||||
ginstall
|
||||
groups
|
||||
head
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
|
||||
## Copyright (C) 1990, 1991, 1993-2008 Free Software Foundation, Inc.
|
||||
## Copyright (C) 1990, 1991, 1993-2009 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
|
||||
@@ -26,6 +26,8 @@ no_install__progs = \
|
||||
build_if_possible__progs = \
|
||||
chroot df hostid nice pinky stty su uname uptime users who
|
||||
|
||||
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||
|
||||
EXTRA_PROGRAMS = \
|
||||
$(no_install__progs) \
|
||||
$(build_if_possible__progs) \
|
||||
@@ -44,7 +46,7 @@ EXTRA_PROGRAMS = \
|
||||
|
||||
bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
|
||||
|
||||
noinst_PROGRAMS = setuidgid
|
||||
noinst_PROGRAMS = setuidgid getlimits
|
||||
|
||||
noinst_HEADERS = \
|
||||
chown-core.h \
|
||||
@@ -82,6 +84,7 @@ LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
|
||||
cat_LDADD = $(LDADD)
|
||||
df_LDADD = $(LDADD)
|
||||
du_LDADD = $(LDADD)
|
||||
getlimits_LDADD = $(LDADD)
|
||||
ptx_LDADD = $(LDADD)
|
||||
split_LDADD = $(LDADD)
|
||||
timeout_LDADD = $(LDADD)
|
||||
@@ -149,9 +152,9 @@ su_LDADD = $(LDADD) $(LIB_CRYPT)
|
||||
dir_LDADD += $(LIB_ACL)
|
||||
ls_LDADD += $(LIB_ACL)
|
||||
vdir_LDADD += $(LIB_ACL)
|
||||
cp_LDADD += $(LIB_ACL)
|
||||
mv_LDADD += $(LIB_ACL)
|
||||
ginstall_LDADD += $(LIB_ACL)
|
||||
cp_LDADD += $(LIB_ACL) $(LIB_XATTR)
|
||||
mv_LDADD += $(LIB_ACL) $(LIB_XATTR)
|
||||
ginstall_LDADD += $(LIB_ACL) $(LIB_XATTR)
|
||||
|
||||
stat_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
|
||||
@@ -160,11 +163,16 @@ cat_LDADD += $(LIBICONV)
|
||||
cp_LDADD += $(LIBICONV)
|
||||
df_LDADD += $(LIBICONV)
|
||||
du_LDADD += $(LIBICONV)
|
||||
getlimits_LDADD += $(LIBICONV)
|
||||
ptx_LDADD += $(LIBICONV)
|
||||
split_LDADD += $(LIBICONV)
|
||||
timeout_LDADD += $(LIBICONV)
|
||||
truncate_LDADD += $(LIBICONV)
|
||||
|
||||
# programs that use getaddrinfo (e.g., via canon_host)
|
||||
pinky_LDADD = $(LDADD) $(GETADDRINFO_LIB)
|
||||
who_LDADD = $(LDADD) $(GETADDRINFO_LIB)
|
||||
|
||||
$(PROGRAMS): ../lib/libcoreutils.a
|
||||
|
||||
# Get the release year from ../lib/version-etc.c.
|
||||
@@ -351,7 +359,7 @@ pm = progs-makefile
|
||||
pr = progs-readme
|
||||
# Ensure that the list of programs in README matches the list
|
||||
# of programs we can build.
|
||||
check: check-README check-misc check-duplicate-no-install
|
||||
check: check-README check-duplicate-no-install
|
||||
.PHONY: check-README
|
||||
check-README:
|
||||
rm -rf $(pr) $(pm)
|
||||
@@ -374,8 +382,8 @@ au_dotdot = authors-dotdot
|
||||
au_actual = authors-actual
|
||||
.PHONY: check-AUTHORS
|
||||
check-AUTHORS: $(all_programs)
|
||||
rm -f $(au_actual) $(au_dotdot)
|
||||
for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
|
||||
@rm -f $(au_actual) $(au_dotdot)
|
||||
@for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
|
||||
| $(ASSORT) -u`; do \
|
||||
test "$$i" = '[' && continue; \
|
||||
exe=$$i; \
|
||||
@@ -384,24 +392,12 @@ check-AUTHORS: $(all_programs)
|
||||
elif test "$$i" = test; then \
|
||||
exe='['; \
|
||||
fi; \
|
||||
LC_ALL=en_US.UTF-8 ./$$exe --version \
|
||||
LC_ALL=en_US.UTF-8 ./$$exe --version \
|
||||
| perl -0 -pi -e 's/,\n/, /gm' \
|
||||
|sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
|
||||
done > $(au_actual)
|
||||
sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
|
||||
diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
|
||||
|
||||
# Make sure we don't define any S_IS* macros in src/*.c files.
|
||||
# Not a big deal, but they're already defined via system.h.
|
||||
#
|
||||
# Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
|
||||
# This is a bit of a kludge, since it prevents use of the string
|
||||
# even in comments, but for now it does the job with no false positives.
|
||||
.PHONY: check-misc
|
||||
check-misc:
|
||||
cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
|
||||
cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
|
||||
cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
|
||||
@sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
|
||||
@diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
|
||||
|
||||
# Extract the list of authors from each file.
|
||||
sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
|
||||
@@ -409,7 +405,6 @@ sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
|
||||
s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
|
||||
# Sometimes the string is on the backslash-continued line after the #define.
|
||||
s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
|
||||
# FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
|
||||
../AUTHORS: $(SOURCES)
|
||||
rm -f $@-t
|
||||
( \
|
||||
@@ -453,6 +448,7 @@ sc_tight_scope: $(all_programs)
|
||||
) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
|
||||
nm -e *.$(OBJEXT) \
|
||||
| sed -n 's/.* T //p' \
|
||||
| sed 's/^_//' \
|
||||
| grep -Ev -f $$t && \
|
||||
{ echo 'the above functions should have static scope' 1>&2; \
|
||||
exit 1; } || : ; \
|
||||
@@ -461,6 +457,7 @@ sc_tight_scope: $(all_programs)
|
||||
$$hdr *.h ) | $(ASSORT) -u > $$t; \
|
||||
nm -e *.$(OBJEXT) \
|
||||
| sed -n 's/.* [BD] //p' \
|
||||
| sed 's/^_//' \
|
||||
| grep -Ev -f $$t && \
|
||||
{ echo 'the above variables should have static scope' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
@@ -48,7 +48,7 @@ static struct option const long_options[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static void
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != EXIT_SUCCESS)
|
||||
|
||||
19
src/cat.c
19
src/cat.c
@@ -1,5 +1,5 @@
|
||||
/* cat -- concatenate files and print on the standard output.
|
||||
Copyright (C) 88, 90, 91, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 1995-2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "full-write.h"
|
||||
#include "quote.h"
|
||||
#include "safe-read.h"
|
||||
#include "xfreopen.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cat"
|
||||
@@ -47,10 +48,6 @@
|
||||
proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \
|
||||
proper_name ("Richard M. Stallman")
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
#undef max
|
||||
#define max(h,i) ((h) > (i) ? (h) : (i))
|
||||
|
||||
/* Name of input file. May be "-". */
|
||||
static char const *infile;
|
||||
|
||||
@@ -336,7 +333,7 @@ cat (
|
||||
input_pending = true;
|
||||
#endif
|
||||
|
||||
if (input_pending)
|
||||
if (!input_pending)
|
||||
write_pending (outbuf, &bpout);
|
||||
|
||||
/* Read more input into INBUF. */
|
||||
@@ -639,7 +636,7 @@ main (int argc, char **argv)
|
||||
if (fstat (STDOUT_FILENO, &stat_buf) < 0)
|
||||
error (EXIT_FAILURE, errno, _("standard output"));
|
||||
|
||||
outsize = ST_BLKSIZE (stat_buf);
|
||||
outsize = io_blksize (stat_buf);
|
||||
/* Input file can be output file for non-regular files.
|
||||
fstat on pipes returns S_IFSOCK on some systems, S_IFIFO
|
||||
on others, so the checking should not be done for those types,
|
||||
@@ -664,7 +661,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
file_open_mode |= O_BINARY;
|
||||
if (O_BINARY && ! isatty (STDOUT_FILENO))
|
||||
freopen (NULL, "wb", stdout);
|
||||
xfreopen (NULL, "wb", stdout);
|
||||
}
|
||||
|
||||
/* Check if any of the input files are the same as the output file. */
|
||||
@@ -684,7 +681,7 @@ main (int argc, char **argv)
|
||||
have_read_stdin = true;
|
||||
input_desc = STDIN_FILENO;
|
||||
if ((file_open_mode & O_BINARY) && ! isatty (STDIN_FILENO))
|
||||
freopen (NULL, "rb", stdin);
|
||||
xfreopen (NULL, "rb", stdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -703,7 +700,7 @@ main (int argc, char **argv)
|
||||
ok = false;
|
||||
goto contin;
|
||||
}
|
||||
insize = ST_BLKSIZE (stat_buf);
|
||||
insize = io_blksize (stat_buf);
|
||||
|
||||
/* Compare the device and i-node numbers of this input file with
|
||||
the corresponding values of the (output file associated with)
|
||||
@@ -725,7 +722,7 @@ main (int argc, char **argv)
|
||||
if (! (number | show_ends | show_nonprinting
|
||||
| show_tabs | squeeze_blank))
|
||||
{
|
||||
insize = max (insize, outsize);
|
||||
insize = MAX (insize, outsize);
|
||||
inbuf = xmalloc (insize + page_size - 1);
|
||||
|
||||
ok &= simple_cat (ptr_align (inbuf, page_size), insize);
|
||||
|
||||
23
src/chcon.c
23
src/chcon.c
@@ -35,26 +35,6 @@
|
||||
proper_name ("Russell Coker"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
enum Change_status
|
||||
{
|
||||
CH_NOT_APPLIED,
|
||||
CH_SUCCEEDED,
|
||||
CH_FAILED,
|
||||
CH_NO_CHANGE_REQUESTED
|
||||
};
|
||||
|
||||
enum Verbosity
|
||||
{
|
||||
/* Print a message for each file that is processed. */
|
||||
V_high,
|
||||
|
||||
/* Print a message for each file whose attributes we change. */
|
||||
V_changes_only,
|
||||
|
||||
/* Do not be verbose. This is the default. */
|
||||
V_off
|
||||
};
|
||||
|
||||
/* If nonzero, and the systems has support for it, change the context
|
||||
of symbolic links rather than any files they point to. */
|
||||
static bool affect_symlink_referent;
|
||||
@@ -369,7 +349,6 @@ Usage: %s [OPTION]... CONTEXT FILE...\n\
|
||||
Change the security context of each FILE to CONTEXT.\n\
|
||||
With --reference, change the security context of each FILE to that of RFILE.\n\
|
||||
\n\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
-h, --no-dereference affect symbolic links instead of any referenced file\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
@@ -430,7 +409,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "HLPRchvu:r:t:l:", long_options, NULL))
|
||||
while ((optc = getopt_long (argc, argv, "HLPRhvu:r:t:l:", long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-2009 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
|
||||
@@ -302,6 +302,7 @@ main (int argc, char **argv)
|
||||
quote ("/"));
|
||||
}
|
||||
|
||||
bit_flags |= FTS_DEFER_STAT;
|
||||
ok = chown_files (argv + optind, bit_flags,
|
||||
(uid_t) -1, gid,
|
||||
(uid_t) -1, (gid_t) -1, &chopt);
|
||||
|
||||
29
src/chmod.c
29
src/chmod.c
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-2009 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
|
||||
@@ -67,7 +67,7 @@ static mode_t umask_value;
|
||||
/* If true, change the modes of directories recursively. */
|
||||
static bool recurse;
|
||||
|
||||
/* If true, force silence (no error messages). */
|
||||
/* If true, force silence (suppress most of error messages). */
|
||||
static bool force_silent;
|
||||
|
||||
/* If true, diagnose surprises from naive misuses like "chmod -r file".
|
||||
@@ -121,7 +121,7 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
|
||||
|
||||
if (stat (file, &new_stats) != 0)
|
||||
{
|
||||
if (!force_silent)
|
||||
if (! force_silent)
|
||||
error (0, errno, _("getting new attributes of %s"), quote (file));
|
||||
return false;
|
||||
}
|
||||
@@ -203,24 +203,29 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
fts_set (fts, ent, FTS_AGAIN);
|
||||
return true;
|
||||
}
|
||||
error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
|
||||
if (! force_silent)
|
||||
error (0, ent->fts_errno, _("cannot access %s"),
|
||||
quote (file_full_name));
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case FTS_ERR:
|
||||
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
|
||||
if (! force_silent)
|
||||
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case FTS_DNR:
|
||||
error (0, ent->fts_errno, _("cannot read directory %s"),
|
||||
quote (file_full_name));
|
||||
if (! force_silent)
|
||||
error (0, ent->fts_errno, _("cannot read directory %s"),
|
||||
quote (file_full_name));
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case FTS_SLNONE:
|
||||
error (0, 0, _("cannot operate on dangling symlink %s"),
|
||||
quote (file_full_name));
|
||||
if (! force_silent)
|
||||
error (0, 0, _("cannot operate on dangling symlink %s"),
|
||||
quote (file_full_name));
|
||||
ok = false;
|
||||
|
||||
default:
|
||||
@@ -319,7 +324,8 @@ process_files (char **files, int bit_flags)
|
||||
if (errno != 0)
|
||||
{
|
||||
/* FIXME: try to give a better message */
|
||||
error (0, errno, _("fts_read failed"));
|
||||
if (! force_silent)
|
||||
error (0, errno, _("fts_read failed"));
|
||||
ok = false;
|
||||
}
|
||||
break;
|
||||
@@ -528,7 +534,8 @@ main (int argc, char **argv)
|
||||
root_dev_ino = NULL;
|
||||
}
|
||||
|
||||
ok = process_files (argv + optind, FTS_COMFOLLOW | FTS_PHYSICAL);
|
||||
ok = process_files (argv + optind,
|
||||
FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT);
|
||||
|
||||
exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -296,18 +296,22 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
fts_set (fts, ent, FTS_AGAIN);
|
||||
return true;
|
||||
}
|
||||
error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
|
||||
if (! chopt->force_silent)
|
||||
error (0, ent->fts_errno, _("cannot access %s"),
|
||||
quote (file_full_name));
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case FTS_ERR:
|
||||
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
|
||||
if (! chopt->force_silent)
|
||||
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case FTS_DNR:
|
||||
error (0, ent->fts_errno, _("cannot read directory %s"),
|
||||
quote (file_full_name));
|
||||
if (! chopt->force_silent)
|
||||
error (0, ent->fts_errno, _("cannot read directory %s"),
|
||||
quote (file_full_name));
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
@@ -338,8 +342,9 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
{
|
||||
if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot dereference %s"),
|
||||
quote (file_full_name));
|
||||
if (! chopt->force_silent)
|
||||
error (0, errno, _("cannot dereference %s"),
|
||||
quote (file_full_name));
|
||||
ok = false;
|
||||
}
|
||||
|
||||
@@ -492,7 +497,8 @@ chown_files (char **files, int bit_flags,
|
||||
if (errno != 0)
|
||||
{
|
||||
/* FIXME: try to give a better message */
|
||||
error (0, errno, _("fts_read failed"));
|
||||
if (! chopt->force_silent)
|
||||
error (0, errno, _("fts_read failed"));
|
||||
ok = false;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chown -- change user and group ownership of files
|
||||
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-2009 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
|
||||
@@ -312,7 +312,7 @@ main (int argc, char **argv)
|
||||
empty string so that diagnostics say "ownership :GROUP"
|
||||
rather than "group GROUP". */
|
||||
if (!chopt.user_name && chopt.group_name)
|
||||
chopt.user_name = "";
|
||||
chopt.user_name = bad_cast ("");
|
||||
|
||||
optind++;
|
||||
}
|
||||
@@ -326,6 +326,7 @@ main (int argc, char **argv)
|
||||
quote ("/"));
|
||||
}
|
||||
|
||||
bit_flags |= FTS_DEFER_STAT;
|
||||
ok = chown_files (argv + optind, bit_flags,
|
||||
uid, gid,
|
||||
required_uid, required_gid, &chopt);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chroot -- run command or shell with special root directory
|
||||
Copyright (C) 95, 96, 1997, 1999-2004, 2007-2008
|
||||
Copyright (C) 95, 96, 1997, 1999-2004, 2007-2009
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -83,7 +83,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (chroot (argv[optind]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot change root directory to %s"), argv[1]);
|
||||
error (EXIT_FAILURE, errno, _("cannot change root directory to %s"),
|
||||
argv[optind]);
|
||||
|
||||
if (chdir ("/"))
|
||||
error (EXIT_FAILURE, errno, _("cannot chdir to root directory"));
|
||||
@@ -93,9 +94,9 @@ main (int argc, char **argv)
|
||||
/* No command. Run an interactive shell. */
|
||||
char *shell = getenv ("SHELL");
|
||||
if (shell == NULL)
|
||||
shell = "/bin/sh";
|
||||
shell = bad_cast ("/bin/sh");
|
||||
argv[0] = shell;
|
||||
argv[1] = "-i";
|
||||
argv[1] = bad_cast ("-i");
|
||||
argv[2] = NULL;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include "system.h"
|
||||
#include "xfreopen.h"
|
||||
|
||||
#ifdef CRCTAB
|
||||
|
||||
@@ -192,7 +193,7 @@ cksum (const char *file, bool print_name)
|
||||
fp = stdin;
|
||||
have_read_stdin = true;
|
||||
if (O_BINARY && ! isatty (STDIN_FILENO))
|
||||
freopen (NULL, "rb", stdin);
|
||||
xfreopen (NULL, "rb", stdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
10
src/comm.c
10
src/comm.c
@@ -1,5 +1,5 @@
|
||||
/* comm -- compare two sorted files line by line.
|
||||
Copyright (C) 86, 90, 91, 1995-2005, 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 90, 91, 1995-2005, 2008-2009 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
|
||||
@@ -23,9 +23,9 @@
|
||||
#include "system.h"
|
||||
#include "linebuffer.h"
|
||||
#include "error.h"
|
||||
#include "hard-locale.h"
|
||||
#include "quote.h"
|
||||
#include "stdio--.h"
|
||||
#include "memcmp2.h"
|
||||
#include "xmemcoll.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -200,10 +200,8 @@ check_order (struct linebuffer const *prev,
|
||||
order = xmemcoll (prev->buffer, prev->length - 1,
|
||||
current->buffer, current->length - 1);
|
||||
else
|
||||
{
|
||||
size_t len = min (prev->length, current->length) - 1;
|
||||
order = memcmp (prev->buffer, current->buffer, len);
|
||||
}
|
||||
order = memcmp2 (prev->buffer, prev->length - 1,
|
||||
current->buffer, current->length - 1);
|
||||
|
||||
if (0 < order)
|
||||
{
|
||||
|
||||
205
src/copy.c
205
src/copy.c
@@ -1,5 +1,5 @@
|
||||
/* copy.c -- core functions for copying files and directories
|
||||
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-2009 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
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "buffer-lcm.h"
|
||||
#include "copy.h"
|
||||
#include "cp-hash.h"
|
||||
#include "euidaccess.h"
|
||||
#include "error.h"
|
||||
#include "fcntl--.h"
|
||||
#include "file-set.h"
|
||||
@@ -44,7 +43,7 @@
|
||||
#include "full-write.h"
|
||||
#include "hash.h"
|
||||
#include "hash-triple.h"
|
||||
#include "lchmod.h"
|
||||
#include "ignore-value.h"
|
||||
#include "quote.h"
|
||||
#include "same.h"
|
||||
#include "savedir.h"
|
||||
@@ -55,6 +54,13 @@
|
||||
#include "areadlink.h"
|
||||
#include "yesno.h"
|
||||
|
||||
#if USE_XATTR
|
||||
# include <attr/error_context.h>
|
||||
# include <attr/libattr.h>
|
||||
# include <stdarg.h>
|
||||
# include "verror.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FCHOWN
|
||||
# define HAVE_FCHOWN false
|
||||
# define fchown(fd, uid, gid) (-1)
|
||||
@@ -98,6 +104,7 @@ static bool copy_internal (char const *src_name, char const *dst_name,
|
||||
struct dir_list *ancestors,
|
||||
const struct cp_options *x,
|
||||
bool command_line_arg,
|
||||
bool *first_dir_created_per_command_line_arg,
|
||||
bool *copy_into_self,
|
||||
bool *rename_succeeded);
|
||||
static bool owner_failure_ok (struct cp_options const *x);
|
||||
@@ -124,18 +131,91 @@ is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
|
||||
return false;
|
||||
}
|
||||
|
||||
#if USE_XATTR
|
||||
static void
|
||||
copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED,
|
||||
char const *fmt, ...)
|
||||
{
|
||||
int err = errno;
|
||||
va_list ap;
|
||||
|
||||
/* use verror module to print error message */
|
||||
va_start (ap, fmt);
|
||||
verror (0, err, fmt, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
static char const *
|
||||
copy_attr_quote (struct error_context *ctx ATTRIBUTE_UNUSED, char const *str)
|
||||
{
|
||||
return quote (str);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_attr_free (struct error_context *ctx ATTRIBUTE_UNUSED,
|
||||
char const *str ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
static bool
|
||||
copy_attr_by_fd (char const *src_path, int src_fd,
|
||||
char const *dst_path, int dst_fd, const struct cp_options *x)
|
||||
{
|
||||
struct error_context ctx =
|
||||
{
|
||||
.error = copy_attr_error,
|
||||
.quote = copy_attr_quote,
|
||||
.quote_free = copy_attr_free
|
||||
};
|
||||
return 0 == attr_copy_fd (src_path, src_fd, dst_path, dst_fd, 0,
|
||||
x->reduce_diagnostics ? NULL : &ctx);
|
||||
}
|
||||
|
||||
static bool
|
||||
copy_attr_by_name (char const *src_path, char const *dst_path,
|
||||
const struct cp_options *x)
|
||||
{
|
||||
struct error_context ctx =
|
||||
{
|
||||
.error = copy_attr_error,
|
||||
.quote = copy_attr_quote,
|
||||
.quote_free = copy_attr_free
|
||||
};
|
||||
return 0 == attr_copy_file (src_path, dst_path, 0,
|
||||
x-> reduce_diagnostics ? NULL :&ctx);
|
||||
}
|
||||
#else /* USE_XATTR */
|
||||
|
||||
static bool
|
||||
copy_attr_by_fd (char const *src_path, int src_fd,
|
||||
char const *dst_path, int dst_fd, const struct cp_options *x)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
copy_attr_by_name (char const *src_path, char const *dst_path,
|
||||
const struct cp_options *x)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif /* USE_XATTR */
|
||||
|
||||
/* Read the contents of the directory SRC_NAME_IN, and recursively
|
||||
copy the contents to DST_NAME_IN. NEW_DST is true if
|
||||
DST_NAME_IN is a directory that was created previously in the
|
||||
recursion. SRC_SB and ANCESTORS describe SRC_NAME_IN.
|
||||
Set *COPY_INTO_SELF if SRC_NAME_IN is a parent of
|
||||
FIRST_DIR_CREATED_PER_COMMAND_LINE_ARG FIXME
|
||||
(or the same as) DST_NAME_IN; otherwise, clear it.
|
||||
Return true if successful. */
|
||||
|
||||
static bool
|
||||
copy_dir (char const *src_name_in, char const *dst_name_in, bool new_dst,
|
||||
const struct stat *src_sb, struct dir_list *ancestors,
|
||||
const struct cp_options *x, bool *copy_into_self)
|
||||
const struct cp_options *x,
|
||||
bool *first_dir_created_per_command_line_arg,
|
||||
bool *copy_into_self)
|
||||
{
|
||||
char *name_space;
|
||||
char *namep;
|
||||
@@ -165,12 +245,19 @@ copy_dir (char const *src_name_in, char const *dst_name_in, bool new_dst,
|
||||
|
||||
ok &= copy_internal (src_name, dst_name, new_dst, src_sb->st_dev,
|
||||
ancestors, &non_command_line_options, false,
|
||||
first_dir_created_per_command_line_arg,
|
||||
&local_copy_into_self, NULL);
|
||||
*copy_into_self |= local_copy_into_self;
|
||||
|
||||
free (dst_name);
|
||||
free (src_name);
|
||||
|
||||
/* If we're copying into self, there's no point in continuing,
|
||||
and in fact, that would even infloop, now that we record only
|
||||
the first created directory per command line argument. */
|
||||
if (local_copy_into_self)
|
||||
break;
|
||||
|
||||
namep += strlen (namep) + 1;
|
||||
}
|
||||
free (name_space);
|
||||
@@ -203,7 +290,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
|
||||
group. Avoid the window by first changing to a restrictive
|
||||
temporary mode if necessary. */
|
||||
|
||||
if (!new_dst & (x->preserve_mode | x->move_mode | x->set_mode))
|
||||
if (!new_dst && (x->preserve_mode | x->move_mode | x->set_mode))
|
||||
{
|
||||
mode_t old_mode = dst_sb->st_mode;
|
||||
mode_t new_mode =
|
||||
@@ -230,7 +317,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
|
||||
/* We've failed to set *both*. Now, try to set just the group
|
||||
ID, but ignore any failure here, and don't change errno. */
|
||||
int saved_errno = errno;
|
||||
(void) fchown (dest_desc, -1, gid);
|
||||
ignore_value (fchown (dest_desc, -1, gid));
|
||||
errno = saved_errno;
|
||||
}
|
||||
}
|
||||
@@ -243,7 +330,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
|
||||
/* We've failed to set *both*. Now, try to set just the group
|
||||
ID, but ignore any failure here, and don't change errno. */
|
||||
int saved_errno = errno;
|
||||
(void) lchown (dst_name, -1, gid);
|
||||
ignore_value (lchown (dst_name, -1, gid));
|
||||
errno = saved_errno;
|
||||
}
|
||||
}
|
||||
@@ -378,7 +465,8 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
security_context_t con = NULL;
|
||||
if (getfscreatecon (&con) < 0)
|
||||
{
|
||||
error (0, errno, _("failed to get file system create context"));
|
||||
if (!x->reduce_diagnostics)
|
||||
error (0, errno, _("failed to get file system create context"));
|
||||
if (x->require_preserve_context)
|
||||
{
|
||||
return_val = false;
|
||||
@@ -390,9 +478,10 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
{
|
||||
if (fsetfilecon (dest_desc, con) < 0)
|
||||
{
|
||||
error (0, errno,
|
||||
_("failed to set the security context of %s to %s"),
|
||||
quote_n (0, dst_name), quote_n (1, con));
|
||||
if (!x->reduce_diagnostics)
|
||||
error (0, errno,
|
||||
_("failed to set the security context of %s to %s"),
|
||||
quote_n (0, dst_name), quote_n (1, con));
|
||||
if (x->require_preserve_context)
|
||||
{
|
||||
return_val = false;
|
||||
@@ -400,7 +489,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
goto close_src_and_dst_desc;
|
||||
}
|
||||
}
|
||||
freecon(con);
|
||||
freecon (con);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,7 +512,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
if (*new_dst)
|
||||
{
|
||||
int open_flags = O_WRONLY | O_CREAT | O_BINARY;
|
||||
dest_desc = open (dst_name, open_flags | O_EXCL ,
|
||||
dest_desc = open (dst_name, open_flags | O_EXCL,
|
||||
dst_mode & ~omitted_permissions);
|
||||
dest_errno = errno;
|
||||
|
||||
@@ -483,7 +572,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
/* Choose a suitable buffer size; it may be adjusted later. */
|
||||
size_t buf_alignment = lcm (getpagesize (), sizeof (word));
|
||||
size_t buf_alignment_slop = sizeof (word) + buf_alignment - 1;
|
||||
size_t buf_size = ST_BLKSIZE (sb);
|
||||
size_t buf_size = io_blksize (sb);
|
||||
|
||||
/* Deal with sparse files. */
|
||||
bool last_write_made_hole = false;
|
||||
@@ -511,21 +600,12 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
buffer size. */
|
||||
if (! make_holes)
|
||||
{
|
||||
/* These days there's no point ever messing with buffers smaller
|
||||
than 8 KiB. It would be nice to configure SMALL_BUF_SIZE
|
||||
dynamically for this host and pair of files, but there doesn't
|
||||
seem to be a good way to get readahead info portably. */
|
||||
enum { SMALL_BUF_SIZE = 8 * 1024 };
|
||||
|
||||
/* Compute the least common multiple of the input and output
|
||||
buffer sizes, adjusting for outlandish values. */
|
||||
size_t blcm_max = MIN (SIZE_MAX, SSIZE_MAX) - buf_alignment_slop;
|
||||
size_t blcm = buffer_lcm (ST_BLKSIZE (src_open_sb), buf_size,
|
||||
size_t blcm = buffer_lcm (io_blksize (src_open_sb), buf_size,
|
||||
blcm_max);
|
||||
|
||||
/* Do not use a block size that is too small. */
|
||||
buf_size = MAX (SMALL_BUF_SIZE, blcm);
|
||||
|
||||
/* Do not bother with a buffer larger than the input file, plus one
|
||||
byte to make sure the file has not grown while reading it. */
|
||||
if (S_ISREG (src_open_sb.st_mode) && src_open_sb.st_size < buf_size)
|
||||
@@ -682,6 +762,11 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
|
||||
set_author (dst_name, dest_desc, src_sb);
|
||||
|
||||
if (x->preserve_xattr && ! copy_attr_by_fd (src_name, source_desc,
|
||||
dst_name, dest_desc, x)
|
||||
&& x->require_preserve_xattr)
|
||||
return false;
|
||||
|
||||
if (x->preserve_mode || x->move_mode)
|
||||
{
|
||||
if (copy_acl (src_name, source_desc, dst_name, dest_desc, src_mode) != 0
|
||||
@@ -1046,6 +1131,7 @@ restore_default_fscreatecon_or_die (void)
|
||||
not known. ANCESTORS points to a linked, null terminated list of
|
||||
devices and inodes of parent directories of SRC_NAME. COMMAND_LINE_ARG
|
||||
is true iff SRC_NAME was specified on the command line.
|
||||
FIRST_DIR_CREATED_PER_COMMAND_LINE_ARG is both input and output.
|
||||
Set *COPY_INTO_SELF if SRC_NAME is a parent of (or the
|
||||
same as) DST_NAME; otherwise, clear it.
|
||||
Return true if successful. */
|
||||
@@ -1056,6 +1142,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
struct dir_list *ancestors,
|
||||
const struct cp_options *x,
|
||||
bool command_line_arg,
|
||||
bool *first_dir_created_per_command_line_arg,
|
||||
bool *copy_into_self,
|
||||
bool *rename_succeeded)
|
||||
{
|
||||
@@ -1412,6 +1499,10 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
we can arrange to create a hard link between the corresponding names
|
||||
in the destination tree.
|
||||
|
||||
When using the --link (-l) option, there is no need to take special
|
||||
measures, because (barring race conditions) files that are hard-linked
|
||||
in the source tree will also be hard-linked in the destination tree.
|
||||
|
||||
Sometimes, when preserving links, we have to record dev/ino even
|
||||
though st_nlink == 1:
|
||||
- when in move_mode, since we may be moving a group of N hard-linked
|
||||
@@ -1430,27 +1521,29 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
- likewise for -L except that it applies to all files, not just
|
||||
command line arguments.
|
||||
|
||||
Also record directory dev/ino when using --recursive. We'll use that
|
||||
info to detect this problem: cp -R dir dir. FIXME-maybe: ideally,
|
||||
directory info would be recorded in a separate hash table, since
|
||||
such entries are useful only while a single command line hierarchy
|
||||
is being copied -- so that separate table could be cleared between
|
||||
command line args. Using the same hash table to preserve hard
|
||||
links means that it may not be cleared. */
|
||||
Also, with --recursive, record dev/ino of each command-line directory.
|
||||
We'll use that info to detect this problem: cp -R dir dir. */
|
||||
|
||||
if (x->move_mode && src_sb.st_nlink == 1)
|
||||
{
|
||||
earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev);
|
||||
}
|
||||
else if ((x->preserve_links
|
||||
&& (1 < src_sb.st_nlink
|
||||
|| (command_line_arg
|
||||
&& x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
|
||||
|| x->dereference == DEREF_ALWAYS))
|
||||
|| (x->recursive && S_ISDIR (src_mode)))
|
||||
else if (x->preserve_links
|
||||
&& !x->hard_link
|
||||
&& (1 < src_sb.st_nlink
|
||||
|| (command_line_arg
|
||||
&& x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
|
||||
|| x->dereference == DEREF_ALWAYS))
|
||||
{
|
||||
earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev);
|
||||
}
|
||||
else if (x->recursive && S_ISDIR (src_mode))
|
||||
{
|
||||
if (command_line_arg)
|
||||
earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev);
|
||||
else
|
||||
earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev);
|
||||
}
|
||||
|
||||
/* Did we copy this inode somewhere else (in this command line argument)
|
||||
and therefore this is a second hard link to the inode? */
|
||||
@@ -1638,9 +1731,10 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
{
|
||||
if (setfscreatecon (con) < 0)
|
||||
{
|
||||
error (0, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (con));
|
||||
if (!x->reduce_diagnostics)
|
||||
error (0, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (con));
|
||||
if (x->require_preserve_context)
|
||||
{
|
||||
freecon (con);
|
||||
@@ -1653,9 +1747,10 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
{
|
||||
if (errno != ENOTSUP && errno != ENODATA)
|
||||
{
|
||||
error (0, errno,
|
||||
_("failed to get security context of %s"),
|
||||
quote (src_name));
|
||||
if (!x->reduce_diagnostics)
|
||||
error (0, errno,
|
||||
_("failed to get security context of %s"),
|
||||
quote (src_name));
|
||||
if (x->require_preserve_context)
|
||||
return false;
|
||||
}
|
||||
@@ -1728,11 +1823,15 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
}
|
||||
}
|
||||
|
||||
/* Insert the created directory's inode and device
|
||||
numbers into the search structure, so that we can
|
||||
avoid copying it again. */
|
||||
|
||||
remember_copied (dst_name, dst_sb.st_ino, dst_sb.st_dev);
|
||||
/* Record the created directory's inode and device numbers into
|
||||
the search structure, so that we can avoid copying it again.
|
||||
Do this only for the first directory that is created for each
|
||||
source command line argument. */
|
||||
if (!*first_dir_created_per_command_line_arg)
|
||||
{
|
||||
remember_copied (dst_name, dst_sb.st_ino, dst_sb.st_dev);
|
||||
*first_dir_created_per_command_line_arg = true;
|
||||
}
|
||||
|
||||
if (x->verbose)
|
||||
emit_verbose (src_name, dst_name, NULL);
|
||||
@@ -1751,6 +1850,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
in a source directory would cause the containing destination
|
||||
directory not to have owner/perms set properly. */
|
||||
delayed_ok = copy_dir (src_name, dst_name, new_dst, &src_sb, dir, x,
|
||||
first_dir_created_per_command_line_arg,
|
||||
copy_into_self);
|
||||
}
|
||||
}
|
||||
@@ -1980,6 +2080,10 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
|
||||
set_author (dst_name, -1, &src_sb);
|
||||
|
||||
if (x->preserve_xattr && ! copy_attr_by_name (src_name, dst_name, x)
|
||||
&& x->require_preserve_xattr)
|
||||
return false;
|
||||
|
||||
if (x->preserve_mode || x->move_mode)
|
||||
{
|
||||
if (copy_acl (src_name, -1, dst_name, -1, src_mode) != 0
|
||||
@@ -2094,8 +2198,11 @@ copy (char const *src_name, char const *dst_name,
|
||||
top_level_src_name = src_name;
|
||||
top_level_dst_name = dst_name;
|
||||
|
||||
bool first_dir_created_per_command_line_arg = false;
|
||||
return copy_internal (src_name, dst_name, nonexistent_dst, 0, NULL,
|
||||
options, true, copy_into_self, rename_succeeded);
|
||||
options, true,
|
||||
&first_dir_created_per_command_line_arg,
|
||||
copy_into_self, rename_succeeded);
|
||||
}
|
||||
|
||||
/* Set *X to the default options for a value of type struct cp_options. */
|
||||
|
||||
22
src/copy.h
22
src/copy.h
@@ -1,5 +1,5 @@
|
||||
/* core functions for copying files and directories
|
||||
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
# include <stdbool.h>
|
||||
# include "hash.h"
|
||||
# include "lstat.h"
|
||||
|
||||
/* Control creation of sparse files (files with holes). */
|
||||
enum Sparse_type
|
||||
@@ -174,6 +173,25 @@ struct cp_options
|
||||
fail if it is unable to do so. */
|
||||
bool require_preserve_context;
|
||||
|
||||
/* If true, attempt to preserve extended attributes using libattr.
|
||||
Ignored if coreutils are compiled without xattr support. */
|
||||
bool preserve_xattr;
|
||||
|
||||
/* Useful only when preserve_xattr is true.
|
||||
If true, a failed attempt to preserve file's extended attributes
|
||||
propagates failure "out" to the caller. If false, a failure to
|
||||
preserve file's extended attributes does not change the invoking
|
||||
application's exit status. Give diagnostics for failed syscalls
|
||||
regardless of this setting. For example, with "cp --preserve=xattr"
|
||||
this flag is "true", while with "cp --preserve=all", it is false. */
|
||||
bool require_preserve_xattr;
|
||||
|
||||
/* Used as difference boolean between cp -a and cp -dR --preserve=all.
|
||||
If true, non-mandatory failure diagnostics are not displayed. This
|
||||
should prevent poluting cp -a output.
|
||||
*/
|
||||
bool reduce_diagnostics;
|
||||
|
||||
/* If true, copy directories recursively and copy special files
|
||||
as themselves rather than copying their contents. */
|
||||
bool recursive;
|
||||
|
||||
@@ -19,14 +19,11 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include "same.h"
|
||||
#include "quote.h"
|
||||
#include "hash.h"
|
||||
#include "error.h"
|
||||
#include "cp-hash.h"
|
||||
|
||||
/* Use ST_DEV and ST_INO as the key, FILENAME as the value.
|
||||
@@ -97,24 +94,6 @@ forget_created (ino_t ino, dev_t dev)
|
||||
src_to_dest_free (ent);
|
||||
}
|
||||
|
||||
/* Add FILE to the list of files that we have created.
|
||||
Return true if successful. */
|
||||
|
||||
extern bool
|
||||
remember_created (char const *file)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
if (stat (file, &sb) < 0)
|
||||
{
|
||||
error (0, errno, "%s", quote (file));
|
||||
return false;
|
||||
}
|
||||
|
||||
remember_copied (file, sb.st_ino, sb.st_dev);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* If INO/DEV correspond to an already-copied source file, return the
|
||||
name of the corresponding destination file. Otherwise, return NULL. */
|
||||
|
||||
|
||||
@@ -2,5 +2,4 @@ void hash_init (void);
|
||||
void forget_all (void);
|
||||
void forget_created (ino_t ino, dev_t dev);
|
||||
char *remember_copied (const char *node, ino_t ino, dev_t dev);
|
||||
bool remember_created (char const *file);
|
||||
char *src_to_dest_lookup (ino_t ino, dev_t dev);
|
||||
|
||||
88
src/cp.c
88
src/cp.c
@@ -1,5 +1,5 @@
|
||||
/* cp.c -- file copying (main routines)
|
||||
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-2009 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
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "cp-hash.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "lchmod.h"
|
||||
#include "ignore-value.h"
|
||||
#include "quote.h"
|
||||
#include "stat-time.h"
|
||||
#include "utimens.h"
|
||||
@@ -76,18 +76,11 @@ enum
|
||||
NO_PRESERVE_ATTRIBUTES_OPTION,
|
||||
PARENTS_OPTION,
|
||||
PRESERVE_ATTRIBUTES_OPTION,
|
||||
REPLY_OPTION,
|
||||
SPARSE_OPTION,
|
||||
STRIP_TRAILING_SLASHES_OPTION,
|
||||
UNLINK_DEST_BEFORE_OPENING
|
||||
};
|
||||
|
||||
/* Initial number of entries in each hash table entry's table of inodes. */
|
||||
#define INITIAL_HASH_MODULE 100
|
||||
|
||||
/* Initial number of entries in the inode hash table. */
|
||||
#define INITIAL_ENTRY_TAB_SIZE 70
|
||||
|
||||
/* True if the kernel is SELinux enabled. */
|
||||
static bool selinux_enabled;
|
||||
|
||||
@@ -108,18 +101,6 @@ static enum Sparse_type const sparse_type[] =
|
||||
};
|
||||
ARGMATCH_VERIFY (sparse_type_string, sparse_type);
|
||||
|
||||
/* Valid arguments to the `--reply' option. */
|
||||
static char const* const reply_args[] =
|
||||
{
|
||||
"yes", "no", "query", NULL
|
||||
};
|
||||
/* The values that correspond to the above strings. */
|
||||
static int const reply_vals[] =
|
||||
{
|
||||
I_ALWAYS_YES, I_ALWAYS_NO, I_ASK_USER
|
||||
};
|
||||
ARGMATCH_VERIFY (reply_args, reply_vals);
|
||||
|
||||
static struct option const long_opts[] =
|
||||
{
|
||||
{"archive", no_argument, NULL, 'a'},
|
||||
@@ -129,6 +110,7 @@ static struct option const long_opts[] =
|
||||
{"force", no_argument, NULL, 'f'},
|
||||
{"interactive", no_argument, NULL, 'i'},
|
||||
{"link", no_argument, NULL, 'l'},
|
||||
{"no-clobber", no_argument, NULL, 'n'},
|
||||
{"no-dereference", no_argument, NULL, 'P'},
|
||||
{"no-preserve", required_argument, NULL, NO_PRESERVE_ATTRIBUTES_OPTION},
|
||||
{"no-target-directory", no_argument, NULL, 'T'},
|
||||
@@ -138,8 +120,6 @@ static struct option const long_opts[] =
|
||||
{"preserve", optional_argument, NULL, PRESERVE_ATTRIBUTES_OPTION},
|
||||
{"recursive", no_argument, NULL, 'R'},
|
||||
{"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING},
|
||||
{"reply", required_argument, NULL, REPLY_OPTION}, /* Deprecated 2005-07-03,
|
||||
remove in 2008. */
|
||||
{"sparse", required_argument, NULL, SPARSE_OPTION},
|
||||
{"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
|
||||
{"suffix", required_argument, NULL, 'S'},
|
||||
@@ -174,7 +154,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
|
||||
Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-a, --archive same as -dpR\n\
|
||||
-a, --archive same as -dR --preserve=all\n\
|
||||
--backup[=CONTROL] make a backup of each existing destination file\n\
|
||||
-b like --backup but does not accept an argument\n\
|
||||
--copy-contents copy contents of special files when recursive\n\
|
||||
@@ -182,8 +162,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-f, --force if an existing destination file cannot be\n\
|
||||
opened, remove it and try again\n\
|
||||
-i, --interactive prompt before overwrite\n\
|
||||
opened, remove it and try again (redundant if\n\
|
||||
the -n option is used)\n\
|
||||
-i, --interactive prompt before overwrite (overrides a previous -n\n\
|
||||
option)\n\
|
||||
-H follow command-line symbolic links in SOURCE\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
@@ -191,13 +173,16 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-L, --dereference always follow symbolic links in SOURCE\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-n, --no-clobber do not overwrite an existing file (overrides\n\
|
||||
a previous -i option)\n\
|
||||
-P, --no-dereference never follow symbolic links in SOURCE\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-p same as --preserve=mode,ownership,timestamps\n\
|
||||
--preserve[=ATTR_LIST] preserve the specified attributes (default:\n\
|
||||
mode,ownership,timestamps), if possible\n\
|
||||
additional attributes: context, links, all\n\
|
||||
additional attributes: context, links, xattr,\n\
|
||||
all\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--no-preserve=ATTR_LIST don't preserve the specified attributes\n\
|
||||
@@ -326,7 +311,7 @@ re_protect (char const *const_dst_name, size_t src_offset,
|
||||
}
|
||||
/* Failing to preserve ownership is OK. Still, try to preserve
|
||||
the group, but ignore the possible error. */
|
||||
(void) lchown (dst_name, -1, p->st.st_gid);
|
||||
ignore_value (lchown (dst_name, -1, p->st.st_gid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -774,6 +759,9 @@ cp_option_init (struct cp_options *x)
|
||||
x->preserve_timestamps = false;
|
||||
x->preserve_security_context = false;
|
||||
x->require_preserve_context = false;
|
||||
x->preserve_xattr = false;
|
||||
x->reduce_diagnostics = false;
|
||||
x->require_preserve_xattr = false;
|
||||
|
||||
x->require_preserve = false;
|
||||
x->recursive = false;
|
||||
@@ -810,18 +798,20 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off)
|
||||
PRESERVE_OWNERSHIP,
|
||||
PRESERVE_LINK,
|
||||
PRESERVE_CONTEXT,
|
||||
PRESERVE_XATTR,
|
||||
PRESERVE_ALL
|
||||
};
|
||||
static enum File_attribute const preserve_vals[] =
|
||||
{
|
||||
PRESERVE_MODE, PRESERVE_TIMESTAMPS,
|
||||
PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_ALL
|
||||
PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_XATTR,
|
||||
PRESERVE_ALL
|
||||
};
|
||||
/* Valid arguments to the `--preserve' option. */
|
||||
static char const* const preserve_args[] =
|
||||
{
|
||||
"mode", "timestamps",
|
||||
"ownership", "links", "context", "all", NULL
|
||||
"ownership", "links", "context", "xattr", "all", NULL
|
||||
};
|
||||
ARGMATCH_VERIFY (preserve_args, preserve_vals);
|
||||
|
||||
@@ -862,6 +852,11 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off)
|
||||
x->require_preserve_context = on_off;
|
||||
break;
|
||||
|
||||
case PRESERVE_XATTR:
|
||||
x->preserve_xattr = on_off;
|
||||
x->require_preserve_xattr = on_off;
|
||||
break;
|
||||
|
||||
case PRESERVE_ALL:
|
||||
x->preserve_mode = on_off;
|
||||
x->preserve_timestamps = on_off;
|
||||
@@ -869,6 +864,7 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off)
|
||||
x->preserve_links = on_off;
|
||||
if (selinux_enabled)
|
||||
x->preserve_security_context = on_off;
|
||||
x->preserve_xattr = on_off;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -909,7 +905,7 @@ main (int argc, char **argv)
|
||||
we'll actually use backup_suffix_string. */
|
||||
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abdfHilLprst:uvxPRS:T",
|
||||
while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:T",
|
||||
long_opts, NULL))
|
||||
!= -1)
|
||||
{
|
||||
@@ -920,13 +916,17 @@ main (int argc, char **argv)
|
||||
sparse_type_string, sparse_type);
|
||||
break;
|
||||
|
||||
case 'a': /* Like -dpR. */
|
||||
case 'a': /* Like -dR --preserve=all with reduced failure diagnostics. */
|
||||
x.dereference = DEREF_NEVER;
|
||||
x.preserve_links = true;
|
||||
x.preserve_ownership = true;
|
||||
x.preserve_mode = true;
|
||||
x.preserve_timestamps = true;
|
||||
x.require_preserve = true;
|
||||
if (selinux_enabled)
|
||||
x.preserve_security_context = true;
|
||||
x.preserve_xattr = true;
|
||||
x.reduce_diagnostics = true;
|
||||
x.recursive = true;
|
||||
break;
|
||||
|
||||
@@ -965,6 +965,10 @@ main (int argc, char **argv)
|
||||
x.dereference = DEREF_ALWAYS;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
x.interactive = I_ALWAYS_NO;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
x.dereference = DEREF_NEVER;
|
||||
break;
|
||||
@@ -1001,13 +1005,6 @@ main (int argc, char **argv)
|
||||
x.recursive = true;
|
||||
break;
|
||||
|
||||
case REPLY_OPTION: /* Deprecated */
|
||||
x.interactive = XARGMATCH ("--reply", optarg,
|
||||
reply_args, reply_vals);
|
||||
error (0, 0,
|
||||
_("the --reply option is deprecated; use -i or -f instead"));
|
||||
break;
|
||||
|
||||
case UNLINK_DEST_BEFORE_OPENING:
|
||||
x.unlink_dest_before_opening = true;
|
||||
break;
|
||||
@@ -1072,6 +1069,13 @@ main (int argc, char **argv)
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (make_backups && x.interactive == I_ALWAYS_NO)
|
||||
{
|
||||
error (0, 0,
|
||||
_("options --backup and --no-clobber are mutually exclusive"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (backup_suffix_string)
|
||||
simple_backup_suffix = xstrdup (backup_suffix_string);
|
||||
|
||||
@@ -1105,6 +1109,12 @@ main (int argc, char **argv)
|
||||
"without an SELinux-enabled kernel"));
|
||||
}
|
||||
|
||||
#if !USE_XATTR
|
||||
if (x.require_preserve_xattr)
|
||||
error (EXIT_FAILURE, 0, _("cannot preserve extended attributes, cp is "
|
||||
"built without xattr support"));
|
||||
#endif
|
||||
|
||||
/* Allocate space for remembering copied and created files. */
|
||||
|
||||
hash_init ();
|
||||
|
||||
35
src/csplit.c
35
src/csplit.c
@@ -1,5 +1,5 @@
|
||||
/* csplit - split a file into sections determined by context lines
|
||||
Copyright (C) 91, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-2009 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
|
||||
@@ -34,17 +34,6 @@
|
||||
#include "stdio--.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
|
||||
present. */
|
||||
#ifndef SA_NOCLDSTOP
|
||||
# define SA_NOCLDSTOP 0
|
||||
# define sigprocmask(How, Set, Oset) /* empty */
|
||||
# define sigset_t int
|
||||
# if ! HAVE_SIGINTERRUPT
|
||||
# define siginterrupt(sig, flag) /* empty */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "csplit"
|
||||
|
||||
@@ -52,9 +41,6 @@
|
||||
proper_name ("Stuart Kemp"), \
|
||||
proper_name ("David MacKenzie")
|
||||
|
||||
/* Increment size of area for control records. */
|
||||
#define ALLOC_SIZE 20
|
||||
|
||||
/* The default prefix for output file names. */
|
||||
#define DEFAULT_PREFIX "xx"
|
||||
|
||||
@@ -238,12 +224,10 @@ xalloc_die (void)
|
||||
static void
|
||||
interrupt_handler (int sig)
|
||||
{
|
||||
if (! SA_NOCLDSTOP)
|
||||
signal (sig, SIG_IGN);
|
||||
|
||||
delete_all_files (true);
|
||||
|
||||
signal (sig, SIG_DFL);
|
||||
/* The signal has been reset to SIG_DFL, but blocked during this
|
||||
handler. Force the default action of this signal once the
|
||||
handler returns and the block is removed. */
|
||||
raise (sig);
|
||||
}
|
||||
|
||||
@@ -1421,7 +1405,6 @@ main (int argc, char **argv)
|
||||
};
|
||||
enum { nsigs = sizeof sig / sizeof sig[0] };
|
||||
|
||||
#if SA_NOCLDSTOP
|
||||
struct sigaction act;
|
||||
|
||||
sigemptyset (&caught_signals);
|
||||
@@ -1434,19 +1417,11 @@ main (int argc, char **argv)
|
||||
|
||||
act.sa_handler = interrupt_handler;
|
||||
act.sa_mask = caught_signals;
|
||||
act.sa_flags = 0;
|
||||
act.sa_flags = SA_NODEFER | SA_RESETHAND;
|
||||
|
||||
for (i = 0; i < nsigs; i++)
|
||||
if (sigismember (&caught_signals, sig[i]))
|
||||
sigaction (sig[i], &act, NULL);
|
||||
#else
|
||||
for (i = 0; i < nsigs; i++)
|
||||
if (signal (sig[i], SIG_IGN) != SIG_IGN)
|
||||
{
|
||||
signal (sig[i], interrupt_handler);
|
||||
siginterrupt (sig[i], 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
split_file ();
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
|
||||
#define AUTHORS proper_name ("David MacKenzie")
|
||||
|
||||
int putenv ();
|
||||
|
||||
static bool show_date (const char *format, struct timespec when);
|
||||
|
||||
enum Time_spec
|
||||
@@ -385,7 +383,7 @@ main (int argc, char **argv)
|
||||
/* POSIX says that `date -u' is equivalent to setting the TZ
|
||||
environment variable, so this option should do nothing other
|
||||
than setting TZ. */
|
||||
if (putenv ("TZ=UTC0") != 0)
|
||||
if (putenv (bad_cast ("TZ=UTC0")) != 0)
|
||||
xalloc_die ();
|
||||
TZSET;
|
||||
break;
|
||||
|
||||
143
src/dd.c
143
src/dd.c
@@ -1,5 +1,5 @@
|
||||
/* dd -- convert a file while copying it.
|
||||
Copyright (C) 85, 90, 91, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 85, 90, 91, 1995-2009 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
|
||||
@@ -66,11 +66,16 @@ static void process_signals (void);
|
||||
# define SIGINFO SIGUSR1
|
||||
#endif
|
||||
|
||||
/* This may belong in GNULIB's fcntl module instead.
|
||||
Define O_CIO to 0 if it is not supported by this OS. */
|
||||
#ifndef O_CIO
|
||||
# define O_CIO 0
|
||||
#endif
|
||||
|
||||
#if ! HAVE_FDATASYNC
|
||||
# define fdatasync(fd) (errno = ENOSYS, -1)
|
||||
#endif
|
||||
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define output_char(c) \
|
||||
do \
|
||||
{ \
|
||||
@@ -194,8 +199,7 @@ static bool input_seekable;
|
||||
static int input_seek_errno;
|
||||
|
||||
/* File offset of the input, in bytes, along with a flag recording
|
||||
whether it overflowed. The offset is valid only if the input is
|
||||
seekable and if the offset has not overflowed. */
|
||||
whether it overflowed. */
|
||||
static uintmax_t input_offset;
|
||||
static bool input_offset_overflow;
|
||||
|
||||
@@ -261,21 +265,28 @@ static struct symbol_value const conversions[] =
|
||||
|
||||
enum
|
||||
{
|
||||
/* Use a value that is larger than that of any other O_ symbol. */
|
||||
O_FULLBLOCK = ((MAX (O_APPEND,
|
||||
MAX (O_BINARY,
|
||||
MAX (O_DIRECT,
|
||||
MAX (O_DIRECTORY,
|
||||
MAX (O_DSYNC,
|
||||
MAX (O_NOATIME,
|
||||
MAX (O_NOCTTY,
|
||||
MAX (O_NOFOLLOW,
|
||||
MAX (O_NOLINKS,
|
||||
MAX (O_NONBLOCK,
|
||||
MAX (O_SYNC, O_TEXT)))))))))))) << 1)
|
||||
/* Compute a value that's bitwise disjoint from the union
|
||||
of all O_ values. */
|
||||
v = ~(0
|
||||
| O_APPEND
|
||||
| O_BINARY
|
||||
| O_CIO
|
||||
| O_DIRECT
|
||||
| O_DIRECTORY
|
||||
| O_DSYNC
|
||||
| O_NOATIME
|
||||
| O_NOCTTY
|
||||
| O_NOFOLLOW
|
||||
| O_NOLINKS
|
||||
| O_NONBLOCK
|
||||
| O_SYNC
|
||||
| O_TEXT
|
||||
),
|
||||
/* Use its lowest bit. */
|
||||
O_FULLBLOCK = v ^ (v & (v - 1))
|
||||
};
|
||||
|
||||
/* Ensure that we didn't shift it off the end. */
|
||||
/* Ensure that we got something. */
|
||||
verify (O_FULLBLOCK != 0);
|
||||
|
||||
#define MULTIPLE_BITS_SET(i) (((i) & ((i) - 1)) != 0)
|
||||
@@ -288,6 +299,7 @@ static struct symbol_value const flags[] =
|
||||
{
|
||||
{"append", O_APPEND},
|
||||
{"binary", O_BINARY},
|
||||
{"cio", O_CIO},
|
||||
{"direct", O_DIRECT},
|
||||
{"directory", O_DIRECTORY},
|
||||
{"dsync", O_DSYNC},
|
||||
@@ -455,16 +467,16 @@ Usage: %s [OPERAND]...\n\
|
||||
fputs (_("\
|
||||
Copy a file, converting and formatting according to the operands.\n\
|
||||
\n\
|
||||
bs=BYTES force ibs=BYTES and obs=BYTES\n\
|
||||
bs=BYTES read and write BYTES bytes at a time (also see ibs=,obs=)\n\
|
||||
cbs=BYTES convert BYTES bytes at a time\n\
|
||||
conv=CONVS convert the file as per the comma separated symbol list\n\
|
||||
count=BLOCKS copy only BLOCKS input blocks\n\
|
||||
ibs=BYTES read BYTES bytes at a time\n\
|
||||
ibs=BYTES read BYTES bytes at a time (default: 512)\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
if=FILE read from FILE instead of stdin\n\
|
||||
iflag=FLAGS read as per the comma separated symbol list\n\
|
||||
obs=BYTES write BYTES bytes at a time\n\
|
||||
obs=BYTES write BYTES bytes at a time (default: 512)\n\
|
||||
of=FILE write to FILE instead of stdout\n\
|
||||
oflag=FLAGS write as per the comma separated symbol list\n\
|
||||
seek=BLOCKS skip BLOCKS obs-sized blocks at start of output\n\
|
||||
@@ -508,6 +520,8 @@ Each FLAG symbol may be:\n\
|
||||
\n\
|
||||
append append mode (makes sense only for output; conv=notrunc suggested)\n\
|
||||
"), stdout);
|
||||
if (O_CIO)
|
||||
fputs (_(" cio use concurrent I/O for data\n"), stdout);
|
||||
if (O_DIRECT)
|
||||
fputs (_(" direct use direct I/O for data\n"), stdout);
|
||||
if (O_DIRECTORY)
|
||||
@@ -659,7 +673,7 @@ cleanup (void)
|
||||
_("closing output file %s"), quote (output_file));
|
||||
}
|
||||
|
||||
static inline void ATTRIBUTE_NORETURN
|
||||
static void ATTRIBUTE_NORETURN
|
||||
quit (int code)
|
||||
{
|
||||
cleanup ();
|
||||
@@ -998,13 +1012,11 @@ scanargs (int argc, char *const *argv)
|
||||
{
|
||||
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP));
|
||||
input_blocksize = n;
|
||||
conversions_mask |= C_TWOBUFS;
|
||||
}
|
||||
else if (operand_is (name, "obs"))
|
||||
{
|
||||
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (OUTPUT_BLOCK_SLOP));
|
||||
output_blocksize = n;
|
||||
conversions_mask |= C_TWOBUFS;
|
||||
}
|
||||
else if (operand_is (name, "bs"))
|
||||
{
|
||||
@@ -1035,12 +1047,13 @@ scanargs (int argc, char *const *argv)
|
||||
|
||||
if (blocksize)
|
||||
input_blocksize = output_blocksize = blocksize;
|
||||
else
|
||||
{
|
||||
/* POSIX says dd aggregates short reads into
|
||||
output_blocksize if bs= is not specified. */
|
||||
conversions_mask |= C_TWOBUFS;
|
||||
}
|
||||
|
||||
/* If bs= was given, both `input_blocksize' and `output_blocksize' will
|
||||
have been set to positive values. If either has not been set,
|
||||
bs= was not given, so make sure two buffers are used. */
|
||||
if (input_blocksize == 0 || output_blocksize == 0)
|
||||
conversions_mask |= C_TWOBUFS;
|
||||
if (input_blocksize == 0)
|
||||
input_blocksize = DEFAULT_BLOCKSIZE;
|
||||
if (output_blocksize == 0)
|
||||
@@ -1249,12 +1262,62 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize,
|
||||
&& 0 <= skip_via_lseek (file, fdesc, offset, SEEK_CUR))
|
||||
{
|
||||
if (fdesc == STDIN_FILENO)
|
||||
advance_input_offset (offset);
|
||||
return 0;
|
||||
{
|
||||
struct stat st;
|
||||
if (fstat (STDIN_FILENO, &st) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot fstat %s"), quote (file));
|
||||
if (S_ISREG (st.st_mode) && st.st_size < (input_offset + offset))
|
||||
{
|
||||
/* When skipping past EOF, return the number of _full_ blocks
|
||||
* that are not skipped, and set offset to EOF, so the caller
|
||||
* can determine the requested skip was not satisfied. */
|
||||
records = ( offset - st.st_size ) / blocksize;
|
||||
offset = st.st_size - input_offset;
|
||||
}
|
||||
else
|
||||
records = 0;
|
||||
advance_input_offset (offset);
|
||||
}
|
||||
else
|
||||
records = 0;
|
||||
return records;
|
||||
}
|
||||
else
|
||||
{
|
||||
int lseek_errno = errno;
|
||||
off_t soffset;
|
||||
|
||||
/* The seek request may have failed above if it was too big
|
||||
(> device size, > max file size, etc.)
|
||||
Or it may not have been done at all (> OFF_T_MAX).
|
||||
Therefore try to seek to the end of the file,
|
||||
to avoid redundant reading. */
|
||||
if ((soffset = skip_via_lseek (file, fdesc, 0, SEEK_END)) >= 0)
|
||||
{
|
||||
/* File is seekable, and we're at the end of it, and
|
||||
size <= OFF_T_MAX. So there's no point using read to advance. */
|
||||
|
||||
if (!lseek_errno)
|
||||
{
|
||||
/* The original seek was not attempted as offset > OFF_T_MAX.
|
||||
We should error for write as can't get to the desired
|
||||
location, even if OFF_T_MAX < max file size.
|
||||
For read we're not going to read any data anyway,
|
||||
so we should error for consistency.
|
||||
It would be nice to not error for /dev/{zero,null}
|
||||
for any offset, but that's not a significant issue. */
|
||||
lseek_errno = EOVERFLOW;
|
||||
}
|
||||
|
||||
if (fdesc == STDIN_FILENO)
|
||||
error (0, lseek_errno, _("%s: cannot skip"), quote (file));
|
||||
else
|
||||
error (0, lseek_errno, _("%s: cannot seek"), quote (file));
|
||||
/* If the file has a specific size and we've asked
|
||||
to skip/seek beyond the max allowable, then quit. */
|
||||
quit (EXIT_FAILURE);
|
||||
}
|
||||
/* else file_size && offset > OFF_T_MAX or file ! seekable */
|
||||
|
||||
do
|
||||
{
|
||||
@@ -1527,10 +1590,22 @@ dd_copy (void)
|
||||
|
||||
if (skip_records != 0)
|
||||
{
|
||||
skip (STDIN_FILENO, input_file, skip_records, input_blocksize, ibuf);
|
||||
uintmax_t us_bytes = input_offset + (skip_records * input_blocksize);
|
||||
uintmax_t us_blocks = skip (STDIN_FILENO, input_file,
|
||||
skip_records, input_blocksize, ibuf);
|
||||
us_bytes -= input_offset;
|
||||
|
||||
/* POSIX doesn't say what to do when dd detects it has been
|
||||
asked to skip past EOF, so I assume it's non-fatal if the
|
||||
call to 'skip' returns nonzero. FIXME: maybe give a warning. */
|
||||
asked to skip past EOF, so I assume it's non-fatal.
|
||||
There are 3 reasons why there might be unskipped blocks/bytes:
|
||||
1. file is too small
|
||||
2. pipe has not enough data
|
||||
3. short reads */
|
||||
if (us_blocks || (!input_offset_overflow && us_bytes))
|
||||
{
|
||||
error (0, 0,
|
||||
_("%s: cannot skip to specified offset"), quote (input_file));
|
||||
}
|
||||
}
|
||||
|
||||
if (seek_records != 0)
|
||||
@@ -1768,7 +1843,7 @@ main (int argc, char **argv)
|
||||
|
||||
offset = lseek (STDIN_FILENO, 0, SEEK_CUR);
|
||||
input_seekable = (0 <= offset);
|
||||
input_offset = offset;
|
||||
input_offset = MAX(0, offset);
|
||||
input_seek_errno = errno;
|
||||
|
||||
if (output_file == NULL)
|
||||
|
||||
39
src/df.c
39
src/df.c
@@ -231,18 +231,28 @@ excluded_fstype (const char *fstype)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return true if N is a known integer value. On many file systems,
|
||||
UINTMAX_MAX represents an unknown value; on AIX, UINTMAX_MAX - 1
|
||||
represents unknown. Use a rule that works on AIX file systems, and
|
||||
that almost-always works on other types. */
|
||||
static bool
|
||||
known_value (uintmax_t n)
|
||||
{
|
||||
return n < UINTMAX_MAX - 1;
|
||||
}
|
||||
|
||||
/* Like human_readable (N, BUF, human_output_opts, INPUT_UNITS, OUTPUT_UNITS),
|
||||
except:
|
||||
|
||||
- If NEGATIVE, then N represents a negative number,
|
||||
expressed in two's complement.
|
||||
- Otherwise, return "-" if N is UINTMAX_MAX. */
|
||||
- Otherwise, return "-" if N is unknown. */
|
||||
|
||||
static char const *
|
||||
df_readable (bool negative, uintmax_t n, char *buf,
|
||||
uintmax_t input_units, uintmax_t output_units)
|
||||
{
|
||||
if (n == UINTMAX_MAX && !negative)
|
||||
if (! known_value (n) && !negative)
|
||||
return "-";
|
||||
else
|
||||
{
|
||||
@@ -393,8 +403,10 @@ show_dev (char const *disk, char const *mount_point,
|
||||
negate_available = false;
|
||||
available_to_root = available;
|
||||
|
||||
grand_fsu.fsu_files += total;
|
||||
grand_fsu.fsu_ffree += available;
|
||||
if (known_value (total))
|
||||
grand_fsu.fsu_files += total;
|
||||
if (known_value (available))
|
||||
grand_fsu.fsu_ffree += available;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -419,19 +431,22 @@ show_dev (char const *disk, char const *mount_point,
|
||||
total = fsu.fsu_blocks;
|
||||
available = fsu.fsu_bavail;
|
||||
negate_available = (fsu.fsu_bavail_top_bit_set
|
||||
& (available != UINTMAX_MAX));
|
||||
& known_value (available));
|
||||
available_to_root = fsu.fsu_bfree;
|
||||
|
||||
grand_fsu.fsu_blocks += input_units * total;
|
||||
grand_fsu.fsu_bfree += input_units * available_to_root;
|
||||
add_uint_with_neg_flag (&grand_fsu.fsu_bavail,
|
||||
&grand_fsu.fsu_bavail_top_bit_set,
|
||||
input_units * available, negate_available);
|
||||
if (known_value (total))
|
||||
grand_fsu.fsu_blocks += input_units * total;
|
||||
if (known_value (available_to_root))
|
||||
grand_fsu.fsu_bfree += input_units * available_to_root;
|
||||
if (known_value (available))
|
||||
add_uint_with_neg_flag (&grand_fsu.fsu_bavail,
|
||||
&grand_fsu.fsu_bavail_top_bit_set,
|
||||
input_units * available, negate_available);
|
||||
}
|
||||
|
||||
used = UINTMAX_MAX;
|
||||
negate_used = false;
|
||||
if (total != UINTMAX_MAX && available_to_root != UINTMAX_MAX)
|
||||
if (known_value (total) && known_value (available_to_root))
|
||||
{
|
||||
used = total - available_to_root;
|
||||
negate_used = (total < available_to_root);
|
||||
@@ -446,7 +461,7 @@ show_dev (char const *disk, char const *mount_point,
|
||||
width, df_readable (negate_available, available,
|
||||
buf[2], input_units, output_units));
|
||||
|
||||
if (used == UINTMAX_MAX || available == UINTMAX_MAX)
|
||||
if (! known_value (used) || ! known_value (available))
|
||||
;
|
||||
else if (!negate_used
|
||||
&& used <= TYPE_MAXIMUM (uintmax_t) / 100
|
||||
|
||||
@@ -63,14 +63,15 @@ static const char *const slack_codes[] =
|
||||
"SYMLINK", "ORPHAN", "MISSING", "FIFO", "PIPE", "SOCK", "BLK", "BLOCK",
|
||||
"CHR", "CHAR", "DOOR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE",
|
||||
"END", "ENDCODE", "SUID", "SETUID", "SGID", "SETGID", "STICKY",
|
||||
"OTHER_WRITABLE", "OWR", "STICKY_OTHER_WRITABLE", "OWT", "CAPABILITY", NULL
|
||||
"OTHER_WRITABLE", "OWR", "STICKY_OTHER_WRITABLE", "OWT", "CAPABILITY",
|
||||
"HARDLINK", "CLRTOEOL", NULL
|
||||
};
|
||||
|
||||
static const char *const ls_codes[] =
|
||||
{
|
||||
"no", "no", "fi", "rs", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi",
|
||||
"so", "bd", "bd", "cd", "cd", "do", "ex", "lc", "lc", "rc", "rc", "ec", "ec",
|
||||
"su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", "ca", NULL
|
||||
"su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", "ca", "hl", "cl", NULL
|
||||
};
|
||||
#define array_len(Array) (sizeof (Array) / sizeof *(Array))
|
||||
verify (array_len (slack_codes) == array_len (ls_codes));
|
||||
|
||||
@@ -69,6 +69,7 @@ RESET 0 # reset to "normal" color
|
||||
DIR 01;34 # directory
|
||||
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
|
||||
# numerical value, the color is as for the file pointed to.)
|
||||
HARDLINK 44;37 # regular file with more than one link
|
||||
FIFO 40;33 # pipe
|
||||
SOCK 01;35 # socket
|
||||
DOOR 01;35 # door
|
||||
|
||||
172
src/du.c
172
src/du.c
@@ -1,5 +1,5 @@
|
||||
/* du -- summarize disk usage
|
||||
Copyright (C) 1988-1991, 1995-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-1991, 1995-2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <assert.h>
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "argv-iter.h"
|
||||
#include "error.h"
|
||||
#include "exclude.h"
|
||||
#include "fprintftime.h"
|
||||
@@ -37,7 +38,6 @@
|
||||
#include "human.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "readtokens0.h"
|
||||
#include "same.h"
|
||||
#include "stat-time.h"
|
||||
#include "xfts.h"
|
||||
@@ -292,9 +292,9 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--files0-from=F summarize disk usage of the NUL-terminated file\n\
|
||||
names specified in file F\n\
|
||||
-H like --si, but also evokes a warning; will soon\n\
|
||||
change to be equivalent to --dereference-args (-D)\n\
|
||||
names specified in file F;\n\
|
||||
If F is - then read names from standard input\n\
|
||||
-H equivalent to --dereference-args (-D)\n\
|
||||
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
|
||||
--si like -h, but use powers of 1000 not 1024\n\
|
||||
"), stdout);
|
||||
@@ -648,9 +648,6 @@ du_files (char **files, int bit_flags)
|
||||
fts_close (fts);
|
||||
}
|
||||
|
||||
if (print_grand_total)
|
||||
print_size (&tot_dui, _("total"));
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -659,13 +656,11 @@ main (int argc, char **argv)
|
||||
{
|
||||
char *cwd_only[2];
|
||||
bool max_depth_specified = false;
|
||||
char **files;
|
||||
bool ok = true;
|
||||
char *files_from = NULL;
|
||||
struct Tokens tok;
|
||||
|
||||
/* Bit flags that control how fts works. */
|
||||
int bit_flags = FTS_TIGHT_CYCLE_CHECK;
|
||||
int bit_flags = FTS_TIGHT_CYCLE_CHECK | FTS_DEFER_STAT;
|
||||
|
||||
/* Select one of the three FTS_ options that control if/when
|
||||
to follow a symlink. */
|
||||
@@ -674,7 +669,7 @@ main (int argc, char **argv)
|
||||
/* If true, display only a total for each argument. */
|
||||
bool opt_summarize_only = false;
|
||||
|
||||
cwd_only[0] = ".";
|
||||
cwd_only[0] = bad_cast (".");
|
||||
cwd_only[1] = NULL;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -733,11 +728,6 @@ main (int argc, char **argv)
|
||||
output_block_size = 1;
|
||||
break;
|
||||
|
||||
case 'H': /* FIXME: remove warning and move this "case 'H'" to
|
||||
precede --dereference-args in late 2006. */
|
||||
error (0, 0, _("WARNING: use --si, not -H; the meaning of the -H\
|
||||
option will soon\nchange to be the same as that of --dereference-args (-D)"));
|
||||
/* fall through */
|
||||
case HUMAN_SI_OPTION:
|
||||
human_output_opts = human_autoscale | human_SI;
|
||||
output_block_size = 1;
|
||||
@@ -766,7 +756,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case MEGABYTES_LONG_OPTION:
|
||||
case MEGABYTES_LONG_OPTION: /* FIXME: remove in 2009 */
|
||||
error (0, 0,
|
||||
_("the --megabytes option is deprecated; use -m instead"));
|
||||
/* fall through */
|
||||
@@ -796,7 +786,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D': /* This will eventually be 'H' (-H), too. */
|
||||
case 'H': /* NOTE: before 2008-12, -H was equivalent to --si. */
|
||||
case 'D':
|
||||
symlink_deref_bits = FTS_COMFOLLOW | FTS_PHYSICAL;
|
||||
break;
|
||||
|
||||
@@ -925,6 +916,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
struct argv_iterator *ai;
|
||||
if (files_from)
|
||||
{
|
||||
/* When using --files0-from=F, you may not specify any files
|
||||
@@ -941,78 +933,96 @@ main (int argc, char **argv)
|
||||
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quote (files_from));
|
||||
|
||||
readtokens0_init (&tok);
|
||||
|
||||
if (! readtokens0 (stdin, &tok) || fclose (stdin) != 0)
|
||||
error (EXIT_FAILURE, 0, _("cannot read file names from %s"),
|
||||
quote (files_from));
|
||||
|
||||
files = tok.tok;
|
||||
ai = argv_iter_init_stream (stdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
files = (optind < argc ? argv + optind : cwd_only);
|
||||
char **files = (optind < argc ? argv + optind : cwd_only);
|
||||
ai = argv_iter_init_argv (files);
|
||||
}
|
||||
|
||||
if (!ai)
|
||||
xalloc_die ();
|
||||
|
||||
/* Initialize the hash structure for inode numbers. */
|
||||
hash_init ();
|
||||
|
||||
/* Report and filter out any empty file names before invoking fts.
|
||||
This works around a glitch in fts, which fails immediately
|
||||
(without looking at the other file names) when given an empty
|
||||
file name. */
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t j;
|
||||
|
||||
for (j = 0; ; j++)
|
||||
{
|
||||
if (i != j)
|
||||
files[i] = files[j];
|
||||
|
||||
if ( ! files[i])
|
||||
break;
|
||||
|
||||
if (files_from && STREQ (files_from, "-") && STREQ (files[i], "-"))
|
||||
{
|
||||
/* Give a better diagnostic in an unusual case:
|
||||
printf - | du --files0-from=- */
|
||||
error (0, 0, _("when reading file names from stdin, "
|
||||
"no file name of %s allowed"),
|
||||
quote ("-"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (files[i][0])
|
||||
i++;
|
||||
else
|
||||
{
|
||||
/* Diagnose a zero-length file name. When it's one
|
||||
among many, knowing the record number may help. */
|
||||
if (files_from)
|
||||
{
|
||||
/* Using the standard `filename:line-number:' prefix here is
|
||||
not totally appropriate, since NUL is the separator, not NL,
|
||||
but it might be better than nothing. */
|
||||
unsigned long int file_number = j + 1;
|
||||
error (0, 0, "%s:%lu: %s", quotearg_colon (files_from),
|
||||
file_number, _("invalid zero-length file name"));
|
||||
}
|
||||
else
|
||||
error (0, 0, "%s", _("invalid zero-length file name"));
|
||||
}
|
||||
}
|
||||
|
||||
ok = (i == j);
|
||||
}
|
||||
|
||||
bit_flags |= symlink_deref_bits;
|
||||
ok &= du_files (files, bit_flags);
|
||||
static char *temp_argv[] = { NULL, NULL };
|
||||
|
||||
/* This isn't really necessary, but it does ensure we
|
||||
exercise this function. */
|
||||
if (files_from)
|
||||
readtokens0_free (&tok);
|
||||
while (true)
|
||||
{
|
||||
bool skip_file = false;
|
||||
enum argv_iter_err ai_err;
|
||||
char *file_name = argv_iter (ai, &ai_err);
|
||||
if (ai_err == AI_ERR_EOF)
|
||||
break;
|
||||
if (!file_name)
|
||||
{
|
||||
switch (ai_err)
|
||||
{
|
||||
case AI_ERR_READ:
|
||||
error (0, errno, _("%s: read error"), quote (files_from));
|
||||
skip_file = true;
|
||||
continue;
|
||||
|
||||
case AI_ERR_MEM:
|
||||
xalloc_die ();
|
||||
|
||||
default:
|
||||
assert (!"unexpected error code from argv_iter");
|
||||
}
|
||||
}
|
||||
if (files_from && STREQ (files_from, "-") && STREQ (file_name, "-"))
|
||||
{
|
||||
/* Give a better diagnostic in an unusual case:
|
||||
printf - | du --files0-from=- */
|
||||
error (0, 0, _("when reading file names from stdin, "
|
||||
"no file name of %s allowed"),
|
||||
quote (file_name));
|
||||
skip_file = true;
|
||||
}
|
||||
|
||||
/* Report and skip any empty file names before invoking fts.
|
||||
This works around a glitch in fts, which fails immediately
|
||||
(without looking at the other file names) when given an empty
|
||||
file name. */
|
||||
if (!file_name[0])
|
||||
{
|
||||
/* Diagnose a zero-length file name. When it's one
|
||||
among many, knowing the record number may help.
|
||||
FIXME: currently print the record number only with
|
||||
--files0-from=FILE. Maybe do it for argv, too? */
|
||||
if (files_from == NULL)
|
||||
error (0, 0, "%s", _("invalid zero-length file name"));
|
||||
else
|
||||
{
|
||||
/* Using the standard `filename:line-number:' prefix here is
|
||||
not totally appropriate, since NUL is the separator, not NL,
|
||||
but it might be better than nothing. */
|
||||
unsigned long int file_number = argv_iter_n_args (ai);
|
||||
error (0, 0, "%s:%lu: %s", quotearg_colon (files_from),
|
||||
file_number, _("invalid zero-length file name"));
|
||||
}
|
||||
skip_file = true;
|
||||
}
|
||||
|
||||
if (skip_file)
|
||||
ok = false;
|
||||
else
|
||||
{
|
||||
temp_argv[0] = file_name;
|
||||
ok &= du_files (temp_argv, bit_flags);
|
||||
}
|
||||
}
|
||||
|
||||
argv_iter_free (ai);
|
||||
|
||||
if (files_from && (ferror (stdin) || fclose (stdin) != 0))
|
||||
error (EXIT_FAILURE, 0, _("error reading %s"), quote (files_from));
|
||||
|
||||
if (print_grand_total)
|
||||
print_size (&tot_dui, _("total"));
|
||||
|
||||
hash_free (htab);
|
||||
|
||||
|
||||
25
src/echo.c
25
src/echo.c
@@ -1,5 +1,5 @@
|
||||
/* echo.c, derived from code echo.c in Bash.
|
||||
Copyright (C) 87,89, 1991-1997, 1999-2005, 2007-2008 Free Software
|
||||
Copyright (C) 87,89, 1991-1997, 1999-2005, 2007-2009 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "echo"
|
||||
@@ -41,7 +40,10 @@ usage (int status)
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf (_("Usage: %s [OPTION]... [STRING]...\n"), program_name);
|
||||
printf (_("\
|
||||
Usage: %s [SHORT-OPTION]... [STRING]...\n\
|
||||
or: %s LONG-OPTION\n\
|
||||
"), program_name, program_name);
|
||||
fputs (_("\
|
||||
Echo the STRING(s) to standard output.\n\
|
||||
\n\
|
||||
@@ -121,9 +123,20 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
if (allow_options)
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
/* We directly parse options, rather than use parse_long_options, in
|
||||
order to avoid accepting abbreviations. */
|
||||
if (allow_options && argc == 2)
|
||||
{
|
||||
if (STREQ (argv[1], "--help"))
|
||||
usage (EXIT_SUCCESS);
|
||||
|
||||
if (STREQ (argv[1], "--version"))
|
||||
{
|
||||
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
|
||||
(char *) NULL);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
--argc;
|
||||
++argv;
|
||||
|
||||
@@ -91,8 +91,6 @@
|
||||
proper_name ("Richard Mlynarik"), \
|
||||
proper_name ("David MacKenzie")
|
||||
|
||||
int putenv ();
|
||||
|
||||
extern char **environ;
|
||||
|
||||
static struct option const longopts[] =
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* expand - convert tabs to spaces
|
||||
Copyright (C) 89, 91, 1995-2006, 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 91, 1995-2006, 2008-2009 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
|
||||
@@ -47,10 +47,6 @@
|
||||
|
||||
#define AUTHORS proper_name ("David MacKenzie")
|
||||
|
||||
/* The number of bytes added at a time to the amount of memory
|
||||
allocated for the output line. */
|
||||
#define OUTPUT_BLOCK 256
|
||||
|
||||
/* If true, convert blanks even after nonblank characters have been
|
||||
read on the line. */
|
||||
static bool convert_entire_line;
|
||||
@@ -76,7 +72,7 @@ static char **file_list;
|
||||
/* Default for `file_list' if no files are given on the command line. */
|
||||
static char *stdin_argv[] =
|
||||
{
|
||||
"-", NULL
|
||||
(char *) "-", NULL
|
||||
};
|
||||
|
||||
/* True if we have ever read standard input. */
|
||||
|
||||
715
src/expr.c
715
src/expr.c
@@ -33,20 +33,122 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <regex.h>
|
||||
#if HAVE_GMP
|
||||
#include <gmp.h>
|
||||
#endif
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quotearg.h"
|
||||
#include "strnumcmp.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* Various parts of this code assume size_t fits into unsigned long
|
||||
int, the widest unsigned type that GMP supports. */
|
||||
verify (SIZE_MAX <= ULONG_MAX);
|
||||
|
||||
static void integer_overflow (char) ATTRIBUTE_NORETURN;
|
||||
|
||||
#ifndef HAVE_GMP
|
||||
# define HAVE_GMP 0
|
||||
#endif
|
||||
|
||||
#if HAVE_GMP
|
||||
# include <gmp.h>
|
||||
#else
|
||||
/* Approximate gmp.h well enough for expr.c's purposes. */
|
||||
typedef intmax_t mpz_t[1];
|
||||
static void mpz_clear (mpz_t z) {}
|
||||
static void mpz_init_set_ui (mpz_t z, unsigned long int i) { z[0] = i; }
|
||||
static int
|
||||
mpz_init_set_str (mpz_t z, char *s, int base)
|
||||
{
|
||||
return xstrtoimax (s, NULL, base, z, NULL) == LONGINT_OK ? 0 : -1;
|
||||
}
|
||||
static void
|
||||
mpz_add (mpz_t r, mpz_t a0, mpz_t b0)
|
||||
{
|
||||
intmax_t a = a0[0];
|
||||
intmax_t b = b0[0];
|
||||
intmax_t val = a + b;
|
||||
if ((val < a) != (b < 0))
|
||||
integer_overflow ('+');
|
||||
r[0] = val;
|
||||
}
|
||||
static void
|
||||
mpz_sub (mpz_t r, mpz_t a0, mpz_t b0)
|
||||
{
|
||||
intmax_t a = a0[0];
|
||||
intmax_t b = b0[0];
|
||||
intmax_t val = a - b;
|
||||
if ((a < val) != (b < 0))
|
||||
integer_overflow ('-');
|
||||
r[0] = val;
|
||||
}
|
||||
static void
|
||||
mpz_mul (mpz_t r, mpz_t a0, mpz_t b0)
|
||||
{
|
||||
intmax_t a = a0[0];
|
||||
intmax_t b = b0[0];
|
||||
intmax_t val = a * b;
|
||||
if (! (a == 0 || b == 0
|
||||
|| ((val < 0) == ((a < 0) ^ (b < 0)) && val / a == b)))
|
||||
integer_overflow ('*');
|
||||
r[0] = val;
|
||||
}
|
||||
static void
|
||||
mpz_tdiv_q (mpz_t r, mpz_t a0, mpz_t b0)
|
||||
{
|
||||
intmax_t a = a0[0];
|
||||
intmax_t b = b0[0];
|
||||
|
||||
/* Some x86-style hosts raise an exception for INT_MIN / -1. */
|
||||
if (a < - INTMAX_MAX && b == -1)
|
||||
integer_overflow ('/');
|
||||
r[0] = a / b;
|
||||
}
|
||||
static void
|
||||
mpz_tdiv_r (mpz_t r, mpz_t a0, mpz_t b0)
|
||||
{
|
||||
intmax_t a = a0[0];
|
||||
intmax_t b = b0[0];
|
||||
|
||||
/* Some x86-style hosts raise an exception for INT_MIN % -1. */
|
||||
r[0] = a < - INTMAX_MAX && b == -1 ? 0 : a % b;
|
||||
}
|
||||
static char *
|
||||
mpz_get_str (char const *str, int base, mpz_t z)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
return xstrdup (imaxtostr (z[0], buf));
|
||||
}
|
||||
static int
|
||||
mpz_sgn (mpz_t z)
|
||||
{
|
||||
return z[0] < 0 ? -1 : 0 < z[0];
|
||||
}
|
||||
static int
|
||||
mpz_fits_ulong_p (mpz_t z)
|
||||
{
|
||||
return 0 <= z[0] && z[0] <= ULONG_MAX;
|
||||
}
|
||||
static unsigned long int
|
||||
mpz_get_ui (mpz_t z)
|
||||
{
|
||||
return z[0];
|
||||
}
|
||||
static int
|
||||
mpz_out_str (FILE *stream, int base, mpz_t z)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
return fputs (imaxtostr (z[0], buf), stream) != EOF;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "expr"
|
||||
|
||||
#define AUTHORS proper_name ("Mike Parker"), proper_name ("James Youngman")
|
||||
#define AUTHORS \
|
||||
proper_name ("Mike Parker"), \
|
||||
proper_name ("James Youngman"), \
|
||||
proper_name ("Paul Eggert")
|
||||
|
||||
/* Exit statuses. */
|
||||
enum
|
||||
@@ -61,14 +163,10 @@ enum
|
||||
EXPR_FAILURE
|
||||
};
|
||||
|
||||
/* The kinds of value we can have.
|
||||
In the comments below, a variable is described as "arithmetic" if
|
||||
it is either integer or mp_integer. Variables are of type mp_integer
|
||||
only if GNU MP is available, but the type designator is always defined. */
|
||||
/* The kinds of value we can have. */
|
||||
enum valtype
|
||||
{
|
||||
integer,
|
||||
mp_integer,
|
||||
string
|
||||
};
|
||||
typedef enum valtype TYPE;
|
||||
@@ -79,12 +177,7 @@ struct valinfo
|
||||
TYPE type; /* Which kind. */
|
||||
union
|
||||
{ /* The value itself. */
|
||||
/* We could use intmax_t but that would integrate less well with GMP,
|
||||
since GMP has mpz_set_si but no intmax_t equivalent. */
|
||||
signed long int i;
|
||||
#if HAVE_GMP
|
||||
mpz_t z;
|
||||
#endif
|
||||
mpz_t i;
|
||||
char *s;
|
||||
} u;
|
||||
};
|
||||
@@ -98,34 +191,6 @@ static bool nomoreargs (void);
|
||||
static bool null (VALUE *v);
|
||||
static void printv (VALUE *v);
|
||||
|
||||
/* Arithmetic is done in one of three modes.
|
||||
|
||||
The --bignum option forces all arithmetic to use bignums other than
|
||||
string indexing (mode==MP_ALWAYS). The --no-bignum option forces
|
||||
all arithmetic to use native types rather than bignums
|
||||
(mode==MP_NEVER).
|
||||
|
||||
The default mode is MP_AUTO if GMP is available and MP_NEVER if
|
||||
not. Most functions will process a bignum if one is found, but
|
||||
will not convert a native integer to a string if the mode is
|
||||
MP_NEVER. */
|
||||
enum arithmetic_mode
|
||||
{
|
||||
MP_NEVER, /* Never use bignums */
|
||||
#if HAVE_GMP
|
||||
MP_ALWAYS, /* Always use bignums. */
|
||||
MP_AUTO, /* Switch if result would otherwise overflow */
|
||||
#endif
|
||||
};
|
||||
static enum arithmetic_mode mode =
|
||||
#if HAVE_GMP
|
||||
MP_AUTO
|
||||
#else
|
||||
MP_NEVER
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -140,10 +205,6 @@ Usage: %s EXPRESSION\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
putchar ('\n');
|
||||
fputs (_("\
|
||||
--bignum always use arbitrary-precision arithmetic\n\
|
||||
--no-bignum always use single-precision arithmetic\n"),
|
||||
stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
fputs (_("\
|
||||
@@ -220,47 +281,23 @@ syntax_error (void)
|
||||
static void
|
||||
integer_overflow (char op)
|
||||
{
|
||||
error (EXPR_FAILURE, 0,
|
||||
_("arithmetic operation %c produced an out of range value, "
|
||||
"but arbitrary-precision arithmetic is not available"), op);
|
||||
}
|
||||
|
||||
static void die (int exit_status, int errno_val, char const *msg)
|
||||
ATTRIBUTE_NORETURN;
|
||||
static void
|
||||
die (int exit_status, int errno_val, char const *msg)
|
||||
{
|
||||
assert (exit_status != 0);
|
||||
error (exit_status, errno_val, "%s", msg);
|
||||
error (EXPR_FAILURE, ERANGE, "%c", op);
|
||||
abort (); /* notreached */
|
||||
}
|
||||
|
||||
static void die (int errno_val, char const *msg)
|
||||
ATTRIBUTE_NORETURN;
|
||||
static void
|
||||
string_too_long (void)
|
||||
die (int errno_val, char const *msg)
|
||||
{
|
||||
die (EXPR_FAILURE, ERANGE, _("string too long"));
|
||||
error (EXPR_FAILURE, errno_val, "%s", msg);
|
||||
abort (); /* notreached */
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
USE_BIGNUM = CHAR_MAX + 1,
|
||||
NO_USE_BIGNUM
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"bignum", no_argument, NULL, USE_BIGNUM},
|
||||
{"no-bignum", no_argument, NULL, NO_USE_BIGNUM},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
VALUE *v;
|
||||
int c;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -271,49 +308,23 @@ main (int argc, char **argv)
|
||||
initialize_exit_failure (EXPR_FAILURE);
|
||||
atexit (close_stdout);
|
||||
|
||||
/* The argument -0 should not result in an error message. */
|
||||
opterr = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "+", long_options, NULL)) != -1)
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
/* The above handles --help and --version.
|
||||
Since there is no other invocation of getopt, handle `--' here. */
|
||||
if (argc > 1 && STREQ (argv[1], "--"))
|
||||
{
|
||||
/* "expr -0" should interpret the -0 as an integer argument.
|
||||
arguments like --foo should also be interpreted as a string
|
||||
argument to be "evaluated".
|
||||
*/
|
||||
if ('?' == c)
|
||||
{
|
||||
--optind;
|
||||
break;
|
||||
}
|
||||
else
|
||||
switch (c)
|
||||
{
|
||||
case USE_BIGNUM:
|
||||
#if HAVE_GMP
|
||||
mode = MP_ALWAYS;
|
||||
#else
|
||||
error (EXPR_FAILURE, 0,
|
||||
_("arbitrary-precision support is not available"));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case NO_USE_BIGNUM:
|
||||
mode = MP_NEVER;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
}
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (argc <= optind)
|
||||
if (argc <= 1)
|
||||
{
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXPR_INVALID);
|
||||
}
|
||||
|
||||
args = argv + optind;
|
||||
args = argv + 1;
|
||||
|
||||
v = eval (true);
|
||||
if (!nomoreargs ())
|
||||
@@ -326,21 +337,11 @@ main (int argc, char **argv)
|
||||
/* Return a VALUE for I. */
|
||||
|
||||
static VALUE *
|
||||
int_value (long int i)
|
||||
int_value (unsigned long int i)
|
||||
{
|
||||
VALUE *v = xmalloc (sizeof *v);
|
||||
#if HAVE_GMP
|
||||
if (mode == MP_ALWAYS)
|
||||
{
|
||||
/* all integer values are handled as bignums. */
|
||||
mpz_init_set_si (v->u.z, i);
|
||||
v->type = mp_integer;
|
||||
return v;
|
||||
}
|
||||
#endif
|
||||
|
||||
v->type = integer;
|
||||
v->u.i = i;
|
||||
mpz_init_set_ui (v->u.i, i);
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -355,42 +356,15 @@ str_value (char const *s)
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
static VALUE *
|
||||
substr_value (char const *s, size_t len, size_t pos, size_t nchars_wanted)
|
||||
{
|
||||
if (pos >= len)
|
||||
return str_value ("");
|
||||
else
|
||||
{
|
||||
VALUE *v = xmalloc (sizeof *v);
|
||||
size_t vlen = MIN (nchars_wanted, len - pos + 1);
|
||||
char *vlim;
|
||||
v->type = string;
|
||||
v->u.s = xmalloc (vlen + 1);
|
||||
vlim = mempcpy (v->u.s, s + pos, vlen);
|
||||
*vlim = '\0';
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Free VALUE V, including structure components. */
|
||||
|
||||
static void
|
||||
freev (VALUE *v)
|
||||
{
|
||||
if (v->type == string)
|
||||
{
|
||||
free (v->u.s);
|
||||
}
|
||||
else if (v->type == mp_integer)
|
||||
{
|
||||
assert (mode != MP_NEVER);
|
||||
#if HAVE_GMP
|
||||
mpz_clear (v->u.z);
|
||||
#endif
|
||||
}
|
||||
free (v->u.s);
|
||||
else
|
||||
mpz_clear (v->u.i);
|
||||
free (v);
|
||||
}
|
||||
|
||||
@@ -402,21 +376,15 @@ printv (VALUE *v)
|
||||
switch (v->type)
|
||||
{
|
||||
case integer:
|
||||
printf ("%ld\n", v->u.i);
|
||||
mpz_out_str (stdout, 10, v->u.i);
|
||||
putchar ('\n');
|
||||
break;
|
||||
case string:
|
||||
puts (v->u.s);
|
||||
break;
|
||||
#if HAVE_GMP
|
||||
case mp_integer:
|
||||
mpz_out_str (stdout, 10, v->u.z);
|
||||
putchar ('\n');
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Return true if V is a null-string or zero-number. */
|
||||
@@ -427,11 +395,7 @@ null (VALUE *v)
|
||||
switch (v->type)
|
||||
{
|
||||
case integer:
|
||||
return v->u.i == 0;
|
||||
#if HAVE_GMP
|
||||
case mp_integer:
|
||||
return mpz_sgn (v->u.z) == 0;
|
||||
#endif
|
||||
return mpz_sgn (v->u.i) == 0;
|
||||
case string:
|
||||
{
|
||||
char const *cp = v->u.s;
|
||||
@@ -474,29 +438,16 @@ looks_like_integer (char const *cp)
|
||||
static void
|
||||
tostring (VALUE *v)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (long int)];
|
||||
|
||||
switch (v->type)
|
||||
{
|
||||
case integer:
|
||||
snprintf (buf, sizeof buf, "%ld", v->u.i);
|
||||
v->u.s = xstrdup (buf);
|
||||
v->type = string;
|
||||
break;
|
||||
#if HAVE_GMP
|
||||
case mp_integer:
|
||||
{
|
||||
char *s = mpz_get_str (NULL, 10, v->u.z);
|
||||
if (!s)
|
||||
{
|
||||
xalloc_die ();
|
||||
}
|
||||
mpz_clear (v->u.z);
|
||||
char *s = mpz_get_str (NULL, 10, v->u.i);
|
||||
mpz_clear (v->u.i);
|
||||
v->u.s = s;
|
||||
v->type = string;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case string:
|
||||
break;
|
||||
default:
|
||||
@@ -504,8 +455,7 @@ tostring (VALUE *v)
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to an arithmetic value.
|
||||
Return true on success, false on failure. */
|
||||
/* Coerce V to an integer value. Return true on success, false on failure. */
|
||||
|
||||
static bool
|
||||
toarith (VALUE *v)
|
||||
@@ -513,40 +463,17 @@ toarith (VALUE *v)
|
||||
switch (v->type)
|
||||
{
|
||||
case integer:
|
||||
case mp_integer:
|
||||
return true;
|
||||
|
||||
case string:
|
||||
{
|
||||
long int value;
|
||||
char *s = v->u.s;
|
||||
|
||||
if (! looks_like_integer (v->u.s))
|
||||
if (! looks_like_integer (s))
|
||||
return false;
|
||||
if (xstrtol (v->u.s, NULL, 10, &value, NULL) != LONGINT_OK)
|
||||
{
|
||||
#if HAVE_GMP
|
||||
if (mode != MP_NEVER)
|
||||
{
|
||||
char *s = v->u.s;
|
||||
if (mpz_init_set_str (v->u.z, s, 10))
|
||||
abort (); /* Bug in looks_like_integer, perhaps. */
|
||||
v->type = mp_integer;
|
||||
free (s);
|
||||
}
|
||||
else
|
||||
{
|
||||
error (EXPR_FAILURE, ERANGE, "%s", v->u.s);
|
||||
}
|
||||
#else
|
||||
error (EXPR_FAILURE, ERANGE, "%s", v->u.s);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
free (v->u.s);
|
||||
v->u.i = value;
|
||||
v->type = integer;
|
||||
}
|
||||
if (mpz_init_set_str (v->u.i, s, 10) != 0 && !HAVE_GMP)
|
||||
error (EXPR_FAILURE, ERANGE, "%s", s);
|
||||
free (s);
|
||||
v->type = integer;
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
@@ -554,58 +481,23 @@ toarith (VALUE *v)
|
||||
}
|
||||
}
|
||||
|
||||
/* Extract a size_t value from a positive arithmetic value, V.
|
||||
The extracted value is stored in *VAL. */
|
||||
static bool
|
||||
getsize (const VALUE *v, size_t *val, bool *negative)
|
||||
/* Extract a size_t value from a integer value I.
|
||||
If the value is negative, return SIZE_MAX.
|
||||
If the value is too large, return SIZE_MAX - 1. */
|
||||
static size_t
|
||||
getsize (mpz_t i)
|
||||
{
|
||||
if (v->type == integer)
|
||||
if (mpz_sgn (i) < 0)
|
||||
return SIZE_MAX;
|
||||
if (mpz_fits_ulong_p (i))
|
||||
{
|
||||
if (v->u.i < 0)
|
||||
{
|
||||
*negative = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
*negative = false;
|
||||
*val = v->u.i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (v->type == mp_integer)
|
||||
{
|
||||
#if HAVE_GMP
|
||||
if (mpz_sgn (v->u.z) < 0)
|
||||
{
|
||||
*negative = true;
|
||||
return false;
|
||||
}
|
||||
else if (mpz_fits_ulong_p (v->u.z))
|
||||
{
|
||||
unsigned long ul;
|
||||
ul = mpz_get_ui (v->u.z);
|
||||
*val = ul;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
*negative = false;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
abort ();
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
abort (); /* should not pass a string. */
|
||||
unsigned long int ul = mpz_get_ui (i);
|
||||
if (ul < SIZE_MAX)
|
||||
return ul;
|
||||
}
|
||||
return SIZE_MAX - 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Return true and advance if the next token matches STR exactly.
|
||||
STR must not be NULL. */
|
||||
|
||||
@@ -784,41 +676,14 @@ eval6 (bool evaluate)
|
||||
}
|
||||
else if (nextarg ("index"))
|
||||
{
|
||||
size_t pos, len;
|
||||
size_t pos;
|
||||
|
||||
l = eval6 (evaluate);
|
||||
r = eval6 (evaluate);
|
||||
tostring (l);
|
||||
tostring (r);
|
||||
pos = strcspn (l->u.s, r->u.s);
|
||||
len = strlen (l->u.s);
|
||||
if (pos == len)
|
||||
{
|
||||
v = int_value (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pos < LONG_MAX)
|
||||
{
|
||||
v = int_value (pos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if HAVE_GMP
|
||||
if (mode != MP_NEVER
|
||||
&& pos < ULONG_MAX)
|
||||
{
|
||||
v = xmalloc (sizeof *v);
|
||||
mpz_init_set_ui (v->u.z, pos+1);
|
||||
v->type = mp_integer;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
string_too_long ();
|
||||
}
|
||||
}
|
||||
}
|
||||
v = int_value (l->u.s[pos] ? pos + 1 : 0);
|
||||
freev (l);
|
||||
freev (r);
|
||||
return v;
|
||||
@@ -836,25 +701,21 @@ eval6 (bool evaluate)
|
||||
v = str_value ("");
|
||||
else
|
||||
{
|
||||
size_t pos, len;
|
||||
bool negative = false;
|
||||
size_t pos = getsize (i1->u.i);
|
||||
size_t len = getsize (i2->u.i);
|
||||
|
||||
if (getsize (i1, &pos, &negative))
|
||||
if (getsize (i2, &len, &negative))
|
||||
if (pos == 0 || len == 0)
|
||||
v = str_value ("");
|
||||
else
|
||||
v = substr_value (l->u.s, llen, pos-1, len);
|
||||
else
|
||||
if (negative)
|
||||
v = str_value ("");
|
||||
else
|
||||
die (EXPR_FAILURE, ERANGE, _("string offset is too large"));
|
||||
if (llen < pos || pos == 0 || len == 0 || len == SIZE_MAX)
|
||||
v = str_value ("");
|
||||
else
|
||||
if (negative)
|
||||
v = str_value ("");
|
||||
else
|
||||
die (EXPR_FAILURE, ERANGE, _("substring length too large"));
|
||||
{
|
||||
size_t vlen = MIN (len, llen - pos + 1);
|
||||
char *vlim;
|
||||
v = xmalloc (sizeof *v);
|
||||
v->type = string;
|
||||
v->u.s = xmalloc (vlen + 1);
|
||||
vlim = mempcpy (v->u.s, l->u.s + pos - 1, vlen);
|
||||
*vlim = '\0';
|
||||
}
|
||||
}
|
||||
freev (l);
|
||||
freev (i1);
|
||||
@@ -897,170 +758,6 @@ eval5 (bool evaluate)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if HAVE_GMP
|
||||
static void
|
||||
promote (VALUE *x)
|
||||
{
|
||||
if (x->type == integer)
|
||||
mpz_init_set_si (x->u.z, x->u.i);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* L = L * R. Both L and R are arithmetic. */
|
||||
static void
|
||||
domult (VALUE *l, VALUE *r)
|
||||
{
|
||||
if (l->type == integer && r->type == integer)
|
||||
{
|
||||
long int val = 0;
|
||||
val = l->u.i * r->u.i;
|
||||
if (! (l->u.i == 0 || r->u.i == 0
|
||||
|| ((val < 0) == ((l->u.i < 0) ^ (r->u.i < 0))
|
||||
&& val / l->u.i == r->u.i)))
|
||||
{
|
||||
/* Result would (did) overflow. Handle with MP if available. */
|
||||
if (mode != MP_NEVER)
|
||||
{
|
||||
#if HAVE_GMP
|
||||
mpz_init_set_si (l->u.z, l->u.i);
|
||||
mpz_mul_si (l->u.z, l->u.z, r->u.i); /* L*=R */
|
||||
l->type = mp_integer;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
integer_overflow ('*');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
l->u.i = val;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* At least one operand is already mp_integer, so promote the other. */
|
||||
#if HAVE_GMP
|
||||
/* We could use mpz_mul_si here if R is not already mp_integer,
|
||||
but for the moment we'll try to minimise code paths. */
|
||||
if (l->type == integer)
|
||||
mpz_init_set_si (l->u.z, l->u.i);
|
||||
if (r->type == integer)
|
||||
mpz_init_set_si (r->u.z, r->u.i);
|
||||
l->type = r->type = mp_integer;
|
||||
mpz_mul (l->u.z, l->u.z, r->u.z); /* L*=R */
|
||||
#else
|
||||
abort ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* L = L / R or (if WANT_MODULUS) L = L % R */
|
||||
static void
|
||||
dodivide (VALUE *l, VALUE *r, bool want_modulus)
|
||||
{
|
||||
if (r->type == integer && r->u.i == 0)
|
||||
error (EXPR_INVALID, 0, _("division by zero"));
|
||||
#if HAVE_GMP
|
||||
if (r->type == mp_integer && mpz_sgn (r->u.z) == 0)
|
||||
error (EXPR_INVALID, 0, _("division by zero"));
|
||||
#endif
|
||||
if (l->type == integer && r->type == integer)
|
||||
{
|
||||
if (l->u.i < - INT_MAX && r->u.i == -1)
|
||||
{
|
||||
/* Some x86-style hosts raise an exception for
|
||||
INT_MIN / -1 and INT_MIN % -1, so handle these
|
||||
problematic cases specially. */
|
||||
if (want_modulus)
|
||||
{
|
||||
/* X mod -1 is zero for all negative X.
|
||||
Although strictly this is implementation-defined,
|
||||
we don't want to coredump, so we avoid the calculation. */
|
||||
l->u.i = 0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mode != MP_NEVER)
|
||||
{
|
||||
#if HAVE_GMP
|
||||
/* Handle the case by promoting. */
|
||||
mpz_init_set_si (l->u.z, l->u.i);
|
||||
l->type = mp_integer;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
integer_overflow ('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
l->u.i = want_modulus ? l->u.i % r->u.i : l->u.i / r->u.i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* If we get to here, at least one operand is mp_integer
|
||||
and R is not 0. */
|
||||
#if HAVE_GMP
|
||||
{
|
||||
int sign_l, sign_r;
|
||||
promote (l);
|
||||
promote (r);
|
||||
sign_l = mpz_sgn (l->u.z);
|
||||
sign_r = mpz_sgn (r->u.z);
|
||||
|
||||
if (!want_modulus)
|
||||
{
|
||||
if (!sign_l)
|
||||
{
|
||||
mpz_set_si (l->u.z, 0);
|
||||
}
|
||||
else if (sign_l < 0 || sign_r < 0)
|
||||
{
|
||||
/* At least one operand is negative. For integer arithmetic,
|
||||
it's platform-dependent if the operation rounds up or down.
|
||||
We mirror what the implementation does. */
|
||||
switch ((3*sign_l) / (2*sign_r))
|
||||
{
|
||||
case 2: /* round toward +inf. */
|
||||
case -1: /* round toward +inf. */
|
||||
mpz_cdiv_q (l->u.z, l->u.z, r->u.z);
|
||||
break;
|
||||
case -2: /* round toward -inf. */
|
||||
case 1: /* round toward -inf */
|
||||
mpz_fdiv_q (l->u.z, l->u.z, r->u.z);
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Both operands positive. Round toward -inf. */
|
||||
mpz_fdiv_q (l->u.z, l->u.z, r->u.z);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mpz_mod (l->u.z, l->u.z, r->u.z); /* L = L % R */
|
||||
|
||||
/* If either operand is negative, it's platform-dependent if
|
||||
the remainer is positive or negative. We mirror what the
|
||||
implementation does. */
|
||||
if (sign_l % sign_r < 0)
|
||||
mpz_neg (l->u.z, l->u.z); /* L = (-L) */
|
||||
}
|
||||
}
|
||||
#else
|
||||
abort ();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Handle *, /, % operators. */
|
||||
|
||||
static VALUE *
|
||||
@@ -1089,71 +786,17 @@ eval4 (bool evaluate)
|
||||
{
|
||||
if (!toarith (l) || !toarith (r))
|
||||
error (EXPR_INVALID, 0, _("non-numeric argument"));
|
||||
switch (fxn)
|
||||
{
|
||||
case multiply:
|
||||
domult (l, r);
|
||||
break;
|
||||
case divide:
|
||||
case mod:
|
||||
dodivide (l, r, fxn==mod);
|
||||
break;
|
||||
}
|
||||
if (fxn != multiply && mpz_sgn (r->u.i) == 0)
|
||||
error (EXPR_INVALID, 0, _("division by zero"));
|
||||
((fxn == multiply ? mpz_mul
|
||||
: fxn == divide ? mpz_tdiv_q
|
||||
: mpz_tdiv_r)
|
||||
(l->u.i, l->u.i, r->u.i));
|
||||
}
|
||||
freev (r);
|
||||
}
|
||||
}
|
||||
|
||||
/* L = L + R, or L = L - R */
|
||||
static void
|
||||
doadd (VALUE *l, VALUE *r, bool add)
|
||||
{
|
||||
long int val = 0;
|
||||
|
||||
if (!toarith (l) || !toarith (r))
|
||||
error (EXPR_INVALID, 0, _("non-numeric argument"));
|
||||
if (l->type == integer && r->type == integer)
|
||||
{
|
||||
if (add)
|
||||
{
|
||||
val = l->u.i + r->u.i;
|
||||
if ((val < l->u.i) == (r->u.i < 0))
|
||||
{
|
||||
l->u.i = val;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
val = l->u.i - r->u.i;
|
||||
if ((l->u.i < val) == (r->u.i < 0))
|
||||
{
|
||||
l->u.i = val;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* If we get to here, either the operation overflowed or at least
|
||||
one operand is an mp_integer. */
|
||||
if (mode != MP_NEVER)
|
||||
{
|
||||
#if HAVE_GMP
|
||||
promote (l);
|
||||
promote (r);
|
||||
if (add)
|
||||
mpz_add (l->u.z, l->u.z, r->u.z);
|
||||
else
|
||||
mpz_sub (l->u.z, l->u.z, r->u.z);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
integer_overflow ('-');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Handle +, - operators. */
|
||||
|
||||
static VALUE *
|
||||
@@ -1161,7 +804,7 @@ eval3 (bool evaluate)
|
||||
{
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
bool add;
|
||||
enum { plus, minus } fxn;
|
||||
|
||||
#ifdef EVAL_TRACE
|
||||
trace ("eval3");
|
||||
@@ -1170,15 +813,17 @@ eval3 (bool evaluate)
|
||||
while (1)
|
||||
{
|
||||
if (nextarg ("+"))
|
||||
add = true;
|
||||
fxn = plus;
|
||||
else if (nextarg ("-"))
|
||||
add = false;
|
||||
fxn = minus;
|
||||
else
|
||||
return l;
|
||||
r = eval4 (evaluate);
|
||||
if (evaluate)
|
||||
{
|
||||
doadd (l, r, add);
|
||||
if (!toarith (l) || !toarith (r))
|
||||
error (EXPR_INVALID, 0, _("non-numeric argument"));
|
||||
(fxn == plus ? mpz_add : mpz_sub) (l->u.i, l->u.i, r->u.i);
|
||||
}
|
||||
freev (r);
|
||||
}
|
||||
|
||||
190
src/factor.c
190
src/factor.c
@@ -1,5 +1,5 @@
|
||||
/* factor -- print prime factors of n.
|
||||
Copyright (C) 86, 1995-2005, 2007-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 1995-2005, 2007-2009 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
|
||||
@@ -29,9 +29,7 @@
|
||||
#include <gmp.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define NDEBUG 1
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
@@ -49,15 +47,6 @@
|
||||
|
||||
static bool verbose = false;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ALGO_AUTOSELECT, /* default */
|
||||
ALGO_GMP, /* --bignum */
|
||||
ALGO_SINGLE /* --no-bignum */
|
||||
} ALGORITHM_CHOICE;
|
||||
static ALGORITHM_CHOICE algorithm = ALGO_AUTOSELECT;
|
||||
|
||||
|
||||
#if HAVE_GMP
|
||||
static mpz_t *factor = NULL;
|
||||
static size_t nfactors_found = 0;
|
||||
@@ -91,6 +80,7 @@ emit_ul_factor (unsigned long int i)
|
||||
mpz_init (t);
|
||||
mpz_set_ui (t, i);
|
||||
emit_factor (t);
|
||||
mpz_clear (t);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -267,51 +257,13 @@ S4:
|
||||
mpz_clear (y);
|
||||
}
|
||||
|
||||
/* Arbitrary-precision factoring */
|
||||
static bool
|
||||
extract_factors_multi (char const *s)
|
||||
#else
|
||||
|
||||
static void
|
||||
debug (char const *fmt ATTRIBUTE_UNUSED, ...)
|
||||
{
|
||||
unsigned int division_limit;
|
||||
size_t n_bits;
|
||||
mpz_t t;
|
||||
|
||||
mpz_init (t);
|
||||
if (1 != gmp_sscanf (s, "%Zd", t))
|
||||
{
|
||||
error (0, 0, _("%s is not a valid positive integer"), quote (s));
|
||||
return false;
|
||||
}
|
||||
|
||||
printf ("%s:", s);
|
||||
|
||||
if (mpz_sgn (t) == 0)
|
||||
{
|
||||
mpz_clear (t);
|
||||
return true; /* 0; no factors */
|
||||
}
|
||||
|
||||
/* Set the trial division limit according to the size of t. */
|
||||
n_bits = mpz_sizeinbase (t, 2);
|
||||
division_limit = MIN (n_bits, 1000);
|
||||
division_limit *= division_limit;
|
||||
|
||||
factor_using_division (t, division_limit);
|
||||
|
||||
if (mpz_cmp_ui (t, 1) != 0)
|
||||
{
|
||||
debug ("[is number prime?] ");
|
||||
if (mpz_probab_prime_p (t, 3))
|
||||
{
|
||||
emit_factor (t);
|
||||
}
|
||||
else
|
||||
{
|
||||
factor_using_pollard_rho (t, 1);
|
||||
}
|
||||
}
|
||||
mpz_clear (t);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* The maximum number of factors, including -1, for negative numbers. */
|
||||
@@ -379,30 +331,18 @@ factor_wheel (uintmax_t n0, size_t max_n_factors, uintmax_t *factors)
|
||||
}
|
||||
|
||||
/* Single-precision factoring */
|
||||
static bool
|
||||
print_factors_single (char const *s)
|
||||
static void
|
||||
print_factors_single (uintmax_t n)
|
||||
{
|
||||
uintmax_t factors[MAX_N_FACTORS];
|
||||
uintmax_t n;
|
||||
size_t n_factors;
|
||||
size_t n_factors = factor_wheel (n, MAX_N_FACTORS, factors);
|
||||
size_t i;
|
||||
char buf[INT_BUFSIZE_BOUND (uintmax_t)];
|
||||
strtol_error err;
|
||||
|
||||
if ((err = xstrtoumax (s, NULL, 10, &n, "")) != LONGINT_OK)
|
||||
{
|
||||
if (err == LONGINT_OVERFLOW)
|
||||
error (0, 0, _("%s is too large"), quote (s));
|
||||
else
|
||||
error (0, 0, _("%s is not a valid positive integer"), quote (s));
|
||||
return false;
|
||||
}
|
||||
n_factors = factor_wheel (n, MAX_N_FACTORS, factors);
|
||||
printf ("%s:", umaxtostr (n, buf));
|
||||
for (i = 0; i < n_factors; i++)
|
||||
printf (" %s", umaxtostr (factors[i], buf));
|
||||
putchar ('\n');
|
||||
return true;
|
||||
}
|
||||
|
||||
#if HAVE_GMP
|
||||
@@ -450,67 +390,93 @@ free_factors (void)
|
||||
nfactors_found = 0;
|
||||
}
|
||||
|
||||
/* Arbitrary-precision factoring */
|
||||
static void
|
||||
print_factors_multi (mpz_t t)
|
||||
{
|
||||
mpz_out_str (stdout, 10, t);
|
||||
putchar (':');
|
||||
|
||||
if (mpz_sgn (t) != 0)
|
||||
{
|
||||
/* Set the trial division limit according to the size of t. */
|
||||
size_t n_bits = mpz_sizeinbase (t, 2);
|
||||
unsigned int division_limit = MIN (n_bits, 1000);
|
||||
division_limit *= division_limit;
|
||||
|
||||
factor_using_division (t, division_limit);
|
||||
|
||||
if (mpz_cmp_ui (t, 1) != 0)
|
||||
{
|
||||
debug ("[is number prime?] ");
|
||||
if (mpz_probab_prime_p (t, 3))
|
||||
emit_factor (t);
|
||||
else
|
||||
factor_using_pollard_rho (t, 1);
|
||||
}
|
||||
}
|
||||
|
||||
mpz_clear (t);
|
||||
sort_and_print_factors ();
|
||||
free_factors ();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Emit the factors of the indicated number. If we have the option of using
|
||||
either algorithm, we select on the basis of the length of the number.
|
||||
For longer numbers, we prefer the MP algorithm even if the native algorithm
|
||||
has enough digits, because the algorithm is better. The turnover point
|
||||
depends on the value as well as the length, but since we don't already know
|
||||
if the number presented has small factors, we just switch over at 6 digits.
|
||||
*/
|
||||
has enough digits, because the algorithm is better. The turnover point
|
||||
depends on the value. */
|
||||
static bool
|
||||
print_factors (char const *s)
|
||||
{
|
||||
if (ALGO_AUTOSELECT == algorithm)
|
||||
uintmax_t n;
|
||||
strtol_error err = xstrtoumax (s, NULL, 10, &n, "");
|
||||
|
||||
#if HAVE_GMP
|
||||
enum { GMP_TURNOVER_POINT = 100000 };
|
||||
|
||||
if (err == LONGINT_OVERFLOW
|
||||
|| (err == LONGINT_OK && GMP_TURNOVER_POINT <= n))
|
||||
{
|
||||
const size_t digits = strlen (s); /* upper limit on number of digits */
|
||||
algorithm = digits < 6 ? ALGO_SINGLE : ALGO_GMP;
|
||||
}
|
||||
if (ALGO_GMP == algorithm)
|
||||
{
|
||||
debug ("[%s]", _("using arbitrary-precision arithmetic"));
|
||||
if (extract_factors_multi (s))
|
||||
mpz_t t;
|
||||
mpz_init (t);
|
||||
if (gmp_sscanf (s, "%Zd", t) == 1)
|
||||
{
|
||||
sort_and_print_factors ();
|
||||
free_factors ();
|
||||
debug ("[%s]", _("using arbitrary-precision arithmetic"));
|
||||
print_factors_multi (t);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
err = LONGINT_INVALID;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
switch (err)
|
||||
{
|
||||
case LONGINT_OK:
|
||||
debug ("[%s]", _("using single-precision arithmetic"));
|
||||
return print_factors_single (s);
|
||||
}
|
||||
}
|
||||
#else
|
||||
static bool
|
||||
print_factors (const char *s) /* Single-precision only. */
|
||||
{
|
||||
if (ALGO_GMP == algorithm)
|
||||
{
|
||||
error (0, 0, _("arbitrary-precision arithmetic is not available"));
|
||||
print_factors_single (n);
|
||||
return true;
|
||||
|
||||
case LONGINT_OVERFLOW:
|
||||
error (0, 0, _("%s is too large"), quote (s));
|
||||
return false;
|
||||
|
||||
default:
|
||||
error (0, 0, _("%s is not a valid positive integer"), quote (s));
|
||||
return false;
|
||||
}
|
||||
return print_factors_single (s);
|
||||
}
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
VERBOSE_OPTION = CHAR_MAX + 1,
|
||||
USE_BIGNUM,
|
||||
NO_USE_BIGNUM
|
||||
VERBOSE_OPTION = CHAR_MAX + 1
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"verbose", no_argument, NULL, VERBOSE_OPTION},
|
||||
{"bignum", no_argument, NULL, USE_BIGNUM},
|
||||
{"no-bignum", no_argument, NULL, NO_USE_BIGNUM},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -534,10 +500,6 @@ Print the prime factors of each specified integer NUMBER. If none\n\
|
||||
are specified on the command line, read them from standard input.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--bignum always use arbitrary-precision arithmetic\n\
|
||||
--no-bignum always use single-precision arithmetic\n"),
|
||||
stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
@@ -588,14 +550,6 @@ main (int argc, char **argv)
|
||||
verbose = true;
|
||||
break;
|
||||
|
||||
case USE_BIGNUM:
|
||||
algorithm = ALGO_GMP;
|
||||
break;
|
||||
|
||||
case NO_USE_BIGNUM:
|
||||
algorithm = ALGO_SINGLE;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
180
src/getlimits.c
Normal file
180
src/getlimits.c
Normal file
@@ -0,0 +1,180 @@
|
||||
/* getlimits - print various platform dependent limits.
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Pádraig Brady */
|
||||
|
||||
#include <config.h> /* sets _FILE_OFFSET_BITS=64 etc. */
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "c-ctype.h"
|
||||
#include "long-options.h"
|
||||
|
||||
#define PROGRAM_NAME "getlimits"
|
||||
|
||||
#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
|
||||
|
||||
#ifndef TIME_T_MAX
|
||||
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
|
||||
#endif
|
||||
|
||||
#ifndef TIME_T_MIN
|
||||
# define TIME_T_MIN TYPE_MINIMUM (time_t)
|
||||
#endif
|
||||
|
||||
#ifndef SSIZE_MIN
|
||||
# define SSIZE_MIN TYPE_MINIMUM (ssize_t)
|
||||
#endif
|
||||
|
||||
#ifndef PID_T_MIN
|
||||
# define PID_T_MIN TYPE_MINIMUM (pid_t)
|
||||
#endif
|
||||
|
||||
/* These are not interesting to print.
|
||||
* Instead of these defines it would be nice to be able to do
|
||||
* #ifdef (TYPE##_MIN) in function macro below. */
|
||||
#define SIZE_MIN 0
|
||||
#define UCHAR_MIN 0
|
||||
#define UINT_MIN 0
|
||||
#define ULONG_MIN 0
|
||||
#define UINTMAX_MIN 0
|
||||
#define UID_T_MIN 0
|
||||
#define GID_T_MIN 0
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != EXIT_SUCCESS)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s\n\
|
||||
"), program_name);
|
||||
|
||||
fputs (_("\
|
||||
Output platform dependent limits in a format useful for shell scripts.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* Add absolute values of ascii decimal strings.
|
||||
* Strings can have leading spaces.
|
||||
* If any string has a '-' it's preserved in the output:
|
||||
* I.E.
|
||||
* 1 + 1 -> 2
|
||||
* -1 + -1 -> -2
|
||||
* -1 + 1 -> -2
|
||||
* 1 + -1 -> -2
|
||||
*/
|
||||
static char *
|
||||
decimal_ascii_add (const char *str1, const char *str2)
|
||||
{
|
||||
int len1 = strlen (str1);
|
||||
int len2 = strlen (str2);
|
||||
int rlen = MAX (len1, len2) + 3; /* space for extra digit or sign + NUL */
|
||||
char *result = xmalloc (rlen);
|
||||
char *rp = result + rlen - 1;
|
||||
const char *d1 = str1 + len1 - 1;
|
||||
const char *d2 = str2 + len2 - 1;
|
||||
int carry = 0;
|
||||
*rp = '\0';
|
||||
|
||||
while (1)
|
||||
{
|
||||
char c1 = (d1 < str1 ? ' ' : (*d1 == '-' ? ' ' : *d1--));
|
||||
char c2 = (d2 < str2 ? ' ' : (*d2 == '-' ? ' ' : *d2--));
|
||||
char t1 = c1 + c2 + carry; /* ASCII digits are BCD */
|
||||
if (!c_isdigit (c1) && !c_isdigit (c2) && !carry)
|
||||
break;
|
||||
carry = t1 > '0' + '9' || t1 == ' ' + '9' + 1;
|
||||
t1 += 6 * carry;
|
||||
*--rp = (t1 & 0x0F) | 0x30; /* top nibble to ASCII */
|
||||
}
|
||||
if ((d1 >= str1 && *d1 == '-') || (d2 >= str2 && (*d2 == '-')))
|
||||
*--rp = '-';
|
||||
|
||||
if (rp != result)
|
||||
memmove (result, rp, rlen - (rp - result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char limit[64]; /* big enough for 128 bit at least */
|
||||
char *oflow;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
initialize_exit_failure (EXIT_FAILURE);
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
|
||||
#define print_int(TYPE) \
|
||||
snprintf (limit, sizeof(limit), "%"PRIuMAX, (uintmax_t)TYPE##_MAX); \
|
||||
printf (#TYPE"_MAX=%s\n", limit); \
|
||||
oflow = decimal_ascii_add (limit, "1"); \
|
||||
printf (#TYPE"_OFLOW=%s\n", oflow); \
|
||||
free (oflow); \
|
||||
if (TYPE##_MIN) \
|
||||
{ \
|
||||
snprintf (limit, sizeof(limit), "%"PRIdMAX, (intmax_t)TYPE##_MIN); \
|
||||
printf (#TYPE"_MIN=%s\n", limit); \
|
||||
oflow = decimal_ascii_add (limit, "-1"); \
|
||||
printf (#TYPE"_UFLOW=%s\n", oflow); \
|
||||
free (oflow); \
|
||||
}
|
||||
|
||||
/* Variable sized ints */
|
||||
print_int (CHAR);
|
||||
print_int (SCHAR);
|
||||
print_int (UCHAR);
|
||||
print_int (SHRT);
|
||||
print_int (INT);
|
||||
print_int (UINT);
|
||||
print_int (LONG);
|
||||
print_int (ULONG);
|
||||
print_int (SIZE);
|
||||
print_int (SSIZE);
|
||||
print_int (TIME_T);
|
||||
print_int (UID_T);
|
||||
print_int (GID_T);
|
||||
print_int (PID_T);
|
||||
print_int (OFF_T);
|
||||
print_int (INTMAX);
|
||||
print_int (UINTMAX);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
@@ -1,5 +1,5 @@
|
||||
/* group-list.c --Print a list of group IDs or names.
|
||||
Copyright (C) 1989-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2009 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
|
||||
@@ -57,7 +57,7 @@ print_group_list (const char *username,
|
||||
#if HAVE_GETGROUPS
|
||||
{
|
||||
GETGROUPS_T *groups;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
|
||||
&groups);
|
||||
@@ -83,9 +83,9 @@ print_group_list (const char *username,
|
||||
ok = false;
|
||||
}
|
||||
free (groups);
|
||||
return ok;
|
||||
}
|
||||
#endif /* HAVE_GETGROUPS */
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "full-read.h"
|
||||
#include "quote.h"
|
||||
#include "safe-read.h"
|
||||
#include "xfreopen.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -838,7 +839,7 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines,
|
||||
fd = STDIN_FILENO;
|
||||
filename = _("standard input");
|
||||
if (O_BINARY && ! isatty (STDIN_FILENO))
|
||||
freopen (NULL, "rb", stdin);
|
||||
xfreopen (NULL, "rb", stdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1051,7 +1052,7 @@ main (int argc, char **argv)
|
||||
: default_file_list);
|
||||
|
||||
if (O_BINARY && ! isatty (STDOUT_FILENO))
|
||||
freopen (NULL, "wb", stdout);
|
||||
xfreopen (NULL, "wb", stdout);
|
||||
|
||||
for (i = 0; file_list[i]; ++i)
|
||||
ok &= head_file (file_list[i], n_units, count_lines, elide_from_end);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user