mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
551 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42285406aa | ||
|
|
5149348906 | ||
|
|
fbc5aa7c47 | ||
|
|
15f4d612df | ||
|
|
e505736f82 | ||
|
|
7eb15e1020 | ||
|
|
ef13885b37 | ||
|
|
0628b73f35 | ||
|
|
dafbd407bc | ||
|
|
94c59c97f9 | ||
|
|
ab02e256e9 | ||
|
|
0eff09dfcf | ||
|
|
0482f193b5 | ||
|
|
cfe3602ad6 | ||
|
|
cee53c1430 | ||
|
|
0643c51cab | ||
|
|
b616886492 | ||
|
|
58aaf71f07 | ||
|
|
24412edeaf | ||
|
|
a5111af33e | ||
|
|
1e3ebd660a | ||
|
|
2f706199d0 | ||
|
|
e13188e7ef | ||
|
|
2a4dcb627e | ||
|
|
13a2025998 | ||
|
|
9a33347007 | ||
|
|
e916c8ff05 | ||
|
|
beaee48f26 | ||
|
|
2643b4b77d | ||
|
|
8c4a656fad | ||
|
|
fec05eb377 | ||
|
|
6d5bf36d5c | ||
|
|
be11df4916 | ||
|
|
2f776f3096 | ||
|
|
13edec7c62 | ||
|
|
57622cac71 | ||
|
|
3b39aa796f | ||
|
|
a7ea04404c | ||
|
|
e34eb51728 | ||
|
|
771484f47a | ||
|
|
c7c961a3e5 | ||
|
|
4718a2fdf4 | ||
|
|
2298544c64 | ||
|
|
18efee4e2a | ||
|
|
f923ceceba | ||
|
|
e10e4b6697 | ||
|
|
cddcb5d468 | ||
|
|
3e8f9c8d35 | ||
|
|
ae1c205fc4 | ||
|
|
2221ea2c3a | ||
|
|
a06afbeec5 | ||
|
|
d9903062cf | ||
|
|
9dcebc51be | ||
|
|
1084bf78ea | ||
|
|
68561594ca | ||
|
|
22e5102f19 | ||
|
|
e4fa3e7808 | ||
|
|
737461d23f | ||
|
|
6b22726dd4 | ||
|
|
54281e9c60 | ||
|
|
ea2887bbe4 | ||
|
|
ef6a361a07 | ||
|
|
63a7120c28 | ||
|
|
5bf3e7ee96 | ||
|
|
0c1fc1c715 | ||
|
|
f03a67735a | ||
|
|
f325d180cf | ||
|
|
bfe4a55520 | ||
|
|
8ea96a5c90 | ||
|
|
f3574102d3 | ||
|
|
edd292f8d4 | ||
|
|
929479026b | ||
|
|
4c9fae4e97 | ||
|
|
a01c4720d6 | ||
|
|
081ebb2822 | ||
|
|
22999697b8 | ||
|
|
7e0019b168 | ||
|
|
64c25ed741 | ||
|
|
d9c0881137 | ||
|
|
4290abda87 | ||
|
|
5a74a2d566 | ||
|
|
7ee3d2430a | ||
|
|
f0f6e14610 | ||
|
|
e4fd2bf4e6 | ||
|
|
18e2a330b9 | ||
|
|
4ebf956b4e | ||
|
|
0392142b87 | ||
|
|
127c689f64 | ||
|
|
baad54258d | ||
|
|
d3ad58376d | ||
|
|
a1cb30c1fb | ||
|
|
d7e2f425e7 | ||
|
|
4b5e044be3 | ||
|
|
43f66923cc | ||
|
|
cd1f4bc1ec | ||
|
|
b673a5b8ac | ||
|
|
2a2d3f237b | ||
|
|
0d279d2378 | ||
|
|
c339cff4a6 | ||
|
|
ae5ae5e117 | ||
|
|
f65cafd67b | ||
|
|
d9207b48a3 | ||
|
|
d7f79cf6cb | ||
|
|
8c3835bf93 | ||
|
|
273c10fc2c | ||
|
|
f4bffea5e9 | ||
|
|
6b9f1bdd66 | ||
|
|
ffc630e598 | ||
|
|
c4c3dbc024 | ||
|
|
110df929fc | ||
|
|
e3b5543ea8 | ||
|
|
84f6abfe00 | ||
|
|
00c6aacf31 | ||
|
|
8d974b00fb | ||
|
|
b44f5f74aa | ||
|
|
662ce25d83 | ||
|
|
0d75784da0 | ||
|
|
cbdcc9fb4e | ||
|
|
bee58d8a04 | ||
|
|
e535754fdb | ||
|
|
f674a10f7e | ||
|
|
4fff95cfe1 | ||
|
|
77d97a1be4 | ||
|
|
f82c5ba71e | ||
|
|
9bb0d5766e | ||
|
|
1ee81530c0 | ||
|
|
ecb0ea20ca | ||
|
|
9a221e27f5 | ||
|
|
4e6af68846 | ||
|
|
186b45aaed | ||
|
|
773be9eca8 | ||
|
|
8461d49df0 | ||
|
|
b1a1fcbf57 | ||
|
|
0fb0a03c5c | ||
|
|
63467fa187 | ||
|
|
5483165b12 | ||
|
|
9a4e22d036 | ||
|
|
bba4d3e054 | ||
|
|
760bc6f7e7 | ||
|
|
9396eb9037 | ||
|
|
8da8dfc470 | ||
|
|
1d9b3de948 | ||
|
|
f38003890b | ||
|
|
5b610a06b2 | ||
|
|
5cc42f7de6 | ||
|
|
0a98d79bd2 | ||
|
|
a676856285 | ||
|
|
e2dbcee444 | ||
|
|
8ce745dc61 | ||
|
|
1fcd8cf8b4 | ||
|
|
595fc63c42 | ||
|
|
58b2e1204a | ||
|
|
27311c9e85 | ||
|
|
556fbb5721 | ||
|
|
b1a1c9ee06 | ||
|
|
3d309aa725 | ||
|
|
4f4700cca8 | ||
|
|
2e6fa14d16 | ||
|
|
3ea1fe588e | ||
|
|
574f761403 | ||
|
|
c1aabf84e6 | ||
|
|
02bfd65480 | ||
|
|
2c88abe2a2 | ||
|
|
7d10e30088 | ||
|
|
61f94d4dbc | ||
|
|
a087f17a44 | ||
|
|
20905b0cdc | ||
|
|
322c6f2e5c | ||
|
|
3435bb7f40 | ||
|
|
96ae7199c4 | ||
|
|
a7a328af0f | ||
|
|
94cecb5cf6 | ||
|
|
58db1bb942 | ||
|
|
45e67188d6 | ||
|
|
3de1559830 | ||
|
|
956abf969c | ||
|
|
b1db942595 | ||
|
|
2cbbbf6319 | ||
|
|
837bb31803 | ||
|
|
44530f2ddd | ||
|
|
9823682c2f | ||
|
|
1463824d8e | ||
|
|
d42994df5d | ||
|
|
d7d80c5b7b | ||
|
|
20c0b8701f | ||
|
|
46a811b9e7 | ||
|
|
bbbc35c9ed | ||
|
|
c49b2e32bb | ||
|
|
b83c498809 | ||
|
|
6c79825ce9 | ||
|
|
3808eccbbf | ||
|
|
81d0c8f367 | ||
|
|
98a96822d9 | ||
|
|
5f47278372 | ||
|
|
47ed009e57 | ||
|
|
394f88c4aa | ||
|
|
8253a9aeb4 | ||
|
|
a16bee4f07 | ||
|
|
e63c9825da | ||
|
|
263bb1be67 | ||
|
|
23c2a0cbac | ||
|
|
252d6d01c9 | ||
|
|
6eec737ade | ||
|
|
68158e6b10 | ||
|
|
75e0047c4b | ||
|
|
74c0bfbc4c | ||
|
|
80213bc66d | ||
|
|
4b92612944 | ||
|
|
896b672499 | ||
|
|
1b0b6c8d08 | ||
|
|
cc4bdb92f9 | ||
|
|
0647f3eb5a | ||
|
|
77b1bfc85c | ||
|
|
434258ca73 | ||
|
|
eebe731014 | ||
|
|
91c1384602 | ||
|
|
265c4b83a8 | ||
|
|
4a510cd399 | ||
|
|
ecb67c8389 | ||
|
|
86535835fe | ||
|
|
01e6181965 | ||
|
|
8a4192d3c0 | ||
|
|
423f28be77 | ||
|
|
dd3612a12b | ||
|
|
3cafcf8584 | ||
|
|
4db4c2aa6d | ||
|
|
d81d2e0ba6 | ||
|
|
eba365275b | ||
|
|
eb4b2d462e | ||
|
|
72df741618 | ||
|
|
fc6827e2bb | ||
|
|
6c9b505329 | ||
|
|
9f678af5f3 | ||
|
|
8581bcc9e3 | ||
|
|
00a3098235 | ||
|
|
c6c9e8730e | ||
|
|
8976a2b27e | ||
|
|
87386cc8a9 | ||
|
|
545a116748 | ||
|
|
9d59509937 | ||
|
|
26552f2756 | ||
|
|
86837548f1 | ||
|
|
199d850038 | ||
|
|
581b2e3cee | ||
|
|
d8382a4d26 | ||
|
|
74a106985a | ||
|
|
be2abe31fd | ||
|
|
b69b4cca95 | ||
|
|
7855cbfcac | ||
|
|
29290d0485 | ||
|
|
3ceabe1bfc | ||
|
|
5e6a1837ea | ||
|
|
76367f06b3 | ||
|
|
c4a9551eee | ||
|
|
9300779cc8 | ||
|
|
878e51ebfa | ||
|
|
51243cdaca | ||
|
|
1081bbc74e | ||
|
|
ea54b6f47c | ||
|
|
4a4fe636dc | ||
|
|
c6a3937288 | ||
|
|
0bf3eb3682 | ||
|
|
513a235858 | ||
|
|
433881d802 | ||
|
|
295d47736a | ||
|
|
346dd8b5bf | ||
|
|
65d65fe094 | ||
|
|
a59258fbc7 | ||
|
|
b347377bd3 | ||
|
|
0fe9fc4558 | ||
|
|
15b0d75930 | ||
|
|
f0ad302ca9 | ||
|
|
28c9d4ecff | ||
|
|
ce7b12ef1b | ||
|
|
7fcb73cec0 | ||
|
|
6a9c6804dd | ||
|
|
7c9c6c7875 | ||
|
|
d3dc29c0be | ||
|
|
6ec3a4f033 | ||
|
|
7cc3733f29 | ||
|
|
e98006dde0 | ||
|
|
bc2b9e04e9 | ||
|
|
5ad6145142 | ||
|
|
2656da4705 | ||
|
|
3269104d17 | ||
|
|
f15e62d12e | ||
|
|
32b84c9c90 | ||
|
|
1f3e964802 | ||
|
|
62ebe4dabd | ||
|
|
cca51697aa | ||
|
|
22adc16d9c | ||
|
|
f375a52f51 | ||
|
|
eb62800728 | ||
|
|
f02102211e | ||
|
|
209850fd7e | ||
|
|
4d3bf408b9 | ||
|
|
2224ef83fe | ||
|
|
0b66c5776e | ||
|
|
c64411a38a | ||
|
|
fcd450ecb9 | ||
|
|
d701f6abb7 | ||
|
|
a892af0d48 | ||
|
|
e3171c43eb | ||
|
|
bbc49eb536 | ||
|
|
bbc0cb0f37 | ||
|
|
28f1b61e59 | ||
|
|
29a2fb3856 | ||
|
|
ed30cd94e3 | ||
|
|
eef629eea1 | ||
|
|
2f55920ffc | ||
|
|
d6ec836387 | ||
|
|
5a3b0c4805 | ||
|
|
972e2737ab | ||
|
|
816e56a3de | ||
|
|
bbafdc3c8f | ||
|
|
dfdb532fd3 | ||
|
|
53d8a2c412 | ||
|
|
427f179542 | ||
|
|
8dc387dba5 | ||
|
|
cca6a8d7e5 | ||
|
|
6bbbd65d89 | ||
|
|
d30ac3d321 | ||
|
|
37370a584c | ||
|
|
8657cf19e2 | ||
|
|
1a5b6e3a50 | ||
|
|
0a4a938b6b | ||
|
|
d9c1b8fd30 | ||
|
|
0bc8813b1e | ||
|
|
68466d44b1 | ||
|
|
79a98d9bc1 | ||
|
|
a6894d063c | ||
|
|
90bc2fe272 | ||
|
|
c51900a6bd | ||
|
|
b214b51ca0 | ||
|
|
512e111a92 | ||
|
|
d25bf9dceb | ||
|
|
fdb7e5b44c | ||
|
|
b29e812e82 | ||
|
|
e347e9d722 | ||
|
|
87de29e6f0 | ||
|
|
dc4a8e6280 | ||
|
|
b021f59dfa | ||
|
|
6856089f7b | ||
|
|
7e1075dd74 | ||
|
|
a85752ff4b | ||
|
|
0d03baa068 | ||
|
|
57ae7da075 | ||
|
|
9bb5e5e9af | ||
|
|
d9cdf8ce28 | ||
|
|
5d8b8d8b74 | ||
|
|
bc22dbbf84 | ||
|
|
7cb24684cc | ||
|
|
739cf4e832 | ||
|
|
08f2a71ee3 | ||
|
|
4827dd27b0 | ||
|
|
f91dec277a | ||
|
|
512c906ca6 | ||
|
|
2ef40e9654 | ||
|
|
051c345f17 | ||
|
|
a899840bcc | ||
|
|
40c2d565ba | ||
|
|
eab0cebc76 | ||
|
|
8b3ec19019 | ||
|
|
383b1e3b5c | ||
|
|
9982e26c12 | ||
|
|
2741677b28 | ||
|
|
c1b6f9458a | ||
|
|
f3653f0d20 | ||
|
|
184a0298f3 | ||
|
|
1fb8739c0b | ||
|
|
a1a0b32bd7 | ||
|
|
9b16f4cc8c | ||
|
|
6e177448b9 | ||
|
|
504fa74e24 | ||
|
|
157ff3506e | ||
|
|
5916dec460 | ||
|
|
94251ff084 | ||
|
|
1a0104fc63 | ||
|
|
ed9120545f | ||
|
|
f433c3835f | ||
|
|
0d34887fe9 | ||
|
|
e373bb1933 | ||
|
|
72e962c97e | ||
|
|
0ec483f365 | ||
|
|
76576ba2f5 | ||
|
|
eb8fa94f2c | ||
|
|
cdb16829a6 | ||
|
|
dc16dc835c | ||
|
|
17720c10cd | ||
|
|
818dbee8dc | ||
|
|
b58a8b4ef5 | ||
|
|
6743f81136 | ||
|
|
0e5381fe93 | ||
|
|
72d052896a | ||
|
|
f7d1c59c22 | ||
|
|
5f2ea441ac | ||
|
|
da9f5e7fdf | ||
|
|
157a274da5 | ||
|
|
1a7f64b157 | ||
|
|
c3869f6564 | ||
|
|
a0851554bd | ||
|
|
4f812540a2 | ||
|
|
6e5bbc267a | ||
|
|
e73dfc3899 | ||
|
|
18ce670a33 | ||
|
|
04f1470c51 | ||
|
|
677610ec7c | ||
|
|
ba4b9d9d6e | ||
|
|
4682f132f2 | ||
|
|
8058da0065 | ||
|
|
2c7bed000e | ||
|
|
9e2ed5521d | ||
|
|
22e66dfc12 | ||
|
|
092239c608 | ||
|
|
116f832b45 | ||
|
|
63feb84a2d | ||
|
|
4b544e447e | ||
|
|
2708cd9ca0 | ||
|
|
7feeb7cf23 | ||
|
|
8378eca4d4 | ||
|
|
e3b22389a8 | ||
|
|
29ff7a3943 | ||
|
|
0ecdb0a52a | ||
|
|
12ff1eb9b9 | ||
|
|
c960211fe7 | ||
|
|
a5d8b18bea | ||
|
|
dec8bb25bb | ||
|
|
9c393fa194 | ||
|
|
3c7a6ae340 | ||
|
|
381e69eace | ||
|
|
c58c2ea3e4 | ||
|
|
d44893c5db | ||
|
|
b7a836c0a3 | ||
|
|
f5d58041d5 | ||
|
|
c7d33788e0 | ||
|
|
07bc841590 | ||
|
|
dd647e78ca | ||
|
|
87a2903cca | ||
|
|
137c167a16 | ||
|
|
8eacedd3b5 | ||
|
|
dcc543f44c | ||
|
|
b22067a582 | ||
|
|
cce03822fc | ||
|
|
b4be756402 | ||
|
|
e8139f2768 | ||
|
|
f33599c144 | ||
|
|
39fc8c581b | ||
|
|
d622ad088b | ||
|
|
5a0b032e9e | ||
|
|
e81d5a49b7 | ||
|
|
710e5f32fc | ||
|
|
46e51208c7 | ||
|
|
d2177c280c | ||
|
|
0dc92c8fde | ||
|
|
3bb1783158 | ||
|
|
fcdf32c159 | ||
|
|
9396e9104e | ||
|
|
dacff7cb2b | ||
|
|
f656cafd4c | ||
|
|
a15329798c | ||
|
|
49f7ebaac4 | ||
|
|
bf9e98344d | ||
|
|
0f8faebb97 | ||
|
|
d2d9234098 | ||
|
|
a1ec12dad6 | ||
|
|
cb3147d298 | ||
|
|
c78039b87d | ||
|
|
59b803e3d0 | ||
|
|
4f3ff2e700 | ||
|
|
a1e715698a | ||
|
|
4242d4f5c4 | ||
|
|
b8108fd2dd | ||
|
|
1d96b88c66 | ||
|
|
38bfb60c11 | ||
|
|
f0bafdb427 | ||
|
|
ace5387fb6 | ||
|
|
bbb82c231a | ||
|
|
5b9f908ce3 | ||
|
|
483297d5dd | ||
|
|
7dc26da47c | ||
|
|
526e43a1c2 | ||
|
|
2c42c1c2ce | ||
|
|
cc8b73b1d9 | ||
|
|
167b8025ac | ||
|
|
0601086bd8 | ||
|
|
70a2bd1864 | ||
|
|
31d7d5d8c8 | ||
|
|
6ed90c719e | ||
|
|
5b954a8756 | ||
|
|
2746a6c05c | ||
|
|
d80aaca2da | ||
|
|
48b9ff8555 | ||
|
|
b0823fb415 | ||
|
|
61d93cb0d8 | ||
|
|
29ebe8f50a | ||
|
|
06a369c34e | ||
|
|
64b39468b8 | ||
|
|
39137a5d05 | ||
|
|
5282e54c08 | ||
|
|
72565ddffe | ||
|
|
52d9bba712 | ||
|
|
0f197c8acd | ||
|
|
1bfffd6a2d | ||
|
|
16c005fe6a | ||
|
|
5ae0543737 | ||
|
|
dcc6638e46 | ||
|
|
a09dadf100 | ||
|
|
0981b56f26 | ||
|
|
ae96ae296b | ||
|
|
7cf7888ee9 | ||
|
|
1d6931a643 | ||
|
|
ffd3ba2805 | ||
|
|
9a0b4599c7 | ||
|
|
49d22be1a6 | ||
|
|
e8bb94a4e3 | ||
|
|
62b7b422a2 | ||
|
|
839f321fde | ||
|
|
afeeea66f3 | ||
|
|
ed5c4e770a | ||
|
|
194ca7b3f9 | ||
|
|
b0d3d97a0f | ||
|
|
69b1a35c6d | ||
|
|
c1c51585f6 | ||
|
|
a7f5e64909 | ||
|
|
533391a2a7 | ||
|
|
a6228c5437 | ||
|
|
77abf69a60 | ||
|
|
ae17ae779e | ||
|
|
ca3de82a18 | ||
|
|
76c9c9845e | ||
|
|
c0c8685d46 | ||
|
|
2c6754363f | ||
|
|
b5d6e9db91 | ||
|
|
73cfcbac05 | ||
|
|
6b5f3dd224 | ||
|
|
d81716addb | ||
|
|
3b9b0c5c16 | ||
|
|
5983242eef | ||
|
|
ce0adae571 | ||
|
|
1440ca24fd | ||
|
|
9675ed627d | ||
|
|
ec8e146a6d | ||
|
|
9783d76bf6 | ||
|
|
27d1636b33 | ||
|
|
0702758ca4 | ||
|
|
1a8e00ef27 | ||
|
|
d2e298b45d | ||
|
|
f088d94d25 | ||
|
|
9e8a6b696e | ||
|
|
daf28a3110 | ||
|
|
e4c0fce73c |
7
.gitattributes
vendored
Normal file
7
.gitattributes
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
*.texi* diff=texinfo
|
||||
|
||||
# Put something like the following e.g., in your ~/.gitconfig file
|
||||
# # Include proper "function name" string in diffs of texinfo.
|
||||
# # Derived from the regexp in emacs' lisp/add-log.el.
|
||||
# [diff "texinfo"]
|
||||
# funcname = "^@node[ \t][ \t]*\\([^,][^,]*\\)"
|
||||
55
.gitignore
vendored
55
.gitignore
vendored
@@ -5,14 +5,30 @@
|
||||
*/.deps
|
||||
*~
|
||||
.gdb-history
|
||||
.kludge-stamp
|
||||
.tarball-version
|
||||
.version
|
||||
ABOUT-NLS
|
||||
ChangeLog
|
||||
GNUmakefile
|
||||
ID
|
||||
INSTALL
|
||||
Makefile
|
||||
Makefile.in
|
||||
TAGS
|
||||
THANKS-to-translators
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
build-aux/.gitignore
|
||||
build-aux/compile
|
||||
build-aux/config.guess
|
||||
build-aux/config.sub
|
||||
build-aux/depcomp
|
||||
build-aux/install-sh
|
||||
build-aux/mdate-sh
|
||||
build-aux/missing
|
||||
build-aux/texinfo.tex
|
||||
build-aux/ylwrap
|
||||
config.cache
|
||||
config.h
|
||||
config.hin
|
||||
@@ -25,44 +41,33 @@ coreutils-*.tar.gz
|
||||
coreutils-*.tar.gz.sig
|
||||
coreutils-*.tar.lzma
|
||||
coreutils-*.tar.lzma.sig
|
||||
coreutils-*.xdelta
|
||||
coreutils-*.xdelta.sig
|
||||
gnulib-tests
|
||||
lib/.cvsignore
|
||||
lib/.gitignore
|
||||
lib/arpa
|
||||
lib/binary-io.h
|
||||
lib/charset.alias
|
||||
lib/configmake.h
|
||||
lib/uniwidth/
|
||||
lib/libcoreutils.a
|
||||
lib/printf.c
|
||||
lib/progname.c
|
||||
lib/progname.h
|
||||
lib/selinux
|
||||
lib/uniwidth
|
||||
m4/.cvsignore
|
||||
m4/.gitignore
|
||||
po/*.gmo
|
||||
po/*.po
|
||||
po/.gitignore
|
||||
po/.reference
|
||||
po/LINGUAS
|
||||
po/Makefile.in
|
||||
po/Makevars
|
||||
po/POTFILES
|
||||
po/checksums
|
||||
po/coreutils.pot
|
||||
po/stamp-po
|
||||
src/version.c
|
||||
src/version.h
|
||||
stamp-h1
|
||||
tests/*/*.log
|
||||
tests/cut/Makefile.am
|
||||
tests/cut/cut-tests
|
||||
tests/head/Makefile.am
|
||||
tests/head/head-tests
|
||||
tests/join/Makefile.am
|
||||
tests/join/join-tests
|
||||
tests/pr/Makefile.am
|
||||
tests/pr/pr-tests
|
||||
tests/sort/Makefile.am
|
||||
tests/sort/sort-tests
|
||||
tests/tac/Makefile.am
|
||||
tests/tac/tac-tests
|
||||
tests/tail/Makefile.am
|
||||
tests/tail/tail-tests
|
||||
tests/test/Makefile.am
|
||||
tests/test/test-tests
|
||||
tests/tr/Makefile.am
|
||||
tests/tr/tr-tests
|
||||
tests/uniq/Makefile.am
|
||||
tests/uniq/uniq-tests
|
||||
tests/wc/Makefile.am
|
||||
tests/wc/wc-tests
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.9.91
|
||||
6.12
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Suppress valgrind diagnostics we don't care about.
|
||||
|
||||
# Copyright (C) 2003, 2004, 2006-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003, 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
|
||||
@@ -90,3 +90,11 @@
|
||||
fun:gobble_file
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
utimensat-NULL
|
||||
Memcheck:Param
|
||||
utimensat(filename)
|
||||
fun:futimens
|
||||
fun:gl_futimens
|
||||
fun:main
|
||||
}
|
||||
|
||||
1
.x-sc_error_message_uppercase
Normal file
1
.x-sc_error_message_uppercase
Normal file
@@ -0,0 +1 @@
|
||||
build-aux/cvsu
|
||||
@@ -1,8 +1,5 @@
|
||||
ChangeLog
|
||||
Makefile.maint
|
||||
NEWS
|
||||
config-log
|
||||
po/
|
||||
src/df.c
|
||||
src/stat.c
|
||||
tests/misc/df-P
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
ChangeLog*
|
||||
Makefile.maint
|
||||
config.hin
|
||||
configure
|
||||
m4/jm-macros.m4
|
||||
src/system.h
|
||||
ChangeLog
|
||||
|
||||
2
.x-sc_program_name
Normal file
2
.x-sc_program_name
Normal file
@@ -0,0 +1,2 @@
|
||||
gl/lib/randint.c
|
||||
lib/euidaccess-stat.c
|
||||
@@ -1,11 +1,6 @@
|
||||
^configure$
|
||||
ChangeLog
|
||||
^TODO$
|
||||
^lib/mktime\.c$
|
||||
^lib/getloadavg\.c$
|
||||
^lib/euidaccess\.c$
|
||||
^lib/euidaccess-stat\.c$
|
||||
^lib/group-member\.c$
|
||||
^Makefile\.maint$
|
||||
^maint\.mk$
|
||||
^doc/coreutils.texi$
|
||||
^tests/misc/stty-invalid$
|
||||
|
||||
40
AUTHORS
40
AUTHORS
@@ -3,35 +3,35 @@ each followed by the name(s) of its author(s).
|
||||
|
||||
arch: David MacKenzie, Karel Zak
|
||||
base64: Simon Josefsson
|
||||
basename: FIXME unknown
|
||||
cat: Torbjorn Granlund, Richard M. Stallman
|
||||
basename: David MacKenzie
|
||||
cat: Torbjörn Granlund, Richard M. Stallman
|
||||
chcon: Russell Coker, Jim Meyering
|
||||
chgrp: David MacKenzie, Jim Meyering
|
||||
chmod: David MacKenzie, Jim Meyering
|
||||
chown: David MacKenzie, Jim Meyering
|
||||
chroot: Roland McGrath
|
||||
cksum: Q. Frank Xia
|
||||
comm: Richard Stallman, David MacKenzie
|
||||
cp: Torbjorn Granlund, David MacKenzie, Jim Meyering
|
||||
comm: Richard M. Stallman, David MacKenzie
|
||||
cp: Torbjörn Granlund, David MacKenzie, Jim Meyering
|
||||
csplit: Stuart Kemp, David MacKenzie
|
||||
cut: David Ihnat, David MacKenzie, Jim Meyering
|
||||
cut: David M. Ihnat, David MacKenzie, Jim Meyering
|
||||
date: David MacKenzie
|
||||
dd: Paul Rubin, David MacKenzie, Stuart Kemp
|
||||
df: Torbjorn Granlund, David MacKenzie, Paul Eggert
|
||||
dir: Richard Stallman, David MacKenzie
|
||||
df: Torbjörn Granlund, David MacKenzie, Paul Eggert
|
||||
dir: Richard M. Stallman, David MacKenzie
|
||||
dircolors: H. Peter Anvin
|
||||
dirname: David MacKenzie, Jim Meyering
|
||||
du: Torbjorn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
|
||||
echo: FIXME unknown
|
||||
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
|
||||
expr: Mike Parker, James Youngman
|
||||
factor: Paul Rubin
|
||||
false: Jim Meyering
|
||||
fmt: Ross Paterson
|
||||
fold: David MacKenzie
|
||||
ginstall: David MacKenzie
|
||||
groups: David MacKenzie
|
||||
groups: David MacKenzie, James Youngman
|
||||
head: David MacKenzie, Jim Meyering
|
||||
hostid: Jim Meyering
|
||||
hostname: Jim Meyering
|
||||
@@ -41,7 +41,7 @@ kill: Paul Eggert
|
||||
link: Michael Stone
|
||||
ln: Mike Parker, David MacKenzie
|
||||
logname: FIXME: unknown
|
||||
ls: Richard Stallman, David MacKenzie
|
||||
ls: Richard M. Stallman, David MacKenzie
|
||||
md5sum: Ulrich Drepper, Scott Miller, David Madore
|
||||
mkdir: David MacKenzie
|
||||
mkfifo: David MacKenzie
|
||||
@@ -58,10 +58,10 @@ pinky: Joseph Arceneaux, David MacKenzie, Kaveh Ghazi
|
||||
pr: Pete TerMaat, Roland Huebner
|
||||
printenv: David MacKenzie, Richard Mlynarik
|
||||
printf: David MacKenzie
|
||||
ptx: F. Pinard
|
||||
ptx: François Pinard
|
||||
pwd: Jim Meyering
|
||||
readlink: Dmitry V. Levin
|
||||
rm: Paul Rubin, David MacKenzie, Richard Stallman, Jim Meyering
|
||||
rm: Paul Rubin, David MacKenzie, Richard M. Stallman, Jim Meyering
|
||||
rmdir: David MacKenzie
|
||||
runcon: Russell Coker
|
||||
seq: Ulrich Drepper
|
||||
@@ -74,7 +74,7 @@ shred: Colin Plumb
|
||||
shuf: Paul Eggert
|
||||
sleep: Jim Meyering, Paul Eggert
|
||||
sort: Mike Haertel, Paul Eggert
|
||||
split: Torbjorn Granlund, Richard M. Stallman
|
||||
split: Torbjörn Granlund, Richard M. Stallman
|
||||
stat: Michael Meskes
|
||||
stty: David MacKenzie
|
||||
su: David MacKenzie
|
||||
@@ -84,19 +84,25 @@ tac: Jay Lepreau, David MacKenzie
|
||||
tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, Jim Meyering
|
||||
tee: Mike Parker, Richard M. Stallman, David MacKenzie
|
||||
test: Kevin Braunsdorf, Matthew Bradburn
|
||||
timeout: Pádraig Brady
|
||||
touch: Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, Randy Smith
|
||||
tr: Jim Meyering
|
||||
true: Jim Meyering
|
||||
truncate: Pádraig Brady
|
||||
tsort: Mark Kettenis
|
||||
tty: David MacKenzie
|
||||
uname: David MacKenzie
|
||||
unexpand: David MacKenzie
|
||||
uniq: Richard Stallman, David MacKenzie
|
||||
uniq: Richard M. Stallman, David MacKenzie
|
||||
unlink: Michael Stone
|
||||
uptime: Joseph Arceneaux, David MacKenzie, Kaveh Ghazi
|
||||
users: Joseph Arceneaux, David MacKenzie
|
||||
vdir: Richard Stallman, David MacKenzie
|
||||
vdir: Richard M. Stallman, David MacKenzie
|
||||
wc: Paul Rubin, David MacKenzie
|
||||
who: Joseph Arceneaux, David MacKenzie, Michael Stone
|
||||
whoami: Richard Mlynarik
|
||||
yes: David MacKenzie
|
||||
|
||||
;; Local Variables:
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
|
||||
605
ChangeLog-2005
605
ChangeLog-2005
@@ -1,3 +1,608 @@
|
||||
2005-12-27 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* Makefile.maint (sc_obsolete_symbols): Prohibit use of O_NDELAY.
|
||||
(sc_prohibit_assert_without_use): New rule.
|
||||
(syntax-check-rules): Add it to the list.
|
||||
* .x-sc_prohibit_assert_without_use: New empty file.
|
||||
* Makefile.am (EXTRA_DIST): Add it.
|
||||
|
||||
* Makefile.maint (CVS_LIST): Define in terms of $(srcdir).
|
||||
|
||||
* cp.c, df.c, link.c, mknod.c, nice.c, sleep.c, unlink.c:
|
||||
Don't include <assert.h>; it wasn't used.
|
||||
|
||||
2005-12-26 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/chown-core.c (restricted_chown):
|
||||
Don't try O_WRONLY unless O_RDONLY failed wth EACCES.
|
||||
* src/remove.c (fd_to_subdirp): Open with O_DIRECTORY | O_NOCTTY
|
||||
| O_NOFOLLOW too, for consistency with other dir-openers.
|
||||
Use POSIX-preferred O_NONBLOCK rather than O_NDELAY.
|
||||
(is_empty_dir): Likewise.
|
||||
* src/shred.c (wipename): Likewise. Don't bother trying to open
|
||||
dir for writing, since POSIX prohibits it.
|
||||
|
||||
2005-12-22 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* tests/help-version: Redirect stderr to /dev/full, to suppress
|
||||
write error diagnostic.
|
||||
|
||||
2005-12-19 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/mkdir.c, src/mknod.c, src/mkfifo.c (main)
|
||||
Avoid a minor race condition when `-m MODE' is specified, by using
|
||||
open, fchown, and close rather than just chown. To do that reliably --
|
||||
even with an overly restrictive umask -- ensure that each mkdir,
|
||||
mknod and mkfifo call uses a mode including at least owner-read access.
|
||||
* src/mknod.c (main): When `-m MODE' is specified, exit nonzero if
|
||||
the subsequent chown (or equivalent open,fchown,close) fails.
|
||||
* tests/misc/mknod: New tests.
|
||||
* tests/misc/Makefile.am (TESTS): Add mknod.
|
||||
|
||||
2005-12-17 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/remove.c (is_empty_dir): Open with O_NDELAY, so we don't hang,
|
||||
e.g., on a named pipe.
|
||||
(OPEN_NO_FOLLOW_SYMLINK): Remove definition. Use O_NOFOLLOW in
|
||||
place of all uses, since it is guaranteed (system.h) to be defined.
|
||||
|
||||
2005-12-05 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
Add POSIX ACL support
|
||||
* src/ls.c: Switch back from HAVE_ACL to USE_ACL: The acl() syscall
|
||||
is no requirement for ACL support; particularly, it does not exist
|
||||
on systems that have POSIX ACLs.
|
||||
* src/copy.h (cp_option_init) [umask_kill]: Remove member.
|
||||
* src/cp.c (umask_kill): With default acls, the umask is not to be
|
||||
applied. Remove umask_kill, don't change the process umask, and let
|
||||
the kernel apply the umask where appropriate.
|
||||
* src/cp.c (make_dir_parents_private): Fix logic for POSIX ACLs.
|
||||
* src/copy.c (get_dest_mode): Remove; it is obsolete after removing
|
||||
umask_kill.
|
||||
(copy_reg, copy_internal): Use copy_acl and set_acl
|
||||
instead of fchown/chown. Fix the logic for POSIX ACLs.
|
||||
(chown_succeded): Remove; we now always copy acls and
|
||||
preserve S_ISUID, S_ISGID, and S_ISVTX when needed, no matter if we
|
||||
did a chown before or not.
|
||||
* src/mv.c, src/install.c (cp_option_init): Don't set umask_kill member.
|
||||
* src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD, cp_LDADD,
|
||||
mv_LDADD, ginstall_LDADD): On systems with an ACL library, arrange
|
||||
to link with it via $(LIB_ACL), for the utilities that need it.
|
||||
|
||||
2005-12-16 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/remove.c (OPENAT_CWD_RESTORE__REQUIRE): Remove.
|
||||
(OPENAT_CWD_RESTORE__ALLOW_FAILURE): Likewise.
|
||||
(fd_to_subdirp): Remove openat_cwd_restore_allow_failure arg; its
|
||||
value is now signified by whether cwd_errno is null.
|
||||
(fd_to_subdirp, remove_dir, rm_1); Change cwd failure indicator from
|
||||
pointer-to-bool to pointer-to-errno-value. All callers changed.
|
||||
(rm_1): Don't bother setting a local cwd failure flag and then
|
||||
ORing it into the caller's. Just set the caller's.
|
||||
(rm): Use cwd failure errno value to print a slightly-better
|
||||
diagnostic.
|
||||
|
||||
2005-12-15 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/stat.c (print_it): Properly handle a backslash at the
|
||||
end of a --printf format string. Reported by Paul Eggert.
|
||||
* tests/misc/stat-printf (end-bs): Add a test for the above.
|
||||
|
||||
2005-12-15 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* tests/acl: Port to pre-POSIX shells like Solaris 8 /bin/sh.
|
||||
Don't assume /etc/passwd contains user names; use 'id' instead.
|
||||
|
||||
2005-12-15 Jim Meyering <jim@meyering.net>
|
||||
|
||||
stat: revert behavior of --format=FMT (-c)
|
||||
stat: add new option: --printf=FMT
|
||||
* NEWS: Mention this.
|
||||
* src/stat.c (isodigit, octtobin, hextobin): Define.
|
||||
(PRINTF_OPTION): Define.
|
||||
(interpret_backslash_escapes, trailing_delim): New globals.
|
||||
(usage): Document them. Alphabetize on long option names.
|
||||
(print_esc_char): New function.
|
||||
(print_it): Rewrite, in order to handle backslash escapes.
|
||||
(main): Handle new option. Set globals for --format, too.
|
||||
|
||||
* tests/misc/stat-printf: Test --printf and --format.
|
||||
* tests/misc/Makefile.am (TESTS): Add stat-printf.
|
||||
|
||||
2005-12-14 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* NEWS: sort now reports incompatible options.
|
||||
* src/sort.c (incompatible_options, check_ordering_compatibility):
|
||||
New functions.
|
||||
(main): Use them. Don't bother with a usage message for
|
||||
"sort -c a b", for consistency with other error diagnostics.
|
||||
* tests/sort/Test.pm (incompat1, incompat2, incompat3, incompat4):
|
||||
New tests.
|
||||
|
||||
* src/cat.c (main): Undo previous change. close_stdout already
|
||||
does the check, so the previous change wasn't necessary.
|
||||
|
||||
2005-12-13 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/cat.c (main): Check for close (STDOUT_FILENO) failure.
|
||||
|
||||
2005-12-12 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Install a more-conservative approach for sort -R. It's the
|
||||
same basic idea as the existing code, except it uses the full ISAAC
|
||||
approach (called the "more kosher" approach in the existing comments).
|
||||
This makes "sort -R" quite a bit slower (about a factor of 2 on my
|
||||
little tests involving 10000 lines on a 2.4 GHz P4), but I think it's
|
||||
better to be conservative here at first, and review any performance
|
||||
improvements carefully.
|
||||
* .x-sc_require_config_h: Add src/rand-isaac.c.
|
||||
* src/rand-isaac.h: Remove. All uses now simply include rand-isaac.c.
|
||||
* src/Makefile.am (noinst_HEADERS): Remove rand-isaac.h.
|
||||
(shred_SOURCES, sort_SOURCES): Remove.
|
||||
(EXTRA_DIST): Add rand-isaac.c.
|
||||
* src/rand-isaac.c: Revert to what used to be in shred.c, without
|
||||
changing it to allow for varying numbers of words in the state.
|
||||
Alter so that we include rand-isaac.c directly rather than
|
||||
compiling it and linking to it. Don't include config.h or
|
||||
system.h; that's the includer's responsibility.
|
||||
Omit functions that are specific to shred.
|
||||
(ISAAC_LOG, ISAAC_WORDS, ISAAC_BYTES, struct isaac_state, ind):
|
||||
(isaac_step, struct irand_state):
|
||||
Resurrect these, with the same defns that used to be in shred.c.
|
||||
(ISAAC_SIZE, isaac_new, isaac_copy): Remove.
|
||||
(isaac_refill, isaac_seed_start, isaac_seed_data, irand_init, irand32):
|
||||
static again.
|
||||
(struct isaac_state, isaac_refill, isaac_mix, isaac_init):
|
||||
(isaac_seed_start, isaac_seed_data, isaac_seed_finish, isaac_seed):
|
||||
(irand_init, irand32, irand_mod):
|
||||
Number of words is constant again.
|
||||
(struct irand_state, irand_init, irand32, irand_mod): Move to shred.c.
|
||||
* src/shred.c: Include rand-isaac.c rather than rand-isaac.h.
|
||||
* src/sort.c: Likewise.
|
||||
* src/shred.c (fillrand, dopass, main): Undo previous change.
|
||||
(struct irand_state, irand_init, irand32, irand_mod): Moved back here,
|
||||
from rand-isaac.c.
|
||||
* src/sort.c: Don't include md5.h; it wasn't needed.
|
||||
(struct keyfield): Rename random_hash to random, for consistency
|
||||
with the other member names. All uses changed.
|
||||
(usage): Tweak wording to mention STRING for --seed option.
|
||||
(short_options): Rorder for consistency with other programs.
|
||||
(rand_state): Now a struct, not a pointer to one. All uses changed.
|
||||
(HASH_WORDS, HASH_SIZE): Remove.
|
||||
(get_hash): Remove comments around resbuf size, since we can assume C89.
|
||||
Use a "more-kosher" (but slower) approach of invoking isaac_refill.
|
||||
(keycompare): Adjust to the new get_hash.
|
||||
Add a FIXME.
|
||||
(badfieldspec): Omit recently-introduced comment; it isn't needed.
|
||||
(main): Don't set need_random simply because gkey has it set; that
|
||||
doesn't necessarily mean we'll need random numbers.
|
||||
Redo seeding to match new get_hash approach.
|
||||
|
||||
2005-12-10 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/Makefile.am (noinst_HEADERS): Add rand-isaac.h.
|
||||
|
||||
Avoid shred segfault on 64-bit systems.
|
||||
* src/rand-isaac.c (isaac_refill): Don't try to negate a
|
||||
local of type uint32_t. Make the local an `int' instead.
|
||||
|
||||
* NEWS: Mention sort's new options.
|
||||
|
||||
* src/rand-isaac.c (isaac_mix): Declare to be static.
|
||||
Mark all other functions as `extern' so the tight-scope
|
||||
part of `make distcheck' passes once again.
|
||||
* src/rand-isaac.h (isaac_mix): Remove declaration.
|
||||
|
||||
* src/sort.c (get_hash): Change position of `*' in parameter
|
||||
type to conform with convention.
|
||||
(main): Split a long line so it fits in 80 columns.
|
||||
(keycompare): Remove stray SPACE before TAB that was
|
||||
causing `make distcheck' to fail.
|
||||
|
||||
* src/shred.c: Don't include gethrxtime.h. No longer needed.
|
||||
|
||||
* tests/misc/sort-rand: New file: basic tests for the new options.
|
||||
* tests/misc/Makefile.am (TESTS): Add sort-rand.
|
||||
|
||||
2005-12-10 Frederik Eaton <frederik@ofb.net>
|
||||
|
||||
* src/Makefile.am (sort_LDADD): Add $(LIB_GETHRXTIME).
|
||||
(shred_SOURCES, sort_SOURCES): New macros, so we compile rand-isaac.c.
|
||||
* src/rand-isaac.c: New file, containing ISAAC code that was in shred.c.
|
||||
Make state size runtime-configurable.
|
||||
(isaac_new, isaac_copy): New functions.
|
||||
* src/rand-isaac.h: New file.
|
||||
* src/shred.c: Include rand-isaac.h. Move ISAAC code to rand-isaac.c.
|
||||
(fillrand, main): Adjust to the fact that the state size is now
|
||||
runtime-configurable.
|
||||
* src/sort.c (short_options, long_options, WORDS, keycompare, main):
|
||||
(usage): Add options --random-sort and --seed to implement a random
|
||||
shuffle.
|
||||
Include md5.h and rand-isaac.h.
|
||||
(get_hash): New function.
|
||||
(rand_state): New var.
|
||||
(HASH_WORDS, HASH_SIZE): New macros.
|
||||
|
||||
2005-12-09 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* tests/dd/misc: Add test for dd iflags=noatime.
|
||||
|
||||
2005-12-09 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/sort.c (usage): Mention white space vs -b and -t options.
|
||||
From The Wanderer.
|
||||
|
||||
2005-12-09 Eric Blake <ebb9@byu.net>
|
||||
|
||||
* src/test.c (main): Fix misleading comment.
|
||||
|
||||
2005-12-07 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* NEWS: Mention dd's new noatime flag.
|
||||
* src/system.h (O_NOATIME): Define to 0 if not already defined.
|
||||
* src/dd.c (flags, usage): Add support for noatime flag.
|
||||
|
||||
2005-12-07 Jim Meyering <jim@meyering.net>
|
||||
|
||||
Distribute the cvsu script, used only by `make syntax-check'.
|
||||
* Makefile.am (EXTRA_DIST): Add build-aux/cvsu.
|
||||
* Makefile.maint (CVS_LIST): Use build-aux/cvsu, now that we
|
||||
distribute a copy of this script.
|
||||
* .x-sc_unmarked_diagnostics: Add build-aux/cvsu.
|
||||
|
||||
* tests/mv/acl: exit-77 before the trap, not after, if we fail
|
||||
to create a temporary directory on another partition.
|
||||
From Andreas Gruenbacher.
|
||||
|
||||
2005-12-06 Tomas Pospisek <tpo@sourcepole.ch> (tiny change)
|
||||
|
||||
* man/basename.x: Cross-reference to dirname and readlink.
|
||||
* man/dirname.x: Cross-reference to basename and readlink.
|
||||
|
||||
2005-12-05 Andreas Gruenbacher
|
||||
|
||||
* src/copy.c [!HAVE_FCHOWN]: Define fchown(...) to -1.
|
||||
(set_owner, preserve_author): New functions, factored out of copy_reg.
|
||||
(copy_reg): Use them.
|
||||
(copy_internal): Use them here, too.
|
||||
|
||||
2005-12-04 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/sleep.c (usage): Say what happens with two or more arguments.
|
||||
Suggested by Justin Pryzby.
|
||||
|
||||
* src/uptime.c (print_uptime): Move decl of `upsecs' into scope
|
||||
where it's used.
|
||||
|
||||
2005-12-03 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/rm.c (long_opts): Change the name of each undocumented, for-
|
||||
testing-only option to start with `-', so that it cannot render
|
||||
ambiguous any prefix it happens to share with some other option name.
|
||||
Problem reported by Eric Blake.
|
||||
* src/head.c (long_options): Likewise.
|
||||
* src/tail.c (long_options): Likewise.
|
||||
|
||||
* tests/misc/head-elide-tail: Update uses of undocumented, for-
|
||||
testing-only --presume* options to start with `---'.
|
||||
* tests/rm/dangling-symlink: Likewise.
|
||||
* tests/rm/dir-no-w: Likewise.
|
||||
* tests/rm/isatty: Likewise.
|
||||
|
||||
2005-11-30 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* Makefile.maint: Add a comment about cvsu.
|
||||
|
||||
2005-11-25 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* NEWS: df updates for "none", "proc", inaccessible file systems.
|
||||
* src/df.c (show_point): Ignore inaccessible file systems.
|
||||
(usage): -a includes dummy file systems, not size-0 file systems.
|
||||
|
||||
* src/od.c (unsigned_long_long_int): Renamed from ulonglong_t,
|
||||
to avoid collision with POSIX name space. All uses changed.
|
||||
|
||||
2005-11-24 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* tests/Makefile.am (EXTRA_DIST): Add acl to the list.
|
||||
* tests/acl: Add `$0: ' prefix to diagnostics.
|
||||
|
||||
* .x-sc_require_config_h: Add lib/buffer-lcm.c to the list.
|
||||
|
||||
2005-11-23 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/copy.c: Improve performance a bit by optimizing away
|
||||
unnecessary system calls and going to a block size of at least
|
||||
8192 (on normal hosts, anyway). This improved performance 5% on my
|
||||
Debian stable host (2.4.27 kernel, x86, copying from root
|
||||
ext3 file system to itself).
|
||||
Include "buffer-lcm.h".
|
||||
(copy_reg): Omit last argument. All callers changed.
|
||||
Use xmalloc to allocate rather than trusting alloca
|
||||
(which is unwise with large block sizes).
|
||||
Declare locals more locally, if possible.
|
||||
Use uintptr_t words instead of int words, for a bit more speed
|
||||
when looking for null blocks on 64-bit hosts.
|
||||
Optimize away reads of zero bytes on regular files.
|
||||
In the typical case, insist on 8 KiB buffers, at least.
|
||||
Avoid unnecessary extra call to fstat when checking for sparse files.
|
||||
Avoid now-unnecessary cast to off_t, and "0L".
|
||||
Avoid unnecessary test of *new_dst when checking for same owner
|
||||
and group.
|
||||
|
||||
2005-11-22 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/remove.c (rm): Don't assume C99 for-loop syntax.
|
||||
|
||||
2005-11-22 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/remove.c (AD_push): Remove debugging cruft.
|
||||
|
||||
* tests/rm/unread2 (rm): Change expected diagnostic,
|
||||
`cannot open directory' to `cannot remove', to align with
|
||||
new version of rm.
|
||||
* tests/rm/rm2: Ensure that rm now continues removing entries
|
||||
even after certain types of failure.
|
||||
|
||||
* src/remove.c: Rewrite. Now, this module is reentrant on systems
|
||||
that provide openat (Solaris), and on systems like Linux+procfs
|
||||
where our openat emulation code is reentrant. This also fixes a
|
||||
few low-probability leaks and eliminates some code that could,
|
||||
in very unusual circumstances, cause rm() (via a callee) to exit.
|
||||
* NEWS: Mention this.
|
||||
|
||||
* configure.ac: Put copyright dates all on one line so the
|
||||
emacs function that updates them works properly.
|
||||
|
||||
2005-11-18 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* configure.ac (AM_PROG_CC_C_O): Add. Needed for CVS Automake.
|
||||
Problem reported by Eric Blake.
|
||||
(AC_PROG_CC_STDC): Use this instead of AC_PROG_CC, so that
|
||||
we get a standard-conforming compiler. This relies on the new
|
||||
m4/c.m4 file. Note that it's a bit tricky, since c.m4 doesn't
|
||||
define AC_PROG_CC_STDC; we are relying on Autoconf 2.59 internals.
|
||||
m4/c.m4 can go away with Autoconf 2.60 comes out.
|
||||
|
||||
2005-11-17 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/remove.c (AD_mark_helper): Make a `char *' parameter `const'.
|
||||
(AD_mark_current_as_unremovable): Likewise, but for a local.
|
||||
(rm_1): Likewise.
|
||||
|
||||
* tests/mv/acl: Let traps handle removing temporary directories.
|
||||
|
||||
Expect acl-related tests to fail, until the corresponding
|
||||
patches are committed.
|
||||
* tests/mv/Makefile.am (XFAIL_TESTS): Add acl.
|
||||
* tests/cp/Makefile.am (XFAIL_TESTS): Likewise.
|
||||
|
||||
ACL tests, from Andreas Gruenbacher.
|
||||
* tests/acl, tests/mv/acl, tests/cp/acl: New files.
|
||||
* tests/mv/Makefile.am (TESTS): Add acl.
|
||||
* tests/cp/Makefile.am (TESTS): Add acl.
|
||||
|
||||
* src/ls.c (basename_is_dot_or_dotdot): Correct wording in comment.
|
||||
|
||||
2005-11-16 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* NEWS: Improve quality of ln's diagnostics.
|
||||
* src/ln.c (do_link, usage): Likewise.
|
||||
(do_link): Don't use alloca on a buffer of unbounded size.
|
||||
|
||||
2005-11-16 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* tests/cp/fail-perm: Accommodate HPUX. It appears to fail
|
||||
with EACCES rather than EPERM. Reported by Peter O'Gorman here:
|
||||
http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/5766
|
||||
This also affects AIX 4.3.3, according to Ralf Wildenhues, in
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2006-05/msg00192.html
|
||||
|
||||
2005-11-14 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* NEWS (sort): Mention consequences of today's mkstemp-safer.c fix.
|
||||
|
||||
2005-11-13 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* announce-gen: Accept new option, --gpg-key-id=ID and
|
||||
emit a blurb telling how to use the .sig files.
|
||||
* Makefile.cfg (gpg_key_ID): Define.
|
||||
* Makefile.maint (announcement): Use new option and key.
|
||||
|
||||
Require that most .c files include <config.h>.
|
||||
* Makefile.maint (sc_require_config_h): New rule.
|
||||
(syntax-check-rules): Add it.
|
||||
* .x-sc_require_config_h: New file listing exceptions to the
|
||||
above rule. Some are legit, others are simply grandfathered in.
|
||||
* Makefile.am (EXTRA_DIST): Add .x-sc_require_config_h here, too.
|
||||
|
||||
2005-11-12 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/checksum.h, src/md5.c, src/sha1sum.c: Remove now-unused files.
|
||||
|
||||
2005-11-11 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* NEWS: Mention `readlink -f' bug fix in 5.3.0 news.
|
||||
Mention new readlink options in 5.3.0's `New features' section.
|
||||
Spotted by Thomas Hood.
|
||||
|
||||
2005-11-08 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* NEWS: Merge in changes from b5_9x branch.
|
||||
|
||||
2005-11-08 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* NEWS: ls now defaults to --time-style='locale', which in turn acts
|
||||
like --time-style='posix-long-iso' if the locale settings are messed up.
|
||||
* src/ls.c (decode_switches): Implement this.
|
||||
|
||||
2005-11-08 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* tests/du/2g: s/expensive/very expensive/ in a comment.
|
||||
From Paul Townsend.
|
||||
|
||||
2005-10-17 Eric Blake <ebb9@byu.net>
|
||||
|
||||
* src/ls.c (usage): Fix descriptions of --sort, --time.
|
||||
Reported by Vitaly A. Ostanin.
|
||||
|
||||
2005-11-04 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/ln.c: Include filenamecat.c.
|
||||
(FILE_BASENAME_CONCAT): Remove.
|
||||
(do_link): Remove last arg DEST_IS_DIR. All callers changed.
|
||||
(main): Use file_name_concat, base_name, and strip_trailing_slashes
|
||||
instead of FILE_BASENAME_CONCAT. This simplifies the code, and avoids
|
||||
the use of alloca.
|
||||
|
||||
2005-11-04 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/du.c (process_file): Don't overflow for files of size >= 2^31
|
||||
on systems with stat.st_blocks of a signed 32-bit type.
|
||||
This bug causes trouble on some AIX 5.1 systems.
|
||||
Report and trivial patch from Paul Townsend:
|
||||
<http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00033.html>
|
||||
* NEWS: Mention this.
|
||||
|
||||
* tests/du/2g: New (very-expensive) test for the above-fixed bug.
|
||||
* tests/du/Makefile.am (TESTS): Add it here.
|
||||
* tests/very-expensive: New file.
|
||||
* tests/Makefile.am (EXTRA_DIST): Add it here.
|
||||
* tests/cp/perm: Mark this test as `very-expensive', too.
|
||||
|
||||
2005-11-02 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* NEWS: Mention that rm -d and maybe ln -d are scheduled for
|
||||
removal in 2006.
|
||||
* src/remove.h (struct rm_options): Remove unlink_dirs. All uses
|
||||
removed.
|
||||
* src/rm.c (usage): Don't mention rm -d.
|
||||
|
||||
2005-11-02 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* tests/dd/skip-seek: Fix typo in comment: s/fileutils/coreutils.
|
||||
From Andreas Schwab.
|
||||
|
||||
* tests/dd/unblock-sync: Redirect stderr to /dev/null so the
|
||||
`M+N records in/out' lines don't pollute `make check' output.
|
||||
|
||||
* tests/dd/skip-seek (sk-seek4): New test, to exercise the bug
|
||||
fixed on 2005-10-31. This test uses the new, IN_PIPE specifier.
|
||||
* tests/Coreutils.pm: Accept a new type of input specifier: IN_PIPE,
|
||||
to indicate that the input file should be piped into the command
|
||||
under test (via `cat FILE | $prog ...').
|
||||
|
||||
* src/remove.c (remove_entry): Emit a better diagnostic when rm
|
||||
(without -r) fails to remove a directory on a non-Linux system.
|
||||
This change affects only newer Solaris systems (with priv_*
|
||||
functions like priv_allocset). Reported by Keith Thompson.
|
||||
|
||||
* tests/rm/dir-nonrecur: New file/test for the above fix.
|
||||
* tests/rm/Makefile.am (TESTS): Add dir-nonrecur.
|
||||
|
||||
2005-11-01 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* NEWS: "tail -c 2 FILE" and "touch 0101000000" now operate as
|
||||
POSIX 1002.1-2001 requires.
|
||||
* src/tail.c (parse_obsolete_option): Implement this.
|
||||
Problem reported by Vincent Lefevre.
|
||||
* src/touch.c (main): Pass PDS_PRE_2000 to posixtime.
|
||||
* tests/tail/Test.pm (c-2, c-2-minus, c2, c2-minus): New tests.
|
||||
(test_vector): Add special cases for _POSIX2_VERSION, and
|
||||
regularize the old ones a bit.
|
||||
* tests/touch/obsolescent: Add y2000 test.
|
||||
|
||||
2005-10-31 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/dd.c (skip): Fix off-by-one error reported by
|
||||
Theodoros V. Kalamatianos.
|
||||
|
||||
2005-10-30 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* tests/mkdir/p-3: Require that the test be run as non-root.
|
||||
Problem and trivial fix reported by Theodoros V. Kalamatianos.
|
||||
|
||||
2005-10-28 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/ln.c (FILE_BASENAME_CONCAT): Omit unnecessary slashes in the
|
||||
boundary between DEST and SOURCE in the result.
|
||||
|
||||
2005-10-26 Dmitry V. Levin <ldv@altlinux.org>
|
||||
|
||||
* src/md5sum.c (main) [!O_BINARY]: Changed default read mode
|
||||
back to text, to sync with documentation and for backwards
|
||||
compatibility.
|
||||
|
||||
2005-10-25 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* tests/dircolors/simple (other-wr): Add an explicit test for
|
||||
the dircolors bug (NULL-dereference) fixed yesterday.
|
||||
|
||||
2005-10-24 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/tac.c (tac_file): When determining whether a file is seekable,
|
||||
also test whether it is a tty. Using only the lseek-based test would
|
||||
give a false positive on Solaris. Reported by Peter Fales.
|
||||
|
||||
2005-10-24 Dmitry V. Levin <ldv@altlinux.org>
|
||||
|
||||
* tests/install/d-slashdot: New test, for "install -d" failure.
|
||||
* tests/install/Makefile.am (TESTS): Add d-slashdot.
|
||||
* tests/mkdir/p-slashdot: New test, for "mkdir -p" failure.
|
||||
* tests/mkdir/Makefile.am (TESTS): Add p-slashdot.
|
||||
|
||||
2005-10-24 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/dircolors.c (ls_codes): Add missing comma.
|
||||
Anonymous report and patch from
|
||||
http://savannah.gnu.org/bugs/?func=detailitem&item_id=14849
|
||||
|
||||
* src/dircolors.c: Add compile-time assertion that the slack_codes
|
||||
and ls_codes arrays have the same number of elements. This would
|
||||
have prevented the above-fixed bug.
|
||||
|
||||
* src/expand.c (parse_tab_stops): Add a comment to make this function
|
||||
identical to the one in unexpand.c.
|
||||
* src/unexpand.c (parse_tab_stops): Adjust syntax to make this function
|
||||
identical to the one in expand.c.
|
||||
|
||||
* src/expand.c (next_file): Don't assume fopen cannot return stdin.
|
||||
|
||||
2005-10-23 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/md5sum.c (digest_check, main): Use ptr_align rather than
|
||||
a dangerous pointer-value-to-`unsigned' cast.
|
||||
* NEWS: mention the new sha* programs.
|
||||
* AUTHORS: Add new sha* programs.
|
||||
|
||||
2005-08-28 David Madore <david.madore@ens.fr>
|
||||
|
||||
Add new programs: sha224sum, sha256sum, sha384sum, sha512sum.
|
||||
* README: Add their names to the list.
|
||||
* src/md5sum.c: Provide framework for computing sha-2 hashes.
|
||||
* src/Makefile.am (sha224sum, sha256sum, sha384sum, sha512sum):
|
||||
Rules for compiling sha-2 utilities
|
||||
(noinst_HEADERS): Remove checksum.h.
|
||||
* man/sha512sum.x, man/sha384sum.x, man/sha256sum.x, man/sha224sum.x:
|
||||
New files.
|
||||
* man/Makefile.am (dist_man_MANS): Add the corresponding .1 names.
|
||||
(sha224sum.1, sha256sum.1, sha384sum.1, sha512sum.1): New dependencies.
|
||||
* tests/misc/sha224sum, tests/misc/sha256sum: New files.
|
||||
* tests/misc/sha384sum, tests/misc/sha512sum: New files.
|
||||
* tests/misc/Makefile.am (TESTS): Add new sha224sum, sha256sum,
|
||||
sha384sum, sha512sum test scripts here rather that each in its
|
||||
own directory.
|
||||
|
||||
2005-08-28 David Madore <david.madore@ens.fr>
|
||||
|
||||
* tests/sha1sum/basic-1 (million-a): Add the "million a's" test (one
|
||||
of the FIPS test vectors).
|
||||
|
||||
2005-10-23 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* configure.ac: Use 6.0-cvs as the version string.
|
||||
* NEWS: Adjust accordingly.
|
||||
|
||||
2005-10-22 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* Version 5.92.
|
||||
|
||||
4040
ChangeLog-2006
Normal file
4040
ChangeLog-2006
Normal file
File diff suppressed because it is too large
Load Diff
4022
ChangeLog-2007
Normal file
4022
ChangeLog-2007
Normal file
File diff suppressed because it is too large
Load Diff
374
ChangeLog-2008
Normal file
374
ChangeLog-2008
Normal file
@@ -0,0 +1,374 @@
|
||||
2008-02-07 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
We *do* need two different version files.
|
||||
One for tarball-only, the other to be updated any time we
|
||||
get a new value of $(VERSION).
|
||||
* Makefile.am (dist-hook): Create .tarball-version in dist tarball.
|
||||
* GNUmakefile (_curr-ver): Make git-version-gen use it.
|
||||
* .gitignore: Ignore it.
|
||||
|
||||
Fix a typo in description of size suffixes: s/GB/G/.
|
||||
* doc/coreutils.texi (od invocation, head invocation, tail invocation):
|
||||
Spotted by Bert Wesarg.
|
||||
|
||||
* NEWS [6.9.90]: Mention the added feature that head, od, split and
|
||||
tail now accept the standard size suffixes (kB, M, MB, G, GB, and
|
||||
so on for T, P, Y, Z, and Y) on arguments to selected options.
|
||||
|
||||
2008-02-06 Steven Schubiger <schubiger@gmail.com>
|
||||
|
||||
mkdir, split: write --verbose output to stdout, not stderr.
|
||||
* src/mkdir.c (verbose_output): New function.
|
||||
(announce_mkdir): Use it.
|
||||
* src/split.c (usage): Update.
|
||||
* src/split.c (cwrite): Write to stdout, not stderr.
|
||||
* doc/coreutils.texi (split invocation): Remove the mention
|
||||
of --verbose output being printed to stderr.
|
||||
* tests/mkdir/p-v: Redirect stdout, not stderr.
|
||||
* tests/misc/split-a: Likewise.
|
||||
* NEWS: Mention this change.
|
||||
* TODO: Remove this item.
|
||||
|
||||
2008-02-04 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
* Makefile.maint (announcement): Remove stale comment.
|
||||
|
||||
2008-02-02 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Clarify a comment.
|
||||
* tests/sort/Test.pm: Replace a vague ChangeLog reference with a URL.
|
||||
|
||||
2008-01-31 Bob Proulx <bob@proulx.com>
|
||||
|
||||
Improve wording of date and time man page.
|
||||
* man/date.x: Improve compact description of the --date=STRING.
|
||||
* man/touch.x: Likewise.
|
||||
Suggested by A. Costa.
|
||||
|
||||
2008-01-31 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Remove alignment constraint from the sha*_read_ctx functions.
|
||||
* lib/sha256.c (set_uint32): New function.
|
||||
(sha256_read_ctx, sha224_read_ctx): Use it.
|
||||
* lib/sha512.c (set_uint64): New function.
|
||||
(sha512_read_ctx, sha384_read_ctx): Use it.
|
||||
* lib/sha256.h: Remove warning about alignment constraint.
|
||||
* lib/sha512.h: Likewise.
|
||||
Prompted by similar changes in gnulib's sha1 and md[45] modules.
|
||||
|
||||
Adapt to new version of vc-list-files.
|
||||
* tests/check.mk (vc_exe_in_TESTS): Adapt to new constraint
|
||||
that vc-list-files be run only from $(top_srcdir).
|
||||
|
||||
Pull vc-list-files from gnulib.
|
||||
* bootstrap.conf (gnulib_modules): Add vc-list-files.
|
||||
* build-aux/vc-list-files: Remove file.
|
||||
|
||||
Improve the cp/parent-perm test.
|
||||
* tests/cp/parent-perm: Also check that perms of existing dest
|
||||
dirs are changed to match those of corresponding src dir
|
||||
|
||||
2008-01-30 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Don't modify argv in dd due to ',' in arguments.
|
||||
* src/dd.c: Include quotearg.h.
|
||||
(operand_matches): New function.
|
||||
(parse_symbols, operand_is): Use it.
|
||||
(parse_symbols): 1st arg is now const pointer. Don't modify it.
|
||||
msgid arg is now just the message, not a format.
|
||||
(scanargs): Add some 'const's to check for problems like the above.
|
||||
|
||||
2008-01-30 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
* src/c99-to-c89.diff: Adjust remove.c offsets, again.
|
||||
|
||||
Now that system.h defines is_empty_dir, include "openat.h".
|
||||
* src/system.h: Include "openat.h" here, ...
|
||||
* src/chcon.c: ... not here.
|
||||
* src/chmod.c: Likewise.
|
||||
* src/chown-core.c: Likewise.
|
||||
* src/remove.c: Likewise.
|
||||
|
||||
* src/c99-to-c89.diff: Adjust remove.c offsets.
|
||||
|
||||
Improve "rmdir --ignore-fail-on-non-empty"
|
||||
* src/rmdir.c (remove_parents, main): With --ignore-fail-on-non-empty,
|
||||
suppress a diagnostic also for other errno values, which can arise
|
||||
with read-only media or when the parent directory has the immutable
|
||||
attribute (set via chattr +i).
|
||||
(errno_may_be_empty, ignorable_failure): New functions.
|
||||
* src/remove.c (is_empty_dir): Move function to ...
|
||||
* src/system.h (is_empty_dir): ...here, and make it inline.
|
||||
Suggested by Josselin Mouette in <http://bugs.debian.org/363011>
|
||||
via Bob Proulx.
|
||||
* NEWS: Mention the improvement.
|
||||
|
||||
2008-01-29 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Don't modify argv in dd.
|
||||
* src/dd.c (operand_is): New function.
|
||||
(scanargs): Use it so that we don't need to modify argv, as a nicety.
|
||||
Problem reported by Adam Goode in
|
||||
<http://lists.gnu.org/archive/html/bug-coreutils/2008-01/msg00264.html>.
|
||||
|
||||
2008-01-29 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
* Makefile.am (BUILT_SOURCES): Ensure that .version exists.
|
||||
Reported by Bob Proulx.
|
||||
|
||||
2008-01-29 Bob Proulx <bob@proulx.com>
|
||||
|
||||
Improve the man pages of --date=STRING for 'date' and 'touch'.
|
||||
* man/date.x: Add a compact description of the --date=STRING.
|
||||
* man/touch.x: Likewise.
|
||||
Reported by A. Costa in http://bugs.debian.org/363011
|
||||
|
||||
2008-01-29 Michael Stone <mstone@debian.org>
|
||||
|
||||
Improve the description of when dd outputs its final statistics.
|
||||
* doc/coreutils.texi (dd invocation): Say that dd prints stats
|
||||
upon normal termination and upon SIGINT.
|
||||
|
||||
2008-01-29 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Avoid "make distcheck" failure: newly-created man/*.1 files not removed
|
||||
* Makefile.am (EXTRA_DIST): Add .version.
|
||||
(.version): New rule.
|
||||
(dist-hook): Don't create $(distdir)/.version here, now that it's
|
||||
being distributed.
|
||||
* man/Makefile.am (common_dep): Use ../.version, not ../VERSION.
|
||||
(../VERSION): Remove rule.
|
||||
* GNUmakefile (dummy): Create .version, not VERSION.
|
||||
Add an extra "...:= $(shell..." statement to ensure that
|
||||
.version exists even when the preceding code is not run.
|
||||
* .gitignore: Remove both .version and VERSION.
|
||||
|
||||
ls: don't segfault on files in /proc with an old libselinux
|
||||
* src/ls.c (gobble_file): Work around a bug in libselinux1-2.0.15
|
||||
whereby getfilecon returns 0 yet sets the context to NULL.
|
||||
Reported by Jan Moringen via Michael Stone in
|
||||
http://bugs.debian.org/463043
|
||||
* tests/ls/Makefile.am (TESTS): Add proc-selinux-segfault.
|
||||
* tests/ls/proc-selinux-segfault: Test for the above fix.
|
||||
* NEWS: Mention the fix.
|
||||
|
||||
2008-01-26 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Work around Darwin9's set-GID-like group ownership inheritance.
|
||||
This avoids another spurious Mac OS 10.5.1 (Darwin 9.1) test failure.
|
||||
* tests/cp/preserve-gid: Accept a group ID of 0, as well.
|
||||
Reported by Elias Pipping.
|
||||
|
||||
Emit "info coreutils 'PROG invocation'" into the man page,
|
||||
rather than just "info PROG". The latter would often fail
|
||||
or simply display the man page.
|
||||
* man/help2man: Change the template.
|
||||
Prompted by http://bugs.debian.org/399684
|
||||
|
||||
chcon: correct description of --no-dereference (-h) option.
|
||||
* src/chcon.c (usage): Remove invalid reference to lchown.
|
||||
Reported by Göran Uddeborg.
|
||||
|
||||
Ensure that each version string change propagates to man pages.
|
||||
* man/Makefile.am (common_dep): Don't depend on configure.ac for
|
||||
version changes. Instead, depend on ../VERSION.
|
||||
(../VERSION): New rule.
|
||||
* Makefile.am (DISTCLEANFILES): Define.
|
||||
* GNUmakefile: Update ./VERSION.
|
||||
* .gitignore: List VERSION.
|
||||
Reported by Sven Joachim.
|
||||
|
||||
Avoid cp/preserve-gid test failure on Mac OS 10.5.1 (Darwin 9.1)
|
||||
* tests/cp/preserve-gid: Set group as well as owner on ".".
|
||||
Reported by Elias Pipping.
|
||||
|
||||
Improve a warning about non-portable "mv" usage.
|
||||
* doc/coreutils.texi (mv invocation): Adjust the warning: moving a
|
||||
dir-symlink-specified-with-a-trailing-slash works in a surprising
|
||||
manner only on some systems. Reported by Tomas Pospisek in
|
||||
http://bugs.debian.org/343652.
|
||||
|
||||
2008-01-26 Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
* src/dircolors.hin (TERM): Add jfbterm.
|
||||
|
||||
2008-01-23 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Clean up build-related rules.
|
||||
* Makefile.cfg (gnulib_dir): Update comment.
|
||||
* Makefile.maint (announcement) [cl_date, utc_date]: Don't set
|
||||
now-unused variables.
|
||||
|
||||
* TODO: Update the note on getgrouplist.
|
||||
|
||||
2008-01-23 Zvi Har'El <rl@math.technion.ac.il>
|
||||
|
||||
Add a ";", so "make install" works with --enable-install-program=su.
|
||||
* src/Makefile.am (install_su): Add a semicolon. (tiny change)
|
||||
|
||||
2008-01-23 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Avoid misinterpreting mgetgroups failure in running root-only tests.
|
||||
* src/setuidgid.c (main): Don't misinterpret as size_t an error
|
||||
return from mgetgroups. Reported by Theodoros V. Kalamatianos.
|
||||
|
||||
* README: Remove/convert a few stray mentions of CVS.
|
||||
|
||||
2008-01-22 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Require automake-1.10.1, for its support of dist-lzma.
|
||||
* configure.ac (AM_INIT_AUTOMAKE): Require 1.10.1.
|
||||
|
||||
Version 6.10.
|
||||
|
||||
* NEWS: Record release date.
|
||||
|
||||
* README-hacking: Update to reflect existence of automake-1.10.1.
|
||||
|
||||
2008-01-18 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Update README.
|
||||
* README: Remove a note about failing tests on SunOS 4.
|
||||
On Mac OS 10.5.1 (Darwin 9.1), you'll need --disable-acl.
|
||||
(Running tests as root): Recommend using "check-root", not "check".
|
||||
|
||||
2008-01-17 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Do not define-away __attribute__ when __STRICT_ANSI__ is set.
|
||||
* src/system.h (__attribute__): Remove the __STRICT_ANSI__ disjunct.
|
||||
It has been unnecessary since approximately gcc-2.6, and now, leaving
|
||||
it would cause gcc -Werror -ansi to fail to compile csplit.c.
|
||||
* gl/lib/randread.c (__attribute__): Likewise.
|
||||
|
||||
2008-01-16 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
* NEWS: Mention the configure.ac fix.
|
||||
|
||||
* TODO: Add an introduction.
|
||||
Remove a few entries. Update a few others.
|
||||
|
||||
2008-01-13 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Remove each output redirection target before writing to it.
|
||||
* tests/check.mk (vc_exe_in_TESTS): Remove t1 and t2 _first_,
|
||||
in case they exist beforehand and are not writable.
|
||||
* build-aux/check.mk (am__check_pre): Likewise, remove $@-t.
|
||||
|
||||
2008-01-13 Elias Pipping <pipping@gentoo.org>
|
||||
|
||||
* configure.ac: Correct a non-portable use of sed.
|
||||
|
||||
2008-01-12 Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
* src/dircolors.hin (image formats): Add the .svg suffix.
|
||||
|
||||
2008-01-12 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Use new version of announce-gen.
|
||||
* Makefile.maint (announcement): Remove use of the
|
||||
--gnulib-snapshot-time-stamp option.
|
||||
Use new --gnulib-version option instead.
|
||||
(gnulib-version): New variable.
|
||||
|
||||
2008-01-11 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
* Version 6.9.92.
|
||||
|
||||
* tests/tr/Test.pm: Prefer en_US.ISO-8859-1 to en_US.iso88591.
|
||||
Suggestions from James Youngman and Pádraig Brady in
|
||||
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12218/focus=12227
|
||||
|
||||
2008-01-10 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
* README-hacking: Add Git to the list of required tools.
|
||||
|
||||
2008-01-08 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Fix a minor race condition when using cp -p --parents.
|
||||
* src/cp.c (make_dir_parents_private): If stat fails on the parent
|
||||
directory, do not add it to the list of directories whose modes
|
||||
might need fixing later. Also, do not bother invoking 'stat'
|
||||
unless the stat results might be needed later.
|
||||
|
||||
2008-01-08 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
parent-perm: avoid a bizarre test failure.
|
||||
* tests/cp/parent-perm: Accommodate the situation in which
|
||||
chmod ("dir", 02755) returns 0 yet fails to set the S_ISGID bit.
|
||||
|
||||
Remove uses of now-undefined Makefile variable.
|
||||
* src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): Remove uses
|
||||
of no-longer-defined variable, $(LIB_ACL_TRIVIAL).
|
||||
|
||||
2008-01-07 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
cp (but not copy.c): plug a small leak.
|
||||
* src/cp.c (do_copy) [--parents]: Free the attribute list.
|
||||
|
||||
Make a racy test failure less likely to happen.
|
||||
* tests/misc/tty-eof: Uncomment a debug "warn".
|
||||
This change happens to make this test far less likely to fail.
|
||||
With that statement commented out, this test would fail about
|
||||
20% of the time on my desktop. Now, it's gone 100 iterations
|
||||
in a row with no failure.
|
||||
|
||||
* NEWS: Mention the cp bug fix.
|
||||
|
||||
2008-01-07 Jan Blunck <jblunck@suse.de>
|
||||
|
||||
cp --parents: don't use uninitialized memory when restoring permissions
|
||||
* src/cp.c (make_dir_parents_private): Always stat each source
|
||||
directory, in case its permissions are required in re_protect,
|
||||
when setting permissions of a just-created destination directory.
|
||||
|
||||
2008-01-07 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
cp: add a test for today's bug fix.
|
||||
* tests/cp/parent-perm: New script. Test today's change.
|
||||
Based on reproducer from Jan Blunck.
|
||||
* tests/cp/Makefile.am (TESTS): Add parent-perm.
|
||||
|
||||
2008-01-06 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
touch: add a test for today's change.
|
||||
* tests/touch/now-owned-by-other: New script. Test today's change.
|
||||
* tests/touch/Makefile.am (TESTS): Add now-owned-by-other.
|
||||
* tests/Makefile.am (all_t): Add td, a new root-only test.
|
||||
(td): New target.
|
||||
* NEWS: Mention the improvement.
|
||||
|
||||
2008-01-06 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
touch: ignore "-d now" option, when appropriate
|
||||
* src/touch.c (main): Treat "-d now" as if it were absent, if
|
||||
neither -a nor -m is specified. Problem reported by Dan Jacobson in:
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2008-01/msg00010.html
|
||||
|
||||
2008-01-05 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Avoid tr case-conversion failure in some locales.
|
||||
* src/tr.c (skip_construct): New function.
|
||||
(main): When processing a pair of case-converting classes, don't
|
||||
iterate through the elements of each [:upper:] or [:lower:] class.
|
||||
Reported by Gerald Pfeifer in
|
||||
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12218>.
|
||||
* tests/tr/Test.pm [tolower-F]: New test for the above fix.
|
||||
[upcase-xtra, dncase-xtra]: New tests, for a related code path.
|
||||
* NEWS: Mention the tr bug fix.
|
||||
|
||||
2008-01-02 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* .gitignore: Ignore lzma-compressed files, too.
|
||||
|
||||
Update copyright date.
|
||||
* tests/sample-test: Likewise.
|
||||
* doc/coreutils.texi: Likewise.
|
||||
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without
|
||||
modification, are permitted provided the copyright notice
|
||||
and this notice are preserved.
|
||||
71
GNUmakefile
71
GNUmakefile
@@ -1,71 +0,0 @@
|
||||
# Having a separate GNUmakefile lets me `include' the dynamically
|
||||
# generated rules created via Makefile.maint as well as Makefile.maint itself.
|
||||
# This makefile is used only if you run GNU Make.
|
||||
# It is necessary if you want to build targets usually of interest
|
||||
# only to the maintainer.
|
||||
|
||||
# Copyright (C) 2001, 2003, 2006-2007 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/>.
|
||||
|
||||
# Systems where /bin/sh is not the default shell need this. The $(shell)
|
||||
# command below won't work with e.g. stock DOS/Windows shells.
|
||||
ifeq ($(wildcard /bin/s[h]),/bin/sh)
|
||||
SHELL = /bin/sh
|
||||
else
|
||||
# will be used only with the next shell-test line, then overwritten
|
||||
# by a configured-in value
|
||||
SHELL = sh
|
||||
endif
|
||||
|
||||
have-Makefile := $(shell test -f Makefile && echo yes)
|
||||
|
||||
# If the user runs GNU make but has not yet run ./configure,
|
||||
# give them a diagnostic.
|
||||
ifeq ($(have-Makefile),yes)
|
||||
|
||||
# Make tar archive easier to reproduce.
|
||||
export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
|
||||
|
||||
include Makefile
|
||||
|
||||
# Ensure that $(VERSION) is up to date for dist-related targets, but not
|
||||
# for others: running autoreconf and recompiling everything isn't cheap.
|
||||
ifeq (0,$(MAKELEVEL))
|
||||
_is-dist-target = $(filter dist% alpha beta major,$(MAKECMDGOALS))
|
||||
ifneq (,$(_is-dist-target))
|
||||
_curr-ver := $(shell build-aux/git-version-gen .version)
|
||||
ifneq ($(_curr-ver),$(VERSION))
|
||||
$(info INFO: running autoreconf for new version string: $(_curr-ver))
|
||||
dummy := $(shell rm -rf autom4te.cache; autoreconf)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(srcdir)/Makefile.cfg
|
||||
include $(srcdir)/Makefile.maint
|
||||
|
||||
else
|
||||
|
||||
all:
|
||||
@echo There seems to be no Makefile in this directory. 1>&2
|
||||
@echo "You must run ./configure before running \`make'." 1>&2
|
||||
@exit 1
|
||||
|
||||
endif
|
||||
|
||||
# Tell version 3.79 and up of GNU make to not build goals in this
|
||||
# directory in parallel. This is necessary in case someone tries to
|
||||
# build multiple targets on one command line.
|
||||
.NOTPARALLEL:
|
||||
404
HACKING
Normal file
404
HACKING
Normal file
@@ -0,0 +1,404 @@
|
||||
Coreutils Contribution Guidelines
|
||||
|
||||
|
||||
Prerequisites
|
||||
=============
|
||||
You will need the "git" version control tools.
|
||||
On Fedora-based systems, do "yum install git".
|
||||
On Debian-based ones install the "git-core" package.
|
||||
Then run "git --version". If that says it's older than
|
||||
version 1.4.4, then you'd do well to get a newer version.
|
||||
At worst, just download the latest stable release from
|
||||
http://git.or.cz/ and build from source.
|
||||
|
||||
For details on building the programs in this package, see
|
||||
the file, README-hacking.
|
||||
|
||||
|
||||
Use the latest upstream sources
|
||||
===============================
|
||||
Base any changes you make on the latest upstream sources.
|
||||
You can get a copy of the latest with this command:
|
||||
|
||||
git clone git://git.sv.gnu.org/coreutils
|
||||
|
||||
That downloads the entire repository, including revision control history
|
||||
dating back to 1991. The repository (the part you download, and which
|
||||
resides in coreutils/.git) currently weighs in at about 30MB. So you
|
||||
don't want to download it more often than necessary. Once downloaded,
|
||||
you can get incremental updates by running one of these commands from
|
||||
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
|
||||
|
||||
|
||||
*Before* you commit changes
|
||||
===========================
|
||||
|
||||
In this project, we much prefer patches that automatically record
|
||||
authorship. That is important not just to give credit where due, but
|
||||
also from a legal standpoint (see below). To create author-annotated
|
||||
patches with git, you must first tell git who you are. That information
|
||||
is best recorded in your ~/.gitconfig file. Edit that file, creating
|
||||
it if needed, and put your name and email address in place of these
|
||||
example values:
|
||||
|
||||
[user]
|
||||
name = Joe X. User
|
||||
email = joe.user@example.com
|
||||
|
||||
|
||||
Your first commit: the quick and dirty way
|
||||
==========================================
|
||||
First of all, realize that to "commit" a change in git is a purely
|
||||
local operation. It affects only the local repository (the .git/ dir)
|
||||
in your current coreutils/ hierarchy.
|
||||
|
||||
To try this out, modify a file or two. If you create a new file, you'll
|
||||
need to tell git about it with "git add new-file.c". Commit all changes
|
||||
with "git commit -a". That prompts you for a log message, which should
|
||||
include a one-line summary, a blank line, and ChangeLog-style entries
|
||||
for all affected files. More on that below.
|
||||
|
||||
Once your change is committed, you can create a proper patch that includes
|
||||
a log message and authorship information as well as any permissions
|
||||
changes. Use this command to save that single, most-recent change set:
|
||||
|
||||
git format-patch --stdout -1 > DIFF
|
||||
|
||||
The trouble with this approach is that you've just checked in a change
|
||||
(remember, it's only local) on the "master" branch, and that's where new
|
||||
changes would normally appear when you pull the latest from "upstream".
|
||||
When you "pull" from a remote repository to get the latest, your local
|
||||
changes on "master" may well induce conflicts. For this reason, you
|
||||
may want to keep "master" free of any local changes, so that you can
|
||||
use it to track unadulterated upstream sources.
|
||||
|
||||
However, if your cloned directory is for a one-shot patch submission and
|
||||
you're going to remove it right afterwards, then this approach is fine.
|
||||
Otherwise, for a more sustainable (and more generally useful, IMHO)
|
||||
process, read on about "topic" branches.
|
||||
|
||||
|
||||
Make your changes on a private "topic" branch
|
||||
=============================================
|
||||
So you checked out coreutils like this:
|
||||
|
||||
git clone git://git.sv.gnu.org/coreutils
|
||||
|
||||
Now, cd into the coreutils/ directory and run:
|
||||
|
||||
git checkout -b my-topic
|
||||
|
||||
That creates the my-topic branch and puts you on it.
|
||||
To see which branch you're on, type "git branch".
|
||||
Right after the clone, you were on "master" (aka the trunk).
|
||||
To get back to the trunk, do this:
|
||||
|
||||
git checkout master
|
||||
|
||||
Note 1:
|
||||
Be careful to run "git pull" only when on the "master" branch,
|
||||
not when on a branch. With newer versions of git, you can't cause
|
||||
trouble if you forget, so this is a good reason to ensure you're
|
||||
using 1.5.3.1 or newer.
|
||||
|
||||
Note 2:
|
||||
It's best not to try to switch from one branch to another if
|
||||
you have pending (uncommitted) changes. Sometimes it works,
|
||||
sometimes the checkout will fail, telling you that your local
|
||||
modifications conflict with changes required to switch branches.
|
||||
However, in any case, you will *not* lose your uncommitted changes.
|
||||
|
||||
Anyhow, get back onto your just-created branch:
|
||||
|
||||
git checkout my-topic
|
||||
|
||||
Now, modify some file and commit it:
|
||||
|
||||
git commit some-file.c
|
||||
|
||||
Personally, no matter what package I'm working on, I find it useful to
|
||||
put the ChangeLog entries *only* in the commit log, initially, unless
|
||||
I plan to commit/push right away. Otherwise, I tend to get unnecessary
|
||||
merge conflicts with each rebase (see below). In coreutils, I've gone
|
||||
a step further, and no longer maintain an explicit ChangeLog file in
|
||||
version control. Instead, in a git working directory, you can view
|
||||
ChangeLog information via "git log". However, each distribution tarball
|
||||
does include a ChangeLog file that is automatically generated from the
|
||||
git logs.
|
||||
|
||||
So, you've committed a change. But it's only in your local repository,
|
||||
and only on your "my-topic" branch. Let's say you wait a day, and
|
||||
then see that someone else changed something and pushed it to the
|
||||
public repository. Now, you want to update your trunk and "rebase"
|
||||
your changes on the branch so that they are once again relative to the
|
||||
tip of the trunk. Currently, your branch is attached to the trunk at
|
||||
the next-to-last change set.
|
||||
|
||||
First: update the trunk from the public repo:
|
||||
[you've first made sure that "git diff" produces no output]
|
||||
|
||||
git checkout master
|
||||
git pull
|
||||
|
||||
Now, return to your branch, and "rebase" relative to trunk (master):
|
||||
|
||||
git checkout my-topic
|
||||
git rebase master
|
||||
|
||||
If there are no conflicts, this requires no more work from you.
|
||||
However, let's say there was one in ChangeLog, since you didn't
|
||||
follow my advice and modified it anyway.
|
||||
git rebase will tell you there was a conflict and in which
|
||||
file, and instruct you to resolve it and then resume with
|
||||
"git rebase --continue" once that's done.
|
||||
|
||||
So you resolve as usual, by editing ChangeLog (which has the
|
||||
usual conflict markers), then type "git rebase --continue".
|
||||
That will fail, with a diagnostic telling you to mark
|
||||
the file as "conflict resolved" by doing this:
|
||||
|
||||
git add ChangeLog
|
||||
|
||||
Then, finally, you can proceed (possibly onto more conflict resolution,
|
||||
if there are conflicts in other files):
|
||||
|
||||
git rebase --continue
|
||||
|
||||
Once it finishes, your changes on the branch are now relative to
|
||||
the tip of the trunk.
|
||||
|
||||
Now use git format-patch, as above.
|
||||
|
||||
|
||||
Amending the most recent change on your private branch
|
||||
======================================================
|
||||
Let's say you've just committed a change on your private
|
||||
branch, and then realize that something about it is not right.
|
||||
It's easy to adjust:
|
||||
|
||||
edit your files # this can include running "git add NEW" or "git rm BAD"
|
||||
git commit --amend -e -a
|
||||
git format-patch --stdout -1 > your-branch.diff
|
||||
|
||||
That replaces the most recent change-set with the revised one.
|
||||
|
||||
|
||||
|
||||
Coreutils-specific:
|
||||
|
||||
No more ChangeLog files
|
||||
=======================
|
||||
Do not modify any of the ChangeLog files in coreutils. Starting in
|
||||
2008, the policy changed. Before, we would insert the exact same text
|
||||
(or worse, sometimes slightly differing) into both the ChangeLog file
|
||||
and the commit log. Now we put that information only in the commit log,
|
||||
and generate the top-level ChangeLog file from logs at "make dist" time.
|
||||
As such, there are strict requirements on the form of the commit log
|
||||
messages.
|
||||
|
||||
|
||||
Commit log requirements
|
||||
=======================
|
||||
Your commit log should always start with a one-line summary, the second
|
||||
line should be blank, and the remaining lines are usually ChangeLog-style
|
||||
entries for all affected files. Omit the leading TABs that you're used
|
||||
to seeing in a "real" ChangeLog file.
|
||||
|
||||
Try to make the summary line fit one of the following forms:
|
||||
|
||||
program_name: change-description
|
||||
prog1, prog2: change-description
|
||||
doc: change-description
|
||||
tests: change-description
|
||||
|
||||
|
||||
Use SPACE-only indentation in new files.
|
||||
========================================
|
||||
In any new file, eliminate all leading TABs (e.g., via running GNU indent
|
||||
with --no-tabs) and put these lines at the end of the file:
|
||||
[FIXME: suggest vim syntax to do same thing, if it can be done safely.
|
||||
Most distros now "set nomodeline" by default for a good reason. ]
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
||||
Do not change TABs to spaces or vice versa in any existing file.
|
||||
|
||||
|
||||
Send patches to the address listed in --help output
|
||||
===================================================
|
||||
Please follow the guidelines in the "Sending your patches." section of
|
||||
git's own SubmittingPatches:
|
||||
|
||||
http://git.kernel.org/?p=git/git.git;a=blob;f=Documentation/SubmittingPatches
|
||||
|
||||
|
||||
Add documentation
|
||||
=================
|
||||
If you add a feature or change some user-visible aspect of a program,
|
||||
document it. If you add an option, document it both in --help output
|
||||
(i.e., in the usage function that generates the --help output) and in
|
||||
doc/*.texi. The man pages are generated from --help output, so
|
||||
you shouldn't need to change anything under man/. User-visible changes
|
||||
are usually documented in NEWS, too.
|
||||
|
||||
When writing prose (documentation, comments, log entries), use an
|
||||
active voice, not a passive one. I.e., say "print the frobnozzle",
|
||||
not "the frobnozzle will be printed".
|
||||
|
||||
|
||||
Minor syntactic preferences
|
||||
===========================
|
||||
[I hesitate to write this one down, because it appears to be an
|
||||
acquired taste, at least for native-English speakers. It seems odd
|
||||
(if not truly backwards) to nearly anyone who doesn't have a strong
|
||||
mathematics background and perhaps a streak of something odd in their
|
||||
character ;-) ]
|
||||
In writing arithmetic comparisons, use "<" and "<=" rather than
|
||||
">" and ">=". For some justification, read this:
|
||||
http://thread.gmane.org/gmane.comp.version-control.git/3903/focus=4126
|
||||
|
||||
const placement:
|
||||
Write "Type const *var", not "const Type *var".
|
||||
FIXME: dig up justification
|
||||
|
||||
|
||||
Be nice to translators
|
||||
======================
|
||||
Don't change translatable strings if you can avoid it.
|
||||
If you must rearrange individual lines (e.g., in multi-line --help
|
||||
strings), extract and create new strings, rather than extracting
|
||||
and moving into existing blocks. This avoids making unnecessary
|
||||
work for translators.
|
||||
|
||||
|
||||
Add tests
|
||||
==========
|
||||
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.
|
||||
|
||||
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
|
||||
in tests/misc.
|
||||
|
||||
If writing tests is not your thing, don't worry too much about it,
|
||||
but do provide scenarios, input/output pairs, or whatever, along with
|
||||
examples of running the tool to demonstrate the new or changed feature,
|
||||
and someone else will massage that into a test (writing portable tests
|
||||
can be a challenge).
|
||||
|
||||
|
||||
Copyright assignment
|
||||
====================
|
||||
If your change is significant (i.e., if it adds more than ~10 lines),
|
||||
then you'll have to have a copyright assignment on file with the FSF.
|
||||
Since that involves first an email exchange between you and the FSF,
|
||||
and then the exchange (FSF to you, then back) of an actual sheet of paper
|
||||
with your signature on it, and finally, some administrative processing
|
||||
in Boston, the process can take a few weeks.
|
||||
|
||||
The forms to choose from are in gnulib's doc/Copyright/ directory.
|
||||
If you want to assign a single change, you should use the file,
|
||||
doc/Copyright/request-assign.changes:
|
||||
|
||||
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=doc/Copyright/request-assign.changes;hb=HEAD
|
||||
|
||||
If you would like to assign past and future contributions to a project,
|
||||
you'd use doc/Copyright/request-assign.future:
|
||||
|
||||
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=doc/Copyright/request-assign.future;hb=HEAD
|
||||
|
||||
You may make assignments for up to four projects at a time.
|
||||
|
||||
|
||||
Run "make syntax-check", or even "make distcheck"
|
||||
================================================
|
||||
Making either of those targets runs many integrity and
|
||||
project-specific policy-conformance tests. For example, the former
|
||||
ensures that you add no trailing blanks and no uses of certain deprecated
|
||||
functions. The latter performs all "syntax-check" tests, and also
|
||||
ensures that the build completes with no warnings when using a certain
|
||||
set of gcc -W... options. Don't even bother running "make distcheck"
|
||||
unless you have a reasonably up to date installation including recent
|
||||
versions of gcc and the linux kernel, and modern GNU tools.
|
||||
|
||||
|
||||
Ensure that your changes are indented properly.
|
||||
===============================================
|
||||
Format the code the way GNU indent does.
|
||||
In a file with the "indent-tabs-mode: nil" directive at the end,
|
||||
running "indent --no-tabs" should induce no change.
|
||||
With other files, there will be some existing differences.
|
||||
Try not to add any more.
|
||||
|
||||
|
||||
-------------------------------------------
|
||||
|
||||
Miscellaneous useful git commands
|
||||
=================================
|
||||
|
||||
* gitk: give a graphical view of the revision graph
|
||||
* git log: to get most of the same info in text form
|
||||
* git log -p: same as above, but with diffs
|
||||
* git log -p SOME_FILE: same as above, but limit to SOME_FILE
|
||||
* git reset --soft HEAD^: Commit the delta required to restore
|
||||
state to the revision just before HEAD (i.e., next-to-last).
|
||||
* git rebase -i master: run this from on a branch, and it gives
|
||||
you an interface with which you can reorder and modify arbitrary
|
||||
change sets on that branch.
|
||||
|
||||
* if you "misplace" a change set, i.e., via git reset --hard ..., so that
|
||||
it's no longer reachable by any branch, you can use "git fsck" to find
|
||||
its SHA1 and then tag it or cherry-pick it onto an existing branch.
|
||||
For example, run this:
|
||||
git fsck --lost-found HEAD && cd .git/lost-found/commit \
|
||||
&& for i in *; do git show $i|grep SOME_IDENTIFYING_STRING \
|
||||
&& echo $i; done
|
||||
The "git fsck ..." command creates the .git/lost-found/... hierarchy
|
||||
listing all unreachable objects. Then the for loop
|
||||
print SHA1s for commits that match via log or patch.
|
||||
For example, say that found 556fbb57216b119155cdda824c98dc579b8121c8,
|
||||
you could run "git show 556fbb57216b119" to examine the change set,
|
||||
or "git checkout -b found 556fbb5721" to give it a branch name.
|
||||
Finally, you might run "git checkout master && git cherry-pick 556fbb5721"
|
||||
to put that change on the tip of "master".
|
||||
|
||||
-------------------------------------------
|
||||
|
||||
Finding things to do
|
||||
====================
|
||||
If you don't know where to start, check out the TODO file for projects
|
||||
that look like they're at your skill-/interest-level. Another good
|
||||
option is always to improve tests. You never know what you might
|
||||
uncover when you improve test coverage, and even if you don't find
|
||||
any bugs your contribution is sure to be appreciated.
|
||||
|
||||
A good way to quickly assess current test coverage is to use "lcov"
|
||||
to generate HTML coverage reports. Follow these steps:
|
||||
|
||||
# configure with coverage information
|
||||
./configure CFLAGS="-g -fprofile-arcs -ftest-coverage"
|
||||
make
|
||||
# run whatever tests you want, i.e.:
|
||||
make check
|
||||
# run lcov
|
||||
lcov -t coreutils -q -d lib -b lib -o lib.lcov -c
|
||||
lcov -t coreutils -q -d src -b src -o src.lcov -c
|
||||
# generate HTML from the output
|
||||
genhtml -p `pwd` -t coreutils -q --output-directory lcov-html *.lcov
|
||||
|
||||
Then just open the index.html file (in the generated lcov-html directory)
|
||||
in your favorite web browser.
|
||||
53
Makefile.am
53
Makefile.am
@@ -1,6 +1,6 @@
|
||||
# Make coreutils. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 1990, 1993-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1990, 1993-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
|
||||
@@ -16,12 +16,15 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
SUBDIRS = lib src doc man po tests gnulib-tests
|
||||
EXTRA_DIST = Makefile.cfg Makefile.maint GNUmakefile \
|
||||
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_file_system \
|
||||
.x-sc_obsolete_symbols \
|
||||
.x-sc_program_name \
|
||||
.x-sc_prohibit_atoi_atof \
|
||||
.x-sc_prohibit_strcmp \
|
||||
.x-sc_require_config_h \
|
||||
@@ -30,6 +33,9 @@ EXTRA_DIST = Makefile.cfg Makefile.maint GNUmakefile \
|
||||
.x-sc_unmarked_diagnostics \
|
||||
.x-sc_useless_cpp_parens \
|
||||
ChangeLog-2005 \
|
||||
ChangeLog-2006 \
|
||||
ChangeLog-2007 \
|
||||
ChangeLog-2008 \
|
||||
bootstrap \
|
||||
bootstrap.conf \
|
||||
build-aux/cvsu \
|
||||
@@ -53,7 +59,7 @@ ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
# Some tests always need root privileges, others need them only sometimes.
|
||||
check-root:
|
||||
cd tests && $(MAKE) $@
|
||||
cd tests && $(MAKE) $@ SUBDIRS=
|
||||
|
||||
# Just prior to distribution, ...
|
||||
# transform the automake-generated rule that runs `rm -f rm'.
|
||||
@@ -65,17 +71,32 @@ check-root:
|
||||
rm_subst = \
|
||||
s!(rm -f (rm\b|\$$\(bin_PROGRAMS\)$$))!$$1 > /dev/null 2>&1 || /bin/$$1!
|
||||
|
||||
# Arrange so that .version appears only in distribution tarballs,
|
||||
# never in a checked-out repository.
|
||||
BUILT_SOURCES = .version
|
||||
.version:
|
||||
echo $(VERSION) > $@-t && mv $@-t $@
|
||||
|
||||
# Arrange so that .tarball-version appears only in the distribution
|
||||
# tarball, and never in a checked-out repository.
|
||||
# The perl substitution is to change some key uses of "rm" to "/bin/rm".
|
||||
# See the rm_subst comment for details.
|
||||
dist-hook:
|
||||
echo $(VERSION) > $(distdir)/.version
|
||||
dist-hook: gen-ChangeLog
|
||||
echo $(VERSION) > $(distdir)/.tarball-version
|
||||
perl -pi -e '$(rm_subst)' $(distdir)/src/Makefile.in
|
||||
|
||||
distcheck-hook:
|
||||
gen_start_date = 2008-02-08
|
||||
.PHONY: gen-ChangeLog
|
||||
gen-ChangeLog:
|
||||
if test -d .git; then \
|
||||
$(top_srcdir)/build-aux/gitlog-to-changelog \
|
||||
--since=$(gen_start_date) > $(distdir)/cl-t; \
|
||||
rm -f $(distdir)/ChangeLog; \
|
||||
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
|
||||
fi
|
||||
|
||||
distcheck-hook: check-ls-dircolors
|
||||
$(MAKE) my-distcheck
|
||||
|
||||
DISTCLEANFILES = VERSION
|
||||
MAINTAINERCLEANFILES = THANKS-to-translators
|
||||
THANKS-to-translators: po/LINGUAS THANKStt.in
|
||||
( \
|
||||
@@ -84,3 +105,17 @@ THANKS-to-translators: po/LINGUAS THANKStt.in
|
||||
echo http://www.iro.umontreal.ca/contrib/po/HTML/team-$$lang.html; \
|
||||
done; \
|
||||
) > $@-tmp && mv $@-tmp $@
|
||||
|
||||
# Ensure that the sets of two-letter codes in ls.c and dircolors.c
|
||||
# remain in sync.
|
||||
.PHONY: check-ls-dircolors
|
||||
check-ls-dircolors:
|
||||
dc=$$(sed -n '/static.*ls_codes\[/,/};'/p \
|
||||
$(srcdir)/src/dircolors.c \
|
||||
|sed -n '/^ *"/p'|tr , '\n'|sed 's/^ *//' \
|
||||
|sed -n 's/^"\(..\)"/\1/p'|sort -u); \
|
||||
ls=$$(sed -n '/static.*indicator_name\[/,/};'/\p \
|
||||
$(srcdir)/src/ls.c \
|
||||
|sed -n '/^ *"/p'|tr , '\n'|sed 's/^ *//' \
|
||||
|sed -n 's/^"\(..\)"/\1/p'|sort -u); \
|
||||
test "$$dc" = "$$ls"
|
||||
|
||||
229
NEWS
229
NEWS
@@ -1,5 +1,227 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 7.0 (2008-10-05) [beta]
|
||||
|
||||
** New programs
|
||||
|
||||
timeout: Run a command with bounded time.
|
||||
truncate: Set the size of a file to a specified size.
|
||||
|
||||
** New features
|
||||
|
||||
chgrp, chmod, chown, chcon, du, rm: now all display linear performance,
|
||||
even when operating on million-entry directories on ext3 and ext4 file
|
||||
systems. Before, they would exhibit O(N^2) performance, due to linear
|
||||
per-entry seek time cost when operating on entries in readdir order.
|
||||
Rm was improved directly, while the others inherit the improvement
|
||||
from the newer version of fts in gnulib.
|
||||
|
||||
comm now verifies that the inputs are in sorted order. This check can
|
||||
be turned off with the --nocheck-order option.
|
||||
|
||||
comm accepts new option, --output-delimiter=STR, that allows specification
|
||||
of an output delimiter other than the default single TAB.
|
||||
|
||||
cp and mv: the deprecated --reply=X option is now also undocumented.
|
||||
|
||||
dd accepts iflag=fullblock to make it accumulate full input blocks.
|
||||
With this new option, after a short read, dd repeatedly calls read,
|
||||
until it fills the incomplete block, reaches EOF, or encounters an error.
|
||||
|
||||
df accepts a new option --total, which produces a grand total of all
|
||||
arguments after all arguments have been processed.
|
||||
|
||||
If the GNU MP library is available at configure time, factor and
|
||||
expr support arbitrarily large numbers. Pollard's rho algorithm is
|
||||
used to factor large numbers.
|
||||
|
||||
install accepts a new option --strip-program to specify the program used to
|
||||
strip binaries.
|
||||
|
||||
ls now colorizes files with capabilities if libcap is available
|
||||
|
||||
ls -v now uses filevercmp function as sort predicate (instead of strverscmp)
|
||||
|
||||
md5sum now accepts the new option, --quiet, to suppress the printing of
|
||||
'OK' messages. sha1sum, sha224sum, sha384sum, and sha512sum accept it, too.
|
||||
|
||||
sort accepts a new option, --files0-from=F, that specifies a file
|
||||
containing a null-separated list of files to sort. This list is used
|
||||
instead of filenames passed on the command-line to avoid problems with
|
||||
maximum command-line (argv) length.
|
||||
|
||||
sort accepts a new option --batch-size=NMERGE, where NMERGE
|
||||
represents the maximum number of inputs that will be merged at once.
|
||||
When processing more than NMERGE inputs, sort uses temporary files.
|
||||
|
||||
sort accepts a new option --version-sort (-V, --sort=version),
|
||||
specifying that ordering is to be based on filevercmp.
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chcon --verbose now prints a newline after each message
|
||||
|
||||
od no longer suffers from platform bugs in printf(3). This is
|
||||
probably most noticeable when using 'od -tfL' to print long doubles.
|
||||
|
||||
seq -0.1 0.1 2 now prints 2,0 when locale's decimal point is ",".
|
||||
Before, it would mistakenly omit the final number in that example.
|
||||
|
||||
shuf honors the --zero-terminated (-z) option, even with --input-range=LO-HI
|
||||
|
||||
shuf --head-count is now correctly documented. The documentation
|
||||
previously claimed it was called --head-lines.
|
||||
|
||||
** Improvements
|
||||
|
||||
Improved support for access control lists (ACLs): On MacOS X, Solaris 7..10,
|
||||
HP-UX 11, Tru64, AIX, IRIX 6.5, and Cygwin, "ls -l" now displays the presence
|
||||
of an ACL on a file via a '+' sign after the mode, and "cp -p" copies ACLs.
|
||||
|
||||
join has significantly better performance due to better memory management
|
||||
|
||||
ls now uses constant memory when not sorting and using one_per_line format,
|
||||
no matter how many files are in a given directory
|
||||
|
||||
od now aligns fields across lines when printing multiple -t
|
||||
specifiers, and no longer prints fields that resulted entirely from
|
||||
padding the input out to the least common multiple width.
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
stat's --context (-Z) option has always been a no-op.
|
||||
Now it evokes a warning that it is obsolete and will be removed.
|
||||
|
||||
|
||||
* Noteworthy changes in release 6.12 (2008-05-31) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chcon, runcon: --help output now includes the bug-reporting address
|
||||
|
||||
cp -p copies permissions more portably. For example, on MacOS X 10.5,
|
||||
"cp -p some-fifo some-file" no longer fails while trying to copy the
|
||||
permissions from the some-fifo argument.
|
||||
|
||||
id with no options now prints the SELinux context only when invoked
|
||||
with no USERNAME argument.
|
||||
|
||||
id and groups once again print the AFS-specific nameless group-ID (PAG).
|
||||
Printing of such large-numbered, kernel-only (not in /etc/group) group-IDs
|
||||
was suppressed in 6.11 due to ignorance that they are useful.
|
||||
|
||||
uniq: avoid subtle field-skipping malfunction due to isblank misuse.
|
||||
In some locales on some systems, isblank(240) (aka  ) is nonzero.
|
||||
On such systems, uniq --skip-fields=N would fail to skip the proper
|
||||
number of fields for some inputs.
|
||||
|
||||
tac: avoid segfault with --regex (-r) and multiple files, e.g.,
|
||||
"echo > x; tac -r x x". [bug present at least in textutils-1.8b, from 1992]
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
install once again sets SELinux context, when possible
|
||||
[it was deliberately disabled in 6.9.90]
|
||||
|
||||
|
||||
* Noteworthy changes in release 6.11 (2008-04-19) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
configure --enable-no-install-program=groups now works.
|
||||
|
||||
"cp -fR fifo E" now succeeds with an existing E. Before this fix, using
|
||||
-fR to copy a fifo or "special" file onto an existing file would fail
|
||||
with EEXIST. Now, it once again unlinks the destination before trying
|
||||
to create the destination file. [bug introduced in coreutils-5.90]
|
||||
|
||||
dd once again works with unnecessary options like if=/dev/stdin and
|
||||
of=/dev/stdout. [bug introduced in fileutils-4.0h]
|
||||
|
||||
id now uses getgrouplist, when possible. This results in
|
||||
much better performance when there are many users and/or groups.
|
||||
|
||||
ls no longer segfaults on files in /proc when linked with an older version
|
||||
of libselinux. E.g., ls -l /proc/sys would dereference a NULL pointer.
|
||||
|
||||
md5sum would segfault for invalid BSD-style input, e.g.,
|
||||
echo 'MD5 (' | md5sum -c - Now, md5sum ignores that line.
|
||||
sha1sum, sha224sum, sha384sum, and sha512sum are affected, too.
|
||||
[bug introduced in coreutils-5.1.0]
|
||||
|
||||
md5sum -c would accept a NUL-containing checksum string like "abcd\0..."
|
||||
and would unnecessarily read and compute the checksum of the named file,
|
||||
and then compare that checksum to the invalid one: guaranteed to fail.
|
||||
Now, it recognizes that the line is not valid and skips it.
|
||||
sha1sum, sha224sum, sha384sum, and sha512sum are affected, too.
|
||||
[bug present in the original version, in coreutils-4.5.1, 1995]
|
||||
|
||||
"mkdir -Z x dir" no longer segfaults when diagnosing invalid context "x"
|
||||
mkfifo and mknod would fail similarly. Now they're fixed.
|
||||
|
||||
mv would mistakenly unlink a destination file before calling rename,
|
||||
when the destination had two or more hard links. It no longer does that.
|
||||
[bug introduced in coreutils-5.3.0]
|
||||
|
||||
"paste -d'\' file" no longer overruns memory (heap since coreutils-5.1.2,
|
||||
stack before then) [bug present in the original version, in 1992]
|
||||
|
||||
"pr -e" with a mix of backspaces and TABs no longer corrupts the heap
|
||||
[bug present in the original version, in 1992]
|
||||
|
||||
"ptx -F'\' long-file-name" would overrun a malloc'd buffer and corrupt
|
||||
the heap. That was triggered by a lone backslash (or odd number of them)
|
||||
at the end of the option argument to --flag-truncation=STRING (-F),
|
||||
--word-regexp=REGEXP (-W), or --sentence-regexp=REGEXP (-S).
|
||||
|
||||
"rm -r DIR" would mistakenly declare to be "write protected" -- and
|
||||
prompt about -- full DIR-relative names longer than MIN (PATH_MAX, 8192).
|
||||
|
||||
"rmdir --ignore-fail-on-non-empty" detects and ignores the failure
|
||||
in more cases when a directory is empty.
|
||||
|
||||
"seq -f % 1" would issue the erroneous diagnostic "seq: memory exhausted"
|
||||
rather than reporting the invalid string format.
|
||||
[bug introduced in coreutils-6.0]
|
||||
|
||||
** New features
|
||||
|
||||
join now verifies that the inputs are in sorted order. This check can
|
||||
be turned off with the --nocheck-order option.
|
||||
|
||||
sort accepts the new option --sort=WORD, where WORD can be one of
|
||||
general-numeric, month, numeric or random. These are equivalent to the
|
||||
options --general-numeric-sort/-g, --month-sort/-M, --numeric-sort/-n
|
||||
and --random-sort/-R, resp.
|
||||
|
||||
** Improvements
|
||||
|
||||
id and groups work around an AFS-related bug whereby those programs
|
||||
would print an invalid group number, when given no user-name argument.
|
||||
|
||||
ls --color no longer outputs unnecessary escape sequences
|
||||
|
||||
seq gives better diagnostics for invalid formats.
|
||||
|
||||
** Portability
|
||||
|
||||
rm now works properly even on systems like BeOS and Haiku,
|
||||
which have negative errno values.
|
||||
|
||||
** Consistency
|
||||
|
||||
install, mkdir, rmdir and split now write --verbose output to stdout,
|
||||
not to stderr.
|
||||
|
||||
|
||||
* Noteworthy changes in release 6.10 (2008-01-22) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Fix a non-portable use of sed in configure.ac.
|
||||
[bug introduced in coreutils-6.9.92]
|
||||
|
||||
|
||||
* Noteworthy changes in release 6.9.92 (2008-01-12) [beta]
|
||||
|
||||
** Bug fixes
|
||||
@@ -75,6 +297,11 @@ GNU coreutils NEWS -*- outline -*-
|
||||
* ls accepts a slightly modified -Z option.
|
||||
* ls: contrary to Fedora version, does not accept --lcontext and --scontext
|
||||
|
||||
The following commands and options now support the standard size
|
||||
suffixes kB, M, MB, G, GB, and so on for T, P, Y, Z, and Y:
|
||||
head -c, head -n, od -j, od -N, od -S, split -b, split -C,
|
||||
tail -c, tail -n.
|
||||
|
||||
cp -p tries to preserve the GID of a file even if preserving the UID
|
||||
is not possible.
|
||||
|
||||
@@ -120,7 +347,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
loss of the contents of a/f.
|
||||
|
||||
stty no longer silently accepts certain invalid hex values
|
||||
in its 35-colon commmand-line argument
|
||||
in its 35-colon command-line argument
|
||||
|
||||
** Bug fixes
|
||||
|
||||
|
||||
34
README
34
README
@@ -13,15 +13,15 @@ The programs that can be built with this package are:
|
||||
link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup
|
||||
od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir
|
||||
runcon seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf
|
||||
sleep sort split stat stty su sum sync tac tail tee test touch tr true
|
||||
tsort tty uname unexpand uniq unlink uptime users vdir wc who whoami yes
|
||||
sleep sort split stat stty su sum sync tac tail tee test timeout touch tr
|
||||
true truncate tsort tty uname unexpand uniq unlink uptime users vdir wc who
|
||||
whoami yes
|
||||
|
||||
See the file NEWS for a list of major changes in the current release.
|
||||
|
||||
If you obtained this file as part of a "cvs checkout" or "git clone",
|
||||
then see the README-hacking file. If this file came to you as part of a
|
||||
tar archive, then see the file INSTALL for compilation and installation
|
||||
instructions.
|
||||
If you obtained this file as part of a "git clone", then see the
|
||||
README-hacking file. If this file came to you as part of a tar archive,
|
||||
then see the file INSTALL for compilation and installation instructions.
|
||||
|
||||
These programs are intended to conform to POSIX (with BSD and other
|
||||
extensions), like the rest of the GNU system. By default they conform
|
||||
@@ -58,9 +58,16 @@ and from the corresponding --help usage message. Patches to the template
|
||||
files (man/*.x) are welcome. However, the authoritative documentation
|
||||
is in texinfo form in the doc directory.
|
||||
|
||||
If you run the tests on a SunOS4.1.4 system, expect the ctime-part of
|
||||
the ls `time-1' test to fail. I believe that is due to a bug in the
|
||||
way Sun implemented link(2) and chmod(2).
|
||||
|
||||
*****************************************
|
||||
On Mac OS X 10.5.1 (Darwin 9.1), test failure
|
||||
-----------------------------------------
|
||||
|
||||
Mac OS X 10.5.1 (Darwin 9.1) provides only partial (and incompatible)
|
||||
ACL support, so although "./configure && make" succeeds, "make check"
|
||||
exposes numerous failures. The solution is to turn off ACL support
|
||||
manually via "./configure --disable-acl". For details, see
|
||||
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12292/focus=12318>.
|
||||
|
||||
|
||||
*****************************************
|
||||
@@ -139,7 +146,7 @@ I find that it is best to unpack and build as a non-privileged
|
||||
user, and then to run the following command as that user in order
|
||||
to run the privilege-requiring tests:
|
||||
|
||||
sudo env NON_ROOT_USERNAME=$USER make -k check
|
||||
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
|
||||
|
||||
If you can run the tests as root, please do so and report any
|
||||
problems. We get much less test coverage in that mode, and it's
|
||||
@@ -178,14 +185,13 @@ If you sent a complete patch and, after a couple weeks you haven't
|
||||
received any acknowledgement, please ping us. A complete patch includes
|
||||
a well-written ChangeLog entry, unified (diff -u format) diffs relative
|
||||
to the most recent test release (or, better, relative to the latest
|
||||
sources in the CVS repository), an explanation for why the patch is
|
||||
sources in the public repository), an explanation for why the patch is
|
||||
necessary or useful, and if at all possible, enough information to
|
||||
reproduce whatever problem prompted it. Plus, you'll earn lots of
|
||||
karma if you include a test case to exercise any bug(s) you fix.
|
||||
Instructions for checking out the latest source via CVS are here:
|
||||
|
||||
http://savannah.gnu.org/cvs/?group=coreutils
|
||||
Here are instructions for checking out the latest development sources:
|
||||
|
||||
http://savannah.gnu.org/git/?group=coreutils
|
||||
|
||||
If your patch adds a new feature, please try to get some sort of consensus
|
||||
that it is a worthwhile change. One way to do that is to send mail to
|
||||
|
||||
@@ -30,27 +30,11 @@ Later, a plain `git pull && make' should be sufficient.
|
||||
|
||||
* LZMA
|
||||
|
||||
The coreutils build procedure can build distribution tarballs with the
|
||||
LZMA compression scheme. This feature is so new that it is not
|
||||
supported by the latest version of Automake. If you don't care about
|
||||
building LZMA tarballs, you can manually remove the string "dist-lzma"
|
||||
from configure.ac before bootstrapping.
|
||||
|
||||
If you do want to build LZMA tarballs, you'll need to make sure you
|
||||
have the latest stable version of the LZMA Utils
|
||||
<http://tukaani.org/lzma/>. Also, you'll need a version of
|
||||
Automake that supports the dist-lzma feature, which was added to
|
||||
Automake on 2007-10-09 but is not yet available in a stable Automake
|
||||
version. So until Automake 1.11 comes out, you'll need to get the
|
||||
bleeding-edge Automake version with a command like this:
|
||||
|
||||
$ git clone git://git.sv.gnu.org/automake
|
||||
$ cd automake
|
||||
$ ./bootstrap
|
||||
$ ./configure
|
||||
$ make install
|
||||
|
||||
and build and install that version.
|
||||
This package's build procedure uses LZMA 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/>.
|
||||
|
||||
* First GIT checkout
|
||||
|
||||
@@ -80,7 +64,7 @@ Enjoy!
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-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
|
||||
|
||||
29
THANKS
29
THANKS
@@ -21,6 +21,8 @@ Albert Hopkins ahopkins@dynacare.com
|
||||
Alberto Accomazzi alberto@cfa0.harvard.edu
|
||||
aldomel aldomel@ix.netcom.com
|
||||
Alen Muzinic zveki@fly.cc.fer.hr
|
||||
Allen Hewes allen@decisiv.net
|
||||
Axel Dörfler axeld@pinc-software.de
|
||||
Alexandre Duret-Lutz duret_g@epita.fr
|
||||
Alexey Solovyov alekso@math.uu.se
|
||||
Alexey Vyskubov alexey@pippuri.mawhrin.net
|
||||
@@ -69,6 +71,7 @@ Bernhard Baehr bernhard.baehr@gmx.de
|
||||
Bernhard Gabler bernhard@uni-koblenz.de
|
||||
Bernhard Rosenkraenzer bero@redhat.de
|
||||
Bert Deknuydt Bert.Deknuydt@esat.kuleuven.ac.be
|
||||
Bert Wesarg bert.wesarg@googlemail.com
|
||||
Bill Peters peters@gaffel.as.arizona.edu
|
||||
Bjorn Helgaas helgaas@rsn.hp.com
|
||||
Bob McCracken kerouac@ravenet.com
|
||||
@@ -76,12 +79,14 @@ 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 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
|
||||
Carl Johnson carlj@cjlinux.home.org
|
||||
Carl Lowenstein cdl@mpl.UCSD.EDU
|
||||
Carl Roth roth@urs.us
|
||||
Carlos Canau Carlos.Canau@relay.puug.pt
|
||||
Charles Karney karney@pppl.gov
|
||||
Charles Randall crandall@matchlogic.com
|
||||
@@ -104,12 +109,15 @@ Colin Plumb colin@nyx.net
|
||||
Colin Watson cjw44@riva.ucam.org
|
||||
Collin Rogowski collin@rogowski.de
|
||||
Cray-Cyber Project http://www.cray-cyber.org
|
||||
Cristian Cadar cristic@stanford.edu
|
||||
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 Pascu dan@services.iiruc.ro
|
||||
Daniel Bergstrom noa@melody.se
|
||||
Daniel Dunbar ddunbar@stanford.edu
|
||||
Daniel P. Berrangé berrange@redhat.com
|
||||
Dániel Varga danielv@axelero.hu
|
||||
Danny Levinson danny.levinson@overture.com
|
||||
@@ -124,8 +132,10 @@ 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
|
||||
Dawson Engler engler@stanford.edu
|
||||
Dean Gaudet dean-savannah@arctic.org
|
||||
Deepak Goel deego@gnufans.org
|
||||
Denis Excoffier denis.excoffier@airbus.com
|
||||
Dennis Henriksen opus@flamingo.osrl.dk
|
||||
Dennis Smit ds@nerds-incorporated.org
|
||||
Derek Clegg dclegg@next.com
|
||||
@@ -146,8 +156,11 @@ Edzer Pebesma Edzer.Pebesma@rivm.nl
|
||||
Egmont Koblinger egmont@uhulinux.hu
|
||||
Eirik Fuller eirik@hackrat.com
|
||||
Eivind eivindt@multinet.no
|
||||
Elbert Pol elbert.pol@gmail.com
|
||||
Eli Zaretskii eliz@is.elta.co.il
|
||||
Elias Pipping pipping@gentoo.org
|
||||
Emile LeBlanc leblanc@math.toronto.edu
|
||||
Erik Auerswald auerswal@unix-ag.uni-kl.de
|
||||
Eric Backus ericb@lsid.hp.com
|
||||
Eric Blake ebb9@byu.net
|
||||
Eric G. Miller egm2@jps.net
|
||||
@@ -173,6 +186,7 @@ Gabor Z. Papp gzp@gzp.org.hu
|
||||
Gaël Quéri gqueri@mail.dotcom.fr
|
||||
Galen Hazelwood galenh@micron.net
|
||||
Gary Anderson ganderson@clark.net
|
||||
Gary Johnson garyjohn@spk.agilent.com
|
||||
Gary V. Vaughan gary@gnu.org
|
||||
Gaute Hvoslef Kvalnes gaute@verdsveven.com
|
||||
Geoff Collyer geoff at collyer.net
|
||||
@@ -201,6 +215,7 @@ Harald Dunkel harald.dunkel@t-online.de
|
||||
Harry Liu rliu@lek.ugcs.caltech.edu
|
||||
Harti Brandt brandt@fokus.fraunhofer.de
|
||||
Harvey Eneman Harvey.Eneman@oracle.com
|
||||
Heiko Marr h.marr@webmasters.de
|
||||
Helen Faulkner helen_ml_faulkner@yahoo.co.uk
|
||||
Herbert Xu herbert@gondor.apana.org.au
|
||||
Holger Berger hberger@ess.nec.de
|
||||
@@ -212,26 +227,31 @@ Ian Jackson ijackson@chiark.greenend.org.uk
|
||||
Ian Lance Taylor ian@cygnus.com
|
||||
Ian Turner vectro@pipeline.com
|
||||
Iida Yosiaki iida@gnu.org
|
||||
Ilya N. Golubev gin@mo.msk.ru
|
||||
Ingo Saitz ingo@debian.org
|
||||
Ivo Timmermans ivo@debian.org
|
||||
James james@albion.glarp.com
|
||||
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
|
||||
James Lemley James.Lemley@acxiom.com
|
||||
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
|
||||
Jamie Lokier jamie@imbolc.ucc.ie
|
||||
Jamie McClelland jm@mayfirst.org
|
||||
Jan Fedak J.Fedak@sh.cvut.cz
|
||||
Jan Moringen jan.moringen@uni-bielefeld.de
|
||||
Jan Nieuwenhuizen janneke@gnu.org
|
||||
Janos Farkas chexum@shadow.banki.hu
|
||||
Jarkko Hietaniemi jhi@epsilon.hut.fi
|
||||
Jarod Wilson jwilson@redhat.com
|
||||
Jean Charles Delepine delepine@u-picardie.fr
|
||||
Jeff Moore jbm@mordor.com
|
||||
Jeff Sheinberg jeff@bsrd.net
|
||||
Jens Elkner elkner@imsgroup.de
|
||||
Jens Schmidt jms@jsds.hamburg.com
|
||||
Jeph Cowan jeph@ucar.edu
|
||||
Jeremy Maitin-Shepard jbms@cmu.edu
|
||||
Jerome Abela abela@hsc.fr
|
||||
Jérôme Zago bug-coreutils-ml@agt-the-walker.net
|
||||
@@ -262,6 +282,7 @@ Joost van Baal joostvb@xs4all.nl
|
||||
Jorge Stolfi stolfi@ic.unicamp.br
|
||||
Joseph S. Myers jsm28@cam.ac.uk
|
||||
Joshua Hudson joshudson@gmail.com
|
||||
Josselin Mouette joss@debian.org
|
||||
Juan F. Codagnone juam@arnet.com.ar
|
||||
Juan M. Guerrero st001906@hrz1.hrz.tu-darmstadt.de
|
||||
Jungshik Shin jshin@pantheon.yale.edu
|
||||
@@ -422,6 +443,7 @@ Peter Seebach seebs@taniemarie.solon.com
|
||||
Petter Reinholdtsen pere@hungry.com
|
||||
Phelippe Neveu pneveu@pcigeomatics.com
|
||||
Phil Richards phil.richards@vf.vodafone.co.uk
|
||||
Philip Rowlands phr@doc.ic.ac.uk
|
||||
Philippe De Muyter phdm@macqel.be
|
||||
Philippe Schnoebelen Philippe.Schnoebelen@imag.fr
|
||||
Phillip Jones mouse@datastacks.com
|
||||
@@ -429,6 +451,7 @@ Piergiorgio Sartor sartor@sony.de
|
||||
Pieter Bowman bowman@math.utah.edu
|
||||
Piotr Kwapulinski kwap@univ.gda.pl
|
||||
Prashant TR tr@eth.net
|
||||
Priit Jõerüüt jemm4jemm@yahoo.com
|
||||
Rainer Orth ro@TechFak.Uni-Bielefeld.DE
|
||||
Ralf W. Stephan stephan@tmt.de
|
||||
Ralf Wildenhues Ralf.Wildenhues@gmx.de
|
||||
@@ -464,7 +487,7 @@ Sander van Malssen svm@kozmix.ow.nl
|
||||
Santiago Vila Doncel sanvila@unex.es
|
||||
Savochkin Andrey Vladimirovich saw@msu.ru
|
||||
Scott Lurndal slurn@griffin.engr.sgi.com
|
||||
Sébastien Maret smaret@umich.edu
|
||||
Sébastien Maret smaret@umich.edu
|
||||
Shing-Shong Shei shei@cs.indiana.edu
|
||||
Soeren Sonnenburg sonnenburg@informatik.hu-berlin.de
|
||||
Solar Designer solar@owl.openwall.com
|
||||
@@ -482,12 +505,13 @@ Steven G. Johnson stevenj@alum.mit.edu
|
||||
Steven Mocking ufo@quicknet.nl
|
||||
Steven P Watson steven@magelico.net
|
||||
Stuart Kemp skemp@peter.bmc.com
|
||||
Sven Joachim sven_joachim@web.de
|
||||
Sven Joachim svenjoac@gmx.de
|
||||
Szakacsits Szabolcs szaka@sienet.hu
|
||||
Tadayoshi Funaba tadf@kt.rim.or.jp
|
||||
TAKAI Kousuke takai@vlsi.kuee.kyoto-u.ac.jp
|
||||
Theodore Ts'o tytso@rsts-11.mit.edu
|
||||
The Wanderer inverseparadox@comcast.net
|
||||
Theodoros V. Kalamatianos nyb@users.sourceforge.net
|
||||
Thomas Bushnell thomas@gnu.ai.mit.edu
|
||||
Thomas Goerlich thomas@schnappmatik.de
|
||||
Thomas Hood jdthood@yahoo.co.uk
|
||||
@@ -498,6 +522,7 @@ Thomas Schwinge tschwinge@gnu.org
|
||||
Thomas Wolff mined@towo.net
|
||||
Tim J. Robbins tjr@FreeBSD.org
|
||||
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
|
||||
Toby Peterson toby@opendarwin.org
|
||||
|
||||
92
TODO
92
TODO
@@ -1,16 +1,36 @@
|
||||
If you're interested in helping, here are some tasks that we've considered
|
||||
over the years. Beware: some are quite old and no longer valid. To avoid
|
||||
wasting your time by duplicating work or by working on a task that is no
|
||||
longer pertinent, please search the mailing list and post your intent
|
||||
before embarking on a big project.
|
||||
|
||||
==================================================
|
||||
Modify chmod so that it does not change an inode's st_ctime
|
||||
when the selected operation would have no other effect.
|
||||
First suggested by Hans Ecke <http://hans.ecke.ws> in
|
||||
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/2920
|
||||
Discussed more recently on <http://bugs.debian.org/497514>.
|
||||
|
||||
document the following in coreutils.texi:
|
||||
runcon
|
||||
chcon
|
||||
mktemp
|
||||
[
|
||||
pinky
|
||||
uptime
|
||||
Also document the SELinux changes.
|
||||
|
||||
comm: add an option, --output-delimiter=STR
|
||||
Files to change: src/comm.c, ChangeLog, NEWS, doc/coreutils.texi,
|
||||
Add a new file, tests/misc/comm (use another file in that directory as
|
||||
a template), to exercise the new option. Suggestion from Dan Jacobson.
|
||||
Suggestion from Paul Eggert:
|
||||
More generally, there's not that much use for imaxtostr nowadays,
|
||||
since the inttypes module and newer versions of gettext allow things
|
||||
like _("truncating %s at %" PRIdMAX " bytes") to work portably.
|
||||
I suspect that (if someone cares to take the time) we can remove
|
||||
all instances of imaxtostr and umaxtostr in coreutils and gnulib.
|
||||
|
||||
cp --recursive: use fts and *at functions to perform directory traversals
|
||||
in source and destination hierarchy rather than forming full file names.
|
||||
The latter (current) approach fails unnecessarily when the names
|
||||
become very long, and requires space and time that is quadratic in the
|
||||
depth of the hierarchy. [Bo Borgerson is working on this]
|
||||
|
||||
printf:
|
||||
Now that gnulib supports *printf("%a"), import one of the
|
||||
@@ -20,9 +40,7 @@ printf:
|
||||
|
||||
renice: POSIX utility, needs implementing.
|
||||
suggestion from Karl Berry (among others).
|
||||
|
||||
install: add an option to specify the program used to strip binaries.
|
||||
suggestion from Karl Berry
|
||||
Bob Proulx is working on this.
|
||||
|
||||
doc/coreutils.texi:
|
||||
Address this comment: FIXME: mv's behavior in this case is system-dependent
|
||||
@@ -38,13 +56,6 @@ And once that's done, add an exclusion so that `cp --link'
|
||||
no longer incurs the overhead of saving src. dev/ino and dest. filename
|
||||
in the hash table.
|
||||
|
||||
See if we can be consistent about where --verbose sends its output:
|
||||
These all send --verbose output to stdout:
|
||||
head, tail, rm, cp, mv, ln, chmod, chown, chgrp, install, ln
|
||||
These send it to stderr:
|
||||
shred mkdir split
|
||||
readlink is different
|
||||
|
||||
Write an autoconf test to work around build failure in HPUX's 64-bit mode.
|
||||
See notes in README -- and remove them once there's a work-around.
|
||||
|
||||
@@ -58,12 +69,6 @@ Should printf '\0123' print "\n3"?
|
||||
|
||||
printf: consider adapting builtins/printf.def from bash
|
||||
|
||||
df: add `--total' option, suggested here http://bugs.debian.org/186007
|
||||
|
||||
seq: give better diagnostics for invalid formats:
|
||||
e.g. no or too many % directives
|
||||
seq: consider allowing format string to contain no %-directives
|
||||
|
||||
tail: don't use xlseek; it *exits*.
|
||||
Instead, maybe use a macro and return nonzero.
|
||||
|
||||
@@ -99,26 +104,21 @@ 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.
|
||||
|
||||
cp --recursive: perform dir traversals in source and dest hierarchy rather
|
||||
than forming full file names. The latter (current) approach fails
|
||||
unnecessarily when the names become very long.
|
||||
|
||||
Remove suspicious uses of alloca (ones that may allocate more than
|
||||
about 4k)
|
||||
|
||||
Adapt these contribution guidelines for coreutils:
|
||||
http://sources.redhat.com/automake/contribute.html
|
||||
|
||||
Improve test coverage.
|
||||
See HACKING for instructions on generating an html test coverage report.
|
||||
Find a program that has poor coverage and improve.
|
||||
|
||||
Changes expected to go in, someday.
|
||||
======================================
|
||||
|
||||
dd patch from Olivier Delhomme
|
||||
|
||||
Andreas Gruenbacher's xattr changes
|
||||
|
||||
Apply Bruno Haible's hostname changes
|
||||
|
||||
test/mv/*: clean up $other_partition_tmpdir in all cases
|
||||
|
||||
ls: when both -l and --dereference-command-line-symlink-to-dir are
|
||||
@@ -127,18 +127,12 @@ Changes expected to go in, someday.
|
||||
an implicit --NO-dereference-command-line-symlink-to-dir meaning.
|
||||
Pointed out by Karl Berry.
|
||||
|
||||
A more efficient version of factor, and possibly one that
|
||||
accepts inputs of size 2^64 and larger.
|
||||
|
||||
dd: consider adding an option to suppress `bytes/block read/written'
|
||||
output to stderr. Suggested here:
|
||||
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=165045
|
||||
|
||||
Pending copyright papers:
|
||||
------------------------
|
||||
ls --color: Ed Avis' patch to suppress escape sequences for
|
||||
non-highlighted files
|
||||
|
||||
getpwnam from Bruce Korb
|
||||
|
||||
pb (progress bar) from Miika Pekkarinen
|
||||
@@ -152,37 +146,31 @@ Add a distcheck-time test to ensure that every distributed
|
||||
file is either read-only(indicating generated) or is
|
||||
version-controlled and up to date.
|
||||
|
||||
Implement Ulrich Drepper's suggestion to use getgrouplist rather
|
||||
than getugroups. This affects only `id', but makes a big difference
|
||||
on systems with many users and/or groups, and makes id usable once
|
||||
again on systems where access restrictions make getugroups fail.
|
||||
But first we'll need a run-test (either in an autoconf macro or at
|
||||
run time) to avoid the segfault bug in libc-2.3.2's getgrouplist.
|
||||
In that case, we'd revert to using a new (to-be-written) getgrouplist
|
||||
module that does most of what `id' already does. Or just avoid the
|
||||
buggy use of getgrouplist by never passing it a buffer of length zero.
|
||||
See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=200327
|
||||
|
||||
remove `%s' notation:
|
||||
remove `%s' notation (now that they're all gone, add a maint.mk sc_
|
||||
rule to ensure no new ones are added):
|
||||
grep -E "\`%.{,4}s'" src/*.c
|
||||
|
||||
remove all uses of the `register' keyword: Done. add a maint.mk rule
|
||||
for this, too.
|
||||
|
||||
remove or adjust chown's --changes option, since it
|
||||
can't always do what it currently says it does.
|
||||
|
||||
Support arbitrary-precision arithmetic in those tools for which it
|
||||
makes sense. Factor and expr already support this via libgmp.
|
||||
The "test" program is covered via its string-based comparison of
|
||||
integers. To be converted: seq.
|
||||
|
||||
Adapt tools like wc, tr, fmt, etc. (most of the textutils) to be
|
||||
multibyte aware. The problem is that I want to avoid duplicating
|
||||
significant blocks of logic, yet I also want to incur only minimal
|
||||
(preferably `no') cost when operating in single-byte mode.
|
||||
|
||||
Remove all uses of the `register' keyword
|
||||
|
||||
pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
|
||||
|
||||
ls.c: use gettime rather than clock_gettime, gettimeofday, time
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-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
|
||||
|
||||
118
bootstrap
118
bootstrap
@@ -2,7 +2,7 @@
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-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
|
||||
@@ -49,7 +49,7 @@ Options:
|
||||
not to have been checked out.
|
||||
--skip-po Do not download po files.
|
||||
|
||||
If the file bootstrap.conf exists in the current working directory, its
|
||||
If the file $0.conf exists in the same directory as this script, its
|
||||
contents are read as shell variables to configure the bootstrap.
|
||||
|
||||
Running without arguments will suffice in most cases.
|
||||
@@ -96,6 +96,11 @@ package=`sed -n "$extract_package_name" configure.ac` || exit
|
||||
gnulib_name=lib$package
|
||||
|
||||
build_aux=build-aux
|
||||
source_base=lib
|
||||
m4_base=m4
|
||||
doc_base=doc
|
||||
tests_base=tests
|
||||
|
||||
# Extra files from gnulib, which override files from other sources.
|
||||
gnulib_extra_files="
|
||||
$build_aux/install-sh
|
||||
@@ -121,6 +126,9 @@ XGETTEXT_OPTIONS='\\\
|
||||
--flag=error:3:c-format --flag=error_at_line:5:c-format\\\
|
||||
'
|
||||
|
||||
# Package bug report address for gettext files
|
||||
MSGID_BUGS_ADDRESS=bug-$package@gnu.org
|
||||
|
||||
# Files we don't want to import.
|
||||
excluded_files=
|
||||
|
||||
@@ -138,7 +146,13 @@ copy=false
|
||||
vc_ignore=auto
|
||||
|
||||
# Override the default configuration, if necessary.
|
||||
test -r bootstrap.conf && . ./bootstrap.conf
|
||||
# Make sure that bootstrap.conf is sourced from the current directory
|
||||
# if we were invoked as "sh bootstrap".
|
||||
case "$0" in
|
||||
*/*) test -r "$0.conf" && . "$0.conf" ;;
|
||||
*) test -r "$0.conf" && . ./"$0.conf" ;;
|
||||
esac
|
||||
|
||||
|
||||
if test "$vc_ignore" = auto; then
|
||||
vc_ignore=
|
||||
@@ -157,7 +171,7 @@ do
|
||||
usage
|
||||
exit;;
|
||||
--gnulib-srcdir=*)
|
||||
GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
|
||||
GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
|
||||
--skip-po)
|
||||
SKIP_PO=t;;
|
||||
--force)
|
||||
@@ -210,17 +224,40 @@ fi
|
||||
|
||||
echo "$0: Bootstrapping from checked-out $package sources..."
|
||||
|
||||
# See if we can use gnulib's git-merge-changelog merge driver.
|
||||
if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
|
||||
if git config merge.merge-changelog.driver >/dev/null ; then
|
||||
:
|
||||
elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
|
||||
echo "initializing git-merge-changelog driver"
|
||||
git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
|
||||
git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
|
||||
else
|
||||
echo "consider installing git-merge-changelog from gnulib"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
cleanup_gnulib() {
|
||||
status=$?
|
||||
rm -fr gnulib
|
||||
exit $status
|
||||
}
|
||||
|
||||
git_modules_config () {
|
||||
GIT_CONFIG_LOCAL=.gitmodules git config "$@"
|
||||
}
|
||||
|
||||
# Get gnulib files.
|
||||
|
||||
case ${GNULIB_SRCDIR--} in
|
||||
-)
|
||||
if [ ! -d gnulib ]; then
|
||||
if git_modules_config submodule.gnulib.url >/dev/null; then
|
||||
echo "$0: getting gnulib files..."
|
||||
git submodule init || exit $?
|
||||
git submodule update || exit $?
|
||||
|
||||
elif [ ! -d gnulib ]; then
|
||||
echo "$0: getting gnulib files..."
|
||||
|
||||
trap cleanup_gnulib 1 2 13 15
|
||||
@@ -231,6 +268,20 @@ case ${GNULIB_SRCDIR--} in
|
||||
trap - 1 2 13 15
|
||||
fi
|
||||
GNULIB_SRCDIR=gnulib
|
||||
;;
|
||||
*)
|
||||
# Redirect the gnulib submodule to the directory on the command line
|
||||
# if possible.
|
||||
if test -d "$GNULIB_SRCDIR"/.git && \
|
||||
git_modules_config submodule.gnulib.url >/dev/null; then
|
||||
git submodule init
|
||||
GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
|
||||
git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
|
||||
echo "$0: getting gnulib files..."
|
||||
git submodule update || exit $?
|
||||
GNULIB_SRCDIR=gnulib
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
|
||||
@@ -265,7 +316,7 @@ update_po_files() {
|
||||
|
||||
langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
|
||||
test "$langs" = '*' && langs=x
|
||||
for po in `cd $ref_po_dir && echo *.po|sed 's/\.po//g'`; do
|
||||
for po in $langs; do
|
||||
case $po in x) continue;; esac
|
||||
new_po="$ref_po_dir/$po.po"
|
||||
cksum_file="$ref_po_dir/$po.s1"
|
||||
@@ -375,9 +426,13 @@ cp_mark_as_generated()
|
||||
|
||||
if test -z "$c1"; then
|
||||
cmp -s "$cp_src" "$cp_dst" || {
|
||||
# Copy the file first to get proper permissions if it
|
||||
# doesn't already exist. Then overwrite the copy.
|
||||
echo "$0: cp -f $cp_src $cp_dst" &&
|
||||
rm -f "$cp_dst" &&
|
||||
sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst"
|
||||
cp "$cp_src" "$cp_dst-t" &&
|
||||
sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
|
||||
mv -f "$cp_dst-t" "$cp_dst"
|
||||
}
|
||||
else
|
||||
# Copy the file first to get proper permissions if it
|
||||
@@ -386,6 +441,7 @@ cp_mark_as_generated()
|
||||
(
|
||||
echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
|
||||
echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
|
||||
echo '#line 1' &&
|
||||
sed "s!$bt_regex/!!g" "$cp_src"
|
||||
) > $cp_dst-t &&
|
||||
if cmp -s "$cp_dst-t" "$cp_dst"; then
|
||||
@@ -406,7 +462,9 @@ version_controlled_file() {
|
||||
grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
|
||||
grep '^/[^/]*/[0-9]' > /dev/null && found=yes
|
||||
elif test -d .git; then
|
||||
git-rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
|
||||
git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
|
||||
elif test -d .svn; then
|
||||
svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
|
||||
else
|
||||
echo "$0: no version control for $dir/$file?" >&2
|
||||
fi
|
||||
@@ -488,11 +546,11 @@ gnulib_tool_options="\
|
||||
--import\
|
||||
--no-changelog\
|
||||
--aux-dir $bt/$build_aux\
|
||||
--doc-base $bt/doc\
|
||||
--doc-base $bt/$doc_base\
|
||||
--lib $gnulib_name\
|
||||
--m4-base $bt/m4/\
|
||||
--source-base $bt/lib/\
|
||||
--tests-base $bt/tests\
|
||||
--m4-base $bt/$m4_base/\
|
||||
--source-base $bt/$source_base/\
|
||||
--tests-base $bt/$tests_base\
|
||||
--local-dir $local_gl_dir\
|
||||
$gnulib_tool_option_extras\
|
||||
"
|
||||
@@ -515,28 +573,20 @@ if test $with_gettext = yes; then
|
||||
cp configure.ac $bt2 &&
|
||||
(cd $bt2 && autopoint && rm configure.ac) &&
|
||||
slurp $bt2 $bt || exit
|
||||
|
||||
rm -fr $bt $bt2 || exit
|
||||
fi
|
||||
rm -fr $bt $bt2 || exit
|
||||
|
||||
# Coreutils is unusual in that it generates some of its test-related
|
||||
# Makefile.am files. That must be done before invoking automake.
|
||||
mam_template=tests/Makefile.am.in
|
||||
if test -f $mam_template; then
|
||||
PERL=perl
|
||||
for tool in cut head join pr sort tac tail test tr uniq wc; do
|
||||
m=tests/$tool/Makefile.am
|
||||
t=${m}t
|
||||
rm -f $m $t
|
||||
sed -n '1,/^##test-files-begin/p' $mam_template > $t
|
||||
echo "x = $tool" >> $t
|
||||
srcdir=tests/$tool
|
||||
$PERL -I$srcdir -w -- tests/mk-script $srcdir --list >> $t
|
||||
sed -n '/^##test-files-end/,$p' $mam_template >> $t
|
||||
chmod -w $t
|
||||
mv $t $m
|
||||
done
|
||||
fi
|
||||
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
|
||||
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
|
||||
# The following requires GNU find 4.2.3 or newer. Considering the usual
|
||||
# portability constraints of this script, that may seem a very demanding
|
||||
# requirement, but it should be ok. Ignore any failure, which is fine,
|
||||
# since this is only a convenience to help developers avoid the relatively
|
||||
# unusual case in which a symlinked-to .m4 file is git-removed from gnulib
|
||||
# between successive runs of this script.
|
||||
find "$m4_base" "$source_base" \
|
||||
-depth \( -name '*.m4' -o -name '*.[ch]' \) \
|
||||
-type l -xtype l -delete > /dev/null 2>&1
|
||||
|
||||
# Reconfigure, getting other files.
|
||||
|
||||
@@ -573,7 +623,7 @@ if test $with_gettext = yes; then
|
||||
rm -f po/Makevars
|
||||
sed '
|
||||
/^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
|
||||
/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
|
||||
/^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
|
||||
/^XGETTEXT_OPTIONS *=/{
|
||||
s/$/ \\/
|
||||
a\
|
||||
@@ -606,6 +656,4 @@ m=gnulib-tests/gnulib.mk
|
||||
sed 's,\.\./\.\.,..,g' $m > $m-t
|
||||
mv -f $m-t $m
|
||||
|
||||
chmod a+x gnulib-tests/test-*.sh
|
||||
|
||||
echo "$0: done. Now you can run './configure'."
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bootstrap configuration.
|
||||
|
||||
# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 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
|
||||
@@ -26,7 +26,7 @@ avoided_gnulib_modules='
|
||||
# These modules are obsolete and can probably be removed soon,
|
||||
# but leave them in for now to minimize changes.
|
||||
obsolete_gnulib_modules='
|
||||
atexit free memchr memcmp memcpy memmove memset rename
|
||||
atexit memchr memcmp memcpy memmove memset rename
|
||||
strcspn strtod strtol utime
|
||||
'
|
||||
|
||||
@@ -41,11 +41,14 @@ gnulib_modules="
|
||||
c-strtold calloc canon-host canonicalize chown cloexec
|
||||
config-h configmake
|
||||
closein closeout
|
||||
crypto/md5 crypto/sha1
|
||||
crypto/md5
|
||||
crypto/sha1
|
||||
crypto/sha256
|
||||
crypto/sha512
|
||||
cycle-check
|
||||
d-ino d-type diacrit dirfd dirname dup2
|
||||
error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl
|
||||
file-type fileblocks filemode filenamecat fnmatch-gnu
|
||||
file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu
|
||||
fopen-safer
|
||||
fprintftime
|
||||
fseeko
|
||||
@@ -55,7 +58,8 @@ gnulib_modules="
|
||||
getline getloadavg getndelim2 getopt getpagesize getpass-gnu
|
||||
gettext gettime gettimeofday getugroups getusershell
|
||||
git-version-gen
|
||||
gnu-make gnupload
|
||||
gitlog-to-changelog
|
||||
gnu-make gnumakefile gnupload
|
||||
group-member hard-locale hash hash-pjw host-os human idcache
|
||||
inttostr inttypes isapipe
|
||||
lchmod lchown lib-ignore linebuffer link-follow
|
||||
@@ -63,7 +67,12 @@ gnulib_modules="
|
||||
memrchr mgetgroups
|
||||
mkancesdirs mkdir mkdir-p mkstemp mktime modechange
|
||||
mountlist mpsort obstack pathmax perl physmem
|
||||
posix-shell posixtm posixver putenv
|
||||
posix-shell
|
||||
posixtm
|
||||
posixver
|
||||
progname
|
||||
propername
|
||||
putenv
|
||||
quote quotearg raise readlink areadlink-with-size
|
||||
randint
|
||||
randperm
|
||||
@@ -81,8 +90,11 @@ gnulib_modules="
|
||||
strftime
|
||||
strpbrk strtoimax strtoumax strverscmp sys_stat timespec tzset
|
||||
unicodeio unistd-safer unlink-busy unlinkdir unlocked-io
|
||||
uptime userspec utimecmp utimens
|
||||
uptime
|
||||
useless-if-before-free
|
||||
userspec utimecmp utimens
|
||||
vasprintf-posix
|
||||
vc-list-files
|
||||
verify version-etc-fsf
|
||||
wcwidth winsz-ioctl winsz-termios write-any-file
|
||||
xalloc xgetcwd xgethostname
|
||||
@@ -111,6 +123,14 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||
--flag=xprintf:1:c-format\\\
|
||||
'
|
||||
|
||||
# Append these, since we use the propername module.
|
||||
see_manual='"This is a proper name. See the gettext manual, section Names."'
|
||||
see_manual=\'"$see_manual"\'
|
||||
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||
--keyword=proper_name:1,'"$see_manual"'\\\
|
||||
--keyword=proper_name_utf8:1,'"$see_manual"'\\\
|
||||
'
|
||||
|
||||
# If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]"
|
||||
# appears in configure.ac, exclude some unnecessary files.
|
||||
# Without grep's -E option (not portable enough, pre-configure),
|
||||
@@ -139,3 +159,6 @@ if test $gettext_external = 1; then
|
||||
fi
|
||||
|
||||
gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
|
||||
|
||||
# Automake requires that ChangeLog exist.
|
||||
touch ChangeLog
|
||||
|
||||
14
build-aux/.gitignore
vendored
14
build-aux/.gitignore
vendored
@@ -1,14 +0,0 @@
|
||||
announce-gen
|
||||
compile
|
||||
config.guess
|
||||
config.rpath
|
||||
config.sub
|
||||
depcomp
|
||||
git-version-gen
|
||||
gnupload
|
||||
install-sh
|
||||
link-warning.h
|
||||
mdate-sh
|
||||
missing
|
||||
texinfo.tex
|
||||
ylwrap
|
||||
@@ -41,7 +41,7 @@ ENABLE_HARD_ERRORS = :
|
||||
|
||||
## We use GNU Make extensions (%-rules) inside GNU_MAKE checks,
|
||||
## and we override check-TESTS.
|
||||
AUTOMAKE_OPTIONS = -Wno-portability -Wno-override
|
||||
AUTOMAKE_OPTIONS += -Wno-portability -Wno-override
|
||||
|
||||
# Restructured Text title and section.
|
||||
am__rst_title = sed 's/.*/ & /;h;s/./=/g;p;x;p;g;p;s/.*//'
|
||||
@@ -89,17 +89,31 @@ tput sgr0 >/dev/null 2>&1 && \
|
||||
# by disabling -e (using the XSI extension "set +e") if it's set.
|
||||
SH_E_WORKAROUND = case $$- in *e*) set +e;; esac
|
||||
|
||||
# Emulate dirname with sed.
|
||||
_d_no_slash = s,^[^/]*$$,.,
|
||||
_d_strip_trailing = s,\([^/]\)//*$$,\1,
|
||||
_d_abs_trivial = s,^//*[^/]*$$,/,
|
||||
_d_rm_basename = s,\([^/]\)//*[^/]*$$,\1,
|
||||
_dirname = \
|
||||
sed '$(_d_no_slash);$(_d_strip_trailing);$(_d_abs_trivial);$(_d_rm_basename)'
|
||||
|
||||
# To be inserted before the command running the test. Creates the
|
||||
# directory for the log if needed. Stores in $dir the directory
|
||||
# containing $src, and passes TESTS_ENVIRONMENT.
|
||||
# Save and restore TERM around use of TESTS_ENVIRONMENT,
|
||||
# in case that unsets it.
|
||||
am__check_pre = \
|
||||
$(SH_E_WORKAROUND); \
|
||||
tst=`echo "$$src" | sed 's|^.*/||'`; \
|
||||
$(mkdir_p) "$$(dirname $@)" || exit; \
|
||||
rm -f $@-t; \
|
||||
trap 'st=$$?; rm -f '\''$(abs_builddir)/$@-t'\''; (exit $$st); exit $$st' \
|
||||
1 2 13 15; \
|
||||
$(mkdir_p) "$$(echo '$@'|$(_dirname))" || exit; \
|
||||
if test -f "./$$src"; then dir=./; \
|
||||
elif test -f "$$src"; then dir=; \
|
||||
else dir="$(srcdir)/"; fi; \
|
||||
$(TESTS_ENVIRONMENT) $(SHELL)
|
||||
__SAVED_TERM=$$TERM; \
|
||||
$(TESTS_ENVIRONMENT)
|
||||
|
||||
# To be appended to the command running the test. Handles the stdout
|
||||
# and stderr redirection, and catch the exit status.
|
||||
@@ -109,6 +123,7 @@ estatus=$$?; \
|
||||
if test $$estatus -eq 177; then \
|
||||
$(ENABLE_HARD_ERRORS) || estatus=1; \
|
||||
fi; \
|
||||
TERM=$$__SAVED_TERM; export TERM; \
|
||||
$(am__tty_colors); \
|
||||
xfailed=PASS; \
|
||||
for xfail in : $(XFAIL_TESTS); do \
|
||||
@@ -130,7 +145,7 @@ echo "$$res: $@ (exit: $$estatus)" | \
|
||||
cat $@-t >>$@; \
|
||||
rm $@-t
|
||||
|
||||
SUFFIXES = .html .log
|
||||
SUFFIXES += .html .log
|
||||
|
||||
# From a test (with no extension) to a log file.
|
||||
if GNU_MAKE
|
||||
@@ -144,8 +159,9 @@ CHECK-FORCE:
|
||||
DEPENDENCY = CHECK-FORCE
|
||||
$(TEST_LOGS): $(DEPENDENCY)
|
||||
@if test '$(DEPENDENCY)' = CHECK-FORCE; then \
|
||||
dst=$@; \
|
||||
exec $(MAKE) $(AM_MAKEFLAGS) DEPENDENCY='$(srcdir)'/$${dst%.log} $@;\
|
||||
dst=$@; src=$${dst%.log}; \
|
||||
test -x "$$src" || src='$(srcdir)'/$$src; \
|
||||
exec $(MAKE) $(AM_MAKEFLAGS) DEPENDENCY="$$src" $@; \
|
||||
else \
|
||||
src='$(DEPENDENCY)'; \
|
||||
$(am__check_pre) "$$dir$$src" $(am__check_post); \
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/sh
|
||||
# List the specified version-controlled files.
|
||||
|
||||
# Copyright (C) 2006, 2007 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/>.
|
||||
|
||||
|
||||
# List the specified version-controlled files.
|
||||
# With no argument, list them all.
|
||||
# This script must be run solely from the top of a $srcdir build directory.
|
||||
|
||||
# If there's an argument, it must be a single, "."-relative directory name.
|
||||
# cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
|
||||
|
||||
dir=
|
||||
case $# in
|
||||
0) ;;
|
||||
1) dir=$1 ;;
|
||||
*) echo "$0: too many arguments" 1>&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
test "x$dir" = x && dir=.
|
||||
|
||||
if test -d CVS; then
|
||||
if test -x build-aux/cvsu; then
|
||||
build-aux/cvsu --find --types=AFGM "$dir"
|
||||
else
|
||||
awk -F/ '{ \
|
||||
if (!$1 && $3 !~ /^-/) { \
|
||||
f=FILENAME; \
|
||||
sub(/CVS\/Entries/, "", f); \
|
||||
print f $2; \
|
||||
}}' \
|
||||
$(find ${*-*} -name Entries -print) /dev/null;
|
||||
fi
|
||||
else
|
||||
git-ls-files "$dir"
|
||||
fi
|
||||
@@ -1,5 +1,5 @@
|
||||
# Customize Makefile.maint. -*- makefile -*-
|
||||
# Copyright (C) 2003-2007 Free Software Foundation, Inc.
|
||||
# Customize maint.mk -*- makefile -*-
|
||||
# Copyright (C) 2003-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
|
||||
@@ -33,6 +33,13 @@ gpg_key_ID = B9AB9A16
|
||||
# at the top of the file for each `make distcheck' run.
|
||||
local-checks-to-skip = changelog-check strftime-check
|
||||
|
||||
# The local directory containing the checked-out copy of gnulib used in
|
||||
# this release. Used solely to get a date for the "announcement" target.
|
||||
local-checks-to-skip += patch-check
|
||||
|
||||
# The local directory containing the checked-out copy of gnulib used in this
|
||||
# release. Used solely to get gnulib's SHA1 for the "announcement" target.
|
||||
gnulib_dir = /gnulib
|
||||
|
||||
# Now that we have better (check.mk) tests, make this the default.
|
||||
export VERBOSE = yes
|
||||
|
||||
old_NEWS_hash = 95fc7a26fa253d57cabe4b058167a4f9 -
|
||||
55
configure.ac
55
configure.ac
@@ -1,7 +1,7 @@
|
||||
# -*- autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1991, 1993-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991, 1993-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
|
||||
@@ -23,7 +23,8 @@ 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)
|
||||
# following the v6.9 tag, and that 58ddd is a prefix of the commit SHA1.
|
||||
AC_INIT([GNU coreutils], m4_esyscmd([build-aux/git-version-gen .version]),
|
||||
AC_INIT([GNU coreutils],
|
||||
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
||||
[bug-coreutils@gnu.org])
|
||||
|
||||
AC_CONFIG_SRCDIR(src/ls.c)
|
||||
@@ -31,8 +32,7 @@ AC_CONFIG_SRCDIR(src/ls.c)
|
||||
AC_CONFIG_AUX_DIR(build-aux)
|
||||
AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
|
||||
|
||||
AB_INIT()
|
||||
AM_INIT_AUTOMAKE([1.10 dist-lzma])
|
||||
AM_INIT_AUTOMAKE([1.10a dist-lzma])
|
||||
|
||||
AC_PROG_CC_STDC
|
||||
AM_PROG_CC_C_O
|
||||
@@ -244,6 +244,7 @@ AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
|
||||
#include <signal.h>])
|
||||
|
||||
cu_LIB_CHECK
|
||||
cu_GMP
|
||||
|
||||
# Build df only if there's a point to it.
|
||||
if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
|
||||
@@ -258,7 +259,7 @@ mk="$srcdir/src/Makefile.am"
|
||||
v=EXTRA_PROGRAMS
|
||||
for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
|
||||
| sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
|
||||
| tr -s '\\012\\\\' ' '`; do
|
||||
| tr -s '\\015\\012\\\\' ' '`; do
|
||||
gl_ADD_PROG([optional_bin_progs], $gl_i)
|
||||
done
|
||||
|
||||
@@ -267,7 +268,7 @@ done
|
||||
v=no_install__progs
|
||||
t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
|
||||
| sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
|
||||
| tr -s '\\012\\\\' ' '`
|
||||
| tr -s '\\015\\012\\\\' ' '`
|
||||
# Remove any trailing space.
|
||||
no_install_progs_default=`echo "$t"|sed 's/ $//'`
|
||||
|
||||
@@ -279,7 +280,9 @@ no_install_progs_default=`echo "$t"|sed 's/ $//'`
|
||||
# The compromise is to ensure that the space-separated list extracted
|
||||
# above matches the literal 2nd argument below.
|
||||
c="$srcdir/configure.ac"
|
||||
t=`sed -n '/^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])/{s//\1/;s/,/ /gp}' $c`
|
||||
re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
|
||||
t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
|
||||
}' $c`
|
||||
case $t in
|
||||
$no_install_progs_default) ;;
|
||||
*) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
|
||||
@@ -307,10 +310,11 @@ case " $optional_bin_progs " in
|
||||
*) INSTALL_SU=no ;;
|
||||
esac
|
||||
|
||||
MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'`
|
||||
MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
|
||||
|
||||
# Change ginstall.1 to "install.h" in $MAN.
|
||||
MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done | tr '\012' ' '; echo`
|
||||
MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
|
||||
| tr '\015\012' ' '; echo`
|
||||
|
||||
# Remove [.1, since writing a portable rule for it in man/Makefile.am
|
||||
# is not practical. The sed LHS below uses the autoconf quadrigraph
|
||||
@@ -322,6 +326,8 @@ AC_SUBST([OPTIONAL_BIN_PROGS])
|
||||
NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
|
||||
AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
|
||||
|
||||
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
|
||||
|
||||
# Arrange to rerun configure whenever the file, src/Makefile.am,
|
||||
# containing the list of program names changes.
|
||||
CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
|
||||
@@ -331,6 +337,9 @@ AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
|
||||
AM_GNU_GETTEXT([external], [need-formatstring-macros])
|
||||
AM_GNU_GETTEXT_VERSION([0.15])
|
||||
|
||||
# For a test of uniq: it uses the $LOCALE_FR envvar.
|
||||
gt_LOCALE_FR
|
||||
|
||||
AC_CONFIG_FILES(
|
||||
Makefile
|
||||
doc/Makefile
|
||||
@@ -340,33 +349,5 @@ AC_CONFIG_FILES(
|
||||
src/Makefile
|
||||
tests/Makefile
|
||||
gnulib-tests/Makefile
|
||||
tests/chgrp/Makefile
|
||||
tests/chmod/Makefile
|
||||
tests/chown/Makefile
|
||||
tests/cp/Makefile
|
||||
tests/cut/Makefile
|
||||
tests/dd/Makefile
|
||||
tests/du/Makefile
|
||||
tests/head/Makefile
|
||||
tests/install/Makefile
|
||||
tests/join/Makefile
|
||||
tests/ln/Makefile
|
||||
tests/ls/Makefile
|
||||
tests/misc/Makefile
|
||||
tests/mkdir/Makefile
|
||||
tests/mv/Makefile
|
||||
tests/pr/Makefile
|
||||
tests/readlink/Makefile
|
||||
tests/rm/Makefile
|
||||
tests/rmdir/Makefile
|
||||
tests/sort/Makefile
|
||||
tests/tac/Makefile
|
||||
tests/tail-2/Makefile
|
||||
tests/tail/Makefile
|
||||
tests/test/Makefile
|
||||
tests/touch/Makefile
|
||||
tests/tr/Makefile
|
||||
tests/uniq/Makefile
|
||||
tests/wc/Makefile
|
||||
)
|
||||
AC_OUTPUT
|
||||
|
||||
15
doc/.gitignore
vendored
15
doc/.gitignore
vendored
@@ -1,5 +1,20 @@
|
||||
constants.texi
|
||||
coreutils.aux
|
||||
coreutils.cp
|
||||
coreutils.cps
|
||||
coreutils.dvi
|
||||
coreutils.fl
|
||||
coreutils.fn
|
||||
coreutils.html
|
||||
coreutils.info
|
||||
coreutils.ky
|
||||
coreutils.log
|
||||
coreutils.op
|
||||
coreutils.pdf
|
||||
coreutils.pg
|
||||
coreutils.toc
|
||||
coreutils.tp
|
||||
coreutils.vr
|
||||
fdl.texi
|
||||
getdate.texi
|
||||
stamp-vti
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Make coreutils documentation. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 1995-1998, 2001-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1995-1998, 2001-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 @@ check-texinfo: $(syntax_checks)
|
||||
$(srcdir)/*.texi 2> /dev/null || fail=1; }; \
|
||||
$(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi && fail=1; \
|
||||
$(EGREP) -i '$(_W)path(name)?s?$(W_)' $(srcdir)/*.texi \
|
||||
| $(EGREP) -v '@vindex PATH$$|@env[{]PATH[}]' && fail=1; \
|
||||
| $(EGREP) -v 'search path|@vindex PATH$$|@env[{]PATH[}]' && fail=1; \
|
||||
exit $$fail
|
||||
|
||||
# Use `time zone', not `timezone'.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
558
gl/lib/base64.c
558
gl/lib/base64.c
@@ -1,558 +0,0 @@
|
||||
/* base64.c -- Encode binary data using printable characters.
|
||||
Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006, 2007 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 Simon Josefsson. Partially adapted from GNU MailUtils
|
||||
* (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
|
||||
* from Paul Eggert, Bruno Haible, and Stepan Kasal.
|
||||
*
|
||||
* See also RFC 3548 <http://www.ietf.org/rfc/rfc3548.txt>.
|
||||
*
|
||||
* Be careful with error checking. Here is how you would typically
|
||||
* use these functions:
|
||||
*
|
||||
* bool ok = base64_decode_alloc (in, inlen, &out, &outlen);
|
||||
* if (!ok)
|
||||
* FAIL: input was not valid base64
|
||||
* if (out == NULL)
|
||||
* FAIL: memory allocation error
|
||||
* OK: data in OUT/OUTLEN
|
||||
*
|
||||
* size_t outlen = base64_encode_alloc (in, inlen, &out);
|
||||
* if (out == NULL && outlen == 0 && inlen != 0)
|
||||
* FAIL: input too long
|
||||
* if (out == NULL)
|
||||
* FAIL: memory allocation error
|
||||
* OK: data in OUT/OUTLEN.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Get prototype. */
|
||||
#include "base64.h"
|
||||
|
||||
/* Get malloc. */
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Get UCHAR_MAX. */
|
||||
#include <limits.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* C89 compliant way to cast 'char' to 'unsigned char'. */
|
||||
static inline unsigned char
|
||||
to_uchar (char ch)
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN.
|
||||
If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as
|
||||
possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero
|
||||
terminate the output buffer. */
|
||||
void
|
||||
base64_encode (const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t outlen)
|
||||
{
|
||||
static const char b64str[64] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
while (inlen && outlen)
|
||||
{
|
||||
*out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f];
|
||||
if (!--outlen)
|
||||
break;
|
||||
*out++ = b64str[((to_uchar (in[0]) << 4)
|
||||
+ (--inlen ? to_uchar (in[1]) >> 4 : 0))
|
||||
& 0x3f];
|
||||
if (!--outlen)
|
||||
break;
|
||||
*out++ =
|
||||
(inlen
|
||||
? b64str[((to_uchar (in[1]) << 2)
|
||||
+ (--inlen ? to_uchar (in[2]) >> 6 : 0))
|
||||
& 0x3f]
|
||||
: '=');
|
||||
if (!--outlen)
|
||||
break;
|
||||
*out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '=';
|
||||
if (!--outlen)
|
||||
break;
|
||||
if (inlen)
|
||||
inlen--;
|
||||
if (inlen)
|
||||
in += 3;
|
||||
}
|
||||
|
||||
if (outlen)
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
/* Allocate a buffer and store zero terminated base64 encoded data
|
||||
from array IN of size INLEN, returning BASE64_LENGTH(INLEN), i.e.,
|
||||
the length of the encoded data, excluding the terminating zero. On
|
||||
return, the OUT variable will hold a pointer to newly allocated
|
||||
memory that must be deallocated by the caller. If output string
|
||||
length would overflow, 0 is returned and OUT is set to NULL. If
|
||||
memory allocation failed, OUT is set to NULL, and the return value
|
||||
indicates length of the requested memory block, i.e.,
|
||||
BASE64_LENGTH(inlen) + 1. */
|
||||
size_t
|
||||
base64_encode_alloc (const char *in, size_t inlen, char **out)
|
||||
{
|
||||
size_t outlen = 1 + BASE64_LENGTH (inlen);
|
||||
|
||||
/* Check for overflow in outlen computation.
|
||||
*
|
||||
* If there is no overflow, outlen >= inlen.
|
||||
*
|
||||
* If the operation (inlen + 2) overflows then it yields at most +1, so
|
||||
* outlen is 0.
|
||||
*
|
||||
* If the multiplication overflows, we lose at least half of the
|
||||
* correct value, so the result is < ((inlen + 2) / 3) * 2, which is
|
||||
* less than (inlen + 2) * 0.66667, which is less than inlen as soon as
|
||||
* (inlen > 4).
|
||||
*/
|
||||
if (inlen > outlen)
|
||||
{
|
||||
*out = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*out = malloc (outlen);
|
||||
if (!*out)
|
||||
return outlen;
|
||||
|
||||
base64_encode (in, inlen, *out, outlen);
|
||||
|
||||
return outlen - 1;
|
||||
}
|
||||
|
||||
/* With this approach this file works independent of the charset used
|
||||
(think EBCDIC). However, it does assume that the characters in the
|
||||
Base64 alphabet (A-Za-z0-9+/) are encoded in 0..255. POSIX
|
||||
1003.1-2001 require that char and unsigned char are 8-bit
|
||||
quantities, though, taking care of that problem. But this may be a
|
||||
potential problem on non-POSIX C99 platforms.
|
||||
|
||||
IBM C V6 for AIX mishandles "#define B64(x) ...'x'...", so use "_"
|
||||
as the formal parameter rather than "x". */
|
||||
#define B64(_) \
|
||||
((_) == 'A' ? 0 \
|
||||
: (_) == 'B' ? 1 \
|
||||
: (_) == 'C' ? 2 \
|
||||
: (_) == 'D' ? 3 \
|
||||
: (_) == 'E' ? 4 \
|
||||
: (_) == 'F' ? 5 \
|
||||
: (_) == 'G' ? 6 \
|
||||
: (_) == 'H' ? 7 \
|
||||
: (_) == 'I' ? 8 \
|
||||
: (_) == 'J' ? 9 \
|
||||
: (_) == 'K' ? 10 \
|
||||
: (_) == 'L' ? 11 \
|
||||
: (_) == 'M' ? 12 \
|
||||
: (_) == 'N' ? 13 \
|
||||
: (_) == 'O' ? 14 \
|
||||
: (_) == 'P' ? 15 \
|
||||
: (_) == 'Q' ? 16 \
|
||||
: (_) == 'R' ? 17 \
|
||||
: (_) == 'S' ? 18 \
|
||||
: (_) == 'T' ? 19 \
|
||||
: (_) == 'U' ? 20 \
|
||||
: (_) == 'V' ? 21 \
|
||||
: (_) == 'W' ? 22 \
|
||||
: (_) == 'X' ? 23 \
|
||||
: (_) == 'Y' ? 24 \
|
||||
: (_) == 'Z' ? 25 \
|
||||
: (_) == 'a' ? 26 \
|
||||
: (_) == 'b' ? 27 \
|
||||
: (_) == 'c' ? 28 \
|
||||
: (_) == 'd' ? 29 \
|
||||
: (_) == 'e' ? 30 \
|
||||
: (_) == 'f' ? 31 \
|
||||
: (_) == 'g' ? 32 \
|
||||
: (_) == 'h' ? 33 \
|
||||
: (_) == 'i' ? 34 \
|
||||
: (_) == 'j' ? 35 \
|
||||
: (_) == 'k' ? 36 \
|
||||
: (_) == 'l' ? 37 \
|
||||
: (_) == 'm' ? 38 \
|
||||
: (_) == 'n' ? 39 \
|
||||
: (_) == 'o' ? 40 \
|
||||
: (_) == 'p' ? 41 \
|
||||
: (_) == 'q' ? 42 \
|
||||
: (_) == 'r' ? 43 \
|
||||
: (_) == 's' ? 44 \
|
||||
: (_) == 't' ? 45 \
|
||||
: (_) == 'u' ? 46 \
|
||||
: (_) == 'v' ? 47 \
|
||||
: (_) == 'w' ? 48 \
|
||||
: (_) == 'x' ? 49 \
|
||||
: (_) == 'y' ? 50 \
|
||||
: (_) == 'z' ? 51 \
|
||||
: (_) == '0' ? 52 \
|
||||
: (_) == '1' ? 53 \
|
||||
: (_) == '2' ? 54 \
|
||||
: (_) == '3' ? 55 \
|
||||
: (_) == '4' ? 56 \
|
||||
: (_) == '5' ? 57 \
|
||||
: (_) == '6' ? 58 \
|
||||
: (_) == '7' ? 59 \
|
||||
: (_) == '8' ? 60 \
|
||||
: (_) == '9' ? 61 \
|
||||
: (_) == '+' ? 62 \
|
||||
: (_) == '/' ? 63 \
|
||||
: -1)
|
||||
|
||||
static const signed char b64[0x100] = {
|
||||
B64 (0), B64 (1), B64 (2), B64 (3),
|
||||
B64 (4), B64 (5), B64 (6), B64 (7),
|
||||
B64 (8), B64 (9), B64 (10), B64 (11),
|
||||
B64 (12), B64 (13), B64 (14), B64 (15),
|
||||
B64 (16), B64 (17), B64 (18), B64 (19),
|
||||
B64 (20), B64 (21), B64 (22), B64 (23),
|
||||
B64 (24), B64 (25), B64 (26), B64 (27),
|
||||
B64 (28), B64 (29), B64 (30), B64 (31),
|
||||
B64 (32), B64 (33), B64 (34), B64 (35),
|
||||
B64 (36), B64 (37), B64 (38), B64 (39),
|
||||
B64 (40), B64 (41), B64 (42), B64 (43),
|
||||
B64 (44), B64 (45), B64 (46), B64 (47),
|
||||
B64 (48), B64 (49), B64 (50), B64 (51),
|
||||
B64 (52), B64 (53), B64 (54), B64 (55),
|
||||
B64 (56), B64 (57), B64 (58), B64 (59),
|
||||
B64 (60), B64 (61), B64 (62), B64 (63),
|
||||
B64 (64), B64 (65), B64 (66), B64 (67),
|
||||
B64 (68), B64 (69), B64 (70), B64 (71),
|
||||
B64 (72), B64 (73), B64 (74), B64 (75),
|
||||
B64 (76), B64 (77), B64 (78), B64 (79),
|
||||
B64 (80), B64 (81), B64 (82), B64 (83),
|
||||
B64 (84), B64 (85), B64 (86), B64 (87),
|
||||
B64 (88), B64 (89), B64 (90), B64 (91),
|
||||
B64 (92), B64 (93), B64 (94), B64 (95),
|
||||
B64 (96), B64 (97), B64 (98), B64 (99),
|
||||
B64 (100), B64 (101), B64 (102), B64 (103),
|
||||
B64 (104), B64 (105), B64 (106), B64 (107),
|
||||
B64 (108), B64 (109), B64 (110), B64 (111),
|
||||
B64 (112), B64 (113), B64 (114), B64 (115),
|
||||
B64 (116), B64 (117), B64 (118), B64 (119),
|
||||
B64 (120), B64 (121), B64 (122), B64 (123),
|
||||
B64 (124), B64 (125), B64 (126), B64 (127),
|
||||
B64 (128), B64 (129), B64 (130), B64 (131),
|
||||
B64 (132), B64 (133), B64 (134), B64 (135),
|
||||
B64 (136), B64 (137), B64 (138), B64 (139),
|
||||
B64 (140), B64 (141), B64 (142), B64 (143),
|
||||
B64 (144), B64 (145), B64 (146), B64 (147),
|
||||
B64 (148), B64 (149), B64 (150), B64 (151),
|
||||
B64 (152), B64 (153), B64 (154), B64 (155),
|
||||
B64 (156), B64 (157), B64 (158), B64 (159),
|
||||
B64 (160), B64 (161), B64 (162), B64 (163),
|
||||
B64 (164), B64 (165), B64 (166), B64 (167),
|
||||
B64 (168), B64 (169), B64 (170), B64 (171),
|
||||
B64 (172), B64 (173), B64 (174), B64 (175),
|
||||
B64 (176), B64 (177), B64 (178), B64 (179),
|
||||
B64 (180), B64 (181), B64 (182), B64 (183),
|
||||
B64 (184), B64 (185), B64 (186), B64 (187),
|
||||
B64 (188), B64 (189), B64 (190), B64 (191),
|
||||
B64 (192), B64 (193), B64 (194), B64 (195),
|
||||
B64 (196), B64 (197), B64 (198), B64 (199),
|
||||
B64 (200), B64 (201), B64 (202), B64 (203),
|
||||
B64 (204), B64 (205), B64 (206), B64 (207),
|
||||
B64 (208), B64 (209), B64 (210), B64 (211),
|
||||
B64 (212), B64 (213), B64 (214), B64 (215),
|
||||
B64 (216), B64 (217), B64 (218), B64 (219),
|
||||
B64 (220), B64 (221), B64 (222), B64 (223),
|
||||
B64 (224), B64 (225), B64 (226), B64 (227),
|
||||
B64 (228), B64 (229), B64 (230), B64 (231),
|
||||
B64 (232), B64 (233), B64 (234), B64 (235),
|
||||
B64 (236), B64 (237), B64 (238), B64 (239),
|
||||
B64 (240), B64 (241), B64 (242), B64 (243),
|
||||
B64 (244), B64 (245), B64 (246), B64 (247),
|
||||
B64 (248), B64 (249), B64 (250), B64 (251),
|
||||
B64 (252), B64 (253), B64 (254), B64 (255)
|
||||
};
|
||||
|
||||
#if UCHAR_MAX == 255
|
||||
# define uchar_in_range(c) true
|
||||
#else
|
||||
# define uchar_in_range(c) ((c) <= 255)
|
||||
#endif
|
||||
|
||||
/* Return true if CH is a character from the Base64 alphabet, and
|
||||
false otherwise. Note that '=' is padding and not considered to be
|
||||
part of the alphabet. */
|
||||
bool
|
||||
isbase64 (char ch)
|
||||
{
|
||||
return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)];
|
||||
}
|
||||
|
||||
/* Initialize decode-context buffer, CTX. */
|
||||
void
|
||||
base64_decode_ctx_init (struct base64_decode_context *ctx)
|
||||
{
|
||||
ctx->i = 0;
|
||||
}
|
||||
|
||||
/* If CTX->i is 0 or 4, there are four or more bytes in [*IN..IN_END), and
|
||||
none of those four is a newline, then return *IN. Otherwise, copy up to
|
||||
4 - CTX->i non-newline bytes from that range into CTX->buf, starting at
|
||||
index CTX->i and setting CTX->i to reflect the number of bytes copied,
|
||||
and return CTX->buf. In either case, advance *IN to point to the byte
|
||||
after the last one processed, and set *N_NON_NEWLINE to the number of
|
||||
verified non-newline bytes accessible through the returned pointer. */
|
||||
static inline char *
|
||||
get_4 (struct base64_decode_context *ctx,
|
||||
char const *restrict *in, char const *restrict in_end,
|
||||
size_t *n_non_newline)
|
||||
{
|
||||
if (ctx->i == 4)
|
||||
ctx->i = 0;
|
||||
|
||||
if (ctx->i == 0)
|
||||
{
|
||||
char const *t = *in;
|
||||
if (4 <= in_end - *in && memchr (t, '\n', 4) == NULL)
|
||||
{
|
||||
/* This is the common case: no newline. */
|
||||
*in += 4;
|
||||
*n_non_newline = 4;
|
||||
return (char *) t;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* Copy non-newline bytes into BUF. */
|
||||
char const *p = *in;
|
||||
while (p < in_end)
|
||||
{
|
||||
char c = *p++;
|
||||
if (c != '\n')
|
||||
{
|
||||
ctx->buf[ctx->i++] = c;
|
||||
if (ctx->i == 4)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*in = p;
|
||||
*n_non_newline = ctx->i;
|
||||
return ctx->buf;
|
||||
}
|
||||
}
|
||||
|
||||
#define return_false \
|
||||
do \
|
||||
{ \
|
||||
*outp = out; \
|
||||
return false; \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
/* Decode up to four bytes of base64-encoded data, IN, of length INLEN
|
||||
into the output buffer, *OUT, of size *OUTLEN bytes. Return true if
|
||||
decoding is successful, false otherwise. If *OUTLEN is too small,
|
||||
as many bytes as possible are written to *OUT. On return, advance
|
||||
*OUT to point to the byte after the last one written, and decrement
|
||||
*OUTLEN to reflect the number of bytes remaining in *OUT. */
|
||||
static inline bool
|
||||
decode_4 (char const *restrict in, size_t inlen,
|
||||
char *restrict *outp, size_t *outleft)
|
||||
{
|
||||
char *out = *outp;
|
||||
if (inlen < 2)
|
||||
return false;
|
||||
|
||||
if (!isbase64 (in[0]) || !isbase64 (in[1]))
|
||||
return false;
|
||||
|
||||
if (*outleft)
|
||||
{
|
||||
*out++ = ((b64[to_uchar (in[0])] << 2)
|
||||
| (b64[to_uchar (in[1])] >> 4));
|
||||
--*outleft;
|
||||
}
|
||||
|
||||
if (inlen == 2)
|
||||
return_false;
|
||||
|
||||
if (in[2] == '=')
|
||||
{
|
||||
if (inlen != 4)
|
||||
return_false;
|
||||
|
||||
if (in[3] != '=')
|
||||
return_false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isbase64 (in[2]))
|
||||
return_false;
|
||||
|
||||
if (*outleft)
|
||||
{
|
||||
*out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0)
|
||||
| (b64[to_uchar (in[2])] >> 2));
|
||||
--*outleft;
|
||||
}
|
||||
|
||||
if (inlen == 3)
|
||||
return_false;
|
||||
|
||||
if (in[3] == '=')
|
||||
{
|
||||
if (inlen != 4)
|
||||
return_false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isbase64 (in[3]))
|
||||
return_false;
|
||||
|
||||
if (*outleft)
|
||||
{
|
||||
*out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0)
|
||||
| b64[to_uchar (in[3])]);
|
||||
--*outleft;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*outp = out;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Decode base64-encoded input array IN of length INLEN to output array
|
||||
OUT that can hold *OUTLEN bytes. The input data may be interspersed
|
||||
with newlines. Return true if decoding was successful, i.e. if the
|
||||
input was valid base64 data, false otherwise. If *OUTLEN is too
|
||||
small, as many bytes as possible will be written to OUT. On return,
|
||||
*OUTLEN holds the length of decoded bytes in OUT. Note that as soon
|
||||
as any non-alphabet, non-newline character is encountered, decoding
|
||||
is stopped and false is returned. If INLEN is zero, then process
|
||||
only whatever data is stored in CTX.
|
||||
|
||||
Initially, CTX must have been initialized via base64_decode_ctx_init.
|
||||
Subsequent calls to this function must reuse whatever state is recorded
|
||||
in that buffer. It is necessary for when a quadruple of base64 input
|
||||
bytes spans two input buffers. */
|
||||
|
||||
bool
|
||||
base64_decode (struct base64_decode_context *ctx,
|
||||
const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t *outlen)
|
||||
{
|
||||
size_t outleft = *outlen;
|
||||
bool flush_ctx = inlen == 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
size_t outleft_save = outleft;
|
||||
if (ctx->i == 0 && !flush_ctx)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
/* Save a copy of outleft, in case we need to re-parse this
|
||||
block of four bytes. */
|
||||
outleft_save = outleft;
|
||||
if (!decode_4 (in, inlen, &out, &outleft))
|
||||
break;
|
||||
|
||||
in += 4;
|
||||
inlen -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (inlen == 0 && !flush_ctx)
|
||||
break;
|
||||
|
||||
/* Handle the common case of 72-byte wrapped lines.
|
||||
This also handles any other multiple-of-4-byte wrapping. */
|
||||
if (inlen && *in == '\n')
|
||||
{
|
||||
++in;
|
||||
--inlen;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Restore OUT and OUTLEFT. */
|
||||
out -= outleft_save - outleft;
|
||||
outleft = outleft_save;
|
||||
|
||||
{
|
||||
char const *in_end = in + inlen;
|
||||
char const *non_nl = get_4 (ctx, &in, in_end, &inlen);
|
||||
|
||||
/* If the input is empty or consists solely of newlines (0 non-newlines),
|
||||
then we're done. Likewise if there are fewer than 4 bytes when not
|
||||
flushing context. */
|
||||
if (inlen == 0 || (inlen < 4 && !flush_ctx))
|
||||
{
|
||||
inlen = 0;
|
||||
break;
|
||||
}
|
||||
if (!decode_4 (non_nl, inlen, &out, &outleft))
|
||||
break;
|
||||
|
||||
inlen = in_end - in;
|
||||
}
|
||||
}
|
||||
|
||||
*outlen -= outleft;
|
||||
|
||||
return inlen == 0;
|
||||
}
|
||||
|
||||
/* Allocate an output buffer in *OUT, and decode the base64 encoded
|
||||
data stored in IN of size INLEN to the *OUT buffer. On return, the
|
||||
size of the decoded data is stored in *OUTLEN. OUTLEN may be NULL,
|
||||
if the caller is not interested in the decoded length. *OUT may be
|
||||
NULL to indicate an out of memory error, in which case *OUTLEN
|
||||
contains the size of the memory block needed. The function returns
|
||||
true on successful decoding and memory allocation errors. (Use the
|
||||
*OUT and *OUTLEN parameters to differentiate between successful
|
||||
decoding and memory error.) The function returns false if the
|
||||
input was invalid, in which case *OUT is NULL and *OUTLEN is
|
||||
undefined. */
|
||||
bool
|
||||
base64_decode_alloc (struct base64_decode_context *ctx,
|
||||
const char *in, size_t inlen, char **out,
|
||||
size_t *outlen)
|
||||
{
|
||||
/* This may allocate a few bytes too many, depending on input,
|
||||
but it's not worth the extra CPU time to compute the exact size.
|
||||
The exact size is 3 * inlen / 4, minus 1 if the input ends
|
||||
with "=" and minus another 1 if the input ends with "==".
|
||||
Dividing before multiplying avoids the possibility of overflow. */
|
||||
size_t needlen = 3 * (inlen / 4) + 2;
|
||||
|
||||
*out = malloc (needlen);
|
||||
if (!*out)
|
||||
return true;
|
||||
|
||||
if (!base64_decode (ctx, in, inlen, *out, &needlen))
|
||||
{
|
||||
free (*out);
|
||||
*out = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (outlen)
|
||||
*outlen = needlen;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/* base64.h -- Encode binary data using printable characters.
|
||||
Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
Written by Simon Josefsson.
|
||||
|
||||
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/>. */
|
||||
|
||||
#ifndef BASE64_H
|
||||
# define BASE64_H
|
||||
|
||||
/* Get size_t. */
|
||||
# include <stddef.h>
|
||||
|
||||
/* Get bool. */
|
||||
# include <stdbool.h>
|
||||
|
||||
/* This uses that the expression (n+(k-1))/k means the smallest
|
||||
integer >= n/k, i.e., the ceiling of n/k. */
|
||||
# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
|
||||
|
||||
struct base64_decode_context
|
||||
{
|
||||
unsigned int i;
|
||||
char buf[4];
|
||||
};
|
||||
|
||||
extern bool isbase64 (char ch);
|
||||
|
||||
extern void base64_encode (const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t outlen);
|
||||
|
||||
extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
|
||||
|
||||
extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
|
||||
extern bool base64_decode (struct base64_decode_context *ctx,
|
||||
const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t *outlen);
|
||||
|
||||
extern bool base64_decode_alloc (struct base64_decode_context *ctx,
|
||||
const char *in, size_t inlen,
|
||||
char **out, size_t *outlen);
|
||||
|
||||
#endif /* BASE64_H */
|
||||
@@ -1,6 +1,6 @@
|
||||
/* mgetgroups.c -- return a list of the groups a user is in
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation.
|
||||
Copyright (C) 2007-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
|
||||
@@ -21,13 +21,30 @@
|
||||
|
||||
#include "mgetgroups.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if HAVE_GETGROUPLIST
|
||||
# include <grp.h>
|
||||
#endif
|
||||
#include "getugroups.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
|
||||
static void *
|
||||
allocate_groupbuf (int size)
|
||||
{
|
||||
if (xalloc_oversized (size, sizeof (GETGROUPS_T)))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return malloc (size * sizeof (GETGROUPS_T));
|
||||
}
|
||||
|
||||
/* Like getugroups, but store the result in malloc'd storage.
|
||||
Set *GROUPS to the malloc'd list of all group IDs of which USERNAME
|
||||
is a member. If GID is not -1, store it first. GID should be the
|
||||
@@ -37,12 +54,68 @@
|
||||
the number of groups. */
|
||||
|
||||
int
|
||||
mgetgroups (const char *username, gid_t gid, GETGROUPS_T **groups)
|
||||
mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
|
||||
{
|
||||
int max_n_groups;
|
||||
int ng;
|
||||
GETGROUPS_T *g;
|
||||
|
||||
#if HAVE_GETGROUPLIST
|
||||
/* We prefer to use getgrouplist if available, because it has better
|
||||
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
|
||||
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);
|
||||
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;
|
||||
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)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (g);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
g = h;
|
||||
}
|
||||
}
|
||||
/* else no username, so fall through and use getgroups. */
|
||||
#endif
|
||||
|
||||
max_n_groups = (username
|
||||
? getugroups (0, NULL, username, gid)
|
||||
: getgroups (0, NULL));
|
||||
@@ -52,13 +125,7 @@ mgetgroups (const char *username, gid_t gid, GETGROUPS_T **groups)
|
||||
if (max_n_groups < 0)
|
||||
max_n_groups = 5;
|
||||
|
||||
if (xalloc_oversized (max_n_groups, sizeof *g))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
g = malloc (max_n_groups * sizeof *g);
|
||||
g = allocate_groupbuf (max_n_groups);
|
||||
if (g == NULL)
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate buffers of random data.
|
||||
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 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
|
||||
@@ -44,7 +44,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,8 @@ 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 int getcon (security_context_t *con)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline void freecon (security_context_t con) {}
|
||||
|
||||
|
||||
@@ -28,7 +29,6 @@ static inline int setfscreatecon (security_context_t con)
|
||||
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)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#serial 1
|
||||
dnl Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
#serial 2
|
||||
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,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_MGETGROUPS],
|
||||
[
|
||||
AC_CHECK_FUNCS(getgrouplist)
|
||||
AC_LIBOBJ([mgetgroups])
|
||||
])
|
||||
|
||||
@@ -7,7 +7,6 @@ lib/mgetgroups.h
|
||||
m4/mgetgroups.m4
|
||||
|
||||
Depends-on:
|
||||
free
|
||||
getugroups
|
||||
xalloc
|
||||
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
include gnulib.mk
|
||||
|
||||
TEST_LOGS = $(TESTS:=.log)
|
||||
|
||||
# Parallel replacement of Automake's check-TESTS target.
|
||||
include $(top_srcdir)/build-aux/check.mk
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Invoke open, but return either a desired file descriptor or -1.
|
||||
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 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
|
||||
@@ -31,15 +31,13 @@
|
||||
int
|
||||
fd_reopen (int desired_fd, char const *file, int flags, mode_t mode)
|
||||
{
|
||||
int fd;
|
||||
int fd = open (file, flags, mode);
|
||||
|
||||
close (desired_fd);
|
||||
fd = open (file, flags, mode);
|
||||
if (fd == desired_fd || fd < 0)
|
||||
return fd;
|
||||
else
|
||||
{
|
||||
int fd2 = fcntl (fd, F_DUPFD, desired_fd);
|
||||
int fd2 = dup2 (fd, desired_fd);
|
||||
int saved_errno = errno;
|
||||
close (fd);
|
||||
errno = saved_errno;
|
||||
|
||||
545
lib/sha256.c
545
lib/sha256.c
@@ -1,545 +0,0 @@
|
||||
/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
|
||||
memory blocks according to the NIST specification FIPS-180-2.
|
||||
|
||||
Copyright (C) 2005, 2006 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 David Madore, considerably copypasting from
|
||||
Scott G. Miller's sha1.c
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "sha256.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#if USE_UNLOCKED_IO
|
||||
# include "unlocked-io.h"
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define SWAP(n) (n)
|
||||
#else
|
||||
# define SWAP(n) \
|
||||
(((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
|
||||
#endif
|
||||
|
||||
#define BLOCKSIZE 4096
|
||||
#if BLOCKSIZE % 64 != 0
|
||||
# error "invalid BLOCKSIZE"
|
||||
#endif
|
||||
|
||||
/* This array contains the bytes used to pad the buffer to the next
|
||||
64-byte boundary. */
|
||||
static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
|
||||
|
||||
|
||||
/*
|
||||
Takes a pointer to a 256 bit block of data (eight 32 bit ints) and
|
||||
intializes it to the start constants of the SHA256 algorithm. This
|
||||
must be called before using hash in the call to sha256_hash
|
||||
*/
|
||||
void
|
||||
sha256_init_ctx (struct sha256_ctx *ctx)
|
||||
{
|
||||
ctx->state[0] = 0x6a09e667UL;
|
||||
ctx->state[1] = 0xbb67ae85UL;
|
||||
ctx->state[2] = 0x3c6ef372UL;
|
||||
ctx->state[3] = 0xa54ff53aUL;
|
||||
ctx->state[4] = 0x510e527fUL;
|
||||
ctx->state[5] = 0x9b05688cUL;
|
||||
ctx->state[6] = 0x1f83d9abUL;
|
||||
ctx->state[7] = 0x5be0cd19UL;
|
||||
|
||||
ctx->total[0] = ctx->total[1] = 0;
|
||||
ctx->buflen = 0;
|
||||
}
|
||||
|
||||
void
|
||||
sha224_init_ctx (struct sha256_ctx *ctx)
|
||||
{
|
||||
ctx->state[0] = 0xc1059ed8UL;
|
||||
ctx->state[1] = 0x367cd507UL;
|
||||
ctx->state[2] = 0x3070dd17UL;
|
||||
ctx->state[3] = 0xf70e5939UL;
|
||||
ctx->state[4] = 0xffc00b31UL;
|
||||
ctx->state[5] = 0x68581511UL;
|
||||
ctx->state[6] = 0x64f98fa7UL;
|
||||
ctx->state[7] = 0xbefa4fa4UL;
|
||||
|
||||
ctx->total[0] = ctx->total[1] = 0;
|
||||
ctx->buflen = 0;
|
||||
}
|
||||
|
||||
/* Put result from CTX in first 32 bytes following RESBUF. The result
|
||||
must be in little endian byte order.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32-bit value. */
|
||||
void *
|
||||
sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
((uint32_t *) resbuf)[i] = SWAP (ctx->state[i]);
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
|
||||
void *
|
||||
sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
((uint32_t *) resbuf)[i] = SWAP (ctx->state[i]);
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
|
||||
/* Process the remaining bytes in the internal buffer and the usual
|
||||
prolog according to the standard and write the result to RESBUF.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32-bit value. */
|
||||
static void
|
||||
sha256_conclude_ctx (struct sha256_ctx *ctx)
|
||||
{
|
||||
/* Take yet unprocessed bytes into account. */
|
||||
uint32_t bytes = ctx->buflen;
|
||||
size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
|
||||
|
||||
/* Now count remaining bytes. */
|
||||
ctx->total[0] += bytes;
|
||||
if (ctx->total[0] < bytes)
|
||||
++ctx->total[1];
|
||||
|
||||
/* Put the 64-bit file length in *bits* at the end of the buffer. */
|
||||
ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
|
||||
ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
|
||||
|
||||
memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
|
||||
|
||||
/* Process last bytes. */
|
||||
sha256_process_block (ctx->buffer, size * 4, ctx);
|
||||
}
|
||||
|
||||
void *
|
||||
sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
|
||||
{
|
||||
sha256_conclude_ctx (ctx);
|
||||
return sha256_read_ctx (ctx, resbuf);
|
||||
}
|
||||
|
||||
void *
|
||||
sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
|
||||
{
|
||||
sha256_conclude_ctx (ctx);
|
||||
return sha224_read_ctx (ctx, resbuf);
|
||||
}
|
||||
|
||||
/* Compute SHA256 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 32 bytes
|
||||
beginning at RESBLOCK. */
|
||||
int
|
||||
sha256_stream (FILE *stream, void *resblock)
|
||||
{
|
||||
struct sha256_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha256_init_ctx (&ctx);
|
||||
|
||||
/* Iterate over full file contents. */
|
||||
while (1)
|
||||
{
|
||||
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
|
||||
computation function processes the whole buffer so that with the
|
||||
next round of the loop another block can be read. */
|
||||
size_t n;
|
||||
sum = 0;
|
||||
|
||||
/* Read block. Take care for partial reads. */
|
||||
while (1)
|
||||
{
|
||||
n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
|
||||
|
||||
sum += n;
|
||||
|
||||
if (sum == BLOCKSIZE)
|
||||
break;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
/* Check for the error flag IFF N == 0, so that we don't
|
||||
exit the loop after a partial read due to e.g., EAGAIN
|
||||
or EWOULDBLOCK. */
|
||||
if (ferror (stream))
|
||||
return 1;
|
||||
goto process_partial_block;
|
||||
}
|
||||
|
||||
/* We've read at least one byte, so ignore errors. But always
|
||||
check for EOF, since feof may be true even though N > 0.
|
||||
Otherwise, we could end up calling fread after EOF. */
|
||||
if (feof (stream))
|
||||
goto process_partial_block;
|
||||
}
|
||||
|
||||
/* Process buffer with BLOCKSIZE bytes. Note that
|
||||
BLOCKSIZE % 64 == 0
|
||||
*/
|
||||
sha256_process_block (buffer, BLOCKSIZE, &ctx);
|
||||
}
|
||||
|
||||
process_partial_block:;
|
||||
|
||||
/* Process any remaining bytes. */
|
||||
if (sum > 0)
|
||||
sha256_process_bytes (buffer, sum, &ctx);
|
||||
|
||||
/* Construct result in desired memory. */
|
||||
sha256_finish_ctx (&ctx, resblock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: Avoid code duplication */
|
||||
int
|
||||
sha224_stream (FILE *stream, void *resblock)
|
||||
{
|
||||
struct sha256_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha224_init_ctx (&ctx);
|
||||
|
||||
/* Iterate over full file contents. */
|
||||
while (1)
|
||||
{
|
||||
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
|
||||
computation function processes the whole buffer so that with the
|
||||
next round of the loop another block can be read. */
|
||||
size_t n;
|
||||
sum = 0;
|
||||
|
||||
/* Read block. Take care for partial reads. */
|
||||
while (1)
|
||||
{
|
||||
n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
|
||||
|
||||
sum += n;
|
||||
|
||||
if (sum == BLOCKSIZE)
|
||||
break;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
/* Check for the error flag IFF N == 0, so that we don't
|
||||
exit the loop after a partial read due to e.g., EAGAIN
|
||||
or EWOULDBLOCK. */
|
||||
if (ferror (stream))
|
||||
return 1;
|
||||
goto process_partial_block;
|
||||
}
|
||||
|
||||
/* We've read at least one byte, so ignore errors. But always
|
||||
check for EOF, since feof may be true even though N > 0.
|
||||
Otherwise, we could end up calling fread after EOF. */
|
||||
if (feof (stream))
|
||||
goto process_partial_block;
|
||||
}
|
||||
|
||||
/* Process buffer with BLOCKSIZE bytes. Note that
|
||||
BLOCKSIZE % 64 == 0
|
||||
*/
|
||||
sha256_process_block (buffer, BLOCKSIZE, &ctx);
|
||||
}
|
||||
|
||||
process_partial_block:;
|
||||
|
||||
/* Process any remaining bytes. */
|
||||
if (sum > 0)
|
||||
sha256_process_bytes (buffer, sum, &ctx);
|
||||
|
||||
/* Construct result in desired memory. */
|
||||
sha224_finish_ctx (&ctx, resblock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compute SHA512 message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
void *
|
||||
sha256_buffer (const char *buffer, size_t len, void *resblock)
|
||||
{
|
||||
struct sha256_ctx ctx;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha256_init_ctx (&ctx);
|
||||
|
||||
/* Process whole buffer but last len % 64 bytes. */
|
||||
sha256_process_bytes (buffer, len, &ctx);
|
||||
|
||||
/* Put result in desired memory area. */
|
||||
return sha256_finish_ctx (&ctx, resblock);
|
||||
}
|
||||
|
||||
void *
|
||||
sha224_buffer (const char *buffer, size_t len, void *resblock)
|
||||
{
|
||||
struct sha256_ctx ctx;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha224_init_ctx (&ctx);
|
||||
|
||||
/* Process whole buffer but last len % 64 bytes. */
|
||||
sha256_process_bytes (buffer, len, &ctx);
|
||||
|
||||
/* Put result in desired memory area. */
|
||||
return sha224_finish_ctx (&ctx, resblock);
|
||||
}
|
||||
|
||||
void
|
||||
sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
|
||||
{
|
||||
/* When we already have some bits in our internal buffer concatenate
|
||||
both inputs first. */
|
||||
if (ctx->buflen != 0)
|
||||
{
|
||||
size_t left_over = ctx->buflen;
|
||||
size_t add = 128 - left_over > len ? len : 128 - left_over;
|
||||
|
||||
memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
|
||||
ctx->buflen += add;
|
||||
|
||||
if (ctx->buflen > 64)
|
||||
{
|
||||
sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
|
||||
|
||||
ctx->buflen &= 63;
|
||||
/* The regions in the following copy operation cannot overlap. */
|
||||
memcpy (ctx->buffer,
|
||||
&((char *) ctx->buffer)[(left_over + add) & ~63],
|
||||
ctx->buflen);
|
||||
}
|
||||
|
||||
buffer = (const char *) buffer + add;
|
||||
len -= add;
|
||||
}
|
||||
|
||||
/* Process available complete blocks. */
|
||||
if (len >= 64)
|
||||
{
|
||||
#if !_STRING_ARCH_unaligned
|
||||
# define alignof(type) offsetof (struct { char c; type x; }, x)
|
||||
# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
|
||||
if (UNALIGNED_P (buffer))
|
||||
while (len > 64)
|
||||
{
|
||||
sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
|
||||
buffer = (const char *) buffer + 64;
|
||||
len -= 64;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sha256_process_block (buffer, len & ~63, ctx);
|
||||
buffer = (const char *) buffer + (len & ~63);
|
||||
len &= 63;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move remaining bytes in internal buffer. */
|
||||
if (len > 0)
|
||||
{
|
||||
size_t left_over = ctx->buflen;
|
||||
|
||||
memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
|
||||
left_over += len;
|
||||
if (left_over >= 64)
|
||||
{
|
||||
sha256_process_block (ctx->buffer, 64, ctx);
|
||||
left_over -= 64;
|
||||
memcpy (ctx->buffer, &ctx->buffer[16], left_over);
|
||||
}
|
||||
ctx->buflen = left_over;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Code below is the primary difference between sha1.c and sha256.c --- */
|
||||
|
||||
/* SHA256 round constants */
|
||||
#define K(I) sha256_round_constants[I]
|
||||
static const uint32_t sha256_round_constants[64] = {
|
||||
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
|
||||
0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
|
||||
0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
|
||||
0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
|
||||
0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
|
||||
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
|
||||
0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
|
||||
0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
|
||||
0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
|
||||
0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
|
||||
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
|
||||
0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
|
||||
0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
|
||||
0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
|
||||
0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
|
||||
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL,
|
||||
};
|
||||
|
||||
/* Round functions. */
|
||||
#define F2(A,B,C) ( ( A & B ) | ( C & ( A | B ) ) )
|
||||
#define F1(E,F,G) ( G ^ ( E & ( F ^ G ) ) )
|
||||
|
||||
/* Process LEN bytes of BUFFER, accumulating context into CTX.
|
||||
It is assumed that LEN % 64 == 0.
|
||||
Most of this code comes from GnuPG's cipher/sha1.c. */
|
||||
|
||||
void
|
||||
sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
|
||||
{
|
||||
const uint32_t *words = buffer;
|
||||
size_t nwords = len / sizeof (uint32_t);
|
||||
const uint32_t *endp = words + nwords;
|
||||
uint32_t x[16];
|
||||
uint32_t a = ctx->state[0];
|
||||
uint32_t b = ctx->state[1];
|
||||
uint32_t c = ctx->state[2];
|
||||
uint32_t d = ctx->state[3];
|
||||
uint32_t e = ctx->state[4];
|
||||
uint32_t f = ctx->state[5];
|
||||
uint32_t g = ctx->state[6];
|
||||
uint32_t h = ctx->state[7];
|
||||
|
||||
/* First increment the byte count. FIPS PUB 180-2 specifies the possible
|
||||
length of the file up to 2^64 bits. Here we only compute the
|
||||
number of bytes. Do a double word increment. */
|
||||
ctx->total[0] += len;
|
||||
if (ctx->total[0] < len)
|
||||
++ctx->total[1];
|
||||
|
||||
#define rol(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
#define S0(x) (rol(x,25)^rol(x,14)^(x>>3))
|
||||
#define S1(x) (rol(x,15)^rol(x,13)^(x>>10))
|
||||
#define SS0(x) (rol(x,30)^rol(x,19)^rol(x,10))
|
||||
#define SS1(x) (rol(x,26)^rol(x,21)^rol(x,7))
|
||||
|
||||
#define M(I) ( tm = S1(x[(I-2)&0x0f]) + x[(I-7)&0x0f] \
|
||||
+ S0(x[(I-15)&0x0f]) + x[I&0x0f] \
|
||||
, x[I&0x0f] = tm )
|
||||
|
||||
#define R(A,B,C,D,E,F,G,H,K,M) do { t0 = SS0(A) + F2(A,B,C); \
|
||||
t1 = H + SS1(E) \
|
||||
+ F1(E,F,G) \
|
||||
+ K \
|
||||
+ M; \
|
||||
D += t1; H = t0 + t1; \
|
||||
} while(0)
|
||||
|
||||
while (words < endp)
|
||||
{
|
||||
uint32_t tm;
|
||||
uint32_t t0, t1;
|
||||
int t;
|
||||
/* FIXME: see sha1.c for a better implementation. */
|
||||
for (t = 0; t < 16; t++)
|
||||
{
|
||||
x[t] = SWAP (*words);
|
||||
words++;
|
||||
}
|
||||
|
||||
R( a, b, c, d, e, f, g, h, K( 0), x[ 0] );
|
||||
R( h, a, b, c, d, e, f, g, K( 1), x[ 1] );
|
||||
R( g, h, a, b, c, d, e, f, K( 2), x[ 2] );
|
||||
R( f, g, h, a, b, c, d, e, K( 3), x[ 3] );
|
||||
R( e, f, g, h, a, b, c, d, K( 4), x[ 4] );
|
||||
R( d, e, f, g, h, a, b, c, K( 5), x[ 5] );
|
||||
R( c, d, e, f, g, h, a, b, K( 6), x[ 6] );
|
||||
R( b, c, d, e, f, g, h, a, K( 7), x[ 7] );
|
||||
R( a, b, c, d, e, f, g, h, K( 8), x[ 8] );
|
||||
R( h, a, b, c, d, e, f, g, K( 9), x[ 9] );
|
||||
R( g, h, a, b, c, d, e, f, K(10), x[10] );
|
||||
R( f, g, h, a, b, c, d, e, K(11), x[11] );
|
||||
R( e, f, g, h, a, b, c, d, K(12), x[12] );
|
||||
R( d, e, f, g, h, a, b, c, K(13), x[13] );
|
||||
R( c, d, e, f, g, h, a, b, K(14), x[14] );
|
||||
R( b, c, d, e, f, g, h, a, K(15), x[15] );
|
||||
R( a, b, c, d, e, f, g, h, K(16), M(16) );
|
||||
R( h, a, b, c, d, e, f, g, K(17), M(17) );
|
||||
R( g, h, a, b, c, d, e, f, K(18), M(18) );
|
||||
R( f, g, h, a, b, c, d, e, K(19), M(19) );
|
||||
R( e, f, g, h, a, b, c, d, K(20), M(20) );
|
||||
R( d, e, f, g, h, a, b, c, K(21), M(21) );
|
||||
R( c, d, e, f, g, h, a, b, K(22), M(22) );
|
||||
R( b, c, d, e, f, g, h, a, K(23), M(23) );
|
||||
R( a, b, c, d, e, f, g, h, K(24), M(24) );
|
||||
R( h, a, b, c, d, e, f, g, K(25), M(25) );
|
||||
R( g, h, a, b, c, d, e, f, K(26), M(26) );
|
||||
R( f, g, h, a, b, c, d, e, K(27), M(27) );
|
||||
R( e, f, g, h, a, b, c, d, K(28), M(28) );
|
||||
R( d, e, f, g, h, a, b, c, K(29), M(29) );
|
||||
R( c, d, e, f, g, h, a, b, K(30), M(30) );
|
||||
R( b, c, d, e, f, g, h, a, K(31), M(31) );
|
||||
R( a, b, c, d, e, f, g, h, K(32), M(32) );
|
||||
R( h, a, b, c, d, e, f, g, K(33), M(33) );
|
||||
R( g, h, a, b, c, d, e, f, K(34), M(34) );
|
||||
R( f, g, h, a, b, c, d, e, K(35), M(35) );
|
||||
R( e, f, g, h, a, b, c, d, K(36), M(36) );
|
||||
R( d, e, f, g, h, a, b, c, K(37), M(37) );
|
||||
R( c, d, e, f, g, h, a, b, K(38), M(38) );
|
||||
R( b, c, d, e, f, g, h, a, K(39), M(39) );
|
||||
R( a, b, c, d, e, f, g, h, K(40), M(40) );
|
||||
R( h, a, b, c, d, e, f, g, K(41), M(41) );
|
||||
R( g, h, a, b, c, d, e, f, K(42), M(42) );
|
||||
R( f, g, h, a, b, c, d, e, K(43), M(43) );
|
||||
R( e, f, g, h, a, b, c, d, K(44), M(44) );
|
||||
R( d, e, f, g, h, a, b, c, K(45), M(45) );
|
||||
R( c, d, e, f, g, h, a, b, K(46), M(46) );
|
||||
R( b, c, d, e, f, g, h, a, K(47), M(47) );
|
||||
R( a, b, c, d, e, f, g, h, K(48), M(48) );
|
||||
R( h, a, b, c, d, e, f, g, K(49), M(49) );
|
||||
R( g, h, a, b, c, d, e, f, K(50), M(50) );
|
||||
R( f, g, h, a, b, c, d, e, K(51), M(51) );
|
||||
R( e, f, g, h, a, b, c, d, K(52), M(52) );
|
||||
R( d, e, f, g, h, a, b, c, K(53), M(53) );
|
||||
R( c, d, e, f, g, h, a, b, K(54), M(54) );
|
||||
R( b, c, d, e, f, g, h, a, K(55), M(55) );
|
||||
R( a, b, c, d, e, f, g, h, K(56), M(56) );
|
||||
R( h, a, b, c, d, e, f, g, K(57), M(57) );
|
||||
R( g, h, a, b, c, d, e, f, K(58), M(58) );
|
||||
R( f, g, h, a, b, c, d, e, K(59), M(59) );
|
||||
R( e, f, g, h, a, b, c, d, K(60), M(60) );
|
||||
R( d, e, f, g, h, a, b, c, K(61), M(61) );
|
||||
R( c, d, e, f, g, h, a, b, K(62), M(62) );
|
||||
R( b, c, d, e, f, g, h, a, K(63), M(63) );
|
||||
|
||||
a = ctx->state[0] += a;
|
||||
b = ctx->state[1] += b;
|
||||
c = ctx->state[2] += c;
|
||||
d = ctx->state[3] += d;
|
||||
e = ctx->state[4] += e;
|
||||
f = ctx->state[5] += f;
|
||||
g = ctx->state[6] += g;
|
||||
h = ctx->state[7] += h;
|
||||
}
|
||||
}
|
||||
87
lib/sha256.h
87
lib/sha256.h
@@ -1,87 +0,0 @@
|
||||
/* Declarations of functions and data types used for SHA256 and SHA224 sum
|
||||
library functions.
|
||||
Copyright (C) 2005, 2006 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/>. */
|
||||
|
||||
#ifndef SHA256_H
|
||||
# define SHA256_H 1
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdint.h>
|
||||
|
||||
/* Structure to save state of computation between the single steps. */
|
||||
struct sha256_ctx
|
||||
{
|
||||
uint32_t state[8];
|
||||
|
||||
uint32_t total[2];
|
||||
uint32_t buflen;
|
||||
uint32_t buffer[32];
|
||||
};
|
||||
|
||||
|
||||
/* Initialize structure containing state of computation. */
|
||||
extern void sha256_init_ctx (struct sha256_ctx *ctx);
|
||||
extern void sha224_init_ctx (struct sha256_ctx *ctx);
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is necessary that LEN is a multiple of 64!!! */
|
||||
extern void sha256_process_block (const void *buffer, size_t len,
|
||||
struct sha256_ctx *ctx);
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is NOT required that LEN is a multiple of 64. */
|
||||
extern void sha256_process_bytes (const void *buffer, size_t len,
|
||||
struct sha256_ctx *ctx);
|
||||
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
in first 32 (28) bytes following RESBUF. The result is always in little
|
||||
endian byte order, so that a byte-wise output yields to the wanted
|
||||
ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF be correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf);
|
||||
extern void *sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf);
|
||||
|
||||
|
||||
/* Put result from CTX in first 32 (28) bytes following RESBUF. The result is
|
||||
always in little endian byte order, so that a byte-wise output yields
|
||||
to the wanted ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf);
|
||||
extern void *sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf);
|
||||
|
||||
|
||||
/* Compute SHA256 (SHA224) message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 32 (28) bytes
|
||||
beginning at RESBLOCK. */
|
||||
extern int sha256_stream (FILE *stream, void *resblock);
|
||||
extern int sha224_stream (FILE *stream, void *resblock);
|
||||
|
||||
/* Compute SHA256 (SHA224) message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
extern void *sha256_buffer (const char *buffer, size_t len, void *resblock);
|
||||
extern void *sha224_buffer (const char *buffer, size_t len, void *resblock);
|
||||
|
||||
#endif
|
||||
595
lib/sha512.c
595
lib/sha512.c
@@ -1,595 +0,0 @@
|
||||
/* sha512.c - Functions to compute SHA512 and SHA384 message digest of files or
|
||||
memory blocks according to the NIST specification FIPS-180-2.
|
||||
|
||||
Copyright (C) 2005, 2006 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 David Madore, considerably copypasting from
|
||||
Scott G. Miller's sha1.c
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "sha512.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#if USE_UNLOCKED_IO
|
||||
# include "unlocked-io.h"
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define SWAP(n) (n)
|
||||
#else
|
||||
# define SWAP(n) \
|
||||
u64or (u64or (u64or (u64shl (n, 56), \
|
||||
u64shl (u64and (n, u64lo (0x0000ff00)), 40)), \
|
||||
u64or (u64shl (u64and (n, u64lo (0x00ff0000)), 24), \
|
||||
u64shl (u64and (n, u64lo (0xff000000)), 8))), \
|
||||
u64or (u64or (u64and (u64shr (n, 8), u64lo (0xff000000)), \
|
||||
u64and (u64shr (n, 24), u64lo (0x00ff0000))), \
|
||||
u64or (u64and (u64shr (n, 40), u64lo (0x0000ff00)), \
|
||||
u64shr (n, 56))))
|
||||
#endif
|
||||
|
||||
#define BLOCKSIZE 4096
|
||||
#if BLOCKSIZE % 128 != 0
|
||||
# error "invalid BLOCKSIZE"
|
||||
#endif
|
||||
|
||||
/* This array contains the bytes used to pad the buffer to the next
|
||||
128-byte boundary. */
|
||||
static const unsigned char fillbuf[128] = { 0x80, 0 /* , 0, 0, ... */ };
|
||||
|
||||
|
||||
/*
|
||||
Takes a pointer to a 512 bit block of data (eight 64 bit ints) and
|
||||
intializes it to the start constants of the SHA512 algorithm. This
|
||||
must be called before using hash in the call to sha512_hash
|
||||
*/
|
||||
void
|
||||
sha512_init_ctx (struct sha512_ctx *ctx)
|
||||
{
|
||||
ctx->state[0] = u64hilo (0x6a09e667, 0xf3bcc908);
|
||||
ctx->state[1] = u64hilo (0xbb67ae85, 0x84caa73b);
|
||||
ctx->state[2] = u64hilo (0x3c6ef372, 0xfe94f82b);
|
||||
ctx->state[3] = u64hilo (0xa54ff53a, 0x5f1d36f1);
|
||||
ctx->state[4] = u64hilo (0x510e527f, 0xade682d1);
|
||||
ctx->state[5] = u64hilo (0x9b05688c, 0x2b3e6c1f);
|
||||
ctx->state[6] = u64hilo (0x1f83d9ab, 0xfb41bd6b);
|
||||
ctx->state[7] = u64hilo (0x5be0cd19, 0x137e2179);
|
||||
|
||||
ctx->total[0] = ctx->total[1] = u64lo (0);
|
||||
ctx->buflen = 0;
|
||||
}
|
||||
|
||||
void
|
||||
sha384_init_ctx (struct sha512_ctx *ctx)
|
||||
{
|
||||
ctx->state[0] = u64hilo (0xcbbb9d5d, 0xc1059ed8);
|
||||
ctx->state[1] = u64hilo (0x629a292a, 0x367cd507);
|
||||
ctx->state[2] = u64hilo (0x9159015a, 0x3070dd17);
|
||||
ctx->state[3] = u64hilo (0x152fecd8, 0xf70e5939);
|
||||
ctx->state[4] = u64hilo (0x67332667, 0xffc00b31);
|
||||
ctx->state[5] = u64hilo (0x8eb44a87, 0x68581511);
|
||||
ctx->state[6] = u64hilo (0xdb0c2e0d, 0x64f98fa7);
|
||||
ctx->state[7] = u64hilo (0x47b5481d, 0xbefa4fa4);
|
||||
|
||||
ctx->total[0] = ctx->total[1] = u64lo (0);
|
||||
ctx->buflen = 0;
|
||||
}
|
||||
|
||||
/* Put result from CTX in first 64 bytes following RESBUF. The result
|
||||
must be in little endian byte order.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 64-bit value. */
|
||||
void *
|
||||
sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
((u64 *) resbuf)[i] = SWAP (ctx->state[i]);
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
|
||||
void *
|
||||
sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
((u64 *) resbuf)[i] = SWAP (ctx->state[i]);
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
|
||||
/* Process the remaining bytes in the internal buffer and the usual
|
||||
prolog according to the standard and write the result to RESBUF.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 64-bit value. */
|
||||
static void
|
||||
sha512_conclude_ctx (struct sha512_ctx *ctx)
|
||||
{
|
||||
/* Take yet unprocessed bytes into account. */
|
||||
size_t bytes = ctx->buflen;
|
||||
size_t size = (bytes < 112) ? 128 / 8 : 128 * 2 / 8;
|
||||
|
||||
/* Now count remaining bytes. */
|
||||
ctx->total[0] = u64plus (ctx->total[0], u64lo (bytes));
|
||||
if (u64lt (ctx->total[0], u64lo (bytes)))
|
||||
ctx->total[1] = u64plus (ctx->total[1], u64lo (1));
|
||||
|
||||
/* Put the 64-bit file length in *bits* at the end of the buffer. */
|
||||
ctx->buffer[size - 2] = SWAP (u64or (u64shl (ctx->total[1], 3),
|
||||
u64shr (ctx->total[0], 61)));
|
||||
ctx->buffer[size - 1] = SWAP (u64shl (ctx->total[0], 3));
|
||||
|
||||
memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 8 - bytes);
|
||||
|
||||
/* Process last bytes. */
|
||||
sha512_process_block (ctx->buffer, size * 8, ctx);
|
||||
}
|
||||
|
||||
void *
|
||||
sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
|
||||
{
|
||||
sha512_conclude_ctx (ctx);
|
||||
return sha512_read_ctx (ctx, resbuf);
|
||||
}
|
||||
|
||||
void *
|
||||
sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
|
||||
{
|
||||
sha512_conclude_ctx (ctx);
|
||||
return sha384_read_ctx (ctx, resbuf);
|
||||
}
|
||||
|
||||
/* Compute SHA512 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 64 bytes
|
||||
beginning at RESBLOCK. */
|
||||
int
|
||||
sha512_stream (FILE *stream, void *resblock)
|
||||
{
|
||||
struct sha512_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha512_init_ctx (&ctx);
|
||||
|
||||
/* Iterate over full file contents. */
|
||||
while (1)
|
||||
{
|
||||
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
|
||||
computation function processes the whole buffer so that with the
|
||||
next round of the loop another block can be read. */
|
||||
size_t n;
|
||||
sum = 0;
|
||||
|
||||
/* Read block. Take care for partial reads. */
|
||||
while (1)
|
||||
{
|
||||
n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
|
||||
|
||||
sum += n;
|
||||
|
||||
if (sum == BLOCKSIZE)
|
||||
break;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
/* Check for the error flag IFF N == 0, so that we don't
|
||||
exit the loop after a partial read due to e.g., EAGAIN
|
||||
or EWOULDBLOCK. */
|
||||
if (ferror (stream))
|
||||
return 1;
|
||||
goto process_partial_block;
|
||||
}
|
||||
|
||||
/* We've read at least one byte, so ignore errors. But always
|
||||
check for EOF, since feof may be true even though N > 0.
|
||||
Otherwise, we could end up calling fread after EOF. */
|
||||
if (feof (stream))
|
||||
goto process_partial_block;
|
||||
}
|
||||
|
||||
/* Process buffer with BLOCKSIZE bytes. Note that
|
||||
BLOCKSIZE % 128 == 0
|
||||
*/
|
||||
sha512_process_block (buffer, BLOCKSIZE, &ctx);
|
||||
}
|
||||
|
||||
process_partial_block:;
|
||||
|
||||
/* Process any remaining bytes. */
|
||||
if (sum > 0)
|
||||
sha512_process_bytes (buffer, sum, &ctx);
|
||||
|
||||
/* Construct result in desired memory. */
|
||||
sha512_finish_ctx (&ctx, resblock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: Avoid code duplication */
|
||||
int
|
||||
sha384_stream (FILE *stream, void *resblock)
|
||||
{
|
||||
struct sha512_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha384_init_ctx (&ctx);
|
||||
|
||||
/* Iterate over full file contents. */
|
||||
while (1)
|
||||
{
|
||||
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
|
||||
computation function processes the whole buffer so that with the
|
||||
next round of the loop another block can be read. */
|
||||
size_t n;
|
||||
sum = 0;
|
||||
|
||||
/* Read block. Take care for partial reads. */
|
||||
while (1)
|
||||
{
|
||||
n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
|
||||
|
||||
sum += n;
|
||||
|
||||
if (sum == BLOCKSIZE)
|
||||
break;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
/* Check for the error flag IFF N == 0, so that we don't
|
||||
exit the loop after a partial read due to e.g., EAGAIN
|
||||
or EWOULDBLOCK. */
|
||||
if (ferror (stream))
|
||||
return 1;
|
||||
goto process_partial_block;
|
||||
}
|
||||
|
||||
/* We've read at least one byte, so ignore errors. But always
|
||||
check for EOF, since feof may be true even though N > 0.
|
||||
Otherwise, we could end up calling fread after EOF. */
|
||||
if (feof (stream))
|
||||
goto process_partial_block;
|
||||
}
|
||||
|
||||
/* Process buffer with BLOCKSIZE bytes. Note that
|
||||
BLOCKSIZE % 128 == 0
|
||||
*/
|
||||
sha512_process_block (buffer, BLOCKSIZE, &ctx);
|
||||
}
|
||||
|
||||
process_partial_block:;
|
||||
|
||||
/* Process any remaining bytes. */
|
||||
if (sum > 0)
|
||||
sha512_process_bytes (buffer, sum, &ctx);
|
||||
|
||||
/* Construct result in desired memory. */
|
||||
sha384_finish_ctx (&ctx, resblock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compute SHA512 message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
void *
|
||||
sha512_buffer (const char *buffer, size_t len, void *resblock)
|
||||
{
|
||||
struct sha512_ctx ctx;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha512_init_ctx (&ctx);
|
||||
|
||||
/* Process whole buffer but last len % 128 bytes. */
|
||||
sha512_process_bytes (buffer, len, &ctx);
|
||||
|
||||
/* Put result in desired memory area. */
|
||||
return sha512_finish_ctx (&ctx, resblock);
|
||||
}
|
||||
|
||||
void *
|
||||
sha384_buffer (const char *buffer, size_t len, void *resblock)
|
||||
{
|
||||
struct sha512_ctx ctx;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha384_init_ctx (&ctx);
|
||||
|
||||
/* Process whole buffer but last len % 128 bytes. */
|
||||
sha512_process_bytes (buffer, len, &ctx);
|
||||
|
||||
/* Put result in desired memory area. */
|
||||
return sha384_finish_ctx (&ctx, resblock);
|
||||
}
|
||||
|
||||
void
|
||||
sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx)
|
||||
{
|
||||
/* When we already have some bits in our internal buffer concatenate
|
||||
both inputs first. */
|
||||
if (ctx->buflen != 0)
|
||||
{
|
||||
size_t left_over = ctx->buflen;
|
||||
size_t add = 256 - left_over > len ? len : 256 - left_over;
|
||||
|
||||
memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
|
||||
ctx->buflen += add;
|
||||
|
||||
if (ctx->buflen > 128)
|
||||
{
|
||||
sha512_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
|
||||
|
||||
ctx->buflen &= 127;
|
||||
/* The regions in the following copy operation cannot overlap. */
|
||||
memcpy (ctx->buffer,
|
||||
&((char *) ctx->buffer)[(left_over + add) & ~127],
|
||||
ctx->buflen);
|
||||
}
|
||||
|
||||
buffer = (const char *) buffer + add;
|
||||
len -= add;
|
||||
}
|
||||
|
||||
/* Process available complete blocks. */
|
||||
if (len >= 128)
|
||||
{
|
||||
#if !_STRING_ARCH_unaligned
|
||||
# define alignof(type) offsetof (struct { char c; type x; }, x)
|
||||
# define UNALIGNED_P(p) (((size_t) p) % alignof (u64) != 0)
|
||||
if (UNALIGNED_P (buffer))
|
||||
while (len > 128)
|
||||
{
|
||||
sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128, ctx);
|
||||
buffer = (const char *) buffer + 128;
|
||||
len -= 128;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sha512_process_block (buffer, len & ~127, ctx);
|
||||
buffer = (const char *) buffer + (len & ~127);
|
||||
len &= 127;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move remaining bytes in internal buffer. */
|
||||
if (len > 0)
|
||||
{
|
||||
size_t left_over = ctx->buflen;
|
||||
|
||||
memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
|
||||
left_over += len;
|
||||
if (left_over >= 128)
|
||||
{
|
||||
sha512_process_block (ctx->buffer, 128, ctx);
|
||||
left_over -= 128;
|
||||
memcpy (ctx->buffer, &ctx->buffer[16], left_over);
|
||||
}
|
||||
ctx->buflen = left_over;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Code below is the primary difference between sha1.c and sha512.c --- */
|
||||
|
||||
/* SHA512 round constants */
|
||||
#define K(I) sha512_round_constants[I]
|
||||
static u64 const sha512_round_constants[80] = {
|
||||
u64init (0x428a2f98, 0xd728ae22), u64init (0x71374491, 0x23ef65cd),
|
||||
u64init (0xb5c0fbcf, 0xec4d3b2f), u64init (0xe9b5dba5, 0x8189dbbc),
|
||||
u64init (0x3956c25b, 0xf348b538), u64init (0x59f111f1, 0xb605d019),
|
||||
u64init (0x923f82a4, 0xaf194f9b), u64init (0xab1c5ed5, 0xda6d8118),
|
||||
u64init (0xd807aa98, 0xa3030242), u64init (0x12835b01, 0x45706fbe),
|
||||
u64init (0x243185be, 0x4ee4b28c), u64init (0x550c7dc3, 0xd5ffb4e2),
|
||||
u64init (0x72be5d74, 0xf27b896f), u64init (0x80deb1fe, 0x3b1696b1),
|
||||
u64init (0x9bdc06a7, 0x25c71235), u64init (0xc19bf174, 0xcf692694),
|
||||
u64init (0xe49b69c1, 0x9ef14ad2), u64init (0xefbe4786, 0x384f25e3),
|
||||
u64init (0x0fc19dc6, 0x8b8cd5b5), u64init (0x240ca1cc, 0x77ac9c65),
|
||||
u64init (0x2de92c6f, 0x592b0275), u64init (0x4a7484aa, 0x6ea6e483),
|
||||
u64init (0x5cb0a9dc, 0xbd41fbd4), u64init (0x76f988da, 0x831153b5),
|
||||
u64init (0x983e5152, 0xee66dfab), u64init (0xa831c66d, 0x2db43210),
|
||||
u64init (0xb00327c8, 0x98fb213f), u64init (0xbf597fc7, 0xbeef0ee4),
|
||||
u64init (0xc6e00bf3, 0x3da88fc2), u64init (0xd5a79147, 0x930aa725),
|
||||
u64init (0x06ca6351, 0xe003826f), u64init (0x14292967, 0x0a0e6e70),
|
||||
u64init (0x27b70a85, 0x46d22ffc), u64init (0x2e1b2138, 0x5c26c926),
|
||||
u64init (0x4d2c6dfc, 0x5ac42aed), u64init (0x53380d13, 0x9d95b3df),
|
||||
u64init (0x650a7354, 0x8baf63de), u64init (0x766a0abb, 0x3c77b2a8),
|
||||
u64init (0x81c2c92e, 0x47edaee6), u64init (0x92722c85, 0x1482353b),
|
||||
u64init (0xa2bfe8a1, 0x4cf10364), u64init (0xa81a664b, 0xbc423001),
|
||||
u64init (0xc24b8b70, 0xd0f89791), u64init (0xc76c51a3, 0x0654be30),
|
||||
u64init (0xd192e819, 0xd6ef5218), u64init (0xd6990624, 0x5565a910),
|
||||
u64init (0xf40e3585, 0x5771202a), u64init (0x106aa070, 0x32bbd1b8),
|
||||
u64init (0x19a4c116, 0xb8d2d0c8), u64init (0x1e376c08, 0x5141ab53),
|
||||
u64init (0x2748774c, 0xdf8eeb99), u64init (0x34b0bcb5, 0xe19b48a8),
|
||||
u64init (0x391c0cb3, 0xc5c95a63), u64init (0x4ed8aa4a, 0xe3418acb),
|
||||
u64init (0x5b9cca4f, 0x7763e373), u64init (0x682e6ff3, 0xd6b2b8a3),
|
||||
u64init (0x748f82ee, 0x5defb2fc), u64init (0x78a5636f, 0x43172f60),
|
||||
u64init (0x84c87814, 0xa1f0ab72), u64init (0x8cc70208, 0x1a6439ec),
|
||||
u64init (0x90befffa, 0x23631e28), u64init (0xa4506ceb, 0xde82bde9),
|
||||
u64init (0xbef9a3f7, 0xb2c67915), u64init (0xc67178f2, 0xe372532b),
|
||||
u64init (0xca273ece, 0xea26619c), u64init (0xd186b8c7, 0x21c0c207),
|
||||
u64init (0xeada7dd6, 0xcde0eb1e), u64init (0xf57d4f7f, 0xee6ed178),
|
||||
u64init (0x06f067aa, 0x72176fba), u64init (0x0a637dc5, 0xa2c898a6),
|
||||
u64init (0x113f9804, 0xbef90dae), u64init (0x1b710b35, 0x131c471b),
|
||||
u64init (0x28db77f5, 0x23047d84), u64init (0x32caab7b, 0x40c72493),
|
||||
u64init (0x3c9ebe0a, 0x15c9bebc), u64init (0x431d67c4, 0x9c100d4c),
|
||||
u64init (0x4cc5d4be, 0xcb3e42b6), u64init (0x597f299c, 0xfc657e2a),
|
||||
u64init (0x5fcb6fab, 0x3ad6faec), u64init (0x6c44198c, 0x4a475817),
|
||||
};
|
||||
|
||||
/* Round functions. */
|
||||
#define F2(A, B, C) u64or (u64and (A, B), u64and (C, u64or (A, B)))
|
||||
#define F1(E, F, G) u64xor (G, u64and (E, u64xor (F, G)))
|
||||
|
||||
/* Process LEN bytes of BUFFER, accumulating context into CTX.
|
||||
It is assumed that LEN % 128 == 0.
|
||||
Most of this code comes from GnuPG's cipher/sha1.c. */
|
||||
|
||||
void
|
||||
sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
|
||||
{
|
||||
u64 const *words = buffer;
|
||||
u64 const *endp = words + len / sizeof (u64);
|
||||
u64 x[16];
|
||||
u64 a = ctx->state[0];
|
||||
u64 b = ctx->state[1];
|
||||
u64 c = ctx->state[2];
|
||||
u64 d = ctx->state[3];
|
||||
u64 e = ctx->state[4];
|
||||
u64 f = ctx->state[5];
|
||||
u64 g = ctx->state[6];
|
||||
u64 h = ctx->state[7];
|
||||
|
||||
/* First increment the byte count. FIPS PUB 180-2 specifies the possible
|
||||
length of the file up to 2^128 bits. Here we only compute the
|
||||
number of bytes. Do a double word increment. */
|
||||
ctx->total[0] = u64plus (ctx->total[0], u64lo (len));
|
||||
if (u64lt (ctx->total[0], u64lo (len)))
|
||||
ctx->total[1] = u64plus (ctx->total[1], u64lo (1));
|
||||
|
||||
#define S0(x) u64xor (u64rol(x, 63), u64xor (u64rol (x, 56), u64shr (x, 7)))
|
||||
#define S1(x) u64xor (u64rol (x, 45), u64xor (u64rol (x, 3), u64shr (x, 6)))
|
||||
#define SS0(x) u64xor (u64rol (x, 36), u64xor (u64rol (x, 30), u64rol (x, 25)))
|
||||
#define SS1(x) u64xor (u64rol(x, 50), u64xor (u64rol (x, 46), u64rol (x, 23)))
|
||||
|
||||
#define M(I) (x[(I) & 15] \
|
||||
= u64plus (x[(I) & 15], \
|
||||
u64plus (S1 (x[((I) - 2) & 15]), \
|
||||
u64plus (x[((I) - 7) & 15], \
|
||||
S0 (x[((I) - 15) & 15])))))
|
||||
|
||||
#define R(A, B, C, D, E, F, G, H, K, M) \
|
||||
do \
|
||||
{ \
|
||||
u64 t0 = u64plus (SS0 (A), F2 (A, B, C)); \
|
||||
u64 t1 = \
|
||||
u64plus (H, u64plus (SS1 (E), \
|
||||
u64plus (F1 (E, F, G), u64plus (K, M)))); \
|
||||
D = u64plus (D, t1); \
|
||||
H = u64plus (t0, t1); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
while (words < endp)
|
||||
{
|
||||
int t;
|
||||
/* FIXME: see sha1.c for a better implementation. */
|
||||
for (t = 0; t < 16; t++)
|
||||
{
|
||||
x[t] = SWAP (*words);
|
||||
words++;
|
||||
}
|
||||
|
||||
R( a, b, c, d, e, f, g, h, K( 0), x[ 0] );
|
||||
R( h, a, b, c, d, e, f, g, K( 1), x[ 1] );
|
||||
R( g, h, a, b, c, d, e, f, K( 2), x[ 2] );
|
||||
R( f, g, h, a, b, c, d, e, K( 3), x[ 3] );
|
||||
R( e, f, g, h, a, b, c, d, K( 4), x[ 4] );
|
||||
R( d, e, f, g, h, a, b, c, K( 5), x[ 5] );
|
||||
R( c, d, e, f, g, h, a, b, K( 6), x[ 6] );
|
||||
R( b, c, d, e, f, g, h, a, K( 7), x[ 7] );
|
||||
R( a, b, c, d, e, f, g, h, K( 8), x[ 8] );
|
||||
R( h, a, b, c, d, e, f, g, K( 9), x[ 9] );
|
||||
R( g, h, a, b, c, d, e, f, K(10), x[10] );
|
||||
R( f, g, h, a, b, c, d, e, K(11), x[11] );
|
||||
R( e, f, g, h, a, b, c, d, K(12), x[12] );
|
||||
R( d, e, f, g, h, a, b, c, K(13), x[13] );
|
||||
R( c, d, e, f, g, h, a, b, K(14), x[14] );
|
||||
R( b, c, d, e, f, g, h, a, K(15), x[15] );
|
||||
R( a, b, c, d, e, f, g, h, K(16), M(16) );
|
||||
R( h, a, b, c, d, e, f, g, K(17), M(17) );
|
||||
R( g, h, a, b, c, d, e, f, K(18), M(18) );
|
||||
R( f, g, h, a, b, c, d, e, K(19), M(19) );
|
||||
R( e, f, g, h, a, b, c, d, K(20), M(20) );
|
||||
R( d, e, f, g, h, a, b, c, K(21), M(21) );
|
||||
R( c, d, e, f, g, h, a, b, K(22), M(22) );
|
||||
R( b, c, d, e, f, g, h, a, K(23), M(23) );
|
||||
R( a, b, c, d, e, f, g, h, K(24), M(24) );
|
||||
R( h, a, b, c, d, e, f, g, K(25), M(25) );
|
||||
R( g, h, a, b, c, d, e, f, K(26), M(26) );
|
||||
R( f, g, h, a, b, c, d, e, K(27), M(27) );
|
||||
R( e, f, g, h, a, b, c, d, K(28), M(28) );
|
||||
R( d, e, f, g, h, a, b, c, K(29), M(29) );
|
||||
R( c, d, e, f, g, h, a, b, K(30), M(30) );
|
||||
R( b, c, d, e, f, g, h, a, K(31), M(31) );
|
||||
R( a, b, c, d, e, f, g, h, K(32), M(32) );
|
||||
R( h, a, b, c, d, e, f, g, K(33), M(33) );
|
||||
R( g, h, a, b, c, d, e, f, K(34), M(34) );
|
||||
R( f, g, h, a, b, c, d, e, K(35), M(35) );
|
||||
R( e, f, g, h, a, b, c, d, K(36), M(36) );
|
||||
R( d, e, f, g, h, a, b, c, K(37), M(37) );
|
||||
R( c, d, e, f, g, h, a, b, K(38), M(38) );
|
||||
R( b, c, d, e, f, g, h, a, K(39), M(39) );
|
||||
R( a, b, c, d, e, f, g, h, K(40), M(40) );
|
||||
R( h, a, b, c, d, e, f, g, K(41), M(41) );
|
||||
R( g, h, a, b, c, d, e, f, K(42), M(42) );
|
||||
R( f, g, h, a, b, c, d, e, K(43), M(43) );
|
||||
R( e, f, g, h, a, b, c, d, K(44), M(44) );
|
||||
R( d, e, f, g, h, a, b, c, K(45), M(45) );
|
||||
R( c, d, e, f, g, h, a, b, K(46), M(46) );
|
||||
R( b, c, d, e, f, g, h, a, K(47), M(47) );
|
||||
R( a, b, c, d, e, f, g, h, K(48), M(48) );
|
||||
R( h, a, b, c, d, e, f, g, K(49), M(49) );
|
||||
R( g, h, a, b, c, d, e, f, K(50), M(50) );
|
||||
R( f, g, h, a, b, c, d, e, K(51), M(51) );
|
||||
R( e, f, g, h, a, b, c, d, K(52), M(52) );
|
||||
R( d, e, f, g, h, a, b, c, K(53), M(53) );
|
||||
R( c, d, e, f, g, h, a, b, K(54), M(54) );
|
||||
R( b, c, d, e, f, g, h, a, K(55), M(55) );
|
||||
R( a, b, c, d, e, f, g, h, K(56), M(56) );
|
||||
R( h, a, b, c, d, e, f, g, K(57), M(57) );
|
||||
R( g, h, a, b, c, d, e, f, K(58), M(58) );
|
||||
R( f, g, h, a, b, c, d, e, K(59), M(59) );
|
||||
R( e, f, g, h, a, b, c, d, K(60), M(60) );
|
||||
R( d, e, f, g, h, a, b, c, K(61), M(61) );
|
||||
R( c, d, e, f, g, h, a, b, K(62), M(62) );
|
||||
R( b, c, d, e, f, g, h, a, K(63), M(63) );
|
||||
R( a, b, c, d, e, f, g, h, K(64), M(64) );
|
||||
R( h, a, b, c, d, e, f, g, K(65), M(65) );
|
||||
R( g, h, a, b, c, d, e, f, K(66), M(66) );
|
||||
R( f, g, h, a, b, c, d, e, K(67), M(67) );
|
||||
R( e, f, g, h, a, b, c, d, K(68), M(68) );
|
||||
R( d, e, f, g, h, a, b, c, K(69), M(69) );
|
||||
R( c, d, e, f, g, h, a, b, K(70), M(70) );
|
||||
R( b, c, d, e, f, g, h, a, K(71), M(71) );
|
||||
R( a, b, c, d, e, f, g, h, K(72), M(72) );
|
||||
R( h, a, b, c, d, e, f, g, K(73), M(73) );
|
||||
R( g, h, a, b, c, d, e, f, K(74), M(74) );
|
||||
R( f, g, h, a, b, c, d, e, K(75), M(75) );
|
||||
R( e, f, g, h, a, b, c, d, K(76), M(76) );
|
||||
R( d, e, f, g, h, a, b, c, K(77), M(77) );
|
||||
R( c, d, e, f, g, h, a, b, K(78), M(78) );
|
||||
R( b, c, d, e, f, g, h, a, K(79), M(79) );
|
||||
|
||||
a = ctx->state[0] = u64plus (ctx->state[0], a);
|
||||
b = ctx->state[1] = u64plus (ctx->state[1], b);
|
||||
c = ctx->state[2] = u64plus (ctx->state[2], c);
|
||||
d = ctx->state[3] = u64plus (ctx->state[3], d);
|
||||
e = ctx->state[4] = u64plus (ctx->state[4], e);
|
||||
f = ctx->state[5] = u64plus (ctx->state[5], f);
|
||||
g = ctx->state[6] = u64plus (ctx->state[6], g);
|
||||
h = ctx->state[7] = u64plus (ctx->state[7], h);
|
||||
}
|
||||
}
|
||||
88
lib/sha512.h
88
lib/sha512.h
@@ -1,88 +0,0 @@
|
||||
/* Declarations of functions and data types used for SHA512 and SHA384 sum
|
||||
library functions.
|
||||
Copyright (C) 2005, 2006 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/>. */
|
||||
|
||||
#ifndef SHA512_H
|
||||
# define SHA512_H 1
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
# include "u64.h"
|
||||
|
||||
/* Structure to save state of computation between the single steps. */
|
||||
struct sha512_ctx
|
||||
{
|
||||
u64 state[8];
|
||||
|
||||
u64 total[2];
|
||||
size_t buflen;
|
||||
u64 buffer[32];
|
||||
};
|
||||
|
||||
|
||||
/* Initialize structure containing state of computation. */
|
||||
extern void sha512_init_ctx (struct sha512_ctx *ctx);
|
||||
extern void sha384_init_ctx (struct sha512_ctx *ctx);
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is necessary that LEN is a multiple of 128!!! */
|
||||
extern void sha512_process_block (const void *buffer, size_t len,
|
||||
struct sha512_ctx *ctx);
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is NOT required that LEN is a multiple of 128. */
|
||||
extern void sha512_process_bytes (const void *buffer, size_t len,
|
||||
struct sha512_ctx *ctx);
|
||||
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
in first 64 (48) bytes following RESBUF. The result is always in little
|
||||
endian byte order, so that a byte-wise output yields to the wanted
|
||||
ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF be correctly
|
||||
aligned for a 64 bits value. */
|
||||
extern void *sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf);
|
||||
extern void *sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf);
|
||||
|
||||
|
||||
/* Put result from CTX in first 64 (48) bytes following RESBUF. The result is
|
||||
always in little endian byte order, so that a byte-wise output yields
|
||||
to the wanted ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf);
|
||||
extern void *sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf);
|
||||
|
||||
|
||||
/* Compute SHA512 (SHA384) message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 64 (48) bytes
|
||||
beginning at RESBLOCK. */
|
||||
extern int sha512_stream (FILE *stream, void *resblock);
|
||||
extern int sha384_stream (FILE *stream, void *resblock);
|
||||
|
||||
/* Compute SHA512 (SHA384) message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
extern void *sha512_buffer (const char *buffer, size_t len, void *resblock);
|
||||
extern void *sha384_buffer (const char *buffer, size_t len, void *resblock);
|
||||
|
||||
#endif
|
||||
159
lib/u64.h
159
lib/u64.h
@@ -1,159 +0,0 @@
|
||||
/* uint64_t-like operations that work even on hosts lacking uint64_t
|
||||
|
||||
Copyright (C) 2006 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 Paul Eggert. */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Return X rotated left by N bits, where 0 < N < 64. */
|
||||
#define u64rol(x, n) u64or (u64shl (x, n), u64shr (x, 64 - n))
|
||||
|
||||
#ifdef UINT64_MAX
|
||||
|
||||
/* Native implementations are trivial. See below for comments on what
|
||||
these operations do. */
|
||||
typedef uint64_t u64;
|
||||
# define u64hilo(hi, lo) ((u64) (((u64) (hi) << 32) + (lo)))
|
||||
# define u64init(hi, lo) u64hilo (hi, lo)
|
||||
# define u64lo(x) ((u64) (x))
|
||||
# define u64lt(x, y) ((x) < (y))
|
||||
# define u64and(x, y) ((x) & (y))
|
||||
# define u64or(x, y) ((x) | (y))
|
||||
# define u64xor(x, y) ((x) ^ (y))
|
||||
# define u64plus(x, y) ((x) + (y))
|
||||
# define u64shl(x, n) ((x) << (n))
|
||||
# define u64shr(x, n) ((x) >> (n))
|
||||
|
||||
#else
|
||||
|
||||
/* u64 is a 64-bit unsigned integer value.
|
||||
u64init (HI, LO), is like u64hilo (HI, LO), but for use in
|
||||
initializer contexts. */
|
||||
# ifdef WORDS_BIGENDIAN
|
||||
typedef struct { uint32_t hi, lo; } u64;
|
||||
# define u64init(hi, lo) { hi, lo }
|
||||
# else
|
||||
typedef struct { uint32_t lo, hi; } u64;
|
||||
# define u64init(hi, lo) { lo, hi }
|
||||
# endif
|
||||
|
||||
/* Given the high and low-order 32-bit quantities HI and LO, return a u64
|
||||
value representing (HI << 32) + LO. */
|
||||
static inline u64
|
||||
u64hilo (uint32_t hi, uint32_t lo)
|
||||
{
|
||||
u64 r;
|
||||
r.hi = hi;
|
||||
r.lo = lo;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Return a u64 value representing LO. */
|
||||
static inline u64
|
||||
u64lo (uint32_t lo)
|
||||
{
|
||||
u64 r;
|
||||
r.hi = 0;
|
||||
r.lo = lo;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Return X < Y. */
|
||||
static inline int
|
||||
u64lt (u64 x, u64 y)
|
||||
{
|
||||
return x.hi < y.hi || (x.hi == y.hi && x.lo < y.lo);
|
||||
}
|
||||
|
||||
/* Return X & Y. */
|
||||
static inline u64
|
||||
u64and (u64 x, u64 y)
|
||||
{
|
||||
u64 r;
|
||||
r.hi = x.hi & y.hi;
|
||||
r.lo = x.lo & y.lo;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Return X | Y. */
|
||||
static inline u64
|
||||
u64or (u64 x, u64 y)
|
||||
{
|
||||
u64 r;
|
||||
r.hi = x.hi | y.hi;
|
||||
r.lo = x.lo | y.lo;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Return X ^ Y. */
|
||||
static inline u64
|
||||
u64xor (u64 x, u64 y)
|
||||
{
|
||||
u64 r;
|
||||
r.hi = x.hi ^ y.hi;
|
||||
r.lo = x.lo ^ y.lo;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Return X + Y. */
|
||||
static inline u64
|
||||
u64plus (u64 x, u64 y)
|
||||
{
|
||||
u64 r;
|
||||
r.lo = x.lo + y.lo;
|
||||
r.hi = x.hi + y.hi + (r.lo < x.lo);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Return X << N. */
|
||||
static inline u64
|
||||
u64shl (u64 x, int n)
|
||||
{
|
||||
u64 r;
|
||||
if (n < 32)
|
||||
{
|
||||
r.hi = (x.hi << n) | (x.lo >> (32 - n));
|
||||
r.lo = x.lo << n;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.hi = x.lo << (n - 32);
|
||||
r.lo = 0;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Return X >> N. */
|
||||
static inline u64
|
||||
u64shr (u64 x, int n)
|
||||
{
|
||||
u64 r;
|
||||
if (n < 32)
|
||||
{
|
||||
r.hi = x.hi >> n;
|
||||
r.lo = (x.hi << (32 - n)) | (x.lo >> n);
|
||||
}
|
||||
else
|
||||
{
|
||||
r.hi = 0;
|
||||
r.lo = x.hi >> (n - 32);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -52,9 +52,9 @@ xmemxfrm (char *restrict dest, size_t destsize,
|
||||
if (errno)
|
||||
{
|
||||
error (0, errno, _("string transformation failed"));
|
||||
error (0, 0, _("Set LC_ALL='C' to work around the problem."));
|
||||
error (0, 0, _("set LC_ALL='C' to work around the problem"));
|
||||
error (exit_failure, 0,
|
||||
_("The untransformed string was %s."),
|
||||
_("the untransformed string was %s"),
|
||||
quotearg_n_style_mem (0, locale_quoting_style, src, srcsize));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2008-03-02 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
* prereq.m4: Don't require gl_SHA256 or gl_SHA512.
|
||||
|
||||
2007-08-30 Eric Blake <ebb9@byu.net>
|
||||
|
||||
* jm-macros.m4 (coreutils_MACROS): Remove GNU_PACKAGE.
|
||||
|
||||
36
m4/gmp.m4
Normal file
36
m4/gmp.m4
Normal file
@@ -0,0 +1,36 @@
|
||||
# Tests for GNU GMP (or any compatible replacement).
|
||||
|
||||
dnl Copyright (C) 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,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl Written by James Youngman.
|
||||
|
||||
dnl Check for libgmp. We avoid use of AC_CHECK_LIBS because we don't want to
|
||||
dnl add this to $LIBS for all targets.
|
||||
AC_DEFUN([cu_GMP],
|
||||
[
|
||||
LIB_GMP=
|
||||
AC_SUBST([LIB_GMP])
|
||||
|
||||
AC_ARG_WITH([gmp],
|
||||
AS_HELP_STRING([--without-gmp],
|
||||
[do not use the GNU MP library for arbitrary precision
|
||||
calculation (default: use it if available)]),
|
||||
[cu_use_gmp=$withval],
|
||||
[cu_use_gmp=auto])
|
||||
|
||||
if test $cu_use_gmp != no; then
|
||||
cu_saved_libs=$LIBS
|
||||
AC_SEARCH_LIBS([__gmpz_init], [gmp],
|
||||
[test "$ac_cv_search___gmpz_init" = "none required" ||
|
||||
{
|
||||
LIB_GMP=$ac_cv_search___gmpz_init
|
||||
AC_DEFINE([HAVE_GMP], 1,
|
||||
[Define if you have GNU libgmp (or replacement)])
|
||||
}])
|
||||
LIBS=$cu_saved_libs
|
||||
fi
|
||||
])
|
||||
@@ -1,8 +1,8 @@
|
||||
#serial 106 -*- autoconf -*-
|
||||
#serial 107 -*- autoconf -*-
|
||||
|
||||
dnl Misc type-related macros for coreutils.
|
||||
|
||||
# Copyright (C) 1998, 2000-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998, 2000-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
|
||||
@@ -46,6 +46,12 @@ AC_DEFUN([coreutils_MACROS],
|
||||
# used by shred
|
||||
AC_CHECK_FUNCS_ONCE(directio)
|
||||
|
||||
# Used by install.c.
|
||||
AC_CHECK_FUNCS_ONCE([matchpathcon_init_prefix])
|
||||
|
||||
# Used by sort.c.
|
||||
AC_CHECK_FUNCS_ONCE([nl_langinfo])
|
||||
|
||||
AC_CHECK_FUNCS_ONCE( \
|
||||
endgrent \
|
||||
endpwent \
|
||||
@@ -76,6 +82,19 @@ AC_DEFUN([coreutils_MACROS],
|
||||
AC_CHECK_FUNCS(fdatasync)
|
||||
LIBS=$coreutils_saved_libs
|
||||
|
||||
# Check whether libcap is usable -- for ls --color support
|
||||
AC_ARG_ENABLE([libcap],
|
||||
AC_HELP_STRING([--disable-libcap], [disable libcap support]),
|
||||
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])]
|
||||
)],
|
||||
[AC_MSG_WARN([libcap library was not found or not usable, support for libcap will not be built])])
|
||||
])
|
||||
AC_SUBST([LIB_CAP])
|
||||
|
||||
# See if linking `seq' requires -lm.
|
||||
# It does on nearly every system. The single exception (so far) is
|
||||
# BeOS which has all the math functions in the normal runtime library
|
||||
@@ -137,7 +156,6 @@ AC_DEFUN([gl_CHECK_ALL_TYPES],
|
||||
AC_REQUIRE([AC_C_BIGENDIAN])
|
||||
AC_REQUIRE([AC_C_VOLATILE])
|
||||
AC_REQUIRE([AC_C_INLINE])
|
||||
AC_REQUIRE([AC_C_LONG_DOUBLE])
|
||||
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
|
||||
|
||||
AC_REQUIRE([gl_CHECK_ALL_HEADERS])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 74
|
||||
#serial 75
|
||||
|
||||
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-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998, 2000, 2001, 2003-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
|
||||
@@ -40,8 +40,6 @@ AC_DEFUN([gl_PREREQ],
|
||||
AC_REQUIRE([gl_FD_REOPEN])
|
||||
AC_REQUIRE([gl_FUNC_XFTS])
|
||||
AC_REQUIRE([gl_MEMXFRM])
|
||||
AC_REQUIRE([gl_SHA256])
|
||||
AC_REQUIRE([gl_SHA512])
|
||||
AC_REQUIRE([gl_STRINTCMP])
|
||||
AC_REQUIRE([gl_STRNUMCMP])
|
||||
])
|
||||
|
||||
15
m4/sha256.m4
15
m4/sha256.m4
@@ -1,15 +0,0 @@
|
||||
# sha256.m4 serial 1
|
||||
dnl Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_SHA256],
|
||||
[
|
||||
AC_LIBSOURCES([sha256.c, sha256.h])
|
||||
AC_LIBOBJ([sha256])
|
||||
|
||||
dnl Prerequisites of lib/sha256.c.
|
||||
AC_REQUIRE([AC_C_BIGENDIAN])
|
||||
:
|
||||
])
|
||||
15
m4/sha512.m4
15
m4/sha512.m4
@@ -1,15 +0,0 @@
|
||||
# sha512.m4 serial 2
|
||||
dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_SHA512],
|
||||
[
|
||||
AC_LIBSOURCES([sha512.c, sha512.h, u64.h])
|
||||
AC_LIBOBJ([sha512])
|
||||
|
||||
dnl Prerequisites of lib/sha512.c.
|
||||
AC_REQUIRE([AC_C_BIGENDIAN])
|
||||
:
|
||||
])
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*-Makefile-*-
|
||||
# This Makefile fragment is shared between the coreutils,
|
||||
# CPPI, Bison, and Autoconf.
|
||||
# This Makefile fragment tries to be general-purpose enough to be
|
||||
# used by at least coreutils, idutils, CPPI, Bison, and Autoconf.
|
||||
|
||||
## Copyright (C) 2001-2007 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2001-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
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
# This is reported not to work with make-3.79.1
|
||||
# ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
ME := Makefile.maint
|
||||
ME := maint.mk
|
||||
|
||||
# Do not save the original name or timestamp in the .tar.gz file.
|
||||
# Use --rsyncable if available.
|
||||
@@ -27,22 +27,22 @@ gzip_rsyncable := \
|
||||
$(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null && echo --rsyncable)
|
||||
GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
|
||||
|
||||
CVS = cvs
|
||||
GIT = git
|
||||
VC = $(GIT)
|
||||
VC-tag = git-tag -s -m '$(VERSION)'
|
||||
VC-tag = git tag -s -m '$(VERSION)'
|
||||
|
||||
CVS_LIST = build-aux/vc-list-files
|
||||
VC_LIST = $(srcdir)/build-aux/vc-list-files
|
||||
|
||||
CVS_LIST_EXCEPT = \
|
||||
$(CVS_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi
|
||||
VC_LIST_EXCEPT = \
|
||||
$(VC_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi
|
||||
|
||||
ifeq ($(origin prev_version_file), undefined)
|
||||
prev_version_file = .prev-version
|
||||
prev_version_file = $(srcdir)/.prev-version
|
||||
endif
|
||||
|
||||
PREV_VERSION := $(shell cat $(prev_version_file))
|
||||
VERSION_REGEXP = $(subst .,\.,$(VERSION))
|
||||
PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION))
|
||||
|
||||
ifeq ($(VC),$(GIT))
|
||||
this-vc-tag = v$(VERSION)
|
||||
@@ -56,7 +56,6 @@ endif
|
||||
my_distdir = $(PACKAGE)-$(VERSION)
|
||||
|
||||
# Old releases are stored here.
|
||||
# Used for diffs and xdeltas.
|
||||
release_archive_dir ?= ../release
|
||||
|
||||
# Prevent programs like 'sort' from considering distinct strings to be equal.
|
||||
@@ -69,20 +68,14 @@ export LC_ALL = C
|
||||
## Sanity checks. ##
|
||||
## --------------- ##
|
||||
|
||||
# FIXME: add a check to prohibit definition in src/*.c of symbols defined
|
||||
# in system.h. E.g. today I removed from tail.c a useless definition of
|
||||
# ENOSYS. It was useless because system.h ensures it's defined.
|
||||
|
||||
# Collect the names of rules starting with `sc_'.
|
||||
syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
|
||||
syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
|
||||
$(srcdir)/$(ME))
|
||||
.PHONY: $(syntax-check-rules)
|
||||
|
||||
# Checks that don't require cvs.
|
||||
# Run `changelog-check' last, as previous test may reveal problems requiring
|
||||
# new ChangeLog entries.
|
||||
local-checks-available = \
|
||||
po-check copyright-check m4-check author_mark_check \
|
||||
changelog-check patch-check strftime-check $(syntax-check-rules) \
|
||||
patch-check strftime-check $(syntax-check-rules) \
|
||||
makefile_path_separator_check \
|
||||
makefile-check check-AUTHORS
|
||||
.PHONY: $(local-checks-available)
|
||||
@@ -101,23 +94,30 @@ syntax-check: $(local-check)
|
||||
# exit 1; } || :
|
||||
# FIXME: don't allow `#include .strings\.h' anywhere
|
||||
|
||||
sc_avoid_if_before_free:
|
||||
@$(srcdir)/build-aux/useless-if-before-free \
|
||||
$(useless_free_options) \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found useless "if" before "free" above' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_cast_of_argument_to_free:
|
||||
@grep -nE '\<free \(\(' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -nE '\<free *\( *\(' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_cast_of_x_alloc_return_value:
|
||||
@grep -nE '\*\) *x(m|c|re)alloc\>' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -nE '\*\) *x(m|c|re)alloc\>' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_cast_of_alloca_return_value:
|
||||
@grep -nE '\*\) *alloca\>' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -nE '\*\) *alloca\>' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): don'\''t cast alloca return value' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_space_tab:
|
||||
@grep -n '[ ] ' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -n '[ ] ' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
@@ -125,14 +125,14 @@ sc_space_tab:
|
||||
# They provide no error checking mechanism.
|
||||
# Instead, use strto* functions.
|
||||
sc_prohibit_atoi_atof:
|
||||
@grep -nE '\<([fs]?scanf|ato([filq]|ll))\>' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@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; } || :
|
||||
|
||||
# Use STREQ rather than comparing strcmp == 0, or != 0.
|
||||
sc_prohibit_strcmp:
|
||||
@grep -nE '! *str''cmp \(|\<str''cmp \([^)]+\) *==' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -nE '! *str''cmp *\(|\<str''cmp *\([^)]+\) *==' \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): use STREQ in place of the above uses of str''cmp' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
@@ -144,67 +144,116 @@ sc_error_exit_success:
|
||||
{ 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
|
||||
sc_error_message_warn_fatal:
|
||||
@grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
|
||||
| grep -E '"Warning|"Fatal|"fatal' && \
|
||||
{ echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Error messages should not start with a capital letter
|
||||
sc_error_message_uppercase:
|
||||
@grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
|
||||
| grep -E '"[A-Z]' \
|
||||
| grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
|
||||
{ echo '$(ME): found capitalized error message' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Error messages should not end with a period
|
||||
sc_error_message_period:
|
||||
@grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
|
||||
| grep -E '[^."]\."' && \
|
||||
{ echo '$(ME): found error message ending in period' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_file_system:
|
||||
@grep -ni 'file''system' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -ni 'file''system' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found use of "file''system";' \
|
||||
'rewrite to use "file system"' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Don't use cpp tests of this symbol. All code assumes config.h is included.
|
||||
sc_no_have_config_h:
|
||||
@grep -n 'HAVE''_CONFIG_H' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found use of HAVE''_CONFIG_H; remove' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Nearly all .c files must include <config.h>.
|
||||
sc_require_config_h:
|
||||
@if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
|
||||
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
|
||||
grep -L '^# *include <config\.h>' \
|
||||
$$($(CVS_LIST_EXCEPT) | grep '\.c$$') \
|
||||
$$($(VC_LIST_EXCEPT) | grep '\.c$$') \
|
||||
| grep . && \
|
||||
{ echo '$(ME): the above files do not include <config.h>' \
|
||||
1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
|
||||
# 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.
|
||||
define _header_without_use
|
||||
h_esc=`echo "$$h"|sed 's/\./\\./'`; \
|
||||
if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
|
||||
files=$$(grep -l '^# *include '"$$h_esc" \
|
||||
$$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \
|
||||
grep -LE "$$re" $$files | grep . && \
|
||||
{ echo "$(ME): the above files include $$h but don't use it" \
|
||||
1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
endef
|
||||
|
||||
# Prohibit the inclusion of assert.h without an actual use of assert.
|
||||
sc_prohibit_assert_without_use:
|
||||
@if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
|
||||
files=$$(grep -l '# *include <assert\.h>' \
|
||||
$$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \
|
||||
grep -L '\<assert (' $$files \
|
||||
| grep . && \
|
||||
{ echo "$(ME): the above files include <assert.h> but don't use it" \
|
||||
1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
@h='<assert.h>' re='\<assert *\(' $(_header_without_use)
|
||||
|
||||
# Prohibit the inclusion of getopt.h without an actual use.
|
||||
sc_prohibit_getopt_without_use:
|
||||
@h='<getopt.h>' re='\<getopt(_long)? *\(' $(_header_without_use)
|
||||
|
||||
# Don't include quotearg.h unless you use one of its functions.
|
||||
sc_prohibit_quotearg_without_use:
|
||||
@if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
|
||||
files=$$(grep -l '# *include "quotearg\.h"' \
|
||||
$$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \
|
||||
grep -LE '\<quotearg(_[^ ]+)? \(' $$files \
|
||||
| grep . && \
|
||||
{ echo "$(ME): the above files include "quotearg.h" but don't use it" \
|
||||
1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
@h='"quotearg.h"' re='\<quotearg(_[^ ]+)? *\(' $(_header_without_use)
|
||||
|
||||
# Don't include quote.h unless you use one of its functions.
|
||||
sc_prohibit_quote_without_use:
|
||||
@if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
|
||||
files=$$(grep -l '# *include "quote\.h"' \
|
||||
$$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \
|
||||
grep -LE '\<quote(_n)? \(' $$files \
|
||||
| grep . && \
|
||||
{ echo "$(ME): the above files include "quote.h" but don't use it" \
|
||||
1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
@h='"quote.h"' re='\<quote(_n)? *\(' $(_header_without_use)
|
||||
|
||||
# Don't include this header unless you use one of its functions.
|
||||
sc_prohibit_long_options_without_use:
|
||||
@h='"long-options.h"' re='\<parse_long_options *\(' \
|
||||
$(_header_without_use)
|
||||
|
||||
# Don't include this header unless you use one of its functions.
|
||||
sc_prohibit_inttostr_without_use:
|
||||
@h='"inttostr.h"' re='\<(off|[iu]max|uint)tostr *\(' \
|
||||
$(_header_without_use)
|
||||
|
||||
# Don't include this header unless you use one of its functions.
|
||||
sc_prohibit_error_without_use:
|
||||
@h='"error.h"' \
|
||||
re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
|
||||
$(_header_without_use)
|
||||
|
||||
sc_prohibit_safe_read_without_use:
|
||||
@h='"safe-read.h"' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
|
||||
$(_header_without_use)
|
||||
|
||||
sc_prohibit_argmatch_without_use:
|
||||
@h='"argmatch.h"' \
|
||||
re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<argmatch(_exit_fn|_(in)?valid) *\()' \
|
||||
$(_header_without_use)
|
||||
|
||||
sc_prohibit_root_dev_ino_without_use:
|
||||
@h='"root-dev-ino.h"' \
|
||||
re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
|
||||
$(_header_without_use)
|
||||
|
||||
sc_obsolete_symbols:
|
||||
@grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
@@ -237,19 +286,22 @@ endif
|
||||
# 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]' \
|
||||
$$($(CVS_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
|
||||
{ echo '$(ME): do not use jm_ in m4 macro names' \
|
||||
@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 '^PRIV_CHECK_ARG=require-root' \
|
||||
$$($(CVS_LIST) tests) |sed s,tests,., |sort > $$t1; \
|
||||
sed -n 's, cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
|
||||
$(srcdir)/tests/Makefile.am |sort > $$t2; \
|
||||
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" \
|
||||
@@ -286,7 +338,7 @@ headers_with_interesting_macro_defs = \
|
||||
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 $$($(CVS_LIST)) \
|
||||
grep -f .re-defmac $$($(VC_LIST)) \
|
||||
&& { echo '$(ME): define the above via some gnulib .h file' \
|
||||
1>&2; exit 1; } || :; \
|
||||
fi
|
||||
@@ -306,21 +358,49 @@ 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 \
|
||||
$$($(CVS_LIST) src | \
|
||||
$$($(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:
|
||||
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
|
||||
files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$')); \
|
||||
grep -LE 'set_program_name *\(m?argv\[0\]\);' $$files \
|
||||
| grep . && \
|
||||
{ echo '$(ME): the above files do not call set_program_name' \
|
||||
1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
|
||||
# Require that the final line of each test-lib.sh-using test be this one:
|
||||
# Exit $fail
|
||||
# Note: this test requires GNU grep's --label= option.
|
||||
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 \
|
||||
&& : || { 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'; \
|
||||
exit 1; } || :; \
|
||||
fi
|
||||
|
||||
sc_sun_os_names:
|
||||
@grep -nEi \
|
||||
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_the_the:
|
||||
@grep -ni '\<the ''the\>' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -ni '\<the ''the\>' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found use of "the ''the";' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
@@ -328,7 +408,7 @@ sc_tight_scope:
|
||||
$(MAKE) -C src $@
|
||||
|
||||
sc_trailing_blank:
|
||||
@grep -n '[ ]$$' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -n '[ ]$$' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found trailing blank(s)' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
@@ -338,7 +418,7 @@ sc_trailing_blank:
|
||||
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
|
||||
sc_two_space_separator_in_usage:
|
||||
@grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
$$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo "$(ME): help2man requires at least two spaces between"; \
|
||||
echo "$(ME): an option and its description"; \
|
||||
1>&2; exit 1; } || :
|
||||
@@ -347,7 +427,7 @@ sc_two_space_separator_in_usage:
|
||||
# This won't find any for which error's format string is on a separate line.
|
||||
sc_unmarked_diagnostics:
|
||||
@grep -nE \
|
||||
'\<error \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT)) \
|
||||
'\<error \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
|
||||
| grep -v '_''(' && \
|
||||
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
|
||||
exit 1; } || :
|
||||
@@ -355,24 +435,92 @@ sc_unmarked_diagnostics:
|
||||
# Avoid useless parentheses like those in this example:
|
||||
# #if defined (SYMBOL) || defined (SYM2)
|
||||
sc_useless_cpp_parens:
|
||||
@grep -n '^# *if .*defined *(' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -n '^# *if .*defined *(' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found useless parentheses in cpp directive' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Require the latest GPL.
|
||||
sc_GPL_version:
|
||||
@grep -n 'either ''version [^3]' $$($(CVS_LIST_EXCEPT)) && \
|
||||
@grep -n 'either ''version [^3]' $$($(VC_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || :
|
||||
|
||||
# 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
|
||||
|
||||
NEWS_hash = \
|
||||
$$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
|
||||
$(srcdir)/NEWS | md5sum -)
|
||||
|
||||
# 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
|
||||
|
||||
# Each program that uses proper_name_utf8 must link with
|
||||
# one of the ICONV libraries.
|
||||
sc_proper_name_utf8_requires_ICONV:
|
||||
@progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
|
||||
if test "x$$progs" != x; then \
|
||||
fail=0; \
|
||||
for p in $$progs; do \
|
||||
dir=$$(dirname "$$p"); \
|
||||
base=$$(basename "$$p" .c); \
|
||||
grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \
|
||||
|| { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
|
||||
done; \
|
||||
test $$fail = 1 && \
|
||||
{ echo 1>&2 '$(ME): the above do not link with any ICONV library'; \
|
||||
exit 1; } || :; \
|
||||
fi
|
||||
|
||||
# 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; } || :
|
||||
|
||||
sc_const_long_option:
|
||||
@grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
|
||||
| grep -Ev 'const struct option|struct option const' && { \
|
||||
echo 1>&2 '$(ME): add "const" to the above declarations'; \
|
||||
exit 1; } || :
|
||||
|
||||
# Update the hash stored above. Do this after each release and
|
||||
# for any corrections to old entries.
|
||||
update-NEWS-hash: NEWS
|
||||
perl -pi -e 's/^(old_NEWS_hash = ).*/$${1}'"$(NEWS_hash)/" \
|
||||
$(srcdir)/cfg.mk
|
||||
|
||||
epoch_date = 1970-01-01 00:00:00.000000000 +0000
|
||||
# Ensure that the c99-to-c89 patch applies cleanly.
|
||||
patch-check:
|
||||
rm -rf src-c89 $@.1 $@.2
|
||||
cp -a src src-c89
|
||||
(cd src-c89; patch -p1 -V never --fuzz=0) < src/c99-to-c89.diff \
|
||||
cp -a $(srcdir)/src src-c89
|
||||
if test "x$(srcdir)" != x.; then \
|
||||
cp -a src/* src-c89; \
|
||||
dotfiles=`ls src/.[!.]* 2>/dev/null`; \
|
||||
test -z "$$dotfiles" || cp -a src/.[!.]* src-c89; \
|
||||
fi
|
||||
(cd src-c89; patch -p1 -V never --fuzz=0) < $(srcdir)/src/c99-to-c89.diff \
|
||||
> $@.1 2>&1
|
||||
if test "$$REGEN_PATCH" = yes; then \
|
||||
diff -upr src src-c89 | sed 's,src-c89/,src/,' \
|
||||
| grep -v '^Only in' > new-diff || : ; fi
|
||||
if test "$(REGEN_PATCH)" = yes; then \
|
||||
diff -upr $(srcdir)/src src-c89 | sed 's,$(srcdir)/src-c89/,src/,' \
|
||||
| grep -vE '^(Only in|File )' \
|
||||
| perl -pe 's/^((?:\+\+\+|---) \S+\t).*/$${1}$(epoch_date)/;' \
|
||||
-e 's/^ $$//' \
|
||||
> new-diff || : ; fi
|
||||
grep -v '^patching file ' $@.1 > $@.2 || :
|
||||
msg=ok; test -s $@.2 && msg='fuzzy patch' || : ; \
|
||||
rm -f src-c89/*.o || msg='rm failed'; \
|
||||
@@ -402,9 +550,13 @@ check-AUTHORS:
|
||||
# Ensure that we use only the standard $(VAR) notation,
|
||||
# not @...@ in Makefile.am, now that we can rely on automake
|
||||
# to emit a definition for each substituted variable.
|
||||
# We use perl rather than "grep -nE ..." to exempt a single
|
||||
# use of an @...@-delimited variable name in src/Makefile.am.
|
||||
makefile-check:
|
||||
grep -nE '@[A-Z_0-9]+@' `find . -name Makefile.am` \
|
||||
&& { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
|
||||
@perl -ne '/\@[A-Z_0-9]+\@/ && !/^cu_install_program =/' \
|
||||
-e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
|
||||
$$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \
|
||||
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
|
||||
|
||||
news-date-check: NEWS
|
||||
today=`date +%Y-%m-%d`; \
|
||||
@@ -427,20 +579,19 @@ changelog-check:
|
||||
|
||||
m4-check:
|
||||
@grep -n 'AC_DEFUN([^[]' m4/*.m4 \
|
||||
&& { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
|
||||
&& { echo '$(ME): quote the first arg to AC_DEFUN' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Verify that all source files using _() are listed in po/POTFILES.in.
|
||||
# FIXME: don't hard-code file names below; use a more general mechanism.
|
||||
po-check:
|
||||
if test -f po/POTFILES.in; then \
|
||||
@if test -f po/POTFILES.in; then \
|
||||
grep -E -v '^(#|$$)' po/POTFILES.in \
|
||||
| grep -v '^src/false\.c$$' | sort > $@-1; \
|
||||
files=; \
|
||||
for file in $$($(CVS_LIST_EXCEPT)) lib/*.[ch]; do \
|
||||
for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do \
|
||||
case $$file in \
|
||||
djgpp/* | man/*) continue;; \
|
||||
*/c99-to-c89.diff) continue;; \
|
||||
*.?|*.??) ;; \
|
||||
*) continue;; \
|
||||
esac; \
|
||||
case $$file in \
|
||||
*.[ch]) \
|
||||
@@ -460,7 +611,7 @@ po-check:
|
||||
# gettext recognizes it as a string requiring translation.
|
||||
author_mark_check:
|
||||
@grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
|
||||
{ echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
|
||||
{ echo '$(ME): enclose the above strings in N_ (...)' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Sometimes it is useful to change the PATH environment variable
|
||||
@@ -469,7 +620,7 @@ author_mark_check:
|
||||
# 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 = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
|
||||
msg = '$(ME): Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
|
||||
makefile_path_separator_check:
|
||||
@grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
|
||||
&& { echo $(msg) 1>&2; exit 1; } || :
|
||||
@@ -477,16 +628,14 @@ makefile_path_separator_check:
|
||||
# Check that `make alpha' will not fail at the end of the process.
|
||||
writable-files:
|
||||
if test -d $(release_archive_dir); then :; else \
|
||||
mkdir $(release_archive_dir); \
|
||||
for file in $(distdir).tar.gz \
|
||||
$(release_archive_dir)/$(distdir).tar.gz; do \
|
||||
test -e $$file || continue; \
|
||||
test -w $$file \
|
||||
|| { echo ERROR: $$file is not writable; fail=1; }; \
|
||||
done; \
|
||||
test "$$fail" && exit 1 || : ; \
|
||||
fi
|
||||
for file in $(distdir).tar.gz $(xd-delta) \
|
||||
$(release_archive_dir)/$(distdir).tar.gz \
|
||||
$(release_archive_dir)/$(xd-delta); do \
|
||||
test -e $$file || continue; \
|
||||
test -w $$file \
|
||||
|| { echo ERROR: $$file is not writable; fail=1; }; \
|
||||
done; \
|
||||
test "$$fail" && exit 1 || :
|
||||
|
||||
v_etc_file = lib/version-etc.c
|
||||
sample-test = tests/sample-test
|
||||
@@ -527,6 +676,7 @@ cvs-check: vc-diff-check
|
||||
|
||||
maintainer-distcheck:
|
||||
$(MAKE) distcheck
|
||||
$(MAKE) taint-distcheck
|
||||
$(MAKE) my-distcheck
|
||||
|
||||
|
||||
@@ -551,21 +701,84 @@ bin=bin-$$$$
|
||||
|
||||
write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
|
||||
|
||||
TMPDIR ?= /tmp
|
||||
t=$(TMPDIR)/$(PACKAGE)/test
|
||||
pfx=$(t)/i
|
||||
|
||||
# More than once, tainted build and source directory names would
|
||||
# have caused at least one "make check" test to apply "chmod 700"
|
||||
# to all directories under $HOME. Make sure it doesn't happen again.
|
||||
tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$")
|
||||
t_prefix = $(tp)/a
|
||||
t_taint = '$(t_prefix) b'
|
||||
fake_home = $(tp)/home
|
||||
|
||||
# Ensure that tests run from tainted build and src dir names work,
|
||||
# and don't affect anything in $HOME. Create witness files in $HOME,
|
||||
# record their attributes, and build/test. Then ensure that the
|
||||
# witnesses were not affected.
|
||||
taint-distcheck: $(DIST_ARCHIVES)
|
||||
test -d $(t_taint) && chmod -R 700 $(t_taint) || :
|
||||
-rm -rf $(t_taint) $(fake_home)
|
||||
mkdir -p $(t_prefix) $(t_taint) $(fake_home)
|
||||
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t_taint) -zxf $(distdir).tar.gz
|
||||
mkfifo $(fake_home)/fifo
|
||||
touch $(fake_home)/f
|
||||
mkdir -p $(fake_home)/d/e
|
||||
ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
|
||||
cd $(t_taint)/$(distdir) \
|
||||
&& ./configure \
|
||||
&& $(MAKE) \
|
||||
&& HOME=$(fake_home) $(MAKE) check \
|
||||
&& ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
|
||||
&& diff $(tp)/.ls-before $(tp)/.ls-after \
|
||||
&& test -d $(t_prefix)
|
||||
rm -rf $(tp)
|
||||
|
||||
# Verify that a twisted use of --program-transform-name=PROGRAM works.
|
||||
define 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"
|
||||
endef
|
||||
|
||||
# Install, then verify that all binaries and man pages are in place.
|
||||
# Note that neither the binary, ginstall, nor the ].1 man page is installed.
|
||||
define my-instcheck
|
||||
$(MAKE) prefix=$(pfx) install \
|
||||
&& test ! -f $(pfx)/bin/ginstall \
|
||||
&& { fail=0; \
|
||||
for i in $(built_programs); do \
|
||||
test "$$i" = ginstall && i=install; \
|
||||
for j in "$(pfx)/bin/$$i" \
|
||||
"$(pfx)/share/man/man1/$$i.1"; do \
|
||||
case $$j in *'[.1') continue;; esac; \
|
||||
test -f "$$j" && : \
|
||||
|| { echo "$$j not installed"; fail=1; }; \
|
||||
done; \
|
||||
done; \
|
||||
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.
|
||||
# These CFLAGS are pretty strict. If you build this target, you probably
|
||||
# have to have a recent version of gcc and glibc headers.
|
||||
# The for-loop below ensures that there is a bin/ directory full of all
|
||||
# of the programs under test (except the few that are required for basic
|
||||
# Makefile rules), all symlinked to the just-built "false" program.
|
||||
# The hard-linking for-loop below ensures that there is a bin/ directory
|
||||
# full of all of the programs under test (except the ones that are required
|
||||
# for basic Makefile rules), all symlinked to the just-built "false" program.
|
||||
# This is to ensure that if ever a test neglects to make PATH include
|
||||
# the build srcdir, these always-failing programs will run.
|
||||
# Otherwise, it is too easy to test the wrong programs.
|
||||
# Note that "false" itself is a symlink to true, so it too will malfunction.
|
||||
TMPDIR ?= /tmp
|
||||
t=$(TMPDIR)/$(PACKAGE)/test
|
||||
my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz) check
|
||||
my-distcheck: $(DIST_ARCHIVES) $(local-check)
|
||||
$(MAKE) syntax-check
|
||||
$(MAKE) check
|
||||
-rm -rf $(t)
|
||||
mkdir -p $(t)
|
||||
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
|
||||
@@ -574,6 +787,8 @@ my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz) check
|
||||
&& $(MAKE) CFLAGS='$(warn_cflags)' \
|
||||
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
||||
&& $(MAKE) dvi \
|
||||
&& $(install-transform-check) \
|
||||
&& $(my-instcheck) \
|
||||
&& mkdir $(bin) \
|
||||
&& ($(write_loser)) > $(bin)/loser \
|
||||
&& chmod a+x $(bin)/loser \
|
||||
@@ -586,19 +801,14 @@ my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz) check
|
||||
done \
|
||||
&& ln -sf ../src/true $(bin)/false \
|
||||
&& PATH=`pwd`/$(bin):$$PATH $(MAKE) -C tests check \
|
||||
&& $(MAKE) -C gnulib-tests check \
|
||||
&& { test -d gnulib-tests \
|
||||
&& $(MAKE) -C gnulib-tests check \
|
||||
|| :; } \
|
||||
&& rm -rf $(bin) \
|
||||
&& $(MAKE) distclean
|
||||
(cd $(t) && mv $(distdir) $(distdir).old \
|
||||
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz
|
||||
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
|
||||
if test -f $(srcdir)/src/c99-to-c89.diff; then \
|
||||
cd $(t)/$(distdir) \
|
||||
&& (cd src && patch -V never --fuzz=0 <c99-to-c89.diff) \
|
||||
&& ./configure --disable-largefile \
|
||||
CFLAGS='-Werror -ansi -Wno-long-long' \
|
||||
&& $(MAKE); \
|
||||
fi
|
||||
-rm -rf $(t)
|
||||
@echo "========================"; \
|
||||
echo "$(distdir).tar.gz is ready for distribution"; \
|
||||
@@ -616,17 +826,12 @@ rel-check:
|
||||
echo "$(md5) -" > $$md5_tmp; \
|
||||
md5sum -c $$md5_tmp < $$tarz
|
||||
|
||||
prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
|
||||
xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
|
||||
rel-files = $(DIST_ARCHIVES)
|
||||
|
||||
rel-files = $(xd-delta) $(DIST_ARCHIVES)
|
||||
gnulib-version = $$(cd $(gnulib_dir) && git describe)
|
||||
|
||||
# Approximate the date of last gnulib "update" by the ChangeLog file's
|
||||
# mtime, and provide that date in the announcement.
|
||||
announcement: NEWS ChangeLog $(rel-files)
|
||||
@cl_date=$$(stat --printf @%Y $(gnulib_dir)/ChangeLog); \
|
||||
utc_date=$$(date -u --date $$cl_date '+%Y-%m-%d %T %z'); \
|
||||
./build-aux/announce-gen \
|
||||
@./build-aux/announce-gen \
|
||||
--release-type=$(RELEASE_TYPE) \
|
||||
--package=$(PACKAGE) \
|
||||
--prev=$(PREV_VERSION) \
|
||||
@@ -634,7 +839,7 @@ announcement: NEWS ChangeLog $(rel-files)
|
||||
--gpg-key-id=$(gpg_key_ID) \
|
||||
--news=NEWS \
|
||||
--bootstrap-tools=autoconf,automake,bison,gnulib \
|
||||
--gnulib-snapshot-time-stamp="$$utc_date" \
|
||||
--gnulib-version=$(gnulib-version) \
|
||||
$(addprefix --url-dir=, $(url_dir_list))
|
||||
|
||||
## ---------------- ##
|
||||
@@ -657,8 +862,13 @@ emit_upload_commands:
|
||||
@echo =====================================
|
||||
@echo =====================================
|
||||
|
||||
$(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
|
||||
xdelta delta -9 $^ $@ || :
|
||||
noteworthy = * Noteworthy changes in release ?.? (????-??-??) [?]
|
||||
define emit-commit-log
|
||||
printf '%s\n' 'post-release administrivia' '' \
|
||||
'* NEWS: Add header line for next release.' \
|
||||
'* .prev-version: Record previous version.' \
|
||||
'* cfg.mk (old_NEWS_hash): Auto-update.'
|
||||
endef
|
||||
|
||||
.PHONY: alpha beta major
|
||||
alpha beta major: $(local-check) writable-files
|
||||
@@ -667,13 +877,15 @@ alpha beta major: $(local-check) writable-files
|
||||
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
|
||||
|| :
|
||||
$(MAKE) vc-dist
|
||||
$(MAKE) news-date-check changelog-check
|
||||
$(MAKE) $(xd-delta)
|
||||
$(MAKE) news-date-check
|
||||
$(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
|
||||
ln $(rel-files) $(release_archive_dir)
|
||||
chmod a-w $(rel-files)
|
||||
if test -d $(release_archive_dir); then \
|
||||
ln $(rel-files) $(release_archive_dir); \
|
||||
chmod a-w $(rel-files); \
|
||||
fi
|
||||
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
|
||||
echo $(VERSION) > $(prev_version_file)
|
||||
$(VC) commit -m \
|
||||
'$(prev_version_file): Record previous version: $(VERSION).' \
|
||||
$(prev_version_file)
|
||||
$(MAKE) update-NEWS-hash
|
||||
perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS
|
||||
$(emit-commit-log) > .ci-msg
|
||||
$(VC) commit -F .ci-msg -a
|
||||
@@ -1,6 +1,6 @@
|
||||
# Make coreutils man pages. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 2002-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-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
|
||||
@@ -15,15 +15,15 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
dist_man_MANS = groups.1 $(MAN)
|
||||
dist_man1_MANS = $(MAN)
|
||||
|
||||
man_aux = $(dist_man_MANS:.1=.x)
|
||||
man_aux = $(dist_man1_MANS:.1=.x)
|
||||
|
||||
EXTRA_DIST = $(man_aux) $(NO_INSTALL_PROGS_DEFAULT:%=%.x) help2man
|
||||
MAINTAINERCLEANFILES = $(dist_man_MANS)
|
||||
MAINTAINERCLEANFILES = $(dist_man1_MANS)
|
||||
|
||||
# Depend on configure.ac to get version number changes.
|
||||
common_dep = $(top_srcdir)/configure.ac
|
||||
# Depend on ../.version to get version number changes.
|
||||
common_dep = ../.version
|
||||
|
||||
# Note that arch depends on uname.c
|
||||
arch.1: $(common_dep) $(srcdir)/arch.x ../src/uname.c
|
||||
@@ -59,7 +59,7 @@ factor.1: $(common_dep) $(srcdir)/factor.x ../src/factor.c
|
||||
false.1: $(common_dep) $(srcdir)/false.x ../src/false.c
|
||||
fmt.1: $(common_dep) $(srcdir)/fmt.x ../src/fmt.c
|
||||
fold.1: $(common_dep) $(srcdir)/fold.x ../src/fold.c
|
||||
groups.1: $(common_dep) $(srcdir)/groups.x ../src/groups.sh
|
||||
groups.1: $(common_dep) $(srcdir)/groups.x ../src/groups.c
|
||||
head.1: $(common_dep) $(srcdir)/head.x ../src/head.c
|
||||
hostid.1: $(common_dep) $(srcdir)/hostid.x ../src/hostid.c
|
||||
hostname.1: $(common_dep) $(srcdir)/hostname.x ../src/hostname.c
|
||||
@@ -113,9 +113,11 @@ tac.1: $(common_dep) $(srcdir)/tac.x ../src/tac.c
|
||||
tail.1: $(common_dep) $(srcdir)/tail.x ../src/tail.c
|
||||
tee.1: $(common_dep) $(srcdir)/tee.x ../src/tee.c
|
||||
test.1: $(common_dep) $(srcdir)/test.x ../src/test.c
|
||||
timeout.1: $(common_dep) $(srcdir)/timeout.x ../src/timeout.c
|
||||
touch.1: $(common_dep) $(srcdir)/touch.x ../src/touch.c
|
||||
tr.1: $(common_dep) $(srcdir)/tr.x ../src/tr.c
|
||||
true.1: $(common_dep) $(srcdir)/true.x ../src/true.c
|
||||
truncate.1: $(common_dep) $(srcdir)/truncate.x ../src/truncate.c
|
||||
tsort.1: $(common_dep) $(srcdir)/tsort.x ../src/tsort.c
|
||||
tty.1: $(common_dep) $(srcdir)/tty.x ../src/tty.c
|
||||
uname.1: $(common_dep) $(srcdir)/uname.x ../src/uname.c
|
||||
@@ -159,7 +161,6 @@ mapped_name = `echo $*|sed 's/^install$$/ginstall/; s/^test$$/[/'`
|
||||
--output=$t/$@ $t/$*; \
|
||||
} \
|
||||
&& sed 's|$*\.td/||g' $t/$@ > $@ \
|
||||
&& chmod a-w $@ \
|
||||
&& rm -rf $t ;; \
|
||||
esac
|
||||
|
||||
@@ -171,7 +172,7 @@ distcheck-hook: check-x-vs-1 check-programs-vs-x
|
||||
ASSORT = LC_ALL=C sort
|
||||
|
||||
# Ensure that for each .x file in this directory, there is a
|
||||
# corresponding .1 file in the definition of $(dist_man_MANS) above.
|
||||
# corresponding .1 file in the definition of $(dist_man1_MANS) above.
|
||||
# But since that expansion usually lacks programs like su and arch,
|
||||
# add them here manually.
|
||||
.PHONY: check-x-vs-1
|
||||
@@ -179,7 +180,7 @@ check-x-vs-1:
|
||||
PATH=../src$(PATH_SEPARATOR)$$PATH; export PATH; \
|
||||
t=ls-files.$$$$; \
|
||||
(cd $(srcdir) && ls -1 *.x) | sed 's/\.x$$//' | $(ASSORT) > $$t;\
|
||||
(echo $(dist_man_MANS) $(NO_INSTALL_PROGS_DEFAULT) \
|
||||
(echo $(dist_man1_MANS) $(NO_INSTALL_PROGS_DEFAULT) \
|
||||
| tr -s ' ' '\n' | sed 's/\.1$$//') \
|
||||
| $(ASSORT) -u | diff - $$t || { rm $$t; exit 1; }; \
|
||||
rm $$t
|
||||
|
||||
@@ -2,3 +2,12 @@
|
||||
date \- print or set the system date and time
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[DATE STRING]
|
||||
.\" NOTE: keep this paragraph in sync with the one in touch.x
|
||||
The --date=STRING is a mostly free format human readable date string
|
||||
such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or
|
||||
even "next Thursday". A date string may contain items indicating
|
||||
calendar date, time of day, time zone, day of week, relative time,
|
||||
relative date, and numbers. An empty string indicates the beginning
|
||||
of the day. The date string format is more complex than is easily
|
||||
documented here but is fully described in the info documentation.
|
||||
|
||||
@@ -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
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -34,7 +34,7 @@ my $have_gettext;
|
||||
BEGIN {
|
||||
eval {
|
||||
require Locale::gettext;
|
||||
Locale::gettext->import;
|
||||
Locale::gettext->import (qw(gettext textdomain));
|
||||
$have_gettext = 1;
|
||||
};
|
||||
|
||||
@@ -134,7 +134,7 @@ die $help_info unless @ARGV == 1;
|
||||
die "$this_program: no locale support (Locale::gettext required)\n"
|
||||
unless $locale eq 'C' or $have_gettext;
|
||||
|
||||
# Set localisation of date and executable's ouput.
|
||||
# Set localization of date and executable's output.
|
||||
delete @ENV{qw(LANGUAGE LC_MESSAGES LANG)};
|
||||
setlocale LC_ALL, $ENV{LC_ALL} = $locale;
|
||||
|
||||
@@ -567,7 +567,7 @@ and
|
||||
.B %s
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info %s
|
||||
.B info coreutils '%s invocation'
|
||||
.PP
|
||||
should give you access to the complete manual.
|
||||
EOT
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
printf \- format and print data
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
printf(3)
|
||||
|
||||
6
man/timeout.x
Normal file
6
man/timeout.x
Normal file
@@ -0,0 +1,6 @@
|
||||
[NAME]
|
||||
timeout \- run a command with a time limit
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
kill(1)
|
||||
@@ -2,3 +2,12 @@
|
||||
touch \- change file timestamps
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[DATE STRING]
|
||||
.\" NOTE: keep this paragraph in sync with the one in date.x
|
||||
The --date=STRING is a mostly free format human readable date string
|
||||
such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or
|
||||
even "next Thursday". A date string may contain items indicating
|
||||
calendar date, time of day, time zone, day of week, relative time,
|
||||
relative date, and numbers. An empty string indicates the beginning
|
||||
of the day. The date string format is more complex than is easily
|
||||
documented here but is fully described in the info documentation.
|
||||
|
||||
6
man/truncate.x
Normal file
6
man/truncate.x
Normal file
@@ -0,0 +1,6 @@
|
||||
[NAME]
|
||||
truncate \- shrink or extend the size of a file to the specifed size
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
dd(1), truncate(2), ftruncate(2)
|
||||
@@ -1,11 +1,11 @@
|
||||
# List of files which contain translatable strings.
|
||||
# Copyright (C) 1996-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2008 Free Software Foundation, Inc.
|
||||
|
||||
# These are nominally temporary...
|
||||
lib/acl.c
|
||||
lib/argmatch.c
|
||||
lib/closein.c
|
||||
lib/closeout.c
|
||||
lib/copy-acl.c
|
||||
lib/error.c
|
||||
lib/euidaccess-stat.c
|
||||
lib/file-type.c
|
||||
@@ -19,6 +19,7 @@ lib/randread.c
|
||||
lib/regcomp.c
|
||||
lib/root-dev-ino.h
|
||||
lib/rpmatch.c
|
||||
lib/set-mode-acl.c
|
||||
lib/unicodeio.c
|
||||
lib/userspec.c
|
||||
lib/version-etc.c
|
||||
@@ -60,6 +61,8 @@ src/factor.c
|
||||
src/false.c
|
||||
src/fmt.c
|
||||
src/fold.c
|
||||
src/group-list.c
|
||||
src/groups.c
|
||||
src/head.c
|
||||
src/hostid.c
|
||||
src/hostname.c
|
||||
@@ -81,6 +84,7 @@ src/nice.c
|
||||
src/nl.c
|
||||
src/nohup.c
|
||||
src/od.c
|
||||
src/operand2sig.c
|
||||
src/paste.c
|
||||
src/pathchk.c
|
||||
src/pinky.c
|
||||
@@ -112,9 +116,11 @@ src/tac.c
|
||||
src/tail.c
|
||||
src/tee.c
|
||||
src/test.c
|
||||
src/timeout.c
|
||||
src/touch.c
|
||||
src/tr.c
|
||||
src/true.c
|
||||
src/truncate.c
|
||||
src/tsort.c
|
||||
src/tty.c
|
||||
src/uname.c
|
||||
|
||||
4
src/.gitignore
vendored
4
src/.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
*.exe
|
||||
\[
|
||||
arch
|
||||
base64
|
||||
basename
|
||||
cat
|
||||
@@ -38,6 +39,7 @@ hostname
|
||||
id
|
||||
join
|
||||
kill
|
||||
libver.a
|
||||
link
|
||||
ln
|
||||
localedir.h
|
||||
@@ -86,9 +88,11 @@ tac
|
||||
tail
|
||||
tee
|
||||
test
|
||||
timeout
|
||||
touch
|
||||
tr
|
||||
true
|
||||
truncate
|
||||
tsort
|
||||
tty
|
||||
uname
|
||||
|
||||
124
src/Makefile.am
124
src/Makefile.am
@@ -33,16 +33,15 @@ EXTRA_PROGRAMS = \
|
||||
ginstall link ln dir vdir ls mkdir \
|
||||
mkfifo mknod mktemp \
|
||||
mv nohup readlink rm rmdir shred stat sync touch unlink \
|
||||
cat cksum comm csplit cut expand fmt fold head join md5sum \
|
||||
cat cksum comm csplit cut expand fmt fold head join groups md5sum \
|
||||
nl od paste pr ptx sha1sum sha224sum sha256sum sha384sum sha512sum \
|
||||
shuf sort split sum tac tail tr tsort unexpand uniq wc \
|
||||
basename date dirname echo env expr factor false \
|
||||
id kill logname pathchk printenv printf pwd \
|
||||
runcon seq sleep tee \
|
||||
test true tty whoami yes \
|
||||
test timeout true truncate tty whoami yes \
|
||||
base64
|
||||
|
||||
bin_SCRIPTS = groups
|
||||
bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
|
||||
|
||||
noinst_PROGRAMS = setuidgid
|
||||
@@ -53,7 +52,10 @@ noinst_HEADERS = \
|
||||
cp-hash.h \
|
||||
dircolors.h \
|
||||
fs.h \
|
||||
group-list.h \
|
||||
ls.h \
|
||||
operand2sig.h \
|
||||
prog-fprintf.h \
|
||||
remove.h \
|
||||
system.h \
|
||||
wheel-size.h \
|
||||
@@ -61,18 +63,29 @@ noinst_HEADERS = \
|
||||
uname.h
|
||||
|
||||
EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
|
||||
groups.sh wheel-gen.pl extract-magic c99-to-c89.diff
|
||||
wheel-gen.pl extract-magic c99-to-c89.diff
|
||||
BUILT_SOURCES =
|
||||
CLEANFILES = $(SCRIPTS) su
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/lib
|
||||
|
||||
noinst_LIBRARIES = libver.a
|
||||
nodist_libver_a_SOURCES = version.c version.h
|
||||
|
||||
# Sometimes, the expansion of $(LIBINTL) includes -lc which may
|
||||
# include modules defining variables like `optind', so libcoreutils.a
|
||||
# must precede $(LIBINTL) in order to ensure we use GNU getopt.
|
||||
# But libcoreutils.a must also follow $(LIBINTL), since libintl uses
|
||||
# replacement functions defined in libcoreutils.a.
|
||||
LDADD = ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
|
||||
LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
|
||||
|
||||
cat_LDADD = $(LDADD)
|
||||
df_LDADD = $(LDADD)
|
||||
du_LDADD = $(LDADD)
|
||||
ptx_LDADD = $(LDADD)
|
||||
split_LDADD = $(LDADD)
|
||||
timeout_LDADD = $(LDADD)
|
||||
truncate_LDADD = $(LDADD)
|
||||
|
||||
# for eaccess in lib/euidaccess.c.
|
||||
chcon_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
@@ -91,14 +104,15 @@ __LDADD = $(LDADD) $(LIB_EACCESS)
|
||||
|
||||
# for clock_gettime and fdatasync
|
||||
dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
|
||||
dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
|
||||
dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
|
||||
id_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
|
||||
ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
|
||||
mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
|
||||
pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
|
||||
shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
|
||||
shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
|
||||
mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
|
||||
vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
|
||||
tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
|
||||
vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
|
||||
|
||||
## If necessary, add -lm to resolve use of pow in lib/strtod.c.
|
||||
sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
|
||||
@@ -118,6 +132,12 @@ seq_LDADD = $(LDADD) $(POW_LIB)
|
||||
# and the `nanosleep' reference in lib/xnanosleep.c.
|
||||
nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
|
||||
|
||||
# for various GMP functions
|
||||
expr_LDADD = $(LDADD) $(LIB_GMP)
|
||||
|
||||
# for various GMP functions
|
||||
factor_LDADD = $(LDADD) $(LIB_GMP)
|
||||
|
||||
sleep_LDADD = $(nanosec_libs)
|
||||
tail_LDADD = $(nanosec_libs)
|
||||
|
||||
@@ -135,6 +155,16 @@ ginstall_LDADD += $(LIB_ACL)
|
||||
|
||||
stat_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
|
||||
# Append $(LIBICONV) to each program that uses proper_name_utf8.
|
||||
cat_LDADD += $(LIBICONV)
|
||||
cp_LDADD += $(LIBICONV)
|
||||
df_LDADD += $(LIBICONV)
|
||||
du_LDADD += $(LIBICONV)
|
||||
ptx_LDADD += $(LIBICONV)
|
||||
split_LDADD += $(LIBICONV)
|
||||
timeout_LDADD += $(LIBICONV)
|
||||
truncate_LDADD += $(LIBICONV)
|
||||
|
||||
$(PROGRAMS): ../lib/libcoreutils.a
|
||||
|
||||
# Get the release year from ../lib/version-etc.c.
|
||||
@@ -142,20 +172,6 @@ RELEASE_YEAR = \
|
||||
`sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
|
||||
$(top_srcdir)/lib/version-etc.c`
|
||||
|
||||
# This depends on 'Makefile', so that version changes
|
||||
#(reflected in Makefile's VERSION definition)
|
||||
# are reflected into groups --version also between releases.
|
||||
groups: groups.sh Makefile
|
||||
rm -f $@ $@-t
|
||||
sed \
|
||||
-e 's!@''bindir''@!$(bindir)!' \
|
||||
-e 's/@''RELEASE_YEAR'@/$(RELEASE_YEAR)/ \
|
||||
-e 's/@''PACKAGE_NAME''@/$(PACKAGE_NAME)/' \
|
||||
-e 's/@''PACKAGE_BUGREPORT''@/$(PACKAGE_BUGREPORT)/' \
|
||||
-e 's/@''VERSION''@/$(VERSION)/' $(srcdir)/groups.sh > $@-t
|
||||
chmod +x $@-t
|
||||
mv $@-t $@
|
||||
|
||||
all-local: su$(EXEEXT)
|
||||
|
||||
installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
|
||||
@@ -170,7 +186,7 @@ install_su = \
|
||||
echo " chown root $(installed_su)"; \
|
||||
chown root $(installed_su); \
|
||||
echo " chmod $(setuid_root_mode) $(installed_su)"; \
|
||||
chmod $(setuid_root_mode) $(installed_su) \
|
||||
chmod $(setuid_root_mode) $(installed_su); \
|
||||
else \
|
||||
:; \
|
||||
fi
|
||||
@@ -216,8 +232,8 @@ copy_sources = copy.c cp-hash.c
|
||||
# confusion with the `install' target. The install rule transforms `ginstall'
|
||||
# to install before applying any user-specified name transformations.
|
||||
|
||||
transform = s/ginstall/install/; @program_transform_name@
|
||||
ginstall_SOURCES = install.c $(copy_sources)
|
||||
transform = s/ginstall/install/; $(program_transform_name)
|
||||
ginstall_SOURCES = install.c prog-fprintf.c $(copy_sources)
|
||||
|
||||
# This is for the '[' program. Automake transliterates '[' to '_'.
|
||||
__SOURCES = lbracket.c
|
||||
@@ -225,14 +241,21 @@ __SOURCES = lbracket.c
|
||||
cp_SOURCES = cp.c $(copy_sources)
|
||||
dir_SOURCES = ls.c ls-dir.c
|
||||
vdir_SOURCES = ls.c ls-vdir.c
|
||||
id_SOURCES = id.c group-list.c
|
||||
groups_SOURCES = groups.c group-list.c
|
||||
ln_SOURCES = ln.c
|
||||
ls_SOURCES = ls.c ls-ls.c
|
||||
chown_SOURCES = chown.c chown-core.c
|
||||
chgrp_SOURCES = chgrp.c chown-core.c
|
||||
kill_SOURCES = kill.c operand2sig.c
|
||||
timeout_SOURCES = timeout.c operand2sig.c
|
||||
|
||||
mv_SOURCES = mv.c remove.c $(copy_sources)
|
||||
rm_SOURCES = rm.c remove.c
|
||||
|
||||
mkdir_SOURCES = mkdir.c prog-fprintf.c
|
||||
rmdir_SOURCES = rmdir.c prog-fprintf.c
|
||||
|
||||
uname_SOURCES = uname.c uname-uname.c
|
||||
arch_SOURCES = uname.c uname-arch.c
|
||||
|
||||
@@ -249,6 +272,8 @@ sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
|
||||
sha512sum_SOURCES = md5sum.c
|
||||
sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
|
||||
|
||||
ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
|
||||
|
||||
editpl = sed -e 's,@''PERL''@,$(PERL),g'
|
||||
|
||||
BUILT_SOURCES += dircolors.h
|
||||
@@ -286,6 +311,22 @@ fs.h: stat.c extract-magic
|
||||
@chmod a-w $@t
|
||||
mv $@t $@
|
||||
|
||||
BUILT_SOURCES += version.c
|
||||
version.c: Makefile
|
||||
rm -f $@
|
||||
printf '#include <config.h>\n' > $@t
|
||||
printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
|
||||
@chmod a-w $@t
|
||||
mv $@t $@
|
||||
|
||||
BUILT_SOURCES += version.h
|
||||
version.h: Makefile
|
||||
rm -f $@
|
||||
printf 'extern char const *Version;\n' > $@t
|
||||
@chmod a-w $@t
|
||||
mv $@t $@
|
||||
|
||||
DISTCLEANFILES = version.c version.h
|
||||
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
# Sort in traditional ASCII order, regardless of the current locale;
|
||||
@@ -300,7 +341,7 @@ all_programs = \
|
||||
|
||||
built_programs.list:
|
||||
@echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
|
||||
| sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u
|
||||
| sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u | tr '\n' ' '
|
||||
|
||||
all_programs.list:
|
||||
@echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
|
||||
@@ -343,10 +384,11 @@ check-AUTHORS: $(all_programs)
|
||||
elif test "$$i" = test; then \
|
||||
exe='['; \
|
||||
fi; \
|
||||
./$$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)
|
||||
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.
|
||||
@@ -400,19 +442,33 @@ s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
|
||||
sc_tight_scope: $(all_programs)
|
||||
@t=exceptions-$$$$; \
|
||||
trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
|
||||
( printf '^main$$\n^usage$$\n'; \
|
||||
grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
|
||||
| grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
|
||||
src=`for f in $(SOURCES); do \
|
||||
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
|
||||
hdr=`for f in $(noinst_HEADERS); do \
|
||||
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
|
||||
( printf 'main\nusage\n'; \
|
||||
grep -h -A1 '^extern .*[^;]$$' $$src \
|
||||
| grep -vE '^(extern |--)' | sed 's/ .*//'; \
|
||||
perl -ne '/^extern \S+ (\S*) \(/ and print "$$1\n"' $$hdr; \
|
||||
) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
|
||||
nm -e *.$(OBJEXT) \
|
||||
| sed -n 's/.* T //p' \
|
||||
| grep -Ev -f $$t && \
|
||||
{ echo 'the above functions should have static scope' 1>&2; \
|
||||
exit 1; } || : ; \
|
||||
( printf '^program_name$$\n'; \
|
||||
sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p' \
|
||||
$(noinst_HEADERS) ) > $$t; \
|
||||
perl -ne '/^extern .*?\**(\w+);/ and print "^$$1\$$\n"' \
|
||||
$$hdr *.h ) | $(ASSORT) -u > $$t; \
|
||||
nm -e *.$(OBJEXT) \
|
||||
| sed -n 's/.* [BD] //p' \
|
||||
| grep -Ev -f $$t && \
|
||||
{ echo 'the above variables should have static scope' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Use the just-built ./ginstall, when not cross-compiling.
|
||||
if CROSS_COMPILING
|
||||
cu_install_program = @INSTALL_PROGRAM@
|
||||
else
|
||||
cu_install_program = ./ginstall
|
||||
endif
|
||||
INSTALL_PROGRAM = $(cu_install_program)
|
||||
|
||||
28
src/base64.c
28
src/base64.c
@@ -1,5 +1,5 @@
|
||||
/* Base64 encode/decode strings or files.
|
||||
Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004-2008 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Base64.
|
||||
|
||||
@@ -35,17 +35,13 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "base64"
|
||||
|
||||
#define AUTHOR "Simon Josefsson"
|
||||
#define AUTHORS proper_name ("Simon Josefsson")
|
||||
|
||||
/* The invocation name of this program. */
|
||||
char *program_name;
|
||||
|
||||
static const struct option long_options[] = {
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"decode", no_argument, 0, 'd'},
|
||||
{"wrap", required_argument, 0, 'w'},
|
||||
{"ignore-garbage", no_argument, 0, 'i'},
|
||||
{"help", no_argument, 0, GETOPT_HELP_CHAR},
|
||||
{"version", no_argument, 0, GETOPT_VERSION_CHAR},
|
||||
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
@@ -61,7 +57,7 @@ usage (int status)
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION] [FILE]\n\
|
||||
Usage: %s [OPTION]... [FILE]\n\
|
||||
Base64 encode or decode FILE, or standard input, to standard output.\n\
|
||||
\n"), program_name);
|
||||
fputs (_("\
|
||||
@@ -218,12 +214,12 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage)
|
||||
However, when it processes the final input buffer, we want
|
||||
to iterate it one additional time, but with an indicator
|
||||
telling it to flush what is in CTX. */
|
||||
for (k = 0; k < 1 + feof (in); k++)
|
||||
for (k = 0; k < 1 + !!feof (in); k++)
|
||||
{
|
||||
if (k == 1 && ctx.i == 0)
|
||||
break;
|
||||
n = BLOCKSIZE;
|
||||
ok = base64_decode (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);
|
||||
ok = base64_decode_ctx (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);
|
||||
|
||||
if (fwrite (outbuf, 1, n, out) < n)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
@@ -242,22 +238,22 @@ main (int argc, char **argv)
|
||||
FILE *input_fh;
|
||||
const char *infile;
|
||||
|
||||
/* True if --decode has bene given and we should decode data. */
|
||||
/* True if --decode has been given and we should decode data. */
|
||||
bool decode = false;
|
||||
/* True if we should ignore non-alphabetic characters. */
|
||||
/* True if we should ignore non-base64-alphabetic characters. */
|
||||
bool ignore_garbage = false;
|
||||
/* Wrap encoded base64 data around the 76:th column, by default. */
|
||||
uintmax_t wrap_column = 76;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((opt = getopt_long (argc, argv, "dqiw:", long_options, NULL)) != -1)
|
||||
while ((opt = getopt_long (argc, argv, "diw:", long_options, NULL)) != -1)
|
||||
switch (opt)
|
||||
{
|
||||
case 'd':
|
||||
@@ -276,7 +272,7 @@ main (int argc, char **argv)
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHOR);
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename -- strip directory and suffix from file names
|
||||
Copyright (C) 1990-1997, 1999-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1999-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
|
||||
@@ -37,10 +37,7 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "basename"
|
||||
|
||||
#define AUTHORS "FIXME unknown"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
#define AUTHORS proper_name ("David MacKenzie")
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
@@ -99,14 +96,14 @@ main (int argc, char **argv)
|
||||
char *name;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
diff -upr src/remove.c src/remove.c
|
||||
--- src/remove.c 2007-07-23 12:56:20.000000000 +0200
|
||||
+++ src/remove.c 2007-07-23 13:03:12.000000000 +0200
|
||||
--- src/remove.c 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ src/remove.c 1970-01-01 00:00:00.000000000 +0000
|
||||
@@ -262,9 +262,10 @@ pop_dir (Dirstack_state *ds)
|
||||
{
|
||||
size_t n_lengths = obstack_object_size (&ds->len_stack) / sizeof (size_t);
|
||||
@@ -26,15 +26,31 @@ diff -upr src/remove.c src/remove.c
|
||||
if (top->unremovable)
|
||||
hash_free (top->unremovable);
|
||||
obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent));
|
||||
@@ -907,6 +909,7 @@ prompt (int fd_cwd, Dirstack_state const
|
||||
@@ -834,14 +836,13 @@ prompt (int fd_cwd, Dirstack_state const
|
||||
{
|
||||
int write_protected = 0;
|
||||
int dirent_type = *pdirent_type;
|
||||
+ int wp_errno = 0;
|
||||
|
||||
*is_empty = T_UNKNOWN;
|
||||
|
||||
if (x->interactive == RMI_NEVER)
|
||||
return RM_OK;
|
||||
|
||||
- int wp_errno = 0;
|
||||
-
|
||||
if (!x->ignore_missing_files
|
||||
&& ((x->interactive == RMI_ALWAYS) || x->stdin_tty)
|
||||
&& dirent_type != DT_LNK)
|
||||
@@ -889,6 +890,7 @@ prompt (int fd_cwd, Dirstack_state const
|
||||
break;
|
||||
}
|
||||
|
||||
+ {
|
||||
char const *quoted_name = quote (full_filename (filename));
|
||||
|
||||
if (0 < write_protected)
|
||||
@@ -946,6 +949,7 @@ prompt (int fd_cwd, Dirstack_state const
|
||||
if (write_protected < 0)
|
||||
@@ -928,6 +930,7 @@ prompt (int fd_cwd, Dirstack_state const
|
||||
: _("%s: remove %s %s? ")),
|
||||
program_name, file_type (sbuf), quoted_name);
|
||||
}
|
||||
@@ -42,7 +58,7 @@ diff -upr src/remove.c src/remove.c
|
||||
|
||||
if (!yesno ())
|
||||
return RM_USER_DECLINED;
|
||||
@@ -1565,6 +1569,7 @@ rm_1 (Dirstack_state *ds, char const *fi
|
||||
@@ -1547,6 +1550,7 @@ rm_1 (Dirstack_state *ds, char const *fi
|
||||
return RM_ERROR;
|
||||
}
|
||||
|
||||
@@ -50,7 +66,7 @@ diff -upr src/remove.c src/remove.c
|
||||
struct stat st;
|
||||
cache_stat_init (&st);
|
||||
cycle_check_init (&ds->cycle_check_state);
|
||||
@@ -1587,6 +1592,7 @@ rm_1 (Dirstack_state *ds, char const *fi
|
||||
@@ -1569,6 +1573,7 @@ rm_1 (Dirstack_state *ds, char const *fi
|
||||
AD_push_initial (ds);
|
||||
AD_INIT_OTHER_MEMBERS ();
|
||||
|
||||
@@ -58,7 +74,7 @@ diff -upr src/remove.c src/remove.c
|
||||
enum RM_status status = remove_entry (AT_FDCWD, ds, filename,
|
||||
DT_UNKNOWN, &st, x);
|
||||
if (status == RM_NONEMPTY_DIR)
|
||||
@@ -1605,6 +1611,8 @@ rm_1 (Dirstack_state *ds, char const *fi
|
||||
@@ -1587,6 +1592,8 @@ rm_1 (Dirstack_state *ds, char const *fi
|
||||
ds_clear (ds);
|
||||
return status;
|
||||
}
|
||||
@@ -68,8 +84,8 @@ diff -upr src/remove.c src/remove.c
|
||||
/* Remove all files and/or directories specified by N_FILES and FILE.
|
||||
Apply the options in X. */
|
||||
diff -upr src/rm.c src/rm.c
|
||||
--- src/rm.c 2007-07-23 12:56:20.000000000 +0200
|
||||
+++ src/rm.c 2007-07-23 13:03:12.000000000 +0200
|
||||
--- src/rm.c 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ src/rm.c 1970-01-01 00:00:00.000000000 +0000
|
||||
@@ -354,6 +354,7 @@ main (int argc, char **argv)
|
||||
quote ("/"));
|
||||
}
|
||||
@@ -90,9 +106,9 @@ diff -upr src/rm.c src/rm.c
|
||||
+ }
|
||||
}
|
||||
diff -upr src/seq.c src/seq.c
|
||||
--- src/seq.c 2007-07-23 12:56:20.000000000 +0200
|
||||
+++ src/seq.c 2007-07-23 13:03:12.000000000 +0200
|
||||
@@ -164,6 +164,7 @@ scan_arg (const char *arg)
|
||||
--- src/seq.c 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ src/seq.c 1970-01-01 00:00:00.000000000 +0000
|
||||
@@ -163,6 +163,7 @@ scan_arg (const char *arg)
|
||||
: (decimal_point == arg /* .# -> 0.# */
|
||||
|| ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */
|
||||
}
|
||||
@@ -100,7 +116,7 @@ diff -upr src/seq.c src/seq.c
|
||||
char const *e = strchr (arg, 'e');
|
||||
if (! e)
|
||||
e = strchr (arg, 'E');
|
||||
@@ -172,6 +173,7 @@ scan_arg (const char *arg)
|
||||
@@ -171,6 +172,7 @@ scan_arg (const char *arg)
|
||||
long exponent = strtol (e + 1, NULL, 10);
|
||||
ret.precision += exponent < 0 ? -exponent : 0;
|
||||
}
|
||||
@@ -108,7 +124,7 @@ diff -upr src/seq.c src/seq.c
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -311,6 +313,7 @@ get_default_format (operand first, opera
|
||||
@@ -346,6 +348,7 @@ get_default_format (operand first, opera
|
||||
size_t last_width = last.width + (prec - last.precision);
|
||||
if (last.precision && prec == 0)
|
||||
last_width--; /* don't include space for '.' */
|
||||
@@ -116,7 +132,7 @@ diff -upr src/seq.c src/seq.c
|
||||
size_t width = MAX (first_width, last_width);
|
||||
if (width <= INT_MAX)
|
||||
{
|
||||
@@ -318,6 +321,7 @@ get_default_format (operand first, opera
|
||||
@@ -353,6 +356,7 @@ get_default_format (operand first, opera
|
||||
sprintf (format_buf, "%%0%d.%dLf", w, prec);
|
||||
return format_buf;
|
||||
}
|
||||
@@ -124,10 +140,26 @@ diff -upr src/seq.c src/seq.c
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -441,6 +445,7 @@ main (int argc, char **argv)
|
||||
if (format_str)
|
||||
{
|
||||
validate_format (format_str);
|
||||
+ {
|
||||
char const *f = long_double_format (format_str, &layout);
|
||||
if (! f)
|
||||
{
|
||||
@@ -448,6 +453,7 @@ main (int argc, char **argv)
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
format_str = f;
|
||||
+ }
|
||||
}
|
||||
|
||||
last = scan_arg (argv[optind++]);
|
||||
diff -upr src/shred.c src/shred.c
|
||||
--- src/shred.c 2007-07-23 12:56:20.000000000 +0200
|
||||
+++ src/shred.c 2007-07-23 13:03:12.000000000 +0200
|
||||
@@ -461,7 +461,7 @@ dopass (int fd, char const *qname, off_t
|
||||
--- src/shred.c 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ src/shred.c 1970-01-01 00:00:00.000000000 +0000
|
||||
@@ -468,7 +468,7 @@ dopass (int fd, char const *qname, off_t
|
||||
out. Thus, it shouldn't give up on bad blocks. This
|
||||
code works because lim is always a multiple of
|
||||
SECTOR_SIZE, except at the end. */
|
||||
|
||||
13
src/cat.c
13
src/cat.c
@@ -1,5 +1,5 @@
|
||||
/* cat -- concatenate files and print on the standard output.
|
||||
Copyright (C) 88, 90, 91, 1995-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 1995-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
|
||||
@@ -43,15 +43,14 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cat"
|
||||
|
||||
#define AUTHORS "Torbjorn Granlund", "Richard M. Stallman"
|
||||
#define AUTHORS \
|
||||
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 under which this program was invoked. */
|
||||
char *program_name;
|
||||
|
||||
/* Name of input file. May be "-". */
|
||||
static char const *infile;
|
||||
|
||||
@@ -91,7 +90,7 @@ usage (int status)
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION] [FILE]...\n\
|
||||
Usage: %s [OPTION]... [FILE]...\n\
|
||||
"),
|
||||
program_name);
|
||||
fputs (_("\
|
||||
@@ -563,7 +562,7 @@ main (int argc, char **argv)
|
||||
};
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
16
src/chcon.c
16
src/chcon.c
@@ -1,5 +1,5 @@
|
||||
/* chcon -- change security context of files
|
||||
Copyright (C) 2005-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-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
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "system.h"
|
||||
#include "dev-ino.h"
|
||||
#include "error.h"
|
||||
#include "openat.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "root-dev-ino.h"
|
||||
@@ -32,7 +31,9 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chcon"
|
||||
|
||||
#define AUTHORS "Russell Coker", "Jim Meyering"
|
||||
#define AUTHORS \
|
||||
proper_name ("Russell Coker"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
enum Change_status
|
||||
{
|
||||
@@ -54,9 +55,6 @@ enum Verbosity
|
||||
V_off
|
||||
};
|
||||
|
||||
/* The name the program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* 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;
|
||||
@@ -302,7 +300,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
if (ok)
|
||||
{
|
||||
if (verbose)
|
||||
printf (_("changing security context of %s"),
|
||||
printf (_("changing security context of %s\n"),
|
||||
quote (file_full_name));
|
||||
|
||||
if (change_file_context (fts->fts_cwd_fd, file) != 0)
|
||||
@@ -373,7 +371,6 @@ 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\
|
||||
(available only on systems with lchown system call)\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--reference=RFILE use RFILE's security context rather than specifying\n\
|
||||
@@ -402,6 +399,7 @@ one takes effect.\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -425,7 +423,7 @@ main (int argc, char **argv)
|
||||
int optc;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
11
src/chgrp.c
11
src/chgrp.c
@@ -1,5 +1,5 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-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
|
||||
@@ -34,15 +34,14 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chgrp"
|
||||
|
||||
#define AUTHORS "David MacKenzie", "Jim Meyering"
|
||||
#define AUTHORS \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
#if ! HAVE_ENDGRENT
|
||||
# define endgrent() ((void) 0)
|
||||
#endif
|
||||
|
||||
/* The name the program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* The argument to the --reference option. Use the group ID of this file.
|
||||
This file must exist. */
|
||||
static char *reference_file;
|
||||
@@ -182,7 +181,7 @@ main (int argc, char **argv)
|
||||
int optc;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
12
src/chmod.c
12
src/chmod.c
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-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
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "error.h"
|
||||
#include "filemode.h"
|
||||
#include "modechange.h"
|
||||
#include "openat.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "root-dev-ino.h"
|
||||
@@ -35,7 +34,9 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chmod"
|
||||
|
||||
#define AUTHORS "David MacKenzie", "Jim Meyering"
|
||||
#define AUTHORS \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
enum Change_status
|
||||
{
|
||||
@@ -57,9 +58,6 @@ enum Verbosity
|
||||
V_off
|
||||
};
|
||||
|
||||
/* The name the program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* The desired change to the mode. */
|
||||
static struct mode_change *change;
|
||||
|
||||
@@ -393,7 +391,7 @@ main (int argc, char **argv)
|
||||
int c;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chown-core.c -- core functions for changing ownership.
|
||||
Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation.
|
||||
Copyright (C) 2000, 2002-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
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "system.h"
|
||||
#include "chown-core.h"
|
||||
#include "error.h"
|
||||
#include "inttostr.h"
|
||||
#include "openat.h"
|
||||
#include "quote.h"
|
||||
#include "root-dev-ino.h"
|
||||
#include "xfts.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* chown-core.h -- types and prototypes shared by chown and chgrp.
|
||||
|
||||
Copyright (C) 2000, 2003, 2004 Free Software Foundation.
|
||||
Copyright (C) 2000, 2003-2005, 2007-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
|
||||
|
||||
11
src/chown.c
11
src/chown.c
@@ -1,5 +1,5 @@
|
||||
/* chown -- change user and group ownership of files
|
||||
Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-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
|
||||
@@ -43,10 +43,9 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chown"
|
||||
|
||||
#define AUTHORS "David MacKenzie", "Jim Meyering"
|
||||
|
||||
/* The name the program was run with. */
|
||||
char *program_name;
|
||||
#define AUTHORS \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
/* The argument to the --reference option. Use the owner and group IDs
|
||||
of this file. This file must exist. */
|
||||
@@ -184,7 +183,7 @@ main (int argc, char **argv)
|
||||
int optc;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
14
src/chroot.c
14
src/chroot.c
@@ -1,5 +1,6 @@
|
||||
/* chroot -- run command or shell with special root directory
|
||||
Copyright (C) 95, 96, 1997, 1999-2004, 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 95, 96, 1997, 1999-2004, 2007-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
|
||||
@@ -29,10 +30,7 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chroot"
|
||||
|
||||
#define AUTHORS "Roland McGrath"
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
#define AUTHORS proper_name ("Roland McGrath")
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
@@ -43,7 +41,7 @@ usage (int status)
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s NEWROOT [COMMAND...]\n\
|
||||
Usage: %s NEWROOT [COMMAND [ARG]...]\n\
|
||||
or: %s OPTION\n\
|
||||
"), program_name, program_name);
|
||||
fputs (_("\
|
||||
@@ -65,7 +63,7 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -73,7 +71,7 @@ main (int argc, char **argv)
|
||||
initialize_exit_failure (EXIT_FAILURE);
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
12
src/cksum.c
12
src/cksum.c
@@ -1,5 +1,5 @@
|
||||
/* cksum -- calculate and print POSIX checksums and sizes of files
|
||||
Copyright (C) 92, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 1995-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
|
||||
@@ -37,7 +37,7 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cksum"
|
||||
|
||||
#define AUTHORS "Q. Frank Xia"
|
||||
#define AUTHORS proper_name ("Q. Frank Xia")
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
@@ -108,14 +108,10 @@ main (void)
|
||||
# include <getopt.h>
|
||||
# include "long-options.h"
|
||||
# include "error.h"
|
||||
# include "inttostr.h"
|
||||
|
||||
/* Number of bytes to read at once. */
|
||||
# define BUFLEN (1 << 16)
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
static uint_fast32_t const crctab[256] =
|
||||
{
|
||||
0x00000000,
|
||||
@@ -284,14 +280,14 @@ main (int argc, char **argv)
|
||||
bool ok;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
if (getopt_long (argc, argv, "", NULL, NULL) != -1)
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
221
src/comm.c
221
src/comm.c
@@ -1,5 +1,5 @@
|
||||
/* comm -- compare two sorted files line by line.
|
||||
Copyright (C) 86, 90, 91, 1995-2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 90, 91, 1995-2005, 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
|
||||
@@ -31,15 +31,14 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "comm"
|
||||
|
||||
#define AUTHORS "Richard Stallman", "David MacKenzie"
|
||||
#define AUTHORS \
|
||||
proper_name ("Richard M. Stallman"), \
|
||||
proper_name ("David MacKenzie")
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
#undef min
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* True if the LC_COLLATE locale is hard. */
|
||||
static bool hard_LC_COLLATE;
|
||||
|
||||
@@ -52,8 +51,39 @@ static bool only_file_2;
|
||||
/* If true, print lines that are found in both files. */
|
||||
static bool both;
|
||||
|
||||
/* If nonzero, we have seen at least one unpairable line. */
|
||||
static bool seen_unpairable;
|
||||
|
||||
/* If nonzero, we have warned about disorder in that file. */
|
||||
static bool issued_disorder_warning[2];
|
||||
|
||||
/* If nonzero, check that the input is correctly ordered. */
|
||||
static enum
|
||||
{
|
||||
CHECK_ORDER_DEFAULT,
|
||||
CHECK_ORDER_ENABLED,
|
||||
CHECK_ORDER_DISABLED
|
||||
} check_input_order;
|
||||
|
||||
/* Output columns will be delimited with this string, which may be set
|
||||
on the command-line with --output-delimiter=STR. The default is a
|
||||
single TAB character. */
|
||||
static char const *delimiter;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
CHECK_ORDER_OPTION = CHAR_MAX + 1,
|
||||
NOCHECK_ORDER_OPTION,
|
||||
OUTPUT_DELIMITER_OPTION
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"check-order", no_argument, NULL, CHECK_ORDER_OPTION},
|
||||
{"nocheck-order", no_argument, NULL, NOCHECK_ORDER_OPTION},
|
||||
{"output-delimiter", required_argument, NULL, OUTPUT_DELIMITER_OPTION},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -87,6 +117,15 @@ and column three contains lines common to both files.\n\
|
||||
-1 suppress lines unique to FILE1\n\
|
||||
-2 suppress lines unique to FILE2\n\
|
||||
-3 suppress lines that appear in both files\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
--check-order check that the input is correctly sorted, even\n\
|
||||
if all input lines are pairable\n\
|
||||
--nocheck-order do not check that the input is correctly sorted\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--output-delimiter=STR separate columns with STR\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
@@ -101,7 +140,7 @@ and column three contains lines common to both files.\n\
|
||||
2 for a line only in file 2, 3 for a line in both. */
|
||||
|
||||
static void
|
||||
writeline (const struct linebuffer *line, FILE *stream, int class)
|
||||
writeline (struct linebuffer const *line, FILE *stream, int class)
|
||||
{
|
||||
switch (class)
|
||||
{
|
||||
@@ -113,26 +152,73 @@ writeline (const struct linebuffer *line, FILE *stream, int class)
|
||||
case 2:
|
||||
if (!only_file_2)
|
||||
return;
|
||||
/* Print a TAB if we are printing lines from file 1. */
|
||||
/* Print a delimiter if we are printing lines from file 1. */
|
||||
if (only_file_1)
|
||||
putc ('\t', stream);
|
||||
fputs (delimiter, stream);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (!both)
|
||||
return;
|
||||
/* Print a TAB if we are printing lines from file 1. */
|
||||
/* Print a delimiter if we are printing lines from file 1. */
|
||||
if (only_file_1)
|
||||
putc ('\t', stream);
|
||||
/* Print a TAB if we are printing lines from file 2. */
|
||||
fputs (delimiter, stream);
|
||||
/* Print a delimiter if we are printing lines from file 2. */
|
||||
if (only_file_2)
|
||||
putc ('\t', stream);
|
||||
fputs (delimiter, stream);
|
||||
break;
|
||||
}
|
||||
|
||||
fwrite (line->buffer, sizeof (char), line->length, stream);
|
||||
}
|
||||
|
||||
/* Check that successive input lines PREV and CURRENT from input file
|
||||
WHATFILE are presented in order.
|
||||
|
||||
If the user specified --nocheck-order, the check is not made.
|
||||
If the user specified --check-order, the problem is fatal.
|
||||
Otherwise (the default), the message is simply a warning.
|
||||
|
||||
A message is printed at most once per input file.
|
||||
|
||||
This funtion was copied (nearly) verbatim from `src/join.c'. */
|
||||
|
||||
static void
|
||||
check_order (struct linebuffer const *prev,
|
||||
struct linebuffer const *current,
|
||||
int whatfile)
|
||||
{
|
||||
|
||||
if (check_input_order != CHECK_ORDER_DISABLED
|
||||
&& ((check_input_order == CHECK_ORDER_ENABLED) || seen_unpairable))
|
||||
{
|
||||
if (!issued_disorder_warning[whatfile - 1])
|
||||
{
|
||||
int order;
|
||||
|
||||
if (hard_LC_COLLATE)
|
||||
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);
|
||||
}
|
||||
|
||||
if (0 < order)
|
||||
{
|
||||
error ((check_input_order == CHECK_ORDER_ENABLED
|
||||
? EXIT_FAILURE : 0),
|
||||
0, _("file %d is not in sorted order"), whatfile);
|
||||
|
||||
/* If we get to here, the message was just a warning, but we
|
||||
want only to issue it once. */
|
||||
issued_disorder_warning[whatfile - 1] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Compare INFILES[0] and INFILES[1].
|
||||
If either is "-", use the standard input for that file.
|
||||
Assume that each input file is sorted;
|
||||
@@ -141,28 +227,42 @@ writeline (const struct linebuffer *line, FILE *stream, int class)
|
||||
static void
|
||||
compare_files (char **infiles)
|
||||
{
|
||||
/* For each file, we have one linebuffer in lb1. */
|
||||
struct linebuffer lb1[2];
|
||||
/* For each file, we have four linebuffers in lba. */
|
||||
struct linebuffer lba[2][4];
|
||||
|
||||
/* thisline[i] points to the linebuffer holding the next available line
|
||||
in file i, or is NULL if there are no lines left in that file. */
|
||||
struct linebuffer *thisline[2];
|
||||
|
||||
/* all_line[i][alt[i][0]] also points to the linebuffer holding the
|
||||
current line in file i. We keep two buffers of history around so we
|
||||
can look two lines back when we get to the end of a file. */
|
||||
struct linebuffer *all_line[2][4];
|
||||
|
||||
/* This is used to rotate through the buffers for each input file. */
|
||||
int alt[2][3];
|
||||
|
||||
/* streams[i] holds the input stream for file i. */
|
||||
FILE *streams[2];
|
||||
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
/* Initialize the storage. */
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
initbuffer (&lb1[i]);
|
||||
thisline[i] = &lb1[i];
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
initbuffer (&lba[i][j]);
|
||||
all_line[i][j] = &lba[i][j];
|
||||
}
|
||||
alt[i][0] = 0;
|
||||
alt[i][1] = 0;
|
||||
alt[i][2] = 0;
|
||||
streams[i] = (STREQ (infiles[i], "-") ? stdin : fopen (infiles[i], "r"));
|
||||
if (!streams[i])
|
||||
error (EXIT_FAILURE, errno, "%s", infiles[i]);
|
||||
|
||||
thisline[i] = readlinebuffer (thisline[i], streams[i]);
|
||||
thisline[i] = readlinebuffer (all_line[i][alt[i][0]], streams[i]);
|
||||
if (ferror (streams[i]))
|
||||
error (EXIT_FAILURE, errno, "%s", infiles[i]);
|
||||
}
|
||||
@@ -170,6 +270,7 @@ compare_files (char **infiles)
|
||||
while (thisline[0] || thisline[1])
|
||||
{
|
||||
int order;
|
||||
bool fill_up[2] = { false, false };
|
||||
|
||||
/* Compare the next available lines of the two files. */
|
||||
|
||||
@@ -196,25 +297,47 @@ compare_files (char **infiles)
|
||||
/* Output the line that is lesser. */
|
||||
if (order == 0)
|
||||
writeline (thisline[1], stdout, 3);
|
||||
else if (order > 0)
|
||||
writeline (thisline[1], stdout, 2);
|
||||
else
|
||||
writeline (thisline[0], stdout, 1);
|
||||
{
|
||||
seen_unpairable = true;
|
||||
if (order <= 0)
|
||||
writeline (thisline[0], stdout, 1);
|
||||
else
|
||||
writeline (thisline[1], stdout, 2);
|
||||
}
|
||||
|
||||
/* Step the file the line came from.
|
||||
If the files match, step both files. */
|
||||
if (order >= 0)
|
||||
{
|
||||
thisline[1] = readlinebuffer (thisline[1], streams[1]);
|
||||
if (ferror (streams[1]))
|
||||
error (EXIT_FAILURE, errno, "%s", infiles[1]);
|
||||
}
|
||||
if (0 <= order)
|
||||
fill_up[1] = true;
|
||||
if (order <= 0)
|
||||
{
|
||||
thisline[0] = readlinebuffer (thisline[0], streams[0]);
|
||||
if (ferror (streams[0]))
|
||||
error (EXIT_FAILURE, errno, "%s", infiles[0]);
|
||||
}
|
||||
fill_up[0] = true;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
if (fill_up[i])
|
||||
{
|
||||
/* Rotate the buffers for this file. */
|
||||
alt[i][2] = alt[i][1];
|
||||
alt[i][1] = alt[i][0];
|
||||
alt[i][0] = (alt[i][0] + 1) & 0x03;
|
||||
|
||||
thisline[i] = readlinebuffer (all_line[i][alt[i][0]], streams[i]);
|
||||
|
||||
if (thisline[i])
|
||||
check_order (all_line[i][alt[i][1]], thisline[i], i + 1);
|
||||
|
||||
/* If this is the end of the file we may need to re-check
|
||||
the order of the previous two lines, since we might have
|
||||
discovered an unpairable match since we checked before. */
|
||||
else if (all_line[i][alt[i][2]]->buffer)
|
||||
check_order (all_line[i][alt[i][2]],
|
||||
all_line[i][alt[i][1]], i + 1);
|
||||
|
||||
if (ferror (streams[i]))
|
||||
error (EXIT_FAILURE, errno, "%s", infiles[i]);
|
||||
|
||||
fill_up[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
@@ -228,7 +351,7 @@ main (int argc, char **argv)
|
||||
int c;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -240,6 +363,10 @@ main (int argc, char **argv)
|
||||
only_file_2 = true;
|
||||
both = true;
|
||||
|
||||
seen_unpairable = false;
|
||||
issued_disorder_warning[0] = issued_disorder_warning[1] = false;
|
||||
check_input_order = CHECK_ORDER_DEFAULT;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "123", long_options, NULL)) != -1)
|
||||
switch (c)
|
||||
{
|
||||
@@ -255,6 +382,25 @@ main (int argc, char **argv)
|
||||
both = false;
|
||||
break;
|
||||
|
||||
case NOCHECK_ORDER_OPTION:
|
||||
check_input_order = CHECK_ORDER_DISABLED;
|
||||
break;
|
||||
|
||||
case CHECK_ORDER_OPTION:
|
||||
check_input_order = CHECK_ORDER_ENABLED;
|
||||
break;
|
||||
|
||||
case OUTPUT_DELIMITER_OPTION:
|
||||
if (delimiter && !STREQ (delimiter, optarg))
|
||||
error (EXIT_FAILURE, 0, _("multiple delimiters specified"));
|
||||
delimiter = optarg;
|
||||
if (!*delimiter)
|
||||
{
|
||||
error (EXIT_FAILURE, 0, _("empty %s not allowed"),
|
||||
quote ("--output-delimiter"));
|
||||
}
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
@@ -278,7 +424,14 @@ main (int argc, char **argv)
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* The default delimiter is a TAB. */
|
||||
if (!delimiter)
|
||||
delimiter = "\t";
|
||||
|
||||
compare_files (argv + optind);
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
if (issued_disorder_warning[0] || issued_disorder_warning[1])
|
||||
exit (EXIT_FAILURE);
|
||||
else
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
24
src/copy.c
24
src/copy.c
@@ -1,5 +1,5 @@
|
||||
/* copy.c -- core functions for copying files and directories
|
||||
Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-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
|
||||
@@ -65,6 +65,16 @@
|
||||
# define lchown(name, uid, gid) chown (name, uid, gid)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKFIFO
|
||||
static int
|
||||
rpl_mkfifo (char const *file, mode_t mode)
|
||||
{
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
# define mkfifo rpl_mkfifo
|
||||
#endif
|
||||
|
||||
#ifndef USE_ACL
|
||||
# define USE_ACL 0
|
||||
#endif
|
||||
@@ -97,9 +107,6 @@ static bool owner_failure_ok (struct cp_options const *x);
|
||||
static char const *top_level_src_name;
|
||||
static char const *top_level_dst_name;
|
||||
|
||||
/* The invocation name of this program. */
|
||||
extern char *program_name;
|
||||
|
||||
/* FIXME: describe */
|
||||
/* FIXME: rewrite this to use a hash table so we avoid the quadratic
|
||||
performance hit that's probably noticeable only on trees deeper
|
||||
@@ -1339,11 +1346,12 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
new_dst = true;
|
||||
}
|
||||
else if (! S_ISDIR (dst_sb.st_mode)
|
||||
/* Never unlink dst_name when in move mode. */
|
||||
&& ! x->move_mode
|
||||
&& (x->unlink_dest_before_opening
|
||||
|| (x->preserve_links && 1 < dst_sb.st_nlink)
|
||||
|| (!x->move_mode
|
||||
&& x->dereference == DEREF_NEVER
|
||||
&& S_ISLNK (src_sb.st_mode))
|
||||
|| (x->dereference == DEREF_NEVER
|
||||
&& ! S_ISREG (src_sb.st_mode))
|
||||
))
|
||||
{
|
||||
if (unlink (dst_name) != 0 && errno != ENOENT)
|
||||
@@ -1827,9 +1835,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
does not. But fall back on mkfifo, because on some BSD systems,
|
||||
mknod always fails when asked to create a FIFO. */
|
||||
if (mknod (dst_name, src_mode & ~omitted_permissions, 0) != 0)
|
||||
#if HAVE_MKFIFO
|
||||
if (mkfifo (dst_name, src_mode & ~S_IFIFO & ~omitted_permissions) != 0)
|
||||
#endif
|
||||
{
|
||||
error (0, errno, _("cannot create fifo %s"), quote (dst_name));
|
||||
goto un_backup;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* core functions for copying files and directories
|
||||
Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cp-hash.c -- file copying (hash search routines)
|
||||
Copyright (C) 89, 90, 91, 1995-2005 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-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
|
||||
|
||||
18
src/cp.c
18
src/cp.c
@@ -1,5 +1,5 @@
|
||||
/* cp.c -- file copying (main routines)
|
||||
Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-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
|
||||
@@ -52,7 +52,10 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cp"
|
||||
|
||||
#define AUTHORS "Torbjorn Granlund", "David MacKenzie", "Jim Meyering"
|
||||
#define AUTHORS \
|
||||
proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
/* Used by do_copy, make_dir_parents_private, and re_protect
|
||||
to keep a list of leading directories whose protections
|
||||
@@ -85,9 +88,6 @@ enum
|
||||
/* Initial number of entries in the inode hash table. */
|
||||
#define INITIAL_ENTRY_TAB_SIZE 70
|
||||
|
||||
/* The invocation name of this program. */
|
||||
char *program_name;
|
||||
|
||||
/* True if the kernel is SELinux enabled. */
|
||||
static bool selinux_enabled;
|
||||
|
||||
@@ -235,9 +235,9 @@ corresponding DEST file is made sparse as well. That is the behavior\n\
|
||||
selected by --sparse=auto. Specify --sparse=always to create a sparse DEST\n\
|
||||
file whenever the SOURCE file contains a long enough sequence of zero bytes.\n\
|
||||
Use --sparse=never to inhibit creation of sparse files.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\
|
||||
The version control method may be selected via the --backup option or through\n\
|
||||
the VERSION_CONTROL environment variable. Here are the values:\n\
|
||||
@@ -592,7 +592,7 @@ do_copy (int n_files, char **file, const char *target_directory,
|
||||
{
|
||||
if (target_directory)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("Cannot combine --target-directory (-t) "
|
||||
_("cannot combine --target-directory (-t) "
|
||||
"and --no-target-directory (-T)"));
|
||||
if (2 < n_files)
|
||||
{
|
||||
@@ -895,7 +895,7 @@ main (int argc, char **argv)
|
||||
bool no_target_directory = false;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -920,7 +920,7 @@ main (int argc, char **argv)
|
||||
sparse_type_string, sparse_type);
|
||||
break;
|
||||
|
||||
case 'a': /* Like -dpPR. */
|
||||
case 'a': /* Like -dpR. */
|
||||
x.dereference = DEREF_NEVER;
|
||||
x.preserve_links = true;
|
||||
x.preserve_ownership = true;
|
||||
|
||||
12
src/csplit.c
12
src/csplit.c
@@ -1,5 +1,5 @@
|
||||
/* csplit - split a file into sections determined by context lines
|
||||
Copyright (C) 91, 1995-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-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
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "error.h"
|
||||
#include "fd-reopen.h"
|
||||
#include "inttostr.h"
|
||||
#include "quote.h"
|
||||
#include "safe-read.h"
|
||||
#include "stdio--.h"
|
||||
@@ -49,7 +48,9 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "csplit"
|
||||
|
||||
#define AUTHORS "Stuart Kemp", "David MacKenzie"
|
||||
#define AUTHORS \
|
||||
proper_name ("Stuart Kemp"), \
|
||||
proper_name ("David MacKenzie")
|
||||
|
||||
/* Increment size of area for control records. */
|
||||
#define ALLOC_SIZE 20
|
||||
@@ -126,9 +127,6 @@ static void delete_all_files (bool);
|
||||
static void save_line_to_file (const struct cstring *line);
|
||||
void usage (int status);
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* Start of buffer list. */
|
||||
static struct buffer_record *head = NULL;
|
||||
|
||||
@@ -1328,7 +1326,7 @@ main (int argc, char **argv)
|
||||
unsigned long int val;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
17
src/cut.c
17
src/cut.c
@@ -1,5 +1,5 @@
|
||||
/* cut - remove parts of lines of files
|
||||
Copyright (C) 1997-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984 David M. Ihnat
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -39,7 +39,10 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cut"
|
||||
|
||||
#define AUTHORS "David Ihnat", "David MacKenzie", "Jim Meyering"
|
||||
#define AUTHORS \
|
||||
proper_name ("David M. Ihnat"), \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
#define FATAL_ERROR(Message) \
|
||||
do \
|
||||
@@ -117,9 +120,6 @@ enum operating_mode
|
||||
field_mode
|
||||
};
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
static enum operating_mode operating_mode;
|
||||
|
||||
/* If true do not output lines containing no delimeter characters.
|
||||
@@ -210,7 +210,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--complement complement the set of selected bytes, characters\n\
|
||||
or fields.\n\
|
||||
or fields\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-s, --only-delimited do not print lines not containing delimiters\n\
|
||||
@@ -372,7 +372,8 @@ set_fields (const char *fieldstr)
|
||||
initial = (lhs_specified ? value : 1);
|
||||
value = 0;
|
||||
}
|
||||
else if (*fieldstr == ',' || isblank (*fieldstr) || *fieldstr == '\0')
|
||||
else if (*fieldstr == ',' ||
|
||||
isblank (to_uchar (*fieldstr)) || *fieldstr == '\0')
|
||||
{
|
||||
in_digits = false;
|
||||
/* Ending the string, or this field/byte sublist. */
|
||||
@@ -758,7 +759,7 @@ main (int argc, char **argv)
|
||||
char *spec_list_string IF_LINT(= NULL);
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
24
src/date.c
24
src/date.c
@@ -1,5 +1,5 @@
|
||||
/* date - print or set the system date and time
|
||||
Copyright (C) 1989-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-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
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "argmatch.h"
|
||||
#include "error.h"
|
||||
#include "getdate.h"
|
||||
#include "inttostr.h"
|
||||
#include "posixtm.h"
|
||||
#include "quote.h"
|
||||
#include "stat-time.h"
|
||||
@@ -37,7 +36,7 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "date"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
#define AUTHORS proper_name ("David MacKenzie")
|
||||
|
||||
int putenv ();
|
||||
|
||||
@@ -77,9 +76,6 @@ ARGMATCH_VERIFY (time_spec_string, time_spec);
|
||||
/* A format suitable for Internet RFC 2822. */
|
||||
static char const rfc_2822_format[] = "%a, %d %b %Y %H:%M:%S %z";
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
@@ -156,8 +152,7 @@ Display the current time in the given FORMAT, or set the system date.\n\
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
FORMAT controls the output. The only valid option for the second form\n\
|
||||
specifies Coordinated Universal Time. Interpreted sequences are:\n\
|
||||
FORMAT controls the output. Interpreted sequences are:\n\
|
||||
\n\
|
||||
%% a literal %\n\
|
||||
%a locale's abbreviated weekday name (e.g., Sun)\n\
|
||||
@@ -169,7 +164,7 @@ specifies Coordinated Universal Time. Interpreted sequences are:\n\
|
||||
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
%C century; like %Y, except omit last two digits (e.g., 21)\n\
|
||||
%C century; like %Y, except omit last two digits (e.g., 20)\n\
|
||||
%d day of month (e.g, 01)\n\
|
||||
%D date; same as %m/%d/%y\n\
|
||||
%e day of month, space padded; same as %_d\n\
|
||||
@@ -325,7 +320,7 @@ main (int argc, char **argv)
|
||||
int option_specified_date;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -444,8 +439,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
error (0, 0,
|
||||
_("the argument %s lacks a leading `+';\n"
|
||||
"When using an option to specify date(s), any non-option\n"
|
||||
"argument must be a format string beginning with `+'."),
|
||||
"when using an option to specify date(s), any non-option\n"
|
||||
"argument must be a format string beginning with `+'"),
|
||||
quote (argv[optind]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
@@ -543,10 +538,7 @@ show_date (const char *format, struct timespec when)
|
||||
if (! tm)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
error (0, 0, _("time %s is out of range"),
|
||||
(TYPE_SIGNED (time_t)
|
||||
? imaxtostr (when.tv_sec, buf)
|
||||
: umaxtostr (when.tv_sec, buf)));
|
||||
error (0, 0, _("time %s is out of range"), timetostr (when.tv_sec, buf));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
210
src/dd.c
210
src/dd.c
@@ -1,5 +1,5 @@
|
||||
/* dd -- convert a file while copying it.
|
||||
Copyright (C) 85, 90, 91, 1995-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 85, 90, 91, 1995-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
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "human.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "xstrtol.h"
|
||||
#include "xtime.h"
|
||||
|
||||
@@ -39,7 +40,10 @@ static void process_signals (void);
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dd"
|
||||
|
||||
#define AUTHORS "Paul Rubin", "David MacKenzie", "Stuart Kemp"
|
||||
#define AUTHORS \
|
||||
proper_name ("Paul Rubin"), \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Stuart Kemp")
|
||||
|
||||
/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
|
||||
present. SA_NODEFER and SA_RESETHAND are XSI extensions. */
|
||||
@@ -124,9 +128,6 @@ enum
|
||||
STATUS_NOXFER = 01
|
||||
};
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* The name of the input file, or NULL for the standard input. */
|
||||
static char const *input_file = NULL;
|
||||
|
||||
@@ -224,6 +225,9 @@ static sig_atomic_t volatile interrupt_signal;
|
||||
/* A count of the number of pending info signals that have been received. */
|
||||
static sig_atomic_t volatile info_signal_count;
|
||||
|
||||
/* Function used for read (to handle iflag=fullblock parameter). */
|
||||
static ssize_t (*iread_fnc) (int fd, char *buf, size_t size);
|
||||
|
||||
/* A longest symbol in the struct symbol_values tables below. */
|
||||
#define LONGEST_SYMBOL "fdatasync"
|
||||
|
||||
@@ -255,6 +259,30 @@ static struct symbol_value const conversions[] =
|
||||
{"", 0}
|
||||
};
|
||||
|
||||
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)
|
||||
};
|
||||
|
||||
/* Ensure that we didn't shift it off the end. */
|
||||
verify (O_FULLBLOCK != 0);
|
||||
|
||||
#define MULTIPLE_BITS_SET(i) (((i) & ((i) - 1)) != 0)
|
||||
|
||||
/* Ensure that this is a single-bit value. */
|
||||
verify ( ! MULTIPLE_BITS_SET (O_FULLBLOCK));
|
||||
|
||||
/* Flags, for iflag="..." and oflag="...". */
|
||||
static struct symbol_value const flags[] =
|
||||
{
|
||||
@@ -270,6 +298,7 @@ static struct symbol_value const flags[] =
|
||||
{"nonblock", O_NONBLOCK},
|
||||
{"sync", O_SYNC},
|
||||
{"text", O_TEXT},
|
||||
{"fullblock", O_FULLBLOCK}, /* Accumulate full blocks from input. */
|
||||
{"", 0}
|
||||
};
|
||||
|
||||
@@ -391,6 +420,25 @@ static char const ebcdic_to_ascii[] =
|
||||
'\070', '\071', '\372', '\373', '\374', '\375', '\376', '\377'
|
||||
};
|
||||
|
||||
/* True if we need to close the standard output *stream*. */
|
||||
static bool close_stdout_required = true;
|
||||
|
||||
/* The only reason to close the standard output *stream* is if
|
||||
parse_long_options fails (as it does for --help or --version).
|
||||
In any other case, dd uses only the STDOUT_FILENO file descriptor,
|
||||
and the "cleanup" function calls "close (STDOUT_FILENO)".
|
||||
Closing the file descriptor and then letting the usual atexit-run
|
||||
close_stdout function call "fclose (stdout)" would result in a
|
||||
harmless failure of the close syscall (with errno EBADF).
|
||||
This function serves solely to avoid the unnecessary close_stdout
|
||||
call, once parse_long_options has succeeded. */
|
||||
static void
|
||||
maybe_close_stdout (void)
|
||||
{
|
||||
if (close_stdout_required)
|
||||
close_stdout ();
|
||||
}
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -426,8 +474,8 @@ Copy a file, converting and formatting according to the operands.\n\
|
||||
fputs (_("\
|
||||
\n\
|
||||
BLOCKS and BYTES may be followed by the following multiplicative suffixes:\n\
|
||||
xM M, c 1, w 2, b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,\n\
|
||||
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.\n\
|
||||
c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M\n\
|
||||
GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.\n\
|
||||
\n\
|
||||
Each CONV symbol may be:\n\
|
||||
\n\
|
||||
@@ -463,11 +511,13 @@ Each FLAG symbol may be:\n\
|
||||
if (O_DIRECT)
|
||||
fputs (_(" direct use direct I/O for data\n"), stdout);
|
||||
if (O_DIRECTORY)
|
||||
fputs (_(" directory fail unless a directory\n"), stdout);
|
||||
fputs (_(" directory fail unless a directory\n"), stdout);
|
||||
if (O_DSYNC)
|
||||
fputs (_(" dsync use synchronized I/O for data\n"), stdout);
|
||||
if (O_SYNC)
|
||||
fputs (_(" sync likewise, but also for metadata\n"), stdout);
|
||||
fputs (_(" fullblock accumulate full blocks of input (iflag only)\n"),
|
||||
stdout);
|
||||
if (O_NONBLOCK)
|
||||
fputs (_(" nonblock use non-blocking I/O\n"), stdout);
|
||||
if (O_NOATIME)
|
||||
@@ -525,7 +575,7 @@ translate_charset (char const *new_trans)
|
||||
static inline bool
|
||||
multiple_bits_set (int i)
|
||||
{
|
||||
return (i & (i - 1)) != 0;
|
||||
return MULTIPLE_BITS_SET (i);
|
||||
}
|
||||
|
||||
/* Print transfer statistics. */
|
||||
@@ -742,6 +792,27 @@ iread (int fd, char *buf, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
/* Wrapper around iread function to accumulate full blocks. */
|
||||
static ssize_t
|
||||
iread_fullblock (int fd, char *buf, size_t size)
|
||||
{
|
||||
ssize_t nread = 0;
|
||||
|
||||
while (0 < size)
|
||||
{
|
||||
ssize_t ncurr = iread (fd, buf, size);
|
||||
if (ncurr < 0)
|
||||
return ncurr;
|
||||
if (ncurr == 0)
|
||||
break;
|
||||
nread += ncurr;
|
||||
buf += ncurr;
|
||||
size -= ncurr;
|
||||
}
|
||||
|
||||
return nread;
|
||||
}
|
||||
|
||||
/* Write to FD the buffer BUF of size SIZE, processing any signals
|
||||
that arrive. Return the number of bytes written, setting errno if
|
||||
this is less than SIZE. Keep trying if there are partial
|
||||
@@ -796,41 +867,50 @@ write_output (void)
|
||||
oc = 0;
|
||||
}
|
||||
|
||||
/* Return true if STR is of the form "PATTERN" or "PATTERNDELIM...". */
|
||||
|
||||
static bool
|
||||
operand_matches (char const *str, char const *pattern, char delim)
|
||||
{
|
||||
while (*pattern)
|
||||
if (*str++ != *pattern++)
|
||||
return false;
|
||||
return !*str || *str == delim;
|
||||
}
|
||||
|
||||
/* Interpret one "conv=..." or similar operand STR according to the
|
||||
symbols in TABLE, returning the flags specified. If the operand
|
||||
cannot be parsed, use ERROR_MSGID to generate a diagnostic.
|
||||
As a by product, this function replaces each `,' in STR with a NUL byte. */
|
||||
cannot be parsed, use ERROR_MSGID to generate a diagnostic. */
|
||||
|
||||
static int
|
||||
parse_symbols (char *str, struct symbol_value const *table,
|
||||
parse_symbols (char const *str, struct symbol_value const *table,
|
||||
char const *error_msgid)
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
do
|
||||
for (;;)
|
||||
{
|
||||
char const *strcomma = strchr (str, ',');
|
||||
struct symbol_value const *entry;
|
||||
char *new = strchr (str, ',');
|
||||
if (new != NULL)
|
||||
*new++ = '\0';
|
||||
for (entry = table; ; entry++)
|
||||
|
||||
for (entry = table;
|
||||
! (operand_matches (str, entry->symbol, ',') && entry->value);
|
||||
entry++)
|
||||
{
|
||||
if (! entry->symbol[0])
|
||||
{
|
||||
error (0, 0, _(error_msgid), quote (str));
|
||||
size_t slen = strcomma ? strcomma - str : strlen (str);
|
||||
error (0, 0, "%s: %s", _(error_msgid),
|
||||
quotearg_n_style_mem (0, locale_quoting_style, str, slen));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
if (STREQ (entry->symbol, str))
|
||||
{
|
||||
if (! entry->value)
|
||||
error (EXIT_FAILURE, 0, _(error_msgid), quote (str));
|
||||
value |= entry->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
str = new;
|
||||
|
||||
value |= entry->value;
|
||||
if (!strcomma)
|
||||
break;
|
||||
str = strcomma + 1;
|
||||
}
|
||||
while (str);
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -867,78 +947,84 @@ parse_integer (const char *str, bool *invalid)
|
||||
return n;
|
||||
}
|
||||
|
||||
/* OPERAND is of the form "X=...". Return true if X is NAME. */
|
||||
|
||||
static bool
|
||||
operand_is (char const *operand, char const *name)
|
||||
{
|
||||
return operand_matches (operand, name, '=');
|
||||
}
|
||||
|
||||
static void
|
||||
scanargs (int argc, char **argv)
|
||||
scanargs (int argc, char *const *argv)
|
||||
{
|
||||
int i;
|
||||
size_t blocksize = 0;
|
||||
|
||||
for (i = optind; i < argc; i++)
|
||||
{
|
||||
char *name, *val;
|
||||
char const *name = argv[i];
|
||||
char const *val = strchr (name, '=');
|
||||
|
||||
name = argv[i];
|
||||
val = strchr (name, '=');
|
||||
if (val == NULL)
|
||||
{
|
||||
error (0, 0, _("unrecognized operand %s"), quote (name));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
*val++ = '\0';
|
||||
val++;
|
||||
|
||||
if (STREQ (name, "if"))
|
||||
if (operand_is (name, "if"))
|
||||
input_file = val;
|
||||
else if (STREQ (name, "of"))
|
||||
else if (operand_is (name, "of"))
|
||||
output_file = val;
|
||||
else if (STREQ (name, "conv"))
|
||||
else if (operand_is (name, "conv"))
|
||||
conversions_mask |= parse_symbols (val, conversions,
|
||||
N_("invalid conversion: %s"));
|
||||
else if (STREQ (name, "iflag"))
|
||||
N_("invalid conversion"));
|
||||
else if (operand_is (name, "iflag"))
|
||||
input_flags |= parse_symbols (val, flags,
|
||||
N_("invalid input flag: %s"));
|
||||
else if (STREQ (name, "oflag"))
|
||||
N_("invalid input flag"));
|
||||
else if (operand_is (name, "oflag"))
|
||||
output_flags |= parse_symbols (val, flags,
|
||||
N_("invalid output flag: %s"));
|
||||
else if (STREQ (name, "status"))
|
||||
N_("invalid output flag"));
|
||||
else if (operand_is (name, "status"))
|
||||
status_flags |= parse_symbols (val, statuses,
|
||||
N_("invalid status flag: %s"));
|
||||
N_("invalid status flag"));
|
||||
else
|
||||
{
|
||||
bool invalid = false;
|
||||
uintmax_t n = parse_integer (val, &invalid);
|
||||
|
||||
if (STREQ (name, "ibs"))
|
||||
if (operand_is (name, "ibs"))
|
||||
{
|
||||
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP));
|
||||
input_blocksize = n;
|
||||
conversions_mask |= C_TWOBUFS;
|
||||
}
|
||||
else if (STREQ (name, "obs"))
|
||||
else if (operand_is (name, "obs"))
|
||||
{
|
||||
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (OUTPUT_BLOCK_SLOP));
|
||||
output_blocksize = n;
|
||||
conversions_mask |= C_TWOBUFS;
|
||||
}
|
||||
else if (STREQ (name, "bs"))
|
||||
else if (operand_is (name, "bs"))
|
||||
{
|
||||
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP));
|
||||
blocksize = n;
|
||||
}
|
||||
else if (STREQ (name, "cbs"))
|
||||
else if (operand_is (name, "cbs"))
|
||||
{
|
||||
invalid |= ! (0 < n && n <= SIZE_MAX);
|
||||
conversion_blocksize = n;
|
||||
}
|
||||
else if (STREQ (name, "skip"))
|
||||
else if (operand_is (name, "skip"))
|
||||
skip_records = n;
|
||||
else if (STREQ (name, "seek"))
|
||||
else if (operand_is (name, "seek"))
|
||||
seek_records = n;
|
||||
else if (STREQ (name, "count"))
|
||||
else if (operand_is (name, "count"))
|
||||
max_records = n;
|
||||
else
|
||||
{
|
||||
error (0, 0, _("unrecognized operand %s=%s"),
|
||||
quote_n (0, name), quote_n (1, val));
|
||||
error (0, 0, _("unrecognized operand %s"), quote (name));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -965,6 +1051,16 @@ scanargs (int argc, char **argv)
|
||||
if (input_flags & (O_DSYNC | O_SYNC))
|
||||
input_flags |= O_RSYNC;
|
||||
|
||||
if (output_flags & O_FULLBLOCK)
|
||||
{
|
||||
error (0, 0, "%s: %s", _("invalid output flag"), "'fullblock'");
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
iread_fnc = ((input_flags & O_FULLBLOCK)
|
||||
? iread_fullblock
|
||||
: iread);
|
||||
input_flags &= ~O_FULLBLOCK;
|
||||
|
||||
if (multiple_bits_set (conversions_mask & (C_ASCII | C_EBCDIC | C_IBM)))
|
||||
error (EXIT_FAILURE, 0, _("cannot combine any two of {ascii,ebcdic,ibm}"));
|
||||
if (multiple_bits_set (conversions_mask & (C_BLOCK | C_UNBLOCK)))
|
||||
@@ -1162,7 +1258,7 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize,
|
||||
|
||||
do
|
||||
{
|
||||
ssize_t nread = iread (fdesc, buf, blocksize);
|
||||
ssize_t nread = iread_fnc (fdesc, buf, blocksize);
|
||||
if (nread < 0)
|
||||
{
|
||||
if (fdesc == STDIN_FILENO)
|
||||
@@ -1473,7 +1569,7 @@ dd_copy (void)
|
||||
(conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0',
|
||||
input_blocksize);
|
||||
|
||||
nread = iread (STDIN_FILENO, ibuf, input_blocksize);
|
||||
nread = iread_fnc (STDIN_FILENO, ibuf, input_blocksize);
|
||||
|
||||
if (nread == 0)
|
||||
break; /* EOF. */
|
||||
@@ -1633,18 +1729,20 @@ main (int argc, char **argv)
|
||||
off_t offset;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
/* Arrange to close stdout if parse_long_options exits. */
|
||||
atexit (close_stdout);
|
||||
atexit (maybe_close_stdout);
|
||||
|
||||
page_size = getpagesize ();
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
close_stdout_required = false;
|
||||
|
||||
if (getopt_long (argc, argv, "", NULL, NULL) != -1)
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
|
||||
93
src/df.c
93
src/df.c
@@ -1,5 +1,5 @@
|
||||
/* df - summarize free disk space
|
||||
Copyright (C) 91, 1995-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-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
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "error.h"
|
||||
#include "fsusage.h"
|
||||
#include "human.h"
|
||||
#include "inttostr.h"
|
||||
#include "mountlist.h"
|
||||
#include "quote.h"
|
||||
#include "save-cwd.h"
|
||||
@@ -38,10 +37,9 @@
|
||||
#define PROGRAM_NAME "df"
|
||||
|
||||
#define AUTHORS \
|
||||
"Torbjorn Granlund", "David MacKenzie", "Paul Eggert"
|
||||
|
||||
/* Name this program was run with. */
|
||||
char *program_name;
|
||||
proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Paul Eggert")
|
||||
|
||||
/* If true, show inode information. */
|
||||
static bool inode_format;
|
||||
@@ -110,6 +108,12 @@ static struct mount_entry *mount_list;
|
||||
/* If true, print file system type as well. */
|
||||
static bool print_type;
|
||||
|
||||
/* If true, print a grand total at the end. */
|
||||
static bool print_grand_total;
|
||||
|
||||
/* Grand total data. */
|
||||
static struct fs_usage grand_fsu;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
@@ -131,6 +135,7 @@ static struct option const long_options[] =
|
||||
{"print-type", no_argument, NULL, 'T'},
|
||||
{"sync", no_argument, NULL, SYNC_OPTION},
|
||||
{"no-sync", no_argument, NULL, NO_SYNC_OPTION},
|
||||
{"total", no_argument, NULL, 'c'},
|
||||
{"type", required_argument, NULL, 't'},
|
||||
{"exclude-type", required_argument, NULL, 'x'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
@@ -249,6 +254,41 @@ df_readable (bool negative, uintmax_t n, char *buf,
|
||||
}
|
||||
}
|
||||
|
||||
/* Logical equivalence */
|
||||
#define LOG_EQ(a, b) (!(a) == !(b))
|
||||
|
||||
/* Add integral value while using uintmax_t for value part and separate
|
||||
negation flag. It adds value of SRC and SRC_NEG to DEST and DEST_NEG.
|
||||
The result will be in DEST and DEST_NEG. See df_readable to understand
|
||||
how the negation flag is used. */
|
||||
static void
|
||||
add_uint_with_neg_flag (uintmax_t *dest, bool *dest_neg,
|
||||
uintmax_t src, bool src_neg)
|
||||
{
|
||||
if (LOG_EQ (*dest_neg, src_neg))
|
||||
{
|
||||
*dest += src;
|
||||
return;
|
||||
}
|
||||
|
||||
if (*dest_neg)
|
||||
*dest = -*dest;
|
||||
|
||||
if (src_neg)
|
||||
src = -src;
|
||||
|
||||
if (src < *dest)
|
||||
*dest -= src;
|
||||
else
|
||||
{
|
||||
*dest = src - *dest;
|
||||
*dest_neg = src_neg;
|
||||
}
|
||||
|
||||
if (*dest_neg)
|
||||
*dest = -*dest;
|
||||
}
|
||||
|
||||
/* Display a space listing for the disk device with absolute file name DISK.
|
||||
If MOUNT_POINT is non-NULL, it is the name of the root of the
|
||||
file system on DISK.
|
||||
@@ -265,7 +305,8 @@ df_readable (bool negative, uintmax_t n, char *buf,
|
||||
static void
|
||||
show_dev (char const *disk, char const *mount_point,
|
||||
char const *stat_file, char const *fstype,
|
||||
bool me_dummy, bool me_remote)
|
||||
bool me_dummy, bool me_remote,
|
||||
const struct fs_usage *force_fsu)
|
||||
{
|
||||
struct fs_usage fsu;
|
||||
char buf[3][LONGEST_HUMAN_READABLE + 2];
|
||||
@@ -298,7 +339,9 @@ show_dev (char const *disk, char const *mount_point,
|
||||
if (!stat_file)
|
||||
stat_file = mount_point ? mount_point : disk;
|
||||
|
||||
if (get_fs_usage (stat_file, disk, &fsu))
|
||||
if (force_fsu)
|
||||
fsu = *force_fsu;
|
||||
else if (get_fs_usage (stat_file, disk, &fsu))
|
||||
{
|
||||
error (0, errno, "%s", quote (stat_file));
|
||||
exit_status = EXIT_FAILURE;
|
||||
@@ -349,6 +392,9 @@ show_dev (char const *disk, char const *mount_point,
|
||||
available = fsu.fsu_ffree;
|
||||
negate_available = false;
|
||||
available_to_root = available;
|
||||
|
||||
grand_fsu.fsu_files += total;
|
||||
grand_fsu.fsu_ffree += available;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -375,6 +421,12 @@ show_dev (char const *disk, char const *mount_point,
|
||||
negate_available = (fsu.fsu_bavail_top_bit_set
|
||||
& (available != UINTMAX_MAX));
|
||||
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);
|
||||
}
|
||||
|
||||
used = UINTMAX_MAX;
|
||||
@@ -552,7 +604,7 @@ show_disk (char const *disk)
|
||||
{
|
||||
show_dev (best_match->me_devname, best_match->me_mountdir, NULL,
|
||||
best_match->me_type, best_match->me_dummy,
|
||||
best_match->me_remote);
|
||||
best_match->me_remote, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -656,7 +708,8 @@ show_point (const char *point, const struct stat *statp)
|
||||
|
||||
if (best_match)
|
||||
show_dev (best_match->me_devname, best_match->me_mountdir, point,
|
||||
best_match->me_type, best_match->me_dummy, best_match->me_remote);
|
||||
best_match->me_type, best_match->me_dummy, best_match->me_remote,
|
||||
NULL);
|
||||
else
|
||||
{
|
||||
/* We couldn't find the mount entry corresponding to POINT. Go ahead and
|
||||
@@ -667,7 +720,7 @@ show_point (const char *point, const struct stat *statp)
|
||||
char *mp = find_mount_point (point, statp);
|
||||
if (mp)
|
||||
{
|
||||
show_dev (NULL, mp, NULL, NULL, false, false);
|
||||
show_dev (NULL, mp, NULL, NULL, false, false, NULL);
|
||||
free (mp);
|
||||
}
|
||||
}
|
||||
@@ -696,7 +749,7 @@ show_all_entries (void)
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
show_dev (me->me_devname, me->me_mountdir, NULL, me->me_type,
|
||||
me->me_dummy, me->me_remote);
|
||||
me->me_dummy, me->me_remote, NULL);
|
||||
}
|
||||
|
||||
/* Add FSTYPE to the list of file system types to display. */
|
||||
@@ -745,6 +798,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
fputs (_("\
|
||||
-a, --all include dummy file systems\n\
|
||||
-B, --block-size=SIZE use SIZE-byte blocks\n\
|
||||
--total produce a grand total\n\
|
||||
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
|
||||
-H, --si likewise, but use powers of 1000 not 1024\n\
|
||||
"), stdout);
|
||||
@@ -779,7 +833,7 @@ main (int argc, char **argv)
|
||||
struct stat *stats IF_LINT (= 0);
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -796,6 +850,8 @@ main (int argc, char **argv)
|
||||
file_systems_processed = false;
|
||||
posix_format = false;
|
||||
exit_status = EXIT_SUCCESS;
|
||||
print_grand_total = false;
|
||||
grand_fsu.fsu_blocksize = 1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -866,6 +922,10 @@ main (int argc, char **argv)
|
||||
add_excluded_fs_type (optarg);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
print_grand_total = true;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
@@ -961,6 +1021,13 @@ main (int argc, char **argv)
|
||||
else
|
||||
show_all_entries ();
|
||||
|
||||
if (print_grand_total)
|
||||
{
|
||||
if (inode_format)
|
||||
grand_fsu.fsu_blocks = 1;
|
||||
show_dev ("total", NULL, NULL, NULL, false, false, &grand_fsu);
|
||||
}
|
||||
|
||||
if (! file_systems_processed)
|
||||
error (EXIT_FAILURE, 0, _("no file systems processed"));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* dircolors - output commands to set the LS_COLOR environment variable
|
||||
Copyright (C) 1996-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000 H. Peter Anvin
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -32,7 +32,7 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dircolors"
|
||||
|
||||
#define AUTHORS "H. Peter Anvin"
|
||||
#define AUTHORS proper_name ("H. Peter Anvin")
|
||||
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
@@ -59,18 +59,18 @@ static struct obstack lsc_obstack;
|
||||
|
||||
static const char *const slack_codes[] =
|
||||
{
|
||||
"NORMAL", "NORM", "FILE", "DIR", "LNK", "LINK",
|
||||
"NORMAL", "NORM", "FILE", "RESET", "DIR", "LNK", "LINK",
|
||||
"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", NULL
|
||||
"OTHER_WRITABLE", "OWR", "STICKY_OTHER_WRITABLE", "OWT", "CAPABILITY", NULL
|
||||
};
|
||||
|
||||
static const char *const ls_codes[] =
|
||||
{
|
||||
"no", "no", "fi", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi",
|
||||
"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", NULL
|
||||
"su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", "ca", NULL
|
||||
};
|
||||
#define array_len(Array) (sizeof (Array) / sizeof *(Array))
|
||||
verify (array_len (slack_codes) == array_len (ls_codes));
|
||||
@@ -87,8 +87,6 @@ static struct option const long_options[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
char *program_name;
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -402,7 +400,7 @@ main (int argc, char **argv)
|
||||
bool print_database = false;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -450,8 +448,8 @@ to select a shell syntax are mutually exclusive"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[!print_database]));
|
||||
if (print_database)
|
||||
fprintf (stderr, "%s\n",
|
||||
_("File operands cannot be combined with "
|
||||
"--print-database (-p)."));
|
||||
_("file operands cannot be combined with "
|
||||
"--print-database (-p)"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Configuration file for dircolors, a utility to help you set the
|
||||
# LS_COLORS environment variable used by GNU ls with the --color option.
|
||||
|
||||
# Copyright (C) 1996, 1999-2007
|
||||
# Copyright (C) 1996, 1999-2008
|
||||
# Free Software Foundation, Inc.
|
||||
# Copying and distribution of this file, with or without modification,
|
||||
# are permitted provided the copyright notice and this notice are preserved.
|
||||
@@ -30,6 +30,7 @@ TERM dtterm
|
||||
TERM eterm-color
|
||||
TERM gnome
|
||||
TERM gnome-256color
|
||||
TERM jfbterm
|
||||
TERM konsole
|
||||
TERM kterm
|
||||
TERM linux
|
||||
@@ -62,8 +63,9 @@ TERM xterm-debian
|
||||
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
||||
# Background color codes:
|
||||
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
|
||||
NORMAL 00 # global default, although everything should be something.
|
||||
FILE 00 # normal file
|
||||
#NORMAL 00 # no color code at all
|
||||
#FILE 00 # regular file: use no color at all
|
||||
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.)
|
||||
@@ -75,6 +77,7 @@ CHR 40;33;01 # character device driver
|
||||
ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file
|
||||
SETUID 37;41 # file that is setuid (u+s)
|
||||
SETGID 30;43 # file that is setgid (g+s)
|
||||
CAPABILITY 30;41 # file with capability
|
||||
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
|
||||
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
|
||||
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
|
||||
@@ -100,7 +103,6 @@ EXEC 01;32
|
||||
# archives or compressed (bright red)
|
||||
.tar 01;31
|
||||
.tgz 01;31
|
||||
.svgz 01;31
|
||||
.arj 01;31
|
||||
.taz 01;31
|
||||
.lzh 01;31
|
||||
@@ -138,6 +140,8 @@ EXEC 01;32
|
||||
.tif 01;35
|
||||
.tiff 01;35
|
||||
.png 01;35
|
||||
.svg 01;35
|
||||
.svgz 01;35
|
||||
.mng 01;35
|
||||
.pcx 01;35
|
||||
.mov 01;35
|
||||
@@ -159,12 +163,19 @@ EXEC 01;32
|
||||
.flc 01;35
|
||||
.avi 01;35
|
||||
.fli 01;35
|
||||
.flv 01;35
|
||||
.gl 01;35
|
||||
.dl 01;35
|
||||
.xcf 01;35
|
||||
.xwd 01;35
|
||||
.yuv 01;35
|
||||
|
||||
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
|
||||
.axv 01;35
|
||||
.anx 01;35
|
||||
.ogv 01;35
|
||||
.ogx 01;35
|
||||
|
||||
# audio formats
|
||||
.aac 00;36
|
||||
.au 00;36
|
||||
@@ -177,3 +188,9 @@ EXEC 01;32
|
||||
.ogg 00;36
|
||||
.ra 00;36
|
||||
.wav 00;36
|
||||
|
||||
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
|
||||
.axa 00;36
|
||||
.oga 00;36
|
||||
.spx 00;36
|
||||
.xspf 00;36
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* dirname -- strip suffix from file name
|
||||
|
||||
Copyright (C) 1990-1997, 1999-2002, 2004-2007 Free Software
|
||||
Copyright (C) 1990-1997, 1999-2002, 2004-2008 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -31,10 +31,9 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dirname"
|
||||
|
||||
#define AUTHORS "David MacKenzie", "Jim Meyering"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
#define AUTHORS \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
@@ -76,14 +75,14 @@ main (int argc, char **argv)
|
||||
size_t len;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
40
src/du.c
40
src/du.c
@@ -1,5 +1,5 @@
|
||||
/* du -- summarize disk usage
|
||||
Copyright (C) 1988-1991, 1995-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-1991, 1995-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
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "fprintftime.h"
|
||||
#include "hash.h"
|
||||
#include "human.h"
|
||||
#include "inttostr.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "readtokens0.h"
|
||||
@@ -50,7 +49,10 @@ extern bool fts_debug;
|
||||
#define PROGRAM_NAME "du"
|
||||
|
||||
#define AUTHORS \
|
||||
"Torbjorn Granlund", "David MacKenzie, Paul Eggert", "Jim Meyering"
|
||||
proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Paul Eggert"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
#if DU_DEBUG
|
||||
# define FTS_CROSS_CHECK(Fts) fts_cross_check (Fts)
|
||||
@@ -123,9 +125,6 @@ struct dulevel
|
||||
struct duinfo subdir;
|
||||
};
|
||||
|
||||
/* Name under which this program was invoked. */
|
||||
char *program_name;
|
||||
|
||||
/* If true, display counts for all files, not just directories. */
|
||||
static bool opt_all = false;
|
||||
|
||||
@@ -312,9 +311,9 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-s, --summarize display only a total for each argument\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-x, --one-file-system skip directories on different file systems\n\
|
||||
-X FILE, --exclude-from=FILE Exclude files that match any pattern in FILE.\n\
|
||||
--exclude=PATTERN Exclude files that match PATTERN.\n\
|
||||
-x, --one-file-system skip directories on different file systems\n\
|
||||
-X, --exclude-from=FILE exclude files that match any pattern in FILE\n\
|
||||
--exclude=PATTERN exclude files that match PATTERN\n\
|
||||
--max-depth=N print the total for a directory (or file, with --all)\n\
|
||||
only if it is N or fewer levels below the command\n\
|
||||
line argument; --max-depth=0 is the same as\n\
|
||||
@@ -413,10 +412,7 @@ show_date (const char *format, struct timespec when)
|
||||
if (! tm)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
error (0, 0, _("time %s is out of range"),
|
||||
(TYPE_SIGNED (time_t)
|
||||
? imaxtostr (when.tv_sec, buf)
|
||||
: umaxtostr (when.tv_sec, buf)));
|
||||
error (0, 0, _("time %s is out of range"), timetostr (when.tv_sec, buf));
|
||||
fputs (buf, stdout);
|
||||
return;
|
||||
}
|
||||
@@ -479,7 +475,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
bool skip;
|
||||
|
||||
/* If necessary, set FTS_SKIP before returning. */
|
||||
skip = excluded_file_name (exclude, ent->fts_path);
|
||||
skip = excluded_file_name (exclude, file);
|
||||
if (skip)
|
||||
fts_set (fts, ent, FTS_SKIP);
|
||||
|
||||
@@ -682,7 +678,7 @@ main (int argc, char **argv)
|
||||
cwd_only[1] = NULL;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -937,7 +933,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
fprintf (stderr, "%s\n",
|
||||
_("File operands cannot be combined with --files0-from."));
|
||||
_("file operands cannot be combined with --files0-from"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -977,10 +973,22 @@ main (int argc, char **argv)
|
||||
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
|
||||
|
||||
42
src/echo.c
42
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 Free Software
|
||||
Copyright (C) 87,89, 1991-1997, 1999-2005, 2007-2008 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -24,35 +24,15 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "echo"
|
||||
|
||||
#define AUTHORS "FIXME unknown"
|
||||
|
||||
/* echo [-neE] [arg ...]
|
||||
Output the ARGs. If -n is specified, the trailing newline is
|
||||
suppressed. If the -e option is given, interpretation of the
|
||||
following backslash-escaped characters is turned on:
|
||||
\a alert (bell)
|
||||
\b backspace
|
||||
\c suppress trailing newline
|
||||
\f form feed
|
||||
\n new line
|
||||
\r carriage return
|
||||
\t horizontal tab
|
||||
\v vertical tab
|
||||
\\ backslash
|
||||
\0NNN the character whose ASCII code is NNN (octal).
|
||||
|
||||
You can explicitly turn off the interpretation of the above characters
|
||||
on System V systems with the -E option.
|
||||
*/
|
||||
#define AUTHORS \
|
||||
proper_name ("Brian Fox"), \
|
||||
proper_name ("Chet Ramey")
|
||||
|
||||
/* If true, interpret backslash escapes by default. */
|
||||
#ifndef DEFAULT_ECHO_TO_XPG
|
||||
enum { DEFAULT_ECHO_TO_XPG = false };
|
||||
#endif
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -68,12 +48,12 @@ Echo the STRING(s) to standard output.\n\
|
||||
-n do not output the trailing newline\n\
|
||||
"), stdout);
|
||||
fputs (_(DEFAULT_ECHO_TO_XPG
|
||||
? "\
|
||||
? N_("\
|
||||
-e enable interpretation of backslash escapes (default)\n\
|
||||
-E disable interpretation of backslash escapes\n"
|
||||
: "\
|
||||
-E disable interpretation of backslash escapes\n")
|
||||
: N_("\
|
||||
-e enable interpretation of backslash escapes\n\
|
||||
-E disable interpretation of backslash escapes (default)\n"),
|
||||
-E disable interpretation of backslash escapes (default)\n")),
|
||||
stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
@@ -87,7 +67,7 @@ If -e is in effect, the following sequences are recognized:\n\
|
||||
\\b backspace\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\\c suppress trailing newline\n\
|
||||
\\c produce no further output\n\
|
||||
\\f form feed\n\
|
||||
\\n new line\n\
|
||||
\\r carriage return\n\
|
||||
@@ -134,7 +114,7 @@ main (int argc, char **argv)
|
||||
bool do_v9 = DEFAULT_ECHO_TO_XPG;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -142,7 +122,7 @@ main (int argc, char **argv)
|
||||
atexit (close_stdout);
|
||||
|
||||
if (allow_options)
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
|
||||
--argc;
|
||||
|
||||
12
src/env.c
12
src/env.c
@@ -1,5 +1,5 @@
|
||||
/* env - run a program in a modified environment
|
||||
Copyright (C) 1986, 1991-2005, 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 1986, 1991-2005, 2007-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
|
||||
@@ -78,7 +78,6 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
|
||||
@@ -88,15 +87,14 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "env"
|
||||
|
||||
#define AUTHORS "Richard Mlynarik", "David MacKenzie"
|
||||
#define AUTHORS \
|
||||
proper_name ("Richard Mlynarik"), \
|
||||
proper_name ("David MacKenzie")
|
||||
|
||||
int putenv ();
|
||||
|
||||
extern char **environ;
|
||||
|
||||
/* The name by which this program was run. */
|
||||
char *program_name;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"ignore-environment", no_argument, NULL, 'i'},
|
||||
@@ -141,7 +139,7 @@ main (int argc, char **argv)
|
||||
bool ignore_environment = false;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* expand - convert tabs to spaces
|
||||
Copyright (C) 89, 91, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 91, 1995-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
|
||||
@@ -45,15 +45,12 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "expand"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
#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
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If true, convert blanks even after nonblank characters have been
|
||||
read on the line. */
|
||||
static bool convert_entire_line;
|
||||
@@ -370,7 +367,7 @@ main (int argc, char **argv)
|
||||
int c;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
650
src/expr.c
650
src/expr.c
@@ -1,5 +1,5 @@
|
||||
/* expr -- evaluate expressions.
|
||||
Copyright (C) 86, 1991-1997, 1999-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 1991-1997, 1999-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
|
||||
@@ -15,6 +15,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Author: Mike Parker.
|
||||
Modified for arbitrary-precision calculation by James Youngman.
|
||||
|
||||
This program evaluates expressions. Each token (operator, operand,
|
||||
parenthesis) of the expression must be a seperate argument. The
|
||||
@@ -32,10 +33,12 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <regex.h>
|
||||
#include "long-options.h"
|
||||
#if HAVE_GMP
|
||||
#include <gmp.h>
|
||||
#endif
|
||||
#include "error.h"
|
||||
#include "inttostr.h"
|
||||
#include "quotearg.h"
|
||||
#include "strnumcmp.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -43,7 +46,7 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "expr"
|
||||
|
||||
#define AUTHORS "Mike Parker"
|
||||
#define AUTHORS proper_name ("Mike Parker"), proper_name ("James Youngman")
|
||||
|
||||
/* Exit statuses. */
|
||||
enum
|
||||
@@ -58,10 +61,14 @@ enum
|
||||
EXPR_FAILURE
|
||||
};
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
/* 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. */
|
||||
enum valtype
|
||||
{
|
||||
integer,
|
||||
mp_integer,
|
||||
string
|
||||
};
|
||||
typedef enum valtype TYPE;
|
||||
@@ -72,7 +79,12 @@ struct valinfo
|
||||
TYPE type; /* Which kind. */
|
||||
union
|
||||
{ /* The value itself. */
|
||||
intmax_t i;
|
||||
/* 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
|
||||
char *s;
|
||||
} u;
|
||||
};
|
||||
@@ -81,14 +93,39 @@ typedef struct valinfo VALUE;
|
||||
/* The arguments given to the program, minus the program name. */
|
||||
static char **args;
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
static VALUE *eval (bool);
|
||||
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)
|
||||
{
|
||||
@@ -103,6 +140,10 @@ 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 (_("\
|
||||
@@ -179,16 +220,50 @@ syntax_error (void)
|
||||
static void
|
||||
integer_overflow (char op)
|
||||
{
|
||||
error (EXPR_FAILURE, ERANGE, "%c", 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);
|
||||
abort (); /* notreached */
|
||||
}
|
||||
|
||||
static void
|
||||
string_too_long (void)
|
||||
{
|
||||
die (EXPR_FAILURE, ERANGE, _("string too long"));
|
||||
}
|
||||
|
||||
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);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -196,23 +271,49 @@ main (int argc, char **argv)
|
||||
initialize_exit_failure (EXPR_FAILURE);
|
||||
atexit (close_stdout);
|
||||
|
||||
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], "--"))
|
||||
/* The argument -0 should not result in an error message. */
|
||||
opterr = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "+", long_options, NULL)) != -1)
|
||||
{
|
||||
--argc;
|
||||
++argv;
|
||||
/* "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);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc <= 1)
|
||||
if (argc <= optind)
|
||||
{
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXPR_INVALID);
|
||||
}
|
||||
|
||||
args = argv + 1;
|
||||
args = argv + optind;
|
||||
|
||||
v = eval (true);
|
||||
if (!nomoreargs ())
|
||||
@@ -225,9 +326,19 @@ main (int argc, char **argv)
|
||||
/* Return a VALUE for I. */
|
||||
|
||||
static VALUE *
|
||||
int_value (intmax_t i)
|
||||
int_value (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;
|
||||
return v;
|
||||
@@ -244,13 +355,42 @@ 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);
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -259,22 +399,24 @@ freev (VALUE *v)
|
||||
static void
|
||||
printv (VALUE *v)
|
||||
{
|
||||
char *p;
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
|
||||
switch (v->type)
|
||||
{
|
||||
case integer:
|
||||
p = imaxtostr (v->u.i, buf);
|
||||
printf ("%ld\n", v->u.i);
|
||||
break;
|
||||
case string:
|
||||
p = v->u.s;
|
||||
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 ();
|
||||
}
|
||||
|
||||
puts (p);
|
||||
}
|
||||
|
||||
/* Return true if V is a null-string or zero-number. */
|
||||
@@ -286,6 +428,10 @@ null (VALUE *v)
|
||||
{
|
||||
case integer:
|
||||
return v->u.i == 0;
|
||||
#if HAVE_GMP
|
||||
case mp_integer:
|
||||
return mpz_sgn (v->u.z) == 0;
|
||||
#endif
|
||||
case string:
|
||||
{
|
||||
char const *cp = v->u.s;
|
||||
@@ -328,14 +474,29 @@ looks_like_integer (char const *cp)
|
||||
static void
|
||||
tostring (VALUE *v)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
char buf[INT_BUFSIZE_BOUND (long int)];
|
||||
|
||||
switch (v->type)
|
||||
{
|
||||
case integer:
|
||||
v->u.s = xstrdup (imaxtostr (v->u.i, buf));
|
||||
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);
|
||||
v->u.s = s;
|
||||
v->type = string;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case string:
|
||||
break;
|
||||
default:
|
||||
@@ -343,7 +504,8 @@ tostring (VALUE *v)
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to an integer value. Return true on success, false on failure. */
|
||||
/* Coerce V to an arithmetic value.
|
||||
Return true on success, false on failure. */
|
||||
|
||||
static bool
|
||||
toarith (VALUE *v)
|
||||
@@ -351,18 +513,40 @@ toarith (VALUE *v)
|
||||
switch (v->type)
|
||||
{
|
||||
case integer:
|
||||
case mp_integer:
|
||||
return true;
|
||||
|
||||
case string:
|
||||
{
|
||||
intmax_t value;
|
||||
long int value;
|
||||
|
||||
if (! looks_like_integer (v->u.s))
|
||||
return false;
|
||||
if (xstrtoimax (v->u.s, NULL, 10, &value, NULL) != LONGINT_OK)
|
||||
error (EXPR_FAILURE, ERANGE, "%s", v->u.s);
|
||||
free (v->u.s);
|
||||
v->u.i = value;
|
||||
v->type = integer;
|
||||
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;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
@@ -370,6 +554,58 @@ 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)
|
||||
{
|
||||
if (v->type == integer)
|
||||
{
|
||||
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. */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Return true and advance if the next token matches STR exactly.
|
||||
STR must not be NULL. */
|
||||
|
||||
@@ -548,13 +784,41 @@ eval6 (bool evaluate)
|
||||
}
|
||||
else if (nextarg ("index"))
|
||||
{
|
||||
size_t pos, len;
|
||||
|
||||
l = eval6 (evaluate);
|
||||
r = eval6 (evaluate);
|
||||
tostring (l);
|
||||
tostring (r);
|
||||
v = int_value (strcspn (l->u.s, r->u.s) + 1);
|
||||
if (v->u.i == strlen (l->u.s) + 1)
|
||||
v->u.i = 0;
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
freev (l);
|
||||
freev (r);
|
||||
return v;
|
||||
@@ -567,19 +831,30 @@ eval6 (bool evaluate)
|
||||
i2 = eval6 (evaluate);
|
||||
tostring (l);
|
||||
llen = strlen (l->u.s);
|
||||
if (!toarith (i1) || !toarith (i2)
|
||||
|| llen < i1->u.i
|
||||
|| i1->u.i <= 0 || i2->u.i <= 0)
|
||||
|
||||
if (!toarith (i1) || !toarith (i2))
|
||||
v = str_value ("");
|
||||
else
|
||||
{
|
||||
size_t vlen = MIN (i2->u.i, llen - i1->u.i + 1);
|
||||
char *vlim;
|
||||
v = xmalloc (sizeof *v);
|
||||
v->type = string;
|
||||
v->u.s = xmalloc (vlen + 1);
|
||||
vlim = mempcpy (v->u.s, l->u.s + i1->u.i - 1, vlen);
|
||||
*vlim = '\0';
|
||||
size_t pos, len;
|
||||
bool negative = false;
|
||||
|
||||
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"));
|
||||
else
|
||||
if (negative)
|
||||
v = str_value ("");
|
||||
else
|
||||
die (EXPR_FAILURE, ERANGE, _("substring length too large"));
|
||||
}
|
||||
freev (l);
|
||||
freev (i1);
|
||||
@@ -622,6 +897,170 @@ 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 *
|
||||
@@ -630,7 +1069,6 @@ eval4 (bool evaluate)
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
enum { multiply, divide, mod } fxn;
|
||||
intmax_t val = 0;
|
||||
|
||||
#ifdef EVAL_TRACE
|
||||
trace ("eval4");
|
||||
@@ -651,37 +1089,71 @@ eval4 (bool evaluate)
|
||||
{
|
||||
if (!toarith (l) || !toarith (r))
|
||||
error (EXPR_INVALID, 0, _("non-numeric argument"));
|
||||
if (fxn == multiply)
|
||||
switch (fxn)
|
||||
{
|
||||
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)))
|
||||
integer_overflow ('*');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (r->u.i == 0)
|
||||
error (EXPR_INVALID, 0, _("division by zero"));
|
||||
if (l->u.i < - INTMAX_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 (fxn == divide)
|
||||
integer_overflow ('/');
|
||||
val = 0;
|
||||
}
|
||||
else
|
||||
val = fxn == divide ? l->u.i / r->u.i : l->u.i % r->u.i;
|
||||
case multiply:
|
||||
domult (l, r);
|
||||
break;
|
||||
case divide:
|
||||
case mod:
|
||||
dodivide (l, r, fxn==mod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 *
|
||||
@@ -689,8 +1161,7 @@ eval3 (bool evaluate)
|
||||
{
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
enum { plus, minus } fxn;
|
||||
intmax_t val = 0;
|
||||
bool add;
|
||||
|
||||
#ifdef EVAL_TRACE
|
||||
trace ("eval3");
|
||||
@@ -699,32 +1170,17 @@ eval3 (bool evaluate)
|
||||
while (1)
|
||||
{
|
||||
if (nextarg ("+"))
|
||||
fxn = plus;
|
||||
add = true;
|
||||
else if (nextarg ("-"))
|
||||
fxn = minus;
|
||||
add = false;
|
||||
else
|
||||
return l;
|
||||
r = eval4 (evaluate);
|
||||
if (evaluate)
|
||||
{
|
||||
if (!toarith (l) || !toarith (r))
|
||||
error (EXPR_INVALID, 0, _("non-numeric argument"));
|
||||
if (fxn == plus)
|
||||
{
|
||||
val = l->u.i + r->u.i;
|
||||
if ((val < l->u.i) != (r->u.i < 0))
|
||||
integer_overflow ('+');
|
||||
}
|
||||
else
|
||||
{
|
||||
val = l->u.i - r->u.i;
|
||||
if ((l->u.i < val) != (r->u.i < 0))
|
||||
integer_overflow ('-');
|
||||
}
|
||||
doadd (l, r, add);
|
||||
}
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -780,9 +1236,9 @@ eval2 (bool evaluate)
|
||||
if (errno)
|
||||
{
|
||||
error (0, errno, _("string comparison failed"));
|
||||
error (0, 0, _("Set LC_ALL='C' to work around the problem."));
|
||||
error (0, 0, _("set LC_ALL='C' to work around the problem"));
|
||||
error (EXPR_INVALID, 0,
|
||||
_("The strings compared were %s and %s."),
|
||||
_("the strings compared were %s and %s"),
|
||||
quotearg_n_style (0, locale_quoting_style, l->u.s),
|
||||
quotearg_n_style (1, locale_quoting_style, r->u.s));
|
||||
}
|
||||
|
||||
499
src/factor.c
499
src/factor.c
@@ -1,5 +1,5 @@
|
||||
/* factor -- print prime factors of n.
|
||||
Copyright (C) 86, 1995-2005, 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 1995-2005, 2007-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
|
||||
@@ -15,20 +15,26 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Rubin <phr@ocf.berkeley.edu>.
|
||||
Adapted for GNU, fixed to factor UINT_MAX by Jim Meyering. */
|
||||
Adapted for GNU, fixed to factor UINT_MAX by Jim Meyering.
|
||||
Arbitrary-precision code adapted by James Youngman from Torbjörn
|
||||
Granlund's factorize.c, from GNU MP version 4.2.2.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <getopt.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#if HAVE_GMP
|
||||
#include <gmp.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define NDEBUG 1
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "inttostr.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
#include "readtokens.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -36,11 +42,278 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "factor"
|
||||
|
||||
#define AUTHORS "Paul Rubin"
|
||||
#define AUTHORS proper_name ("Paul Rubin")
|
||||
|
||||
/* Token delimiters when reading from a file. */
|
||||
#define DELIM "\n\t "
|
||||
|
||||
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;
|
||||
static size_t nfactors_allocated = 0;
|
||||
|
||||
static void
|
||||
debug (char const *fmt, ...)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
vfprintf (stderr, fmt, ap);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
emit_factor (mpz_t n)
|
||||
{
|
||||
if (nfactors_found == nfactors_allocated)
|
||||
factor = x2nrealloc (factor, &nfactors_allocated, sizeof *factor);
|
||||
mpz_init (factor[nfactors_found]);
|
||||
mpz_set (factor[nfactors_found], n);
|
||||
++nfactors_found;
|
||||
}
|
||||
|
||||
static void
|
||||
emit_ul_factor (unsigned long int i)
|
||||
{
|
||||
mpz_t t;
|
||||
mpz_init (t);
|
||||
mpz_set_ui (t, i);
|
||||
emit_factor (t);
|
||||
}
|
||||
|
||||
static void
|
||||
factor_using_division (mpz_t t, unsigned int limit)
|
||||
{
|
||||
mpz_t q, r;
|
||||
unsigned long int f;
|
||||
int ai;
|
||||
static unsigned int const add[] = {4, 2, 4, 2, 4, 6, 2, 6};
|
||||
unsigned int const *addv = add;
|
||||
unsigned int failures;
|
||||
|
||||
debug ("[trial division (%u)] ", limit);
|
||||
|
||||
mpz_init (q);
|
||||
mpz_init (r);
|
||||
|
||||
f = mpz_scan1 (t, 0);
|
||||
mpz_div_2exp (t, t, f);
|
||||
while (f)
|
||||
{
|
||||
emit_ul_factor (2);
|
||||
--f;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
mpz_tdiv_qr_ui (q, r, t, 3);
|
||||
if (mpz_cmp_ui (r, 0) != 0)
|
||||
break;
|
||||
mpz_set (t, q);
|
||||
emit_ul_factor (3);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
mpz_tdiv_qr_ui (q, r, t, 5);
|
||||
if (mpz_cmp_ui (r, 0) != 0)
|
||||
break;
|
||||
mpz_set (t, q);
|
||||
emit_ul_factor (5);
|
||||
}
|
||||
|
||||
failures = 0;
|
||||
f = 7;
|
||||
ai = 0;
|
||||
while (mpz_cmp_ui (t, 1) != 0)
|
||||
{
|
||||
mpz_tdiv_qr_ui (q, r, t, f);
|
||||
if (mpz_cmp_ui (r, 0) != 0)
|
||||
{
|
||||
f += addv[ai];
|
||||
if (mpz_cmp_ui (q, f) < 0)
|
||||
break;
|
||||
ai = (ai + 1) & 7;
|
||||
failures++;
|
||||
if (failures > limit)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
mpz_swap (t, q);
|
||||
emit_ul_factor (f);
|
||||
failures = 0;
|
||||
}
|
||||
}
|
||||
|
||||
mpz_clear (q);
|
||||
mpz_clear (r);
|
||||
}
|
||||
|
||||
static void
|
||||
factor_using_pollard_rho (mpz_t n, int a_int)
|
||||
{
|
||||
mpz_t x, x1, y, P;
|
||||
mpz_t a;
|
||||
mpz_t g;
|
||||
mpz_t t1, t2;
|
||||
int k, l, c, i;
|
||||
|
||||
debug ("[pollard-rho (%d)] ", a_int);
|
||||
|
||||
mpz_init (g);
|
||||
mpz_init (t1);
|
||||
mpz_init (t2);
|
||||
|
||||
mpz_init_set_si (a, a_int);
|
||||
mpz_init_set_si (y, 2);
|
||||
mpz_init_set_si (x, 2);
|
||||
mpz_init_set_si (x1, 2);
|
||||
k = 1;
|
||||
l = 1;
|
||||
mpz_init_set_ui (P, 1);
|
||||
c = 0;
|
||||
|
||||
while (mpz_cmp_ui (n, 1) != 0)
|
||||
{
|
||||
S2:
|
||||
mpz_mul (x, x, x); mpz_add (x, x, a); mpz_mod (x, x, n);
|
||||
|
||||
mpz_sub (t1, x1, x); mpz_mul (t2, P, t1); mpz_mod (P, t2, n);
|
||||
c++;
|
||||
if (c == 20)
|
||||
{
|
||||
c = 0;
|
||||
mpz_gcd (g, P, n);
|
||||
if (mpz_cmp_ui (g, 1) != 0)
|
||||
goto S4;
|
||||
mpz_set (y, x);
|
||||
}
|
||||
|
||||
k--;
|
||||
if (k > 0)
|
||||
goto S2;
|
||||
|
||||
mpz_gcd (g, P, n);
|
||||
if (mpz_cmp_ui (g, 1) != 0)
|
||||
goto S4;
|
||||
|
||||
mpz_set (x1, x);
|
||||
k = l;
|
||||
l = 2 * l;
|
||||
for (i = 0; i < k; i++)
|
||||
{
|
||||
mpz_mul (x, x, x); mpz_add (x, x, a); mpz_mod (x, x, n);
|
||||
}
|
||||
mpz_set (y, x);
|
||||
c = 0;
|
||||
goto S2;
|
||||
S4:
|
||||
do
|
||||
{
|
||||
mpz_mul (y, y, y); mpz_add (y, y, a); mpz_mod (y, y, n);
|
||||
mpz_sub (t1, x1, y); mpz_gcd (g, t1, n);
|
||||
}
|
||||
while (mpz_cmp_ui (g, 1) == 0);
|
||||
|
||||
mpz_div (n, n, g); /* divide by g, before g is overwritten */
|
||||
|
||||
if (!mpz_probab_prime_p (g, 3))
|
||||
{
|
||||
do
|
||||
{
|
||||
mp_limb_t a_limb;
|
||||
mpn_random (&a_limb, (mp_size_t) 1);
|
||||
a_int = (int) a_limb;
|
||||
}
|
||||
while (a_int == -2 || a_int == 0);
|
||||
|
||||
debug ("[composite factor--restarting pollard-rho] ");
|
||||
factor_using_pollard_rho (g, a_int);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit_factor (g);
|
||||
}
|
||||
mpz_mod (x, x, n);
|
||||
mpz_mod (x1, x1, n);
|
||||
mpz_mod (y, y, n);
|
||||
if (mpz_probab_prime_p (n, 3))
|
||||
{
|
||||
emit_factor (n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mpz_clear (g);
|
||||
mpz_clear (P);
|
||||
mpz_clear (t2);
|
||||
mpz_clear (t1);
|
||||
mpz_clear (a);
|
||||
mpz_clear (x1);
|
||||
mpz_clear (x);
|
||||
mpz_clear (y);
|
||||
}
|
||||
|
||||
/* Arbitrary-precision factoring */
|
||||
static bool
|
||||
extract_factors_multi (char const *s)
|
||||
{
|
||||
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. */
|
||||
#define MAX_N_FACTORS (sizeof (uintmax_t) * CHAR_BIT)
|
||||
|
||||
@@ -59,42 +332,10 @@ static const unsigned char wheel_tab[] =
|
||||
#define WHEEL_START (wheel_tab + WHEEL_SIZE)
|
||||
#define WHEEL_END (wheel_tab + (sizeof wheel_tab / sizeof wheel_tab[0]))
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != EXIT_SUCCESS)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [NUMBER]...\n\
|
||||
or: %s OPTION\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
fputs (_("\
|
||||
Print the prime factors of each NUMBER.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
Print the prime factors of all specified integer NUMBERs. If no arguments\n\
|
||||
are specified on the command line, they are read from standard input.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* FIXME: comment */
|
||||
|
||||
static size_t
|
||||
factor (uintmax_t n0, size_t max_n_factors, uintmax_t *factors)
|
||||
factor_wheel (uintmax_t n0, size_t max_n_factors, uintmax_t *factors)
|
||||
{
|
||||
uintmax_t n = n0, d, q;
|
||||
size_t n_factors = 0;
|
||||
@@ -137,10 +378,9 @@ factor (uintmax_t n0, size_t max_n_factors, uintmax_t *factors)
|
||||
return n_factors;
|
||||
}
|
||||
|
||||
/* FIXME: comment */
|
||||
|
||||
/* Single-precision factoring */
|
||||
static bool
|
||||
print_factors (const char *s)
|
||||
print_factors_single (char const *s)
|
||||
{
|
||||
uintmax_t factors[MAX_N_FACTORS];
|
||||
uintmax_t n;
|
||||
@@ -157,7 +397,7 @@ print_factors (const char *s)
|
||||
error (0, 0, _("%s is not a valid positive integer"), quote (s));
|
||||
return false;
|
||||
}
|
||||
n_factors = factor (n, MAX_N_FACTORS, factors);
|
||||
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));
|
||||
@@ -165,6 +405,146 @@ print_factors (const char *s)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if HAVE_GMP
|
||||
static int
|
||||
mpcompare (const void *av, const void *bv)
|
||||
{
|
||||
mpz_t *const *a = av;
|
||||
mpz_t *const *b = bv;
|
||||
return mpz_cmp (**a, **b);
|
||||
}
|
||||
|
||||
static void
|
||||
sort_and_print_factors (void)
|
||||
{
|
||||
mpz_t **faclist;
|
||||
size_t i;
|
||||
|
||||
faclist = xcalloc (nfactors_found, sizeof *faclist);
|
||||
for (i = 0; i < nfactors_found; ++i)
|
||||
{
|
||||
faclist[i] = &factor[i];
|
||||
}
|
||||
qsort (faclist, nfactors_found, sizeof *faclist, mpcompare);
|
||||
|
||||
for (i = 0; i < nfactors_found; ++i)
|
||||
{
|
||||
fputc (' ', stdout);
|
||||
mpz_out_str (stdout, 10, *faclist[i]);
|
||||
}
|
||||
putchar ('\n');
|
||||
free (faclist);
|
||||
}
|
||||
|
||||
static void
|
||||
free_factors (void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < nfactors_found; ++i)
|
||||
{
|
||||
mpz_clear (factor[i]);
|
||||
}
|
||||
/* Don't actually free factor[] because in the case where we are
|
||||
reading numbers from stdin, we may be about to use it again. */
|
||||
nfactors_found = 0;
|
||||
}
|
||||
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
static bool
|
||||
print_factors (char const *s)
|
||||
{
|
||||
if (ALGO_AUTOSELECT == algorithm)
|
||||
{
|
||||
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))
|
||||
{
|
||||
sort_and_print_factors ();
|
||||
free_factors ();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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"));
|
||||
return false;
|
||||
}
|
||||
return print_factors_single (s);
|
||||
}
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
VERBOSE_OPTION = CHAR_MAX + 1,
|
||||
USE_BIGNUM,
|
||||
NO_USE_BIGNUM
|
||||
};
|
||||
|
||||
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}
|
||||
};
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != EXIT_SUCCESS)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [NUMBER]...\n\
|
||||
or: %s OPTION\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
fputs (_("\
|
||||
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 ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
static bool
|
||||
do_stdin (void)
|
||||
{
|
||||
@@ -190,19 +570,40 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
bool ok;
|
||||
int c;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
if (getopt_long (argc, argv, "", NULL, NULL) != -1)
|
||||
usage (EXIT_FAILURE);
|
||||
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case VERBOSE_OPTION:
|
||||
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);
|
||||
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc <= optind)
|
||||
ok = do_stdin ();
|
||||
@@ -214,6 +615,8 @@ main (int argc, char **argv)
|
||||
if (! print_factors (argv[i]))
|
||||
ok = false;
|
||||
}
|
||||
|
||||
#if HAVE_GMP
|
||||
free (factor);
|
||||
#endif
|
||||
exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
15
src/fmt.c
15
src/fmt.c
@@ -1,5 +1,5 @@
|
||||
/* GNU fmt -- simple text formatter.
|
||||
Copyright (C) 1994-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-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
|
||||
@@ -33,7 +33,7 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "fmt"
|
||||
|
||||
#define AUTHORS "Ross Paterson"
|
||||
#define AUTHORS proper_name ("Ross Paterson")
|
||||
|
||||
/* The following parameters represent the program's idea of what is
|
||||
"best". Adjust to taste, subject to the caveats given. */
|
||||
@@ -167,9 +167,6 @@ static void put_line (WORD *w, int indent);
|
||||
static void put_word (WORD *w);
|
||||
static void put_space (int space);
|
||||
|
||||
/* The name this program was run with. */
|
||||
const char *program_name;
|
||||
|
||||
/* Option values. */
|
||||
|
||||
/* If true, first 2 lines may have different indent (default false). */
|
||||
@@ -269,10 +266,10 @@ usage (int status)
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf (_("Usage: %s [-DIGITS] [OPTION]... [FILE]...\n"), program_name);
|
||||
printf (_("Usage: %s [-WIDTH] [OPTION]... [FILE]...\n"), program_name);
|
||||
fputs (_("\
|
||||
Reformat each paragraph in the FILE(s), writing to standard output.\n\
|
||||
If no FILE or if FILE is `-', read standard input.\n\
|
||||
The option -WIDTH is an abbreviated form of --width=DIGITS.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
@@ -303,7 +300,7 @@ With no FILE, or when FILE is -, read standard input.\n"),
|
||||
|
||||
/* Decode options and launch execution. */
|
||||
|
||||
static const struct option long_options[] =
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"crown-margin", no_argument, NULL, 'c'},
|
||||
{"prefix", required_argument, NULL, 'p'},
|
||||
@@ -324,7 +321,7 @@ main (int argc, char **argv)
|
||||
char const *max_width_option = NULL;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* fold -- wrap each input line to fit in specified width.
|
||||
Copyright (C) 91, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-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
|
||||
@@ -32,10 +32,7 @@
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "fold"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
#define AUTHORS proper_name ("David MacKenzie")
|
||||
|
||||
/* If nonzero, try to break on whitespace. */
|
||||
static bool break_spaces;
|
||||
@@ -247,7 +244,7 @@ main (int argc, char **argv)
|
||||
bool ok;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
121
src/group-list.c
Normal file
121
src/group-list.c
Normal file
@@ -0,0 +1,121 @@
|
||||
/* group-list.c --Print a list of group IDs or names.
|
||||
Copyright (C) 1989-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 Arnold Robbins.
|
||||
Major rewrite by David MacKenzie, djm@gnu.ai.mit.edu.
|
||||
Extracted from id.c by James Youngman. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "mgetgroups.h"
|
||||
#include "quote.h"
|
||||
#include "group-list.h"
|
||||
|
||||
|
||||
/* Print all of the distinct groups the user is in. */
|
||||
extern bool
|
||||
print_group_list (const char *username,
|
||||
uid_t ruid, gid_t rgid, gid_t egid,
|
||||
bool use_names)
|
||||
{
|
||||
bool ok = true;
|
||||
struct passwd *pwd;
|
||||
|
||||
pwd = getpwuid (ruid);
|
||||
if (pwd == NULL)
|
||||
ok = false;
|
||||
|
||||
if (!print_group (rgid, use_names))
|
||||
ok = false;
|
||||
|
||||
if (egid != rgid)
|
||||
{
|
||||
putchar (' ');
|
||||
if (!print_group (egid, use_names))
|
||||
ok = false;
|
||||
}
|
||||
|
||||
#if HAVE_GETGROUPS
|
||||
{
|
||||
GETGROUPS_T *groups;
|
||||
size_t i;
|
||||
|
||||
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
|
||||
&groups);
|
||||
if (n_groups < 0)
|
||||
{
|
||||
if (username)
|
||||
{
|
||||
error (0, errno, _("failed to get groups for user %s"),
|
||||
quote (username));
|
||||
}
|
||||
else
|
||||
{
|
||||
error (0, errno, _("failed to get groups for the current process"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_groups; i++)
|
||||
if (groups[i] != rgid && groups[i] != egid)
|
||||
{
|
||||
putchar (' ');
|
||||
if (!print_group (groups[i], use_names))
|
||||
ok = false;
|
||||
}
|
||||
free (groups);
|
||||
return ok;
|
||||
}
|
||||
#endif /* HAVE_GETGROUPS */
|
||||
}
|
||||
|
||||
|
||||
/* Print the name or value of group ID GID. */
|
||||
extern bool
|
||||
print_group (gid_t gid, bool use_name)
|
||||
{
|
||||
struct group *grp = NULL;
|
||||
bool ok = true;
|
||||
|
||||
if (use_name)
|
||||
{
|
||||
grp = getgrgid (gid);
|
||||
if (grp == NULL)
|
||||
{
|
||||
error (0, 0, _("cannot find name for group ID %lu"),
|
||||
(unsigned long int) gid);
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (grp == NULL)
|
||||
printf ("%lu", (unsigned long int) gid);
|
||||
else
|
||||
printf ("%s", grp->gr_name);
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
19
src/group-list.h
Normal file
19
src/group-list.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/* group-list.h -- prototypes shared by id and groups.
|
||||
|
||||
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/>. */
|
||||
|
||||
bool print_group (gid_t, bool);
|
||||
bool print_group_list (const char *, uid_t, gid_t, gid_t, bool);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user