mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
451 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
804bdc3001 | ||
|
|
25cdc8248d | ||
|
|
826ff082db | ||
|
|
59e889f0f3 | ||
|
|
3440b65ecf | ||
|
|
a59975a3fd | ||
|
|
373c95c45a | ||
|
|
c63f4506cc | ||
|
|
85de525557 | ||
|
|
13e4c87ff6 | ||
|
|
de540a76eb | ||
|
|
02b2e48b12 | ||
|
|
5bc4b89be8 | ||
|
|
553d347d3e | ||
|
|
b1d89070f6 | ||
|
|
20bc0790a7 | ||
|
|
7828d1b4e2 | ||
|
|
5b3313c120 | ||
|
|
0edae5eee6 | ||
|
|
11f43d2e22 | ||
|
|
87c54fa0ae | ||
|
|
3715c01f8e | ||
|
|
d2c7d7b58f | ||
|
|
d1e5a7af56 | ||
|
|
369aaf7e5d | ||
|
|
39e85b7258 | ||
|
|
487e5317be | ||
|
|
112b9537dd | ||
|
|
24045feb85 | ||
|
|
64f972e94b | ||
|
|
1e7a0f088b | ||
|
|
fd6fc97156 | ||
|
|
04131454e3 | ||
|
|
bc86cb44e3 | ||
|
|
0a538a2488 | ||
|
|
ca4f28bc83 | ||
|
|
36aeb30081 | ||
|
|
fe3fbf2f54 | ||
|
|
d9079b12e3 | ||
|
|
222b7c46bd | ||
|
|
4bf9fe82c0 | ||
|
|
fe068c60fb | ||
|
|
e3864a430e | ||
|
|
2639ed8208 | ||
|
|
09aab8cb41 | ||
|
|
9abd8baaaa | ||
|
|
551bed87fa | ||
|
|
b7a568ece8 | ||
|
|
2871ad3b45 | ||
|
|
f0537a71f1 | ||
|
|
1187f011d3 | ||
|
|
c872a5f7bb | ||
|
|
fe4f1227a5 | ||
|
|
13a4b23e79 | ||
|
|
b655a2154e | ||
|
|
272d99e7a3 | ||
|
|
262963212b | ||
|
|
ea42025c70 | ||
|
|
7daf29845b | ||
|
|
5703f662b7 | ||
|
|
b3b6f52fad | ||
|
|
f6f2846bd8 | ||
|
|
e5dbc71841 | ||
|
|
b2a48ec240 | ||
|
|
c62a7156c5 | ||
|
|
195108489b | ||
|
|
55bc95b4d3 | ||
|
|
d480544281 | ||
|
|
817d0261eb | ||
|
|
898d3df2f8 | ||
|
|
9317cccb8f | ||
|
|
cc2d4f6c46 | ||
|
|
471eca0dd6 | ||
|
|
e98137ddd4 | ||
|
|
1b2056c435 | ||
|
|
f92a08e171 | ||
|
|
3ea177e3fa | ||
|
|
75460e090c | ||
|
|
90390c6a92 | ||
|
|
63813d0950 | ||
|
|
2e140cfb42 | ||
|
|
33176a7269 | ||
|
|
813de08e50 | ||
|
|
5a8a00e16e | ||
|
|
54bdcc09ae | ||
|
|
cb121d8f36 | ||
|
|
3a9070dce7 | ||
|
|
93f9b9be84 | ||
|
|
4e73fea3e3 | ||
|
|
c450b625b4 | ||
|
|
f48ca7f500 | ||
|
|
c25841e0d4 | ||
|
|
45a35825dc | ||
|
|
cc388d140c | ||
|
|
c46549dc38 | ||
|
|
2d2255272d | ||
|
|
4cf919bcdf | ||
|
|
d7226387a9 | ||
|
|
dd99d05b4a | ||
|
|
fd32ffb4da | ||
|
|
c363fcb9f0 | ||
|
|
e189deb855 | ||
|
|
aeb892e592 | ||
|
|
6819756293 | ||
|
|
c95bb0c6f0 | ||
|
|
d07d81df27 | ||
|
|
516f42ab40 | ||
|
|
d163cd681a | ||
|
|
0d8ca457b3 | ||
|
|
e152d05d82 | ||
|
|
a09b047947 | ||
|
|
bbb61fa617 | ||
|
|
0c2d21d3f2 | ||
|
|
d282370566 | ||
|
|
b28a8851ed | ||
|
|
1c73876f5f | ||
|
|
251f774621 | ||
|
|
1d72903faf | ||
|
|
82276cbd2e | ||
|
|
c5d2da8ac8 | ||
|
|
31bb8a431a | ||
|
|
c544a36826 | ||
|
|
bbe4be0c9a | ||
|
|
449a3751d1 | ||
|
|
e4eaba04dd | ||
|
|
fc9b328ab4 | ||
|
|
c1f8d48387 | ||
|
|
e7420f9781 | ||
|
|
2b0483aa03 | ||
|
|
9140950afb | ||
|
|
e0b3b059b2 | ||
|
|
2d2a0c8311 | ||
|
|
11b626c20f | ||
|
|
a16f807d7e | ||
|
|
a0b2bc8de7 | ||
|
|
a0d74a99b7 | ||
|
|
124adb3a19 | ||
|
|
054defae19 | ||
|
|
1f7d56fda5 | ||
|
|
f33168da95 | ||
|
|
590a3f5b08 | ||
|
|
bdbd5d31f8 | ||
|
|
3d63c453d5 | ||
|
|
e175f0d5b2 | ||
|
|
fd77348fef | ||
|
|
03b1e07ae0 | ||
|
|
0928c2414a | ||
|
|
d1ad73e0bf | ||
|
|
1e23a1785a | ||
|
|
54050ea91d | ||
|
|
aa5a4fc172 | ||
|
|
bb4112b407 | ||
|
|
9c88531fb0 | ||
|
|
9afcb30571 | ||
|
|
4e2fd4cca6 | ||
|
|
c6357f0cab | ||
|
|
fbcbba4b94 | ||
|
|
48545b5756 | ||
|
|
b5f1873022 | ||
|
|
dad7d86d57 | ||
|
|
bce110cdd5 | ||
|
|
37bcc27707 | ||
|
|
ab58de37e6 | ||
|
|
4082e3be7c | ||
|
|
11bcfcc72a | ||
|
|
aa6a5547b3 | ||
|
|
c8e51ae68a | ||
|
|
2ed0544df4 | ||
|
|
3b933f1e33 | ||
|
|
99d9e13b9c | ||
|
|
419aa62c46 | ||
|
|
482366105a | ||
|
|
f28e07f81d | ||
|
|
8563b4c051 | ||
|
|
f0b5e513d9 | ||
|
|
3b8560a637 | ||
|
|
b5ef9617c4 | ||
|
|
747e7a8da8 | ||
|
|
d2ec687c1c | ||
|
|
457b4e69f5 | ||
|
|
d08d66ebc6 | ||
|
|
5017d1b4e1 | ||
|
|
841d9a7d5d | ||
|
|
67b9752cd1 | ||
|
|
88891aef7e | ||
|
|
bbcfef38a3 | ||
|
|
2eea35fcf2 | ||
|
|
f20cd37e51 | ||
|
|
4b9e987554 | ||
|
|
f24ff8f42b | ||
|
|
699188aa87 | ||
|
|
a828a78563 | ||
|
|
2d4cd37758 | ||
|
|
f0ee72aa01 | ||
|
|
c8ef95eaed | ||
|
|
d69fc66d81 | ||
|
|
4e48b4ce33 | ||
|
|
6f005c8491 | ||
|
|
6f3efa15eb | ||
|
|
33de42f2a8 | ||
|
|
c97742932a | ||
|
|
a6a1e73c0a | ||
|
|
c3154b2947 | ||
|
|
24852bf5b5 | ||
|
|
56007809c3 | ||
|
|
629214eaf8 | ||
|
|
ae3f43d3eb | ||
|
|
ec95137cc3 | ||
|
|
ae3ee95eb8 | ||
|
|
a6895a8da2 | ||
|
|
8d550c12b8 | ||
|
|
0ee9adb1fa | ||
|
|
0473e718e6 | ||
|
|
dab023dec1 | ||
|
|
939c480a79 | ||
|
|
07af816554 | ||
|
|
6b49da0dc3 | ||
|
|
f044d2d51c | ||
|
|
565b165115 | ||
|
|
9f1b96313e | ||
|
|
fc92148eac | ||
|
|
a4f7b723f0 | ||
|
|
e7f7dcb9d1 | ||
|
|
545df07893 | ||
|
|
8406e92795 | ||
|
|
1ea616697a | ||
|
|
5e585ffe84 | ||
|
|
370370c8e4 | ||
|
|
ba45154d8e | ||
|
|
6e7e2709c8 | ||
|
|
aa0fb1e032 | ||
|
|
1ddf7faf11 | ||
|
|
db7092bed3 | ||
|
|
97136cb93f | ||
|
|
9b06af3367 | ||
|
|
a45772d52d | ||
|
|
a43ee65ee5 | ||
|
|
549bbdf7b4 | ||
|
|
5e2f415d17 | ||
|
|
d6a37dfa3b | ||
|
|
8ec7811e82 | ||
|
|
08dcc35470 | ||
|
|
17a7d2c81b | ||
|
|
a23c91026d | ||
|
|
1ce71652fc | ||
|
|
1b95d5ee81 | ||
|
|
6b7c67ad88 | ||
|
|
02e24f2593 | ||
|
|
5891b7ce21 | ||
|
|
c8092e5db0 | ||
|
|
8cafe0070a | ||
|
|
d0275e280e | ||
|
|
37012effc9 | ||
|
|
a409011bba | ||
|
|
a3ae3e8085 | ||
|
|
3ccd02d5b9 | ||
|
|
5272c6daa1 | ||
|
|
e750c5cac8 | ||
|
|
92210636da | ||
|
|
46710dd82a | ||
|
|
efab0d7989 | ||
|
|
659e5f5edc | ||
|
|
b076de8551 | ||
|
|
7719e67e36 | ||
|
|
d66091126a | ||
|
|
41b5fe3246 | ||
|
|
e9a8c140da | ||
|
|
279c41d79c | ||
|
|
81ebd46046 | ||
|
|
318fb0502d | ||
|
|
ad2a81ce8b | ||
|
|
497a5cf465 | ||
|
|
1efc5bda6c | ||
|
|
0cafba44bb | ||
|
|
1a0333565f | ||
|
|
a73fdeb2ce | ||
|
|
751f6acf54 | ||
|
|
8b139ff78c | ||
|
|
b6b438c45d | ||
|
|
fc9b802e3d | ||
|
|
e189a79efd | ||
|
|
56206ccb80 | ||
|
|
3ef2f939f7 | ||
|
|
1b00a69ff2 | ||
|
|
7932d2e2d4 | ||
|
|
2061f04847 | ||
|
|
d5d00c7f9f | ||
|
|
84268dae4e | ||
|
|
78a1d22aa0 | ||
|
|
597bfeb851 | ||
|
|
c24e93d926 | ||
|
|
75be540f7d | ||
|
|
28c7ef509e | ||
|
|
7c96936a04 | ||
|
|
e24ce7c58d | ||
|
|
876e46bce7 | ||
|
|
a0db0def2d | ||
|
|
0766fb8b54 | ||
|
|
b40b5b6917 | ||
|
|
95954ad583 | ||
|
|
e81a82b74f | ||
|
|
3e9cc76189 | ||
|
|
693311a5c3 | ||
|
|
5e42576c01 | ||
|
|
ba6b1acefd | ||
|
|
a3c4e0b94c | ||
|
|
7e4eef7e40 | ||
|
|
a002111341 | ||
|
|
0fdbf2e8c7 | ||
|
|
9b17e1d7d4 | ||
|
|
7054512f14 | ||
|
|
479648040d | ||
|
|
0c0121ed20 | ||
|
|
33d52dbc43 | ||
|
|
9b34202141 | ||
|
|
2457af43cf | ||
|
|
f5417daca0 | ||
|
|
b1289b8716 | ||
|
|
dcf5b47708 | ||
|
|
46775398f2 | ||
|
|
a75684d6ea | ||
|
|
86719b3cd8 | ||
|
|
8d8af1248d | ||
|
|
64e75cf0ed | ||
|
|
e116c805bf | ||
|
|
76a7aea9b6 | ||
|
|
14f131ea57 | ||
|
|
177913f5b8 | ||
|
|
86823158eb | ||
|
|
81afea0110 | ||
|
|
7bc17873e5 | ||
|
|
11cf1d39f2 | ||
|
|
f594f1fb38 | ||
|
|
a186e9eda6 | ||
|
|
d1ea87316f | ||
|
|
8029cc8b5a | ||
|
|
7a0f8b0487 | ||
|
|
dd8398a3c6 | ||
|
|
443d509578 | ||
|
|
e0b2cb892a | ||
|
|
ebcf61da0f | ||
|
|
1491ae9ceb | ||
|
|
f3fbb64189 | ||
|
|
32cfc1ffec | ||
|
|
46693ba15b | ||
|
|
269263a5f7 | ||
|
|
34b35b1a3e | ||
|
|
e2c177710a | ||
|
|
8a2e111207 | ||
|
|
095c1c83eb | ||
|
|
0dc7f78986 | ||
|
|
779168820b | ||
|
|
965232b5b9 | ||
|
|
5dea5d07cd | ||
|
|
f2c088fa10 | ||
|
|
dc9790379c | ||
|
|
8552234cb5 | ||
|
|
b985c478d6 | ||
|
|
1471e1e61f | ||
|
|
8dda1ae431 | ||
|
|
c0b262550c | ||
|
|
bad80a7223 | ||
|
|
9f70d6021b | ||
|
|
5f60ffcfcf | ||
|
|
90224c6639 | ||
|
|
8202f4d6d5 | ||
|
|
e3e4f829a1 | ||
|
|
e245a66054 | ||
|
|
489ff7f0cd | ||
|
|
2983bf7c85 | ||
|
|
34d0ffbce4 | ||
|
|
6089facdc3 | ||
|
|
181428d653 | ||
|
|
4b86e52050 | ||
|
|
dc52b433ef | ||
|
|
4767fc607e | ||
|
|
0fc6edb714 | ||
|
|
c620aeeb90 | ||
|
|
2a8efc2647 | ||
|
|
08984eef49 | ||
|
|
1fa3b50140 | ||
|
|
d78ad5cacc | ||
|
|
c5bccf11cc | ||
|
|
1d4ac49f9d | ||
|
|
a1da4a039d | ||
|
|
184dcf2caf | ||
|
|
41011fa81d | ||
|
|
2f7025ad2a | ||
|
|
9ac369c2bd | ||
|
|
da9541f18e | ||
|
|
d2e7358a9b | ||
|
|
d8086bc220 | ||
|
|
2244cc1456 | ||
|
|
10688306fa | ||
|
|
af8862ae29 | ||
|
|
37986655cf | ||
|
|
f7ecea33e4 | ||
|
|
e245139e46 | ||
|
|
2e328b0196 | ||
|
|
a38becce97 | ||
|
|
31c77a2fde | ||
|
|
af46184a80 | ||
|
|
a4d470409f | ||
|
|
344c446776 | ||
|
|
f2d5658c08 | ||
|
|
0bc935e209 | ||
|
|
b15b6fa192 | ||
|
|
665b228730 | ||
|
|
d37c3b8c6d | ||
|
|
ec3554cd95 | ||
|
|
c2de7816d8 | ||
|
|
0747af4b18 | ||
|
|
a86a56f7d1 | ||
|
|
b7c315cdda | ||
|
|
412a3ca0b0 | ||
|
|
bbab62fd27 | ||
|
|
5f65d05616 | ||
|
|
509febe18b | ||
|
|
3d524d9ab2 | ||
|
|
1cd04b34dd | ||
|
|
d3c6206631 | ||
|
|
f951057414 | ||
|
|
e05de760c2 | ||
|
|
de88ea4c5d | ||
|
|
af5967eae2 | ||
|
|
6649f01059 | ||
|
|
200aa48e15 | ||
|
|
867251d725 | ||
|
|
b4963a7f70 | ||
|
|
453c215003 | ||
|
|
328efced8b | ||
|
|
7c8dece8c6 | ||
|
|
5ffeefb1ab | ||
|
|
2a01141018 | ||
|
|
fae30e1af9 | ||
|
|
2c83d42320 | ||
|
|
396a52f790 | ||
|
|
05ce3b2986 | ||
|
|
1671b056a5 | ||
|
|
856443a97d | ||
|
|
7889cfbbc7 | ||
|
|
90616d3a8f | ||
|
|
f544d8dd1a | ||
|
|
0e3b87195a | ||
|
|
bebf83d0fd | ||
|
|
46dd4b1a8e | ||
|
|
058f319e6d | ||
|
|
87353aebd8 | ||
|
|
5a73ad8c63 | ||
|
|
c9c0dc7bc6 | ||
|
|
9c57927ad1 |
119
.gitignore
vendored
119
.gitignore
vendored
@@ -6,6 +6,8 @@
|
||||
*/.deps
|
||||
*~
|
||||
.kludge-stamp
|
||||
ABOUT-NLS
|
||||
INSTALL
|
||||
Makefile
|
||||
Makefile.in
|
||||
THANKS-to-translators
|
||||
@@ -23,123 +25,6 @@ coreutils-*.tar.gz
|
||||
coreutils-*.tar.gz.sig
|
||||
coreutils-*.xdelta
|
||||
coreutils-*.xdelta.sig
|
||||
doc/constants.texi
|
||||
doc/coreutils.info
|
||||
doc/stamp-vti
|
||||
doc/version.texi
|
||||
lib/alloca.h
|
||||
lib/charset.alias
|
||||
lib/getdate.c
|
||||
lib/libcoreutils.a
|
||||
lib/ref-add.sed
|
||||
lib/ref-del.sed
|
||||
lib/stdint.h
|
||||
lib/t-fpending
|
||||
po/Makefile.in
|
||||
po/POTFILES
|
||||
po/coreutils.pot
|
||||
po/stamp-po
|
||||
src/\[
|
||||
src/base64
|
||||
src/basename
|
||||
src/cat
|
||||
src/chgrp
|
||||
src/chmod
|
||||
src/chown
|
||||
src/chroot
|
||||
src/cksum
|
||||
src/comm
|
||||
src/cp
|
||||
src/csplit
|
||||
src/cut
|
||||
src/date
|
||||
src/dd
|
||||
src/df
|
||||
src/dir
|
||||
src/dircolors
|
||||
src/dircolors.h
|
||||
src/dirname
|
||||
src/du
|
||||
src/echo
|
||||
src/env
|
||||
src/expand
|
||||
src/expr
|
||||
src/factor
|
||||
src/false
|
||||
src/fmt
|
||||
src/fold
|
||||
src/fs.h
|
||||
src/ginstall
|
||||
src/groups
|
||||
src/head
|
||||
src/hostid
|
||||
src/hostname
|
||||
src/id
|
||||
src/join
|
||||
src/kill
|
||||
src/link
|
||||
src/ln
|
||||
src/localedir.h
|
||||
src/logname
|
||||
src/ls
|
||||
src/md5sum
|
||||
src/mkdir
|
||||
src/mkfifo
|
||||
src/mknod
|
||||
src/mv
|
||||
src/nice
|
||||
src/nl
|
||||
src/nohup
|
||||
src/od
|
||||
src/paste
|
||||
src/pathchk
|
||||
src/pinky
|
||||
src/pr
|
||||
src/printenv
|
||||
src/printf
|
||||
src/ptx
|
||||
src/pwd
|
||||
src/readlink
|
||||
src/rm
|
||||
src/rmdir
|
||||
src/seq
|
||||
src/setuidgid
|
||||
src/sha1sum
|
||||
src/sha224sum
|
||||
src/sha256sum
|
||||
src/sha384sum
|
||||
src/sha512sum
|
||||
src/shred
|
||||
src/sleep
|
||||
src/sort
|
||||
src/split
|
||||
src/stat
|
||||
src/stty
|
||||
src/su
|
||||
src/sum
|
||||
src/sync
|
||||
src/tac
|
||||
src/tail
|
||||
src/tee
|
||||
src/test
|
||||
src/touch
|
||||
src/tr
|
||||
src/true
|
||||
src/tsort
|
||||
src/tty
|
||||
src/uname
|
||||
src/unexpand
|
||||
src/uniq
|
||||
src/unlink
|
||||
src/uptime
|
||||
src/users
|
||||
src/vdir
|
||||
src/wc
|
||||
src/wheel-size.h
|
||||
src/wheel.h
|
||||
src/who
|
||||
src/whoami
|
||||
src/yes
|
||||
stamp-h1
|
||||
tests/cut/cut-tests
|
||||
tests/head/head-tests
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.1
|
||||
6.7
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Suppress valgrind diagnostics we don't care about.
|
||||
|
||||
# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003, 2004, 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
|
||||
@@ -49,3 +49,31 @@
|
||||
sigaction(act)
|
||||
fun:__libc_sigaction
|
||||
}
|
||||
|
||||
{
|
||||
libc_expand_dynamic_string_token
|
||||
Memcheck:Cond
|
||||
fun:strlen
|
||||
fun:expand_dynamic_string_token
|
||||
obj:*
|
||||
obj:*
|
||||
obj:*
|
||||
obj:*
|
||||
obj:*
|
||||
}
|
||||
{
|
||||
libc__dl_new_object
|
||||
Memcheck:Cond
|
||||
fun:strlen
|
||||
fun:_dl_new_object
|
||||
obj:*
|
||||
obj:*
|
||||
obj:*
|
||||
obj:*
|
||||
}
|
||||
{
|
||||
libc_fillin_rpath
|
||||
Memcheck:Cond
|
||||
fun:strlen
|
||||
fun:fillin_rpath
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
ChangeLog(-[0-9]+)?$
|
||||
^old/
|
||||
^src/c99-to-c98\.diff$
|
||||
^gl/.*
|
||||
|
||||
@@ -5,3 +5,4 @@ config-log
|
||||
po/
|
||||
src/df.c
|
||||
src/stat.c
|
||||
tests/misc/df-P
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
^configure$
|
||||
ChangeLog
|
||||
^TODO$
|
||||
^lib/mktime\.c$
|
||||
^lib/getloadavg\.c$
|
||||
^lib/euidaccess\.c$
|
||||
^lib/euidaccess-stat\.c$
|
||||
^lib/group-member\.c$
|
||||
^Makefile\.maint$
|
||||
^doc/coreutils.texi$
|
||||
^src/stty.c$
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
Makefile\.in$
|
||||
\.po$
|
||||
^build-aux/texinfo\.tex$
|
||||
^src/c99-to-c89\.diff
|
||||
^tests/pr/
|
||||
|
||||
@@ -10,3 +10,4 @@
|
||||
^lib/strtod.c
|
||||
^lib/xstrtol.c
|
||||
^m4/
|
||||
^tests/misc/pwd-unreadable-parent
|
||||
|
||||
28
Makefile.am
28
Makefile.am
@@ -1,7 +1,6 @@
|
||||
# Make coreutils. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 1990, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||
# 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1990, 1993-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
|
||||
@@ -20,30 +19,32 @@
|
||||
|
||||
SUBDIRS = lib src doc man po tests
|
||||
EXTRA_DIST = Makefile.cfg Makefile.maint GNUmakefile \
|
||||
.hgignore \
|
||||
.gitignore \
|
||||
.hgignore \
|
||||
.kludge-stamp .prev-version THANKS-to-translators THANKStt.in \
|
||||
.vg-suppressions \
|
||||
.x-po-check \
|
||||
.x-sc_space_tab .x-sc_sun_os_names \
|
||||
.x-sc_file_system .x-sc_obsolete_symbols \
|
||||
.x-sc_prohibit_atoi_atof \
|
||||
.x-sc_require_config_h \
|
||||
.x-sc_space_tab .x-sc_sun_os_names \
|
||||
.x-sc_trailing_blank \
|
||||
.x-sc_unmarked_diagnostics \
|
||||
.x-sc_useless_cpp_parens \
|
||||
.x-sc_require_config_h \
|
||||
.x-sc_prohibit_atoi_atof \
|
||||
.x-sc_trailing_blank \
|
||||
announce-gen \
|
||||
ChangeLog-2005 \
|
||||
bootstrap \
|
||||
bootstrap.conf \
|
||||
build-aux/cvsu \
|
||||
build-aux/vc-list-files \
|
||||
gl/modules/getloadavg.diff \
|
||||
m4/ChangeLog \
|
||||
ChangeLog-2005 \
|
||||
old/fileutils/ChangeLog \
|
||||
old/fileutils/ChangeLog-1997 \
|
||||
old/fileutils/NEWS \
|
||||
old/sh-utils/ChangeLog \
|
||||
old/sh-utils/ChangeLog.0 \
|
||||
old/textutils/ChangeLog \
|
||||
old/fileutils/NEWS \
|
||||
old/sh-utils/NEWS \
|
||||
old/textutils/ChangeLog \
|
||||
old/textutils/NEWS
|
||||
|
||||
install-root:
|
||||
@@ -71,16 +72,17 @@ distcheck-hook:
|
||||
|
||||
rm_subst = \
|
||||
s!(rm -f (rm|\$$\(bin_PROGRAMS\)))$$!$$1 > /dev/null 2>&1 || /bin/$$1!
|
||||
MAINTAINERCLEANFILES = .kludge-stamp
|
||||
.kludge-stamp: $(srcdir)/src/Makefile.in
|
||||
perl -pi -e '$(rm_subst)' $(srcdir)/src/Makefile.in
|
||||
touch $@
|
||||
|
||||
|
||||
MAINTAINERCLEANFILES = THANKS-to-translators
|
||||
MAINTAINERCLEANFILES += THANKS-to-translators
|
||||
THANKS-to-translators: po/LINGUAS THANKStt.in
|
||||
( \
|
||||
cat $(srcdir)/THANKStt.in; \
|
||||
for lang in `cat po/LINGUAS`; do \
|
||||
for lang in `cat $(srcdir)/po/LINGUAS`; do \
|
||||
echo http://www.iro.umontreal.ca/contrib/po/HTML/team-$$lang.html; \
|
||||
done; \
|
||||
) > $@-tmp && mv $@-tmp $@
|
||||
|
||||
29
Makefile.cfg
29
Makefile.cfg
@@ -1,5 +1,5 @@
|
||||
# Customize Makefile.maint. -*- makefile -*-
|
||||
# Copyright (C) 2003-2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-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
|
||||
@@ -26,27 +26,6 @@ gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
|
||||
url_dir_list = \
|
||||
ftp://$(gnu_rel_host)/gnu/coreutils
|
||||
|
||||
# Files to update automatically.
|
||||
wget_files = \
|
||||
$(srcdir)/build-aux/config.guess \
|
||||
$(srcdir)/build-aux/config.sub \
|
||||
$(srcdir)/build-aux/texinfo.tex
|
||||
# Of the above, texinfo.tex is out of date,
|
||||
# and the other two are not available.
|
||||
wget_files =
|
||||
|
||||
cvs_files = \
|
||||
$(srcdir)/build-aux/elisp-comp \
|
||||
$(srcdir)/build-aux/depcomp \
|
||||
$(srcdir)/build-aux/mdate-sh \
|
||||
$(srcdir)/build-aux/missing \
|
||||
$(srcdir)/build-aux/install-sh \
|
||||
$(srcdir)/build-aux/mkinstalldirs
|
||||
|
||||
# $(srcdir)/src/ansi2knr.c
|
||||
|
||||
local_updates = wget-update cvs-update
|
||||
|
||||
# The GnuPG ID of the key used to sign the tarballs.
|
||||
gpg_key_ID = D333CBA1
|
||||
|
||||
@@ -54,4 +33,8 @@ gpg_key_ID = D333CBA1
|
||||
# Exclude changelog-check here so that there's less churn in ChangeLog
|
||||
# files -- otherwise, you'd need to have the upcoming version number
|
||||
# at the top of the file for each `make distcheck' run.
|
||||
local-checks-to-skip = changelog-check
|
||||
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.
|
||||
gnulib_dir = /gnulib
|
||||
|
||||
292
Makefile.maint
292
Makefile.maint
@@ -2,7 +2,7 @@
|
||||
# This Makefile fragment is shared between the coreutils,
|
||||
# CPPI, Bison, and Autoconf.
|
||||
|
||||
## Copyright (C) 2001-2006 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2001-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
|
||||
@@ -30,8 +30,10 @@ gzip_rsyncable := \
|
||||
GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
|
||||
|
||||
CVS = cvs
|
||||
GIT = git
|
||||
VC = $(GIT)
|
||||
VC-tag = git-tag -s -m '$(VERSION)'
|
||||
|
||||
# cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
|
||||
CVS_LIST = build-aux/vc-list-files
|
||||
|
||||
CVS_LIST_EXCEPT = \
|
||||
@@ -46,7 +48,7 @@ VERSION_REGEXP = $(subst .,\.,$(VERSION))
|
||||
|
||||
tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
|
||||
tag-this-version = $(subst .,_,$(VERSION))
|
||||
this-cvs-tag = $(tag-package)-$(tag-this-version)
|
||||
this-vc-tag = $(tag-package)-$(tag-this-version)
|
||||
my_distdir = $(PACKAGE)-$(VERSION)
|
||||
|
||||
# Old releases are stored here.
|
||||
@@ -67,23 +69,23 @@ export LC_ALL = C
|
||||
# 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))
|
||||
.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 writable-files m4-check author_mark_check \
|
||||
po-check copyright-check m4-check author_mark_check \
|
||||
changelog-check patch-check strftime-check $(syntax-check-rules) \
|
||||
makefile_path_separator_check \
|
||||
makefile-check check-AUTHORS
|
||||
.PHONY: $(local-checks-available)
|
||||
|
||||
local-check = $(filter-out $(local-checks-to-skip), $(local-checks-available))
|
||||
local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available))
|
||||
|
||||
# Collect the names of rules starting with `sc_'.
|
||||
syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
|
||||
.PHONY: $(syntax-check-rules)
|
||||
|
||||
syntax-check: $(syntax-check-rules)
|
||||
syntax-check: $(local-check)
|
||||
# @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
|
||||
# $$(find -type f -name '*.[chly]') && \
|
||||
# { echo '$(ME): found conditional include' 1>&2; \
|
||||
@@ -96,20 +98,17 @@ syntax-check: $(syntax-check-rules)
|
||||
# FIXME: don't allow `#include .strings\.h' anywhere
|
||||
|
||||
sc_cast_of_argument_to_free:
|
||||
@grep -nE '\<free \(\(' $(srcdir)/{lib,src}/*.[chly] && \
|
||||
@grep -nE '\<free \(\(' $$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_cast_of_x_alloc_return_value:
|
||||
@grep -nE --exclude=$(srcdir)/lib/regex.c \
|
||||
'\*\) *x(m|c|re)alloc\>' \
|
||||
$(srcdir)/{lib,src}/*.[chy] && \
|
||||
@grep -nE '\*\) *x(m|c|re)alloc\>' $$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_cast_of_alloca_return_value:
|
||||
@grep -nE '\*\) *alloca\>' \
|
||||
$(srcdir)/src/*.[chy] && \
|
||||
@grep -nE '\*\) *alloca\>' $$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): don'\''t cast alloca return value' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
@@ -118,18 +117,18 @@ sc_space_tab:
|
||||
{ echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Don't use the old ato* functions in `real' code.
|
||||
# Don't use *scanf or the old ato* functions in `real' code.
|
||||
# They provide no error checking mechanism.
|
||||
# Instead, use strto* functions.
|
||||
sc_prohibit_atoi_atof:
|
||||
@grep -nE '\<ato([filq]|ll)\>' $$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): do not use ato''f, ato''i, ato''l, ato''ll, or ato''q' \
|
||||
@grep -nE '\<([fs]?scanf|ato([filq]|ll))\>' $$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): do not use *scan''f, ato''f, ato''i, ato''l, ato''ll, or ato''q' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Using EXIT_SUCCESS as the first argument to error is misleading,
|
||||
# since when that parameter is 0, error does not exit. Use `0' instead.
|
||||
sc_error_exit_success:
|
||||
@grep -nF 'error (EXIT_SUCCESS,' \
|
||||
@grep -nF 'error (EXIT_SUCCESS,' \
|
||||
$$(find -type f -name '*.[chly]') && \
|
||||
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
|
||||
exit 1; } || :
|
||||
@@ -209,7 +208,9 @@ sc_prohibit_jm_in_m4:
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
sc_root_tests:
|
||||
@t1=sc-root.expected; t2=sc-root.actual; \
|
||||
@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' \
|
||||
@@ -218,7 +219,42 @@ sc_root_tests:
|
||||
rm -f $$t1 $$t2; \
|
||||
test "$$diff" \
|
||||
&& { echo 'tests/Makefile.am: missing check-root action'>&2; \
|
||||
exit 1; } || :
|
||||
exit 1; } || :; \
|
||||
fi
|
||||
|
||||
headers_with_interesting_macro_defs = \
|
||||
exit.h \
|
||||
fcntl_.h \
|
||||
fnmatch_.h \
|
||||
intprops.h \
|
||||
inttypes_.h \
|
||||
lchown.h \
|
||||
openat.h \
|
||||
stat-macros.h \
|
||||
stdint_.h
|
||||
|
||||
# Create a list of regular expressions matching the names
|
||||
# of macros that are guaranteed by parts of gnulib to be defined.
|
||||
.re-defmac:
|
||||
@(cd $(srcdir)/lib; \
|
||||
for f in $(headers_with_interesting_macro_defs); do \
|
||||
test -f $$f && \
|
||||
sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
|
||||
done; \
|
||||
) | sort -u \
|
||||
| grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
|
||||
| sed 's/^/^# *define /' \
|
||||
> $@-t
|
||||
@mv $@-t $@
|
||||
|
||||
# Don't define macros that we already get from gnulib header files.
|
||||
sc_always_defined_macros: .re-defmac
|
||||
@if test -f $(srcdir)/src/system.h; then \
|
||||
trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
|
||||
grep -f .re-defmac $$($(CVS_LIST)) \
|
||||
&& { echo '$(ME): define the above via some gnulib .h file' \
|
||||
1>&2; exit 1; } || :; \
|
||||
fi
|
||||
|
||||
# Create a list of regular expressions matching the names
|
||||
# of files included from system.h. Exclude a couple.
|
||||
@@ -264,7 +300,7 @@ sc_trailing_blank:
|
||||
# Match lines like the following, but where there is only one space
|
||||
# between the options and the description:
|
||||
# -D, --all-repeated[=delimit-method] print all duplicate lines\n
|
||||
longopt_re = --[a-z][0-9A-Za-z-]*(\[=[0-9A-Za-z-]*\])?
|
||||
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)) && \
|
||||
@@ -292,12 +328,18 @@ sc_useless_cpp_parens:
|
||||
patch-check:
|
||||
rm -rf src-c89 $@.1 $@.2
|
||||
cp -a src src-c89
|
||||
(cd src-c89; patch -V never --fuzz=0) < src/c99-to-c89.diff \
|
||||
(cd src-c89; patch -p2 -V never --fuzz=0) < src/c99-to-c89.diff \
|
||||
> $@.1 2>&1
|
||||
if test "$${REGEN_PATCH+set}" = set; then \
|
||||
diff -upr src src-c89 > new-diff || : ; fi
|
||||
grep -v '^patching file ' $@.1 > $@.2 || :
|
||||
fail=0; test -s $@.2 && fail=1 || : ; \
|
||||
rm -rf src-c89 $@.1 $@.2; \
|
||||
test $$fail = 0
|
||||
msg=ok; test -s $@.2 && msg='fuzzy patch' || : ; \
|
||||
rm -f src-c89/*.o || msg='rm failed'; \
|
||||
$(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \
|
||||
|| msg='compile failure with extra options'; \
|
||||
rm -rf src-c89 $@.1 $@.2; \
|
||||
test "$$msg" = ok && : || echo "$$msg" 1>&2; \
|
||||
test "$$msg" = ok
|
||||
|
||||
# Ensure that date's --help output stays in sync with the info
|
||||
# documentation for GNU strftime. The only exception is %N,
|
||||
@@ -325,22 +367,22 @@ makefile-check:
|
||||
&& { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
|
||||
|
||||
news-date-check: NEWS
|
||||
today=`date +%Y-%m-%d`; \
|
||||
if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
|
||||
>/dev/null; then \
|
||||
:; \
|
||||
else \
|
||||
echo "version or today's date is not in NEWS" 1>&2; \
|
||||
exit 1; \
|
||||
today=`date +%Y-%m-%d`; \
|
||||
if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
|
||||
>/dev/null; then \
|
||||
:; \
|
||||
else \
|
||||
echo "version or today's date is not in NEWS" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
changelog-check:
|
||||
if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
|
||||
>/dev/null; then \
|
||||
:; \
|
||||
else \
|
||||
echo "$(VERSION) not in ChangeLog" 1>&2; \
|
||||
exit 1; \
|
||||
if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
|
||||
>/dev/null; then \
|
||||
:; \
|
||||
else \
|
||||
echo "$(VERSION) not in ChangeLog" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
m4-check:
|
||||
@@ -358,6 +400,7 @@ po-check:
|
||||
for file in $$($(CVS_LIST_EXCEPT)) lib/*.[ch]; do \
|
||||
case $$file in \
|
||||
djgpp/* | man/*) continue;; \
|
||||
*/c99-to-c89.diff) continue;; \
|
||||
esac; \
|
||||
case $$file in \
|
||||
*.[ch]) \
|
||||
@@ -366,7 +409,8 @@ po-check:
|
||||
esac; \
|
||||
files="$$files $$file"; \
|
||||
done; \
|
||||
grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort -u > $@-2; \
|
||||
grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
|
||||
| sort -u > $@-2; \
|
||||
diff -u $@-1 $@-2 || exit 1; \
|
||||
rm -f $@-1 $@-2; \
|
||||
fi
|
||||
@@ -405,6 +449,7 @@ writable-files:
|
||||
test "$$fail" && exit 1 || :
|
||||
|
||||
v_etc_file = lib/version-etc.c
|
||||
sample-test = tests/sample-test
|
||||
# Make sure that the copyright date in $(v_etc_file) is up to date.
|
||||
copyright-check:
|
||||
@if test -f $(v_etc_file); then \
|
||||
@@ -413,26 +458,40 @@ copyright-check:
|
||||
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
|
||||
exit 1; }; \
|
||||
fi
|
||||
|
||||
|
||||
# Sanity checks with the CVS repository.
|
||||
cvs-tag-check:
|
||||
echo $(this-cvs-tag); \
|
||||
if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
|
||||
echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
|
||||
exit 1; \
|
||||
else :; fi
|
||||
|
||||
cvs-diff-check:
|
||||
if $(CVS) diff >cvs-diffs; then \
|
||||
rm cvs-diffs; \
|
||||
else \
|
||||
echo "Some files are locally modified:" 1>&2; \
|
||||
cat cvs-diffs; \
|
||||
exit 1; \
|
||||
@if test -f $(sample-test); then \
|
||||
grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
|
||||
>/dev/null \
|
||||
|| { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
|
||||
exit 1; }; \
|
||||
fi
|
||||
|
||||
cvs-check: cvs-diff-check cvs-tag-check
|
||||
|
||||
# Sanity checks with the repository.
|
||||
# Abort early if this tag has already been used.
|
||||
vc-tag-check:
|
||||
used=no; \
|
||||
if $(VC) --help | grep CVS; then \
|
||||
$(CVS) -n log -h README|grep -e $(this-vc-tag): >/dev/null \
|
||||
&& used=yes; \
|
||||
else \
|
||||
$(GIT) tag -l '^$(this-vc-tag)$$' && used=yes; \
|
||||
fi; \
|
||||
if test "$$used" = yes; then \
|
||||
echo "$(this-vc-tag) has already been used; not tagging" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
vc-diff-check:
|
||||
$(VC) diff > vc-diffs || :
|
||||
if test -s vc-diffs; then \
|
||||
cat vc-diffs; \
|
||||
echo "Some files are locally modified:" 1>&2; \
|
||||
exit 1; \
|
||||
else \
|
||||
rm vc-diffs; \
|
||||
fi
|
||||
|
||||
cvs-check: vc-diff-check vc-tag-check
|
||||
|
||||
maintainer-distcheck:
|
||||
$(MAKE) distcheck
|
||||
@@ -442,9 +501,8 @@ maintainer-distcheck:
|
||||
# Tag before making distribution. Also, don't make a distribution if
|
||||
# checks fail. Also, make sure the NEWS file is up-to-date.
|
||||
# FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
|
||||
cvs-dist: $(local-check) cvs-check maintainer-distcheck
|
||||
$(CVS) update po
|
||||
$(CVS) tag -c $(this-cvs-tag)
|
||||
vc-dist: $(local-check) cvs-check maintainer-distcheck
|
||||
$(VC-tag) $(this-vc-tag)
|
||||
$(MAKE) dist
|
||||
|
||||
# Use this to make sure we don't run these programs when building
|
||||
@@ -456,11 +514,11 @@ null_AM_MAKEFLAGS = \
|
||||
AUTOHEADER=false \
|
||||
MAKEINFO=false
|
||||
|
||||
# Detect format-string/arg-list mismatches that would normally be obscured
|
||||
# by the use of _(). The --disable-nls effectively defines away that macro,
|
||||
# and building with CFLAGS='-Wformat -Werror' causes any format warning to be
|
||||
# treated as a failure. Also, check for shadowing problems with -Wshadow,
|
||||
# and for pointer arithmetic problems with -Wpointer-arith.
|
||||
warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
|
||||
|
||||
# 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.
|
||||
TMPDIR ?= /tmp
|
||||
@@ -471,7 +529,7 @@ my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
|
||||
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
|
||||
cd $(t)/$(distdir) \
|
||||
&& ./configure --disable-nls \
|
||||
&& $(MAKE) CFLAGS='-Werror -Wall -Wformat -Wshadow -Wpointer-arith' \
|
||||
&& $(MAKE) CFLAGS='$(warn_cflags)' \
|
||||
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
||||
&& $(MAKE) dvi \
|
||||
&& $(MAKE) check \
|
||||
@@ -479,6 +537,13 @@ my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
|
||||
(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 -pedantic -Wno-long-long' \
|
||||
&& $(MAKE); \
|
||||
fi
|
||||
-rm -rf $(t)
|
||||
@echo "========================"; \
|
||||
echo "$(distdir).tar.gz is ready for distribution"; \
|
||||
@@ -500,17 +565,22 @@ prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
|
||||
xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
|
||||
|
||||
rel-files = $(xd-delta) $(DIST_ARCHIVES)
|
||||
|
||||
# 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)
|
||||
@./announce-gen \
|
||||
@cl_date=$$(stat --printf @%Y $(gnulib_dir)/ChangeLog); \
|
||||
utc_date=$$(date -u --date $$cl_date '+%Y-%m-%d %T %z'); \
|
||||
./build-aux/announce-gen \
|
||||
--release-type=$(RELEASE_TYPE) \
|
||||
--package=$(PACKAGE) \
|
||||
--prev=$(PREV_VERSION) \
|
||||
--curr=$(VERSION) \
|
||||
--release-archive-directory=$(release_archive_dir) \
|
||||
--gpg-key-id=$(gpg_key_ID) \
|
||||
--news=NEWS \
|
||||
$(addprefix --url-dir=, $(url_dir_list)) \
|
||||
|
||||
--bootstrap-tools=autoconf,automake,bison,gnulib \
|
||||
--gnulib-snapshot-time-stamp="$$utc_date" \
|
||||
$(addprefix --url-dir=, $(url_dir_list))
|
||||
|
||||
## ---------------- ##
|
||||
## Updating files. ##
|
||||
@@ -522,79 +592,11 @@ www-gnu = http://www.gnu.org
|
||||
# Use mv, if you don't have/want move-if-change.
|
||||
move_if_change ?= move-if-change
|
||||
|
||||
|
||||
# --------------------- #
|
||||
# Updating everything. #
|
||||
# --------------------- #
|
||||
|
||||
.PHONY: update
|
||||
local_updates ?= wget-update cvs-update
|
||||
update: $(local_updates)
|
||||
|
||||
|
||||
# -------------------------- #
|
||||
# Updating GNU build tools. #
|
||||
# -------------------------- #
|
||||
|
||||
# The following pseudo table associates a local directory and a URL
|
||||
# with each of the files that belongs to some other package and is
|
||||
# regularly updated from the specified URL.
|
||||
wget_files ?= \
|
||||
$(srcdir)/build-aux/config.guess \
|
||||
$(srcdir)/build-aux/config.sub \
|
||||
$(srcdir)/build-aux/texinfo.tex \
|
||||
$(srcdir)/src/ansi2knr.c
|
||||
|
||||
get-targets = $(patsubst %, get-%, $(wget_files))
|
||||
|
||||
config.guess-url_prefix = $(ftp-gnu)/build-aux/
|
||||
config.sub-url_prefix = $(ftp-gnu)/build-aux/
|
||||
|
||||
ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
|
||||
|
||||
texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
|
||||
|
||||
standards.texi-url_prefix = $(www-gnu)/prep/
|
||||
make-stds.texi-url_prefix = $(standards.texi-url_prefix)
|
||||
|
||||
target = $(patsubst get-%, %, $@)
|
||||
url = $($(notdir $(target))-url_prefix)$(notdir $(target))
|
||||
|
||||
.PHONY: $(get-targets)
|
||||
$(get-targets):
|
||||
$(WGET) $(WGETFLAGS) $(url) -O $(target).t \
|
||||
&& $(move_if_change) $(target).t $(target)
|
||||
|
||||
cvs_files ?= \
|
||||
$(srcdir)/build-aux/depcomp \
|
||||
$(srcdir)/build-aux/install-sh \
|
||||
$(srcdir)/build-aux/missing \
|
||||
$(srcdir)/build-aux/mkinstalldirs \
|
||||
$(srcdir)/src/ansi2knr.c
|
||||
automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
|
||||
.PHONY: wget-update
|
||||
wget-update: $(get-targets)
|
||||
|
||||
.PHONY: cvs-update
|
||||
cvs-update:
|
||||
fail=; \
|
||||
for f in $(cvs_files); do \
|
||||
test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
|
||||
cvs diff $$f > /dev/null \
|
||||
|| { echo "*** $$f is locally modified; skipping it" 1>&2; \
|
||||
fail=yes; continue; }; \
|
||||
file=$$(basename $$f); \
|
||||
echo checking out $$file...; \
|
||||
$(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
|
||||
&& $(move_if_change) $$f.t $$f; \
|
||||
done; \
|
||||
test "$$fail" && exit 1
|
||||
|
||||
emit_upload_commands:
|
||||
@echo =====================================
|
||||
@echo =====================================
|
||||
@echo "$(srcdir)/build-aux/gnupload $(GNUPLOADFLAGS) \\"
|
||||
@echo " --to $(gnu_rel_host):coreutils \\"
|
||||
@echo " --to $(gnu_rel_host):$(PACKAGE) \\"
|
||||
@echo " $(rel-files)"
|
||||
@echo '# send the /tmp/announcement e-mail'
|
||||
@echo =====================================
|
||||
@@ -604,16 +606,18 @@ $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
|
||||
xdelta delta -9 $^ $@ || :
|
||||
|
||||
.PHONY: alpha beta major
|
||||
alpha beta major: news-date-check changelog-check $(local-check)
|
||||
alpha beta major: news-date-check changelog-check $(local-check) writable-files
|
||||
test $@ = major \
|
||||
&& { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
|
||||
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
|
||||
|| :
|
||||
$(MAKE) cvs-dist
|
||||
$(MAKE) vc-dist
|
||||
$(MAKE) $(xd-delta)
|
||||
$(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
|
||||
ln $(rel-files) $(release_archive_dir)
|
||||
chmod a-w $(rel-files)
|
||||
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
|
||||
echo $(VERSION) > $(prev_version_file)
|
||||
$(CVS) ci -m. $(prev_version_file)
|
||||
$(VC) commit -m \
|
||||
'$(prev_version_file): Record previous version: $(VERSION).' \
|
||||
$(prev_version_file)
|
||||
|
||||
194
NEWS
194
NEWS
@@ -1,5 +1,197 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 6.9 (2007-03-22) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
cp -x (--one-file-system) would fail to set mount point permissions
|
||||
|
||||
The default block size and output format for df -P are now unaffected by
|
||||
the DF_BLOCK_SIZE, BLOCK_SIZE, and BLOCKSIZE environment variables. It
|
||||
is still affected by POSIXLY_CORRECT, though.
|
||||
|
||||
Using pr -m -s (i.e. merging files, with TAB as the output separator)
|
||||
no longer inserts extraneous spaces between output columns.
|
||||
|
||||
|
||||
* Noteworthy changes in release 6.8 (2007-02-24) [not-unstable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chgrp, chmod, and chown now honor the --preserve-root option.
|
||||
Before, they would warn, yet continuing traversing and operating on /.
|
||||
|
||||
chmod no longer fails in an environment (e.g., a chroot) with openat
|
||||
support but with insufficient /proc support.
|
||||
|
||||
"cp --parents F/G D" no longer creates a directory D/F when F is not
|
||||
a directory (and F/G is therefore invalid).
|
||||
|
||||
"cp --preserve=mode" would create directories that briefly had
|
||||
too-generous permissions in some cases. For example, when copying a
|
||||
directory with permissions 777 the destination directory might
|
||||
temporarily be setgid on some file systems, which would allow other
|
||||
users to create subfiles with the same group as the directory. Fix
|
||||
similar problems with 'install' and 'mv'.
|
||||
|
||||
cut no longer dumps core for usage like "cut -f2- f1 f2" with two or
|
||||
more file arguments. This was due to a double-free bug, introduced
|
||||
in coreutils-5.3.0.
|
||||
|
||||
dd bs= operands now silently override any later ibs= and obs=
|
||||
operands, as POSIX and tradition require.
|
||||
|
||||
"ls -FRL" always follows symbolic links on Linux. Introduced in
|
||||
coreutils-6.0.
|
||||
|
||||
A cross-partition "mv /etc/passwd ~" (by non-root) now prints
|
||||
a reasonable diagnostic. Before, it would print this:
|
||||
"mv: cannot remove `/etc/passwd': Not a directory".
|
||||
|
||||
pwd and "readlink -e ." no longer fail unnecessarily when a parent
|
||||
directory is unreadable.
|
||||
|
||||
"rm -rf /etc/passwd" (run by non-root) now prints a diagnostic.
|
||||
Before it would print nothing.
|
||||
|
||||
"rm --interactive=never F" no longer prompts for an unwritable F
|
||||
|
||||
** New features
|
||||
|
||||
sort's new --compress-program=PROG option specifies a compression
|
||||
program to use when writing and reading temporary files.
|
||||
This can help save both time and disk space when sorting large inputs.
|
||||
|
||||
sort accepts the new option -C, which acts like -c except no diagnostic
|
||||
is printed. Its --check option now accepts an optional argument, and
|
||||
--check=quiet and --check=silent are now aliases for -C, while
|
||||
--check=diagnose-first is an alias for -c or plain --check.
|
||||
|
||||
|
||||
* Noteworthy changes in release 6.7 (2006-12-08) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
When cp -p copied a file with special mode bits set, the same bits
|
||||
were set on the copy even when ownership could not be preserved.
|
||||
This could result in files that were setuid to the wrong user.
|
||||
To fix this, special mode bits are now set in the copy only if its
|
||||
ownership is successfully preserved. Similar problems were fixed
|
||||
with mv when copying across file system boundaries. This problem
|
||||
affects all versions of coreutils through 6.6.
|
||||
|
||||
cp --preserve=ownership would create output files that temporarily
|
||||
had too-generous permissions in some cases. For example, when
|
||||
copying a file with group A and mode 644 into a group-B sticky
|
||||
directory, the output file was briefly readable by group B.
|
||||
Fix similar problems with cp options like -p that imply
|
||||
--preserve=ownership, with install -d when combined with either -o
|
||||
or -g, and with mv when copying across file system boundaries.
|
||||
This bug affects coreutils 6.0 through 6.6.
|
||||
|
||||
du --one-file-system (-x) would skip subdirectories of any directory
|
||||
listed as second or subsequent command line argument. This bug affects
|
||||
coreutils-6.4, 6.5 and 6.6.
|
||||
|
||||
|
||||
* Noteworthy changes in release 6.6 (2006-11-22) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
ls would segfault (dereference a NULL pointer) for a file with a
|
||||
nameless group or owner. This bug was introduced in coreutils-6.5.
|
||||
|
||||
A bug in the latest official m4/gettext.m4 (from gettext-0.15)
|
||||
made configure fail to detect gettext support, due to the unusual
|
||||
way in which coreutils uses AM_GNU_GETTEXT.
|
||||
|
||||
** Improved robustness
|
||||
|
||||
Now, du (and the other fts clients: chmod, chgrp, chown) honor a
|
||||
trailing slash in the name of a symlink-to-directory even on
|
||||
Solaris 9, by working around its buggy fstatat implementation.
|
||||
|
||||
|
||||
* Major changes in release 6.5 (2006-11-19) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
du (and the other fts clients: chmod, chgrp, chown) would exit early
|
||||
when encountering an inaccessible directory on a system with native
|
||||
openat support (i.e., linux-2.6.16 or newer along with glibc-2.4
|
||||
or newer). This bug was introduced with the switch to gnulib's
|
||||
openat-based variant of fts, for coreutils-6.0.
|
||||
|
||||
"ln --backup f f" now produces a sensible diagnostic
|
||||
|
||||
** New features
|
||||
|
||||
rm accepts a new option: --one-file-system
|
||||
|
||||
|
||||
* Major changes in release 6.4 (2006-10-22) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chgrp and chown would malfunction when invoked with both -R and -H and
|
||||
with one or more of the following: --preserve-root, --verbose, --changes,
|
||||
--from=o:g (chown only). This bug was introduced with the switch to
|
||||
gnulib's openat-based variant of fts, for coreutils-6.0.
|
||||
|
||||
cp --backup dir1 dir2, would rename an existing dir2/dir1 to dir2/dir1~.
|
||||
This bug was introduced in coreutils-6.0.
|
||||
|
||||
With --force (-f), rm no longer fails for ENOTDIR.
|
||||
For example, "rm -f existing-non-directory/anything" now exits
|
||||
successfully, ignoring the error about a nonexistent file.
|
||||
|
||||
|
||||
* Major changes in release 6.3 (2006-09-30) [stable]
|
||||
|
||||
** Improved robustness
|
||||
|
||||
pinky no longer segfaults on Darwin 7.9.0 (MacOS X 10.3.9) due to a
|
||||
buggy native getaddrinfo function.
|
||||
|
||||
rm works around a bug in Darwin 7.9.0 (MacOS X 10.3.9) that would
|
||||
sometimes keep it from removing all entries in a directory on an HFS+
|
||||
or NFS-mounted partition.
|
||||
|
||||
sort would fail to handle very large input (around 40GB) on systems with a
|
||||
mkstemp function that returns a file descriptor limited to 32-bit offsets.
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chmod would fail unnecessarily in an unusual case: when an initially-
|
||||
inaccessible argument is rendered accessible by chmod's action on a
|
||||
preceding command line argument. This bug also affects chgrp, but
|
||||
it is harder to demonstrate. It does not affect chown. The bug was
|
||||
introduced with the switch from explicit recursion to the use of fts
|
||||
in coreutils-5.1.0 (2003-10-15).
|
||||
|
||||
cp -i and mv -i occasionally neglected to prompt when the copy or move
|
||||
action was bound to fail. This bug dates back to before fileutils-4.0.
|
||||
|
||||
With --verbose (-v), cp and mv would sometimes generate no output,
|
||||
or neglect to report file removal.
|
||||
|
||||
For the "groups" command:
|
||||
|
||||
"groups" no longer prefixes the output with "user :" unless more
|
||||
than one user is specified; this is for compatibility with BSD.
|
||||
|
||||
"groups user" now exits nonzero when it gets a write error.
|
||||
|
||||
"groups" now processes options like --help more compatibly.
|
||||
|
||||
shuf would infloop, given 8KB or more of piped input
|
||||
|
||||
** Portability
|
||||
|
||||
Versions of chmod, chown, chgrp, du, and rm (tools that use openat etc.)
|
||||
compiled for Solaris 8 now also work when run on Solaris 10.
|
||||
|
||||
|
||||
* Major changes in release 6.2 (2006-09-18) [stable candidate]
|
||||
|
||||
** Changes in behavior
|
||||
@@ -583,7 +775,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
cp and mv: the --reply=X option is deprecated
|
||||
|
||||
date accepts the new option --rfc-3339=TIMESPEC. The old --iso-8602 (-I)
|
||||
date accepts the new option --rfc-3339=TIMESPEC. The old --iso-8601 (-I)
|
||||
option is deprecated; it still works, but new applications should avoid it.
|
||||
date, du, ls, and pr's time formats now support new %:z, %::z, %:::z
|
||||
specifiers for numeric time zone offsets like -07:00, -07:00:00, and -07.
|
||||
|
||||
18
README
18
README
@@ -97,6 +97,18 @@ Here is one possible patch to correct the problem:
|
||||
+#ifndef __LP64__
|
||||
|
||||
|
||||
************************
|
||||
OSF/1 4.0d build failure
|
||||
------------------------
|
||||
|
||||
If you use /usr/bin/make on an OSF/1 4.0d system, it will fail due
|
||||
to the presence of the "[" target. That version of make appears to
|
||||
treat "[" as some syntax relating to locks. To work around that,
|
||||
the best solution is to use GNU make. Otherwise, simply remove
|
||||
all mention of "[$(EXEEXT)" from src/Makefile.
|
||||
|
||||
|
||||
|
||||
**********************
|
||||
Running tests as root:
|
||||
----------------------
|
||||
@@ -167,6 +179,12 @@ as you can. Based on the feedback that generates, you may be able to
|
||||
convince us that it's worth adding.
|
||||
|
||||
|
||||
WARNING: Now that we use the ./bootstrap script, you should not run
|
||||
autoreconf manually. Doing that will overwrite essential source files
|
||||
with older versions, which may make the package unbuildable or introduce
|
||||
subtle bugs.
|
||||
|
||||
|
||||
WARNING: If you modify files like configure.in, m4/*.m4, aclocal.m4,
|
||||
or any Makefile.am, then don't be surprised if what gets regenerated no
|
||||
longer works. To make things work, you'll have to be using appropriate
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
-*- outline -*-
|
||||
|
||||
These notes intend to help people working on the CVS version of
|
||||
this package.
|
||||
These notes intend to help people working on the checked-out sources.
|
||||
These requirements do not apply when building from a distribution tarball.
|
||||
|
||||
* Requirements
|
||||
|
||||
Only the sources are installed in the CVS repository (to ease the
|
||||
maintenance, merges etc.), therefore you will have to get the latest
|
||||
stable versions of the maintainer tools we depend upon, including:
|
||||
We've opted to keep only the highest-level sources in the GIT repository.
|
||||
This eases our maintenance burden, (fewer merges etc.), but imposes more
|
||||
requirements on anyone wishing to build from the just-checked-out sources.
|
||||
For example, you have to use the latest stable versions of the maintainer
|
||||
tools we depend upon, including:
|
||||
|
||||
- Automake <http://www.gnu.org/software/automake/>
|
||||
- Autoconf <http://www.gnu.org/software/autoconf/>
|
||||
- Bison <http://www.gnu.org/software/bison/>
|
||||
- Gettext <http://www.gnu.org/software/gettext/>
|
||||
- Gzip <http://www.gnu.org/software/gzip/>
|
||||
- Tar <http://www.gnu.org/software/tar/>
|
||||
@@ -22,13 +25,13 @@ suggest using test version 1.3.5 (or later, if one becomes available).
|
||||
Valgrind <http://valgrind.org/> is also highly recommended, if
|
||||
Valgrind supports your architecture.
|
||||
|
||||
Only building the initial full source tree will be a bit painful,
|
||||
later, a plain `cvs update -P && make' should be sufficient.
|
||||
Only building the initial full source tree will be a bit painful.
|
||||
Later, a plain `git-pull && make' should be sufficient.
|
||||
|
||||
* First CVS checkout
|
||||
* First GIT checkout
|
||||
|
||||
Obviously, if you are reading these notes, you did manage to check out
|
||||
this package from CVS. The next step is to get other files needed to
|
||||
this package from GIT. The next step is to get other files needed to
|
||||
build, which are extracted from other source packages:
|
||||
|
||||
$ ./bootstrap
|
||||
@@ -40,9 +43,9 @@ And there you are! Just
|
||||
$ make check
|
||||
|
||||
At this point, there should be no difference between your local copy,
|
||||
and the CVS master copy:
|
||||
and the GIT master copy:
|
||||
|
||||
$ cvs diff
|
||||
$ git-diff
|
||||
|
||||
should output no difference.
|
||||
|
||||
@@ -50,8 +53,7 @@ Enjoy!
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
Inc.
|
||||
Copyright (C) 2002-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
|
||||
13
THANKS
13
THANKS
@@ -150,6 +150,7 @@ Eric Pemente pemente@northpark.edu
|
||||
Eric S. Raymond esr@snark.thyrsus.com
|
||||
Erik Bennett bennett@cvo.oneworld.com
|
||||
Erik Corry erik@kroete2.freinet.de
|
||||
Evan Hunt ethanol@armory.com
|
||||
Felix Lee flee@teleport.com
|
||||
Felix Rauch Valenti frauch@cse.unsw.edu.au
|
||||
Ferdinand fw@scenic.mine.nu
|
||||
@@ -192,12 +193,14 @@ Hans Verkuil hans@wyst.hobby.nl
|
||||
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
|
||||
Helen Faulkner helen_ml_faulkner@yahoo.co.uk
|
||||
Herbert Xu herbert@gondor.apana.org.au
|
||||
Holger Berger hberger@ess.nec.de
|
||||
Hon-Yin Kok hkok@yoda.unl.edu
|
||||
Hugh Daniel hugh@xanadu.com
|
||||
Ian Bruce ian.bruce@myrealbox.com
|
||||
Iain Calder ic56@rogers.com
|
||||
Ian Jackson ijackson@chiark.greenend.org.uk
|
||||
Ian Lance Taylor ian@cygnus.com
|
||||
Ian Turner vectro@pipeline.com
|
||||
@@ -207,10 +210,12 @@ 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 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 Nieuwenhuizen janneke@gnu.org
|
||||
Janos Farkas chexum@shadow.banki.hu
|
||||
@@ -287,6 +292,7 @@ Manas Garg manas@cygsoft.com
|
||||
Manfred Hollstein manfred@s-direktnet.de
|
||||
Marc Boucher marc@mbsi.ca
|
||||
Marc Haber mh+debian-bugs@zugschlus.de
|
||||
Marc Lehman schmorp@schmorp.de
|
||||
Marc Olzheim marcolz@stack.nl
|
||||
Marco Franzen Marco.Franzen@Thyron.com
|
||||
Marcus Brinkmann http://www.marcus-brinkmann.de
|
||||
@@ -320,11 +326,13 @@ Matt Perry matt@primefactor.com
|
||||
Matt Schalit mschalit@pacbell.net
|
||||
Matt Swift swift@alum.mit.edu
|
||||
Matthew Arnison maffew@cat.org.au
|
||||
Matthew M. Boedicker matthewm@boedicker.org
|
||||
Matthew Braun matthew@ans.net
|
||||
Matthew Clarke Matthew_Clarke@mindlink.bc.ca
|
||||
Matthew S. Levine mslevine@theory.lcs.mit.edu
|
||||
Matthew Smith matts@bluesguitar.org
|
||||
Matthew Swift swift@alum.mit.edu
|
||||
Matthew Woehlke mw_triad@users.sourceforge.net
|
||||
Matthias Urlichs smurf@noris.de
|
||||
Matti Aarnio matti.aarnio@zmailer.org
|
||||
Mattias Wadenstein maswan@acc.umu.se
|
||||
@@ -388,6 +396,7 @@ Paul Worrall paul@basilisk.uklinux.net
|
||||
Pawel Prokop pablo@wizard.ae.krakow.pl
|
||||
Per Cederqvist ceder@lysator.liu.se
|
||||
Per Kristian Hove perhov@math.ntnu.no
|
||||
Peter Breitenlohner peb@mppmu.mpg.de
|
||||
Peter Eriksson peter@ifm.liu.se
|
||||
Peter Fales psfales@lucent.com
|
||||
Peter Horst peter@ointment.org
|
||||
@@ -432,6 +441,7 @@ Ross Paterson rap@doc.ic.ac.uk
|
||||
Ross Ridge rridge@calum.csclub.uwaterloo.ca
|
||||
Sami Farin sfarin@ratol.fi
|
||||
Samuel Tardieu sam@rfc1149.net
|
||||
Samuel Thibault samuel.thibault@ens-lyon.org
|
||||
Samuli Karkkainen Samuli.Karkkainen@hut.fi
|
||||
Sander van Malssen svm@kozmix.ow.nl
|
||||
Santiago Vila Doncel sanvila@unex.es
|
||||
@@ -449,6 +459,7 @@ Stephen Eglen eglen@pcg.wustl.edu
|
||||
Stephen Gildea gildea@stop.mail-abuse.org
|
||||
Stephen Smoogen smooge@mindspring.com
|
||||
Steve McConnel steve@acadcomp.sil.org
|
||||
Steve McIntyre steve@einval.com
|
||||
Steven G. Johnson stevenj@alum.mit.edu
|
||||
Steven Mocking ufo@quicknet.nl
|
||||
Steven P Watson steven@magelico.net
|
||||
@@ -465,6 +476,7 @@ Thomas Hood jdthood@yahoo.co.uk
|
||||
Thomas Luzat thomas@luzat.com
|
||||
Thomas M.Ott thmo-13@gmx.de
|
||||
Thomas Quinot thomas@Cuivre.FR.EU.ORG
|
||||
Thomas Schwinge tschwinge@gnu.org
|
||||
Thomas Wolff mined@towo.net
|
||||
Tim J. Robbins tjr@FreeBSD.org
|
||||
Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu
|
||||
@@ -507,6 +519,7 @@ William Bader william@nscs.fast.net
|
||||
William Dowling will@franklin.com
|
||||
William Lewis wiml@omnigroup.com
|
||||
wiregauze wiregauze@yahoo.com
|
||||
Wis Macomson wis.macomson@intel.com
|
||||
Wojciech Purczynski cliph@isec.pl
|
||||
Wolfram Kleff kleff@cs.uni-bonn.de
|
||||
Won-kyu Park wkpark@chem.skku.ac.kr
|
||||
|
||||
9
TODO
9
TODO
@@ -1,3 +1,12 @@
|
||||
stty.c:
|
||||
use xstrtoul, not sscanf
|
||||
|
||||
printf:
|
||||
Now that gnulib supports *printf("%a"), import one of the
|
||||
*printf-posix modules so that printf(1) will support %a even on
|
||||
platforms where the native *printf(3) is deficient.
|
||||
Suggestion form Eric Blake.
|
||||
|
||||
strip: add an option to specify the program used to strip binaries.
|
||||
suggestion from Karl Berry
|
||||
|
||||
|
||||
436
announce-gen
436
announce-gen
@@ -1,436 +0,0 @@
|
||||
#!/usr/bin/perl -w
|
||||
# Generate an announcement message.
|
||||
|
||||
# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
use strict;
|
||||
|
||||
use Getopt::Long;
|
||||
use Digest::MD5;
|
||||
use Digest::SHA1;
|
||||
|
||||
(my $VERSION = '$Revision: 1.25 $ ') =~ tr/[0-9].//cd;
|
||||
(my $ME = $0) =~ s|.*/||;
|
||||
|
||||
my %valid_release_types = map {$_ => 1} qw (alpha beta major);
|
||||
|
||||
END
|
||||
{
|
||||
# Nobody ever checks the status of print()s. That's okay, because
|
||||
# if any do fail, we're guaranteed to get an indicator when we close()
|
||||
# the filehandle.
|
||||
#
|
||||
# Close stdout now, and if there were no errors, return happy status.
|
||||
# If stdout has already been closed by the script, though, do nothing.
|
||||
defined fileno STDOUT
|
||||
or return;
|
||||
close STDOUT
|
||||
and return;
|
||||
|
||||
# Errors closing stdout. Indicate that, and hope stderr is OK.
|
||||
warn "$ME: closing standard output: $!\n";
|
||||
|
||||
# Don't be so arrogant as to assume that we're the first END handler
|
||||
# defined, and thus the last one invoked. There may be others yet
|
||||
# to come. $? will be passed on to them, and to the final _exit().
|
||||
#
|
||||
# If it isn't already an error, make it one (and if it _is_ an error,
|
||||
# preserve the value: it might be important).
|
||||
$? ||= 1;
|
||||
}
|
||||
|
||||
sub usage ($)
|
||||
{
|
||||
my ($exit_code) = @_;
|
||||
my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
|
||||
if ($exit_code != 0)
|
||||
{
|
||||
print $STREAM "Try `$ME --help' for more information.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
my @types = sort keys %valid_release_types;
|
||||
print $STREAM <<EOF;
|
||||
Usage: $ME [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
|
||||
Generate an announcement message.
|
||||
|
||||
FIXME: describe the following
|
||||
|
||||
--release-type=TYPE TYPE must be one of @types
|
||||
--package-name=PACKAGE_NAME
|
||||
--previous-version=VER
|
||||
--current-version=VER
|
||||
--gpg-key-id=ID The GnuPG ID of the key used to sign the tarballs
|
||||
--release-archive-directory=DIR
|
||||
--url-directory=URL_DIR
|
||||
--news=NEWS_FILE optional
|
||||
|
||||
--help display this help and exit
|
||||
--version output version information and exit
|
||||
|
||||
EOF
|
||||
}
|
||||
exit $exit_code;
|
||||
}
|
||||
|
||||
|
||||
=item C<%size> = C<sizes (@file)>
|
||||
|
||||
Compute the sizes of the C<@file> and return them as a hash. Return
|
||||
C<undef> if one of the computation failed.
|
||||
|
||||
=cut
|
||||
|
||||
sub sizes (@)
|
||||
{
|
||||
my (@file) = @_;
|
||||
|
||||
my $fail = 0;
|
||||
my %res;
|
||||
foreach my $f (@file)
|
||||
{
|
||||
my $cmd = "du --human $f";
|
||||
my $t = `$cmd`;
|
||||
# FIXME-someday: give a better diagnostic, a la $PROCESS_STATUS
|
||||
$@
|
||||
and (warn "$ME: command failed: `$cmd'\n"), $fail = 1;
|
||||
chomp $t;
|
||||
$t =~ s/^([\d.]+[MkK]).*/${1}B/;
|
||||
$res{$f} = $t;
|
||||
}
|
||||
return $fail ? undef : %res;
|
||||
}
|
||||
|
||||
=item C<print_locations ($title, \@url, \%size, @file)
|
||||
|
||||
Print a section C<$title> dedicated to the list of <@file>, which
|
||||
sizes are stored in C<%size>, and which are available from the C<@url>.
|
||||
|
||||
=cut
|
||||
|
||||
sub print_locations ($\@\%@)
|
||||
{
|
||||
my ($title, $url, $size, @file) = @_;
|
||||
print "Here are the $title:\n";
|
||||
foreach my $url (@{$url})
|
||||
{
|
||||
for my $file (@file)
|
||||
{
|
||||
print " $url/$file";
|
||||
print " (", $$size{$file}, ")"
|
||||
if exists $$size{$file};
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
|
||||
=item C<print_checksums (@file)
|
||||
|
||||
Print the MD5 and SHA1 signature section for each C<@file>.
|
||||
|
||||
=cut
|
||||
|
||||
sub print_checksums (@)
|
||||
{
|
||||
my (@file) = @_;
|
||||
|
||||
print "Here are the MD5 and SHA1 checksums:\n";
|
||||
print "\n";
|
||||
|
||||
foreach my $meth (qw (md5 sha1))
|
||||
{
|
||||
foreach my $f (@file)
|
||||
{
|
||||
open IN, '<', $f
|
||||
or die "$ME: $f: cannot open for reading: $!\n";
|
||||
binmode IN;
|
||||
my $dig =
|
||||
($meth eq 'md5'
|
||||
? Digest::MD5->new->addfile(*IN)->hexdigest
|
||||
: Digest::SHA1->new->addfile(*IN)->hexdigest);
|
||||
close IN;
|
||||
print "$dig $f\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
=item C<print_news_deltas ($news_file, $prev_version, $curr_version)
|
||||
|
||||
Print the section of the NEWS file C<$news_file> addressing changes
|
||||
between versions C<$prev_version> and C<$curr_version>.
|
||||
|
||||
=cut
|
||||
|
||||
sub print_news_deltas ($$$)
|
||||
{
|
||||
my ($news_file, $prev_version, $curr_version) = @_;
|
||||
|
||||
print "\n$news_file\n\n";
|
||||
|
||||
# Print all lines from $news_file, starting with the first one
|
||||
# that mentions $curr_version up to but not including
|
||||
# the first occurrence of $prev_version.
|
||||
my $in_items;
|
||||
|
||||
open NEWS, '<', $news_file
|
||||
or die "$ME: $news_file: cannot open for reading: $!\n";
|
||||
while (defined (my $line = <NEWS>))
|
||||
{
|
||||
if ( ! $in_items)
|
||||
{
|
||||
# Match lines like this one:
|
||||
# * Major changes in release 5.0.1:
|
||||
# but not any other line that starts with a space, *, or -.
|
||||
$line =~ /^(\* Major changes.*|[^ *-].*)\Q$curr_version\E/o
|
||||
or next;
|
||||
$in_items = 1;
|
||||
print $line;
|
||||
}
|
||||
else
|
||||
{
|
||||
# Be careful that this regexp cannot match version numbers
|
||||
# in NEWS items -- they might well say `introduced in 4.5.5',
|
||||
# and we don't want that to match.
|
||||
$line =~ /^(\* Major changes.*|[^ *-].*)\Q$prev_version\E/o
|
||||
and last;
|
||||
print $line;
|
||||
}
|
||||
}
|
||||
close NEWS;
|
||||
|
||||
$in_items
|
||||
or die "$ME: $news_file: no matching lines for `$curr_version'\n";
|
||||
}
|
||||
|
||||
sub print_changelog_deltas ($$)
|
||||
{
|
||||
my ($package_name, $prev_version) = @_;
|
||||
|
||||
# Print new ChangeLog entries.
|
||||
|
||||
# First find all CVS-controlled ChangeLog files.
|
||||
use File::Find;
|
||||
my @changelog;
|
||||
find ({wanted => sub {$_ eq 'ChangeLog' && -d 'CVS'
|
||||
and push @changelog, $File::Find::name}},
|
||||
'.');
|
||||
|
||||
# If there are no ChangeLog files, we're done.
|
||||
@changelog
|
||||
or return;
|
||||
my %changelog = map {$_ => 1} @changelog;
|
||||
|
||||
# Reorder the list of files so that if there are ChangeLog
|
||||
# files in the specified directories, they're listed first,
|
||||
# in this order:
|
||||
my @dir = qw ( . src lib m4 config doc );
|
||||
|
||||
# A typical @changelog array might look like this:
|
||||
# ./ChangeLog
|
||||
# ./po/ChangeLog
|
||||
# ./m4/ChangeLog
|
||||
# ./lib/ChangeLog
|
||||
# ./doc/ChangeLog
|
||||
# ./config/ChangeLog
|
||||
my @reordered;
|
||||
foreach my $d (@dir)
|
||||
{
|
||||
my $dot_slash = $d eq '.' ? $d : "./$d";
|
||||
my $target = "$dot_slash/ChangeLog";
|
||||
delete $changelog{$target}
|
||||
and push @reordered, $target;
|
||||
}
|
||||
|
||||
# Append any remaining ChangeLog files.
|
||||
push @reordered, sort keys %changelog;
|
||||
|
||||
# Remove leading `./'.
|
||||
@reordered = map { s!^\./!!; $_ } @reordered;
|
||||
|
||||
print "\nChangeLog entries:\n\n";
|
||||
# print join ("\n", @reordered), "\n";
|
||||
|
||||
$prev_version =~ s/\./_/g;
|
||||
my $prev_cvs_tag = "\U$package_name\E-$prev_version";
|
||||
|
||||
my $cmd = "cvs -n diff -u -r$prev_cvs_tag -rHEAD @reordered";
|
||||
open DIFF, '-|', $cmd
|
||||
or die "$ME: cannot run `$cmd': $!\n";
|
||||
# Print two types of lines, making minor changes:
|
||||
# Lines starting with `+++ ', e.g.,
|
||||
# +++ ChangeLog 22 Feb 2003 16:52:51 -0000 1.247
|
||||
# and those starting with `+'.
|
||||
# Don't print the others.
|
||||
my $prev_printed_line_empty = 1;
|
||||
while (defined (my $line = <DIFF>))
|
||||
{
|
||||
if ($line =~ /^\+\+\+ /)
|
||||
{
|
||||
my $separator = "*"x70 ."\n";
|
||||
$line =~ s///;
|
||||
$line =~ s/\s.*//;
|
||||
$prev_printed_line_empty
|
||||
or print "\n";
|
||||
print $separator, $line, $separator;
|
||||
}
|
||||
elsif ($line =~ /^\+/)
|
||||
{
|
||||
$line =~ s///;
|
||||
print $line;
|
||||
$prev_printed_line_empty = ($line =~ /^$/);
|
||||
}
|
||||
}
|
||||
close DIFF;
|
||||
|
||||
# The exit code should be 1.
|
||||
# Allow in case there are no modified ChangeLog entries.
|
||||
$? == 256 || $? == 128
|
||||
or warn "$ME: warning: `cmd' had unexpected exit code or signal ($?)\n";
|
||||
}
|
||||
|
||||
{
|
||||
# Neutralize the locale, so that, for instance, "du" does not
|
||||
# issue "1,2" instead of "1.2", what confuses our regexps.
|
||||
$ENV{LC_ALL} = "C";
|
||||
|
||||
my $release_type;
|
||||
my $package_name;
|
||||
my $prev_version;
|
||||
my $curr_version;
|
||||
my $release_archive_dir;
|
||||
my $gpg_key_id;
|
||||
my @url_dir_list;
|
||||
my @news_file;
|
||||
|
||||
GetOptions
|
||||
(
|
||||
'release-type=s' => \$release_type,
|
||||
'package-name=s' => \$package_name,
|
||||
'previous-version=s' => \$prev_version,
|
||||
'current-version=s' => \$curr_version,
|
||||
'gpg-key-id=s' => \$gpg_key_id,
|
||||
'release-archive-directory=s' => \$release_archive_dir,
|
||||
'url-directory=s' => \@url_dir_list,
|
||||
'news=s' => \@news_file,
|
||||
|
||||
help => sub { usage 0 },
|
||||
version => sub { print "$ME version $VERSION\n"; exit },
|
||||
) or usage 1;
|
||||
|
||||
my $fail = 0;
|
||||
# Ensure that sure each required option is specified.
|
||||
$release_type
|
||||
or (warn "$ME: release type not specified\n"), $fail = 1;
|
||||
$package_name
|
||||
or (warn "$ME: package name not specified\n"), $fail = 1;
|
||||
$prev_version
|
||||
or (warn "$ME: previous version string not specified\n"), $fail = 1;
|
||||
$curr_version
|
||||
or (warn "$ME: current version string not specified\n"), $fail = 1;
|
||||
$release_archive_dir
|
||||
or (warn "$ME: release directory name not specified\n"), $fail = 1;
|
||||
@url_dir_list
|
||||
or (warn "$ME: URL directory name(s) not specified\n"), $fail = 1;
|
||||
|
||||
exists $valid_release_types{$release_type}
|
||||
or (warn "$ME: `$release_type': invalid release type\n"), $fail = 1;
|
||||
|
||||
@ARGV
|
||||
and (warn "$ME: too many arguments\n"), $fail = 1;
|
||||
$fail
|
||||
and usage 1;
|
||||
|
||||
my $my_distdir = "$package_name-$curr_version";
|
||||
my $tgz = "$my_distdir.tar.gz";
|
||||
my $tbz = "$my_distdir.tar.bz2";
|
||||
my $xd = "$package_name-$prev_version-$curr_version.xdelta";
|
||||
|
||||
my %size = sizes ($tgz, $tbz, $xd);
|
||||
%size
|
||||
or exit 1;
|
||||
|
||||
# The markup is escaped as <\# so that when this script is sent by
|
||||
# mail (or part of a diff), Gnus is not triggered.
|
||||
print <<EOF;
|
||||
|
||||
Subject: $my_distdir released
|
||||
|
||||
<\#secure method=pgpmime mode=sign>
|
||||
|
||||
FIXME: put comments here
|
||||
|
||||
EOF
|
||||
|
||||
print_locations ("compressed sources", @url_dir_list, %size,
|
||||
$tgz, $tbz);
|
||||
print_locations ("xdelta-style diffs", @url_dir_list, %size,
|
||||
$xd);
|
||||
print_locations ("GPG detached signatures[*]", @url_dir_list, %size,
|
||||
"$tgz.sig", "$tbz.sig");
|
||||
|
||||
print_checksums ($tgz, $tbz, $xd);
|
||||
|
||||
print <<EOF;
|
||||
|
||||
[*] You can use either of the above signature files to verify that
|
||||
the corresponding file (without the .sig suffix) is intact. First,
|
||||
be sure to download both the .sig file and the corresponding tarball.
|
||||
Then, run a command like this:
|
||||
|
||||
gpg --verify $tgz.sig
|
||||
|
||||
If that command fails because you don't have the required public key,
|
||||
then run this command to import it:
|
||||
|
||||
gpg --keyserver wwwkeys.pgp.net --recv-keys $gpg_key_id
|
||||
|
||||
and rerun the \`gpg --verify' command.
|
||||
EOF
|
||||
|
||||
print_news_deltas ($_, $prev_version, $curr_version)
|
||||
foreach @news_file;
|
||||
|
||||
$release_type eq 'major'
|
||||
or print_changelog_deltas ($package_name, $prev_version);
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
### Setup "GNU" style for perl-mode and cperl-mode.
|
||||
## Local Variables:
|
||||
## perl-indent-level: 2
|
||||
## perl-continued-statement-offset: 2
|
||||
## perl-continued-brace-offset: 0
|
||||
## perl-brace-offset: 0
|
||||
## perl-brace-imaginary-offset: 0
|
||||
## perl-label-offset: -2
|
||||
## cperl-indent-level: 2
|
||||
## cperl-brace-offset: 0
|
||||
## cperl-continued-brace-offset: 0
|
||||
## cperl-label-offset: -2
|
||||
## cperl-extra-newline-before-brace: t
|
||||
## cperl-merge-trailing-else: nil
|
||||
## cperl-continued-statement-offset: 2
|
||||
## End:
|
||||
341
bootstrap
341
bootstrap
@@ -1,8 +1,8 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Bootstrap this package from CVS.
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003, 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
|
||||
@@ -29,13 +29,42 @@ nl='
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
# Temporary directory names.
|
||||
bt='._bootmp'
|
||||
bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
|
||||
bt2=${bt}2
|
||||
|
||||
usage() {
|
||||
echo >&2 "\
|
||||
Usage: $0 [OPTION]...
|
||||
Bootstrap this package from the checked-out sources.
|
||||
|
||||
Options:
|
||||
--gnulib-srcdir=DIRNAME Specify the local directory where gnulib
|
||||
sources reside. Use this if you already
|
||||
have gnulib sources on your machine, and
|
||||
do not want to waste your bandwidth downloading
|
||||
them again.
|
||||
--copy Copy files instead of creating symbolic links.
|
||||
--force Attempt to bootstrap even if the sources seem
|
||||
not to have been checked out.
|
||||
--skip-po Do not download po files.
|
||||
--cvs-user=USERNAME Set the username to use when checking out
|
||||
sources from the gnulib repository.
|
||||
|
||||
If the file .bootstrap.conf exists in the current working directory, its
|
||||
contents are read as shell variables to configure the bootstrap.
|
||||
|
||||
Running without arguments will suffice in most cases.
|
||||
"
|
||||
}
|
||||
|
||||
# Configuration.
|
||||
|
||||
# List of gnulib modules needed.
|
||||
gnulib_modules=
|
||||
|
||||
# Any extra gnulib files needed.
|
||||
# Any gnulib files needed that are not in modules.
|
||||
gnulib_files=
|
||||
|
||||
# Translation Project URL, for the registry of all projects
|
||||
@@ -60,18 +89,20 @@ extract_package_name='
|
||||
}
|
||||
'
|
||||
package=`sed -n "$extract_package_name" configure.ac` || exit
|
||||
gnulib_name=lib$package
|
||||
|
||||
# Extra files from gnulib, which are not part of any module yet.
|
||||
gnulib_extra_files='
|
||||
build-aux/install-sh
|
||||
build-aux/missing
|
||||
build-aux/mdate-sh
|
||||
build-aux/texinfo.tex
|
||||
build-aux/depcomp
|
||||
build-aux/config.guess
|
||||
build-aux/config.sub
|
||||
build_aux=build-aux
|
||||
# Extra files from gnulib, which override files from other sources.
|
||||
gnulib_extra_files="
|
||||
$build_aux/install-sh
|
||||
$build_aux/missing
|
||||
$build_aux/mdate-sh
|
||||
$build_aux/texinfo.tex
|
||||
$build_aux/depcomp
|
||||
$build_aux/config.guess
|
||||
$build_aux/config.sub
|
||||
doc/INSTALL
|
||||
'
|
||||
"
|
||||
|
||||
# Other locale categories that need message catalogs.
|
||||
EXTRA_LOCALE_CATEGORIES=
|
||||
@@ -86,6 +117,13 @@ XGETTEXT_OPTIONS='\\\
|
||||
# Files we don't want to import.
|
||||
excluded_files=
|
||||
|
||||
# File that should exist in the top directory of a checked out hierarchy,
|
||||
# but not in a distribution tarball.
|
||||
checkout_only_file=README-hacking
|
||||
|
||||
# Whether to use copies instead of symlinks.
|
||||
copy=false
|
||||
|
||||
# Override the default configuration, if necessary.
|
||||
test -r bootstrap.conf && . ./bootstrap.conf
|
||||
|
||||
@@ -97,7 +135,7 @@ for option
|
||||
do
|
||||
case $option in
|
||||
--help)
|
||||
echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-user=USERNAME] [--skip-po]"
|
||||
usage
|
||||
exit;;
|
||||
--gnulib-srcdir=*)
|
||||
GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
|
||||
@@ -105,13 +143,52 @@ do
|
||||
CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
|
||||
--skip-po)
|
||||
SKIP_PO=t;;
|
||||
--force)
|
||||
checkout_only_file=;;
|
||||
--copy)
|
||||
copy=true;;
|
||||
*)
|
||||
echo >&2 "$0: $option: unknown option"
|
||||
exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "$0: Bootstrapping CVS $package..."
|
||||
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
|
||||
echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If $STR is not already on a line by itself in $FILE, insert it,
|
||||
# sorting the new contents of the file and replacing $FILE with the result.
|
||||
insert_sorted_if_absent() {
|
||||
file=$1
|
||||
str=$2
|
||||
echo "$str" | sort -u - $file | cmp -s - $file \
|
||||
|| echo "$str" | sort -u - $file -o $file \
|
||||
|| exit 1
|
||||
}
|
||||
|
||||
# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
|
||||
found_aux_dir=no
|
||||
grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
|
||||
>/dev/null && found_aux_dir=yes
|
||||
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
|
||||
>/dev/null && found_aux_dir=yes
|
||||
if test $found_aux_dir = no; then
|
||||
echo "$0: expected line not found in configure.ac. Add the following:" >&2
|
||||
echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2.
|
||||
fi
|
||||
|
||||
# If $build_aux doesn't exist, create it now, otherwise some bits
|
||||
# below will malfunction. If creating it, also mark it as ignored.
|
||||
if test ! -d $build_aux; then
|
||||
mkdir $build_aux
|
||||
for ig in .cvsignore .gitignore; do
|
||||
test -f $ig && insert_sorted_if_absent $ig $build_aux
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$0: Bootstrapping from checked-out $package sources..."
|
||||
|
||||
cleanup_gnulib() {
|
||||
status=$?
|
||||
@@ -205,34 +282,112 @@ case $SKIP_PO in
|
||||
WGET_COMMAND='';;
|
||||
esac
|
||||
|
||||
get_translations po $package || exit
|
||||
if test -d po; then
|
||||
get_translations po $package || exit
|
||||
fi
|
||||
|
||||
if test -d runtime-po; then
|
||||
get_translations runtime-po $package-runtime || exit
|
||||
fi;;
|
||||
esac
|
||||
|
||||
symlink_to_gnulib()
|
||||
{
|
||||
src=$GNULIB_SRCDIR/$1
|
||||
dst=${2-$1}
|
||||
|
||||
test -f "$src" && {
|
||||
if $copy; then
|
||||
{
|
||||
test ! -h "$dst" || {
|
||||
echo "$0: rm -f $dst" &&
|
||||
rm -f "$dst"
|
||||
}
|
||||
} &&
|
||||
test -f "$dst" &&
|
||||
cmp -s "$src" "$dst" || {
|
||||
echo "$0: cp -fp $src $dst" &&
|
||||
cp -fp "$src" "$dst"
|
||||
}
|
||||
else
|
||||
test -h "$dst" &&
|
||||
src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
|
||||
dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
|
||||
test "$src_i" = "$dst_i" || {
|
||||
dot_dots=
|
||||
case $src in
|
||||
/*) ;;
|
||||
*)
|
||||
case /$dst/ in
|
||||
*//* | */../* | */./* | /*/*/*/*/*/)
|
||||
echo >&2 "$0: invalid symlink calculation: $src -> $dst"
|
||||
exit 1;;
|
||||
/*/*/*/*/) dot_dots=../../../;;
|
||||
/*/*/*/) dot_dots=../../;;
|
||||
/*/*/) dot_dots=../;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
echo "$0: ln -fs $dot_dots$src $dst" &&
|
||||
ln -fs "$dot_dots$src" "$dst"
|
||||
}
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
cp_mark_as_generated()
|
||||
{
|
||||
cp_src=$1
|
||||
cp_dst=$2
|
||||
case $cp_dst in
|
||||
*.[ch]) c1='/* '; c2=' */';;
|
||||
*.texi) c1='@c '; c2= ;;
|
||||
*.m4|*/Make*|Make*) c1='# ' ; c2= ;;
|
||||
*) c1= ; c2= ;;
|
||||
esac
|
||||
|
||||
if test -z "$c1"; then
|
||||
cp "$cp_src" "$cp_dst"
|
||||
return
|
||||
if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
|
||||
symlink_to_gnulib "$cp_dst"
|
||||
else
|
||||
case $cp_dst in
|
||||
*.[ch]) c1='/* '; c2=' */';;
|
||||
*.texi) c1='@c '; c2= ;;
|
||||
*.m4|*/Make*|Make*) c1='# ' ; c2= ;;
|
||||
*) c1= ; c2= ;;
|
||||
esac
|
||||
|
||||
if test -z "$c1"; then
|
||||
cmp -s "$cp_src" "$cp_dst" || {
|
||||
echo "$0: cp -f $cp_src $cp_dst" &&
|
||||
rm -f "$cp_dst" &&
|
||||
sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst"
|
||||
}
|
||||
else
|
||||
# Copy the file first to get proper permissions if it
|
||||
# doesn't already exist. Then overwrite the copy.
|
||||
cp "$cp_src" "$cp_dst-t" &&
|
||||
(
|
||||
echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
|
||||
echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
|
||||
sed "s!$bt_regex/!!g" "$cp_src"
|
||||
) > $cp_dst-t &&
|
||||
if cmp -s "$cp_dst-t" "$cp_dst"; then
|
||||
rm -f "$cp_dst-t"
|
||||
else
|
||||
echo "$0: cp $cp_src $cp_dst # with edits" &&
|
||||
mv -f "$cp_dst-t" "$cp_dst"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
(
|
||||
echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2"
|
||||
echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2"
|
||||
cat "$cp_src"
|
||||
) >> "$cp_dst"
|
||||
version_controlled_file() {
|
||||
dir=$1
|
||||
file=$2
|
||||
found=no
|
||||
if test -d CVS; then
|
||||
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
|
||||
else
|
||||
echo "$0: no version control for $dir/$file?" >&2
|
||||
fi
|
||||
test $found = yes
|
||||
}
|
||||
|
||||
slurp() {
|
||||
@@ -245,13 +400,15 @@ slurp() {
|
||||
test "$dir/$file" = "$excluded_file" && continue 2
|
||||
done
|
||||
if test $file = Makefile.am; then
|
||||
copied=$copied${sep}gnulib.mk; sep=$nl
|
||||
echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
|
||||
rm -f $dir/gnulib.mk
|
||||
sed '/^[^#].*\/intl/s/^/#/' $1/$dir/$file >$dir/gnulib.mk
|
||||
elif test -r ${2-no/such/dir}/$dir/$file ||
|
||||
grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
|
||||
grep -q '^/[^/]*/[0-9]'; then
|
||||
copied=$copied${sep}gnulib.mk; sep=$nl
|
||||
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
|
||||
sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/gnulib.mk || {
|
||||
echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
|
||||
rm -f $dir/gnulib.mk &&
|
||||
sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk
|
||||
}
|
||||
elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
|
||||
version_controlled_file $dir $file; then
|
||||
echo "$0: $dir/$file overrides $1/$dir/$file"
|
||||
else
|
||||
copied=$copied$sep$file; sep=$nl
|
||||
@@ -267,25 +424,27 @@ slurp() {
|
||||
AC_DEFUN([gl_LOCK_EARLY], [])
|
||||
' $1/$dir/$file >$dir/$file
|
||||
else
|
||||
rm -f $dir/$file
|
||||
cp_mark_as_generated $1/$dir/$file $dir/$file
|
||||
fi
|
||||
fi || exit
|
||||
done
|
||||
|
||||
ig=$dir/.cvsignore
|
||||
if test -n "$copied" && test -f $ig; then
|
||||
echo "$copied" | sort -u - $ig | cmp -s - $ig ||
|
||||
echo "$copied" | sort -u - $ig -o $ig || exit
|
||||
fi
|
||||
for dot_ig in .cvsignore .gitignore; do
|
||||
ig=$dir/$dot_ig
|
||||
if test -n "$copied" && test -f $ig; then
|
||||
insert_sorted_if_absent $ig "$copied"
|
||||
# If an ignored file name ends with _.h, then also add
|
||||
# the name with just ".h". Many gnulib headers are generated,
|
||||
# e.g., stdint_.h -> stdint.h, dirent_.h ->..., etc.
|
||||
f=`echo "$copied"|sed 's/_\.h$/.h/'`
|
||||
insert_sorted_if_absent $ig "$f"
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Create boot temporary directories to import from gnulib and gettext.
|
||||
|
||||
bt='.#bootmp'
|
||||
bt2=${bt}2
|
||||
rm -fr $bt $bt2 &&
|
||||
mkdir $bt $bt2 || exit
|
||||
|
||||
@@ -294,36 +453,52 @@ mkdir $bt $bt2 || exit
|
||||
gnulib_tool_options="\
|
||||
--import\
|
||||
--no-changelog\
|
||||
--aux-dir $bt/build-aux\
|
||||
--aux-dir $bt/$build_aux\
|
||||
--doc-base $bt/doc\
|
||||
--lib lib$package\
|
||||
--lib $gnulib_name\
|
||||
--m4-base $bt/m4/\
|
||||
--source-base $bt/lib/\
|
||||
--tests-base $bt/tests\
|
||||
--local-dir gl\
|
||||
"
|
||||
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
|
||||
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
|
||||
slurp $bt || exit
|
||||
|
||||
for file in $gnulib_files; do
|
||||
symlink_to_gnulib $file || exit
|
||||
done
|
||||
|
||||
|
||||
# Import from gettext.
|
||||
with_gettext=yes
|
||||
grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
|
||||
with_gettext=no
|
||||
|
||||
echo "$0: (cd $bt2; autopoint) ..."
|
||||
cp configure.ac $bt2 &&
|
||||
(cd $bt2 && autopoint && rm configure.ac) &&
|
||||
slurp $bt2 $bt || exit
|
||||
if test $with_gettext = yes; then
|
||||
echo "$0: (cd $bt2; autopoint) ..."
|
||||
cp configure.ac $bt2 &&
|
||||
(cd $bt2 && autopoint && rm configure.ac) &&
|
||||
slurp $bt2 $bt || exit
|
||||
|
||||
rm -fr $bt $bt2 || exit
|
||||
rm -fr $bt $bt2 || exit
|
||||
fi
|
||||
|
||||
|
||||
# Reconfigure, getting other files.
|
||||
|
||||
for command in \
|
||||
libtool \
|
||||
'aclocal --force -I m4' \
|
||||
'autoconf --force' \
|
||||
'autoheader --force' \
|
||||
'automake --add-missing --copy --force-missing';
|
||||
do
|
||||
if test "$command" = libtool; then
|
||||
grep '^[ ]*AM_PROG_LIBTOOL\>' configure.ac >/dev/null ||
|
||||
continue
|
||||
command='libtoolize -c -f'
|
||||
fi
|
||||
echo "$0: $command ..."
|
||||
$command || exit
|
||||
done
|
||||
@@ -332,40 +507,44 @@ done
|
||||
# Get some extra files from gnulib, overriding existing files.
|
||||
|
||||
for file in $gnulib_extra_files; do
|
||||
src=$GNULIB_SRCDIR/$file
|
||||
case $file in
|
||||
*/INSTALL) dest=.;;
|
||||
*) dest=$file;;
|
||||
*/INSTALL) dst=INSTALL;;
|
||||
*) dst=$file;;
|
||||
esac
|
||||
echo "$0: cp -fp $src $dest" &&
|
||||
cp -fp $src $dest || exit
|
||||
symlink_to_gnulib $file $dst || exit
|
||||
done
|
||||
|
||||
|
||||
# Create gettext configuration.
|
||||
echo "$0: Creating po/Makevars from po/Makevars.template ..."
|
||||
rm -f po/Makevars
|
||||
sed '
|
||||
/^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
|
||||
/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
|
||||
/^XGETTEXT_OPTIONS *=/{
|
||||
s/$/ \\/
|
||||
a\
|
||||
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
|
||||
}
|
||||
' po/Makevars.template >po/Makevars
|
||||
|
||||
if test -d runtime-po; then
|
||||
# Likewise for runtime-po/Makevars, except also change a few other parameters.
|
||||
rm -f runtime-po/Makevars
|
||||
if test $with_gettext = yes; then
|
||||
# Create gettext configuration.
|
||||
echo "$0: Creating po/Makevars from po/Makevars.template ..."
|
||||
rm -f po/Makevars
|
||||
sed '
|
||||
s/^\(DOMAIN\) *=.*/\1 = '"$package"'-runtime/
|
||||
s/^\(subdir\) *=.*/\1 = runtime-po/
|
||||
s/^\(XGETTEXT_OPTIONS\) *=.*/\1 = '"$XGETTEXT_OPTIONS_RUNTIME"'/
|
||||
' <po/Makevars >runtime-po/Makevars
|
||||
/^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
|
||||
/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
|
||||
/^XGETTEXT_OPTIONS *=/{
|
||||
s/$/ \\/
|
||||
a\
|
||||
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
|
||||
}
|
||||
' po/Makevars.template >po/Makevars
|
||||
|
||||
# Copy identical files from po to runtime-po.
|
||||
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
|
||||
if test -d runtime-po; then
|
||||
# Similarly for runtime-po/Makevars, but not quite the same.
|
||||
rm -f runtime-po/Makevars
|
||||
sed '
|
||||
/^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
|
||||
/^subdir *=.*/s/=.*/= runtime-po/
|
||||
/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
|
||||
/^XGETTEXT_OPTIONS *=/{
|
||||
s/$/ \\/
|
||||
a\
|
||||
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
|
||||
}
|
||||
' <po/Makevars.template >runtime-po/Makevars
|
||||
|
||||
# Copy identical files from po to runtime-po.
|
||||
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$0: done. Now you can run './configure'."
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bootstrap configuration.
|
||||
|
||||
# Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
# 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
|
||||
@@ -19,11 +19,12 @@
|
||||
|
||||
|
||||
# We don't need these modules, even though gnulib-tool mistakenly
|
||||
# includes them because of gettext dependencies.
|
||||
# includes them because of gettext and fchdir dependencies.
|
||||
avoided_gnulib_modules='
|
||||
--avoid=lock
|
||||
--avoid=size_max
|
||||
--avoid=xsize
|
||||
--avoid=canonicalize-lgpl
|
||||
'
|
||||
|
||||
# These modules are obsolete and can probably be removed soon,
|
||||
@@ -37,12 +38,14 @@ obsolete_gnulib_modules='
|
||||
gnulib_modules="
|
||||
$avoided_gnulib_modules
|
||||
$obsolete_gnulib_modules
|
||||
acl alloca argmatch assert backupfile base64 c-strtod
|
||||
acl alloca announce-gen argmatch assert backupfile base64
|
||||
c-strcase c-strtod
|
||||
c-strtold calloc canon-host canonicalize chown cloexec
|
||||
config-h configmake
|
||||
closeout cycle-check d-ino d-type diacrit dirfd dirname dup2
|
||||
error euidaccess exclude exitfail fcntl fcntl-safer fdl file-type
|
||||
fileblocks filemode filenamecat fnmatch-gnu fopen-safer
|
||||
error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl
|
||||
file-type fileblocks filemode filenamecat fnmatch-gnu
|
||||
fopen-safer
|
||||
fprintftime fsusage ftruncate fts getdate getgroups gethrxtime
|
||||
getline getloadavg getndelim2 getopt getpagesize getpass-gnu
|
||||
gettext gettime gettimeofday getugroups getusershell gnupload
|
||||
@@ -51,18 +54,20 @@ gnulib_modules="
|
||||
lchmod lchown lib-ignore linebuffer link-follow
|
||||
long-options lstat malloc mbswidth md5 memcasecmp mempcpy
|
||||
memrchr mkancesdirs mkdir mkdir-p mkstemp mktime modechange
|
||||
mountlist obstack pathmax perl physmem posixtm posixver putenv
|
||||
mountlist mpsort obstack pathmax perl physmem posixtm posixver putenv
|
||||
quote quotearg raise readlink readtokens readtokens0 readutmp
|
||||
realloc regex rename-dest-slash rmdir rmdir-errno rpmatch
|
||||
realloc regex rename-dest-slash rmdir rmdir-errno
|
||||
root-dev-ino
|
||||
rpmatch
|
||||
safe-read same
|
||||
save-cwd savedir savewd settime sha1 sig2str ssize_t stat-macros
|
||||
stat-time stdbool stdlib-safer stpcpy strcase strftime
|
||||
strpbrk strtoimax strtoumax strverscmp timespec tzset
|
||||
stat-time stdbool stdlib-safer stpcpy strftime
|
||||
strpbrk strtoimax strtoumax strverscmp sys_stat timespec tzset
|
||||
unicodeio unistd-safer unlink-busy unlinkdir unlocked-io
|
||||
uptime userspec utimecmp utimens vasprintf verify version-etc-fsf
|
||||
wcwidth winsz-ioctl winsz-termios xalloc xgetcwd xgethostname
|
||||
xmemcoll xnanosleep xreadlink xstrtod xstrtoimax xstrtol
|
||||
xstrtold xstrtoumax yesno
|
||||
xmemcoll xnanosleep xreadlink xreadlink-with-size xstrtod xstrtoimax
|
||||
xstrtol xstrtold xstrtoumax yesno
|
||||
"
|
||||
|
||||
# Other locale categories that need message catalogs.
|
||||
@@ -76,17 +81,32 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||
--flag=wrapf:1:c-format\\\
|
||||
'
|
||||
|
||||
# Gettext supplies these files, but we don't need them since
|
||||
# we don't have an intl subdirectory.
|
||||
excluded_files='
|
||||
m4/glibc2.m4
|
||||
m4/intdiv0.m4
|
||||
m4/lcmessage.m4
|
||||
m4/lock.m4
|
||||
m4/printf-posix.m4
|
||||
m4/size_max.m4
|
||||
m4/uintmax_t.m4
|
||||
m4/ulonglong.m4
|
||||
m4/visibility.m4
|
||||
m4/xsize.m4
|
||||
'
|
||||
# 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),
|
||||
# the following test is ugly. Also, this depends on the existence
|
||||
# of configure.ac, not the obsolescent-named configure.in. But if
|
||||
# you're using this infrastructure, you should care about such things.
|
||||
|
||||
gettext_external=0
|
||||
grep '^[ ]*AM_GNU_GETTEXT(external\>' configure.ac > /dev/null &&
|
||||
gettext_external=1
|
||||
grep '^[ ]*AM_GNU_GETTEXT(\[external\]' configure.ac > /dev/null &&
|
||||
gettext_external=1
|
||||
|
||||
if test $gettext_external = 1; then
|
||||
# Gettext supplies these files, but we don't need them since
|
||||
# we don't have an intl subdirectory.
|
||||
excluded_files='
|
||||
m4/glibc2.m4
|
||||
m4/intdiv0.m4
|
||||
m4/lcmessage.m4
|
||||
m4/lock.m4
|
||||
m4/printf-posix.m4
|
||||
m4/size_max.m4
|
||||
m4/uintmax_t.m4
|
||||
m4/ulonglong.m4
|
||||
m4/visibility.m4
|
||||
m4/xsize.m4
|
||||
'
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
announce-gen
|
||||
compile
|
||||
config.guess
|
||||
config.rpath
|
||||
@@ -5,6 +6,7 @@ config.sub
|
||||
depcomp
|
||||
gnupload
|
||||
install-sh
|
||||
link-warning.h
|
||||
mdate-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
|
||||
13
build-aux/.gitignore
vendored
Normal file
13
build-aux/.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
announce-gen
|
||||
compile
|
||||
config.guess
|
||||
config.rpath
|
||||
config.sub
|
||||
depcomp
|
||||
gnupload
|
||||
install-sh
|
||||
link-warning.h
|
||||
mdate-sh
|
||||
missing
|
||||
texinfo.tex
|
||||
ylwrap
|
||||
@@ -1,3 +1,13 @@
|
||||
2007-01-30 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* vc-list-files: Select column 2, not 3 (hg-0.9.3's manifest format
|
||||
now has only two columns).
|
||||
|
||||
2006-10-14 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* vc-list-files: Don't filter git-ls-files output through cut.
|
||||
Add a comment about cvsu.
|
||||
|
||||
2006-08-22 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* .cvsignore: New file.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# List the specified version-controlled files.
|
||||
|
||||
# Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
# 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
|
||||
@@ -26,6 +26,7 @@
|
||||
# with no trailing slashes. In mercurial mode, it's used as part of a
|
||||
# "grep" pattern (prepend "^", append "/"), and in cvs mode, it's simply
|
||||
# used as an argument to the cvsu script.
|
||||
# cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
|
||||
|
||||
include_prefix=
|
||||
case $# in
|
||||
@@ -36,15 +37,15 @@ esac
|
||||
|
||||
if test -d .git; then
|
||||
if test "x$include_prefix" = x; then
|
||||
git-ls-files | cut -d ' ' -f 3
|
||||
git-ls-files
|
||||
else
|
||||
git-ls-files | cut -d ' ' -f 3 | grep "^$include_prefix/"
|
||||
git-ls-files | grep "^$include_prefix/"
|
||||
fi
|
||||
elif test -d .hg; then
|
||||
if test "x$include_prefix" = x; then
|
||||
hg manifest | cut -d ' ' -f 3
|
||||
hg manifest | cut -d ' ' -f 2
|
||||
else
|
||||
hg manifest | cut -d ' ' -f 3 | grep "^$include_prefix/"
|
||||
hg manifest | cut -d ' ' -f 2 | grep "^$include_prefix/"
|
||||
fi
|
||||
elif test -x build-aux/cvsu; then
|
||||
build-aux/cvsu --find --types=AFGM $include_prefix
|
||||
|
||||
23
configure.ac
23
configure.ac
@@ -1,7 +1,7 @@
|
||||
# -*- autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1991, 1993-2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991, 1993-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
|
||||
@@ -19,15 +19,15 @@
|
||||
|
||||
dnl Written by Jim Meyering.
|
||||
|
||||
AC_PREREQ(2.60)
|
||||
AC_INIT([GNU coreutils],[6.2],[bug-coreutils@gnu.org])
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT([GNU coreutils],[6.9],[bug-coreutils@gnu.org])
|
||||
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.9.6 gnits dist-bzip2])
|
||||
AM_INIT_AUTOMAKE([1.10 dist-bzip2])
|
||||
|
||||
AC_PROG_CC_STDC
|
||||
AM_PROG_CC_C_O
|
||||
@@ -36,7 +36,10 @@ AC_PROG_GCC_TRADITIONAL
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_LN_S
|
||||
gl_EARLY
|
||||
gl_MACROS
|
||||
gl_INIT
|
||||
coreutils_MACROS
|
||||
|
||||
AC_FUNC_FORK
|
||||
|
||||
AC_CHECK_FUNCS(uname,
|
||||
OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS uname\$(EXEEXT)"
|
||||
@@ -58,14 +61,14 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
extern char **environ;
|
||||
unset_TZ ()
|
||||
void unset_TZ (void)
|
||||
{
|
||||
char **from, **to;
|
||||
for (to = from = environ; (*to = *from); from++)
|
||||
if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
|
||||
to++;
|
||||
}
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
time_t now = time ((time_t *) 0);
|
||||
int hour_GMT0, hour_unset;
|
||||
@@ -146,7 +149,7 @@ coreutils_DUMMY_1
|
||||
AC_MSG_CHECKING(ut_host in struct utmp)
|
||||
AC_CACHE_VAL(su_cv_func_ut_host_in_utmp,
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||
#include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],
|
||||
#include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
|
||||
[su_cv_func_ut_host_in_utmp=yes],
|
||||
[su_cv_func_ut_host_in_utmp=no])])
|
||||
AC_MSG_RESULT($su_cv_func_ut_host_in_utmp)
|
||||
@@ -159,7 +162,7 @@ if test -z "$have_ut_host"; then
|
||||
AC_MSG_CHECKING(ut_host in struct utmpx)
|
||||
AC_CACHE_VAL(su_cv_func_ut_host_in_utmpx,
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||
#include <utmpx.h>]], [[struct utmpx ut; ut.ut_host;]])],
|
||||
#include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
|
||||
[su_cv_func_ut_host_in_utmpx=yes],
|
||||
[su_cv_func_ut_host_in_utmpx=no])])
|
||||
AC_MSG_RESULT($su_cv_func_ut_host_in_utmpx)
|
||||
@@ -201,7 +204,7 @@ yes
|
||||
#define _XOPEN_SOURCE
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <termios.h>]], [[struct termios t; t.c_line;]])],
|
||||
#include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
|
||||
[su_cv_sys_c_line_in_termios=yes],
|
||||
[su_cv_sys_c_line_in_termios=no])])
|
||||
AC_MSG_RESULT($su_cv_sys_c_line_in_termios)
|
||||
|
||||
5
doc/.gitignore
vendored
Normal file
5
doc/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
coreutils.info
|
||||
fdl.texi
|
||||
getdate.texi
|
||||
stamp-vti
|
||||
version.texi
|
||||
101
doc/ChangeLog
101
doc/ChangeLog
@@ -1,3 +1,104 @@
|
||||
2007-03-21 Eric Blake <ebb9@byu.net>
|
||||
|
||||
* coreutils.texi (md5sum invocation): Document escapes in output
|
||||
format. Reported by Armijn Hemel.
|
||||
|
||||
2007-03-15 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Fix manual in response to bug reports by Dan Jacobson.
|
||||
* coreutils.texi (sort invocation): Explain numeric sorts better.
|
||||
Compress self-congratulation into a simple "comparison is exact"
|
||||
notice; the --general-numeric-sort option already explains the
|
||||
tradeoffs.
|
||||
(seq invocation): Add example of -f.
|
||||
|
||||
2007-03-12 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* coreutils.texi (cp invocation): Mention that --preserve=timestamps
|
||||
doesn't preserve time stamps on symbolic links.
|
||||
Reported by Polo Talnir in <https://bugzilla.redhat.com/230866>.
|
||||
|
||||
2007-02-27 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* coreutils.texi (df invocation): With -P, the default block size
|
||||
and output format is not affected by DF_BLOCK_SIZE, BLOCK_SIZE, or
|
||||
BLOCKSIZE.
|
||||
|
||||
2007-01-30 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* coreutils.texi
|
||||
(Input processing in ptx, mkdir invocation, rmdir invocation):
|
||||
@item -> @itemx to fix some typos.
|
||||
|
||||
2007-01-30 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* coreutils.texi (mkdir invocation): Say how to set the file
|
||||
permission bits of a parent directory with mkdir -p.
|
||||
|
||||
2007-01-29 Jim Meyering <jim@meyering.net>
|
||||
|
||||
Document new syntax: "chown +0:+287 file", "chgrp +99 file"
|
||||
* coreutils.texi (Disambiguating names and IDs): New section.
|
||||
(chown invocation, chgrp invocation): Mention the new syntax
|
||||
with an xref to the new section.
|
||||
|
||||
2007-01-19 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* coreutils.texi (ls: General output formatting): Mention the
|
||||
workarounds to accommodate the Apple Terminal bug.
|
||||
|
||||
2007-01-04 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* coreutils.texi (base64 invocation): When decoding, newlines
|
||||
are always accepted.
|
||||
|
||||
2007-01-03 Jim Meyering <jim@meyering.net>
|
||||
|
||||
Document what the ".0" in e.g., "-k 2,3.0" means, and...
|
||||
* coreutils.texi (sort invocation): ... that it can be applied to the
|
||||
field-end spec, but not the field-start one. Patch from Evan Hunt.
|
||||
|
||||
2006-12-21 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* coreutils.texi (dd invocation): Improve the documentation
|
||||
for bs, ibs, obs, and cbs. Suggestion from Dan Jacobson.
|
||||
Patch by Olivier Delhomme.
|
||||
(dd invocation): Add to the description of cbs.
|
||||
(dd invocation): Specify that bs=N overrides only any
|
||||
_preceding_ ibs and obs settings. Spotted by Andreas Schwab.
|
||||
|
||||
2006-12-14 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* coreutils.texi: Remove two doubled words.
|
||||
(Treating / specially): With --preserve-root, chgrp and chown
|
||||
will not modify "/", even through a symlink.
|
||||
|
||||
2006-11-28 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* perm.texi (Mode Structure): Fix typo: s/setgid/setuid/.
|
||||
Reported by Georg Neis as Debian bug 400778.
|
||||
|
||||
2006-10-27 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* coreutils.texi (wc invocation): When giving the order in which
|
||||
the various "counts" are listed, also mention "maximum line length".
|
||||
Prompted by a report from Vincent LeFevre.
|
||||
|
||||
2006-10-23 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* coreutils.texi (rm invocation): Describe --one-file-system.
|
||||
|
||||
2006-09-26 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* coreutils.texi (groups invocation): "groups" no longer prefixes
|
||||
the output with "user :" unless more than one user is specified.
|
||||
|
||||
2006-09-19 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* coreutils.texi (cp invocation): Say that -i and -f are
|
||||
independent. Clarify -i's behavior.
|
||||
(Disk usage): Clarify intro. Problem reported by Van Ly.
|
||||
|
||||
2006-09-08 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* coreutils.texi (tail invocation): Ignore -f when standard input
|
||||
|
||||
@@ -208,6 +208,7 @@ Common Options
|
||||
* Exit status:: Indicating program success or failure.
|
||||
* Backup options:: Backup options
|
||||
* Block size:: Block size
|
||||
* Disambiguating names and IDs:: chgrp and chown owner and group syntax
|
||||
* Random sources:: Sources of random data
|
||||
* Target directory:: Target directory
|
||||
* Trailing slashes:: Trailing slashes
|
||||
@@ -557,8 +558,8 @@ symbolic link to a directory. @xref{Target directory}.
|
||||
@itemx --si
|
||||
@opindex --si
|
||||
@cindex SI output
|
||||
Append an SI-style abbreviation to each size, such as @samp{MB} for
|
||||
megabytes. Powers of 1000 are used, not 1024; @samp{MB} stands for
|
||||
Append an SI-style abbreviation to each size, such as @samp{M} for
|
||||
megabytes. Powers of 1000 are used, not 1024; @samp{M} stands for
|
||||
1,000,000 bytes. This option is equivalent to
|
||||
@option{--block-size=si}. Use the @option{-h} or
|
||||
@option{--human-readable} option if
|
||||
@@ -644,6 +645,7 @@ name.
|
||||
* Exit status:: Indicating program success or failure.
|
||||
* Backup options:: -b -S, in some programs.
|
||||
* Block size:: BLOCK_SIZE and --block-size, in some programs.
|
||||
* Disambiguating names and IDs:: chgrp and chown owner and group syntax
|
||||
* Random sources:: --random-source, in some programs.
|
||||
* Target directory:: Specifying a target directory, in some programs.
|
||||
* Trailing slashes:: --strip-trailing-slashes, in some programs.
|
||||
@@ -924,6 +926,46 @@ set. The @option{-h} or @option{--human-readable} option is equivalent to
|
||||
@option{--block-size=human-readable}. The @option{--si} option is
|
||||
equivalent to @option{--block-size=si}.
|
||||
|
||||
@node Disambiguating names and IDs
|
||||
@section chown and chgrp: Disambiguating user names and IDs
|
||||
@cindex user names, disambiguating
|
||||
@cindex user IDs, disambiguating
|
||||
@cindex group names, disambiguating
|
||||
@cindex group IDs, disambiguating
|
||||
@cindex disambiguating group names and IDs
|
||||
|
||||
Since the @var{owner} and @var{group} arguments to @command{chown} and
|
||||
@command{chgrp} may be specified as names or numeric IDs, there is an
|
||||
apparent ambiguity.
|
||||
What if a user or group @emph{name} is a string of digits?
|
||||
@footnote{Using a number as a user name is common in some environments.}
|
||||
Should the command interpret it as a user name or as an ID?
|
||||
@acronym{POSIX} requires that @command{chown} and @command{chgrp}
|
||||
first attempt to resolve the specified string as a name, and
|
||||
only once that fails, then try to interpret it as an ID.
|
||||
This is troublesome when you want to specify a numeric ID, say 42,
|
||||
and it must work even in a pathological situation where
|
||||
@samp{42} is a user name that maps to some other user ID, say 1000.
|
||||
Simply invoking @code{chown 42 F}, will set @file{F}s owner ID to
|
||||
1000---not what you intended.
|
||||
|
||||
GNU @command{chown} and @command{chgrp} provide a way to work around this,
|
||||
that at the same time may result in a significant performance improvement
|
||||
by eliminating a database look-up.
|
||||
Simply precede each numeric user ID and/or group ID with a @samp{+},
|
||||
in order to force its interpretation as an integer:
|
||||
|
||||
@example
|
||||
chown +42 F
|
||||
chgrp +$numeric_group_id another-file
|
||||
chown +0:+0 /
|
||||
@end example
|
||||
|
||||
GNU @command{chown} and @command{chgrp}
|
||||
skip the name look-up process for each @samp{+}-prefixed string,
|
||||
because a string containing @samp{+} is never a valid user or group name.
|
||||
This syntax is accepted on most common Unix systems, but not on Solaris 10.
|
||||
|
||||
@node Random sources
|
||||
@section Sources of random data
|
||||
|
||||
@@ -1158,6 +1200,10 @@ to operate recursively on @file{/}, so they default to
|
||||
option makes them safer for most purposes. For convenience you can
|
||||
specify @option{--preserve-root} in an alias or in a shell function.
|
||||
|
||||
Note that the @option{--preserve-root} option also ensures
|
||||
that @command{chgrp} and @command{chown} do not modify @file{/}
|
||||
even when dereferencing a symlink pointing to @file{/}.
|
||||
|
||||
@node Special built-in utilities
|
||||
@section Special built-in utilities
|
||||
|
||||
@@ -1845,7 +1891,8 @@ output will be the original data.
|
||||
@opindex -i
|
||||
@opindex --ignore-garbage
|
||||
@cindex Ignore garbage in base64 stream
|
||||
During decoding, ignore unrecognized characters (including newline),
|
||||
When decoding, newlines are always accepted.
|
||||
During decoding, ignore unrecognized bytes,
|
||||
to permit distorted data to be decoded.
|
||||
|
||||
@end table
|
||||
@@ -2950,7 +2997,8 @@ wc [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
given as an argument, it prints the file name following the counts. If
|
||||
more than one @var{file} is given, @command{wc} prints a final line
|
||||
containing the cumulative counts, with the file name @file{total}. The
|
||||
counts are printed in this order: newlines, words, characters, bytes.
|
||||
counts are printed in this order: newlines, words, characters, bytes,
|
||||
maximum line length.
|
||||
Each count is printed right-justified in a field with at least one
|
||||
space between fields so that the numbers and file names normally line
|
||||
up nicely in columns. The width of the count fields varies depending
|
||||
@@ -3155,6 +3203,10 @@ md5sum [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
|
||||
For each @var{file}, @samp{md5sum} outputs the MD5 checksum, a flag
|
||||
indicating a binary or text input file, and the file name.
|
||||
If @var{file} contains a backslash or newline, the
|
||||
line is started with a backslash, and each problematic character in
|
||||
the file name is escaped with a backslash, making the output
|
||||
unambiguous even in the presence of arbitrary file names.
|
||||
If @var{file} is omitted or specified as @samp{-}, standard input is read.
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
@@ -3336,12 +3388,26 @@ mode:
|
||||
|
||||
@item -c
|
||||
@itemx --check
|
||||
@itemx --check=diagnose-first
|
||||
@opindex -c
|
||||
@opindex --check
|
||||
@cindex checking for sortedness
|
||||
Check whether the given files are already sorted: if they are not all
|
||||
sorted, print an error message and exit with a status of 1.
|
||||
Check whether the given file is already sorted: if it is not all
|
||||
sorted, print a diagnostic containing the first out-of-order line and
|
||||
exit with a status of 1.
|
||||
Otherwise, exit successfully.
|
||||
At most one input file can be given.
|
||||
|
||||
@item -C
|
||||
@itemx --check=quiet
|
||||
@itemx --check=silent
|
||||
@opindex -c
|
||||
@opindex --check
|
||||
@cindex checking for sortedness
|
||||
Exit successfully if the given file is already sorted, and
|
||||
exit with status 1 otherwise.
|
||||
At most one input file can be given.
|
||||
This is like @option{-c}, except it does not print a diagnostic.
|
||||
|
||||
@item -m
|
||||
@itemx --merge
|
||||
@@ -3395,7 +3461,7 @@ Exit status:
|
||||
|
||||
@display
|
||||
0 if no error occurred
|
||||
1 if invoked with @option{-c} and the input is not properly sorted
|
||||
1 if invoked with @option{-c} or @option{-C} and the input is not sorted
|
||||
2 if an error occurred
|
||||
@end display
|
||||
|
||||
@@ -3405,7 +3471,6 @@ value as the directory for temporary files instead of @file{/tmp}. The
|
||||
@option{--temporary-directory} (@option{-T}) option in turn overrides
|
||||
the environment variable.
|
||||
|
||||
|
||||
The following options affect the ordering of output lines. They may be
|
||||
specified globally or as part of a specific key field. If no key
|
||||
fields are specified, global options apply to comparison of entire
|
||||
@@ -3514,26 +3579,16 @@ can change this.
|
||||
@opindex --numeric-sort
|
||||
@cindex numeric sort
|
||||
@vindex LC_NUMERIC
|
||||
Sort numerically: the number begins each line; specifically, it consists
|
||||
Sort numerically. The number begins each line and consists
|
||||
of optional blanks, an optional @samp{-} sign, and zero or more
|
||||
digits possibly separated by thousands separators, optionally followed
|
||||
by a decimal-point character and zero or more digits. A string of
|
||||
no digits is interpreted as @samp{0}. The @env{LC_NUMERIC}
|
||||
by a decimal-point character and zero or more digits. An empty
|
||||
number is treated as @samp{0}. The @env{LC_NUMERIC}
|
||||
locale specifies the decimal-point character and thousands separator.
|
||||
By default a blank is a space or a tab, but the @env{LC_CTYPE} locale
|
||||
can change this.
|
||||
|
||||
Numeric sort uses what might be considered an unconventional method to
|
||||
compare strings representing floating point numbers. Rather than first
|
||||
converting each string to the C @code{double} type and then comparing
|
||||
those values, @command{sort} aligns the decimal-point characters in the
|
||||
two strings and compares the strings a character at a time. One benefit
|
||||
of using this approach is its speed. In practice this is much more
|
||||
efficient than performing the two corresponding string-to-double (or
|
||||
even string-to-integer) conversions and then comparing doubles. In
|
||||
addition, there is no corresponding loss of precision. Converting each
|
||||
string to @code{double} before comparison would limit precision to about
|
||||
16 digits on most systems.
|
||||
Comparison is exact; there is no rounding error.
|
||||
|
||||
Neither a leading @samp{+} nor exponential notation is recognized.
|
||||
To compare such strings numerically, use the
|
||||
@@ -3572,6 +3627,18 @@ Other options are:
|
||||
|
||||
@table @samp
|
||||
|
||||
@item --compress-program=@var{prog}
|
||||
Compress any temporary files with the program @var{prog}.
|
||||
|
||||
With no arguments, @var{prog} must compress standard input to standard
|
||||
output, and when given the @option{-d} option it must decompress
|
||||
standard input to standard output.
|
||||
|
||||
Terminate with an error if @var{prog} exits with nonzero status.
|
||||
|
||||
Whitespace and the backslash character should not appear in
|
||||
@var{prog}; they are reserved for future use.
|
||||
|
||||
@item -k @var{pos1}[,@var{pos2}]
|
||||
@itemx --key=@var{pos1}[,@var{pos2}]
|
||||
@opindex -k
|
||||
@@ -3579,9 +3646,21 @@ Other options are:
|
||||
@cindex sort field
|
||||
Specify a sort field that consists of the part of the line between
|
||||
@var{pos1} and @var{pos2} (or the end of the line, if @var{pos2} is
|
||||
omitted), @emph{inclusive}. Fields and character positions are numbered
|
||||
starting with 1. So to sort on the second field, you'd use
|
||||
@option{--key=2,2} (@option{-k 2,2}). See below for more examples.
|
||||
omitted), @emph{inclusive}.
|
||||
|
||||
Each @var{pos} has the form @samp{@var{f}[.@var{c}][@var{opts}]},
|
||||
where @var{f} is the number of the field to use, and @var{c} is the number
|
||||
of the first character from the beginning of the field. Fields and character
|
||||
positions are numbered starting with 1; a character position of zero in
|
||||
@var{pos2} indicates the field's last character. If @samp{.@var{c}} is
|
||||
omitted from @var{pos1}, it defaults to 1 (the beginning of the field);
|
||||
if omitted from @var{pos2}, it defaults to 0 (the end of the field).
|
||||
@var{opts} are ordering options, allowing individual keys to be sorted
|
||||
according to different rules; see below for details. Keys can span
|
||||
multiple fields.
|
||||
|
||||
Example: To sort on the second field, use @option{--key=2,2}
|
||||
(@option{-k 2,2}). See below for more examples.
|
||||
|
||||
@item -o @var{output-file}
|
||||
@itemx --output=@var{output-file}
|
||||
@@ -3685,7 +3764,7 @@ disks and controllers.
|
||||
@cindex uniquifying output
|
||||
|
||||
Normally, output only the first of a sequence of lines that compare
|
||||
equal. For the @option{--check} (@option{-c}) option,
|
||||
equal. For the @option{--check} (@option{-c} or @option{-C}) option,
|
||||
check that no pair of consecutive lines compares equal.
|
||||
|
||||
This option also disables the default last-resort comparison.
|
||||
@@ -3720,29 +3799,21 @@ consistency, @option{-M} has been changed in the same way. This may
|
||||
affect the meaning of character positions in field specifications in
|
||||
obscure cases. The only fix is to add an explicit @option{-b}.
|
||||
|
||||
A position in a sort field specified with the @option{-k}
|
||||
option has the form @samp{@var{f}.@var{c}}, where @var{f} is the number
|
||||
of the field to use and @var{c} is the number of the first character
|
||||
from the beginning of the field. In a start position, an omitted
|
||||
@samp{.@var{c}} stands for the field's first character. In an end
|
||||
position, an omitted or zero @samp{.@var{c}} stands for the field's
|
||||
last character. If the start field falls after the end of the line
|
||||
or after the end field, the field is empty. If the
|
||||
@option{-b} option was specified, the @samp{.@var{c}} part of a field
|
||||
specification is counted from the first nonblank character of the field.
|
||||
|
||||
A sort key position may also have any of the option letters @samp{Mbdfinr}
|
||||
appended to it, in which case the global ordering options are not used
|
||||
for that particular field. The @option{-b} option may be independently
|
||||
attached to either or both of the start and
|
||||
end positions of a field specification, and if it is inherited
|
||||
from the global options it will be attached to both.
|
||||
A position in a sort field specified with @option{-k} may have any
|
||||
of the option letters @samp{Mbdfinr} appended to it, in which case the
|
||||
global ordering options are not used for that particular field. The
|
||||
@option{-b} option may be independently attached to either or both of
|
||||
the start and end positions of a field specification, and if it is
|
||||
inherited from the global options it will be attached to both.
|
||||
If input lines can contain leading or adjacent blanks and @option{-t}
|
||||
is not used, then @option{-k} is typically combined with @option{-b},
|
||||
@option{-g}, @option{-M}, or @option{-n}; otherwise the varying
|
||||
numbers of leading blanks in fields can cause confusing results.
|
||||
|
||||
Keys can span multiple fields.
|
||||
If the start position in a sort field specifier falls after the end of
|
||||
the line or after the end field, the field is empty. If the @option{-b}
|
||||
option was specified, the @samp{.@var{c}} part of a field specification
|
||||
is counted from the first nonblank character of the field.
|
||||
|
||||
@vindex _POSIX2_VERSION
|
||||
@vindex POSIXLY_CORRECT
|
||||
@@ -4488,7 +4559,7 @@ Fold lower case letters to upper case for sorting.
|
||||
@table @samp
|
||||
|
||||
@item -b @var{file}
|
||||
@item --break-file=@var{file}
|
||||
@itemx --break-file=@var{file}
|
||||
|
||||
This option provides an alternative (to @option{-W}) method of describing
|
||||
which characters make up words. It introduces the name of a
|
||||
@@ -6409,6 +6480,13 @@ Assume that each tab stop is @var{cols} columns wide. The default is 8.
|
||||
@command{ls} uses tabs where possible in the output, for efficiency. If
|
||||
@var{cols} is zero, do not use tabs at all.
|
||||
|
||||
@c FIXME: remove in 2009, if Apple Terminal has been fixed for long enough.
|
||||
Some terminal emulators (at least Apple Terminal 1.5 (133) from Mac OS X 10.4.8)
|
||||
do not properly align columns to the right of a TAB following a
|
||||
non-@acronym{ASCII} byte. If you use such a terminal emulator, use the
|
||||
@option{-T0} option or put @code{TABSIZE=0} in your environment to tell
|
||||
@command{ls} to align using spaces, not tabs.
|
||||
|
||||
@item -w
|
||||
@itemx --width=@var{cols}
|
||||
@opindex -w
|
||||
@@ -6890,6 +6968,9 @@ tries to open it again. Contrast this behavior with that enabled by
|
||||
is never opened but rather is unlinked unconditionally. Also see the
|
||||
description of @option{--remove-destination}.
|
||||
|
||||
This option is independent of the @option{--interactive} or
|
||||
@option{-i} option: neither cancels the effect of the other.
|
||||
|
||||
@item -H
|
||||
@opindex -H
|
||||
If a command line argument specifies a symbolic link, then copy the
|
||||
@@ -6901,7 +6982,8 @@ via recursive traversal.
|
||||
@itemx --interactive
|
||||
@opindex -i
|
||||
@opindex --interactive
|
||||
Prompt whether to overwrite existing regular destination files.
|
||||
When copying a file other than a directory, prompt whether to
|
||||
overwrite an existing destination file.
|
||||
|
||||
@item -l
|
||||
@itemx --link
|
||||
@@ -6942,7 +7024,13 @@ and ordinary users
|
||||
may preserve the group ownership of a file only if they happen to be
|
||||
a member of the desired group.
|
||||
@itemx timestamps
|
||||
Preserve the times of last access and last modification.
|
||||
Preserve the times of last access and last modification, when possible.
|
||||
In general, it is not possible to preserve these attributes
|
||||
when the affected file is a symbolic link.
|
||||
However, FreeBSD now provides the @code{lutimes} function, which makes
|
||||
it possibile even for symbolic links. However, this implementation does
|
||||
not yet take advantage of that.
|
||||
@c FIXME: once we provide lutimes support, update the above.
|
||||
@itemx links
|
||||
Preserve in the destination files
|
||||
any links between corresponding source files.
|
||||
@@ -7146,25 +7234,33 @@ bytes (or the size specified with @samp{seek=}).
|
||||
@opindex ibs
|
||||
@cindex block size of input
|
||||
@cindex input block size
|
||||
Read @var{bytes} bytes at a time.
|
||||
Set the input block size to @var{bytes}.
|
||||
This makes @command{dd} read @var{bytes} per block.
|
||||
|
||||
@item obs=@var{bytes}
|
||||
@opindex obs
|
||||
@cindex block size of output
|
||||
@cindex output block size
|
||||
Write @var{bytes} bytes at a time.
|
||||
Set the output block size to @var{bytes}.
|
||||
This makes @command{dd} write @var{bytes} per block.
|
||||
|
||||
@item bs=@var{bytes}
|
||||
@opindex bs
|
||||
@cindex block size
|
||||
Both read and write @var{bytes} bytes at a time. This overrides
|
||||
@samp{ibs} and @samp{obs}.
|
||||
Set both input and output block sizes to @var{bytes}.
|
||||
This makes @command{dd} read and write @var{bytes} per block,
|
||||
overriding any @samp{ibs} and @samp{obs} settings.
|
||||
|
||||
@item cbs=@var{bytes}
|
||||
@opindex cbs
|
||||
@cindex block size of conversion
|
||||
@cindex conversion block size
|
||||
Convert @var{bytes} bytes at a time.
|
||||
@cindex fixed-length records, converting to variable-length
|
||||
@cindex variable-length records, converting to fixed-length
|
||||
Set the conversion block size to @var{bytes}.
|
||||
When converting variable-length records to fixed-length ones
|
||||
(@option{conv=block}) or the reverse (@option{conv=unblock}),
|
||||
use @var{bytes} as the fixed record length.
|
||||
|
||||
@item skip=@var{blocks}
|
||||
@opindex skip
|
||||
@@ -7341,6 +7437,8 @@ Use non-blocking I/O.
|
||||
@opindex noatime
|
||||
@cindex access time
|
||||
Do not update the file's access time.
|
||||
Some older file systems silently ignore this flag, so it is a good
|
||||
idea to test it on your files before relying on it.
|
||||
|
||||
@item noctty
|
||||
@opindex noctty
|
||||
@@ -7768,6 +7866,24 @@ removal is requested. Equivalent to @option{-I}.
|
||||
Specifying @option{--interactive} and no @var{when} is equivalent to
|
||||
@option{--interactive=always}.
|
||||
|
||||
@itemx --one-file-system
|
||||
@opindex --one-file-system
|
||||
@cindex one file system, restricting @command{rm} to
|
||||
When removing a hierarchy recursively, skip any directory that is on a
|
||||
file system different from that of the corresponding command line argument.
|
||||
|
||||
This option is useful when removing a build ``chroot'' hierarchy,
|
||||
which normally contains no valuable data. However, it is not uncommon
|
||||
to bind-mount @file{/home} into such a hierarchy, to make it easier to
|
||||
use one's start-up file. The catch is that it's easy to forget to
|
||||
unmount @file{/home}. Then, when you use @command{rm -rf} to remove
|
||||
your normally throw-away chroot, that command will remove everything
|
||||
under @file{/home}, too.
|
||||
Use the @option{--one-file-system} option, and it will
|
||||
warn about and skip directories on other file systems.
|
||||
Of course, this will not save your @file{/home} if it and your
|
||||
chroot happen to be on the same file system.
|
||||
|
||||
@itemx --preserve-root
|
||||
@opindex --preserve-root
|
||||
@cindex root directory, disallow recursive destruction
|
||||
@@ -8330,15 +8446,23 @@ overridden in this way.
|
||||
@opindex -p
|
||||
@opindex --parents
|
||||
@cindex parent directories, creating
|
||||
Make any missing parent directories for each argument. The file permission
|
||||
bits of parent directories are set to the umask modified by @samp{u+wx}.
|
||||
@xref{Directory Setuid and Setgid}, for how the set-user-ID and
|
||||
set-group-ID bits of parent directories are inherited.
|
||||
Ignore arguments corresponding to existing directories, and do not
|
||||
change their file mode bits.
|
||||
Make any missing parent directories for each argument, setting their
|
||||
file permission bits to the umask modified by @samp{u+wx}. Ignore
|
||||
existing parent directories, and do not change their file permission
|
||||
bits.
|
||||
|
||||
To set the file permission bits of any newly-created parent
|
||||
directories to a value that includes @samp{u+wx}, you can set the
|
||||
umask before invoking @command{mkdir}. For example, if the shell
|
||||
command @samp{(umask u=rwx,go=rx; mkdir -p P/Q)} creates the parent
|
||||
@file{P} it sets the parent's permission bits to @samp{u=rwx,go=rx}.
|
||||
To set a parent's special mode bits as well, you can invoke
|
||||
@command{chmod} after @command{mkdir}. @xref{Directory Setuid and
|
||||
Setgid}, for how the set-user-ID and set-group-ID bits of
|
||||
newly-created parent directories are inherited.
|
||||
|
||||
@item -v
|
||||
@item --verbose
|
||||
@itemx --verbose
|
||||
@opindex -v
|
||||
@opindex --verbose
|
||||
Print a message for each created directory. This is most useful with
|
||||
@@ -8585,7 +8709,7 @@ a failure does not evoke a diagnostic and does not cause @command{rmdir} to
|
||||
exit unsuccessfully.
|
||||
|
||||
@item -v
|
||||
@item --verbose
|
||||
@itemx --verbose
|
||||
@opindex -v
|
||||
@opindex --verbose
|
||||
@cindex directory deletion, reporting
|
||||
@@ -8704,6 +8828,10 @@ owner nor the group is changed.
|
||||
|
||||
@end table
|
||||
|
||||
If @var{owner} or @var{group} is intended to represent a numeric user
|
||||
or group ID, then you may specify it with a leading @samp{+}.
|
||||
@xref{Disambiguating names and IDs}.
|
||||
|
||||
Some older scripts may still use @samp{.} in place of the @samp{:} separator.
|
||||
@acronym{POSIX} 1003.1-2001 (@pxref{Standards conformance}) does not
|
||||
require support for that, but for backward compatibility @acronym{GNU}
|
||||
@@ -8879,6 +9007,10 @@ or to the group of an existing reference file. Synopsis:
|
||||
chgrp [@var{option}]@dots{} @{@var{group} | --reference=@var{ref_file}@} @var{file}@dots{}
|
||||
@end example
|
||||
|
||||
If @var{group} is intended to represent a
|
||||
numeric group ID, then you may specify it with a leading @samp{+}.
|
||||
@xref{Disambiguating names and IDs}.
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@table @samp
|
||||
@@ -9128,7 +9260,7 @@ operations, for a user to change the ctime field to a user-specified value.
|
||||
Time stamps assume the time zone rules specified by the @env{TZ}
|
||||
environment variable, or by the system default rules if @env{TZ} is
|
||||
not set. @xref{TZ Variable,, Specifying the Time Zone with @env{TZ},
|
||||
libc, The GNU C Library}. You can avoid avoid ambiguities during
|
||||
libc, The GNU C Library}. You can avoid ambiguities during
|
||||
daylight saving transitions by using @sc{utc} time stamps.
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
@@ -9225,11 +9357,9 @@ For example, use @samp{touch ./12312359 main.c} or @samp{touch -t
|
||||
|
||||
@cindex disk usage
|
||||
|
||||
No disk can hold an infinite amount of data. These commands report on
|
||||
how much disk storage is in use or available. (This has nothing much to
|
||||
do with how much @emph{main memory}, i.e., RAM, a program is using when
|
||||
it runs; for that, you want @command{ps} or @command{pstat} or @command{swap}
|
||||
or some such command.)
|
||||
No disk can hold an infinite amount of data. These commands report
|
||||
how much disk storage is in use or available, report other file and
|
||||
file status information, and write buffers to disk.
|
||||
|
||||
@menu
|
||||
* df invocation:: Report file system disk space usage.
|
||||
@@ -9351,6 +9481,13 @@ some network mounts), the columns are misaligned.
|
||||
|
||||
@item
|
||||
The labels in the header output line are changed to conform to @acronym{POSIX}.
|
||||
|
||||
@item
|
||||
The default block size and output format are unaffected by the
|
||||
@env{DF_BLOCK_SIZE}, @env{BLOCK_SIZE} and @env{BLOCKSIZE} environment
|
||||
variables. However, the default block size is still affected by
|
||||
@env{POSIXLY_CORRECT}: it is 512 if @env{POSIXLY_CORRECT} is set, 1024
|
||||
otherwise. @xref{Block size}.
|
||||
@end enumerate
|
||||
|
||||
@optSi
|
||||
@@ -9778,7 +9915,7 @@ $ stat --format=%d:%i / /usr
|
||||
@opindex --printf=@var{format}
|
||||
@cindex output format
|
||||
Use @var{format} rather than the default format.
|
||||
Like like @option{--format}, but interpret backslash escapes,
|
||||
Like @option{--format}, but interpret backslash escapes,
|
||||
and do not output a mandatory trailing newline.
|
||||
If you want a newline, include @samp{\n} in the @var{format}.
|
||||
Here's how you would use @option{--printf} to print the device
|
||||
@@ -11971,7 +12108,8 @@ options}.
|
||||
|
||||
@command{groups} prints the names of the primary and any supplementary
|
||||
groups for each given @var{username}, or the current process if no names
|
||||
are given. If names are given, the name of each user is printed before
|
||||
are given. If more than one name is given, the name of each user is
|
||||
printed before
|
||||
the list of that user's groups. Synopsis:
|
||||
|
||||
@example
|
||||
@@ -13795,6 +13933,12 @@ Print all numbers using @var{format}.
|
||||
@var{format} must contain exactly one of the @samp{printf}-style
|
||||
floating point conversion specifications @samp{%a}, @samp{%e},
|
||||
@samp{%f}, @samp{%g}, @samp{%A}, @samp{%E}, @samp{%F}, @samp{%G}.
|
||||
The @samp{%} may be followed by zero or more flags taken from the set
|
||||
@samp{-+#0 '}, then an optional width containing one or more digits,
|
||||
then an optional precision consisting of a @samp{.} followed by zero
|
||||
or more digits. @var{format} may also contain any number of @samp{%%}
|
||||
conversion specifications. All conversion specifications have the
|
||||
same meaning as with @samp{printf}.
|
||||
|
||||
The default format is derived from @var{first}, @var{step}, and
|
||||
@var{last}. If these all use a fixed point decimal representation,
|
||||
@@ -13817,6 +13961,15 @@ decimal representation.
|
||||
|
||||
@end table
|
||||
|
||||
You can get finer-grained control over output with @option{-f}:
|
||||
|
||||
@example
|
||||
$ seq -f '(%9.2E)' -9e5 1.1e6 1.3e6
|
||||
(-9.00E+05)
|
||||
( 2.00E+05)
|
||||
( 1.30E+06)
|
||||
@end example
|
||||
|
||||
If you want hexadecimal integer output, you can use @command{printf}
|
||||
to perform the conversion:
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ executable files (programs) and, on most systems, directories:
|
||||
@cindex set-user-ID
|
||||
@cindex setuid
|
||||
Set the process's effective user ID to that of the file upon execution
|
||||
(called the @dfn{set-user-ID bit}, or sometimes the @dfn{setgid bit}).
|
||||
(called the @dfn{set-user-ID bit}, or sometimes the @dfn{setuid bit}).
|
||||
For directories on a few systems, give files created in the directory
|
||||
the same owner as the directory, no matter who creates them, and set
|
||||
the set-user-ID bit of newly-created subdirectories.
|
||||
|
||||
559
gl/lib/base64.c
Normal file
559
gl/lib/base64.c
Normal file
@@ -0,0 +1,559 @@
|
||||
/* 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 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* 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;
|
||||
}
|
||||
54
gl/lib/base64.h
Normal file
54
gl/lib/base64.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* 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 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#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,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
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,
|
||||
@@ -6,7 +6,6 @@ dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_ROOT_DEV_INO],
|
||||
[
|
||||
AC_LIBSOURCES([root-dev-ino.c, root-dev-ino.h, dev-ino.h, same-inode.h])
|
||||
AC_LIBOBJ([root-dev-ino])
|
||||
|
||||
dnl Prerequisites
|
||||
16
gl/modules/getloadavg.diff
Normal file
16
gl/modules/getloadavg.diff
Normal file
@@ -0,0 +1,16 @@
|
||||
Index: modules/getloadavg
|
||||
===================================================================
|
||||
RCS file: /sources/gnulib/gnulib/modules/getloadavg,v
|
||||
retrieving revision 1.13
|
||||
diff -u -p -r1.13 getloadavg
|
||||
--- modules/getloadavg 22 Sep 2006 12:47:55 -0000 1.13
|
||||
+++ modules/getloadavg 23 Sep 2006 16:41:36 -0000
|
||||
@@ -14,7 +14,7 @@ stdbool
|
||||
fcntl-safer
|
||||
|
||||
configure.ac:
|
||||
-gl_GETLOADAVG([$gl_source_base])
|
||||
+gl_GETLOADAVG([lib])
|
||||
|
||||
Makefile.am:
|
||||
|
||||
25
gl/modules/root-dev-ino
Normal file
25
gl/modules/root-dev-ino
Normal file
@@ -0,0 +1,25 @@
|
||||
Description:
|
||||
Root device and inode number checking.
|
||||
|
||||
Files:
|
||||
lib/root-dev-ino.h
|
||||
lib/root-dev-ino.c
|
||||
m4/root-dev-ino.m4
|
||||
|
||||
Depends-on:
|
||||
dev-ino
|
||||
same-inode
|
||||
|
||||
configure.ac:
|
||||
gl_ROOT_DEV_INO
|
||||
|
||||
Makefile.am:
|
||||
|
||||
Include:
|
||||
"root-dev-ino.h"
|
||||
|
||||
License:
|
||||
GPL
|
||||
|
||||
Maintainer:
|
||||
Jim Meyering
|
||||
@@ -3,8 +3,10 @@ Makefile
|
||||
Makefile.in
|
||||
__fpending.c
|
||||
__fpending.h
|
||||
acl-internal.h
|
||||
acl.c
|
||||
acl.h
|
||||
acl_entries.c
|
||||
alloca.c
|
||||
alloca.h
|
||||
alloca_.h
|
||||
@@ -22,6 +24,11 @@ backupfile.h
|
||||
base64.c
|
||||
base64.h
|
||||
basename.c
|
||||
c-ctype.c
|
||||
c-ctype.h
|
||||
c-strcase.h
|
||||
c-strcasecmp.c
|
||||
c-strncasecmp.c
|
||||
c-strtod.c
|
||||
c-strtod.h
|
||||
c-strtold.c
|
||||
@@ -40,6 +47,7 @@ close-stream.c
|
||||
close-stream.h
|
||||
closeout.c
|
||||
closeout.h
|
||||
concatpath.c
|
||||
config.charset
|
||||
config.h
|
||||
config.hin
|
||||
@@ -52,6 +60,8 @@ diacrit.c
|
||||
diacrit.h
|
||||
dirchownmod.c
|
||||
dirchownmod.h
|
||||
dirent.h
|
||||
dirent_.h
|
||||
dirfd.c
|
||||
dirfd.h
|
||||
dirname.c
|
||||
@@ -67,12 +77,16 @@ exclude.h
|
||||
exit.h
|
||||
exitfail.c
|
||||
exitfail.h
|
||||
fchdir.c
|
||||
fchmodat.c
|
||||
fchown-stub.c
|
||||
fchownat.c
|
||||
fcntl--.h
|
||||
fcntl-safer.h
|
||||
fcntl.h
|
||||
fcntl_.h
|
||||
fd-safer.c
|
||||
file-has-acl.c
|
||||
file-type.c
|
||||
file-type.h
|
||||
fileblocks.c
|
||||
@@ -80,6 +94,8 @@ filemode.c
|
||||
filemode.h
|
||||
filenamecat.c
|
||||
filenamecat.h
|
||||
findprog.c
|
||||
findprog.h
|
||||
fnmatch.c
|
||||
fnmatch.h
|
||||
fnmatch_.h
|
||||
@@ -88,6 +104,7 @@ fopen-safer.c
|
||||
fprintftime.c
|
||||
fprintftime.h
|
||||
free.c
|
||||
fstatat.c
|
||||
fsusage.c
|
||||
fsusage.h
|
||||
ftruncate.c
|
||||
@@ -144,6 +161,8 @@ hash.c
|
||||
hash.h
|
||||
human.c
|
||||
human.h
|
||||
i-ring.c
|
||||
i-ring.h
|
||||
idcache.c
|
||||
imaxtostr.c
|
||||
inet_ntop.c
|
||||
@@ -169,6 +188,7 @@ lstat.h
|
||||
malloc.c
|
||||
mbchar.c
|
||||
mbchar.h
|
||||
mbscasecmp.c
|
||||
mbswidth.c
|
||||
mbswidth.h
|
||||
mbuiter.h
|
||||
@@ -183,9 +203,7 @@ memcoll.h
|
||||
memcpy.c
|
||||
memmove.c
|
||||
mempcpy.c
|
||||
mempcpy.h
|
||||
memrchr.c
|
||||
memrchr.h
|
||||
memset.c
|
||||
mkancesdirs.c
|
||||
mkancesdirs.h
|
||||
@@ -195,21 +213,28 @@ mkdir.c
|
||||
mkdirat.c
|
||||
mkstemp-safer.c
|
||||
mkstemp.c
|
||||
mkstemp.h
|
||||
mktime.c
|
||||
modechange.c
|
||||
modechange.h
|
||||
mountlist.c
|
||||
mountlist.h
|
||||
mpsort.c
|
||||
mpsort.h
|
||||
nanosleep.c
|
||||
netinet_in.h
|
||||
netinet_in_.h
|
||||
obstack.c
|
||||
obstack.h
|
||||
offtostr.c
|
||||
open-safer.c
|
||||
openat-die.c
|
||||
openat-priv.h
|
||||
openat-proc.c
|
||||
openat.c
|
||||
openat.h
|
||||
pathmax.h
|
||||
pathname.h
|
||||
physmem.c
|
||||
physmem.h
|
||||
pipe-safer.c
|
||||
@@ -248,6 +273,8 @@ regexec.c
|
||||
rename-dest-slash.c
|
||||
rename.c
|
||||
rmdir.c
|
||||
root-dev-ino.c
|
||||
root-dev-ino.h
|
||||
rpmatch.c
|
||||
safe-read.c
|
||||
safe-read.h
|
||||
@@ -272,10 +299,12 @@ sig2str.c
|
||||
sig2str.h
|
||||
snprintf.c
|
||||
snprintf.h
|
||||
socket.h
|
||||
socket_.h
|
||||
stamp-h1
|
||||
stat-macros.h
|
||||
stat-time.h
|
||||
stat.h
|
||||
stat_.h
|
||||
stdbool.h
|
||||
stdbool_.h
|
||||
@@ -283,27 +312,27 @@ stdint.h
|
||||
stdint_.h
|
||||
stdio--.h
|
||||
stdio-safer.h
|
||||
stdio.h
|
||||
stdio_.h
|
||||
stdlib--.h
|
||||
stdlib-safer.h
|
||||
stdlib.h
|
||||
stdlib_.h
|
||||
stpcpy.c
|
||||
stpcpy.h
|
||||
strcase.h
|
||||
strcasecmp.c
|
||||
strcspn.c
|
||||
strdup.c
|
||||
strdup.h
|
||||
strftime.c
|
||||
strftime.h
|
||||
string.h
|
||||
string_.h
|
||||
stripslash.c
|
||||
strncasecmp.c
|
||||
strndup.c
|
||||
strndup.h
|
||||
strnlen.c
|
||||
strnlen.h
|
||||
strnlen1.c
|
||||
strnlen1.h
|
||||
strpbrk.c
|
||||
strpbrk.h
|
||||
strtod.c
|
||||
strtoimax.c
|
||||
strtol.c
|
||||
@@ -313,15 +342,24 @@ strtoull.c
|
||||
strtoumax.c
|
||||
strverscmp.c
|
||||
strverscmp.h
|
||||
sys
|
||||
sys_time.h
|
||||
sys_time_.h
|
||||
t-fpending
|
||||
tempname.c
|
||||
tempname.h
|
||||
time.h
|
||||
time_.h
|
||||
time_r.c
|
||||
time_r.h
|
||||
timespec.h
|
||||
uinttostr.c
|
||||
umaxtostr.c
|
||||
unicodeio.h
|
||||
unistd--.h
|
||||
unistd-safer.h
|
||||
unistd.h
|
||||
unistd_.h
|
||||
unlinkdir.c
|
||||
unlinkdir.h
|
||||
unlocked-io.h
|
||||
@@ -340,6 +378,10 @@ verify.h
|
||||
version-etc-fsf.c
|
||||
version-etc.c
|
||||
version-etc.h
|
||||
wchar.h
|
||||
wchar_.h
|
||||
wctype.h
|
||||
wctype_.h
|
||||
wcwidth.h
|
||||
xalloc-die.c
|
||||
xalloc.h
|
||||
@@ -352,6 +394,7 @@ xmemcoll.c
|
||||
xmemcoll.h
|
||||
xnanosleep.c
|
||||
xnanosleep.h
|
||||
xreadlink-with-size.c
|
||||
xreadlink.c
|
||||
xreadlink.h
|
||||
xstrndup.c
|
||||
|
||||
403
lib/.gitignore
vendored
Normal file
403
lib/.gitignore
vendored
Normal file
@@ -0,0 +1,403 @@
|
||||
__fpending.c
|
||||
__fpending.h
|
||||
acl-internal.h
|
||||
acl.c
|
||||
acl.h
|
||||
acl_entries.c
|
||||
alloca.c
|
||||
alloca.h
|
||||
alloca_.h
|
||||
allocsa.c
|
||||
allocsa.h
|
||||
allocsa.valgrind
|
||||
argmatch.c
|
||||
argmatch.h
|
||||
asnprintf.c
|
||||
asprintf.c
|
||||
at-func.c
|
||||
atexit.c
|
||||
backupfile.c
|
||||
backupfile.h
|
||||
base64.c
|
||||
base64.h
|
||||
basename.c
|
||||
c-ctype.c
|
||||
c-ctype.h
|
||||
c-strcase.h
|
||||
c-strcasecmp.c
|
||||
c-strncasecmp.c
|
||||
c-strtod.c
|
||||
c-strtod.h
|
||||
c-strtold.c
|
||||
calloc.c
|
||||
canon-host.c
|
||||
canon-host.h
|
||||
canonicalize.c
|
||||
canonicalize.h
|
||||
charset.alias
|
||||
chdir-long.c
|
||||
chdir-long.h
|
||||
chown.c
|
||||
cloexec.c
|
||||
cloexec.h
|
||||
close-stream.c
|
||||
close-stream.h
|
||||
closeout.c
|
||||
closeout.h
|
||||
concatpath.c
|
||||
config.charset
|
||||
configmake.h
|
||||
creat-safer.c
|
||||
cycle-check.c
|
||||
cycle-check.h
|
||||
dev-ino.h
|
||||
diacrit.c
|
||||
diacrit.h
|
||||
dirchownmod.c
|
||||
dirchownmod.h
|
||||
dirent.h
|
||||
dirent_.h
|
||||
dirfd.c
|
||||
dirfd.h
|
||||
dirname.c
|
||||
dirname.h
|
||||
dup-safer.c
|
||||
dup2.c
|
||||
error.c
|
||||
error.h
|
||||
euidaccess.c
|
||||
euidaccess.h
|
||||
exclude.c
|
||||
exclude.h
|
||||
exit.h
|
||||
exitfail.c
|
||||
exitfail.h
|
||||
fchdir.c
|
||||
fchmodat.c
|
||||
fchown-stub.c
|
||||
fchownat.c
|
||||
fcntl--.h
|
||||
fcntl-safer.h
|
||||
fcntl.h
|
||||
fcntl_.h
|
||||
fd-safer.c
|
||||
file-has-acl.c
|
||||
file-type.c
|
||||
file-type.h
|
||||
fileblocks.c
|
||||
filemode.c
|
||||
filemode.h
|
||||
filenamecat.c
|
||||
filenamecat.h
|
||||
findprog.c
|
||||
findprog.h
|
||||
fnmatch.c
|
||||
fnmatch.h
|
||||
fnmatch_.h
|
||||
fnmatch_loop.c
|
||||
fopen-safer.c
|
||||
fprintftime.c
|
||||
fprintftime.h
|
||||
free.c
|
||||
fstatat.c
|
||||
fsusage.c
|
||||
fsusage.h
|
||||
ftruncate.c
|
||||
fts-cycle.c
|
||||
fts.c
|
||||
fts.h
|
||||
fts_.h
|
||||
full-read.c
|
||||
full-read.h
|
||||
full-write.c
|
||||
full-write.h
|
||||
gai_strerror.c
|
||||
getaddrinfo.c
|
||||
getaddrinfo.h
|
||||
getcwd.c
|
||||
getcwd.h
|
||||
getdate.c
|
||||
getdate.h
|
||||
getdate.y
|
||||
getdelim.c
|
||||
getdelim.h
|
||||
getgroups.c
|
||||
gethostname.c
|
||||
gethrxtime.c
|
||||
gethrxtime.h
|
||||
getline.c
|
||||
getline.h
|
||||
getloadavg.c
|
||||
getndelim2.c
|
||||
getndelim2.h
|
||||
getopt.c
|
||||
getopt.h
|
||||
getopt1.c
|
||||
getopt_.h
|
||||
getopt_int.h
|
||||
getpagesize.h
|
||||
getpass.c
|
||||
getpass.h
|
||||
gettext.h
|
||||
gettime.c
|
||||
gettimeofday.c
|
||||
getugroups.c
|
||||
getusershell.c
|
||||
gnulib.mk
|
||||
group-member.c
|
||||
group-member.h
|
||||
hard-locale.c
|
||||
hard-locale.h
|
||||
hash-pjw.c
|
||||
hash-pjw.h
|
||||
hash.c
|
||||
hash.h
|
||||
human.c
|
||||
human.h
|
||||
i-ring.c
|
||||
i-ring.h
|
||||
idcache.c
|
||||
imaxtostr.c
|
||||
inet_ntop.c
|
||||
inet_ntop.h
|
||||
intprops.h
|
||||
inttostr.c
|
||||
inttostr.h
|
||||
inttypes.h
|
||||
inttypes_.h
|
||||
isapipe.c
|
||||
isapipe.h
|
||||
lchmod.h
|
||||
lchown.c
|
||||
lchown.h
|
||||
libcoreutils.a
|
||||
linebuffer.c
|
||||
linebuffer.h
|
||||
localcharset.c
|
||||
localcharset.h
|
||||
long-options.c
|
||||
long-options.h
|
||||
lstat.c
|
||||
lstat.h
|
||||
malloc.c
|
||||
mbchar.c
|
||||
mbchar.h
|
||||
mbscasecmp.c
|
||||
mbswidth.c
|
||||
mbswidth.h
|
||||
mbuiter.h
|
||||
md5.c
|
||||
md5.h
|
||||
memcasecmp.c
|
||||
memcasecmp.h
|
||||
memchr.c
|
||||
memcmp.c
|
||||
memcoll.c
|
||||
memcoll.h
|
||||
memcpy.c
|
||||
memmove.c
|
||||
mempcpy.c
|
||||
memrchr.c
|
||||
memset.c
|
||||
mkancesdirs.c
|
||||
mkancesdirs.h
|
||||
mkdir-p.c
|
||||
mkdir-p.h
|
||||
mkdir.c
|
||||
mkdirat.c
|
||||
mkstemp-safer.c
|
||||
mkstemp.c
|
||||
mkstemp.h
|
||||
mktime.c
|
||||
modechange.c
|
||||
modechange.h
|
||||
mountlist.c
|
||||
mountlist.h
|
||||
mpsort.c
|
||||
mpsort.h
|
||||
nanosleep.c
|
||||
netinet_in.h
|
||||
netinet_in_.h
|
||||
obstack.c
|
||||
obstack.h
|
||||
offtostr.c
|
||||
open-safer.c
|
||||
openat-die.c
|
||||
openat-priv.h
|
||||
openat-proc.c
|
||||
openat.c
|
||||
openat.h
|
||||
pathmax.h
|
||||
pathname.h
|
||||
physmem.c
|
||||
physmem.h
|
||||
pipe-safer.c
|
||||
posixtm.c
|
||||
posixtm.h
|
||||
posixver.c
|
||||
posixver.h
|
||||
printf-args.c
|
||||
printf-args.h
|
||||
printf-parse.h
|
||||
putenv.c
|
||||
quote.c
|
||||
quote.h
|
||||
quotearg.c
|
||||
quotearg.h
|
||||
raise.c
|
||||
readlink.c
|
||||
readtokens.c
|
||||
readtokens.h
|
||||
readtokens0.c
|
||||
readtokens0.h
|
||||
readutmp.c
|
||||
readutmp.h
|
||||
realloc.c
|
||||
ref-add.sed
|
||||
ref-add.sin
|
||||
ref-del.sed
|
||||
ref-del.sin
|
||||
regcomp.c
|
||||
regex.c
|
||||
regex.h
|
||||
regex_internal.c
|
||||
regex_internal.h
|
||||
regexec.c
|
||||
rename-dest-slash.c
|
||||
rename.c
|
||||
rmdir.c
|
||||
root-dev-ino.c
|
||||
root-dev-ino.h
|
||||
rpmatch.c
|
||||
safe-read.c
|
||||
safe-read.h
|
||||
safe-write.c
|
||||
safe-write.h
|
||||
same-inode.h
|
||||
same.c
|
||||
same.h
|
||||
save-cwd.c
|
||||
save-cwd.h
|
||||
savedir.c
|
||||
savedir.h
|
||||
savewd.c
|
||||
savewd.h
|
||||
setenv.c
|
||||
setenv.h
|
||||
settime.c
|
||||
sha1.c
|
||||
sha1.h
|
||||
sig2str.c
|
||||
sig2str.h
|
||||
snprintf.c
|
||||
snprintf.h
|
||||
socket.h
|
||||
socket_.h
|
||||
stat-macros.h
|
||||
stat-time.h
|
||||
stat.h
|
||||
stat_.h
|
||||
stdbool.h
|
||||
stdbool_.h
|
||||
stdint.h
|
||||
stdint_.h
|
||||
stdio--.h
|
||||
stdio-safer.h
|
||||
stdio.h
|
||||
stdio_.h
|
||||
stdlib--.h
|
||||
stdlib-safer.h
|
||||
stdlib.h
|
||||
stdlib_.h
|
||||
stpcpy.c
|
||||
strcasecmp.c
|
||||
strcspn.c
|
||||
strdup.c
|
||||
strftime.c
|
||||
strftime.h
|
||||
string.h
|
||||
string_.h
|
||||
stripslash.c
|
||||
strncasecmp.c
|
||||
strndup.c
|
||||
strnlen.c
|
||||
strnlen1.c
|
||||
strnlen1.h
|
||||
strpbrk.c
|
||||
strtod.c
|
||||
strtoimax.c
|
||||
strtol.c
|
||||
strtoll.c
|
||||
strtoul.c
|
||||
strtoull.c
|
||||
strtoumax.c
|
||||
strverscmp.c
|
||||
strverscmp.h
|
||||
sys
|
||||
sys_time.h
|
||||
sys_time_.h
|
||||
t-fpending
|
||||
tempname.c
|
||||
tempname.h
|
||||
time.h
|
||||
time_.h
|
||||
time_r.c
|
||||
time_r.h
|
||||
timespec.h
|
||||
uinttostr.c
|
||||
umaxtostr.c
|
||||
unicodeio.h
|
||||
unistd--.h
|
||||
unistd-safer.h
|
||||
unistd.h
|
||||
unistd_.h
|
||||
unlinkdir.c
|
||||
unlinkdir.h
|
||||
unlocked-io.h
|
||||
unsetenv.c
|
||||
userspec.c
|
||||
userspec.h
|
||||
utime.c
|
||||
utimecmp.c
|
||||
utimecmp.h
|
||||
utimens.c
|
||||
utimens.h
|
||||
vasnprintf.h
|
||||
vasprintf.c
|
||||
vasprintf.h
|
||||
verify.h
|
||||
version-etc-fsf.c
|
||||
version-etc.c
|
||||
version-etc.h
|
||||
wchar.h
|
||||
wchar_.h
|
||||
wctype.h
|
||||
wctype_.h
|
||||
wcwidth.h
|
||||
xalloc-die.c
|
||||
xalloc.h
|
||||
xgetcwd.c
|
||||
xgetcwd.h
|
||||
xgethostname.c
|
||||
xgethostname.h
|
||||
xmalloc.c
|
||||
xmemcoll.c
|
||||
xmemcoll.h
|
||||
xnanosleep.c
|
||||
xnanosleep.h
|
||||
xreadlink-with-size.c
|
||||
xreadlink.c
|
||||
xreadlink.h
|
||||
xstrndup.c
|
||||
xstrndup.h
|
||||
xstrtod.c
|
||||
xstrtod.h
|
||||
xstrtoimax.c
|
||||
xstrtol.c
|
||||
xstrtol.h
|
||||
xstrtold.c
|
||||
xstrtoul.c
|
||||
xstrtoumax.c
|
||||
xtime.h
|
||||
yesno.c
|
||||
yesno.h
|
||||
111
lib/ChangeLog
111
lib/ChangeLog
@@ -1,3 +1,114 @@
|
||||
2007-03-20 Jim Meyering <jim@meyering.net>
|
||||
|
||||
Fix a typo in the handling of %x and %X.
|
||||
* vasnprintf.c (VASNPRINTF): When adding 2 to buffer length,
|
||||
don't double it.
|
||||
|
||||
2007-03-04 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* vasnprintf.c (VASNPRINTF): Add missing semicolon.
|
||||
|
||||
2007-03-02 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* vasnprintf.c (VASNPRINTF): Remove cast of alloca return value.
|
||||
|
||||
2007-03-01 Jim Meyering <jim@meyering.net>
|
||||
|
||||
Merge in changes from gnulib:
|
||||
* vasnprintf.c: Add a comment explaining why coreutils has its own
|
||||
version of this file.
|
||||
Include <stdint.h>.
|
||||
(SIZE_MAX): Remove definition (now, stdint.h covers that).
|
||||
(EOVERFLOW): Remove definition (now done via the eoverflow module).
|
||||
Update some #ifdef to #if.
|
||||
Use HAVE_LONG_LONG_INT, not HAVE_LONG_LONG.
|
||||
* printf-parse.c: Likewise.
|
||||
|
||||
2007-02-28 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* tsearch.c: Remove unused file.
|
||||
|
||||
2007-02-23 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* randperm.c (randperm_new): Comment: say that this function
|
||||
returns a pointer to malloc'd storage.
|
||||
|
||||
2007-02-18 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* xfts.c: Include <stdlib.h> rather than exit.h, now that stdlib.h
|
||||
is guaranteed to provide a valid definition of EXIT_FAILURE.
|
||||
|
||||
2007-01-19 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* .cvsignore, .gitignore: Add sys, as well as more
|
||||
bootstrap-inserted file names.
|
||||
|
||||
2007-01-14 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* fchdir-stub.c: Remove file. No longer needed.
|
||||
|
||||
2006-12-03 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* Makefile.am (libcoreutils_a_SOURCES): Remove xmemcoll.c and
|
||||
xmemcoll.h. Now, they're handled by the gnulib xmemcoll module.
|
||||
|
||||
2006-11-22 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* randread.c (__attribute__): Don't define if __attribute__ is
|
||||
already defined. Otherwise, the code won't conform to C99, since
|
||||
the macro arg is spelled differently by some include file, and the
|
||||
compilation fails with pedantic GCC.
|
||||
|
||||
2006-11-22 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* .cvsignore, .gitignore: Add fstat.c.
|
||||
|
||||
2006-11-14 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* readlink-stub.c, lstat-stub.c: Remove now-unused files.
|
||||
|
||||
2006-10-14 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Port sha512sum to hosts where uintmax_t is only 32 bits, e.g.,
|
||||
HP/Tandom NonStop OSS circa 2005 has 32-bit uintmax_t, 64-bit intmax_t.
|
||||
* u64.h: New file.
|
||||
* sha512.c (SWAP, sha512_init_ctx, sha384_init_ctx, sha512_read_ctx):
|
||||
(sha384_read_ctx, sha512_conclude_ctx, sha512_process_bytes):
|
||||
(sha512_round_constants, F2, F1, sha512_process_block):
|
||||
(S0, S1, SS0, SS1, M, R):
|
||||
Rewrite to use u64.h instead of assuming uint64_t.
|
||||
* sha512.h: Include u64.h rather than stdint.h.
|
||||
(rol64): Remove; moved to u64.h and renamed to u64rol.
|
||||
|
||||
2006-10-12 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* Makefile.am (libcoreutils_a_LIBADD): Append $(LIBOBJS),
|
||||
to accommodate the latest version of gnulib-tool.
|
||||
(libcoreutils_a_DEPENDENCIES): Likewise.
|
||||
From Bruno Haible.
|
||||
|
||||
2006-10-06 Jim Meyering <jim@meyering.net>
|
||||
|
||||
Avoid a compiler warning: const'ify and remove a cast.
|
||||
* randread.c (struct randread_source) [handler]: Make parameter "const".
|
||||
[handler_arg]: Add "const" attribute.
|
||||
(randread_error): Make parameter "const".
|
||||
(simple_new, randread_set_handler, randread_set_handler_arg): Likewise.
|
||||
(randread_new): Remove now-unnecessary cast.
|
||||
* randread.h: Adjust prototypes.
|
||||
|
||||
2006-09-29 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* .cvsignore: Add openat-proc.c.
|
||||
|
||||
2006-09-25 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* .cvsignore: Add fchmodat.c.
|
||||
|
||||
2006-09-25 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* fchmodat.c: Remove file. gnulib's copy is identical.
|
||||
|
||||
2006-09-01 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* .cvsignore: Add fcntl.h, fcntl_.h, inttypes_.h, isapipe.c,
|
||||
|
||||
@@ -26,9 +26,11 @@ LDADD = $(noinst_LIBRARIES)
|
||||
|
||||
libcoreutils_a_SOURCES += \
|
||||
buffer-lcm.c buffer-lcm.h \
|
||||
xmemcoll.c xmemcoll.h \
|
||||
xmemxfrm.c xmemxfrm.h
|
||||
|
||||
libcoreutils_a_LIBADD += $(LIBOBJS)
|
||||
libcoreutils_a_DEPENDENCIES += $(LIBOBJS)
|
||||
|
||||
check: unit-test
|
||||
|
||||
.PHONY: unit-test
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#include <config.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* A trivial substitute for `fchdir'.
|
||||
|
||||
DJGPP 2.03 and earlier don't have `fchdir'. */
|
||||
|
||||
int
|
||||
fchdir (int fd)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/* Change the protections of file relative to an open directory.
|
||||
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 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "openat.h"
|
||||
#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
|
||||
#include "save-cwd.h"
|
||||
#include "openat-priv.h"
|
||||
|
||||
#ifndef HAVE_LCHMOD
|
||||
/* Use a different name, to avoid conflicting with any
|
||||
system-supplied declaration. */
|
||||
# undef lchmod
|
||||
# define lchmod lchmod_rpl
|
||||
static int lchmod (char const *f, mode_t m) { errno = ENOSYS; return -1; }
|
||||
#endif
|
||||
|
||||
/* Solaris 10 has no function like this.
|
||||
Invoke chmod or lchmod on file, FILE, using mode MODE, in the directory
|
||||
open on descriptor FD. If possible, do it without changing the
|
||||
working directory. Otherwise, resort to using save_cwd/fchdir,
|
||||
then mkdir/restore_cwd. If either the save_cwd or the restore_cwd
|
||||
fails, then give a diagnostic and exit nonzero.
|
||||
Note that an attempt to use a FLAG value of AT_SYMLINK_NOFOLLOW
|
||||
on a system without lchmod support causes this function to fail. */
|
||||
|
||||
#define AT_FUNC_NAME fchmodat
|
||||
#define AT_FUNC_F1 lchmod
|
||||
#define AT_FUNC_F2 chmod
|
||||
#define AT_FUNC_USE_F1_COND flag == AT_SYMLINK_NOFOLLOW
|
||||
#define AT_FUNC_POST_FILE_PARAM_DECLS , mode_t mode, int flag
|
||||
#define AT_FUNC_POST_FILE_ARGS , mode
|
||||
#include "at-func.c"
|
||||
@@ -1,13 +0,0 @@
|
||||
#include <config.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* A trivial substitute for `lstat'.
|
||||
|
||||
DJGPP 2.03 and earlier don't have `lstat' and don't support
|
||||
symlinks. */
|
||||
|
||||
int
|
||||
lstat (const char *fname, struct stat *st_buf)
|
||||
{
|
||||
return stat (fname, st_buf);
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/* Formatted output to strings.
|
||||
Copyright (C) 1999-2000, 2002-2004, 2006 Free Software Foundation, Inc.
|
||||
This file is intended to provide exactly the same functionality
|
||||
as the version in gnulib, but without the need for the xsize module.
|
||||
|
||||
Copyright (C) 1999-2000, 2002-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
|
||||
@@ -27,21 +30,12 @@
|
||||
/* Get size_t, NULL. */
|
||||
#include <stddef.h>
|
||||
|
||||
/* Get intmax_t. */
|
||||
#if HAVE_STDINT_H_WITH_UINTMAX
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#if HAVE_INTTYPES_H_WITH_UINTMAX
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
/* Get intmax_t, SIZE_MAX. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* malloc(), realloc(), free(). */
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#if WIDE_CHAR_VERSION
|
||||
# define PRINTF_PARSE wprintf_parse
|
||||
# define CHAR_T wchar_t
|
||||
@@ -329,7 +323,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
flags += 8;
|
||||
cp++;
|
||||
}
|
||||
#ifdef HAVE_INTMAX_T
|
||||
#if HAVE_INTMAX_T
|
||||
else if (*cp == 'j')
|
||||
{
|
||||
if (sizeof (intmax_t) > sizeof (long))
|
||||
@@ -385,11 +379,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
switch (c)
|
||||
{
|
||||
case 'd': case 'i':
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#if HAVE_LONG_LONG_INT
|
||||
/* If 'long long' exists and is larger than 'long': */
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_LONGLONGINT;
|
||||
else
|
||||
#endif
|
||||
/* If 'long long' exists and is the same as 'long', we parse
|
||||
"lld" into TYPE_LONGINT. */
|
||||
if (flags >= 8)
|
||||
type = TYPE_LONGINT;
|
||||
else if (flags & 2)
|
||||
@@ -400,11 +397,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
type = TYPE_INT;
|
||||
break;
|
||||
case 'o': case 'u': case 'x': case 'X':
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#if HAVE_LONG_LONG_INT
|
||||
/* If 'long long' exists and is larger than 'long': */
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_ULONGLONGINT;
|
||||
else
|
||||
#endif
|
||||
/* If 'unsigned long long' exists and is the same as
|
||||
'unsigned long', we parse "llu" into TYPE_ULONGINT. */
|
||||
if (flags >= 8)
|
||||
type = TYPE_ULONGINT;
|
||||
else if (flags & 2)
|
||||
@@ -416,7 +416,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
break;
|
||||
case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
|
||||
case 'a': case 'A':
|
||||
#ifdef HAVE_LONG_DOUBLE
|
||||
#if HAVE_LONG_DOUBLE
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_LONGDOUBLE;
|
||||
else
|
||||
@@ -425,7 +425,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
break;
|
||||
case 'c':
|
||||
if (flags >= 8)
|
||||
#ifdef HAVE_WINT_T
|
||||
#if HAVE_WINT_T
|
||||
type = TYPE_WIDE_CHAR;
|
||||
#else
|
||||
goto error;
|
||||
@@ -433,7 +433,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
else
|
||||
type = TYPE_CHAR;
|
||||
break;
|
||||
#ifdef HAVE_WINT_T
|
||||
#if HAVE_WINT_T
|
||||
case 'C':
|
||||
type = TYPE_WIDE_CHAR;
|
||||
c = 'c';
|
||||
@@ -441,7 +441,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
#endif
|
||||
case 's':
|
||||
if (flags >= 8)
|
||||
#ifdef HAVE_WCHAR_T
|
||||
#if HAVE_WCHAR_T
|
||||
type = TYPE_WIDE_STRING;
|
||||
#else
|
||||
goto error;
|
||||
@@ -449,7 +449,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
else
|
||||
type = TYPE_STRING;
|
||||
break;
|
||||
#ifdef HAVE_WCHAR_T
|
||||
#if HAVE_WCHAR_T
|
||||
case 'S':
|
||||
type = TYPE_WIDE_STRING;
|
||||
c = 's';
|
||||
@@ -459,11 +459,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
type = TYPE_POINTER;
|
||||
break;
|
||||
case 'n':
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#if HAVE_LONG_LONG_INT
|
||||
/* If 'long long' exists and is larger than 'long': */
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_COUNT_LONGLONGINT_POINTER;
|
||||
else
|
||||
#endif
|
||||
/* If 'long long' exists and is the same as 'long', we parse
|
||||
"lln" into TYPE_COUNT_LONGINT_POINTER. */
|
||||
if (flags >= 8)
|
||||
type = TYPE_COUNT_LONGINT_POINTER;
|
||||
else if (flags & 2)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random permutations.
|
||||
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
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
|
||||
@@ -58,9 +58,9 @@ randperm_bound (size_t h, size_t n)
|
||||
return bound;
|
||||
}
|
||||
|
||||
/* From R, allocate and return the first H elements of a random
|
||||
permutation of N elements. H must not exceed N. Return NULL if H
|
||||
is zero. */
|
||||
/* From R, allocate and return a malloc'd array of the first H elements
|
||||
of a random permutation of N elements. H must not exceed N.
|
||||
Return NULL if H is zero. */
|
||||
|
||||
size_t *
|
||||
randperm_new (struct randint_source *r, size_t h, size_t n)
|
||||
|
||||
@@ -44,8 +44,10 @@
|
||||
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
@@ -82,8 +84,8 @@ struct randread_source
|
||||
there was an error. If this function returns, it should fix the
|
||||
problem before returning. The default handler assumes that
|
||||
handler_arg is the file name of the source. */
|
||||
void (*handler) (void *);
|
||||
void *handler_arg;
|
||||
void (*handler) (void const *);
|
||||
void const *handler_arg;
|
||||
|
||||
/* The buffer for SOURCE. It's kept here to simplify storage
|
||||
allocation and to make it easier to clear out buffered random
|
||||
@@ -116,7 +118,7 @@ struct randread_source
|
||||
/* The default error handler. */
|
||||
|
||||
static void
|
||||
randread_error (void *file_name)
|
||||
randread_error (void const *file_name)
|
||||
{
|
||||
if (file_name)
|
||||
error (exit_failure, errno,
|
||||
@@ -129,7 +131,7 @@ randread_error (void *file_name)
|
||||
handler. */
|
||||
|
||||
static struct randread_source *
|
||||
simple_new (FILE *source, void *handler_arg)
|
||||
simple_new (FILE *source, void const *handler_arg)
|
||||
{
|
||||
struct randread_source *s = xmalloc (sizeof *s);
|
||||
s->source = source;
|
||||
@@ -167,7 +169,7 @@ randread_new (char const *name, size_t bytes_bound)
|
||||
file_name = NULL;
|
||||
}
|
||||
|
||||
s = simple_new (source, (void *) file_name);
|
||||
s = simple_new (source, file_name);
|
||||
|
||||
if (source)
|
||||
setvbuf (source, s->buf.c, _IOFBF, MIN (sizeof s->buf.c, bytes_bound));
|
||||
@@ -190,13 +192,13 @@ randread_new (char const *name, size_t bytes_bound)
|
||||
does not return. */
|
||||
|
||||
void
|
||||
randread_set_handler (struct randread_source *s, void (*handler) (void *))
|
||||
randread_set_handler (struct randread_source *s, void (*handler) (void const *))
|
||||
{
|
||||
s->handler = handler;
|
||||
}
|
||||
|
||||
void
|
||||
randread_set_handler_arg (struct randread_source *s, void *handler_arg)
|
||||
randread_set_handler_arg (struct randread_source *s, void const *handler_arg)
|
||||
{
|
||||
s->handler_arg = handler_arg;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ struct randread_source;
|
||||
|
||||
struct randread_source *randread_new (char const *, size_t);
|
||||
void randread (struct randread_source *, void *, size_t);
|
||||
void randread_set_handler (struct randread_source *, void (*) (void *));
|
||||
void randread_set_handler_arg (struct randread_source *, void *);
|
||||
void randread_set_handler (struct randread_source *, void (*) (void const *));
|
||||
void randread_set_handler_arg (struct randread_source *, void const *);
|
||||
int randread_free (struct randread_source *);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <config.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* A trivial substitute for `readlink'.
|
||||
|
||||
DJGPP 2.03 and earlier don't have `readlink' and don't support
|
||||
symlinks. */
|
||||
|
||||
int
|
||||
readlink (const char *file, char *buffer, size_t size)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
203
lib/sha512.c
203
lib/sha512.c
@@ -36,9 +36,14 @@
|
||||
# define SWAP(n) (n)
|
||||
#else
|
||||
# define SWAP(n) \
|
||||
(((n) << 56) | (((n) & 0xff00) << 40) | (((n) & 0xff0000UL) << 24) \
|
||||
| (((n) & 0xff000000UL) << 8) | (((n) >> 8) & 0xff000000UL) \
|
||||
| (((n) >> 24) & 0xff0000UL) | (((n) >> 40) & 0xff00UL) | ((n) >> 56))
|
||||
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
|
||||
@@ -59,32 +64,32 @@ static const unsigned char fillbuf[128] = { 0x80, 0 /* , 0, 0, ... */ };
|
||||
void
|
||||
sha512_init_ctx (struct sha512_ctx *ctx)
|
||||
{
|
||||
ctx->state[0] = 0x6a09e667f3bcc908ULL;
|
||||
ctx->state[1] = 0xbb67ae8584caa73bULL;
|
||||
ctx->state[2] = 0x3c6ef372fe94f82bULL;
|
||||
ctx->state[3] = 0xa54ff53a5f1d36f1ULL;
|
||||
ctx->state[4] = 0x510e527fade682d1ULL;
|
||||
ctx->state[5] = 0x9b05688c2b3e6c1fULL;
|
||||
ctx->state[6] = 0x1f83d9abfb41bd6bULL;
|
||||
ctx->state[7] = 0x5be0cd19137e2179ULL;
|
||||
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] = 0;
|
||||
ctx->total[0] = ctx->total[1] = u64lo (0);
|
||||
ctx->buflen = 0;
|
||||
}
|
||||
|
||||
void
|
||||
sha384_init_ctx (struct sha512_ctx *ctx)
|
||||
{
|
||||
ctx->state[0] = 0xcbbb9d5dc1059ed8ULL;
|
||||
ctx->state[1] = 0x629a292a367cd507ULL;
|
||||
ctx->state[2] = 0x9159015a3070dd17ULL;
|
||||
ctx->state[3] = 0x152fecd8f70e5939ULL;
|
||||
ctx->state[4] = 0x67332667ffc00b31ULL;
|
||||
ctx->state[5] = 0x8eb44a8768581511ULL;
|
||||
ctx->state[6] = 0xdb0c2e0d64f98fa7ULL;
|
||||
ctx->state[7] = 0x47b5481dbefa4fa4ULL;
|
||||
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] = 0;
|
||||
ctx->total[0] = ctx->total[1] = u64lo (0);
|
||||
ctx->buflen = 0;
|
||||
}
|
||||
|
||||
@@ -99,7 +104,7 @@ sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
((uint64_t *) resbuf)[i] = SWAP (ctx->state[i]);
|
||||
((u64 *) resbuf)[i] = SWAP (ctx->state[i]);
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
@@ -110,7 +115,7 @@ sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
((uint64_t *) resbuf)[i] = SWAP (ctx->state[i]);
|
||||
((u64 *) resbuf)[i] = SWAP (ctx->state[i]);
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
@@ -124,17 +129,18 @@ static void
|
||||
sha512_conclude_ctx (struct sha512_ctx *ctx)
|
||||
{
|
||||
/* Take yet unprocessed bytes into account. */
|
||||
uint64_t bytes = ctx->buflen;
|
||||
size_t bytes = ctx->buflen;
|
||||
size_t size = (bytes < 112) ? 128 / 8 : 128 * 2 / 8;
|
||||
|
||||
/* Now count remaining bytes. */
|
||||
ctx->total[0] += bytes;
|
||||
if (ctx->total[0] < bytes)
|
||||
++ctx->total[1];
|
||||
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 ((ctx->total[1] << 3) | (ctx->total[0] >> 61));
|
||||
ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
|
||||
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);
|
||||
|
||||
@@ -353,7 +359,7 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx)
|
||||
{
|
||||
#if !_STRING_ARCH_unaligned
|
||||
# define alignof(type) offsetof (struct { char c; type x; }, x)
|
||||
# define UNALIGNED_P(p) (((size_t) p) % alignof (uint64_t) != 0)
|
||||
# define UNALIGNED_P(p) (((size_t) p) % alignof (u64) != 0)
|
||||
if (UNALIGNED_P (buffer))
|
||||
while (len > 128)
|
||||
{
|
||||
@@ -391,22 +397,52 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx)
|
||||
|
||||
/* SHA512 round constants */
|
||||
#define K(I) sha512_round_constants[I]
|
||||
static const uint64_t sha512_round_constants[80] = {
|
||||
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
|
||||
0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL,
|
||||
0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
|
||||
0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL,
|
||||
0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL,
|
||||
0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
|
||||
0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL,
|
||||
0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL,
|
||||
0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
|
||||
0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL,
|
||||
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) ( ( A & B ) | ( C & ( A | B ) ) )
|
||||
#define F1(E,F,G) ( G ^ ( E & ( F ^ G ) ) )
|
||||
#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.
|
||||
@@ -415,47 +451,50 @@ static const uint64_t sha512_round_constants[80] = {
|
||||
void
|
||||
sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
|
||||
{
|
||||
const uint64_t *words = buffer;
|
||||
size_t nwords = len / sizeof (uint64_t);
|
||||
const uint64_t *endp = words + nwords;
|
||||
uint64_t x[16];
|
||||
uint64_t a = ctx->state[0];
|
||||
uint64_t b = ctx->state[1];
|
||||
uint64_t c = ctx->state[2];
|
||||
uint64_t d = ctx->state[3];
|
||||
uint64_t e = ctx->state[4];
|
||||
uint64_t f = ctx->state[5];
|
||||
uint64_t g = ctx->state[6];
|
||||
uint64_t h = ctx->state[7];
|
||||
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] += len;
|
||||
if (ctx->total[0] < len)
|
||||
++ctx->total[1];
|
||||
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) (rol64(x,63)^rol64(x,56)^(x>>7))
|
||||
#define S1(x) (rol64(x,45)^rol64(x,3)^(x>>6))
|
||||
#define SS0(x) (rol64(x,36)^rol64(x,30)^rol64(x,25))
|
||||
#define SS1(x) (rol64(x,50)^rol64(x,46)^rol64(x,23))
|
||||
#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) ( tm = S1(x[(I-2)&0x0f]) + x[(I-7)&0x0f] \
|
||||
+ S0(x[(I-15)&0x0f]) + x[I&0x0f] \
|
||||
, x[I&0x0f] = tm )
|
||||
#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 { t0 = SS0(A) + F2(A,B,C); \
|
||||
t1 = H + SS1(E) \
|
||||
+ F1(E,F,G) \
|
||||
+ K \
|
||||
+ M; \
|
||||
D += t1; H = t0 + t1; \
|
||||
} while(0)
|
||||
#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)
|
||||
{
|
||||
uint64_t tm;
|
||||
uint64_t t0, t1;
|
||||
int t;
|
||||
/* FIXME: see sha1.c for a better implementation. */
|
||||
for (t = 0; t < 16; t++)
|
||||
@@ -545,13 +584,13 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
|
||||
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] += 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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
13
lib/sha512.h
13
lib/sha512.h
@@ -20,16 +20,17 @@
|
||||
# define SHA512_H 1
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdint.h>
|
||||
|
||||
# include "u64.h"
|
||||
|
||||
/* Structure to save state of computation between the single steps. */
|
||||
struct sha512_ctx
|
||||
{
|
||||
uint64_t state[8];
|
||||
u64 state[8];
|
||||
|
||||
uint64_t total[2];
|
||||
uint64_t buflen;
|
||||
uint64_t buffer[32];
|
||||
u64 total[2];
|
||||
size_t buflen;
|
||||
u64 buffer[32];
|
||||
};
|
||||
|
||||
|
||||
@@ -85,6 +86,4 @@ extern int sha384_stream (FILE *stream, void *resblock);
|
||||
extern void *sha512_buffer (const char *buffer, size_t len, void *resblock);
|
||||
extern void *sha384_buffer (const char *buffer, size_t len, void *resblock);
|
||||
|
||||
# define rol64(x,n) ( ((x) << (n)) | ((x) >> (64-(n))) )
|
||||
|
||||
#endif
|
||||
|
||||
698
lib/tsearch.c
698
lib/tsearch.c
@@ -1,698 +0,0 @@
|
||||
/* Copyright (C) 1995, 1996, 1997, 2000, 2005, 2006 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA. */
|
||||
|
||||
/* Tree search for red/black trees.
|
||||
The algorithm for adding nodes is taken from one of the many "Algorithms"
|
||||
books by Robert Sedgewick, although the implementation differs.
|
||||
The algorithm for deleting nodes can probably be found in a book named
|
||||
"Introduction to Algorithms" by Cormen/Leiserson/Rivest. At least that's
|
||||
the book that my professor took most algorithms from during the "Data
|
||||
Structures" course...
|
||||
|
||||
Totally public domain. */
|
||||
|
||||
/* Red/black trees are binary trees in which the edges are colored either red
|
||||
or black. They have the following properties:
|
||||
1. The number of black edges on every path from the root to a leaf is
|
||||
constant.
|
||||
2. No two red edges are adjacent.
|
||||
Therefore there is an upper bound on the length of every path, it's
|
||||
O(log n) where n is the number of nodes in the tree. No path can be longer
|
||||
than 1+2*P where P is the length of the shortest path in the tree.
|
||||
Useful for the implementation:
|
||||
3. If one of the children of a node is NULL, then the other one is red
|
||||
(if it exists).
|
||||
|
||||
In the implementation, not the edges are colored, but the nodes. The color
|
||||
interpreted as the color of the edge leading to this node. The color is
|
||||
meaningless for the root node, but we color the root node black for
|
||||
convenience. All added nodes are red initially.
|
||||
|
||||
Adding to a red/black tree is rather easy. The right place is searched
|
||||
with a usual binary tree search. Additionally, whenever a node N is
|
||||
reached that has two red successors, the successors are colored black and
|
||||
the node itself colored red. This moves red edges up the tree where they
|
||||
pose less of a problem once we get to really insert the new node. Changing
|
||||
N's color to red may violate rule 2, however, so rotations may become
|
||||
necessary to restore the invariants. Adding a new red leaf may violate
|
||||
the same rule, so afterwards an additional check is run and the tree
|
||||
possibly rotated.
|
||||
|
||||
Deleting is hairy. There are mainly two nodes involved: the node to be
|
||||
deleted (n1), and another node that is to be unchained from the tree (n2).
|
||||
If n1 has a successor (the node with a smallest key that is larger than
|
||||
n1), then the successor becomes n2 and its contents are copied into n1,
|
||||
otherwise n1 becomes n2.
|
||||
Unchaining a node may violate rule 1: if n2 is black, one subtree is
|
||||
missing one black edge afterwards. The algorithm must try to move this
|
||||
error upwards towards the root, so that the subtree that does not have
|
||||
enough black edges becomes the whole tree. Once that happens, the error
|
||||
has disappeared. It may not be necessary to go all the way up, since it
|
||||
is possible that rotations and recoloring can fix the error before that.
|
||||
|
||||
Although the deletion algorithm must walk upwards through the tree, we
|
||||
do not store parent pointers in the nodes. Instead, delete allocates a
|
||||
small array of parent pointers and fills it while descending the tree.
|
||||
Since we know that the length of a path is O(log n), where n is the number
|
||||
of nodes, this is likely to use less memory. */
|
||||
|
||||
/* Tree rotations look like this:
|
||||
A C
|
||||
/ \ / \
|
||||
B C A G
|
||||
/ \ / \ --> / \
|
||||
D E F G B F
|
||||
/ \
|
||||
D E
|
||||
|
||||
In this case, A has been rotated left. This preserves the ordering of the
|
||||
binary tree. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if __GNUC__
|
||||
# define alloca __builtin_alloca
|
||||
#else
|
||||
# if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifdef _AIX
|
||||
# pragma alloca
|
||||
# else
|
||||
char *alloca ();
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <search.h>
|
||||
|
||||
#ifndef weak_alias
|
||||
# define __tsearch tsearch
|
||||
# define __tfind tfind
|
||||
# define __tdelete tdelete
|
||||
# define __twalk twalk
|
||||
# define __tdestroy tdestroy
|
||||
#endif
|
||||
|
||||
#ifndef _LIBC
|
||||
# define weak_alias(f,g)
|
||||
# define internal_function
|
||||
#endif
|
||||
|
||||
typedef struct node_t
|
||||
{
|
||||
/* Callers expect this to be the first element in the structure - do not
|
||||
move! */
|
||||
const void *key;
|
||||
struct node_t *left;
|
||||
struct node_t *right;
|
||||
unsigned int red:1;
|
||||
} *node;
|
||||
typedef const struct node_t *const_node;
|
||||
|
||||
#undef DEBUGGING
|
||||
|
||||
#ifdef DEBUGGING
|
||||
|
||||
/* Routines to check tree invariants. */
|
||||
|
||||
# include <assert.h>
|
||||
|
||||
# define CHECK_TREE(a) check_tree(a)
|
||||
|
||||
static void
|
||||
check_tree_recurse (node p, int d_sofar, int d_total)
|
||||
{
|
||||
if (p == NULL)
|
||||
{
|
||||
assert (d_sofar == d_total);
|
||||
return;
|
||||
}
|
||||
|
||||
check_tree_recurse (p->left, d_sofar + (p->left && !p->left->red), d_total);
|
||||
check_tree_recurse (p->right, d_sofar + (p->right && !p->right->red), d_total);
|
||||
if (p->left)
|
||||
assert (!(p->left->red && p->red));
|
||||
if (p->right)
|
||||
assert (!(p->right->red && p->red));
|
||||
}
|
||||
|
||||
static void
|
||||
check_tree (node root)
|
||||
{
|
||||
int cnt = 0;
|
||||
node p;
|
||||
if (root == NULL)
|
||||
return;
|
||||
root->red = 0;
|
||||
for(p = root->left; p; p = p->left)
|
||||
cnt += !p->red;
|
||||
check_tree_recurse (root, 0, cnt);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
# define CHECK_TREE(a)
|
||||
|
||||
#endif
|
||||
|
||||
/* Possibly "split" a node with two red successors, and/or fix up two red
|
||||
edges in a row. ROOTP is a pointer to the lowest node we visited, PARENTP
|
||||
and GPARENTP pointers to its parent/grandparent. P_R and GP_R contain the
|
||||
comparison values that determined which way was taken in the tree to reach
|
||||
ROOTP. MODE is 1 if we need not do the split, but must check for two red
|
||||
edges between GPARENTP and ROOTP. */
|
||||
static void
|
||||
maybe_split_for_insert (node *rootp, node *parentp, node *gparentp,
|
||||
int p_r, int gp_r, int mode)
|
||||
{
|
||||
node root = *rootp;
|
||||
node *rp, *lp;
|
||||
rp = &(*rootp)->right;
|
||||
lp = &(*rootp)->left;
|
||||
|
||||
/* See if we have to split this node (both successors red). */
|
||||
if (mode == 1
|
||||
|| ((*rp) != NULL && (*lp) != NULL && (*rp)->red && (*lp)->red))
|
||||
{
|
||||
/* This node becomes red, its successors black. */
|
||||
root->red = 1;
|
||||
if (*rp)
|
||||
(*rp)->red = 0;
|
||||
if (*lp)
|
||||
(*lp)->red = 0;
|
||||
|
||||
/* If the parent of this node is also red, we have to do
|
||||
rotations. */
|
||||
if (parentp != NULL && (*parentp)->red)
|
||||
{
|
||||
node gp = *gparentp;
|
||||
node p = *parentp;
|
||||
/* There are two main cases:
|
||||
1. The edge types (left or right) of the two red edges differ.
|
||||
2. Both red edges are of the same type.
|
||||
There exist two symmetries of each case, so there is a total of
|
||||
4 cases. */
|
||||
if ((p_r > 0) != (gp_r > 0))
|
||||
{
|
||||
/* Put the child at the top of the tree, with its parent
|
||||
and grandparent as successors. */
|
||||
p->red = 1;
|
||||
gp->red = 1;
|
||||
root->red = 0;
|
||||
if (p_r < 0)
|
||||
{
|
||||
/* Child is left of parent. */
|
||||
p->left = *rp;
|
||||
*rp = p;
|
||||
gp->right = *lp;
|
||||
*lp = gp;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Child is right of parent. */
|
||||
p->right = *lp;
|
||||
*lp = p;
|
||||
gp->left = *rp;
|
||||
*rp = gp;
|
||||
}
|
||||
*gparentp = root;
|
||||
}
|
||||
else
|
||||
{
|
||||
*gparentp = *parentp;
|
||||
/* Parent becomes the top of the tree, grandparent and
|
||||
child are its successors. */
|
||||
p->red = 0;
|
||||
gp->red = 1;
|
||||
if (p_r < 0)
|
||||
{
|
||||
/* Left edges. */
|
||||
gp->left = p->right;
|
||||
p->right = gp;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Right edges. */
|
||||
gp->right = p->left;
|
||||
p->left = gp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Find or insert datum into search tree.
|
||||
KEY is the key to be located, ROOTP is the address of tree root,
|
||||
COMPAR the ordering function. */
|
||||
void *
|
||||
__tsearch (const void *key, void **vrootp, __compar_fn_t compar)
|
||||
{
|
||||
node q;
|
||||
node *parentp = NULL, *gparentp = NULL;
|
||||
node *rootp = (node *) vrootp;
|
||||
node *nextp;
|
||||
int r = 0, p_r = 0, gp_r = 0; /* No they might not, Mr Compiler. */
|
||||
|
||||
if (rootp == NULL)
|
||||
return NULL;
|
||||
|
||||
/* This saves some additional tests below. */
|
||||
if (*rootp != NULL)
|
||||
(*rootp)->red = 0;
|
||||
|
||||
CHECK_TREE (*rootp);
|
||||
|
||||
nextp = rootp;
|
||||
while (*nextp != NULL)
|
||||
{
|
||||
node root = *rootp;
|
||||
r = (*compar) (key, root->key);
|
||||
if (r == 0)
|
||||
return root;
|
||||
|
||||
maybe_split_for_insert (rootp, parentp, gparentp, p_r, gp_r, 0);
|
||||
/* If that did any rotations, parentp and gparentp are now garbage.
|
||||
That doesn't matter, because the values they contain are never
|
||||
used again in that case. */
|
||||
|
||||
nextp = r < 0 ? &root->left : &root->right;
|
||||
if (*nextp == NULL)
|
||||
break;
|
||||
|
||||
gparentp = parentp;
|
||||
parentp = rootp;
|
||||
rootp = nextp;
|
||||
|
||||
gp_r = p_r;
|
||||
p_r = r;
|
||||
}
|
||||
|
||||
q = (struct node_t *) malloc (sizeof (struct node_t));
|
||||
if (q != NULL)
|
||||
{
|
||||
*nextp = q; /* link new node to old */
|
||||
q->key = key; /* initialize new node */
|
||||
q->red = 1;
|
||||
q->left = q->right = NULL;
|
||||
}
|
||||
if (nextp != rootp)
|
||||
/* There may be two red edges in a row now, which we must avoid by
|
||||
rotating the tree. */
|
||||
maybe_split_for_insert (nextp, rootp, parentp, r, p_r, 1);
|
||||
|
||||
return q;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__tsearch, tsearch)
|
||||
#endif
|
||||
|
||||
|
||||
/* Find datum in search tree.
|
||||
KEY is the key to be located, ROOTP is the address of tree root,
|
||||
COMPAR the ordering function. */
|
||||
void *
|
||||
__tfind (key, vrootp, compar)
|
||||
const void *key;
|
||||
void *const *vrootp;
|
||||
__compar_fn_t compar;
|
||||
{
|
||||
node *rootp = (node *) vrootp;
|
||||
|
||||
if (rootp == NULL)
|
||||
return NULL;
|
||||
|
||||
CHECK_TREE (*rootp);
|
||||
|
||||
while (*rootp != NULL)
|
||||
{
|
||||
node root = *rootp;
|
||||
int r;
|
||||
|
||||
r = (*compar) (key, root->key);
|
||||
if (r == 0)
|
||||
return root;
|
||||
|
||||
rootp = r < 0 ? &root->left : &root->right;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__tfind, tfind)
|
||||
#endif
|
||||
|
||||
|
||||
/* Delete node with given key.
|
||||
KEY is the key to be deleted, ROOTP is the address of the root of tree,
|
||||
COMPAR the comparison function. */
|
||||
void *
|
||||
__tdelete (const void *key, void **vrootp, __compar_fn_t compar)
|
||||
{
|
||||
node p, q, r, retval;
|
||||
int cmp;
|
||||
node *rootp = (node *) vrootp;
|
||||
node root, unchained;
|
||||
/* Stack of nodes so we remember the parents without recursion. It's
|
||||
_very_ unlikely that there are paths longer than 40 nodes. The tree
|
||||
would need to have around 250.000 nodes. */
|
||||
int stacksize = 40;
|
||||
int sp = 0;
|
||||
node **nodestack = (node **) alloca (sizeof (node *) * stacksize);
|
||||
|
||||
if (rootp == NULL)
|
||||
return NULL;
|
||||
p = *rootp;
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
CHECK_TREE (p);
|
||||
|
||||
while ((cmp = (*compar) (key, (*rootp)->key)) != 0)
|
||||
{
|
||||
if (sp == stacksize)
|
||||
{
|
||||
node **newstack;
|
||||
stacksize += 20;
|
||||
newstack = (node **) alloca (sizeof (node *) * stacksize);
|
||||
nodestack = memcpy (newstack, nodestack, sp * sizeof (node *));
|
||||
}
|
||||
|
||||
nodestack[sp++] = rootp;
|
||||
p = *rootp;
|
||||
rootp = ((cmp < 0)
|
||||
? &(*rootp)->left
|
||||
: &(*rootp)->right);
|
||||
if (*rootp == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This is bogus if the node to be deleted is the root... this routine
|
||||
really should return an integer with 0 for success, -1 for failure
|
||||
and errno = ESRCH or something. */
|
||||
retval = p;
|
||||
|
||||
/* We don't unchain the node we want to delete. Instead, we overwrite
|
||||
it with its successor and unchain the successor. If there is no
|
||||
successor, we really unchain the node to be deleted. */
|
||||
|
||||
root = *rootp;
|
||||
|
||||
r = root->right;
|
||||
q = root->left;
|
||||
|
||||
if (q == NULL || r == NULL)
|
||||
unchained = root;
|
||||
else
|
||||
{
|
||||
node *parent = rootp, *up = &root->right;
|
||||
for (;;)
|
||||
{
|
||||
if (sp == stacksize)
|
||||
{
|
||||
node **newstack;
|
||||
stacksize += 20;
|
||||
newstack = (node **) alloca (sizeof (node *) * stacksize);
|
||||
nodestack = memcpy (newstack, nodestack, sp * sizeof (node *));
|
||||
}
|
||||
nodestack[sp++] = parent;
|
||||
parent = up;
|
||||
if ((*up)->left == NULL)
|
||||
break;
|
||||
up = &(*up)->left;
|
||||
}
|
||||
unchained = *up;
|
||||
}
|
||||
|
||||
/* We know that either the left or right successor of UNCHAINED is NULL.
|
||||
R becomes the other one, it is chained into the parent of UNCHAINED. */
|
||||
r = unchained->left;
|
||||
if (r == NULL)
|
||||
r = unchained->right;
|
||||
if (sp == 0)
|
||||
*rootp = r;
|
||||
else
|
||||
{
|
||||
q = *nodestack[sp-1];
|
||||
if (unchained == q->right)
|
||||
q->right = r;
|
||||
else
|
||||
q->left = r;
|
||||
}
|
||||
|
||||
if (unchained != root)
|
||||
root->key = unchained->key;
|
||||
if (!unchained->red)
|
||||
{
|
||||
/* Now we lost a black edge, which means that the number of black
|
||||
edges on every path is no longer constant. We must balance the
|
||||
tree. */
|
||||
/* NODESTACK now contains all parents of R. R is likely to be NULL
|
||||
in the first iteration. */
|
||||
/* NULL nodes are considered black throughout - this is necessary for
|
||||
correctness. */
|
||||
while (sp > 0 && (r == NULL || !r->red))
|
||||
{
|
||||
node *pp = nodestack[sp - 1];
|
||||
p = *pp;
|
||||
/* Two symmetric cases. */
|
||||
if (r == p->left)
|
||||
{
|
||||
/* Q is R's brother, P is R's parent. The subtree with root
|
||||
R has one black edge less than the subtree with root Q. */
|
||||
q = p->right;
|
||||
if (q != NULL && q->red)
|
||||
{
|
||||
/* If Q is red, we know that P is black. We rotate P left
|
||||
so that Q becomes the top node in the tree, with P below
|
||||
it. P is colored red, Q is colored black.
|
||||
This action does not change the black edge count for any
|
||||
leaf in the tree, but we will be able to recognize one
|
||||
of the following situations, which all require that Q
|
||||
is black. */
|
||||
q->red = 0;
|
||||
p->red = 1;
|
||||
/* Left rotate p. */
|
||||
p->right = q->left;
|
||||
q->left = p;
|
||||
*pp = q;
|
||||
/* Make sure pp is right if the case below tries to use
|
||||
it. */
|
||||
nodestack[sp++] = pp = &q->left;
|
||||
q = p->right;
|
||||
}
|
||||
/* We know that Q can't be NULL here. We also know that Q is
|
||||
black. */
|
||||
if ((q->left == NULL || !q->left->red)
|
||||
&& (q->right == NULL || !q->right->red))
|
||||
{
|
||||
/* Q has two black successors. We can simply color Q red.
|
||||
The whole subtree with root P is now missing one black
|
||||
edge. Note that this action can temporarily make the
|
||||
tree invalid (if P is red). But we will exit the loop
|
||||
in that case and set P black, which both makes the tree
|
||||
valid and also makes the black edge count come out
|
||||
right. If P is black, we are at least one step closer
|
||||
to the root and we'll try again the next iteration. */
|
||||
q->red = 1;
|
||||
r = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Q is black, one of Q's successors is red. We can
|
||||
repair the tree with one operation and will exit the
|
||||
loop afterwards. */
|
||||
if (q->right == NULL || !q->right->red)
|
||||
{
|
||||
/* The left one is red. We perform the same action as
|
||||
in maybe_split_for_insert where two red edges are
|
||||
adjacent but point in different directions:
|
||||
Q's left successor (let's call it Q2) becomes the
|
||||
top of the subtree we are looking at, its parent (Q)
|
||||
and grandparent (P) become its successors. The former
|
||||
successors of Q2 are placed below P and Q.
|
||||
P becomes black, and Q2 gets the color that P had.
|
||||
This changes the black edge count only for node R and
|
||||
its successors. */
|
||||
node q2 = q->left;
|
||||
q2->red = p->red;
|
||||
p->right = q2->left;
|
||||
q->left = q2->right;
|
||||
q2->right = q;
|
||||
q2->left = p;
|
||||
*pp = q2;
|
||||
p->red = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* It's the right one. Rotate P left. P becomes black,
|
||||
and Q gets the color that P had. Q's right successor
|
||||
also becomes black. This changes the black edge
|
||||
count only for node R and its successors. */
|
||||
q->red = p->red;
|
||||
p->red = 0;
|
||||
|
||||
q->right->red = 0;
|
||||
|
||||
/* left rotate p */
|
||||
p->right = q->left;
|
||||
q->left = p;
|
||||
*pp = q;
|
||||
}
|
||||
|
||||
/* We're done. */
|
||||
sp = 1;
|
||||
r = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Comments: see above. */
|
||||
q = p->left;
|
||||
if (q != NULL && q->red)
|
||||
{
|
||||
q->red = 0;
|
||||
p->red = 1;
|
||||
p->left = q->right;
|
||||
q->right = p;
|
||||
*pp = q;
|
||||
nodestack[sp++] = pp = &q->right;
|
||||
q = p->left;
|
||||
}
|
||||
if ((q->right == NULL || !q->right->red)
|
||||
&& (q->left == NULL || !q->left->red))
|
||||
{
|
||||
q->red = 1;
|
||||
r = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (q->left == NULL || !q->left->red)
|
||||
{
|
||||
node q2 = q->right;
|
||||
q2->red = p->red;
|
||||
p->left = q2->right;
|
||||
q->right = q2->left;
|
||||
q2->left = q;
|
||||
q2->right = p;
|
||||
*pp = q2;
|
||||
p->red = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
q->red = p->red;
|
||||
p->red = 0;
|
||||
q->left->red = 0;
|
||||
p->left = q->right;
|
||||
q->right = p;
|
||||
*pp = q;
|
||||
}
|
||||
sp = 1;
|
||||
r = NULL;
|
||||
}
|
||||
}
|
||||
--sp;
|
||||
}
|
||||
if (r != NULL)
|
||||
r->red = 0;
|
||||
}
|
||||
|
||||
free (unchained);
|
||||
return retval;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__tdelete, tdelete)
|
||||
#endif
|
||||
|
||||
|
||||
/* Walk the nodes of a tree.
|
||||
ROOT is the root of the tree to be walked, ACTION the function to be
|
||||
called at each node. LEVEL is the level of ROOT in the whole tree. */
|
||||
static void
|
||||
internal_function
|
||||
trecurse (const void *vroot, __action_fn_t action, int level)
|
||||
{
|
||||
const_node root = (const_node) vroot;
|
||||
|
||||
if (root->left == NULL && root->right == NULL)
|
||||
(*action) (root, leaf, level);
|
||||
else
|
||||
{
|
||||
(*action) (root, preorder, level);
|
||||
if (root->left != NULL)
|
||||
trecurse (root->left, action, level + 1);
|
||||
(*action) (root, postorder, level);
|
||||
if (root->right != NULL)
|
||||
trecurse (root->right, action, level + 1);
|
||||
(*action) (root, endorder, level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Walk the nodes of a tree.
|
||||
ROOT is the root of the tree to be walked, ACTION the function to be
|
||||
called at each node. */
|
||||
void
|
||||
__twalk (const void *vroot, __action_fn_t action)
|
||||
{
|
||||
const_node root = (const_node) vroot;
|
||||
|
||||
CHECK_TREE (root);
|
||||
|
||||
if (root != NULL && action != NULL)
|
||||
trecurse (root, action, 0);
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__twalk, twalk)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* The standardized functions miss an important functionality: the
|
||||
tree cannot be removed easily. We provide a function to do this. */
|
||||
static void
|
||||
internal_function
|
||||
tdestroy_recurse (node root, void (*freefct)(void *))
|
||||
{
|
||||
if (root->left != NULL)
|
||||
tdestroy_recurse (root->left, freefct);
|
||||
if (root->right != NULL)
|
||||
tdestroy_recurse (root->right, freefct);
|
||||
(*freefct) ((void *) root->key);
|
||||
/* Free the node itself. */
|
||||
free (root);
|
||||
}
|
||||
|
||||
void
|
||||
__tdestroy (void *vroot, void (*freefct)(void *))
|
||||
{
|
||||
node root = (node) vroot;
|
||||
|
||||
CHECK_TREE (root);
|
||||
|
||||
if (root != NULL)
|
||||
tdestroy_recurse (root, freefct);
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__tdestroy, tdestroy)
|
||||
#endif
|
||||
160
lib/u64.h
Normal file
160
lib/u64.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/* 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 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* 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
|
||||
@@ -1,5 +1,8 @@
|
||||
/* vsprintf with automatic memory allocation.
|
||||
Copyright (C) 1999, 2002-2006 Free Software Foundation, Inc.
|
||||
This file is intended to provide exactly the same functionality
|
||||
as the version in gnulib, but without the need for the xsize module.
|
||||
|
||||
Copyright (C) 1999, 2002-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
|
||||
@@ -23,7 +26,6 @@
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifndef IN_LIBINTL
|
||||
# include <alloca.h>
|
||||
#endif
|
||||
@@ -37,6 +39,7 @@
|
||||
|
||||
#include <stdio.h> /* snprintf(), sprintf() */
|
||||
#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
|
||||
#include <stdint.h> /* SIZE_MAX */
|
||||
#include <string.h> /* memcpy(), strlen() */
|
||||
#include <errno.h> /* errno */
|
||||
#include <limits.h> /* CHAR_BIT, INT_MAX */
|
||||
@@ -47,17 +50,8 @@
|
||||
# include "printf-parse.h"
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
|
||||
#ifndef EOVERFLOW
|
||||
# define EOVERFLOW E2BIG
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WCHAR_T
|
||||
# ifdef HAVE_WCSLEN
|
||||
#if HAVE_WCHAR_T
|
||||
# if HAVE_WCSLEN
|
||||
# define local_wcslen wcslen
|
||||
# else
|
||||
/* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
|
||||
@@ -152,7 +146,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
#if HAVE_ALLOCA
|
||||
if (buf_neededlength < 4000 / sizeof (CHAR_T))
|
||||
{
|
||||
buf = (CHAR_T *) alloca (buf_neededlength * sizeof (CHAR_T));
|
||||
buf = alloca (buf_neededlength * sizeof (CHAR_T));
|
||||
buf_malloced = NULL;
|
||||
}
|
||||
else
|
||||
@@ -254,7 +248,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
case TYPE_COUNT_LONGINT_POINTER:
|
||||
*a.arg[dp->arg_index].a.a_count_longint_pointer = length;
|
||||
break;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#if HAVE_LONG_LONG_INT
|
||||
case TYPE_COUNT_LONGLONGINT_POINTER:
|
||||
*a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
|
||||
break;
|
||||
@@ -338,7 +332,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
{
|
||||
|
||||
case 'd': case 'i': case 'u':
|
||||
# ifdef HAVE_LONG_LONG
|
||||
# if HAVE_LONG_LONG_INT
|
||||
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
|
||||
@@ -369,7 +363,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
# ifdef HAVE_LONG_LONG
|
||||
# if HAVE_LONG_LONG_INT
|
||||
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
|
||||
@@ -397,7 +391,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
break;
|
||||
|
||||
case 'x': case 'X':
|
||||
# ifdef HAVE_LONG_LONG
|
||||
# if HAVE_LONG_LONG_INT
|
||||
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
|
||||
@@ -421,12 +415,13 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
if (tmp_length < precision)
|
||||
tmp_length = precision;
|
||||
/* Add 2, to account for a leading sign or alternate form. */
|
||||
if (tmp_length <= SIZE_MAX / 2)
|
||||
tmp_length *= 2;
|
||||
tmp_length += 2;
|
||||
if (tmp_length < 2)
|
||||
goto out_of_memory;
|
||||
break;
|
||||
|
||||
case 'f': case 'F':
|
||||
# ifdef HAVE_LONG_DOUBLE
|
||||
# if HAVE_LONG_DOUBLE
|
||||
if (type == TYPE_LONGDOUBLE)
|
||||
tmp_length =
|
||||
(unsigned int) (LDBL_MAX_EXP
|
||||
@@ -450,7 +445,6 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
break;
|
||||
|
||||
case 'e': case 'E': case 'g': case 'G':
|
||||
case 'a': case 'A':
|
||||
tmp_length =
|
||||
12; /* sign, decimal point, exponent etc. */
|
||||
tmp_length += precision;
|
||||
@@ -458,8 +452,31 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
goto out_of_memory;
|
||||
break;
|
||||
|
||||
case 'a': case 'A':
|
||||
# if HAVE_LONG_DOUBLE
|
||||
if (type == TYPE_LONGDOUBLE)
|
||||
tmp_length =
|
||||
(unsigned int) (LDBL_DIG
|
||||
* 0.831 /* decimal -> hexadecimal */
|
||||
)
|
||||
+ 1; /* turn floor into ceil */
|
||||
else
|
||||
# endif
|
||||
tmp_length =
|
||||
(unsigned int) (DBL_DIG
|
||||
* 0.831 /* decimal -> hexadecimal */
|
||||
)
|
||||
+ 1; /* turn floor into ceil */
|
||||
if (tmp_length < precision)
|
||||
tmp_length = precision;
|
||||
/* Account for sign, decimal point etc. */
|
||||
tmp_length += 12;
|
||||
if (tmp_length < 12)
|
||||
goto out_of_memory;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
# if defined HAVE_WINT_T && !WIDE_CHAR_VERSION
|
||||
# if HAVE_WINT_T && !WIDE_CHAR_VERSION
|
||||
if (type == TYPE_WIDE_CHAR)
|
||||
tmp_length = MB_CUR_MAX;
|
||||
else
|
||||
@@ -468,7 +485,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
break;
|
||||
|
||||
case 's':
|
||||
# ifdef HAVE_WCHAR_T
|
||||
# if HAVE_WCHAR_T
|
||||
if (type == TYPE_WIDE_STRING)
|
||||
{
|
||||
tmp_length =
|
||||
@@ -551,7 +568,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
|
||||
switch (type)
|
||||
{
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#if HAVE_LONG_LONG_INT
|
||||
case TYPE_LONGLONGINT:
|
||||
case TYPE_ULONGLONGINT:
|
||||
*p++ = 'l';
|
||||
@@ -559,15 +576,15 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
#endif
|
||||
case TYPE_LONGINT:
|
||||
case TYPE_ULONGINT:
|
||||
#ifdef HAVE_WINT_T
|
||||
#if HAVE_WINT_T
|
||||
case TYPE_WIDE_CHAR:
|
||||
#endif
|
||||
#ifdef HAVE_WCHAR_T
|
||||
#if HAVE_WCHAR_T
|
||||
case TYPE_WIDE_STRING:
|
||||
#endif
|
||||
*p++ = 'l';
|
||||
break;
|
||||
#ifdef HAVE_LONG_DOUBLE
|
||||
#if HAVE_LONG_DOUBLE
|
||||
case TYPE_LONGDOUBLE:
|
||||
*p++ = 'L';
|
||||
break;
|
||||
@@ -705,7 +722,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
SNPRINTF_BUF (arg);
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#if HAVE_LONG_LONG_INT
|
||||
case TYPE_LONGLONGINT:
|
||||
{
|
||||
long long int arg = a.arg[dp->arg_index].a.a_longlongint;
|
||||
@@ -725,7 +742,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
SNPRINTF_BUF (arg);
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_LONG_DOUBLE
|
||||
#if HAVE_LONG_DOUBLE
|
||||
case TYPE_LONGDOUBLE:
|
||||
{
|
||||
long double arg = a.arg[dp->arg_index].a.a_longdouble;
|
||||
@@ -739,7 +756,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
SNPRINTF_BUF (arg);
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_WINT_T
|
||||
#if HAVE_WINT_T
|
||||
case TYPE_WIDE_CHAR:
|
||||
{
|
||||
wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
|
||||
@@ -753,7 +770,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
SNPRINTF_BUF (arg);
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_WCHAR_T
|
||||
#if HAVE_WCHAR_T
|
||||
case TYPE_WIDE_STRING:
|
||||
{
|
||||
const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* xfts.c -- a wrapper for fts_open
|
||||
|
||||
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003, 2005-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
|
||||
@@ -21,8 +21,8 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "exit.h"
|
||||
#include "error.h"
|
||||
|
||||
#include "gettext.h"
|
||||
|
||||
@@ -30,6 +30,7 @@ dirname.m4
|
||||
dos.m4
|
||||
double-slash-root.m4
|
||||
dup2.m4
|
||||
eaccess.m4
|
||||
eealloc.m4
|
||||
eoverflow.m4
|
||||
error.m4
|
||||
@@ -37,12 +38,15 @@ euidaccess.m4
|
||||
exclude.m4
|
||||
exitfail.m4
|
||||
extensions.m4
|
||||
fchdir.m4
|
||||
fcntl-safer.m4
|
||||
fcntl_h.m4
|
||||
file-type.m4
|
||||
fileblocks.m4
|
||||
filemode.m4
|
||||
filenamecat.m4
|
||||
findprog.m4
|
||||
flexmember.m4
|
||||
fnmatch.m4
|
||||
fpending.m4
|
||||
fprintftime.m4
|
||||
@@ -74,6 +78,7 @@ getusershell.m4
|
||||
glibc2.m4
|
||||
glibc21.m4
|
||||
gnulib-cache.m4
|
||||
gnulib-common.m4
|
||||
gnulib-comp.m4
|
||||
gnulib-tool.m4
|
||||
group-member.m4
|
||||
@@ -81,11 +86,15 @@ hard-locale.m4
|
||||
hash.m4
|
||||
host-os.m4
|
||||
human.m4
|
||||
i-ring.m4
|
||||
iconv.m4
|
||||
idcache.m4
|
||||
include_next.m4
|
||||
inet_ntop.m4
|
||||
inline.m4
|
||||
intdiv0.m4
|
||||
intl.m4
|
||||
intldir.m4
|
||||
intmax.m4
|
||||
intmax_t.m4
|
||||
inttostr.m4
|
||||
@@ -114,6 +123,7 @@ lstat.m4
|
||||
mbchar.m4
|
||||
mbiter.m4
|
||||
mbrtowc.m4
|
||||
mbscasecmp.m4
|
||||
mbstate_t.m4
|
||||
mbswidth.m4
|
||||
md5.m4
|
||||
@@ -133,6 +143,7 @@ mkstemp.m4
|
||||
mktime.m4
|
||||
modechange.m4
|
||||
mountlist.m4
|
||||
mpsort.m4
|
||||
nanosleep.m4
|
||||
netinet_in_h.m4
|
||||
nls.m4
|
||||
@@ -156,6 +167,7 @@ rename-dest-slash.m4
|
||||
rename.m4
|
||||
rmdir-errno.m4
|
||||
rmdir.m4
|
||||
root-dev-ino.m4
|
||||
rpmatch.m4
|
||||
safe-read.m4
|
||||
safe-write.m4
|
||||
@@ -181,12 +193,15 @@ stdbool.m4
|
||||
stdint.m4
|
||||
stdint_h.m4
|
||||
stdio-safer.m4
|
||||
stdio_h.m4
|
||||
stdlib-safer.m4
|
||||
stdlib_h.m4
|
||||
stpcpy.m4
|
||||
strcase.m4
|
||||
strcspn.m4
|
||||
strdup.m4
|
||||
strftime.m4
|
||||
string_h.m4
|
||||
strndup.m4
|
||||
strnlen.m4
|
||||
strpbrk.m4
|
||||
@@ -200,6 +215,9 @@ strtoumax.m4
|
||||
strverscmp.m4
|
||||
sys_socket_h.m4
|
||||
sys_stat_h.m4
|
||||
sys_time_h.m4
|
||||
tempname.m4
|
||||
time_h.m4
|
||||
time_r.m4
|
||||
timespec.m4
|
||||
tm_gmtoff.m4
|
||||
@@ -223,7 +241,9 @@ utimes.m4
|
||||
vasnprintf.m4
|
||||
vasprintf.m4
|
||||
visibility.m4
|
||||
wchar.m4
|
||||
wchar_t.m4
|
||||
wctype.m4
|
||||
wcwidth.m4
|
||||
wint_t.m4
|
||||
xalloc.m4
|
||||
|
||||
245
m4/.gitignore
vendored
Normal file
245
m4/.gitignore
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
absolute-header.m4
|
||||
acl.m4
|
||||
alloca.m4
|
||||
allocsa.m4
|
||||
argmatch.m4
|
||||
arpa_inet_h.m4
|
||||
assert.m4
|
||||
atexit.m4
|
||||
backupfile.m4
|
||||
base64.m4
|
||||
bison.m4
|
||||
c-strtod.m4
|
||||
calloc.m4
|
||||
canon-host.m4
|
||||
canonicalize.m4
|
||||
chdir-long.m4
|
||||
chown.m4
|
||||
clock_time.m4
|
||||
cloexec.m4
|
||||
close-stream.m4
|
||||
closeout.m4
|
||||
codeset.m4
|
||||
config-h.m4
|
||||
cycle-check.m4
|
||||
d-ino.m4
|
||||
d-type.m4
|
||||
dirfd.m4
|
||||
dirname.m4
|
||||
dos.m4
|
||||
double-slash-root.m4
|
||||
dup2.m4
|
||||
eaccess.m4
|
||||
eealloc.m4
|
||||
eoverflow.m4
|
||||
error.m4
|
||||
euidaccess.m4
|
||||
exclude.m4
|
||||
exitfail.m4
|
||||
extensions.m4
|
||||
fchdir.m4
|
||||
fcntl-safer.m4
|
||||
fcntl_h.m4
|
||||
file-type.m4
|
||||
fileblocks.m4
|
||||
filemode.m4
|
||||
filenamecat.m4
|
||||
findprog.m4
|
||||
flexmember.m4
|
||||
fnmatch.m4
|
||||
fpending.m4
|
||||
fprintftime.m4
|
||||
free.m4
|
||||
fstypename.m4
|
||||
fsusage.m4
|
||||
ftruncate.m4
|
||||
fts.m4
|
||||
getaddrinfo.m4
|
||||
getcwd-abort-bug.m4
|
||||
getcwd-path-max.m4
|
||||
getcwd.m4
|
||||
getdate.m4
|
||||
getdelim.m4
|
||||
getgroups.m4
|
||||
gethostname.m4
|
||||
gethrxtime.m4
|
||||
getline.m4
|
||||
getloadavg.m4
|
||||
getndelim2.m4
|
||||
getopt.m4
|
||||
getpagesize.m4
|
||||
getpass.m4
|
||||
gettext.m4
|
||||
gettime.m4
|
||||
gettimeofday.m4
|
||||
getugroups.m4
|
||||
getusershell.m4
|
||||
glibc21.m4
|
||||
gnulib-cache.m4
|
||||
gnulib-common.m4
|
||||
gnulib-comp.m4
|
||||
gnulib-tool.m4
|
||||
group-member.m4
|
||||
hard-locale.m4
|
||||
hash.m4
|
||||
host-os.m4
|
||||
human.m4
|
||||
i-ring.m4
|
||||
iconv.m4
|
||||
idcache.m4
|
||||
inet_ntop.m4
|
||||
inline.m4
|
||||
intl.m4
|
||||
intldir.m4
|
||||
intmax.m4
|
||||
intmax_t.m4
|
||||
inttostr.m4
|
||||
inttypes-h.m4
|
||||
inttypes-pri.m4
|
||||
inttypes.m4
|
||||
inttypes_h.m4
|
||||
isapipe.m4
|
||||
jm-winsz1.m4
|
||||
jm-winsz2.m4
|
||||
lchmod.m4
|
||||
lchown.m4
|
||||
lib-ignore.m4
|
||||
lib-ld.m4
|
||||
lib-link.m4
|
||||
lib-prefix.m4
|
||||
link-follow.m4
|
||||
localcharset.m4
|
||||
long-options.m4
|
||||
longdouble.m4
|
||||
longlong.m4
|
||||
ls-mntd-fs.m4
|
||||
lstat.m4
|
||||
mbchar.m4
|
||||
mbiter.m4
|
||||
mbrtowc.m4
|
||||
mbscasecmp.m4
|
||||
mbstate_t.m4
|
||||
mbswidth.m4
|
||||
md5.m4
|
||||
memcasecmp.m4
|
||||
memchr.m4
|
||||
memcmp.m4
|
||||
memcoll.m4
|
||||
memcpy.m4
|
||||
memmove.m4
|
||||
mempcpy.m4
|
||||
memrchr.m4
|
||||
memset.m4
|
||||
mkancesdirs.m4
|
||||
mkdir-p.m4
|
||||
mkdir-slash.m4
|
||||
mkstemp.m4
|
||||
mktime.m4
|
||||
modechange.m4
|
||||
mountlist.m4
|
||||
mpsort.m4
|
||||
nanosleep.m4
|
||||
netinet_in_h.m4
|
||||
nls.m4
|
||||
openat.m4
|
||||
pathmax.m4
|
||||
perl.m4
|
||||
physmem.m4
|
||||
po.m4
|
||||
posixtm.m4
|
||||
posixver.m4
|
||||
progtest.m4
|
||||
putenv.m4
|
||||
quote.m4
|
||||
quotearg.m4
|
||||
readlink.m4
|
||||
readtokens.m4
|
||||
readutmp.m4
|
||||
regex.m4
|
||||
rename-dest-slash.m4
|
||||
rename.m4
|
||||
rmdir-errno.m4
|
||||
rmdir.m4
|
||||
root-dev-ino.m4
|
||||
rpmatch.m4
|
||||
safe-read.m4
|
||||
safe-write.m4
|
||||
same.m4
|
||||
save-cwd.m4
|
||||
savedir.m4
|
||||
savewd.m4
|
||||
setenv.m4
|
||||
settime.m4
|
||||
sha1.m4
|
||||
sig2str.m4
|
||||
signed.m4
|
||||
snprintf.m4
|
||||
socklen.m4
|
||||
sockpfaf.m4
|
||||
ssize_t.m4
|
||||
st_dm_mode.m4
|
||||
stat-macros.m4
|
||||
stat-time.m4
|
||||
stdarg.m4
|
||||
stdbool.m4
|
||||
stdint.m4
|
||||
stdint_h.m4
|
||||
stdio-safer.m4
|
||||
stdio_h.m4
|
||||
stdlib-safer.m4
|
||||
stdlib_h.m4
|
||||
stpcpy.m4
|
||||
strcase.m4
|
||||
strcspn.m4
|
||||
strdup.m4
|
||||
strftime.m4
|
||||
string_h.m4
|
||||
strndup.m4
|
||||
strnlen.m4
|
||||
strpbrk.m4
|
||||
strtod.m4
|
||||
strtoimax.m4
|
||||
strtol.m4
|
||||
strtoll.m4
|
||||
strtoul.m4
|
||||
strtoull.m4
|
||||
strtoumax.m4
|
||||
strverscmp.m4
|
||||
sys_socket_h.m4
|
||||
sys_stat_h.m4
|
||||
sys_time_h.m4
|
||||
tempname.m4
|
||||
time_h.m4
|
||||
time_r.m4
|
||||
timespec.m4
|
||||
tm_gmtoff.m4
|
||||
tzset.m4
|
||||
unicodeio.m4
|
||||
unistd-safer.m4
|
||||
unistd_h.m4
|
||||
unlink-busy.m4
|
||||
unlinkdir.m4
|
||||
unlocked-io.m4
|
||||
uptime.m4
|
||||
userspec.m4
|
||||
utimbuf.m4
|
||||
utime.m4
|
||||
utimecmp.m4
|
||||
utimens.m4
|
||||
utimes-null.m4
|
||||
utimes.m4
|
||||
vasnprintf.m4
|
||||
vasprintf.m4
|
||||
wchar.m4
|
||||
wchar_t.m4
|
||||
wctype.m4
|
||||
wcwidth.m4
|
||||
wint_t.m4
|
||||
xalloc.m4
|
||||
xgetcwd.m4
|
||||
xnanosleep.m4
|
||||
xreadlink.m4
|
||||
xstrndup.m4
|
||||
xstrtod.m4
|
||||
xstrtol.m4
|
||||
yesno.m4
|
||||
37
m4/ChangeLog
37
m4/ChangeLog
@@ -1,3 +1,40 @@
|
||||
2007-01-19 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* .cvsignore, .gitignore: Add more bootstrap-inserted file names.
|
||||
|
||||
2006-12-12 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* jm-macros.m4: Remove AC_FUNC_SETVBUF_REVERSED, now that it's a no-op.
|
||||
|
||||
2006-10-14 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* sha512.m4 (gl_SHA512): Add u64.h to AC_LIBSOURCES.
|
||||
|
||||
2006-10-12 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* jm-macros.m4 (coreutils_MACROS): Rename from gl_MACROS, now that
|
||||
most of the gnulib macros have migrated into gnulib.
|
||||
Don't call gl_INIT here (now it's called from configure.ac, directly).
|
||||
|
||||
2006-10-07 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* jm-macros.m4 (gl_MACROS): Remove use of AC_CONFIG_LIBOBJ_DIR(lib).
|
||||
It is no longer needed, and was causing dependencies to appear
|
||||
in lib/lib/.deps, which provoked a "make distcheck" failure.
|
||||
|
||||
2006-09-29 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* readdir.m4: Remove file once again.
|
||||
* jm-macros.m4: Remove reference to gl_FUNC_READDIR.
|
||||
|
||||
2006-09-28 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* jm-macros.m4: Require the new macro.
|
||||
* readdir.m4 (gl_FUNC_READDIR): Rename from GL_FUNC_READDIR.
|
||||
Increment serial number.
|
||||
* readdir.m4: Revivify this file.
|
||||
We need it to work around a bug on Darwin 0.7.x.
|
||||
|
||||
2006-09-01 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* .cvsignore: Add fcntl_h.m4, getloadavg.m4, inttypes-h.m4,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 103 -*- autoconf -*-
|
||||
#serial 105 -*- autoconf -*-
|
||||
|
||||
dnl Misc type-related macros for coreutils.
|
||||
|
||||
@@ -21,10 +21,8 @@ dnl Misc type-related macros for coreutils.
|
||||
|
||||
# Written by Jim Meyering.
|
||||
|
||||
AC_DEFUN([gl_MACROS],
|
||||
AC_DEFUN([coreutils_MACROS],
|
||||
[
|
||||
gl_INIT
|
||||
|
||||
GNU_PACKAGE="GNU $PACKAGE"
|
||||
AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
|
||||
[The concatenation of the strings `GNU ', and PACKAGE.])
|
||||
@@ -46,17 +44,12 @@ AC_DEFUN([gl_MACROS],
|
||||
|
||||
AC_REQUIRE([AC_FUNC_FSEEKO])
|
||||
|
||||
AC_CONFIG_LIBOBJ_DIR([lib])
|
||||
|
||||
# By default, argmatch should fail calling usage (1).
|
||||
AC_DEFINE(ARGMATCH_DIE, [usage (1)],
|
||||
[Define to the function xargmatch calls on failures.])
|
||||
AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
|
||||
[Define to the declaration of the xargmatch failure function.])
|
||||
|
||||
dnl Used to define SETVBUF in ../src/system.h.
|
||||
AC_FUNC_SETVBUF_REVERSED
|
||||
|
||||
# used by ls
|
||||
AC_REQUIRE([gl_CLOCK_TIME])
|
||||
# used by shred
|
||||
@@ -66,6 +59,7 @@ AC_DEFUN([gl_MACROS],
|
||||
endgrent \
|
||||
endpwent \
|
||||
fchown \
|
||||
fchmod \
|
||||
ftruncate \
|
||||
iswspace \
|
||||
mkfifo \
|
||||
@@ -115,10 +109,6 @@ AC_DEFUN([gl_MACROS],
|
||||
if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
|
||||
DF_PROG='df$(EXEEXT)'
|
||||
fi
|
||||
|
||||
# If any of these functions don't exist (e.g. DJGPP 2.03),
|
||||
# use the corresponding stub.
|
||||
AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_CHECK_ALL_HEADERS],
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# sha512.m4 serial 1
|
||||
dnl Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
# 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])
|
||||
AC_LIBSOURCES([sha512.c, sha512.h, u64.h])
|
||||
AC_LIBOBJ([sha512])
|
||||
|
||||
dnl Prerequisites of lib/sha512.c.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Make coreutils man pages. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software
|
||||
# Foundation, Inc.
|
||||
# Copyright (C) 2002-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
|
||||
@@ -19,23 +18,26 @@
|
||||
# 02110-1301, USA.
|
||||
|
||||
dist_man_MANS = \
|
||||
base64.1 basename.1 cat.1 chgrp.1 chmod.1 chown.1 chroot.1 cksum.1 comm.1 \
|
||||
base64.1 basename.1 cat.1 chgrp.1 chmod.1 chown.1 cksum.1 comm.1 \
|
||||
cp.1 csplit.1 cut.1 date.1 dd.1 df.1 dir.1 dircolors.1 dirname.1 du.1 \
|
||||
echo.1 env.1 expand.1 expr.1 factor.1 false.1 fmt.1 fold.1 groups.1 \
|
||||
head.1 hostid.1 hostname.1 id.1 install.1 join.1 kill.1 \
|
||||
head.1 hostname.1 id.1 install.1 join.1 kill.1 \
|
||||
link.1 ln.1 logname.1 \
|
||||
ls.1 md5sum.1 mkdir.1 mkfifo.1 mknod.1 mv.1 nice.1 nl.1 nohup.1 od.1 \
|
||||
paste.1 pathchk.1 pinky.1 pr.1 printenv.1 printf.1 ptx.1 pwd.1 readlink.1 \
|
||||
ls.1 md5sum.1 mkdir.1 mkfifo.1 mknod.1 mv.1 nl.1 nohup.1 od.1 \
|
||||
paste.1 pathchk.1 pr.1 printenv.1 printf.1 ptx.1 pwd.1 readlink.1 \
|
||||
rm.1 rmdir.1 seq.1 sha1sum.1 sha224sum.1 sha256sum.1 sha384sum.1 sha512sum.1 \
|
||||
shred.1 shuf.1 sleep.1 sort.1 split.1 stat.1 stty.1 \
|
||||
shred.1 shuf.1 sleep.1 sort.1 split.1 stat.1 \
|
||||
su.1 sum.1 sync.1 tac.1 tail.1 tee.1 test.1 touch.1 tr.1 true.1 tsort.1 \
|
||||
tty.1 uname.1 unexpand.1 uniq.1 unlink.1 uptime.1 users.1 vdir.1 wc.1 \
|
||||
who.1 whoami.1 yes.1
|
||||
tty.1 unexpand.1 uniq.1 unlink.1 vdir.1 wc.1 \
|
||||
whoami.1 yes.1 $(MAN)
|
||||
optional_mans = \
|
||||
chroot.1 hostid.1 nice.1 pinky.1 stty.1 uname.1 uptime.1 users.1 who.1
|
||||
|
||||
man_aux = $(dist_man_MANS:.1=.x)
|
||||
|
||||
EXTRA_DIST = $(man_aux) help2man
|
||||
MAINTAINERCLEANFILES = $(man_MANS)
|
||||
man_aux = $(dist_man_MANS:.1=.x) $(optional_mans:.1=.x)
|
||||
|
||||
EXTRA_DIST = $(man_aux) help2man $(optional_mans)
|
||||
MAINTAINERCLEANFILES = $(dist_man_MANS)
|
||||
|
||||
# Depend on configure.ac to get version number changes.
|
||||
common_dep = $(top_srcdir)/configure.ac
|
||||
@@ -151,17 +153,26 @@ mapped_name = `echo $*|sed 's/install/ginstall/; s/test/[/'`
|
||||
# That is necessary to avoid failures for programs that are also shell built-in
|
||||
# functions like echo, false, printf, pwd.
|
||||
.x.1:
|
||||
@rm -f $@
|
||||
@echo "Updating man page $@"; \
|
||||
rm -rf $t; \
|
||||
mkdir $t; \
|
||||
(cd $t && $(LN_S) ../../src/$(mapped_name) $*); \
|
||||
$(PERL) -- $(srcdir)/help2man \
|
||||
--include=$(srcdir)/$*.x \
|
||||
--output=$t/$@ $t/$*
|
||||
@sed 's|$*\.td/||g' $t/$@ > $@
|
||||
@chmod a-w $@
|
||||
@rm -rf $t
|
||||
@case '$(PERL)' in \
|
||||
*"/missing "*) \
|
||||
echo 'WARNING: cannot update man page $@ since perl is missing' \
|
||||
'or inadequate' 1>&2 \
|
||||
;; \
|
||||
*) \
|
||||
rm -f $@ \
|
||||
&& { echo "Updating man page $@"; \
|
||||
rm -rf $t; \
|
||||
mkdir $t; \
|
||||
(cd $t && $(LN_S) ../../src/$(mapped_name) $*); \
|
||||
$(PERL) -- $(srcdir)/help2man \
|
||||
--source='$(PACKAGE_STRING)' \
|
||||
--include=$(srcdir)/$*.x \
|
||||
--output=$t/$@ $t/$*; \
|
||||
} \
|
||||
&& sed 's|$*\.td/||g' $t/$@ > $@ \
|
||||
&& chmod a-w $@ \
|
||||
&& rm -rf $t ;; \
|
||||
esac
|
||||
|
||||
check-local: check-x-vs-1 check-programs-vs-x
|
||||
|
||||
|
||||
17
po/.gitignore
vendored
Normal file
17
po/.gitignore
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
*.po
|
||||
LINGUAS
|
||||
Makefile.in
|
||||
Makefile.in.in
|
||||
Makevars
|
||||
Makevars.template
|
||||
POTFILES
|
||||
Rules-quot
|
||||
boldquot.sed
|
||||
coreutils.pot
|
||||
en@boldquot.header
|
||||
en@quot.header
|
||||
insert-header.sin
|
||||
quot.sed
|
||||
remove-potcdate.sed
|
||||
remove-potcdate.sin
|
||||
stamp-po
|
||||
@@ -1,3 +1,11 @@
|
||||
2006-10-19 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* POTFILES.in: Also include lib/regcomp.c, since it too uses gettext.
|
||||
|
||||
2006-10-19 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* POTFILES.in: Add lib/xstrtol.h.
|
||||
|
||||
2006-08-22 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* .cvsignore: More ../bootstrap-related fixes, plus remove old
|
||||
|
||||
@@ -16,15 +16,17 @@ lib/obstack.c
|
||||
lib/openat-die.c
|
||||
lib/quotearg.c
|
||||
lib/randread.c
|
||||
lib/regcomp.c
|
||||
lib/root-dev-ino.h
|
||||
lib/rpmatch.c
|
||||
lib/unicodeio.c
|
||||
lib/userspec.c
|
||||
lib/version-etc.c
|
||||
lib/xalloc-die.c
|
||||
lib/xmemxfrm.c
|
||||
lib/xfts.c
|
||||
lib/xmemcoll.c
|
||||
lib/xmemxfrm.c
|
||||
lib/xstrtol.h
|
||||
|
||||
# Package source files
|
||||
|
||||
|
||||
102
src/.gitignore
vendored
Normal file
102
src/.gitignore
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
\[
|
||||
base64
|
||||
basename
|
||||
cat
|
||||
chgrp
|
||||
chmod
|
||||
chown
|
||||
chroot
|
||||
cksum
|
||||
comm
|
||||
cp
|
||||
csplit
|
||||
cut
|
||||
date
|
||||
dd
|
||||
df
|
||||
dir
|
||||
dircolors
|
||||
dircolors.h
|
||||
dirname
|
||||
du
|
||||
echo
|
||||
env
|
||||
expand
|
||||
expr
|
||||
factor
|
||||
false
|
||||
fmt
|
||||
fold
|
||||
fs.h
|
||||
ginstall
|
||||
groups
|
||||
head
|
||||
hostid
|
||||
hostname
|
||||
id
|
||||
join
|
||||
kill
|
||||
link
|
||||
ln
|
||||
localedir.h
|
||||
logname
|
||||
ls
|
||||
md5sum
|
||||
mkdir
|
||||
mkfifo
|
||||
mknod
|
||||
mv
|
||||
nice
|
||||
nl
|
||||
nohup
|
||||
od
|
||||
paste
|
||||
pathchk
|
||||
pinky
|
||||
pr
|
||||
printenv
|
||||
printf
|
||||
ptx
|
||||
pwd
|
||||
readlink
|
||||
rm
|
||||
rmdir
|
||||
seq
|
||||
setuidgid
|
||||
sha1sum
|
||||
sha224sum
|
||||
sha256sum
|
||||
sha384sum
|
||||
sha512sum
|
||||
shred
|
||||
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
|
||||
wheel-size.h
|
||||
wheel.h
|
||||
who
|
||||
whoami
|
||||
yes
|
||||
shuf
|
||||
@@ -1,7 +1,6 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
|
||||
## Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
## 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
## Copyright (C) 1990, 1991, 1993-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
|
||||
@@ -105,9 +104,9 @@ uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
|
||||
|
||||
su_LDADD = $(LDADD) $(LIB_CRYPT)
|
||||
|
||||
dir_LDADD += $(LIB_ACL)
|
||||
ls_LDADD += $(LIB_ACL)
|
||||
vdir_LDADD += $(LIB_ACL)
|
||||
dir_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL)
|
||||
ls_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL)
|
||||
vdir_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL)
|
||||
cp_LDADD += $(LIB_ACL)
|
||||
mv_LDADD += $(LIB_ACL)
|
||||
ginstall_LDADD += $(LIB_ACL)
|
||||
@@ -116,10 +115,16 @@ $(PROGRAMS): ../lib/libcoreutils.a
|
||||
|
||||
SUFFIXES = .sh
|
||||
|
||||
# Get the release year from ../lib/version-etc.c.
|
||||
RELEASE_YEAR = \
|
||||
`sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
|
||||
$(top_srcdir)/lib/version-etc.c`
|
||||
|
||||
.sh:
|
||||
rm -f $@ $@-t
|
||||
sed \
|
||||
-e 's!@''bindir''@!$(bindir)!' \
|
||||
-e 's/@''RELEASE_YEAR'@/$(RELEASE_YEAR)/ \
|
||||
-e 's/@''GNU_PACKAGE''@/$(GNU_PACKAGE)/' \
|
||||
-e 's/@''PACKAGE_BUGREPORT''@/$(PACKAGE_BUGREPORT)/' \
|
||||
-e 's/@''VERSION''@/$(VERSION)/' $< > $@-t
|
||||
|
||||
34
src/base64.c
34
src/base64.c
@@ -1,5 +1,5 @@
|
||||
/* Base64 encode/decode strings or files.
|
||||
Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Base64.
|
||||
|
||||
@@ -83,9 +83,10 @@ With no FILE, or when FILE is -, read standard input.\n"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
The data are encoded as described for the base64 alphabet in RFC 3548.\n\
|
||||
Decoding require compliant input by default, use --ignore-garbage to\n\
|
||||
attempt to recover from non-alphabet characters (such as newlines) in\n\
|
||||
the encoded stream.\n"), stdout);
|
||||
When decoding, the input may contain newlines in addition to the bytes of\n\
|
||||
the formal base64 alphabet. Use --ignore-garbage to attempt to recover\n\
|
||||
from any other non-alphabet bytes in the encoded stream.\n"),
|
||||
stdout);
|
||||
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
|
||||
}
|
||||
|
||||
@@ -183,11 +184,15 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage)
|
||||
char inbuf[B64BLOCKSIZE];
|
||||
char outbuf[BLOCKSIZE];
|
||||
size_t sum;
|
||||
struct base64_decode_context ctx;
|
||||
|
||||
base64_decode_ctx_init (&ctx);
|
||||
|
||||
do
|
||||
{
|
||||
bool ok;
|
||||
size_t n;
|
||||
unsigned int k;
|
||||
|
||||
sum = 0;
|
||||
do
|
||||
@@ -211,14 +216,23 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage)
|
||||
}
|
||||
while (sum < B64BLOCKSIZE && !feof (in));
|
||||
|
||||
n = BLOCKSIZE;
|
||||
ok = base64_decode (inbuf, sum, outbuf, &n);
|
||||
/* The following "loop" is usually iterated just once.
|
||||
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++)
|
||||
{
|
||||
if (k == 1 && ctx.i == 0)
|
||||
break;
|
||||
n = BLOCKSIZE;
|
||||
ok = base64_decode (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);
|
||||
|
||||
if (fwrite (outbuf, 1, n, out) < n)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
if (fwrite (outbuf, 1, n, out) < n)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
if (!ok)
|
||||
error (EXIT_FAILURE, 0, _("invalid input"));
|
||||
if (!ok)
|
||||
error (EXIT_FAILURE, 0, _("invalid input"));
|
||||
}
|
||||
}
|
||||
while (!feof (in));
|
||||
}
|
||||
|
||||
@@ -2,131 +2,117 @@ Index: src/remove.c
|
||||
===================================================================
|
||||
RCS file: /fetish/cu/src/remove.c,v
|
||||
retrieving revision 1.158
|
||||
diff -u -p -u -r1.158 remove.c
|
||||
--- src/remove.c 3 Sep 2006 02:54:51 -0000 1.158
|
||||
+++ src/remove.c 6 Sep 2006 18:57:46 -0000
|
||||
@@ -238,9 +238,10 @@ pop_dir (Dirstack_state *ds)
|
||||
diff --git a/src/remove.c b/src/remove.c
|
||||
index 4728bdd..7477da5 100644
|
||||
--- a/src/remove.c
|
||||
+++ b/src/remove.c
|
||||
@@ -236,9 +236,10 @@ pop_dir (Dirstack_state *ds)
|
||||
{
|
||||
size_t n_lengths = obstack_object_size (&ds->len_stack) / sizeof (size_t);
|
||||
size_t *length = obstack_base (&ds->len_stack);
|
||||
+ size_t top_len;
|
||||
|
||||
|
||||
assert (n_lengths > 0);
|
||||
- size_t top_len = length[n_lengths - 1];
|
||||
+ top_len = length[n_lengths - 1];
|
||||
assert (top_len >= 2);
|
||||
|
||||
|
||||
/* Pop the specified length of file name. */
|
||||
@@ -372,10 +373,11 @@ AD_stack_top (Dirstack_state const *ds)
|
||||
@@ -370,10 +371,11 @@ AD_stack_top (Dirstack_state const *ds)
|
||||
static void
|
||||
AD_stack_pop (Dirstack_state *ds)
|
||||
{
|
||||
+ struct AD_ent *top;
|
||||
assert (0 < AD_stack_height (ds));
|
||||
|
||||
|
||||
/* operate on Active_dir. pop and free top entry */
|
||||
- struct AD_ent *top = AD_stack_top (ds);
|
||||
+ top = AD_stack_top (ds);
|
||||
if (top->unremovable)
|
||||
hash_free (top->unremovable);
|
||||
obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent));
|
||||
@@ -542,6 +544,7 @@ AD_mark_helper (Hash_table **ht, char *f
|
||||
if (*ht == NULL)
|
||||
xalloc_die ();
|
||||
}
|
||||
+ {
|
||||
void *ent = hash_insert (*ht, filename);
|
||||
if (ent == NULL)
|
||||
xalloc_die ();
|
||||
@@ -550,7 +553,7 @@ AD_mark_helper (Hash_table **ht, char *f
|
||||
if (ent != filename)
|
||||
free (filename);
|
||||
}
|
||||
-
|
||||
+ }
|
||||
}
|
||||
|
||||
/* Mark FILENAME (in current directory) as unremovable. */
|
||||
@@ -1090,6 +1093,7 @@ fd_to_subdirp (int fd_cwd, char const *f
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+ {
|
||||
DIR *subdir_dirp = fdopendir (fd_sub);
|
||||
if (subdir_dirp == NULL)
|
||||
@@ -815,6 +817,7 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
|
||||
|
||||
if (write_protected || x->interactive == RMI_ALWAYS)
|
||||
{
|
||||
@@ -1098,6 +1102,7 @@ fd_to_subdirp (int fd_cwd, char const *f
|
||||
}
|
||||
|
||||
return subdir_dirp;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* Remove entries in the directory open on DIRP
|
||||
@@ -1334,9 +1339,10 @@ remove_dir (int fd_cwd, Dirstack_state *
|
||||
/* The name of the directory that we have just processed,
|
||||
nominally removing all of its contents. */
|
||||
char *empty_dir;
|
||||
+ int fd;
|
||||
|
||||
AD_pop_and_chdir (&dirp, ds, &empty_dir);
|
||||
- int fd = (dirp != NULL ? dirfd (dirp) : AT_FDCWD);
|
||||
+ fd = (dirp != NULL ? dirfd (dirp) : AT_FDCWD);
|
||||
assert (dirp != NULL || AD_stack_height (ds) == 1);
|
||||
|
||||
/* Try to remove EMPTY_DIR only if remove_cwd_entries succeeded. */
|
||||
@@ -1414,6 +1420,7 @@ rm_1 (Dirstack_state *ds, char const *fi
|
||||
+ char const *quoted_name = quote (full_filename (filename));
|
||||
if (write_protected <= 0
|
||||
&& cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0)
|
||||
{
|
||||
@@ -832,8 +835,6 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
|
||||
write_protected = EISDIR;
|
||||
}
|
||||
|
||||
- char const *quoted_name = quote (full_filename (filename));
|
||||
-
|
||||
if (0 < write_protected)
|
||||
{
|
||||
error (0, write_protected, _("cannot remove %s"), quoted_name);
|
||||
@@ -1487,6 +1488,7 @@ rm_1 (Dirstack_state *ds, char const *filename,
|
||||
return RM_ERROR;
|
||||
}
|
||||
|
||||
+ {
|
||||
struct stat st;
|
||||
cache_stat_init (&st);
|
||||
if (x->root_dev_ino)
|
||||
@@ -1435,6 +1442,7 @@ rm_1 (Dirstack_state *ds, char const *fi
|
||||
cycle_check_init (&ds->cycle_check_state);
|
||||
@@ -1509,6 +1511,7 @@ rm_1 (Dirstack_state *ds, char const *filename,
|
||||
AD_push_initial (ds);
|
||||
AD_INIT_OTHER_MEMBERS ();
|
||||
|
||||
|
||||
+ {
|
||||
int fd_cwd = AT_FDCWD;
|
||||
enum RM_status status = remove_entry (fd_cwd, ds, filename, &st, x, NULL);
|
||||
enum RM_status status = remove_entry (AT_FDCWD, ds, filename, &st, x, NULL);
|
||||
if (status == RM_NONEMPTY_DIR)
|
||||
@@ -1453,6 +1461,8 @@ rm_1 (Dirstack_state *ds, char const *fi
|
||||
{
|
||||
@@ -1525,6 +1528,8 @@ rm_1 (Dirstack_state *ds, char const *filename,
|
||||
|
||||
ds_clear (ds);
|
||||
|
||||
return status;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
|
||||
/* Remove all files and/or directories specified by N_FILES and FILE.
|
||||
@@ -1475,9 +1485,11 @@ rm (size_t n_files, char const *const *f
|
||||
}
|
||||
|
||||
cycle_check_init (&ds->cycle_check_state);
|
||||
+ {
|
||||
enum RM_status s = rm_1 (ds, file[i], x, &cwd_errno);
|
||||
assert (VALID_STATUS (s));
|
||||
UPDATE_STATUS (status, s);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (x->require_restore_cwd && cwd_errno)
|
||||
Index: src/rm.c
|
||||
===================================================================
|
||||
RCS file: /fetish/cu/src/rm.c,v
|
||||
retrieving revision 1.140
|
||||
diff -u -p -u -r1.140 rm.c
|
||||
--- src/rm.c 3 Sep 2006 02:53:58 -0000 1.140
|
||||
+++ src/rm.c 6 Sep 2006 18:57:46 -0000
|
||||
@@ -357,8 +357,10 @@ main (int argc, char **argv)
|
||||
if (!yesno ())
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
+ {
|
||||
enum RM_status status = rm (n_files, file, &x);
|
||||
assert (VALID_STATUS (status));
|
||||
exit (status == RM_ERROR ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/rm.c b/src/rm.c
|
||||
index 364a21c..7a24014 100644
|
||||
--- a/src/rm.c
|
||||
+++ b/src/rm.c
|
||||
@@ -355,6 +355,7 @@ main (int argc, char **argv)
|
||||
quote ("/"));
|
||||
}
|
||||
|
||||
+ {
|
||||
size_t n_files = argc - optind;
|
||||
char const *const *file = (char const *const *) argv + optind;
|
||||
|
||||
@@ -368,7 +369,10 @@ main (int argc, char **argv)
|
||||
if (!yesno ())
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
+ {
|
||||
enum RM_status status = rm (n_files, file, &x);
|
||||
assert (VALID_STATUS (status));
|
||||
exit (status == RM_ERROR ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
Index: src/shred.c
|
||||
===================================================================
|
||||
RCS file: /fetish/cu/src/shred.c,v
|
||||
retrieving revision 1.130
|
||||
diff -u -p -r1.130 shred.c
|
||||
--- a/src/shred.c 3 Sep 2006 02:53:16 -0000 1.130
|
||||
+++ b/src/shred.c 3 Oct 2006 13:48:24 -0000
|
||||
@@ -464,7 +464,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. */
|
||||
- verify (sizeof r % SECTOR_SIZE == 0);
|
||||
+ { verify (sizeof r % SECTOR_SIZE == 0); }
|
||||
if (errnum == EIO && 0 <= size && (soff | SECTOR_MASK) < lim)
|
||||
{
|
||||
size_t soff1 = (soff | SECTOR_MASK) + 1;
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
char *program_name;
|
||||
|
||||
/* Name of input file. May be "-". */
|
||||
static char *infile;
|
||||
static char const *infile;
|
||||
|
||||
/* Descriptor on which input file is open. */
|
||||
static int input_desc;
|
||||
|
||||
15
src/chgrp.c
15
src/chgrp.c
@@ -28,7 +28,6 @@
|
||||
#include "error.h"
|
||||
#include "fts_.h"
|
||||
#include "group-member.h"
|
||||
#include "lchown.h"
|
||||
#include "quote.h"
|
||||
#include "root-dev-ino.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -120,8 +119,8 @@ Change the group of each FILE to GROUP.\n\
|
||||
With --reference, change the group of each FILE to that of RFILE.\n\
|
||||
\n\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
--dereference affect the referent of each symbolic link, rather\n\
|
||||
than the symbolic link itself (this is the default)\n\
|
||||
--dereference affect the referent of each symbolic link (this is\n\
|
||||
the default), rather than the symbolic link itself\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-h, --no-dereference affect each symbolic link instead of any referenced\n\
|
||||
@@ -261,20 +260,14 @@ main (int argc, char **argv)
|
||||
if (dereference == 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
chopt.affect_symlink_referent = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dereference == 0)
|
||||
error (EXIT_FAILURE, 0, _("-R -h requires -P"));
|
||||
chopt.affect_symlink_referent = true;
|
||||
dereference = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bit_flags = FTS_PHYSICAL;
|
||||
chopt.affect_symlink_referent = (dereference != 0);
|
||||
}
|
||||
chopt.affect_symlink_referent = (dereference != 0);
|
||||
|
||||
if (argc - optind < (reference_file ? 1 : 2))
|
||||
{
|
||||
|
||||
17
src/chmod.c
17
src/chmod.c
@@ -193,6 +193,19 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
return true;
|
||||
|
||||
case FTS_NS:
|
||||
/* For a top-level file or directory, this FTS_NS (stat failed)
|
||||
indicator is determined at the time of the initial fts_open call.
|
||||
With programs like chmod, chown, and chgrp, that modify
|
||||
permissions, it is possible that the file in question is
|
||||
accessible when control reaches this point. So, if this is
|
||||
the first time we've seen the FTS_NS for this file, tell
|
||||
fts_read to stat it "again". */
|
||||
if (ent->fts_level == 0 && ent->fts_number == 0)
|
||||
{
|
||||
ent->fts_number = 1;
|
||||
fts_set (fts, ent, FTS_AGAIN);
|
||||
return true;
|
||||
}
|
||||
error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
|
||||
ok = false;
|
||||
break;
|
||||
@@ -215,6 +228,10 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
if (ok && ROOT_DEV_INO_CHECK (root_dev_ino, file_stats))
|
||||
{
|
||||
ROOT_DEV_INO_WARN (file_full_name);
|
||||
/* Tell fts not to traverse into this hierarchy. */
|
||||
fts_set (fts, ent, FTS_SKIP);
|
||||
/* Ensure that we do not process "/" on the second visit. */
|
||||
ent = fts_read (fts);
|
||||
ok = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chown-core.c -- core functions for changing ownership.
|
||||
Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006 Free Software Foundation.
|
||||
Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -32,6 +32,12 @@
|
||||
#include "root-dev-ino.h"
|
||||
#include "xfts.h"
|
||||
|
||||
#define FTSENT_IS_DIRECTORY(E) \
|
||||
((E)->fts_info == FTS_D \
|
||||
|| (E)->fts_info == FTS_DC \
|
||||
|| (E)->fts_info == FTS_DP \
|
||||
|| (E)->fts_info == FTS_DNR)
|
||||
|
||||
enum RCH_status
|
||||
{
|
||||
/* we called fchown and close, and both succeeded */
|
||||
@@ -258,7 +264,20 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
{
|
||||
case FTS_D:
|
||||
if (chopt->recurse)
|
||||
return true;
|
||||
{
|
||||
if (ROOT_DEV_INO_CHECK (chopt->root_dev_ino, ent->fts_statp))
|
||||
{
|
||||
/* This happens e.g., with "chown -R --preserve-root 0 /"
|
||||
and with "chown -RH --preserve-root 0 symlink-to-root". */
|
||||
ROOT_DEV_INO_WARN (file_full_name);
|
||||
/* Tell fts not to traverse into this hierarchy. */
|
||||
fts_set (fts, ent, FTS_SKIP);
|
||||
/* Ensure that we do not process "/" on the second visit. */
|
||||
ent = fts_read (fts);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case FTS_DP:
|
||||
@@ -267,6 +286,19 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
break;
|
||||
|
||||
case FTS_NS:
|
||||
/* For a top-level file or directory, this FTS_NS (stat failed)
|
||||
indicator is determined at the time of the initial fts_open call.
|
||||
With programs like chmod, chown, and chgrp, that modify
|
||||
permissions, it is possible that the file in question is
|
||||
accessible when control reaches this point. So, if this is
|
||||
the first time we've seen the FTS_NS for this file, tell
|
||||
fts_read to stat it "again". */
|
||||
if (ent->fts_level == 0 && ent->fts_number == 0)
|
||||
{
|
||||
ent->fts_number = 1;
|
||||
fts_set (fts, ent, FTS_AGAIN);
|
||||
return true;
|
||||
}
|
||||
error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
|
||||
ok = false;
|
||||
break;
|
||||
@@ -292,7 +324,9 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
file_stats = NULL;
|
||||
}
|
||||
else if (required_uid == (uid_t) -1 && required_gid == (gid_t) -1
|
||||
&& chopt->verbosity == V_off && ! chopt->root_dev_ino)
|
||||
&& chopt->verbosity == V_off
|
||||
&& ! chopt->root_dev_ino
|
||||
&& ! chopt->affect_symlink_referent)
|
||||
{
|
||||
do_chown = true;
|
||||
file_stats = ent->fts_statp;
|
||||
@@ -303,9 +337,9 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
|
||||
/* If this is a symlink and we're dereferencing them,
|
||||
stat it to get info on the referent. */
|
||||
if (S_ISLNK (file_stats->st_mode) && chopt->affect_symlink_referent)
|
||||
if (chopt->affect_symlink_referent && S_ISLNK (file_stats->st_mode))
|
||||
{
|
||||
if (stat (file, &stat_buf) != 0)
|
||||
if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot dereference %s"),
|
||||
quote (file_full_name));
|
||||
@@ -322,10 +356,13 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
|| required_gid == file_stats->st_gid));
|
||||
}
|
||||
|
||||
if (do_chown && ROOT_DEV_INO_CHECK (chopt->root_dev_ino, file_stats))
|
||||
/* This happens when chown -LR --preserve-root encounters a symlink-to-/. */
|
||||
if (ok
|
||||
&& FTSENT_IS_DIRECTORY (ent)
|
||||
&& ROOT_DEV_INO_CHECK (chopt->root_dev_ino, file_stats))
|
||||
{
|
||||
ROOT_DEV_INO_WARN (file_full_name);
|
||||
ok = do_chown = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (do_chown)
|
||||
@@ -441,7 +478,8 @@ chown_files (char **files, int bit_flags,
|
||||
|
||||
/* Use lstat and stat only if they're needed. */
|
||||
int stat_flags = ((required_uid != (uid_t) -1 || required_gid != (gid_t) -1
|
||||
|| chopt->verbosity != V_off || chopt->root_dev_ino)
|
||||
|| chopt->affect_symlink_referent
|
||||
|| chopt->verbosity != V_off)
|
||||
? 0
|
||||
: FTS_NOSTAT);
|
||||
|
||||
|
||||
15
src/chown.c
15
src/chown.c
@@ -37,7 +37,6 @@
|
||||
#include "chown-core.h"
|
||||
#include "error.h"
|
||||
#include "fts_.h"
|
||||
#include "lchown.h"
|
||||
#include "quote.h"
|
||||
#include "root-dev-ino.h"
|
||||
#include "userspec.h"
|
||||
@@ -101,8 +100,8 @@ Change the owner and/or group of each FILE to OWNER and/or GROUP.\n\
|
||||
With --reference, change the owner and group of each FILE to those of RFILE.\n\
|
||||
\n\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
--dereference affect the referent of each symbolic link, rather\n\
|
||||
than the symbolic link itself (this is the default)\n\
|
||||
--dereference affect the referent of each symbolic link (this is\n\
|
||||
the default), rather than the symbolic link itself\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-h, --no-dereference affect each symbolic link instead of any referenced\n\
|
||||
@@ -274,20 +273,14 @@ main (int argc, char **argv)
|
||||
if (dereference == 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
chopt.affect_symlink_referent = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dereference == 0)
|
||||
error (EXIT_FAILURE, 0, _("-R -h requires -P"));
|
||||
chopt.affect_symlink_referent = true;
|
||||
dereference = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bit_flags = FTS_PHYSICAL;
|
||||
chopt.affect_symlink_referent = (dereference != 0);
|
||||
}
|
||||
chopt.affect_symlink_referent = (dereference != 0);
|
||||
|
||||
if (argc - optind < (reference_file ? 1 : 2))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cksum -- calculate and print POSIX checksums and sizes of files
|
||||
Copyright (C) 92, 1995-2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 1995-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
|
||||
@@ -42,12 +42,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include "system.h"
|
||||
|
||||
#if !defined UINT_FAST32_MAX && !defined uint_fast32_t
|
||||
# define uint_fast32_t unsigned int
|
||||
#endif
|
||||
|
||||
#ifdef CRCTAB
|
||||
|
||||
# define BIT(x) ((uint_fast32_t) 1 << (x))
|
||||
|
||||
384
src/copy.c
384
src/copy.c
@@ -1,5 +1,5 @@
|
||||
/* copy.c -- core functions for copying files and directories
|
||||
Copyright (C) 89, 90, 91, 1995-2006 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "euidaccess.h"
|
||||
#include "error.h"
|
||||
#include "fcntl--.h"
|
||||
#include "filemode.h"
|
||||
#include "filenamecat.h"
|
||||
#include "full-write.h"
|
||||
#include "getpagesize.h"
|
||||
@@ -175,22 +176,22 @@ copy_dir (char const *src_name_in, char const *dst_name_in, bool new_dst,
|
||||
st_gid fields of SRC_SB. If DEST_DESC is undefined (-1), set
|
||||
the owner and owning group of DST_NAME instead. DEST_DESC must
|
||||
refer to the same file as DEST_NAME if defined.
|
||||
Return true if the syscall succeeds, or if it's ok not to
|
||||
preserve ownership. */
|
||||
Return 1 if the syscall succeeds, 0 if it fails but it's OK
|
||||
not to preserve ownership, -1 otherwise. */
|
||||
|
||||
static bool
|
||||
static int
|
||||
set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
|
||||
uid_t uid, gid_t gid)
|
||||
{
|
||||
if (HAVE_FCHOWN && dest_desc != -1)
|
||||
{
|
||||
if (fchown (dest_desc, uid, gid) == 0)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chown (dst_name, uid, gid) == 0)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (! chown_failure_ok (x))
|
||||
@@ -198,10 +199,10 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
|
||||
error (0, errno, _("failed to preserve ownership for %s"),
|
||||
quote (dst_name));
|
||||
if (x->require_preserve)
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set the st_author field of DEST_DESC to the st_author field of
|
||||
@@ -230,11 +231,26 @@ set_author (const char *dst_name, int dest_desc, const struct stat *src_sb)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Change the file mode bits of the file identified by DESC or NAME to MODE.
|
||||
Use DESC if DESC is valid and fchmod is available, NAME otherwise. */
|
||||
|
||||
static int
|
||||
fchmod_or_lchmod (int desc, char const *name, mode_t mode)
|
||||
{
|
||||
#if HAVE_FCHMOD
|
||||
if (0 <= desc)
|
||||
return fchmod (desc, mode);
|
||||
#endif
|
||||
return lchmod (name, mode);
|
||||
}
|
||||
|
||||
/* Copy a regular file from SRC_NAME to DST_NAME.
|
||||
If the source file contains holes, copies holes and blocks of zeros
|
||||
in the source file as holes in the destination file.
|
||||
(Holes are read as zeroes by the `read' system call.)
|
||||
Use DST_MODE as the 3rd argument in the call to open.
|
||||
When creating the destination, use DST_MODE & ~OMITTED_PERMISSIONS
|
||||
as the third argument in the call to open, adding
|
||||
OMITTED_PERMISSIONS after copying as needed.
|
||||
X provides many option settings.
|
||||
Return true if successful.
|
||||
*NEW_DST is as in copy_internal.
|
||||
@@ -242,13 +258,15 @@ set_author (const char *dst_name, int dest_desc, const struct stat *src_sb)
|
||||
|
||||
static bool
|
||||
copy_reg (char const *src_name, char const *dst_name,
|
||||
const struct cp_options *x, mode_t dst_mode, bool *new_dst,
|
||||
const struct cp_options *x,
|
||||
mode_t dst_mode, mode_t omitted_permissions, bool *new_dst,
|
||||
struct stat const *src_sb)
|
||||
{
|
||||
char *buf;
|
||||
char *buf_alloc = NULL;
|
||||
int dest_desc;
|
||||
int source_desc;
|
||||
mode_t src_mode = src_sb->st_mode;
|
||||
struct stat sb;
|
||||
struct stat src_open_sb;
|
||||
bool return_val = true;
|
||||
@@ -260,7 +278,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fstat (source_desc, &src_open_sb))
|
||||
if (fstat (source_desc, &src_open_sb) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot fstat %s"), quote (src_name));
|
||||
return_val = false;
|
||||
@@ -278,15 +296,11 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
goto close_src_desc;
|
||||
}
|
||||
|
||||
/* These semantics are required for cp.
|
||||
The if-block will be taken in move_mode. */
|
||||
if (*new_dst)
|
||||
/* The semantics of the following open calls are mandated
|
||||
by the specs for both cp and mv. */
|
||||
if (! *new_dst)
|
||||
{
|
||||
dest_desc = open (dst_name, O_WRONLY | O_CREAT | O_BINARY, dst_mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
dest_desc = open (dst_name, O_WRONLY | O_TRUNC | O_BINARY, dst_mode);
|
||||
dest_desc = open (dst_name, O_WRONLY | O_TRUNC | O_BINARY);
|
||||
|
||||
if (dest_desc < 0 && x->unlink_dest_after_failed_open)
|
||||
{
|
||||
@@ -296,15 +310,20 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
return_val = false;
|
||||
goto close_src_desc;
|
||||
}
|
||||
if (x->verbose)
|
||||
printf (_("removed %s\n"), quote (dst_name));
|
||||
|
||||
/* Tell caller that the destination file was unlinked. */
|
||||
*new_dst = true;
|
||||
|
||||
/* Try the open again, but this time with different flags. */
|
||||
dest_desc = open (dst_name, O_WRONLY | O_CREAT | O_BINARY, dst_mode);
|
||||
}
|
||||
}
|
||||
|
||||
if (*new_dst)
|
||||
dest_desc = open (dst_name, O_WRONLY | O_CREAT | O_EXCL | O_BINARY,
|
||||
dst_mode & ~omitted_permissions);
|
||||
else
|
||||
omitted_permissions = 0;
|
||||
|
||||
if (dest_desc < 0)
|
||||
{
|
||||
error (0, errno, _("cannot create regular file %s"), quote (dst_name));
|
||||
@@ -312,7 +331,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
goto close_src_desc;
|
||||
}
|
||||
|
||||
if (fstat (dest_desc, &sb))
|
||||
if (fstat (dest_desc, &sb) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot fstat %s"), quote (dst_name));
|
||||
return_val = false;
|
||||
@@ -412,7 +431,17 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
{
|
||||
char *cp;
|
||||
|
||||
buf[n_read] = 1; /* Sentinel to stop loop. */
|
||||
/* Sentinel to stop loop. */
|
||||
buf[n_read] = '\1';
|
||||
#ifdef lint
|
||||
/* Usually, buf[n_read] is not the byte just before a "word"
|
||||
(aka uintptr_t) boundary. In that case, the word-oriented
|
||||
test below (*wp++ == 0) would read some uninitialized bytes
|
||||
after the sentinel. To avoid false-positive reports about
|
||||
this condition (e.g., from a tool like valgrind), set the
|
||||
remaining bytes -- to any value. */
|
||||
memset (buf + n_read + 1, 0, sizeof (word) - 1);
|
||||
#endif
|
||||
|
||||
/* Find first nonzero *word*, or the word with the sentinel. */
|
||||
|
||||
@@ -502,10 +531,16 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
|
||||
if (x->preserve_ownership && ! SAME_OWNER_AND_GROUP (*src_sb, sb))
|
||||
{
|
||||
if (! set_owner (x, dst_name, dest_desc, src_sb->st_uid, src_sb->st_gid))
|
||||
{
|
||||
switch (set_owner (x, dst_name, dest_desc,
|
||||
src_sb->st_uid, src_sb->st_gid))
|
||||
{
|
||||
case -1:
|
||||
return_val = false;
|
||||
goto close_src_and_dst_desc;
|
||||
|
||||
case 0:
|
||||
src_mode &= ~ (S_ISUID | S_ISGID | S_ISVTX);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,8 +548,8 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
|
||||
if (x->preserve_mode || x->move_mode)
|
||||
{
|
||||
if (copy_acl (src_name, source_desc, dst_name, dest_desc,
|
||||
src_sb->st_mode) != 0 && x->require_preserve)
|
||||
if (copy_acl (src_name, source_desc, dst_name, dest_desc, src_mode) != 0
|
||||
&& x->require_preserve)
|
||||
return_val = false;
|
||||
}
|
||||
else if (x->set_mode)
|
||||
@@ -522,6 +557,18 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
if (set_acl (dst_name, dest_desc, x->mode) != 0)
|
||||
return_val = false;
|
||||
}
|
||||
else if (omitted_permissions)
|
||||
{
|
||||
omitted_permissions &= ~ cached_umask ();
|
||||
if (omitted_permissions
|
||||
&& fchmod_or_lchmod (dest_desc, dst_name, dst_mode) != 0)
|
||||
{
|
||||
error (0, errno, _("preserving permissions for %s"),
|
||||
quote (dst_name));
|
||||
if (x->require_preserve)
|
||||
return_val = false;
|
||||
}
|
||||
}
|
||||
|
||||
close_src_and_dst_desc:
|
||||
if (close (dest_desc) < 0)
|
||||
@@ -751,10 +798,14 @@ overwrite_prompt (char const *dst_name, struct stat const *dst_sb)
|
||||
{
|
||||
if (euidaccess (dst_name, W_OK) != 0)
|
||||
{
|
||||
char perms[12]; /* "-rwxrwxrwx " ls-style modes. */
|
||||
strmode (dst_sb->st_mode, perms);
|
||||
perms[10] = '\0';
|
||||
fprintf (stderr,
|
||||
_("%s: overwrite %s, overriding mode %04lo? "),
|
||||
_("%s: try to overwrite %s, overriding mode %04lo (%s)? "),
|
||||
program_name, quote (dst_name),
|
||||
(unsigned long int) (dst_sb->st_mode & CHMOD_MODE_BITS));
|
||||
(unsigned long int) (dst_sb->st_mode & CHMOD_MODE_BITS),
|
||||
&perms[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -968,8 +1019,9 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
struct stat src_sb;
|
||||
struct stat dst_sb;
|
||||
mode_t src_mode;
|
||||
mode_t src_type;
|
||||
mode_t dst_mode IF_LINT (= 0);
|
||||
mode_t dst_mode_bits;
|
||||
mode_t omitted_permissions;
|
||||
bool restore_dst_mode = false;
|
||||
char *earlier_file = NULL;
|
||||
char *dst_backup = NULL;
|
||||
@@ -989,11 +1041,9 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
src_type = src_sb.st_mode;
|
||||
|
||||
src_mode = src_sb.st_mode;
|
||||
|
||||
if (S_ISDIR (src_type) && !x->recursive)
|
||||
if (S_ISDIR (src_mode) && !x->recursive)
|
||||
{
|
||||
error (0, 0, _("omitting directory %s"), quote (src_name));
|
||||
return false;
|
||||
@@ -1036,34 +1086,57 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
that it is XSTAT'able. */
|
||||
bool return_now;
|
||||
bool unlink_src;
|
||||
bool ok = same_file_ok (src_name, &src_sb, dst_name, &dst_sb,
|
||||
x, &return_now, &unlink_src);
|
||||
if (unlink_src)
|
||||
{
|
||||
if (!abandon_move (x, dst_name, &dst_sb)
|
||||
&& unlink (src_name) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot remove %s"), quote (src_name));
|
||||
return false;
|
||||
}
|
||||
/* Tell the caller that there's no need to remove src_name. */
|
||||
if (rename_succeeded)
|
||||
*rename_succeeded = true;
|
||||
}
|
||||
|
||||
if (return_now)
|
||||
return true;
|
||||
|
||||
if (! ok)
|
||||
if (! same_file_ok (src_name, &src_sb, dst_name, &dst_sb,
|
||||
x, &return_now, &unlink_src))
|
||||
{
|
||||
error (0, 0, _("%s and %s are the same file"),
|
||||
quote_n (0, src_name), quote_n (1, dst_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
/* When there is an existing destination file, we may end up
|
||||
returning early, and hence not copying/moving the file.
|
||||
This may be due to an interactive `negative' reply to the
|
||||
prompt about the existing file. It may also be due to the
|
||||
use of the --reply=no option.
|
||||
|
||||
cp and mv treat -i and -f differently. */
|
||||
if (x->move_mode)
|
||||
{
|
||||
if (abandon_move (x, dst_name, &dst_sb)
|
||||
|| (unlink_src && unlink (src_name) == 0))
|
||||
{
|
||||
/* Pretend the rename succeeded, so the caller (mv)
|
||||
doesn't end up removing the source file. */
|
||||
if (rename_succeeded)
|
||||
*rename_succeeded = true;
|
||||
if (unlink_src && x->verbose)
|
||||
printf (_("removed %s\n"), quote (src_name));
|
||||
return true;
|
||||
}
|
||||
if (unlink_src)
|
||||
{
|
||||
error (0, errno, _("cannot remove %s"), quote (src_name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! S_ISDIR (src_mode)
|
||||
&& (x->interactive == I_ALWAYS_NO
|
||||
|| (x->interactive == I_ASK_USER
|
||||
&& (overwrite_prompt (dst_name, &dst_sb), 1)
|
||||
&& ! yesno ())))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (return_now)
|
||||
return true;
|
||||
|
||||
if (!S_ISDIR (dst_sb.st_mode))
|
||||
{
|
||||
if (S_ISDIR (src_type))
|
||||
if (S_ISDIR (src_mode))
|
||||
{
|
||||
if (x->move_mode && x->backup_type != no_backups)
|
||||
{
|
||||
@@ -1097,7 +1170,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
}
|
||||
}
|
||||
|
||||
if (!S_ISDIR (src_type))
|
||||
if (!S_ISDIR (src_mode))
|
||||
{
|
||||
if (S_ISDIR (dst_sb.st_mode))
|
||||
{
|
||||
@@ -1140,37 +1213,6 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
}
|
||||
}
|
||||
|
||||
/* When there is an existing destination file, we may end up
|
||||
returning early, and hence not copying/moving the file.
|
||||
This may be due to an interactive `negative' reply to the
|
||||
prompt about the existing file. It may also be due to the
|
||||
use of the --reply=no option. */
|
||||
if (!S_ISDIR (src_type))
|
||||
{
|
||||
/* cp and mv treat -i and -f differently. */
|
||||
if (x->move_mode)
|
||||
{
|
||||
if (abandon_move (x, dst_name, &dst_sb))
|
||||
{
|
||||
/* Pretend the rename succeeded, so the caller (mv)
|
||||
doesn't end up removing the source file. */
|
||||
if (rename_succeeded)
|
||||
*rename_succeeded = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x->interactive == I_ALWAYS_NO
|
||||
|| (x->interactive == I_ASK_USER
|
||||
&& (overwrite_prompt (dst_name, &dst_sb), 1)
|
||||
&& ! yesno ()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x->move_mode)
|
||||
{
|
||||
/* Don't allow user to move a directory onto a non-directory. */
|
||||
@@ -1187,7 +1229,13 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
if (x->backup_type != no_backups
|
||||
/* Don't try to back up a destination if the last
|
||||
component of src_name is "." or "..". */
|
||||
&& ! dot_or_dotdot (last_component (src_name)))
|
||||
&& ! dot_or_dotdot (last_component (src_name))
|
||||
/* Create a backup of each destination directory in move mode,
|
||||
but not in copy mode. FIXME: it might make sense to add an
|
||||
option to suppress backup creation also for move mode.
|
||||
That would let one use mv to merge new content into an
|
||||
existing hierarchy. */
|
||||
&& (x->move_mode || ! S_ISDIR (dst_sb.st_mode)))
|
||||
{
|
||||
char *tmp_backup = find_backup_file_name (dst_name,
|
||||
x->backup_type);
|
||||
@@ -1250,6 +1298,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
return false;
|
||||
}
|
||||
new_dst = true;
|
||||
if (x->verbose)
|
||||
printf (_("removed %s\n"), quote (dst_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1257,7 +1307,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
/* If the source is a directory, we don't always create the destination
|
||||
directory. So --verbose should not announce anything until we're
|
||||
sure we'll create a directory. */
|
||||
if (x->verbose && !S_ISDIR (src_type))
|
||||
if (x->verbose && !S_ISDIR (src_mode))
|
||||
emit_verbose (src_name, dst_name, backup_succeeded ? dst_backup : NULL);
|
||||
|
||||
/* Associate the destination file name with the source device and inode
|
||||
@@ -1300,7 +1350,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
|| (command_line_arg
|
||||
&& x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
|
||||
|| x->dereference == DEREF_ALWAYS))
|
||||
|| (x->recursive && S_ISDIR (src_type)))
|
||||
|| (x->recursive && S_ISDIR (src_mode)))
|
||||
{
|
||||
earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev);
|
||||
}
|
||||
@@ -1313,7 +1363,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
/* Avoid damaging the destination file system by refusing to preserve
|
||||
hard-linked directories (which are found at least in Netapp snapshot
|
||||
directories). */
|
||||
if (S_ISDIR (src_type))
|
||||
if (S_ISDIR (src_mode))
|
||||
{
|
||||
/* If src_name and earlier_file refer to the same directory entry,
|
||||
then warn about copying a directory into itself. */
|
||||
@@ -1354,6 +1404,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
error (0, errno, _("cannot remove %s"), quote (dst_name));
|
||||
goto un_backup;
|
||||
}
|
||||
if (x->verbose)
|
||||
printf (_("removed %s\n"), quote (dst_name));
|
||||
link_failed = (link (earlier_file, dst_name) != 0);
|
||||
}
|
||||
|
||||
@@ -1372,7 +1424,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
{
|
||||
if (rename (src_name, dst_name) == 0)
|
||||
{
|
||||
if (x->verbose && S_ISDIR (src_type))
|
||||
if (x->verbose && S_ISDIR (src_mode))
|
||||
emit_verbose (src_name, dst_name,
|
||||
backup_succeeded ? dst_backup : NULL);
|
||||
|
||||
@@ -1468,6 +1520,17 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
new_dst = true;
|
||||
}
|
||||
|
||||
/* If the ownership might change, or if it is a directory (whose
|
||||
special mode bits may change after the directory is created),
|
||||
omit some permissions at first, so unauthorized users cannot nip
|
||||
in before the file is ready. */
|
||||
dst_mode_bits = (x->set_mode ? x->mode : src_mode) & CHMOD_MODE_BITS;
|
||||
omitted_permissions =
|
||||
(dst_mode_bits
|
||||
& (x->preserve_ownership ? S_IRWXG | S_IRWXO
|
||||
: S_ISDIR (src_mode) ? S_IWGRP | S_IWOTH
|
||||
: 0));
|
||||
|
||||
delayed_ok = true;
|
||||
|
||||
/* In certain modes (cp's --symbolic-link), and for certain file types
|
||||
@@ -1476,7 +1539,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
In such cases, set this variable to zero. */
|
||||
preserve_metadata = true;
|
||||
|
||||
if (S_ISDIR (src_type))
|
||||
if (S_ISDIR (src_mode))
|
||||
{
|
||||
struct dir_list *dir;
|
||||
|
||||
@@ -1501,7 +1564,11 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
|
||||
if (new_dst || !S_ISDIR (dst_sb.st_mode))
|
||||
{
|
||||
if (mkdir (dst_name, src_mode) != 0)
|
||||
/* POSIX says mkdir's behavior is implementation-defined when
|
||||
(src_mode & ~S_IRWXUGO) != 0. However, common practice is
|
||||
to ask mkdir to copy all the CHMOD_MODE_BITS, letting mkdir
|
||||
decide what to do with S_ISUID | S_ISGID | S_ISVTX. */
|
||||
if (mkdir (dst_name, dst_mode_bits & ~omitted_permissions) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot create directory %s"),
|
||||
quote (dst_name));
|
||||
@@ -1542,19 +1609,20 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
emit_verbose (src_name, dst_name, NULL);
|
||||
}
|
||||
|
||||
/* Are we crossing a file system boundary? */
|
||||
/* Decide whether to copy the contents of the directory. */
|
||||
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
|
||||
return true;
|
||||
|
||||
/* Copy the contents of the directory. */
|
||||
|
||||
if (! copy_dir (src_name, dst_name, new_dst, &src_sb, dir, x,
|
||||
copy_into_self))
|
||||
{
|
||||
/* Don't just return here -- otherwise, the failure to read a
|
||||
single file in a source directory would cause the containing
|
||||
destination directory not to have owner/perms set properly. */
|
||||
delayed_ok = false;
|
||||
/* Here, we are crossing a file system boundary and cp's -x option
|
||||
is in effect: so don't copy the contents of this directory. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Copy the contents of the directory. Don't just return if
|
||||
this fails -- otherwise, the failure to read a single file
|
||||
in a source directory would cause the containing destination
|
||||
directory not to have owner/perms set properly. */
|
||||
delayed_ok = copy_dir (src_name, dst_name, new_dst, &src_sb, dir, x,
|
||||
copy_into_self);
|
||||
}
|
||||
}
|
||||
else if (x->symbolic_link)
|
||||
@@ -1575,8 +1643,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
/* If either stat call fails, it's ok not to report
|
||||
the failure and say dst_name is in the current
|
||||
directory. Other things will fail later. */
|
||||
|| stat (".", &dot_sb)
|
||||
|| stat (dst_parent, &dst_parent_sb)
|
||||
|| stat (".", &dot_sb) != 0
|
||||
|| stat (dst_parent, &dst_parent_sb) != 0
|
||||
|| SAME_INODE (dot_sb, dst_parent_sb));
|
||||
free (dst_parent);
|
||||
|
||||
@@ -1619,36 +1687,46 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
goto un_backup;
|
||||
}
|
||||
}
|
||||
else if (S_ISREG (src_type)
|
||||
|| (x->copy_as_regular && !S_ISLNK (src_type)))
|
||||
else if (S_ISREG (src_mode)
|
||||
|| (x->copy_as_regular && !S_ISLNK (src_mode)))
|
||||
{
|
||||
copied_as_regular = true;
|
||||
/* POSIX says the permission bits of the source file must be
|
||||
used as the 3rd argument in the open call, but that's not consistent
|
||||
with historical practice. */
|
||||
if (! copy_reg (src_name, dst_name, x, src_mode, &new_dst, &src_sb))
|
||||
used as the 3rd argument in the open call. Historical
|
||||
practice passed all the source mode bits to 'open', but the extra
|
||||
bits were ignored, so it should be the same either way. */
|
||||
if (! copy_reg (src_name, dst_name, x, src_mode & S_IRWXUGO,
|
||||
omitted_permissions, &new_dst, &src_sb))
|
||||
goto un_backup;
|
||||
}
|
||||
else if (S_ISFIFO (src_type))
|
||||
else if (S_ISFIFO (src_mode))
|
||||
{
|
||||
if (mkfifo (dst_name, src_mode))
|
||||
{
|
||||
error (0, errno, _("cannot create fifo %s"), quote (dst_name));
|
||||
goto un_backup;
|
||||
}
|
||||
/* Use mknod, rather than mkfifo, because the former preserves
|
||||
the special mode bits of a fifo on Solaris 10, while mkfifo
|
||||
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;
|
||||
}
|
||||
}
|
||||
else if (S_ISBLK (src_type) || S_ISCHR (src_type) || S_ISSOCK (src_type))
|
||||
else if (S_ISBLK (src_mode) || S_ISCHR (src_mode) || S_ISSOCK (src_mode))
|
||||
{
|
||||
if (mknod (dst_name, src_mode, src_sb.st_rdev))
|
||||
if (mknod (dst_name, src_mode & ~omitted_permissions, src_sb.st_rdev)
|
||||
!= 0)
|
||||
{
|
||||
error (0, errno, _("cannot create special file %s"),
|
||||
quote (dst_name));
|
||||
goto un_backup;
|
||||
}
|
||||
}
|
||||
else if (S_ISLNK (src_type))
|
||||
else if (S_ISLNK (src_mode))
|
||||
{
|
||||
char *src_link_val = xreadlink (src_name, src_sb.st_size);
|
||||
char *src_link_val = xreadlink_with_size (src_name, src_sb.st_size);
|
||||
if (src_link_val == NULL)
|
||||
{
|
||||
error (0, errno, _("cannot read symbolic link %s"), quote (src_name));
|
||||
@@ -1668,7 +1746,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
FIXME: This behavior isn't documented, and seems wrong
|
||||
in some cases, e.g., if the destination symlink has the
|
||||
wrong ownership, permissions, or time stamps. */
|
||||
char *dest_link_val = xreadlink (dst_name, dst_sb.st_size);
|
||||
char *dest_link_val =
|
||||
xreadlink_with_size (dst_name, dst_sb.st_size);
|
||||
if (STREQ (dest_link_val, src_link_val))
|
||||
same_link = true;
|
||||
free (dest_link_val);
|
||||
@@ -1751,8 +1830,15 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
if (x->preserve_ownership
|
||||
&& (new_dst || !SAME_OWNER_AND_GROUP (src_sb, dst_sb)))
|
||||
{
|
||||
if (! set_owner (x, dst_name, -1, src_sb.st_uid, src_sb.st_gid))
|
||||
return false;
|
||||
switch (set_owner (x, dst_name, -1, src_sb.st_uid, src_sb.st_gid))
|
||||
{
|
||||
case -1:
|
||||
return false;
|
||||
|
||||
case 0:
|
||||
src_mode &= ~ (S_ISUID | S_ISGID | S_ISVTX);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
set_author (dst_name, -1, &src_sb);
|
||||
@@ -1768,14 +1854,40 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
if (set_acl (dst_name, -1, x->mode) != 0)
|
||||
return false;
|
||||
}
|
||||
else if (restore_dst_mode)
|
||||
else
|
||||
{
|
||||
if (lchmod (dst_name, dst_mode) != 0)
|
||||
if (omitted_permissions)
|
||||
{
|
||||
error (0, errno, _("preserving permissions for %s"),
|
||||
quote (dst_name));
|
||||
if (x->require_preserve)
|
||||
return false;
|
||||
omitted_permissions &= ~ cached_umask ();
|
||||
|
||||
if (omitted_permissions && !restore_dst_mode)
|
||||
{
|
||||
/* Permissions were deliberately omitted when the file
|
||||
was created due to security concerns. See whether
|
||||
they need to be re-added now. It'd be faster to omit
|
||||
the lstat, but deducing the current destination mode
|
||||
is tricky in the presence of implementation-defined
|
||||
rules for special mode bits. */
|
||||
if (new_dst && lstat (dst_name, &dst_sb) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot stat %s"), quote (dst_name));
|
||||
return false;
|
||||
}
|
||||
dst_mode = dst_sb.st_mode;
|
||||
if (omitted_permissions & ~dst_mode)
|
||||
restore_dst_mode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (restore_dst_mode)
|
||||
{
|
||||
if (lchmod (dst_name, dst_mode | omitted_permissions) != 0)
|
||||
{
|
||||
error (0, errno, _("preserving permissions for %s"),
|
||||
quote (dst_name));
|
||||
if (x->require_preserve)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1879,3 +1991,17 @@ chown_failure_ok (struct cp_options const *x)
|
||||
|
||||
return ((errno == EPERM || errno == EINVAL) && !x->chown_privileges);
|
||||
}
|
||||
|
||||
/* Return the user's umask, caching the result. */
|
||||
|
||||
extern mode_t
|
||||
cached_umask (void)
|
||||
{
|
||||
static mode_t mask = (mode_t) -1;
|
||||
if (mask == (mode_t) -1)
|
||||
{
|
||||
mask = umask (0);
|
||||
umask (mask);
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
@@ -213,5 +213,6 @@ void src_info_init (struct cp_options *);
|
||||
|
||||
bool chown_privileges (void);
|
||||
bool chown_failure_ok (struct cp_options const *);
|
||||
mode_t cached_umask (void);
|
||||
|
||||
#endif
|
||||
|
||||
69
src/cp.c
69
src/cp.c
@@ -1,5 +1,5 @@
|
||||
/* cp.c -- file copying (main routines)
|
||||
Copyright (C) 89, 90, 91, 1995-2006 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -413,6 +413,9 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
|
||||
if (XSTAT (x, dir, &stats))
|
||||
{
|
||||
mode_t src_mode;
|
||||
mode_t omitted_permissions;
|
||||
mode_t mkdir_mode;
|
||||
int src_errno;
|
||||
|
||||
/* This component does not exist. We must set
|
||||
*new_dst and new->mode inside this loop because,
|
||||
@@ -420,15 +423,35 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
|
||||
make_dir_parents_private creates only e_dir/../a if
|
||||
./b already exists. */
|
||||
*new_dst = true;
|
||||
if (XSTAT (x, src, &stats))
|
||||
src_errno = (XSTAT (x, src, &stats) != 0
|
||||
? errno
|
||||
: S_ISDIR (stats.st_mode)
|
||||
? 0
|
||||
: ENOTDIR);
|
||||
if (src_errno)
|
||||
{
|
||||
error (0, errno, _("failed to get attributes of %s"),
|
||||
error (0, src_errno, _("failed to get attributes of %s"),
|
||||
quote (src));
|
||||
return false;
|
||||
}
|
||||
src_mode = stats.st_mode;
|
||||
|
||||
if (mkdir (dir, src_mode))
|
||||
/* If the ownership or special mode bits might change,
|
||||
omit some permissions at first, so unauthorized users
|
||||
cannot nip in before the file is ready. */
|
||||
omitted_permissions = (src_mode
|
||||
& (x->preserve_ownership
|
||||
? S_IRWXG | S_IRWXO
|
||||
: x->preserve_mode
|
||||
? S_IWGRP | S_IWOTH
|
||||
: 0));
|
||||
|
||||
/* POSIX says mkdir's behavior is implementation-defined when
|
||||
(src_mode & ~S_IRWXUGO) != 0. However, common practice is
|
||||
to ask mkdir to copy all the CHMOD_MODE_BITS, letting mkdir
|
||||
decide what to do with S_ISUID | S_ISGID | S_ISVTX. */
|
||||
mkdir_mode = src_mode & CHMOD_MODE_BITS & ~omitted_permissions;
|
||||
if (mkdir (dir, mkdir_mode) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot make directory %s"),
|
||||
quote (dir));
|
||||
@@ -450,28 +473,30 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
|
||||
quote (dir));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x->preserve_mode)
|
||||
{
|
||||
new->mode = src_mode;
|
||||
new->restore_mode = (src_mode != stats.st_mode);
|
||||
}
|
||||
|
||||
if ((stats.st_mode & S_IRWXU) != S_IRWXU)
|
||||
{
|
||||
/* Make the new directory searchable and writable. The
|
||||
original permissions will be restored later. */
|
||||
|
||||
new->mode = stats.st_mode;
|
||||
if (! x->preserve_mode)
|
||||
{
|
||||
if (omitted_permissions & ~stats.st_mode)
|
||||
omitted_permissions &= ~ cached_umask ();
|
||||
if (omitted_permissions & ~stats.st_mode
|
||||
|| (stats.st_mode & S_IRWXU) != S_IRWXU)
|
||||
{
|
||||
new->mode = stats.st_mode | omitted_permissions;
|
||||
new->restore_mode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (lchmod (dir, stats.st_mode | S_IRWXU) != 0)
|
||||
{
|
||||
error (0, errno, _("setting permissions for %s"),
|
||||
quote (dir));
|
||||
return false;
|
||||
}
|
||||
if ((stats.st_mode & S_IRWXU) != S_IRWXU)
|
||||
{
|
||||
/* Make the new directory searchable and writable.
|
||||
The original permissions will be restored later. */
|
||||
|
||||
if (lchmod (dir, stats.st_mode | S_IRWXU) != 0)
|
||||
{
|
||||
error (0, errno, _("setting permissions for %s"),
|
||||
quote (dir));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
src/csplit.c
33
src/csplit.c
@@ -1,5 +1,5 @@
|
||||
/* csplit - split a file into sections determined by context lines
|
||||
Copyright (C) 91, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-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
|
||||
@@ -149,13 +149,13 @@ static uintmax_t current_line = 0;
|
||||
static bool have_read_eof = false;
|
||||
|
||||
/* Name of output files. */
|
||||
static char * volatile filename_space = NULL;
|
||||
static char *volatile filename_space = NULL;
|
||||
|
||||
/* Prefix part of output file names. */
|
||||
static char * volatile prefix = NULL;
|
||||
static char const *volatile prefix = NULL;
|
||||
|
||||
/* Suffix part of output file names. */
|
||||
static char * volatile suffix = NULL;
|
||||
static char *volatile suffix = NULL;
|
||||
|
||||
/* Number of digits to use in output file names. */
|
||||
static int volatile digits = 2;
|
||||
@@ -526,6 +526,8 @@ load_buffer (void)
|
||||
|
||||
if (lines_found)
|
||||
save_buffer (b);
|
||||
else
|
||||
free (b);
|
||||
|
||||
return lines_found != 0;
|
||||
}
|
||||
@@ -1400,7 +1402,26 @@ main (int argc, char **argv)
|
||||
|
||||
{
|
||||
int i;
|
||||
static int const sig[] = { SIGHUP, SIGINT, SIGQUIT, SIGTERM };
|
||||
static int const sig[] =
|
||||
{
|
||||
/* The usual suspects. */
|
||||
SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM,
|
||||
#ifdef SIGPOLL
|
||||
SIGPOLL,
|
||||
#endif
|
||||
#ifdef SIGPROF
|
||||
SIGPROF,
|
||||
#endif
|
||||
#ifdef SIGVTALRM
|
||||
SIGVTALRM,
|
||||
#endif
|
||||
#ifdef SIGXCPU
|
||||
SIGXCPU,
|
||||
#endif
|
||||
#ifdef SIGXFSZ
|
||||
SIGXFSZ,
|
||||
#endif
|
||||
};
|
||||
enum { nsigs = sizeof sig / sizeof sig[0] };
|
||||
|
||||
#if SA_NOCLDSTOP
|
||||
@@ -1463,7 +1484,7 @@ and output byte counts of each piece to standard output.\n\
|
||||
Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-b, --suffix-format=FORMAT use sprintf FORMAT instead of %02d\n\
|
||||
-b, --suffix-format=FORMAT use sprintf FORMAT instead of %02d\n\
|
||||
-f, --prefix=PREFIX use PREFIX instead of `xx'\n\
|
||||
-k, --keep-files do not remove output files on errors\n\
|
||||
"), stdout);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cut - remove parts of lines of files
|
||||
Copyright (C) 1997-2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984 David M. Ihnat
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -223,6 +223,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
Use one, and only one of -b, -c or -f. Each LIST is made up of one\n\
|
||||
range, or many ranges separated by commas. Selected input is written\n\
|
||||
in the same order that it is read, and is written exactly once.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
Each range is one of:\n\
|
||||
\n\
|
||||
N N'th byte, character or field, counted from 1\n\
|
||||
@@ -604,6 +606,7 @@ cut_fields (FILE *stream)
|
||||
if (len < 0)
|
||||
{
|
||||
free (field_1_buffer);
|
||||
field_1_buffer = NULL;
|
||||
if (ferror (stream) || feof (stream))
|
||||
break;
|
||||
xalloc_die ();
|
||||
@@ -702,7 +705,7 @@ cut_stream (FILE *stream)
|
||||
Return true if successful. */
|
||||
|
||||
static bool
|
||||
cut_file (char *file)
|
||||
cut_file (char const *file)
|
||||
{
|
||||
FILE *stream;
|
||||
|
||||
|
||||
21
src/date.c
21
src/date.c
@@ -1,5 +1,5 @@
|
||||
/* date - print or set the system date and time
|
||||
Copyright (C) 1989-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-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
|
||||
@@ -142,10 +142,15 @@ Display the current time in the given FORMAT, or set the system date.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-r, --reference=FILE display the last modification time of FILE\n\
|
||||
-R, --rfc-2822 output date and time in RFC 2822 format\n\
|
||||
-R, --rfc-2822 output date and time in RFC 2822 format.\n\
|
||||
Example: Mon, 07 Aug 2006 12:34:56 -0600\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--rfc-3339=TIMESPEC output date and time in RFC 3339 format.\n\
|
||||
TIMESPEC=`date', `seconds', or `ns' for\n\
|
||||
date and time to the indicated precision.\n\
|
||||
Date and time components are separated by\n\
|
||||
a single space: 2006-08-07 12:34:56-06:00\n\
|
||||
-s, --set=STRING set time described by STRING\n\
|
||||
-u, --utc, --universal print or set Coordinated Universal Time\n\
|
||||
"), stdout);
|
||||
@@ -223,13 +228,15 @@ specifies Coordinated Universal Time. Interpreted sequences are:\n\
|
||||
%Z alphabetic time zone abbreviation (e.g., EDT)\n\
|
||||
\n\
|
||||
By default, date pads numeric fields with zeroes.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
The following optional flags may follow `%':\n\
|
||||
\n\
|
||||
- (hyphen) do not pad the field\n\
|
||||
_ (underscore) pad with spaces\n\
|
||||
0 (zero) pad with zeros\n\
|
||||
^ use upper case if possible\n\
|
||||
# use opposite case if possible\n\
|
||||
- (hyphen) do not pad the field\n\
|
||||
_ (underscore) pad with spaces\n\
|
||||
0 (zero) pad with zeros\n\
|
||||
^ use upper case if possible\n\
|
||||
# use opposite case if possible\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
|
||||
12
src/dcgen
12
src/dcgen
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl -w
|
||||
# dcgen -- convert dircolors.hin to dircolors.h.
|
||||
|
||||
# Copyright (C) 1996, 1998, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996, 1998, 2004, 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
|
||||
@@ -44,12 +44,14 @@ while (<>)
|
||||
and push @line, $_;
|
||||
}
|
||||
|
||||
my $last_line = pop @line;
|
||||
my $indent = ' ';
|
||||
|
||||
print "static char const G_line[] =\n";
|
||||
print "static char const G_line[] =\n{\n";
|
||||
foreach (@line)
|
||||
{
|
||||
print "$indent\"$_\\0\"\n";
|
||||
s/./'$&',/g;
|
||||
s/'\\'/'\\\\'/g;
|
||||
s/'''/'\\''/g;
|
||||
print "$indent${_}0,\n";
|
||||
}
|
||||
print "$indent\"$last_line\";\n";
|
||||
print "};\n";
|
||||
|
||||
29
src/dd.c
29
src/dd.c
@@ -1,5 +1,5 @@
|
||||
/* dd -- convert a file while copying it.
|
||||
Copyright (C) 85, 90, 91, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 85, 90, 91, 1995-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
|
||||
@@ -267,7 +267,7 @@ static struct symbol_value const flags[] =
|
||||
{"dsync", O_DSYNC},
|
||||
{"noatime", O_NOATIME},
|
||||
{"noctty", O_NOCTTY},
|
||||
{"nofollow", O_NOFOLLOW},
|
||||
{"nofollow", HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0},
|
||||
{"nolinks", O_NOLINKS},
|
||||
{"nonblock", O_NONBLOCK},
|
||||
{"sync", O_SYNC},
|
||||
@@ -448,10 +448,12 @@ Each CONV symbol may be:\n\
|
||||
notrunc do not truncate the output file\n\
|
||||
ucase change lower case to upper case\n\
|
||||
swab swap every pair of input bytes\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
noerror continue after read errors\n\
|
||||
sync pad every input block with NULs to ibs-size; when used\n\
|
||||
with block or unblock, pad with spaces rather than NULs\n\
|
||||
fdatasync physically write output file data before finishing\n\
|
||||
with block or unblock, pad with spaces rather than NULs\n\
|
||||
fdatasync physically write output file data before finishing\n\
|
||||
fsync likewise, but also write metadata\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
@@ -475,7 +477,7 @@ Each FLAG symbol may be:\n\
|
||||
if (O_NOCTTY)
|
||||
fputs (_(" noctty do not assign controlling terminal from file\n"),
|
||||
stdout);
|
||||
if (O_NOFOLLOW)
|
||||
if (HAVE_WORKING_O_NOFOLLOW)
|
||||
fputs (_(" nofollow do not follow symlinks\n"), stdout);
|
||||
if (O_NOLINKS)
|
||||
fputs (_(" nolinks fail if multiply-linked\n"), stdout);
|
||||
@@ -871,6 +873,7 @@ static void
|
||||
scanargs (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
size_t blocksize = 0;
|
||||
|
||||
for (i = optind; i < argc; i++)
|
||||
{
|
||||
@@ -921,7 +924,7 @@ scanargs (int argc, char **argv)
|
||||
else if (STREQ (name, "bs"))
|
||||
{
|
||||
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP));
|
||||
output_blocksize = input_blocksize = n;
|
||||
blocksize = n;
|
||||
}
|
||||
else if (STREQ (name, "cbs"))
|
||||
{
|
||||
@@ -946,6 +949,9 @@ scanargs (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (blocksize)
|
||||
input_blocksize = output_blocksize = blocksize;
|
||||
|
||||
/* If bs= was given, both `input_blocksize' and `output_blocksize' will
|
||||
have been set to positive values. If either has not been set,
|
||||
bs= was not given, so make sure two buffers are used. */
|
||||
@@ -1220,7 +1226,7 @@ advance_input_after_read_error (size_t nbytes)
|
||||
return true;
|
||||
diff = input_offset - offset;
|
||||
if (! (0 <= diff && diff <= nbytes))
|
||||
error (0, 0, _("warning: screwy file offset after failed read"));
|
||||
error (0, 0, _("warning: invalid file offset after failed read"));
|
||||
if (0 <= skip_via_lseek (input_file, STDIN_FILENO, diff, SEEK_CUR))
|
||||
return true;
|
||||
if (errno == 0)
|
||||
@@ -1377,8 +1383,10 @@ static int
|
||||
dd_copy (void)
|
||||
{
|
||||
char *ibuf, *bufstart; /* Input buffer. */
|
||||
char *real_buf; /* real buffer address before alignment */
|
||||
char *real_obuf;
|
||||
/* These are declared static so that even though we don't free the
|
||||
buffers, valgrind will recognize that there is no "real" leak. */
|
||||
static char *real_buf; /* real buffer address before alignment */
|
||||
static char *real_obuf;
|
||||
ssize_t nread; /* Bytes read in the current block. */
|
||||
|
||||
/* If nonzero, then the previously read block was partial and
|
||||
@@ -1598,9 +1606,6 @@ dd_copy (void)
|
||||
}
|
||||
}
|
||||
|
||||
free (real_buf);
|
||||
free (real_obuf);
|
||||
|
||||
if ((conversions_mask & C_FDATASYNC) && fdatasync (STDOUT_FILENO) != 0)
|
||||
{
|
||||
if (errno != ENOSYS && errno != EINVAL)
|
||||
|
||||
21
src/df.c
21
src/df.c
@@ -1,5 +1,5 @@
|
||||
/* df - summarize free disk space
|
||||
Copyright (C) 91, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-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
|
||||
@@ -748,7 +748,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-a, --all include dummy file systems\n\
|
||||
-B, --block-size=SIZE use SIZE-byte blocks\n\
|
||||
-B, --block-size=SIZE use SIZE-byte blocks\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);
|
||||
@@ -796,10 +796,7 @@ main (int argc, char **argv)
|
||||
inode_format = false;
|
||||
show_all_fs = false;
|
||||
show_listed_fs = false;
|
||||
|
||||
human_output_opts = human_options (getenv ("DF_BLOCK_SIZE"), false,
|
||||
&output_block_size);
|
||||
|
||||
human_output_opts = -1;
|
||||
print_type = false;
|
||||
file_systems_processed = false;
|
||||
posix_format = false;
|
||||
@@ -876,6 +873,18 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (human_output_opts == -1)
|
||||
{
|
||||
if (posix_format)
|
||||
{
|
||||
human_output_opts = 0;
|
||||
output_block_size = (getenv ("POSIXLY_CORRECT") ? 512 : 1024);
|
||||
}
|
||||
else
|
||||
human_output_opts = human_options (getenv ("DF_BLOCK_SIZE"), false,
|
||||
&output_block_size);
|
||||
}
|
||||
|
||||
/* Fail if the same file system type was both selected and excluded. */
|
||||
{
|
||||
bool match = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* dircolors - output commands to set the LS_COLOR environment variable
|
||||
Copyright (C) 1996-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-2007 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
|
||||
@@ -24,11 +24,11 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "dircolors.h"
|
||||
#include "c-strcase.h"
|
||||
#include "error.h"
|
||||
#include "getline.h"
|
||||
#include "obstack.h"
|
||||
#include "quote.h"
|
||||
#include "strcase.h"
|
||||
#include "xstrndup.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -246,7 +246,7 @@ dc_parse_stream (FILE *fp, const char *filename)
|
||||
char *input_line = NULL;
|
||||
size_t input_line_size = 0;
|
||||
char const *line;
|
||||
char *term;
|
||||
char const *term;
|
||||
bool ok = true;
|
||||
|
||||
/* State for the parser. */
|
||||
@@ -296,7 +296,7 @@ dc_parse_stream (FILE *fp, const char *filename)
|
||||
}
|
||||
|
||||
unrecognized = false;
|
||||
if (strcasecmp (keywd, "TERM") == 0)
|
||||
if (c_strcasecmp (keywd, "TERM") == 0)
|
||||
{
|
||||
if (STREQ (arg, term))
|
||||
state = ST_TERMSURE;
|
||||
@@ -325,9 +325,9 @@ dc_parse_stream (FILE *fp, const char *filename)
|
||||
append_quoted (arg);
|
||||
APPEND_CHAR (':');
|
||||
}
|
||||
else if (strcasecmp (keywd, "OPTIONS") == 0
|
||||
|| strcasecmp (keywd, "COLOR") == 0
|
||||
|| strcasecmp (keywd, "EIGHTBIT") == 0)
|
||||
else if (c_strcasecmp (keywd, "OPTIONS") == 0
|
||||
|| c_strcasecmp (keywd, "COLOR") == 0
|
||||
|| c_strcasecmp (keywd, "EIGHTBIT") == 0)
|
||||
{
|
||||
/* Ignore. */
|
||||
}
|
||||
@@ -336,7 +336,7 @@ dc_parse_stream (FILE *fp, const char *filename)
|
||||
int i;
|
||||
|
||||
for (i = 0; slack_codes[i] != NULL; ++i)
|
||||
if (strcasecmp (keywd, slack_codes[i]) == 0)
|
||||
if (c_strcasecmp (keywd, slack_codes[i]) == 0)
|
||||
break;
|
||||
|
||||
if (slack_codes[i] != NULL)
|
||||
|
||||
@@ -23,6 +23,7 @@ TERM con80x30
|
||||
TERM con80x43
|
||||
TERM con80x50
|
||||
TERM con80x60
|
||||
TERM cons25
|
||||
TERM console
|
||||
TERM cygwin
|
||||
TERM dtterm
|
||||
@@ -86,8 +87,13 @@ EXEC 01;32
|
||||
#.com 01;32
|
||||
#.btm 01;32
|
||||
#.bat 01;32
|
||||
# Or if you want to colorize scripts even if they do not have the
|
||||
# executable bit actually set.
|
||||
#.sh 01;32
|
||||
#.csh 01;32
|
||||
|
||||
.tar 01;31 # archives or compressed (bright red)
|
||||
# archives or compressed (bright red)
|
||||
.tar 01;31
|
||||
.tgz 01;31
|
||||
.arj 01;31
|
||||
.taz 01;31
|
||||
@@ -97,9 +103,18 @@ EXEC 01;32
|
||||
.Z 01;31
|
||||
.gz 01;31
|
||||
.bz2 01;31
|
||||
.bz 01;31
|
||||
.tbz2 01;31
|
||||
.tz 01;31
|
||||
.deb 01;31
|
||||
.rpm 01;31
|
||||
.jar 01;31
|
||||
.rar 01;31
|
||||
.ace 01;31
|
||||
.zoo 01;31
|
||||
.cpio 01;31
|
||||
.7z 01;31
|
||||
.rz 01;31
|
||||
|
||||
# image formats
|
||||
.jpg 01;35
|
||||
@@ -115,19 +130,42 @@ EXEC 01;32
|
||||
.tif 01;35
|
||||
.tiff 01;35
|
||||
.png 01;35
|
||||
.mng 01;35
|
||||
.pcx 01;35
|
||||
.mov 01;35
|
||||
.mpg 01;35
|
||||
.mpeg 01;35
|
||||
.m2v 01;35
|
||||
.mkv 01;35
|
||||
.ogm 01;35
|
||||
.mp4 01;35
|
||||
.m4v 01;35
|
||||
.mp4v 01;35
|
||||
.vob 01;35
|
||||
.qt 01;35
|
||||
.nuv 01;35
|
||||
.wmv 01;35
|
||||
.asf 01;35
|
||||
.rm 01;35
|
||||
.rmvb 01;35
|
||||
.flc 01;35
|
||||
.avi 01;35
|
||||
.fli 01;35
|
||||
.gl 01;35
|
||||
.dl 01;35
|
||||
.xcf 01;35
|
||||
.xwd 01;35
|
||||
.yuv 01;35
|
||||
|
||||
# audio formats
|
||||
.flac 01;35
|
||||
.mp3 01;35
|
||||
.mpc 01;35
|
||||
.ogg 01;35
|
||||
.wav 01;35
|
||||
.aac 00;36
|
||||
.au 00;36
|
||||
.flac 00;36
|
||||
.mid 00;36
|
||||
.midi 00;36
|
||||
.mka 00;36
|
||||
.mp3 00;36
|
||||
.mpc 00;36
|
||||
.ogg 00;36
|
||||
.ra 00;36
|
||||
.wav 00;36
|
||||
|
||||
16
src/du-tests
16
src/du-tests
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003, 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
|
||||
@@ -18,11 +18,17 @@
|
||||
|
||||
cat - <<\EOF > /dev/null
|
||||
Invoke e.g., like this
|
||||
DU1=du-4.5.2 DU2=du ./du-tests
|
||||
VG_PATH_PREFIX=/cu/src/vg: DU1=/cu/src/du DU2=/usr/bin/du ./du-tests
|
||||
Where /cu/src/vg/du is a valgrind wrapper around du,
|
||||
and DU1 refers to the just-built du binary you want to test.
|
||||
EOF
|
||||
|
||||
test -x "$DU1" || { echo DU1 envvar not set; exit 1; }
|
||||
test -x "$DU2" || { echo DU2 envvar not set; exit 1; }
|
||||
test -z "$DU1" && { echo DU1 envvar not set 1>&2; exit 1; }
|
||||
test -z "$DU2" && { echo DU2 envvar not set 1>&2; exit 1; }
|
||||
|
||||
test -x "$DU1" || { echo $DU1 not executable 1>&2; exit 1; }
|
||||
test -x "$DU2" || { echo $DU2 not executable 1>&2; exit 1; }
|
||||
|
||||
# Expects $DU1 and $DU2 to be the binaries to compare.
|
||||
d1=$(mktemp -d)
|
||||
cp -a $DU1 $d1/du
|
||||
@@ -47,6 +53,6 @@ for args in \
|
||||
; do
|
||||
echo Args: $args ======================
|
||||
diff -u --label=$DU1 --label=$DU2 \
|
||||
<(PATH=$d1 du $args 2>&1) <(PATH=$d2 du $args 2>&1)
|
||||
<(PATH=$VG_PATH_PREFIX$d1 du $args 2>&1) <(PATH=$d2 du $args 2>&1)
|
||||
done
|
||||
rm -rf $d1 $d2
|
||||
|
||||
12
src/du.c
12
src/du.c
@@ -1,5 +1,5 @@
|
||||
/* du -- summarize disk usage
|
||||
Copyright (C) 1988-1991, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-1991, 1995-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
|
||||
@@ -293,7 +293,9 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
the apparent size is usually smaller, it may be\n\
|
||||
larger due to holes in (`sparse') files, internal\n\
|
||||
fragmentation, indirect blocks, and the like\n\
|
||||
-B, --block-size=SIZE use SIZE-byte blocks\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-B, --block-size=SIZE use SIZE-byte blocks\n\
|
||||
-b, --bytes equivalent to `--apparent-size --block-size=1'\n\
|
||||
-c, --total produce a grand total\n\
|
||||
-D, --dereference-args dereference FILEs that are symbolic links\n\
|
||||
@@ -305,6 +307,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
change to be equivalent to --dereference-args (-D)\n\
|
||||
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
|
||||
--si like -h, but use powers of 1000 not 1024\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-k like --block-size=1K\n\
|
||||
-l, --count-links count sizes many times if hard linked\n\
|
||||
-m like --block-size=1M\n\
|
||||
@@ -319,7 +323,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
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\
|
||||
--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\
|
||||
@@ -330,7 +334,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
directory, or any of its subdirectories\n\
|
||||
--time=WORD show time as WORD instead of modification time:\n\
|
||||
atime, access, use, ctime or status\n\
|
||||
--time-style=STYLE show times using style STYLE:\n\
|
||||
--time-style=STYLE show times using style STYLE:\n\
|
||||
full-iso, long-iso, iso, +FORMAT\n\
|
||||
FORMAT is interpreted like `date'\n\
|
||||
"), stdout);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* env - run a program in a modified environment
|
||||
Copyright (C) 1986, 1991-2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1986, 1991-2005, 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
|
||||
@@ -189,8 +189,9 @@ main (int argc, char **argv)
|
||||
/* If no program is specified, print the environment and exit. */
|
||||
if (argc <= optind)
|
||||
{
|
||||
while (*environ)
|
||||
puts (*environ++);
|
||||
char *const *e = environ;
|
||||
while (*e)
|
||||
puts (*e++);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
14
src/expr.c
14
src/expr.c
@@ -236,7 +236,7 @@ int_value (intmax_t i)
|
||||
/* Return a VALUE for S. */
|
||||
|
||||
static VALUE *
|
||||
str_value (char *s)
|
||||
str_value (char const *s)
|
||||
{
|
||||
VALUE *v = xmalloc (sizeof *v);
|
||||
v->type = string;
|
||||
@@ -427,6 +427,10 @@ docolon (VALUE *sv, VALUE *pv)
|
||||
tostring (sv);
|
||||
tostring (pv);
|
||||
|
||||
re_regs.num_regs = 0;
|
||||
re_regs.start = NULL;
|
||||
re_regs.end = NULL;
|
||||
|
||||
re_buffer.buffer = NULL;
|
||||
re_buffer.allocated = 0;
|
||||
re_buffer.fastmap = fastmap;
|
||||
@@ -463,7 +467,13 @@ docolon (VALUE *sv, VALUE *pv)
|
||||
(matchlen == -2 ? errno : EOVERFLOW),
|
||||
_("error in regular expression matcher"));
|
||||
|
||||
free (re_buffer.buffer);
|
||||
if (0 < re_regs.num_regs)
|
||||
{
|
||||
free (re_regs.start);
|
||||
free (re_regs.end);
|
||||
}
|
||||
re_buffer.fastmap = NULL;
|
||||
regfree (&re_buffer);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
11
src/fmt.c
11
src/fmt.c
@@ -607,12 +607,15 @@ copy_rest (FILE *f, int c)
|
||||
const char *s;
|
||||
|
||||
out_column = 0;
|
||||
if (in_column > next_prefix_indent && c != '\n' && c != EOF)
|
||||
if (in_column > next_prefix_indent || (c != '\n' && c != EOF))
|
||||
{
|
||||
put_space (next_prefix_indent);
|
||||
for (s = prefix; out_column != in_column && *s; out_column++)
|
||||
putchar (*s++);
|
||||
put_space (in_column - out_column);
|
||||
if (c != EOF && c != '\n')
|
||||
put_space (in_column - out_column);
|
||||
if (c == EOF && in_column >= next_prefix_indent + prefix_length)
|
||||
putchar ('\n');
|
||||
}
|
||||
while (c != '\n' && c != EOF)
|
||||
{
|
||||
@@ -688,10 +691,8 @@ get_line (FILE *f, int c)
|
||||
flush_paragraph ();
|
||||
}
|
||||
word_limit++;
|
||||
if (c == EOF)
|
||||
return EOF;
|
||||
}
|
||||
while (c != '\n');
|
||||
while (c != '\n' && c != EOF);
|
||||
return get_prefix (f);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* fold -- wrap each input line to fit in specified width.
|
||||
Copyright (C) 91, 1995-2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-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
|
||||
@@ -122,7 +122,7 @@ adjust_column (size_t column, char c)
|
||||
Return true if successful. */
|
||||
|
||||
static bool
|
||||
fold_file (char *filename, size_t width)
|
||||
fold_file (char const *filename, size_t width)
|
||||
{
|
||||
FILE *istream;
|
||||
int c;
|
||||
|
||||
43
src/fs.h
43
src/fs.h
@@ -1,43 +0,0 @@
|
||||
/* Define the magic numbers as given by statfs(2).
|
||||
Please send additions to bug-coreutils@gnu.org and meskes@debian.org.
|
||||
This file is generated automatically from ./stat.c. */
|
||||
|
||||
#if defined __linux__
|
||||
# define S_MAGIC_AFFS 0xADFF
|
||||
# define S_MAGIC_DEVPTS 0x1CD1
|
||||
# define S_MAGIC_EXT 0x137D
|
||||
# define S_MAGIC_EXT2_OLD 0xEF51
|
||||
# define S_MAGIC_EXT2 0xEF53
|
||||
# define S_MAGIC_JFS 0x3153464a
|
||||
# define S_MAGIC_XFS 0x58465342
|
||||
# define S_MAGIC_HPFS 0xF995E849
|
||||
# define S_MAGIC_ISOFS 0x9660
|
||||
# define S_MAGIC_ISOFS_WIN 0x4000
|
||||
# define S_MAGIC_ISOFS_R_WIN 0x4004
|
||||
# define S_MAGIC_MINIX 0x137F
|
||||
# define S_MAGIC_MINIX_30 0x138F
|
||||
# define S_MAGIC_MINIX_V2 0x2468
|
||||
# define S_MAGIC_MINIX_V2_30 0x2478
|
||||
# define S_MAGIC_MSDOS 0x4d44
|
||||
# define S_MAGIC_FAT 0x4006
|
||||
# define S_MAGIC_NCP 0x564c
|
||||
# define S_MAGIC_NFS 0x6969
|
||||
# define S_MAGIC_PROC 0x9fa0
|
||||
# define S_MAGIC_SMB 0x517B
|
||||
# define S_MAGIC_XENIX 0x012FF7B4
|
||||
# define S_MAGIC_SYSV4 0x012FF7B5
|
||||
# define S_MAGIC_SYSV2 0x012FF7B6
|
||||
# define S_MAGIC_COH 0x012FF7B7
|
||||
# define S_MAGIC_UFS 0x00011954
|
||||
# define S_MAGIC_XIAFS 0x012FD16D
|
||||
# define S_MAGIC_NTFS 0x5346544e
|
||||
# define S_MAGIC_TMPFS 0x1021994
|
||||
# define S_MAGIC_REISERFS 0x52654973
|
||||
# define S_MAGIC_CRAMFS 0x28cd3d45
|
||||
# define S_MAGIC_ROMFS 0x7275
|
||||
# define S_MAGIC_RAMFS 0x858458f6
|
||||
# define S_MAGIC_SQUASHFS 0x73717368
|
||||
# define S_MAGIC_SYSFS 0x62656572
|
||||
#elif defined __GNU__
|
||||
# include <hurd/hurd_types.h>
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# groups -- print the groups a user is in
|
||||
# Copyright (C) 1991, 1997, 2000, 2002, 2004 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991, 1997, 2000, 2002, 2004-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
|
||||
@@ -32,39 +32,52 @@ Same as id -Gn. If no USERNAME, use current process.
|
||||
Report bugs to <@PACKAGE_BUGREPORT@>."
|
||||
|
||||
version='groups (@GNU_PACKAGE@) @VERSION@
|
||||
Written by David MacKenzie.
|
||||
Copyright (C) @RELEASE_YEAR@ Free Software Foundation, Inc.
|
||||
This is free software. You may redistribute copies of it under the terms of
|
||||
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'
|
||||
Written by David MacKenzie.'
|
||||
|
||||
|
||||
fail=0
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
--help | --hel | --he | --h)
|
||||
exec echo "$usage" ;;
|
||||
--version | --versio | --versi | --vers | --ver | --ve | --v)
|
||||
exec echo "$version" ;;
|
||||
--)
|
||||
shift
|
||||
break ;;
|
||||
-*)
|
||||
echo "$0: invalid option: $arg" >&2
|
||||
exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# With fewer than two arguments, simply exec "id".
|
||||
case $# in
|
||||
1 )
|
||||
case "z${1}" in
|
||||
z--help )
|
||||
echo "$usage" || fail=1; exit $fail;;
|
||||
z--version )
|
||||
echo "$version" || fail=1; exit $fail;;
|
||||
* ) ;;
|
||||
esac
|
||||
;;
|
||||
* ) ;;
|
||||
0|1) exec id -Gn -- "$@" ;;
|
||||
esac
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
id -Gn
|
||||
fail=$?
|
||||
else
|
||||
for name in "$@"; do
|
||||
groups=`id -Gn -- $name`
|
||||
# With more, we need a loop, and be sure to exit nonzero upon failure.
|
||||
status=0
|
||||
write_error=0
|
||||
|
||||
for name
|
||||
do
|
||||
if groups=`id -Gn -- "$name"`; then
|
||||
echo "$name : $groups" || {
|
||||
status=$?
|
||||
if test $write_error = 0; then
|
||||
echo "$0: write error" >&2
|
||||
write_error=1
|
||||
fi
|
||||
}
|
||||
else
|
||||
status=$?
|
||||
if test $status = 0; then
|
||||
echo $name : $groups
|
||||
else
|
||||
fail=$status
|
||||
fi
|
||||
done
|
||||
fi
|
||||
exit $fail
|
||||
fi
|
||||
done
|
||||
|
||||
exit $status
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* install - copy files and set attributes
|
||||
Copyright (C) 89, 90, 91, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-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
|
||||
@@ -79,7 +79,8 @@ static bool install_file_in_file (const char *from, const char *to,
|
||||
static void get_ids (void);
|
||||
static void strip (char const *name);
|
||||
static void announce_mkdir (char const *dir, void *options);
|
||||
static int make_ancestor (char const *dir, void *options);
|
||||
static int make_ancestor (char const *dir, char const *component,
|
||||
void *options);
|
||||
void usage (int status);
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
@@ -458,11 +459,10 @@ install_file_in_file (const char *from, const char *to,
|
||||
return false;
|
||||
if (strip_files)
|
||||
strip (to);
|
||||
if (! change_attributes (to))
|
||||
if (x->preserve_timestamps && (strip_files || ! S_ISREG (from_sb.st_mode))
|
||||
&& ! change_timestamps (&from_sb, to))
|
||||
return false;
|
||||
if (x->preserve_timestamps && (strip_files || ! S_ISREG (from_sb.st_mode)))
|
||||
return change_timestamps (&from_sb, to);
|
||||
return true;
|
||||
return change_attributes (to);
|
||||
}
|
||||
|
||||
/* Copy file FROM into directory TO_DIR, keeping its same name,
|
||||
@@ -566,11 +566,10 @@ strip (char const *name)
|
||||
error (EXIT_FAILURE, errno, _("cannot run strip"));
|
||||
break;
|
||||
default: /* Parent. */
|
||||
/* Parent process. */
|
||||
while (pid != wait (&status)) /* Wait for kid to finish. */
|
||||
/* Do nothing. */ ;
|
||||
if (status)
|
||||
error (EXIT_FAILURE, 0, _("strip failed"));
|
||||
if (waitpid (pid, &status, 0) < 0)
|
||||
error (EXIT_FAILURE, errno, _("waiting for strip"));
|
||||
else if (! WIFEXITED (status) || WEXITSTATUS (status))
|
||||
error (EXIT_FAILURE, 0, _("strip process terminated abnormally"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -629,11 +628,13 @@ announce_mkdir (char const *dir, void *options)
|
||||
error (0, 0, _("creating directory %s"), quote (dir));
|
||||
}
|
||||
|
||||
/* Make ancestor directory DIR, with options OPTIONS. */
|
||||
/* Make ancestor directory DIR, whose last file name component is
|
||||
COMPONENT, with options OPTIONS. Assume the working directory is
|
||||
COMPONENT's parent. */
|
||||
static int
|
||||
make_ancestor (char const *dir, void *options)
|
||||
make_ancestor (char const *dir, char const *component, void *options)
|
||||
{
|
||||
int r = mkdir (dir, DEFAULT_MODE);
|
||||
int r = mkdir (component, DEFAULT_MODE);
|
||||
if (r == 0)
|
||||
announce_mkdir (dir, options);
|
||||
return r;
|
||||
@@ -681,7 +682,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-p, --preserve-timestamps apply access/modification times of SOURCE files\n\
|
||||
to corresponding destination files\n\
|
||||
-s, --strip strip symbol tables\n\
|
||||
-S, --suffix=SUFFIX override the usual backup suffix\n\
|
||||
-S, --suffix=SUFFIX override the usual backup suffix\n\
|
||||
-t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY\n\
|
||||
-T, --no-target-directory treat DEST as a normal file\n\
|
||||
-v, --verbose print the name of each directory as it is created\n\
|
||||
|
||||
13
src/join.c
13
src/join.c
@@ -599,7 +599,8 @@ add_field (int file, size_t field)
|
||||
|
||||
/* Convert a string of decimal digits, STR (the 1-based join field number),
|
||||
to an integral value. Upon successful conversion, return one less
|
||||
(the zero-based field number). If it cannot be converted, give a
|
||||
(the zero-based field number). Silently convert too-large values
|
||||
to SIZE_MAX - 1. Otherwise, if a value cannot be converted, give a
|
||||
diagnostic and exit. */
|
||||
|
||||
static size_t
|
||||
@@ -607,16 +608,12 @@ string_to_join_field (char const *str)
|
||||
{
|
||||
size_t result;
|
||||
unsigned long int val;
|
||||
verify (SIZE_MAX <= ULONG_MAX);
|
||||
|
||||
strtol_error s_err = xstrtoul (str, NULL, 10, &val, "");
|
||||
if (s_err == LONGINT_OVERFLOW || (s_err == LONGINT_OK && SIZE_MAX < val))
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("value %s is so large that it is not representable"),
|
||||
quote (str));
|
||||
}
|
||||
|
||||
if (s_err != LONGINT_OK || val == 0)
|
||||
val = SIZE_MAX;
|
||||
else if (s_err != LONGINT_OK || val == 0)
|
||||
error (EXIT_FAILURE, 0, _("invalid field number: %s"), quote (str));
|
||||
|
||||
result = val - 1;
|
||||
|
||||
25
src/ln.c
25
src/ln.c
@@ -112,8 +112,9 @@ target_directory_operand (char const *file)
|
||||
size_t blen = strlen (b);
|
||||
bool looks_like_a_dir = (blen == 0 || ISSLASH (b[blen - 1]));
|
||||
struct stat st;
|
||||
int err = ((dereference_dest_dir_symlinks ? stat : lstat) (file, &st) == 0
|
||||
? 0 : errno);
|
||||
int stat_result =
|
||||
(dereference_dest_dir_symlinks ? stat (file, &st) : lstat (file, &st));
|
||||
int err = (stat_result == 0 ? 0 : errno);
|
||||
bool is_a_dir = !err && S_ISDIR (st.st_mode);
|
||||
if (err && err != ENOENT)
|
||||
error (EXIT_FAILURE, err, _("accessing %s"), quote (file));
|
||||
@@ -132,7 +133,7 @@ do_link (const char *source, const char *dest)
|
||||
struct stat source_stats;
|
||||
struct stat dest_stats;
|
||||
char *dest_backup = NULL;
|
||||
bool lstat_ok = false;
|
||||
bool dest_lstat_ok = false;
|
||||
bool source_is_dir = false;
|
||||
bool ok;
|
||||
|
||||
@@ -170,8 +171,8 @@ do_link (const char *source, const char *dest)
|
||||
|
||||
if (remove_existing_files || interactive || backup_type != no_backups)
|
||||
{
|
||||
lstat_ok = (lstat (dest, &dest_stats) == 0);
|
||||
if (!lstat_ok && errno != ENOENT)
|
||||
dest_lstat_ok = (lstat (dest, &dest_stats) == 0);
|
||||
if (!dest_lstat_ok && errno != ENOENT)
|
||||
{
|
||||
error (0, errno, _("accessing %s"), quote (dest));
|
||||
return false;
|
||||
@@ -183,8 +184,14 @@ do_link (const char *source, const char *dest)
|
||||
(with --backup, it just renames any existing destination file)
|
||||
But if the source and destination are the same, don't remove
|
||||
anything and fail right here. */
|
||||
if (remove_existing_files
|
||||
&& lstat_ok
|
||||
if ((remove_existing_files
|
||||
/* Ensure that "ln --backup f f" fails here, with the
|
||||
"... same file" diagnostic, below. Otherwise, subsequent
|
||||
code would give a misleading "file not found" diagnostic.
|
||||
This case is different than the others handled here, since
|
||||
the command in question doesn't use --force. */
|
||||
|| (!symbolic_link && backup_type != no_backups))
|
||||
&& dest_lstat_ok
|
||||
/* Allow `ln -sf --backup k k' to succeed in creating the
|
||||
self-referential symlink, but don't allow the hard-linking
|
||||
equivalent: `ln -f k k' (with or without --backup) to get
|
||||
@@ -204,7 +211,7 @@ do_link (const char *source, const char *dest)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lstat_ok)
|
||||
if (dest_lstat_ok)
|
||||
{
|
||||
if (S_ISDIR (dest_stats.st_mode))
|
||||
{
|
||||
@@ -254,7 +261,7 @@ do_link (const char *source, const char *dest)
|
||||
Try to unlink DEST even if we may have backed it up successfully.
|
||||
In some unusual cases (when DEST and DEST_BACKUP are hard-links
|
||||
that refer to the same file), rename succeeds and DEST remains.
|
||||
If we didn't remove DEST in that case, the subsequent LINKFUNC
|
||||
If we didn't remove DEST in that case, the subsequent symlink or link
|
||||
call would fail. */
|
||||
|
||||
if (!ok && errno == EEXIST && (remove_existing_files || dest_backup))
|
||||
|
||||
267
src/ls.c
267
src/ls.c
@@ -1,5 +1,5 @@
|
||||
/* `dir', `vdir' and `ls' directory listing programs for GNU.
|
||||
Copyright (C) 85, 88, 90, 91, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 85, 88, 90, 91, 1995-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
|
||||
@@ -93,6 +93,7 @@
|
||||
#include "ls.h"
|
||||
#include "lstat.h"
|
||||
#include "mbswidth.h"
|
||||
#include "mpsort.h"
|
||||
#include "obstack.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
@@ -155,22 +156,23 @@ struct fileinfo
|
||||
/* The file name. */
|
||||
char *name;
|
||||
|
||||
struct stat stat;
|
||||
bool stat_ok;
|
||||
|
||||
/* For symbolic link, name of the file linked to, otherwise zero. */
|
||||
char *linkname;
|
||||
|
||||
struct stat stat;
|
||||
|
||||
enum filetype filetype;
|
||||
|
||||
/* For symbolic link and long listing, st_mode of file linked to, otherwise
|
||||
zero. */
|
||||
mode_t linkmode;
|
||||
|
||||
bool stat_ok;
|
||||
|
||||
/* For symbolic link and color printing, true if linked-to file
|
||||
exists, otherwise false. */
|
||||
bool linkok;
|
||||
|
||||
enum filetype filetype;
|
||||
|
||||
#if USE_ACL
|
||||
/* For long listings, true if the file has an access control list. */
|
||||
bool have_acl;
|
||||
@@ -266,18 +268,23 @@ static Hash_table *active_dir_set;
|
||||
|
||||
/* The table of files in the current directory:
|
||||
|
||||
`files' points to a vector of `struct fileinfo', one per file.
|
||||
`nfiles' is the number of elements space has been allocated for.
|
||||
`files_index' is the number actually in use. */
|
||||
`cwd_file' points to a vector of `struct fileinfo', one per file.
|
||||
`cwd_n_alloc' is the number of elements space has been allocated for.
|
||||
`cwd_n_used' is the number actually in use. */
|
||||
|
||||
/* Address of block containing the files that are described. */
|
||||
static struct fileinfo *files; /* FIXME: rename this to e.g. cwd_file */
|
||||
static struct fileinfo *cwd_file;
|
||||
|
||||
/* Length of block that `files' points to, measured in files. */
|
||||
static size_t nfiles; /* FIXME: rename this to e.g. cwd_n_alloc */
|
||||
/* Length of block that `cwd_file' points to, measured in files. */
|
||||
static size_t cwd_n_alloc;
|
||||
|
||||
/* Index of first unused in `files'. */
|
||||
static size_t files_index; /* FIXME: rename this to e.g. cwd_n_used */
|
||||
/* Index of first unused slot in `cwd_file'. */
|
||||
static size_t cwd_n_used;
|
||||
|
||||
/* Vector of pointers to files, in proper sorted order, and the number
|
||||
of entries allocated for it. */
|
||||
static void **sorted_file;
|
||||
static size_t sorted_file_alloc;
|
||||
|
||||
/* When true, in a color listing, color each symlink name according to the
|
||||
type of file it points to. Otherwise, color them according to the `ln'
|
||||
@@ -863,11 +870,11 @@ static size_t dired_pos;
|
||||
|
||||
/* Write S to STREAM and increment DIRED_POS by S_LEN. */
|
||||
#define DIRED_FPUTS(s, stream, s_len) \
|
||||
do {fputs ((s), (stream)); dired_pos += s_len;} while (0)
|
||||
do {fputs (s, stream); dired_pos += s_len;} while (0)
|
||||
|
||||
/* Like DIRED_FPUTS, but for use when S is a literal string. */
|
||||
#define DIRED_FPUTS_LITERAL(s, stream) \
|
||||
do {fputs ((s), (stream)); dired_pos += sizeof((s)) - 1;} while (0)
|
||||
do {fputs (s, stream); dired_pos += sizeof (s) - 1;} while (0)
|
||||
|
||||
#define DIRED_INDENT() \
|
||||
do \
|
||||
@@ -892,7 +899,7 @@ static struct obstack subdired_obstack;
|
||||
do \
|
||||
{ \
|
||||
if (dired) \
|
||||
obstack_grow ((obs), &dired_pos, sizeof (dired_pos)); \
|
||||
obstack_grow (obs, &dired_pos, sizeof (dired_pos)); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
@@ -1113,8 +1120,29 @@ main (int argc, char **argv)
|
||||
int n_files;
|
||||
|
||||
/* The signals that are trapped, and the number of such signals. */
|
||||
static int const sig[] = { SIGHUP, SIGINT, SIGPIPE,
|
||||
SIGQUIT, SIGTERM, SIGTSTP };
|
||||
static int const sig[] =
|
||||
{
|
||||
/* This one is handled specially. */
|
||||
SIGTSTP,
|
||||
|
||||
/* The usual suspects. */
|
||||
SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM,
|
||||
#ifdef SIGPOLL
|
||||
SIGPOLL,
|
||||
#endif
|
||||
#ifdef SIGPROF
|
||||
SIGPROF,
|
||||
#endif
|
||||
#ifdef SIGVTALRM
|
||||
SIGVTALRM,
|
||||
#endif
|
||||
#ifdef SIGXCPU
|
||||
SIGXCPU,
|
||||
#endif
|
||||
#ifdef SIGXFSZ
|
||||
SIGXFSZ,
|
||||
#endif
|
||||
};
|
||||
enum { nsigs = sizeof sig / sizeof sig[0] };
|
||||
|
||||
#if ! SA_NOCLDSTOP
|
||||
@@ -1231,9 +1259,9 @@ main (int argc, char **argv)
|
||||
obstack_init (&subdired_obstack);
|
||||
}
|
||||
|
||||
nfiles = 100;
|
||||
files = xnmalloc (nfiles, sizeof *files);
|
||||
files_index = 0;
|
||||
cwd_n_alloc = 100;
|
||||
cwd_file = xnmalloc (cwd_n_alloc, sizeof *cwd_file);
|
||||
cwd_n_used = 0;
|
||||
|
||||
clear_files ();
|
||||
|
||||
@@ -1251,19 +1279,19 @@ main (int argc, char **argv)
|
||||
gobble_file (argv[i++], unknown, NOT_AN_INODE_NUMBER, true, "");
|
||||
while (i < argc);
|
||||
|
||||
if (files_index)
|
||||
if (cwd_n_used)
|
||||
{
|
||||
sort_files ();
|
||||
if (!immediate_dirs)
|
||||
extract_dirs_from_files (NULL, true);
|
||||
/* `files_index' might be zero now. */
|
||||
/* `cwd_n_used' might be zero now. */
|
||||
}
|
||||
|
||||
/* In the following if/else blocks, it is sufficient to test `pending_dirs'
|
||||
(and not pending_dirs->name) because there may be no markers in the queue
|
||||
at this point. A marker may be enqueued when extract_dirs_from_files is
|
||||
called with a non-empty string or via print_dir. */
|
||||
if (files_index)
|
||||
if (cwd_n_used)
|
||||
{
|
||||
print_current_files ();
|
||||
if (pending_dirs)
|
||||
@@ -2314,6 +2342,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
|
||||
{
|
||||
file_failure (command_line_arg,
|
||||
_("cannot determine device and inode of %s"), name);
|
||||
closedir (dirp);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2323,13 +2352,14 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
|
||||
{
|
||||
error (0, 0, _("%s: not listing already-listed directory"),
|
||||
quotearg_colon (name));
|
||||
closedir (dirp);
|
||||
return;
|
||||
}
|
||||
|
||||
DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino);
|
||||
}
|
||||
|
||||
/* Read the directory entries, and insert the subfiles into the `files'
|
||||
/* Read the directory entries, and insert the subfiles into the `cwd_file'
|
||||
table. */
|
||||
|
||||
clear_files ();
|
||||
@@ -2418,7 +2448,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
|
||||
DIRED_PUTCHAR ('\n');
|
||||
}
|
||||
|
||||
if (files_index)
|
||||
if (cwd_n_used)
|
||||
print_current_files ();
|
||||
}
|
||||
|
||||
@@ -2472,7 +2502,7 @@ unsigned_file_size (off_t size)
|
||||
return size + (size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN + 1);
|
||||
}
|
||||
|
||||
/* Enter and remove entries in the table `files'. */
|
||||
/* Enter and remove entries in the table `cwd_file'. */
|
||||
|
||||
/* Empty the table of files. */
|
||||
|
||||
@@ -2481,13 +2511,14 @@ clear_files (void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < files_index; i++)
|
||||
for (i = 0; i < cwd_n_used; i++)
|
||||
{
|
||||
free (files[i].name);
|
||||
free (files[i].linkname);
|
||||
struct fileinfo *f = sorted_file[i];
|
||||
free (f->name);
|
||||
free (f->linkname);
|
||||
}
|
||||
|
||||
files_index = 0;
|
||||
cwd_n_used = 0;
|
||||
#if USE_ACL
|
||||
any_has_acl = false;
|
||||
#endif
|
||||
@@ -2517,13 +2548,13 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
which is not used for command line arguments. */
|
||||
assert (! command_line_arg || inode == NOT_AN_INODE_NUMBER);
|
||||
|
||||
if (files_index == nfiles)
|
||||
if (cwd_n_used == cwd_n_alloc)
|
||||
{
|
||||
files = xnrealloc (files, nfiles, 2 * sizeof *files);
|
||||
nfiles *= 2;
|
||||
cwd_file = xnrealloc (cwd_file, cwd_n_alloc, 2 * sizeof *cwd_file);
|
||||
cwd_n_alloc *= 2;
|
||||
}
|
||||
|
||||
f = &files[files_index];
|
||||
f = &cwd_file[cwd_n_used];
|
||||
memset (f, '\0', sizeof *f);
|
||||
f->stat.st_ino = inode;
|
||||
f->filetype = type;
|
||||
@@ -2534,14 +2565,15 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
direct.d_type), we have to stat it in order to indicate
|
||||
sticky and/or other-writable attributes. */
|
||||
|| (type == directory && print_with_color)
|
||||
|| (print_inode
|
||||
&& (inode == NOT_AN_INODE_NUMBER
|
||||
/* When dereferencing symlinks, the inode must come from
|
||||
stat, but readdir provides the inode of lstat. Command
|
||||
line dereferences are already taken care of by the above
|
||||
assertion that the inode number is not yet known. */
|
||||
|| (dereference == DEREF_ALWAYS
|
||||
&& (type == symbolic_link || type == unknown))))
|
||||
/* When dereferencing symlinks, the inode and type must come from
|
||||
stat, but readdir provides the inode and type of lstat. */
|
||||
|| ((print_inode || format_needs_type)
|
||||
&& (type == symbolic_link || type == unknown)
|
||||
&& (dereference == DEREF_ALWAYS
|
||||
|| (command_line_arg && dereference != DEREF_NEVER)))
|
||||
/* Command line dereferences are already taken care of by the above
|
||||
assertion that the inode number is not yet known. */
|
||||
|| (print_inode && inode == NOT_AN_INODE_NUMBER)
|
||||
|| (format_needs_type
|
||||
&& (type == unknown || command_line_arg
|
||||
/* --indicator-style=classify (aka -F)
|
||||
@@ -2614,7 +2646,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
return 0;
|
||||
|
||||
f->name = xstrdup (name);
|
||||
files_index++;
|
||||
cwd_n_used++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2747,7 +2779,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
}
|
||||
|
||||
f->name = xstrdup (name);
|
||||
files_index++;
|
||||
cwd_n_used++;
|
||||
|
||||
return blocks;
|
||||
}
|
||||
@@ -2766,7 +2798,7 @@ is_directory (const struct fileinfo *f)
|
||||
static void
|
||||
get_link_name (char const *filename, struct fileinfo *f, bool command_line_arg)
|
||||
{
|
||||
f->linkname = xreadlink (filename, f->stat.st_size);
|
||||
f->linkname = xreadlink_with_size (filename, f->stat.st_size);
|
||||
if (f->linkname == NULL)
|
||||
file_failure (command_line_arg, _("cannot read symbolic link %s"),
|
||||
filename);
|
||||
@@ -2812,7 +2844,7 @@ basename_is_dot_or_dotdot (const char *name)
|
||||
return dot_or_dotdot (base);
|
||||
}
|
||||
|
||||
/* Remove any entries from FILES that are for directories,
|
||||
/* Remove any entries from CWD_FILE that are for directories,
|
||||
and queue them to be listed as directories instead.
|
||||
DIRNAME is the prefix to prepend to each dirname
|
||||
to make it correct relative to ls's working dir;
|
||||
@@ -2837,39 +2869,37 @@ extract_dirs_from_files (char const *dirname, bool command_line_arg)
|
||||
|
||||
/* Queue the directories last one first, because queueing reverses the
|
||||
order. */
|
||||
for (i = files_index; i-- != 0; )
|
||||
if (is_directory (&files[i])
|
||||
&& (! ignore_dot_and_dot_dot
|
||||
|| ! basename_is_dot_or_dotdot (files[i].name)))
|
||||
{
|
||||
if (!dirname || files[i].name[0] == '/')
|
||||
{
|
||||
queue_directory (files[i].name, files[i].linkname,
|
||||
command_line_arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *name = file_name_concat (dirname, files[i].name, NULL);
|
||||
queue_directory (name, files[i].linkname, command_line_arg);
|
||||
free (name);
|
||||
}
|
||||
if (files[i].filetype == arg_directory)
|
||||
free (files[i].name);
|
||||
}
|
||||
for (i = cwd_n_used; i-- != 0; )
|
||||
{
|
||||
struct fileinfo *f = sorted_file[i];
|
||||
|
||||
if (is_directory (f)
|
||||
&& (! ignore_dot_and_dot_dot
|
||||
|| ! basename_is_dot_or_dotdot (f->name)))
|
||||
{
|
||||
if (!dirname || f->name[0] == '/')
|
||||
queue_directory (f->name, f->linkname, command_line_arg);
|
||||
else
|
||||
{
|
||||
char *name = file_name_concat (dirname, f->name, NULL);
|
||||
queue_directory (name, f->linkname, command_line_arg);
|
||||
free (name);
|
||||
}
|
||||
if (f->filetype == arg_directory)
|
||||
free (f->name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now delete the directories from the table, compacting all the remaining
|
||||
entries. */
|
||||
|
||||
for (i = 0, j = 0; i < files_index; i++)
|
||||
for (i = 0, j = 0; i < cwd_n_used; i++)
|
||||
{
|
||||
if (files[i].filetype != arg_directory)
|
||||
{
|
||||
if (j < i)
|
||||
files[j] = files[i];
|
||||
++j;
|
||||
}
|
||||
struct fileinfo *f = sorted_file[i];
|
||||
sorted_file[j] = f;
|
||||
j += (f->filetype != arg_directory);
|
||||
}
|
||||
files_index = j;
|
||||
cwd_n_used = j;
|
||||
}
|
||||
|
||||
/* Use strcoll to compare strings in this locale. If an error occurs,
|
||||
@@ -3091,6 +3121,15 @@ static qsortFunc sort_functions[][2][2][2] =
|
||||
verify (ARRAY_CARDINALITY (sort_functions)
|
||||
== sort_numtypes + time_numtypes - 1 );
|
||||
|
||||
/* Set up SORTED_FILE to point to the in-use entries in CWD_FILE, in order. */
|
||||
|
||||
static void
|
||||
initialize_ordering_vector (void)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < cwd_n_used; i++)
|
||||
sorted_file[i] = &cwd_file[i];
|
||||
}
|
||||
|
||||
/* Sort the files now in the table. */
|
||||
|
||||
@@ -3099,6 +3138,15 @@ sort_files (void)
|
||||
{
|
||||
bool use_strcmp;
|
||||
|
||||
if (sorted_file_alloc < cwd_n_used + cwd_n_used / 2)
|
||||
{
|
||||
free (sorted_file);
|
||||
sorted_file = xnmalloc (cwd_n_used, 3 * sizeof *sorted_file);
|
||||
sorted_file_alloc = 3 * cwd_n_used;
|
||||
}
|
||||
|
||||
initialize_ordering_vector ();
|
||||
|
||||
if (sort_type == sort_none)
|
||||
return;
|
||||
|
||||
@@ -3113,13 +3161,14 @@ sort_files (void)
|
||||
{
|
||||
use_strcmp = true;
|
||||
assert (sort_type != sort_version);
|
||||
initialize_ordering_vector ();
|
||||
}
|
||||
|
||||
/* When sort_type == sort_time, use time_type as subindex. */
|
||||
qsort (files, files_index, sizeof *files,
|
||||
sort_functions[sort_type + (sort_type == sort_time ? time_type : 0)]
|
||||
[use_strcmp][sort_reverse]
|
||||
[directories_first]);
|
||||
mpsort ((void const **) sorted_file, cwd_n_used,
|
||||
sort_functions[sort_type + (sort_type == sort_time ? time_type : 0)]
|
||||
[use_strcmp][sort_reverse]
|
||||
[directories_first]);
|
||||
}
|
||||
|
||||
/* List all the files now in the table. */
|
||||
@@ -3132,9 +3181,9 @@ print_current_files (void)
|
||||
switch (format)
|
||||
{
|
||||
case one_per_line:
|
||||
for (i = 0; i < files_index; i++)
|
||||
for (i = 0; i < cwd_n_used; i++)
|
||||
{
|
||||
print_file_name_and_frills (files + i);
|
||||
print_file_name_and_frills (sorted_file[i]);
|
||||
putchar ('\n');
|
||||
}
|
||||
break;
|
||||
@@ -3152,9 +3201,9 @@ print_current_files (void)
|
||||
break;
|
||||
|
||||
case long_format:
|
||||
for (i = 0; i < files_index; i++)
|
||||
for (i = 0; i < cwd_n_used; i++)
|
||||
{
|
||||
print_long_format (files + i);
|
||||
print_long_format (sorted_file[i]);
|
||||
DIRED_PUTCHAR ('\n');
|
||||
}
|
||||
break;
|
||||
@@ -3604,8 +3653,7 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
|
||||
reach its end, replacing each non-printable multibyte
|
||||
character with a single question mark. */
|
||||
{
|
||||
mbstate_t mbstate;
|
||||
memset (&mbstate, 0, sizeof mbstate);
|
||||
mbstate_t mbstate = { 0, };
|
||||
do
|
||||
{
|
||||
wchar_t wc;
|
||||
@@ -3948,7 +3996,7 @@ print_many_per_line (void)
|
||||
|
||||
/* Calculate the number of rows that will be in each column except possibly
|
||||
for a short column on the right. */
|
||||
size_t rows = files_index / cols + (files_index % cols != 0);
|
||||
size_t rows = cwd_n_used / cols + (cwd_n_used % cols != 0);
|
||||
|
||||
for (row = 0; row < rows; row++)
|
||||
{
|
||||
@@ -3959,12 +4007,13 @@ print_many_per_line (void)
|
||||
/* Print the next row. */
|
||||
while (1)
|
||||
{
|
||||
size_t name_length = length_of_file_name_and_frills (files + filesno);
|
||||
struct fileinfo const *f = sorted_file[filesno];
|
||||
size_t name_length = length_of_file_name_and_frills (f);
|
||||
size_t max_name_length = line_fmt->col_arr[col++];
|
||||
print_file_name_and_frills (files + filesno);
|
||||
print_file_name_and_frills (f);
|
||||
|
||||
filesno += rows;
|
||||
if (filesno >= files_index)
|
||||
if (filesno >= cwd_n_used)
|
||||
break;
|
||||
|
||||
indent (pos + name_length, pos + max_name_length);
|
||||
@@ -3981,15 +4030,16 @@ print_horizontal (void)
|
||||
size_t pos = 0;
|
||||
size_t cols = calculate_columns (false);
|
||||
struct column_info const *line_fmt = &column_info[cols - 1];
|
||||
size_t name_length = length_of_file_name_and_frills (files);
|
||||
size_t name_length = length_of_file_name_and_frills (cwd_file);
|
||||
size_t max_name_length = line_fmt->col_arr[0];
|
||||
|
||||
/* Print first entry. */
|
||||
print_file_name_and_frills (files);
|
||||
print_file_name_and_frills (cwd_file);
|
||||
|
||||
/* Now the rest. */
|
||||
for (filesno = 1; filesno < files_index; ++filesno)
|
||||
for (filesno = 1; filesno < cwd_n_used; ++filesno)
|
||||
{
|
||||
struct fileinfo const *f;
|
||||
size_t col = filesno % cols;
|
||||
|
||||
if (col == 0)
|
||||
@@ -4003,9 +4053,10 @@ print_horizontal (void)
|
||||
pos += max_name_length;
|
||||
}
|
||||
|
||||
print_file_name_and_frills (files + filesno);
|
||||
f = sorted_file[filesno];
|
||||
print_file_name_and_frills (f);
|
||||
|
||||
name_length = length_of_file_name_and_frills (files + filesno);
|
||||
name_length = length_of_file_name_and_frills (f);
|
||||
max_name_length = line_fmt->col_arr[col];
|
||||
}
|
||||
putchar ('\n');
|
||||
@@ -4017,9 +4068,10 @@ print_with_commas (void)
|
||||
size_t filesno;
|
||||
size_t pos = 0;
|
||||
|
||||
for (filesno = 0; filesno < files_index; filesno++)
|
||||
for (filesno = 0; filesno < cwd_n_used; filesno++)
|
||||
{
|
||||
size_t len = length_of_file_name_and_frills (files + filesno);
|
||||
struct fileinfo const *f = sorted_file[filesno];
|
||||
size_t len = length_of_file_name_and_frills (f);
|
||||
|
||||
if (filesno != 0)
|
||||
{
|
||||
@@ -4040,7 +4092,7 @@ print_with_commas (void)
|
||||
putchar (separator);
|
||||
}
|
||||
|
||||
print_file_name_and_frills (files + filesno);
|
||||
print_file_name_and_frills (f);
|
||||
pos += len;
|
||||
}
|
||||
putchar ('\n');
|
||||
@@ -4098,7 +4150,7 @@ static void
|
||||
init_column_info (void)
|
||||
{
|
||||
size_t i;
|
||||
size_t max_cols = MIN (max_idx, files_index);
|
||||
size_t max_cols = MIN (max_idx, cwd_n_used);
|
||||
|
||||
/* Currently allocated columns in column_info. */
|
||||
static size_t column_info_alloc;
|
||||
@@ -4165,20 +4217,21 @@ init_column_info (void)
|
||||
static size_t
|
||||
calculate_columns (bool by_columns)
|
||||
{
|
||||
size_t filesno; /* Index into files. */
|
||||
size_t filesno; /* Index into cwd_file. */
|
||||
size_t cols; /* Number of files across. */
|
||||
|
||||
/* Normally the maximum number of columns is determined by the
|
||||
screen width. But if few files are available this might limit it
|
||||
as well. */
|
||||
size_t max_cols = MIN (max_idx, files_index);
|
||||
size_t max_cols = MIN (max_idx, cwd_n_used);
|
||||
|
||||
init_column_info ();
|
||||
|
||||
/* Compute the maximum number of possible columns. */
|
||||
for (filesno = 0; filesno < files_index; ++filesno)
|
||||
for (filesno = 0; filesno < cwd_n_used; ++filesno)
|
||||
{
|
||||
size_t name_length = length_of_file_name_and_frills (files + filesno);
|
||||
struct fileinfo const *f = sorted_file[filesno];
|
||||
size_t name_length = length_of_file_name_and_frills (f);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < max_cols; ++i)
|
||||
@@ -4186,7 +4239,7 @@ calculate_columns (bool by_columns)
|
||||
if (column_info[i].valid_len)
|
||||
{
|
||||
size_t idx = (by_columns
|
||||
? filesno / ((files_index + i) / (i + 1))
|
||||
? filesno / ((cwd_n_used + i) / (i + 1))
|
||||
: filesno % (i + 1));
|
||||
size_t real_length = name_length + (idx == i ? 0 : 2);
|
||||
|
||||
@@ -4271,6 +4324,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-h, --human-readable with -l, print sizes in human readable format\n\
|
||||
(e.g., 1K 234M 2G)\n\
|
||||
--si likewise, but use powers of 1000 not 1024\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-H, --dereference-command-line\n\
|
||||
follow symbolic links listed on the command line\n\
|
||||
--dereference-command-line-symlink-to-dir\n\
|
||||
@@ -4280,7 +4335,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
(overridden by -a or -A)\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--indicator-style=WORD append indicator with style WORD to entry names:\n\
|
||||
--indicator-style=WORD append indicator with style WORD to entry names:\n\
|
||||
none (default), slash (-p),\n\
|
||||
file-type (--file-type), classify (-F)\n\
|
||||
-i, --inode print the index number of each file\n\
|
||||
@@ -4313,7 +4368,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
fputs (_("\
|
||||
-r, --reverse reverse order while sorting\n\
|
||||
-R, --recursive list subdirectories recursively\n\
|
||||
-s, --size with -l, print size of each file, in blocks\n\
|
||||
-s, --size print the size of each file, in blocks\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-S sort by file size\n\
|
||||
@@ -4332,6 +4387,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
non-recent files and FORMAT2 to recent files;\n\
|
||||
if STYLE is prefixed with `posix-', STYLE\n\
|
||||
takes effect only outside the POSIX locale\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-t sort by modification time\n\
|
||||
-T, --tabsize=COLS assume tab stops at each COLS instead of 8\n\
|
||||
"), stdout);
|
||||
|
||||
15
src/mkdir.c
15
src/mkdir.c
@@ -81,7 +81,7 @@ struct mkdir_options
|
||||
{
|
||||
/* Function to make an ancestor, or NULL if ancestors should not be
|
||||
made. */
|
||||
int (*make_ancestor_function) (char const *, void *);
|
||||
int (*make_ancestor_function) (char const *, char const *, void *);
|
||||
|
||||
/* Mode for ancestor directory. */
|
||||
mode_t ancestor_mode;
|
||||
@@ -105,15 +105,16 @@ announce_mkdir (char const *dir, void *options)
|
||||
error (0, 0, o->created_directory_format, quote (dir));
|
||||
}
|
||||
|
||||
/* Make ancestor directory DIR, with options OPTIONS. Return 0 if
|
||||
successful and the resulting directory is readable, 1 if successful
|
||||
but the resulting directory is not readable, -1 (setting errno)
|
||||
otherwise. */
|
||||
/* Make ancestor directory DIR, whose last component is COMPONENT,
|
||||
with options OPTIONS. Assume the working directory is COMPONENT's
|
||||
parent. Return 0 if successful and the resulting directory is
|
||||
readable, 1 if successful but the resulting directory is not
|
||||
readable, -1 (setting errno) otherwise. */
|
||||
static int
|
||||
make_ancestor (char const *dir, void *options)
|
||||
make_ancestor (char const *dir, char const *component, void *options)
|
||||
{
|
||||
struct mkdir_options const *o = options;
|
||||
int r = mkdir (dir, o->ancestor_mode);
|
||||
int r = mkdir (component, o->ancestor_mode);
|
||||
if (r == 0)
|
||||
{
|
||||
r = ! (o->ancestor_mode & S_IRUSR);
|
||||
|
||||
5
src/mv.c
5
src/mv.c
@@ -1,5 +1,5 @@
|
||||
/* mv -- move or rename files
|
||||
Copyright (C) 86, 89, 90, 91, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 89, 90, 91, 1995-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
|
||||
@@ -94,10 +94,11 @@ rm_option_init (struct rm_options *x)
|
||||
x->ignore_missing_files = false;
|
||||
x->root_dev_ino = NULL;
|
||||
x->recursive = true;
|
||||
x->one_file_system = false;
|
||||
|
||||
/* Should we prompt for removal, too? No. Prompting for the `move'
|
||||
part is enough. It implies removal. */
|
||||
x->interactive = 0;
|
||||
x->interactive = RMI_NEVER;
|
||||
x->stdin_tty = false;
|
||||
|
||||
x->verbose = false;
|
||||
|
||||
23
src/nl.c
23
src/nl.c
@@ -1,5 +1,5 @@
|
||||
/* nl -- number lines of files
|
||||
Copyright (C) 89, 92, 1995-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 92, 1995-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
|
||||
@@ -64,16 +64,16 @@ enum section
|
||||
char *program_name;
|
||||
|
||||
/* Format of body lines (-b). */
|
||||
static char *body_type = "t";
|
||||
static char const *body_type = "t";
|
||||
|
||||
/* Format of header lines (-h). */
|
||||
static char *header_type = "n";
|
||||
static char const *header_type = "n";
|
||||
|
||||
/* Format of footer lines (-f). */
|
||||
static char *footer_type = "n";
|
||||
static char const *footer_type = "n";
|
||||
|
||||
/* Format currently being used (body, header, or footer). */
|
||||
static char *current_type;
|
||||
static char const *current_type;
|
||||
|
||||
/* Regex for body lines to number (-bp). */
|
||||
static struct re_pattern_buffer body_regex;
|
||||
@@ -93,7 +93,7 @@ static char footer_fastmap[UCHAR_MAX + 1];
|
||||
static struct re_pattern_buffer *current_regex = NULL;
|
||||
|
||||
/* Separator string to print after line number (-s). */
|
||||
static char *separator_str = "\t";
|
||||
static char const *separator_str = "\t";
|
||||
|
||||
/* Input section delimiter string (-d). */
|
||||
static char const *section_del = DEFAULT_SECTION_DELIMITERS;
|
||||
@@ -217,7 +217,7 @@ second character implies :. Type \\\\ for \\. STYLE is one of:\n\
|
||||
t number only nonempty lines\n\
|
||||
n number no lines\n\
|
||||
pBRE number only lines that contain a match for the basic regular\n\
|
||||
expression, BRE\n\
|
||||
expression, BRE\n\
|
||||
\n\
|
||||
FORMAT is one of:\n\
|
||||
\n\
|
||||
@@ -235,9 +235,10 @@ FORMAT is one of:\n\
|
||||
according to `optarg'. */
|
||||
|
||||
static bool
|
||||
build_type_arg (char **typep, struct re_pattern_buffer *regexp, char *fastmap)
|
||||
build_type_arg (char const **typep,
|
||||
struct re_pattern_buffer *regexp, char *fastmap)
|
||||
{
|
||||
const char *errmsg;
|
||||
char const *errmsg;
|
||||
bool rval = true;
|
||||
|
||||
switch (*optarg)
|
||||
@@ -347,7 +348,7 @@ proc_text (void)
|
||||
break;
|
||||
case 'p':
|
||||
switch (re_search (current_regex, line_buf.buffer, line_buf.length - 1,
|
||||
0, line_buf.length - 1, (struct re_registers *) 0))
|
||||
0, line_buf.length - 1, NULL))
|
||||
{
|
||||
case -2:
|
||||
error (EXIT_FAILURE, errno, _("error in regular expression search"));
|
||||
@@ -414,7 +415,7 @@ process_file (FILE *fp)
|
||||
Return true if successful. */
|
||||
|
||||
static bool
|
||||
nl_file (const char *file)
|
||||
nl_file (char const *file)
|
||||
{
|
||||
FILE *stream;
|
||||
|
||||
|
||||
8
src/od.c
8
src/od.c
@@ -358,6 +358,8 @@ An OFFSET operand means -j OFFSET. LABEL is the pseudo-address\n\
|
||||
at first byte printed, incremented when dump is progressing.\n\
|
||||
For OFFSET and LABEL, a 0x or 0X prefix indicates hexadecimal;\n\
|
||||
suffixes may be . for octal and b for multiply by 512.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
TYPE is made up of one or more of these specifications:\n\
|
||||
\n\
|
||||
@@ -388,7 +390,7 @@ of output. \
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--string without a number implies 3. --width without a number\n\
|
||||
implies 32. By default, od uses -A o -t d2 -w 16.\n\
|
||||
implies 32. By default, od uses -A o -t d2 -w16.\n\
|
||||
"), stdout);
|
||||
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
|
||||
}
|
||||
@@ -926,7 +928,7 @@ open_next_file (void)
|
||||
while (in_stream == NULL);
|
||||
|
||||
if (limit_bytes_to_format & !flag_dump_strings)
|
||||
SETVBUF (in_stream, NULL, _IONBF, 0);
|
||||
setvbuf (in_stream, NULL, _IONBF, 0);
|
||||
|
||||
return ok;
|
||||
}
|
||||
@@ -1175,7 +1177,7 @@ write_block (uintmax_t current_offset, size_t n_bytes,
|
||||
static bool first = true;
|
||||
static bool prev_pair_equal = false;
|
||||
|
||||
#define EQUAL_BLOCKS(b1, b2) (memcmp ((b1), (b2), bytes_per_block) == 0)
|
||||
#define EQUAL_BLOCKS(b1, b2) (memcmp (b1, b2, bytes_per_block) == 0)
|
||||
|
||||
if (abbreviate_duplicate_blocks
|
||||
&& !first && n_bytes == bytes_per_block
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user