mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
349 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc8689a07c | ||
|
|
bec53850b7 | ||
|
|
541b026b11 | ||
|
|
606f54d157 | ||
|
|
6e2b4769cc | ||
|
|
3dc8657648 | ||
|
|
30039cb23a | ||
|
|
c0f02a8f5b | ||
|
|
a51af43294 | ||
|
|
ecb2fecdf9 | ||
|
|
4cb2742d70 | ||
|
|
26fd96a96c | ||
|
|
6259593ac7 | ||
|
|
f77a6352fb | ||
|
|
c45fcb2ed2 | ||
|
|
e0cce6b62a | ||
|
|
7ebbeeb03d | ||
|
|
7b2064216c | ||
|
|
5a1d00e450 | ||
|
|
ff42adb55e | ||
|
|
193449b173 | ||
|
|
91e69cd2d0 | ||
|
|
1913bfcf57 | ||
|
|
5d3fd24f42 | ||
|
|
425b8a2f53 | ||
|
|
07a69fc3ba | ||
|
|
a46f34bb56 | ||
|
|
bf73a7602a | ||
|
|
48cd67663d | ||
|
|
dda89eb5d3 | ||
|
|
c07a7d999e | ||
|
|
b8d1b00e21 | ||
|
|
c7f422940a | ||
|
|
0cafa1524f | ||
|
|
00a34a05f5 | ||
|
|
9a50494875 | ||
|
|
44c9578a08 | ||
|
|
ab4ffc8503 | ||
|
|
c1cf5148a1 | ||
|
|
7b92e9fb26 | ||
|
|
9d8890d872 | ||
|
|
fea833591b | ||
|
|
c877c7c1ee | ||
|
|
6cd2d5e533 | ||
|
|
fcfba90d0d | ||
|
|
e397ba1a31 | ||
|
|
f3bcb59ebd | ||
|
|
79c628901d | ||
|
|
f2e70e2d19 | ||
|
|
df5fa309c2 | ||
|
|
45411e3fc6 | ||
|
|
feda512e97 | ||
|
|
49912bac28 | ||
|
|
9907b6f5dc | ||
|
|
3bbdb39388 | ||
|
|
10be42f033 | ||
|
|
d9dc02b09a | ||
|
|
7f57ac2d20 | ||
|
|
9b6c25510b | ||
|
|
a357cfb021 | ||
|
|
e82af7c2e6 | ||
|
|
430663cb35 | ||
|
|
8e3b0feb1d | ||
|
|
ad4a9d02f5 | ||
|
|
01e52b9adc | ||
|
|
0a33c5384f | ||
|
|
e298046727 | ||
|
|
0fee70a9ff | ||
|
|
aed1aa29db | ||
|
|
d39c523728 | ||
|
|
afa5d70c0d | ||
|
|
f85472082c | ||
|
|
76604db7d2 | ||
|
|
6ec1fb46ab | ||
|
|
c01ee18934 | ||
|
|
aa50ea55ea | ||
|
|
c4c5ed8f4e | ||
|
|
b09dc6306e | ||
|
|
f07f5b008f | ||
|
|
a966dcdb69 | ||
|
|
752ccef3eb | ||
|
|
a9e4725773 | ||
|
|
b8f0502bb1 | ||
|
|
8a757c220b | ||
|
|
1f651f4b3d | ||
|
|
9e67ccd745 | ||
|
|
76ec516242 | ||
|
|
ebb985dc41 | ||
|
|
4dda343663 | ||
|
|
9cc8d6ff59 | ||
|
|
98d463ef5d | ||
|
|
343b8d7ba7 | ||
|
|
c343bee1b5 | ||
|
|
63e9f1ae61 | ||
|
|
da091b3ab3 | ||
|
|
0d9547474d | ||
|
|
4de72b7d9f | ||
|
|
49c8dab5b2 | ||
|
|
9becda5d93 | ||
|
|
0ee8b03422 | ||
|
|
73d119f4f8 | ||
|
|
615167cc4d | ||
|
|
74b9d6a6e8 | ||
|
|
0ed9d1823a | ||
|
|
77201c506f | ||
|
|
3bee7c9754 | ||
|
|
a72b7823b4 | ||
|
|
a257b63ce7 | ||
|
|
23e26ed972 | ||
|
|
3e0d7787e6 | ||
|
|
4c15a1b6e6 | ||
|
|
394b29aaff | ||
|
|
7f2c97a241 | ||
|
|
56e9acb292 | ||
|
|
bd45f0963c | ||
|
|
ba5017b65a | ||
|
|
11b01fc21f | ||
|
|
2709bea0f4 | ||
|
|
a3ce33c106 | ||
|
|
8d60cd8ad6 | ||
|
|
5602342a16 | ||
|
|
4edb14d20f | ||
|
|
684e810ae2 | ||
|
|
2f3d9524bb | ||
|
|
0292a5678a | ||
|
|
f7e25d5bb5 | ||
|
|
8c735f6585 | ||
|
|
60bd7bad9d | ||
|
|
dcc1514d9a | ||
|
|
f4a59d453e | ||
|
|
5f538c27a1 | ||
|
|
d733f2ec26 | ||
|
|
2e0dcd87bf | ||
|
|
caa716803a | ||
|
|
378dc38f48 | ||
|
|
a2434d3e58 | ||
|
|
0c46704832 | ||
|
|
de4e704273 | ||
|
|
2245a95806 | ||
|
|
f40c6b5cf2 | ||
|
|
6b8b1f9e77 | ||
|
|
8d41285fe4 | ||
|
|
769ace51e8 | ||
|
|
9ecc4f4e44 | ||
|
|
a6064bb864 | ||
|
|
17a9e79023 | ||
|
|
bee39b93f5 | ||
|
|
31076e8689 | ||
|
|
a6648d4102 | ||
|
|
fc1822a042 | ||
|
|
14d35d5bad | ||
|
|
c5a210a9c8 | ||
|
|
fb51f74ff6 | ||
|
|
092f8178c0 | ||
|
|
c80a538d96 | ||
|
|
6c16044d8d | ||
|
|
17bddc047b | ||
|
|
654700ba5d | ||
|
|
2593502290 | ||
|
|
d24a117707 | ||
|
|
8367b95a13 | ||
|
|
3564e3a572 | ||
|
|
3b0f5b9971 | ||
|
|
75e24853b7 | ||
|
|
c7ec75a276 | ||
|
|
3cff27ddc1 | ||
|
|
a66a4b77a5 | ||
|
|
67324bf19c | ||
|
|
69bd8be403 | ||
|
|
68f4c238ca | ||
|
|
217d68104a | ||
|
|
65a1c5b441 | ||
|
|
9cd52bd999 | ||
|
|
5f97136160 | ||
|
|
de4a5220f2 | ||
|
|
74439d15d7 | ||
|
|
850a056441 | ||
|
|
8ed8d003f1 | ||
|
|
07f8ec6bff | ||
|
|
af21374071 | ||
|
|
e0326b0473 | ||
|
|
2c902cc288 | ||
|
|
50e99b59bf | ||
|
|
75bf3c00d3 | ||
|
|
8463f41e4d | ||
|
|
cbb6dfec55 | ||
|
|
632beba630 | ||
|
|
9530a14420 | ||
|
|
2dddc87214 | ||
|
|
e3f15c9c4a | ||
|
|
c8340962dd | ||
|
|
9348edb6b6 | ||
|
|
5c9998fbab | ||
|
|
b3afbcad9c | ||
|
|
f4e2e2bb57 | ||
|
|
5e44ad4e6d | ||
|
|
13e13107e1 | ||
|
|
900606431e | ||
|
|
016e9a3bb8 | ||
|
|
32e8ead131 | ||
|
|
25727ebd6a | ||
|
|
13f439ce56 | ||
|
|
d553ab43c6 | ||
|
|
e15f5ab354 | ||
|
|
b0af86d062 | ||
|
|
4f92de5822 | ||
|
|
27c76b83b4 | ||
|
|
20b9a015e5 | ||
|
|
622eea03cd | ||
|
|
f2c2643fc5 | ||
|
|
fc5e68612f | ||
|
|
1ea34cbf6a | ||
|
|
d8cfa5db49 | ||
|
|
58977651ec | ||
|
|
0cb8332196 | ||
|
|
d428096a6a | ||
|
|
db1d95f43b | ||
|
|
dc3c843187 | ||
|
|
049e5b0f87 | ||
|
|
85edb4afbd | ||
|
|
9b673e61af | ||
|
|
f31229ebd1 | ||
|
|
5420604332 | ||
|
|
d70d55c0a4 | ||
|
|
ad82336026 | ||
|
|
422dcd424c | ||
|
|
911c0bc41d | ||
|
|
0e58c95000 | ||
|
|
cb7bb52551 | ||
|
|
93e30466ff | ||
|
|
73ba9f71e1 | ||
|
|
7783df863a | ||
|
|
10dcb0b125 | ||
|
|
e886b300f7 | ||
|
|
89c8c5fff3 | ||
|
|
0b2796750f | ||
|
|
703d2d6bd4 | ||
|
|
244268f719 | ||
|
|
df73cf50e9 | ||
|
|
a0b8c4ad61 | ||
|
|
6387164e5e | ||
|
|
e20d63c442 | ||
|
|
08c325c63b | ||
|
|
89f7d44912 | ||
|
|
73a813e484 | ||
|
|
46e5702bf3 | ||
|
|
9970fac34b | ||
|
|
9cbda6e1f8 | ||
|
|
779f34e180 | ||
|
|
a102826245 | ||
|
|
76c795bf2e | ||
|
|
39f5c3f92e | ||
|
|
3cb862ce5f | ||
|
|
b0e41e3f30 | ||
|
|
4bf182f92a | ||
|
|
8fd50b8672 | ||
|
|
464be62df6 | ||
|
|
1b86b70dd5 | ||
|
|
47e1388d6f | ||
|
|
02a4ebd6c4 | ||
|
|
b1df1d557e | ||
|
|
e0a4a60af5 | ||
|
|
ca7711456f | ||
|
|
a03c00023a | ||
|
|
0b2ff7637f | ||
|
|
ef47b928d0 | ||
|
|
c0e7e4a1d4 | ||
|
|
ebd776a422 | ||
|
|
86614ba1c2 | ||
|
|
5e1e0993b5 | ||
|
|
2f1cffe07a | ||
|
|
1ac8630f1e | ||
|
|
80a6c7faa2 | ||
|
|
57ffc40323 | ||
|
|
6380a66a7d | ||
|
|
d727aba601 | ||
|
|
123d03dca4 | ||
|
|
c0285a7136 | ||
|
|
17aaba6a41 | ||
|
|
d438486cb5 | ||
|
|
a44b866b11 | ||
|
|
6d61667d0d | ||
|
|
478055dc30 | ||
|
|
2522c1db68 | ||
|
|
16b5ca6e0d | ||
|
|
e600fbb764 | ||
|
|
e8858f1515 | ||
|
|
ed9d8b8730 | ||
|
|
3638944ff5 | ||
|
|
5ac7f2d281 | ||
|
|
15925d0e5b | ||
|
|
d53190ed46 | ||
|
|
f780a85985 | ||
|
|
4ac941565f | ||
|
|
7814596fa9 | ||
|
|
91a74d3614 | ||
|
|
3789024073 | ||
|
|
e8e81fc44b | ||
|
|
b841f111de | ||
|
|
66ea09b0fe | ||
|
|
c2173c0a52 | ||
|
|
bf574deec8 | ||
|
|
e1e21f6dff | ||
|
|
6c975de166 | ||
|
|
6a61883757 | ||
|
|
3621d51c9d | ||
|
|
e8909df3ce | ||
|
|
4d12f4df0c | ||
|
|
0147288d20 | ||
|
|
d055228e34 | ||
|
|
b7c8eb0046 | ||
|
|
48f5a39872 | ||
|
|
fe18d3982a | ||
|
|
17479ef60c | ||
|
|
d5d9b67eec | ||
|
|
76e1200eeb | ||
|
|
ba0527d4ca | ||
|
|
800c86d5fa | ||
|
|
aed3b8190a | ||
|
|
f218412b9a | ||
|
|
059e53e5b4 | ||
|
|
ba128e628c | ||
|
|
3f942cd03f | ||
|
|
42f33ae68c | ||
|
|
7edec89fc3 | ||
|
|
fae65623a9 | ||
|
|
300af78691 | ||
|
|
c6b1fe4347 | ||
|
|
7223651ad1 | ||
|
|
6d683a1d02 | ||
|
|
2cae0419c9 | ||
|
|
35adc746a0 | ||
|
|
21e7573508 | ||
|
|
6c199713ed | ||
|
|
d178b49754 | ||
|
|
941027eeb7 | ||
|
|
5e1c5f2d71 | ||
|
|
4eb5abbff4 | ||
|
|
b16553cdad | ||
|
|
3fb0cc80fa | ||
|
|
cc078f747f | ||
|
|
7ea7c020e8 | ||
|
|
82e1750daa | ||
|
|
5595673d5c | ||
|
|
0e62ba282e | ||
|
|
9d333aca43 | ||
|
|
e29f4411c8 | ||
|
|
6bab375973 | ||
|
|
f6229adb09 |
4
.github/ISSUE_TEMPLATE.txt
vendored
4
.github/ISSUE_TEMPLATE.txt
vendored
@@ -13,7 +13,7 @@ Before reporting a new bug, please check the following resources:
|
||||
* Coreutils FAQ: https://www.gnu.org/software/coreutils/faq/coreutils-faq.html
|
||||
|
||||
* Coreutils Gotchas: https://www.pixelbeat.org/docs/coreutils-gotchas.html
|
||||
contains a list of some quirks and unexpected behaviour (which are often
|
||||
contains a list of some quirks and unexpected behavior (which are often
|
||||
mistaken for bugs).
|
||||
|
||||
* Online Manual:
|
||||
@@ -68,7 +68,7 @@ When sending messages to coreutils@gnu.org or bug-coreutils@gnu.org :
|
||||
|
||||
|
||||
<!--
|
||||
Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2017-2024 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
|
||||
|
||||
4
.github/PULL_REQUEST_TEMPLATE.txt
vendored
4
.github/PULL_REQUEST_TEMPLATE.txt
vendored
@@ -22,7 +22,7 @@ contributing to the GNU Project, please read
|
||||
* Coreutils FAQ: https://www.gnu.org/software/coreutils/faq/coreutils-faq.html
|
||||
|
||||
* Coreutils Gotchas: https://www.pixelbeat.org/docs/coreutils-gotchas.html
|
||||
contains a list of some quirks and unexpected behaviour (which are often
|
||||
contains a list of some quirks and unexpected behavior (which are often
|
||||
mistaken for bugs).
|
||||
|
||||
* Online Manual:
|
||||
@@ -88,7 +88,7 @@ in this matter.
|
||||
|
||||
|
||||
<!--
|
||||
Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2017-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
16
.gitignore
vendored
16
.gitignore
vendored
@@ -1,16 +1,19 @@
|
||||
*.I[12]
|
||||
*.[EIOX]
|
||||
*.[EIOXao]
|
||||
*.bak
|
||||
*.gcda
|
||||
*.gcno
|
||||
*.o
|
||||
*.a
|
||||
*~
|
||||
._bootmp
|
||||
.deps
|
||||
.gdb-history
|
||||
.kludge-stamp
|
||||
.version
|
||||
/*.patch
|
||||
/.Tpo
|
||||
/.am*
|
||||
/.re-list
|
||||
/.sc-start-*
|
||||
/ABOUT-NLS
|
||||
/ChangeLog
|
||||
/GNUmakefile
|
||||
@@ -84,6 +87,7 @@
|
||||
/lib/math.h
|
||||
/lib/netdb.h
|
||||
/lib/netinet/in.h
|
||||
/lib/obstack.h
|
||||
/lib/parse-datetime-gen.h
|
||||
/lib/parse-datetime.c
|
||||
/lib/poll.h
|
||||
@@ -111,7 +115,12 @@
|
||||
/lib/sys/
|
||||
/lib/termios.h
|
||||
/lib/time.h
|
||||
/lib/uchar.h
|
||||
/lib/unicase.h
|
||||
/lib/unicase/
|
||||
/lib/unictype
|
||||
/lib/unictype.h
|
||||
/lib/uninorm.h
|
||||
/lib/unistd.h
|
||||
/lib/unistr
|
||||
/lib/unistr.h
|
||||
@@ -200,6 +209,7 @@
|
||||
/tests/factor/t[0-9][0-9].sh
|
||||
/tests/t?
|
||||
/tests/test-suite.log
|
||||
/tight-scope.mk
|
||||
ID
|
||||
Makefile
|
||||
Makefile.in
|
||||
|
||||
@@ -1 +1 @@
|
||||
9.2
|
||||
9.4
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Suppress valgrind diagnostics we don't care about.
|
||||
|
||||
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
22
AUTHORS
22
AUTHORS
@@ -2,30 +2,30 @@ Here are the names of the programs in this package,
|
||||
each followed by the name(s) of its author(s).
|
||||
|
||||
arch: David MacKenzie, Karel Zak
|
||||
b2sum: Padraig Brady, Samuel Neves
|
||||
b2sum: Pádraig Brady, Samuel Neves
|
||||
base32: Simon Josefsson
|
||||
base64: Simon Josefsson
|
||||
basename: David MacKenzie
|
||||
basenc: Simon Josefsson, Assaf Gordon
|
||||
cat: Torbjorn Granlund, Richard M. Stallman
|
||||
cat: Torbjörn Granlund, Richard M. Stallman
|
||||
chcon: Russell Coker, Jim Meyering
|
||||
chgrp: David MacKenzie, Jim Meyering
|
||||
chmod: David MacKenzie, Jim Meyering
|
||||
chown: David MacKenzie, Jim Meyering
|
||||
chroot: Roland McGrath
|
||||
cksum: Padraig Brady, Q. Frank Xia
|
||||
cksum: Pádraig Brady, Q. Frank Xia
|
||||
comm: Richard M. Stallman, David MacKenzie
|
||||
coreutils: Alex Deymo
|
||||
cp: Torbjorn Granlund, David MacKenzie, Jim Meyering
|
||||
cp: Torbjörn Granlund, David MacKenzie, Jim Meyering
|
||||
csplit: Stuart Kemp, David MacKenzie
|
||||
cut: David M. Ihnat, David MacKenzie, Jim Meyering
|
||||
date: David MacKenzie
|
||||
dd: Paul Rubin, David MacKenzie, Stuart Kemp
|
||||
df: Torbjorn Granlund, David MacKenzie, Paul Eggert
|
||||
df: Torbjörn Granlund, David MacKenzie, Paul Eggert
|
||||
dir: Richard M. Stallman, David MacKenzie
|
||||
dircolors: H. Peter Anvin
|
||||
dirname: David MacKenzie, Jim Meyering
|
||||
du: Torbjorn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
|
||||
du: Torbjörn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
|
||||
echo: Brian Fox, Chet Ramey
|
||||
env: Richard Mlynarik, David MacKenzie, Assaf Gordon
|
||||
expand: David MacKenzie
|
||||
@@ -67,7 +67,7 @@ printf: David MacKenzie
|
||||
ptx: François Pinard
|
||||
pwd: Jim Meyering
|
||||
readlink: Dmitry V. Levin
|
||||
realpath: Padraig Brady
|
||||
realpath: Pádraig Brady
|
||||
rm: Paul Rubin, David MacKenzie, Richard M. Stallman, Jim Meyering
|
||||
rmdir: David MacKenzie
|
||||
runcon: Russell Coker
|
||||
@@ -81,9 +81,9 @@ shred: Colin Plumb
|
||||
shuf: Paul Eggert
|
||||
sleep: Jim Meyering, Paul Eggert
|
||||
sort: Mike Haertel, Paul Eggert
|
||||
split: Torbjorn Granlund, Richard M. Stallman
|
||||
split: Torbjörn Granlund, Richard M. Stallman
|
||||
stat: Michael Meskes
|
||||
stdbuf: Padraig Brady
|
||||
stdbuf: Pádraig Brady
|
||||
stty: David MacKenzie
|
||||
sum: Kayvan Aghaiepour, David MacKenzie
|
||||
sync: Jim Meyering, Giuseppe Scrivano
|
||||
@@ -91,11 +91,11 @@ tac: Jay Lepreau, David MacKenzie
|
||||
tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, Jim Meyering
|
||||
tee: Mike Parker, Richard M. Stallman, David MacKenzie
|
||||
test: Kevin Braunsdorf, Matthew Bradburn
|
||||
timeout: Padraig Brady
|
||||
timeout: Pádraig Brady
|
||||
touch: Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, Randy Smith
|
||||
tr: Jim Meyering
|
||||
true: Jim Meyering
|
||||
truncate: Padraig Brady
|
||||
truncate: Pádraig Brady
|
||||
tsort: Mark Kettenis
|
||||
tty: David MacKenzie
|
||||
uname: David MacKenzie
|
||||
|
||||
19
HACKING
19
HACKING
@@ -3,22 +3,21 @@ Coreutils Contribution Guidelines
|
||||
|
||||
Prerequisites
|
||||
=============
|
||||
You will need the "git" version control tools.
|
||||
On Fedora-based systems, do "yum install git".
|
||||
On Debian-based ones install the "git-core" package.
|
||||
Then run "git --version". If that says it's older than
|
||||
version 1.4.4, then you'd do well to get a newer version.
|
||||
You will need the "git" version control tools. On Fedora-based
|
||||
systems, do "yum install git". On Debian-based ones install the
|
||||
"git-core" package. Then run "git --version". If that says it's
|
||||
older than version 1.4.4, then you'd do well to get a newer version.
|
||||
At worst, just download the latest stable release from
|
||||
https://git-scm.com/ and build from source.
|
||||
|
||||
For details on building the programs in this package, see
|
||||
the file, README-hacking.
|
||||
For details on building the programs in this package, see the file,
|
||||
README-hacking.
|
||||
|
||||
|
||||
Use the latest upstream sources
|
||||
===============================
|
||||
Base any changes you make on the latest upstream sources.
|
||||
You can get a copy of the latest with this command:
|
||||
Base any changes you make on the latest upstream sources. You can get
|
||||
a copy of the latest with this command:
|
||||
|
||||
git clone https://git.savannah.gnu.org/git/coreutils.git
|
||||
cd coreutils
|
||||
@@ -617,7 +616,7 @@ and root only tests, is to follow these steps (requires lcov to be installed):
|
||||
xdg-open doc/coverage/index.html
|
||||
|
||||
========================================================================
|
||||
Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Make coreutils. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 1990-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1990-2024 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,7 +94,7 @@ dist-hook: gen-ChangeLog
|
||||
$(AM_V_at)touch $(distdir)/doc/constants.texi \
|
||||
$(distdir)/doc/coreutils.info
|
||||
|
||||
gen_start_ver = 8.29
|
||||
gen_start_ver = 8.31
|
||||
.PHONY: gen-ChangeLog
|
||||
gen-ChangeLog:
|
||||
$(AM_V_GEN)if test -d .git; then \
|
||||
|
||||
262
NEWS
262
NEWS
@@ -1,5 +1,251 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 9.5 (2024-03-28) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chmod -R now avoids a race where an attacker may replace a traversed file
|
||||
with a symlink, causing chmod to operate on an unintended file.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
cp, mv, and install no longer issue spurious diagnostics like "failed
|
||||
to preserve ownership" when copying to GNU/Linux CIFS file systems.
|
||||
They do this by working around some Linux CIFS bugs.
|
||||
|
||||
cp --no-preserve=mode will correctly maintain set-group-ID bits
|
||||
for created directories. Previously on systems that didn't support ACLs,
|
||||
cp would have reset the set-group-ID bit on created directories.
|
||||
[bug introduced in coreutils-8.20]
|
||||
|
||||
join and uniq now support multi-byte characters better.
|
||||
For example, 'join -tX' now works even if X is a multi-byte character,
|
||||
and both programs now treat multi-byte characters like U+3000
|
||||
IDEOGRAPHIC SPACE as blanks if the current locale treats them so.
|
||||
|
||||
numfmt options like --suffix no longer have an arbitrary 127-byte limit.
|
||||
[bug introduced with numfmt in coreutils-8.21]
|
||||
|
||||
mktemp with --suffix now better diagnoses templates with too few X's.
|
||||
Previously it conflated the insignificant --suffix in the error.
|
||||
[bug introduced in coreutils-8.1]
|
||||
|
||||
sort again handles thousands grouping characters in single-byte locales
|
||||
where the grouping character is greater than CHAR_MAX. For e.g. signed
|
||||
character platforms with a 0xA0 (aka  ) grouping character.
|
||||
[bug introduced in coreutils-9.1]
|
||||
|
||||
split --line-bytes with a mixture of very long and short lines
|
||||
no longer overwrites the heap (CVE-2024-0684).
|
||||
[bug introduced in coreutils-9.2]
|
||||
|
||||
tail no longer mishandles input from files in /proc and /sys file systems,
|
||||
on systems with a page size larger than the stdio BUFSIZ.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
timeout avoids a narrow race condition, where it might kill arbitrary
|
||||
processes after a failed process fork.
|
||||
[bug introduced with timeout in coreutils-7.0]
|
||||
|
||||
timeout avoids a narrow race condition, where it might fail to
|
||||
kill monitored processes immediately after forking them.
|
||||
[bug introduced with timeout in coreutils-7.0]
|
||||
|
||||
wc no longer fails to count unprintable characters as parts of words.
|
||||
[bug introduced in textutils-2.1]
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
base32 and base64 no longer require padding when decoding.
|
||||
Previously an error was given for non padded encoded data.
|
||||
|
||||
base32 and base64 have improved detection of corrupted encodings.
|
||||
Previously encodings with non zero padding bits were accepted.
|
||||
|
||||
basenc --base16 -d now supports lower case hexadecimal characters.
|
||||
Previously an error was given for lower case hex digits.
|
||||
|
||||
cp --no-clobber, and mv -n no longer exit with failure status if
|
||||
existing files are encountered in the destination. Instead they revert
|
||||
to the behavior from before v9.2, silently skipping existing files.
|
||||
|
||||
ls --dired now implies long format output without hyperlinks enabled,
|
||||
and will take precedence over previously specified formats or hyperlink mode.
|
||||
|
||||
numfmt will accept lowercase 'k' to indicate Kilo or Kibi units on input,
|
||||
and uses lowercase 'k' when outputting such units in '--to=si' mode.
|
||||
|
||||
pinky no longer tries to canonicalize the user's login location by default,
|
||||
rather requiring the new --lookup option to enable this often slow feature.
|
||||
|
||||
wc no longer ignores encoding errors when counting words.
|
||||
Instead, it treats them as non white space.
|
||||
|
||||
** New features
|
||||
|
||||
chgrp now accepts the --from=OWNER:GROUP option to restrict changes to files
|
||||
with matching current OWNER and/or GROUP, as already supported by chown(1).
|
||||
|
||||
chmod adds support for -h, -H,-L,-P, and --dereference options, providing
|
||||
more control over symlink handling. This supports more secure handling of
|
||||
CLI arguments, and is more consistent with chown, and chmod on other systems.
|
||||
|
||||
cp now accepts the --keep-directory-symlink option (like tar), to preserve
|
||||
and follow existing symlinks to directories in the destination.
|
||||
|
||||
cp and mv now accept the --update=none-fail option, which is similar
|
||||
to the --no-clobber option, except that existing files are diagnosed,
|
||||
and the command exits with failure status if existing files.
|
||||
The -n,--no-clobber option is best avoided due to platform differences.
|
||||
|
||||
env now accepts the -a,--argv0 option to override the zeroth argument
|
||||
of the command being executed.
|
||||
|
||||
mv now accepts an --exchange option, which causes the source and
|
||||
destination to be exchanged. It should be combined with
|
||||
--no-target-directory (-T) if the destination is a directory.
|
||||
The exchange is atomic if source and destination are on a single
|
||||
file system that supports atomic exchange; --exchange is not yet
|
||||
supported in other situations.
|
||||
|
||||
od now supports printing IEEE half precision floating point with -t fH,
|
||||
or brain 16 bit floating point with -t fB, where supported by the compiler.
|
||||
|
||||
tail now supports following multiple processes, with repeated --pid options.
|
||||
|
||||
** Improvements
|
||||
|
||||
cp,mv,install,cat,split now read and write a minimum of 256KiB at a time.
|
||||
This was previously 128KiB and increasing to 256KiB was seen to increase
|
||||
throughput by 10-20% when reading cached files on modern systems.
|
||||
|
||||
env,kill,timeout now support unnamed signals. kill(1) for example now
|
||||
supports sending such signals, and env(1) will list them appropriately.
|
||||
|
||||
SELinux operations in file copy operations are now more efficient,
|
||||
avoiding unneeded MCS/MLS label translation.
|
||||
|
||||
sort no longer dynamically links to libcrypto unless -R is used.
|
||||
This decreases startup overhead in the typical case.
|
||||
|
||||
wc is now much faster in single-byte locales and somewhat faster in
|
||||
multi-byte locales.
|
||||
|
||||
|
||||
* Noteworthy changes in release 9.4 (2023-08-29) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
On GNU/Linux s390x and alpha, programs like 'cp' and 'ls' no longer
|
||||
fail on files with inode numbers that do not fit into 32 bits.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
'b2sum --check' will no longer read unallocated memory when
|
||||
presented with malformed checksum lines.
|
||||
[bug introduced in coreutils-9.2]
|
||||
|
||||
'cp --parents' again succeeds when preserving mode for absolute directories.
|
||||
Previously it would have failed with a "No such file or directory" error.
|
||||
[bug introduced in coreutils-9.1]
|
||||
|
||||
'cp --sparse=never' will avoid copy-on-write (reflinking) and copy offloading,
|
||||
to ensure no holes present in the destination copy.
|
||||
[bug introduced in coreutils-9.0]
|
||||
|
||||
cksum again diagnoses read errors in its default CRC32 mode.
|
||||
[bug introduced in coreutils-9.0]
|
||||
|
||||
'cksum --check' now ensures filenames with a leading backslash character
|
||||
are escaped appropriately in the status output.
|
||||
This also applies to the standalone checksumming utilities.
|
||||
[bug introduced in coreutils-8.25]
|
||||
|
||||
dd again supports more than two multipliers for numbers.
|
||||
Previously numbers of the form '1024x1024x32' gave "invalid number" errors.
|
||||
[bug introduced in coreutils-9.1]
|
||||
|
||||
factor, numfmt, and tsort now diagnose read errors on the input.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
'install --strip' now supports installing to files with a leading hyphen.
|
||||
Previously such file names would have caused the strip process to fail.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
ls now shows symlinks specified on the command line that can't be traversed.
|
||||
Previously a "Too many levels of symbolic links" diagnostic was given.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
pinky, uptime, users, and who no longer misbehave on 32-bit GNU/Linux
|
||||
platforms like x86 and ARM where time_t was historically 32 bits.
|
||||
Also see the new --enable-systemd option mentioned below.
|
||||
[bug introduced in coreutils-9.0]
|
||||
|
||||
'pr --length=1 --double-space' no longer enters an infinite loop.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
shred again operates on Solaris when built for 64 bits.
|
||||
Previously it would have exited with a "getrandom: Invalid argument" error.
|
||||
[bug introduced in coreutils-9.0]
|
||||
|
||||
tac now handles short reads on its input. Previously it may have exited
|
||||
erroneously, especially with large input files with no separators.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
'uptime' no longer incorrectly prints "0 users" on OpenBSD,
|
||||
and is being built again on FreeBSD and Haiku.
|
||||
[bugs introduced in coreutils-9.2]
|
||||
|
||||
'wc -l' and 'cksum' no longer crash with an "Illegal instruction" error
|
||||
on x86 Linux kernels that disable XSAVE YMM. This was seen on Xen VMs.
|
||||
[bug introduced in coreutils-9.0]
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
'cp -v' and 'mv -v' will no longer output a message for each file skipped
|
||||
due to -i, or -u. Instead they only output this information with --debug.
|
||||
I.e., 'cp -u -v' etc. will have the same verbosity as before coreutils-9.3.
|
||||
|
||||
'cksum -b' no longer prints base64-encoded checksums. Rather that
|
||||
short option is reserved to better support emulation of the standalone
|
||||
checksum utilities with cksum.
|
||||
|
||||
'mv dir x' now complains differently if x/dir is a nonempty directory.
|
||||
Previously it said "mv: cannot move 'dir' to 'x/dir': Directory not empty",
|
||||
where it was unclear whether 'dir' or 'x/dir' was the problem.
|
||||
Now it says "mv: cannot overwrite 'x/dir': Directory not empty".
|
||||
Similarly for other renames where the destination must be the problem.
|
||||
[problem introduced in coreutils-6.0]
|
||||
|
||||
** Improvements
|
||||
|
||||
cp, mv, and install now avoid copy_file_range on linux kernels before 5.3
|
||||
irrespective of which kernel version coreutils is built against,
|
||||
reinstating that behavior from coreutils-9.0.
|
||||
|
||||
comm, cut, join, od, and uniq will now exit immediately upon receiving a
|
||||
write error, which is significant when reading large / unbounded inputs.
|
||||
|
||||
split now uses more tuned access patterns for its potentially large input.
|
||||
This was seen to improve throughput by 5% when reading from SSD.
|
||||
|
||||
split now supports a configurable $TMPDIR for handling any temporary files.
|
||||
|
||||
tac now falls back to '/tmp' if a configured $TMPDIR is unavailable.
|
||||
|
||||
'who -a' now displays the boot time on Alpine Linux, OpenBSD,
|
||||
Cygwin, Haiku, and some Android distributions
|
||||
|
||||
'uptime' now succeeds on some Android distributions, and now counts
|
||||
VM saved/sleep time on GNU (Linux, Hurd, kFreeBSD), NetBSD, OpenBSD,
|
||||
Minix, and Cygwin.
|
||||
|
||||
On GNU/Linux platforms where utmp-format files have 32-bit timestamps,
|
||||
pinky, uptime, and who can now work for times after the year 2038,
|
||||
so long as systemd is installed, you configure with a new, experimental
|
||||
option --enable-systemd, and you use the programs without file arguments.
|
||||
(For example, with systemd 'who /var/log/wtmp' does not work because
|
||||
systemd does not support the equivalent of /var/log/wtmp.)
|
||||
|
||||
|
||||
* Noteworthy changes in release 9.3 (2023-04-18) [stable]
|
||||
|
||||
** Bug fixes
|
||||
@@ -11,7 +257,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
[bug introduced in coreutils-9.2]
|
||||
|
||||
cp --recursive --backup will again operate correctly.
|
||||
Previousy it may have issued "File exists" errors when
|
||||
Previously it may have issued "File exists" errors when
|
||||
it failed to appropriately rename files being replaced.
|
||||
[bug introduced in coreutils-9.2]
|
||||
|
||||
@@ -301,7 +547,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
though they still work.
|
||||
|
||||
ls no longer colors files with capabilities by default, as file-based
|
||||
capabilties are very rarely used, and lookup increases processing per file by
|
||||
capabilities are rarely used, and lookup increases processing per file by
|
||||
about 30%. It's best to use getcap [-r] to identify files with capabilities.
|
||||
|
||||
ls no longer tries to automount files, reverting to the behavior
|
||||
@@ -392,7 +638,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
expr no longer mishandles unmatched \(...\) in regular expressions.
|
||||
[bug introduced in coreutils-6.0]
|
||||
|
||||
ls no longer crashes when printing the SELinux context for unstatable files.
|
||||
ls no longer crashes when printing the SELinux context for unstattable files.
|
||||
[bug introduced in coreutils-6.9.91]
|
||||
|
||||
mkdir -m no longer mishandles modes more generous than the umask.
|
||||
@@ -971,7 +1217,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
** Bug fixes
|
||||
|
||||
cp --parents will now set an SELinux context for created directories,
|
||||
as appropriate for the -a, --preseve=context, or -Z options.
|
||||
as appropriate for the -a, --preserve=context, or -Z options.
|
||||
[bug present since SELinux support added in coreutils-6.10]
|
||||
|
||||
date again converts from a specified time zone. Previously output was
|
||||
@@ -1608,7 +1854,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
** Bug fixes
|
||||
|
||||
df now processes the mount list correctly in the presence of unstatable
|
||||
df now processes the mount list correctly in the presence of unstattable
|
||||
mount points. Previously it may have failed to output some mount points.
|
||||
[bug introduced in coreutils-8.21]
|
||||
|
||||
@@ -2861,7 +3107,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
ls --color now handles files with capabilities correctly. Previously
|
||||
files with capabilities were often not colored, and also sometimes, files
|
||||
without capabilites were colored in error. [bug introduced in coreutils-7.0]
|
||||
without capabilities were colored in error. [bug introduced in coreutils-7.0]
|
||||
|
||||
md5sum now prints checksums atomically so that concurrent
|
||||
processes will not intersperse their output.
|
||||
@@ -3010,7 +3256,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
avoid the disproportionate quadratic performance penalty. Leading to
|
||||
another improvement:
|
||||
|
||||
rm -r is now slightly more standards-conformant when operating on
|
||||
rm -r is now slightly more standard-conforming when operating on
|
||||
write-protected files with relative names longer than 8KiB.
|
||||
|
||||
|
||||
@@ -5650,7 +5896,7 @@ packages, see ./old/*/NEWS.
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
7
README
7
README
@@ -96,8 +96,8 @@ run this command:
|
||||
|
||||
make check TESTS=tests/df/df-P.sh VERBOSE=yes SUBDIRS=. >> log 2>&1
|
||||
|
||||
For some tests, you can get even more detail by adding DEBUG=yes.
|
||||
Then include the contents of the file 'log' in your bug report.
|
||||
For some tests, particularly perl tests, you can get even more detail by adding
|
||||
DEBUG=yes. Then include the contents of the file 'log' in your bug report.
|
||||
|
||||
|
||||
***************************************
|
||||
@@ -127,10 +127,11 @@ https://www.gnu.org/prep/standards/
|
||||
For any copyright year range specified as YYYY-ZZZZ in this package
|
||||
note that the range specifies every single year in that closed interval.
|
||||
|
||||
Please see the file COPYING for copying conditions.
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -101,7 +101,7 @@ each program. One way to do this is to use vc-dwim
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2024 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,7 +58,7 @@ Although 32-bit builds fail if that forces time_t to be 32 bits, this
|
||||
can be fixed by using 64-bit builds. For example, on AIX where GCC
|
||||
defaults to 32 bits, one can use "./configure CC='gcc -maix64' AR='ar
|
||||
-X64'"; similarly, on Solaris one can configure with CC='gcc -m64'.
|
||||
If all else fails one can configure with ac_year2038_required=no;
|
||||
If all else fails one can configure with --disable-year2038;
|
||||
however, this will mishandle timestamps after 2038, and please file
|
||||
bug reports for any such situations.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#! /bin/bash
|
||||
# Convert this package for use with valgrind.
|
||||
|
||||
# Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2024 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
|
||||
@@ -41,7 +41,7 @@ _path='export PATH='$srcdir':${PATH#*:}'
|
||||
pre='#!/bin/sh\n'"$_path"'\n'
|
||||
n=15 # stack trace depth
|
||||
log_fd=3 # One can redirect this to file like 3>vg.log
|
||||
test -e /tmp/cu-vg && suppressions='--supressions=/tmp/cu-vg'
|
||||
test -e /tmp/cu-vg && suppressions='--suppressions=/tmp/cu-vg'
|
||||
vg="exec /usr/bin/valgrind $suppressions --log-fd=$log_fd \
|
||||
--leak-check=yes --track-fds=yes --leak-check=full --num-callers=$n"
|
||||
cat <<EOF > src/vg/gen
|
||||
|
||||
@@ -211,6 +211,7 @@ Francesco Montorsi fr_m@hotmail.com
|
||||
François Pinard pinard@iro.umontreal.ca
|
||||
François Rigault rigault.francois@gmail.com
|
||||
Frank Adler fadler@allesklar.de
|
||||
Frank Busse f.busse@imperial.ac.uk
|
||||
Frank T Lofaro ftlofaro@snooks.Egr.UNLV.EDU
|
||||
Fred Fish fnf@ninemoons.com
|
||||
Frédéric L. W. Meunier 0@pervalidus.net
|
||||
@@ -237,7 +238,6 @@ Greg McGary gkm@gnu.org
|
||||
Greg Metcalfe metcalfegreg@qwest.net
|
||||
Greg Schafer gschafer@zip.com.au
|
||||
Greg Troxel gdt@bbn.com
|
||||
Greg Wooledge gawooledge@sherwin.com
|
||||
Gregory Leblanc gleblanc@cu-portland.edu
|
||||
Guido Leenders guido.leenders@invantive.com
|
||||
Guntram Blohm Extern.Guntram.Blohm@AUDI.DE
|
||||
@@ -411,6 +411,7 @@ Marty Leisner leisner@sdsp.mc.xerox.com
|
||||
Masami Takikawa takikawm@CS.ORST.EDU
|
||||
Mate Wierdl mw@moni.msci.memphis.edu
|
||||
Matej Vela mvela@public.srce.hr
|
||||
Matheus Afonso Martins Moreira matheus.a.m.moreira@gmail.com
|
||||
Mathias Brodala info@noctus.net
|
||||
Matias A. Fonzo selk@dragora.org
|
||||
Matt Kraai kraai@ftbfs.org
|
||||
@@ -565,7 +566,6 @@ Rudolf Kastl rkastl@redhat.com
|
||||
Sahil Amoli sahilamoli@gmail.com
|
||||
Sami Farin sfarin@ratol.fi
|
||||
Samuel Neves sneves@dei.uc.pt
|
||||
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
|
||||
@@ -634,7 +634,7 @@ Tony Leneis tony@plaza.ds.adp.com
|
||||
Tony Robinson ajr@eng.cam.ac.uk
|
||||
Toomas Soome Toomas.Soome@Elion.ee
|
||||
Toralf Förster toralf.foerster@gmx.de
|
||||
Torbjorn Lindgren tl@funcom.no
|
||||
Torbjörn Lindgren tl@funcom.no
|
||||
Torsten Landschoff torsten@pclab.ifg.uni-kiel.de
|
||||
Travis Gummels tgummels@redhat.com
|
||||
Tristan Miller psychonaut@nothingisreal.com
|
||||
|
||||
4
TODO
4
TODO
@@ -18,7 +18,7 @@ document the following in coreutils.texi:
|
||||
Suggestion from Paul Eggert:
|
||||
More generally, there's not that much use for imaxtostr nowadays,
|
||||
since the inttypes module and newer versions of gettext allow things
|
||||
like _("truncating %s at %" PRIdMAX " bytes") to work portably.
|
||||
like _("truncating %s at %jd bytes") to work portably.
|
||||
I suspect that (if someone cares to take the time) we can remove
|
||||
all instances of imaxtostr and umaxtostr in coreutils and gnulib.
|
||||
|
||||
@@ -143,7 +143,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bootstrap configuration.
|
||||
|
||||
# Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2024 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,6 +20,8 @@
|
||||
avoided_gnulib_modules='
|
||||
--avoid=canonicalize-lgpl
|
||||
--avoid=dummy
|
||||
--avoid=mbuiter
|
||||
--avoid=mbuiterf
|
||||
'
|
||||
|
||||
# gnulib modules used by this package.
|
||||
@@ -36,25 +38,27 @@ gnulib_modules="
|
||||
argv-iter
|
||||
assert
|
||||
assert-h
|
||||
assure
|
||||
attribute
|
||||
autobuild
|
||||
backupfile
|
||||
backup-rename
|
||||
backupfile
|
||||
base32
|
||||
base64
|
||||
btowc
|
||||
btoc32
|
||||
buffer-lcm
|
||||
byteswap
|
||||
c-strcase
|
||||
cl-strtod
|
||||
cl-strtold
|
||||
calloc-gnu
|
||||
c32iscntrl
|
||||
c32isspace
|
||||
c32width
|
||||
canon-host
|
||||
canonicalize
|
||||
chmodat
|
||||
chown
|
||||
chownat
|
||||
cloexec
|
||||
cl-strtod
|
||||
cl-strtold
|
||||
closein
|
||||
closeout
|
||||
config-h
|
||||
@@ -103,6 +107,7 @@ gnulib_modules="
|
||||
fnmatch-gnu
|
||||
fopen-safer
|
||||
fprintftime
|
||||
fpurge
|
||||
free-posix
|
||||
freopen
|
||||
freopen-safer
|
||||
@@ -115,7 +120,6 @@ gnulib_modules="
|
||||
fts
|
||||
full-read
|
||||
full-write
|
||||
getgroups
|
||||
gethrxtime
|
||||
getline
|
||||
getloadavg
|
||||
@@ -123,19 +127,14 @@ gnulib_modules="
|
||||
getndelim2
|
||||
getopt-gnu
|
||||
getpagesize
|
||||
getpass-gnu
|
||||
gettext-h
|
||||
gettime
|
||||
gettime-res
|
||||
getugroups
|
||||
getusershell
|
||||
git-version-gen
|
||||
gitlog-to-changelog
|
||||
gnu-make
|
||||
gnu-web-doc-update
|
||||
gnumakefile
|
||||
gnupload
|
||||
group-member
|
||||
hard-locale
|
||||
hash
|
||||
hash-triple
|
||||
@@ -152,7 +151,6 @@ gnulib_modules="
|
||||
isblank
|
||||
largefile
|
||||
lchmod
|
||||
lchown
|
||||
ldtoastr
|
||||
lib-ignore
|
||||
libgmp
|
||||
@@ -166,18 +164,19 @@ gnulib_modules="
|
||||
malloc-gnu
|
||||
manywarnings
|
||||
mbrlen
|
||||
mbrtoc32
|
||||
mbrtowc
|
||||
mbsalign
|
||||
mbschr
|
||||
mbslen
|
||||
mbswidth
|
||||
mbszero
|
||||
mcel-prefer
|
||||
memcasecmp
|
||||
memchr
|
||||
memcmp2
|
||||
mempcpy
|
||||
memrchr
|
||||
minmax
|
||||
mgetgroups
|
||||
mkancesdirs
|
||||
mkdir
|
||||
mkdir-p
|
||||
@@ -191,9 +190,9 @@ gnulib_modules="
|
||||
modechange
|
||||
mountlist
|
||||
mpsort
|
||||
netinet_in
|
||||
nproc
|
||||
nstrftime
|
||||
nullptr
|
||||
obstack
|
||||
open
|
||||
openat-safer
|
||||
@@ -209,7 +208,7 @@ gnulib_modules="
|
||||
posixver
|
||||
priv-set
|
||||
progname
|
||||
propername
|
||||
propername-lite
|
||||
pthread-cond
|
||||
pthread-mutex
|
||||
pthread-thread
|
||||
@@ -221,19 +220,15 @@ gnulib_modules="
|
||||
randperm
|
||||
rawmemchr
|
||||
read-file
|
||||
readlink
|
||||
readtokens
|
||||
readtokens0
|
||||
readutmp
|
||||
realloc-gnu
|
||||
regex
|
||||
remove
|
||||
rename
|
||||
renameat
|
||||
renameatu
|
||||
rmdir
|
||||
root-dev-ino
|
||||
rpmatch
|
||||
safe-read
|
||||
same
|
||||
save-cwd
|
||||
@@ -245,17 +240,18 @@ gnulib_modules="
|
||||
settime
|
||||
sig2str
|
||||
sigaction
|
||||
skipchars
|
||||
smack
|
||||
ssize_t
|
||||
stat-macros
|
||||
stat-size
|
||||
stat-time
|
||||
stdbool
|
||||
stdckdint
|
||||
stdlib-safer
|
||||
stpcpy
|
||||
stpncpy
|
||||
strdup-posix
|
||||
strncat
|
||||
strnlen
|
||||
strnumcmp
|
||||
strsignal
|
||||
strtoimax
|
||||
@@ -271,8 +267,7 @@ gnulib_modules="
|
||||
time_rz
|
||||
timer-time
|
||||
timespec
|
||||
tmpfile
|
||||
tzset
|
||||
tmpdir
|
||||
uname
|
||||
unicodeio
|
||||
unistd-safer
|
||||
@@ -282,7 +277,6 @@ gnulib_modules="
|
||||
unlocked-io
|
||||
unsetenv
|
||||
update-copyright
|
||||
uptime
|
||||
useless-if-before-free
|
||||
userspec
|
||||
utimecmp
|
||||
@@ -293,9 +287,6 @@ gnulib_modules="
|
||||
verify
|
||||
verror
|
||||
version-etc-fsf
|
||||
wchar-single
|
||||
wcswidth
|
||||
wcwidth
|
||||
winsz-ioctl
|
||||
winsz-termios
|
||||
write-any-file
|
||||
@@ -318,7 +309,7 @@ gnulib_modules="
|
||||
xstrtol-error
|
||||
xstrtold
|
||||
xstrtoumax
|
||||
year2038-required
|
||||
year2038-recommended
|
||||
yesno
|
||||
"
|
||||
|
||||
@@ -347,7 +338,7 @@ see_manual='"This is a proper name. See the gettext manual, section Names."'
|
||||
see_manual=\'"$see_manual"\'
|
||||
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||
--keyword=proper_name:1,'"$see_manual"'\\\
|
||||
--keyword=proper_name_utf8:1,'"$see_manual"'\\\
|
||||
--keyword=proper_name_lite:1,'"$see_manual"'\\\
|
||||
'
|
||||
|
||||
gnulib_tool_option_extras="--tests-base=gnulib-tests --with-tests --symlink\
|
||||
@@ -364,11 +355,13 @@ gettext 0.19.2
|
||||
git 1.4.4
|
||||
gperf -
|
||||
gzip -
|
||||
m4 -
|
||||
makeinfo 6.1
|
||||
texi2pdf 6.1
|
||||
patch -
|
||||
perl 5.5
|
||||
rsync -
|
||||
tar -
|
||||
wget -
|
||||
xz -
|
||||
"
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ build_if_possible_progs='
|
||||
stdbuf
|
||||
stty
|
||||
timeout
|
||||
uptime
|
||||
users
|
||||
who
|
||||
'
|
||||
@@ -132,6 +131,7 @@ normal_progs='
|
||||
unexpand
|
||||
uniq
|
||||
unlink
|
||||
uptime
|
||||
vdir
|
||||
wc
|
||||
whoami
|
||||
|
||||
@@ -71,6 +71,7 @@ override_single() {
|
||||
override_single dir ls
|
||||
override_single vdir ls
|
||||
override_single arch uname
|
||||
override_single chgrp chown
|
||||
|
||||
for cmd in $ALL_PROGRAMS; do
|
||||
echo "# Command $cmd"
|
||||
|
||||
91
cfg.mk
91
cfg.mk
@@ -1,5 +1,5 @@
|
||||
# Customize maint.mk -*- makefile -*-
|
||||
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -26,7 +26,6 @@ VC_LIST_ALWAYS_EXCLUDE_REGEX = src/blake2/.*$$
|
||||
|
||||
# Tests not to run as part of "make distcheck".
|
||||
local-checks-to-skip = \
|
||||
sc_proper_name_utf8_requires_ICONV \
|
||||
sc_indent
|
||||
|
||||
# Tools used to bootstrap this package, used for "announcement".
|
||||
@@ -49,10 +48,11 @@ export VERBOSE = yes
|
||||
# 4914152 9e
|
||||
export XZ_OPT = -8e
|
||||
|
||||
old_NEWS_hash = 72a8f8283d3c9daef72e06be5bb52734
|
||||
old_NEWS_hash = d66ee7a9fdb974017a4a17cf358d047d
|
||||
|
||||
# Add an exemption for sc_makefile_at_at_check.
|
||||
_makefile_at_at_check_exceptions = ' && !/^cu_install_prog/ && !/dynamic-dep/'
|
||||
_makefile_at_at_check_exceptions = \
|
||||
' && !/MAKEINFO/ && !/^cu_install_prog/ && !/dynamic-dep/'
|
||||
|
||||
# Our help-version script is in a slightly different location.
|
||||
_hv_file ?= $(srcdir)/tests/misc/help-version
|
||||
@@ -189,12 +189,15 @@ sc_prohibit_quotes_notation:
|
||||
exit 1; } \
|
||||
|| :
|
||||
|
||||
error_fns = (error|diagnose)
|
||||
|
||||
# Files in src/ should quote all strings in error() output, so that
|
||||
# unexpected input chars like \r etc. don't corrupt the error.
|
||||
# In edge cases this can be avoided by putting the format string
|
||||
# on a separate line to the arguments, or the arguments in parenthesis.
|
||||
sc_error_quotes:
|
||||
@cd $(srcdir)/src && GIT_PAGER= git grep -n 'error *(.*%s.*, [^(]*);$$'\
|
||||
@cd $(srcdir)/src \
|
||||
&& GIT_PAGER= git grep -E -n '$(error_fns) *\(.*%s.*, [^(]*\);$$' \
|
||||
*.c | grep -v ', q' \
|
||||
&& { echo '$(ME): '"Use quote() for error string arguments" 1>&2; \
|
||||
exit 1; } \
|
||||
@@ -206,7 +209,7 @@ sc_error_quotes:
|
||||
sc_error_shell_quotes:
|
||||
@cd $(srcdir)/src && \
|
||||
{ GIT_PAGER= git grep -E \
|
||||
'error \(.*%s[:"], .*(name|file)[^"]*\);$$' *.c; \
|
||||
'$(error_fns) \(.*%s[:"], .*(name|file)[^"]*\);$$' *.c; \
|
||||
GIT_PAGER= git grep -E \
|
||||
' quote[ _].*file' *.c; } \
|
||||
| grep -Ev '(quotef|q[^ ]*name)' \
|
||||
@@ -220,27 +223,17 @@ sc_error_shell_quotes:
|
||||
# to provide better support for copy and paste.
|
||||
sc_error_shell_always_quotes:
|
||||
@cd $(srcdir)/src && GIT_PAGER= git grep -E \
|
||||
'error \(.*[^:] %s[ "].*, .*(name|file)[^"]*\);$$' \
|
||||
'$(error_fns) \(.*[^:] %s[ "].*, .*(name|file)[^"]*\);$$' \
|
||||
*.c | grep -Ev '(quoteaf|q[^ ]*name)' \
|
||||
&& { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \
|
||||
exit 1; } \
|
||||
|| :
|
||||
@cd $(srcdir)/src && GIT_PAGER= git grep -E -A1 \
|
||||
'error \([^%]*[^:] %s[ "]' *.c | grep 'quotef' \
|
||||
'$(error_fns) \([^%]*[^:] %s[ "]' *.c | grep 'quotef' \
|
||||
&& { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \
|
||||
exit 1; } \
|
||||
|| :
|
||||
|
||||
# Usage of error() with an exit constant, should instead use die(),
|
||||
# as that avoids warnings and may generate better code, due to being apparent
|
||||
# to the compiler that it doesn't return.
|
||||
sc_die_EXIT_FAILURE:
|
||||
@cd $(srcdir)/src && GIT_PAGER= git grep -E \
|
||||
'error \([^?]*EXIT_' \
|
||||
&& { echo '$(ME): '"Use die() instead of error" 1>&2; \
|
||||
exit 1; } \
|
||||
|| :
|
||||
|
||||
# Avoid unstyled quoting to internal slots and thus destined for diagnostics
|
||||
# as that can leak unescaped control characters to the output, when using
|
||||
# the default "literal" quoting style.
|
||||
@@ -295,27 +288,6 @@ sc_check-AUTHORS: $(all_programs)
|
||||
&& diff $(au_actual) $(au_dotdot) \
|
||||
&& rm -f $(au_actual) $(au_dotdot)
|
||||
|
||||
# Each program with a non-ASCII author name must link with LIBICONV.
|
||||
sc_check-I18N-AUTHORS:
|
||||
@cd $(srcdir)/src && \
|
||||
for i in $$(git grep -l -w proper_name_utf8 *.c|sed 's/\.c//'); do \
|
||||
grep -E "^src_$${i}_LDADD"' .?= .*\$$\(LIBICONV\)' local.mk \
|
||||
> /dev/null \
|
||||
|| { echo "$(ME): link rules for $$i do not include" \
|
||||
'$$(LIBICONV)' 1>&2; exit 1; }; \
|
||||
done
|
||||
|
||||
# Disallow the C99 printf size specifiers %z and %j as they're not portable.
|
||||
# The gnulib printf replacement does support them, however the printf
|
||||
# replacement is not currently explicitly depended on by the gnulib error()
|
||||
# module for example. Also we use fprintf() in a few places to output simple
|
||||
# formats but don't use the gnulib module as it is seen as overkill at present.
|
||||
# We'd have to adjust the above gnulib items before disabling this.
|
||||
sc_prohibit-c99-printf-format:
|
||||
@cd $(srcdir)/src && GIT_PAGER= git grep -n '%[0*]*[jz][udx]' *.c \
|
||||
&& { echo '$(ME): Use PRI*MAX instead of %j or %z' 1>&2; exit 1; } \
|
||||
|| :
|
||||
|
||||
# Ensure the alternative __attribute (keyword) form isn't used as
|
||||
# that form is not elided where required. Also ensure that we don't
|
||||
# directly use attributes already defined by gnulib.
|
||||
@@ -343,7 +315,7 @@ FILTER_LONG_LINES = \
|
||||
\|^[^:]*NEWS:.*https\{,1\}://| d; \
|
||||
\|^[^:]*doc/fdl.texi:| d; \
|
||||
\|^[^:]*man/help2man:| d; \
|
||||
\|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d; \
|
||||
\|^[^:]*tests/cksum/sha[0-9]*sum.*\.pl[-:]| d; \
|
||||
\|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
|
||||
sc_long_lines:
|
||||
@wc -L /dev/null >/dev/null 2>/dev/null \
|
||||
@@ -509,6 +481,18 @@ sc_prohibit_man_see_also_period:
|
||||
{ echo '$(ME): do not end "SEE ALSO" section with a period' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
sc_prohibit_exit_write_error:
|
||||
@prohibit='error.*EXIT_FAILURE.*write error' \
|
||||
in_vc_files='\.c$$' \
|
||||
halt='Use write_error() instead' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
sc_prohibit_NULL:
|
||||
@prohibit='$(begword)NULL$(endword)' \
|
||||
in_vc_files='\.[ch]$$' \
|
||||
halt='use nullptr instead' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
|
||||
sc_prohibit_emacs__indent_tabs_mode__setting:
|
||||
@prohibit='^( *[*#] *)?indent-tabs-mode:' \
|
||||
@@ -561,7 +545,7 @@ sc_prohibit_short_facl_mode_spec:
|
||||
# Ensure that "stdio--.h" is used where appropriate.
|
||||
sc_require_stdio_safer:
|
||||
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
|
||||
files=$$(grep -l '$(begword)freopen \?(' $$($(VC_LIST_EXCEPT) \
|
||||
files=$$(grep -El '$(begword)freopen ?\(' $$($(VC_LIST_EXCEPT)\
|
||||
| grep '\.[ch]$$')); \
|
||||
test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \
|
||||
| grep . && \
|
||||
@@ -570,6 +554,18 @@ sc_require_stdio_safer:
|
||||
else :; \
|
||||
fi
|
||||
|
||||
# Ensure that "stdlib--.h" is used where appropriate.
|
||||
sc_require_stdlib_safer:
|
||||
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
|
||||
files=$$(grep -El '$(begword)mkstemp ?\(' $$($(VC_LIST_EXCEPT)\
|
||||
| grep '\.[ch]$$')); \
|
||||
test -n "$$files" && grep -LE 'include "stdlib--.h"' $$files \
|
||||
| grep . && \
|
||||
{ echo '$(ME): the above files should use "stdlib--.h"' \
|
||||
1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
|
||||
sc_prohibit_perl_hash_quotes:
|
||||
@prohibit="\{'[A-Z_]+' *[=}]" \
|
||||
halt="in Perl code, write \$$hash{KEY}, not \$$hash{'K''EY'}" \
|
||||
@@ -626,7 +622,8 @@ sc_prohibit_test_empty:
|
||||
sc_some_programs_must_avoid_exit_failure:
|
||||
@cd $(srcdir) \
|
||||
&& grep -nw EXIT_FAILURE \
|
||||
$$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' $(srcdir)/src) \
|
||||
$$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' src/) \
|
||||
| grep -v '^src/system\.h:' \
|
||||
| grep -vE '= EXIT_FAILURE|return .* \?' | grep . \
|
||||
&& { echo '$(ME): do not use EXIT_FAILURE in the above' \
|
||||
1>&2; exit 1; } || :
|
||||
@@ -842,9 +839,10 @@ exclude_file_name_regexp--sc_bindtextdomain = \
|
||||
exclude_file_name_regexp--sc_trailing_blank = \
|
||||
^(tests/pr/|gl/.*\.diff$$|man/help2man)
|
||||
exclude_file_name_regexp--sc_system_h_headers = \
|
||||
^src/((die|system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
|
||||
^src/((system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
|
||||
|
||||
_src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
|
||||
_src := (false|lbracket|chown-(chgrp|chown)
|
||||
_src := $(_src)|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
|
||||
_gl_src = (xdecto.max|cl-strtold)
|
||||
exclude_file_name_regexp--sc_require_config_h_first = \
|
||||
(^lib/buffer-lcm\.c|gl/lib/$(_gl_src)\.c|src/$(_src)\.c)$$
|
||||
@@ -885,7 +883,7 @@ exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
|
||||
exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \
|
||||
^src/(system\.h|od\.c|printf\.c|getlimits\.c)$$
|
||||
|
||||
_cksum = ^tests/misc/cksum-base64\.pl$$
|
||||
_cksum = ^tests/cksum/cksum-base64\.pl$$
|
||||
exclude_file_name_regexp--sc_prohibit_test_backticks = \
|
||||
^tests/(local\.mk|(init|misc/stdbuf|factor/create-test)\.sh)$$|$(_cksum)
|
||||
|
||||
@@ -929,6 +927,9 @@ _gl_TS_other_headers = $(srcdir)/src/*.h src/*.h
|
||||
# Normally, the rule would detect its declaration, but that uses a
|
||||
# different name, __clz_tab.
|
||||
_gl_TS_unmarked_extern_vars = factor_clz_tab
|
||||
# Avoid tight_scope rule stating these should be static
|
||||
# as there is no way to achieve that with the way these are defined.
|
||||
_gl_TS_unmarked_extern_vars += ptr_MD5_.*
|
||||
# Other tight_scope settings
|
||||
_gl_TS_dir = .
|
||||
_gl_TS_obj_files = src/*.$(OBJEXT)
|
||||
|
||||
270
configure.ac
270
configure.ac
@@ -1,7 +1,7 @@
|
||||
# -*- autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1991-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991-2024 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
|
||||
@@ -55,7 +55,6 @@ gl_ASSERT_NO_GNULIB_POSIXCHECK])
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CPP
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_EGREP
|
||||
AC_PROG_LN_S
|
||||
@@ -64,6 +63,26 @@ gl_SET_CRYPTO_CHECK_DEFAULT([auto-gpl-compat])
|
||||
gl_INIT
|
||||
coreutils_MACROS
|
||||
|
||||
# These are safe, since 'sort', coreutils's only multithreaded app,
|
||||
# does not use the relevant modules.
|
||||
AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1],
|
||||
[Define to 1 if apps call 'exclude' functions from a single thread.])
|
||||
AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1],
|
||||
[Define to 1 if apps call 'regex' functions from a single thread.])
|
||||
# Although 'sort' is multithreaded and can use these functions,
|
||||
# it uses them only from the main thread.
|
||||
AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1],
|
||||
[Define to 1 if apps call mbrtowc, mbrtoc32, and 'regex' functions
|
||||
from a single thread.])
|
||||
# This is safe, since all apps set locale early.
|
||||
AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1],
|
||||
[Define to 1 if apps don't set the locale after calling
|
||||
locale-sensitive functions like mbrtowc and wcwidth.])
|
||||
|
||||
AC_DEFINE([GNULIB_MBRTOC32_REGULAR], [1],
|
||||
[Do not worry about rare encodings like CP864, EBCDIC, Johab, and Shift JIS
|
||||
that glibc does not support.])
|
||||
|
||||
# The test suite needs to know if we have a working perl.
|
||||
AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
|
||||
|
||||
@@ -153,6 +172,13 @@ AC_ARG_ENABLE([gcc-warnings],
|
||||
&& gl_gcc_warnings=yes])]
|
||||
)
|
||||
|
||||
# clang is unduly picky about some things, even by default.
|
||||
if test "$gl_cv_compiler_clang" = yes; then
|
||||
gl_WARN_ADD([-Wno-format-extra-args])
|
||||
gl_WARN_ADD([-Wno-implicit-const-int-float-conversion])
|
||||
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
|
||||
fi
|
||||
|
||||
if test $gl_gcc_warnings != no; then
|
||||
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
|
||||
AC_SUBST([WERROR_CFLAGS])
|
||||
@@ -160,8 +186,7 @@ if test $gl_gcc_warnings != no; then
|
||||
ew=
|
||||
AS_IF([test $gl_gcc_warnings != expensive],
|
||||
[# -fanalyzer and related options slow GCC considerably.
|
||||
ew="$ew -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak"
|
||||
ew="$ew -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"])
|
||||
ew="$ew -fanalyzer -Wno-analyzer-malloc-leak"])
|
||||
|
||||
# This, $nw, is the list of warnings we disable.
|
||||
nw=$ew
|
||||
@@ -184,7 +209,7 @@ if test $gl_gcc_warnings != no; then
|
||||
nw="$nw -Wswitch-enum" # Too many warnings for now
|
||||
nw="$nw -Wswitch-default" # Too many warnings for now
|
||||
nw="$nw -Wstack-protector" # not worth working around
|
||||
nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 80776
|
||||
nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 110333
|
||||
nw="$nw -Wformat-truncation=2" # False alarm in ls.c, probably related
|
||||
# things I might fix soon:
|
||||
nw="$nw -Wfloat-equal" # sort.c, seq.c
|
||||
@@ -214,21 +239,6 @@ if test $gl_gcc_warnings != no; then
|
||||
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
|
||||
gl_WARN_ADD([-Wno-format-nonliteral])
|
||||
|
||||
# clang is unduly picky about some things.
|
||||
AC_CACHE_CHECK([whether the compiler is clang], [utils_cv_clang],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#ifndef __clang__
|
||||
#error "not clang"
|
||||
#endif
|
||||
]])],
|
||||
[utils_cv_clang=yes],
|
||||
[utils_cv_clang=no])])
|
||||
if test $utils_cv_clang = yes; then
|
||||
gl_WARN_ADD([-Wno-format-extra-args])
|
||||
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
|
||||
fi
|
||||
|
||||
gl_WARN_ADD([-fdiagnostics-show-option])
|
||||
gl_WARN_ADD([-funit-at-a-time])
|
||||
|
||||
@@ -262,6 +272,10 @@ if test $gl_gcc_warnings != no; then
|
||||
# FP in careadlinkat.c w/gcc 10.0.1 20200205
|
||||
gl_WARN_ADD([-Wno-return-local-addr])
|
||||
|
||||
# FIXME: remove this line when gcc improves
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
|
||||
gl_WARN_ADD([-Wno-stringop-overflow])
|
||||
|
||||
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
||||
AC_SUBST([GNULIB_WARN_CFLAGS])
|
||||
|
||||
@@ -337,6 +351,51 @@ if test $utils_cv_localtime_cache = yes; then
|
||||
AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
|
||||
fi
|
||||
|
||||
# Find the library for dynamic loading of shared libraries.
|
||||
AC_SEARCH_LIBS([dlopen], [dl])
|
||||
AS_CASE([$ac_cv_search_dlopen],
|
||||
[no | 'none required'],
|
||||
[LIB_DL=],
|
||||
[*],
|
||||
[LIB_DL="$ac_cv_search_dlopen"])
|
||||
AC_SUBST([LIB_DL])
|
||||
|
||||
# Should 'sort' link libcrypto dynamically?
|
||||
AS_CASE([$LIB_CRYPTO],
|
||||
[-lcrypto],
|
||||
[# Check for dlopen and libcrypto dynamic linking in one program,
|
||||
# as there's little point to checking them separately.
|
||||
AC_CACHE_CHECK([for dlopen and whether libcrypto is linked dynamically],
|
||||
[utils_cv_dlopen_libcrypto],
|
||||
[utils_cv_dlopen_libcrypto=no
|
||||
saved_LIBS=$LIBS
|
||||
LIBS="$LIBS $LIB_DL $LIB_CRYPTO"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <dlfcn.h>
|
||||
#include <openssl/sha.h>
|
||||
/* Use SHA512 rather than MD5 here to avoid deprecation warnings.
|
||||
So need to check HAVE_OPENSSL_MD5.. with DLOPEN_LIBCRYPTO. */
|
||||
]],
|
||||
[[return !(dlopen ("libcrypto.so", RTLD_LAZY | RTLD_GLOBAL)
|
||||
&& SHA512 (0, 0, 0));]])],
|
||||
[# readelf works with cross-builds; ldd works on more platforms.
|
||||
LIBCRYPTO_SONAME="`(readelf -d conftest$EXEEXT || ldd conftest$EXEEXT
|
||||
) 2>/dev/null |
|
||||
sed -n 's/.*\(libcrypto\.so\.[[.0-9]]*\).*/\1/p'`"
|
||||
AS_CASE([$LIBCRYPTO_SONAME],
|
||||
[*libcrypto*],
|
||||
[utils_cv_dlopen_libcrypto=yes])])
|
||||
LIBS=$saved_LIBS])
|
||||
AS_CASE([$utils_cv_dlopen_libcrypto],
|
||||
[yes],
|
||||
[AC_DEFINE([DLOPEN_LIBCRYPTO], [1],
|
||||
[Define to 1 if dlopen exists and libcrypto is
|
||||
linked dynamically.])
|
||||
AC_DEFINE_UNQUOTED([LIBCRYPTO_SONAME], ["$LIBCRYPTO_SONAME"],
|
||||
[versioned libcrypto])
|
||||
])])
|
||||
|
||||
# macOS >= 10.12
|
||||
AC_CHECK_FUNCS([fclonefileat])
|
||||
|
||||
@@ -403,38 +462,6 @@ AC_DEFUN([coreutils_DUMMY_1],
|
||||
])
|
||||
coreutils_DUMMY_1
|
||||
|
||||
AC_MSG_CHECKING([ut_host in struct utmp])
|
||||
AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||
#include <utmp.h>
|
||||
struct utmp ut;
|
||||
int s = 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])
|
||||
if test $su_cv_func_ut_host_in_utmp = yes; then
|
||||
have_ut_host=1
|
||||
AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
|
||||
fi
|
||||
|
||||
if test -z "$have_ut_host"; then
|
||||
AC_MSG_CHECKING([ut_host in struct utmpx])
|
||||
AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||
#include <utmpx.h>
|
||||
struct utmpx ut;
|
||||
int s = 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])
|
||||
if test $su_cv_func_ut_host_in_utmpx = yes; then
|
||||
AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
|
||||
AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
|
||||
fi
|
||||
fi
|
||||
|
||||
GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
|
||||
|
||||
AC_SYS_POSIX_TERMIOS()
|
||||
gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
|
||||
|
||||
@@ -500,11 +527,6 @@ if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
|
||||
[Define if your system defines TIOCGWINSZ in sys/pty.h.])
|
||||
fi
|
||||
|
||||
# For src/kill.c.
|
||||
AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#include <signal.h>])
|
||||
|
||||
# Build df only if there's a point to it.
|
||||
if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
|
||||
gl_ADD_PROG([optional_bin_progs], [df])
|
||||
@@ -522,7 +544,8 @@ gl_WARN_ADD([-errwarn], [CFLAGS])
|
||||
AC_MSG_CHECKING([whether this system supports stdbuf])
|
||||
CFLAGS="-fPIC $CFLAGS"
|
||||
LDFLAGS="-shared $LDFLAGS"
|
||||
stdbuf_supported=no
|
||||
AC_CACHE_VAL([utils_cv_stdbuf_supported],[
|
||||
utils_cv_stdbuf_supported=no
|
||||
# Note we only LINK here rather than RUN to support cross compilation
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
@@ -536,40 +559,69 @@ AC_LINK_IFELSE(
|
||||
if (stdbuf != 1)
|
||||
return 1;]])
|
||||
],
|
||||
[stdbuf_supported=yes])
|
||||
AC_MSG_RESULT([$stdbuf_supported])
|
||||
if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
|
||||
[utils_cv_stdbuf_supported=yes])])
|
||||
AC_MSG_RESULT([$utils_cv_stdbuf_supported])
|
||||
if test "$utils_cv_stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
|
||||
gl_ADD_PROG([optional_bin_progs], [stdbuf])
|
||||
fi
|
||||
CFLAGS=$ac_save_CFLAGS
|
||||
LDFLAGS=$ac_save_LDFLAGS
|
||||
ac_c_werror_flag=$cu_save_c_werror_flag
|
||||
|
||||
AC_MSG_CHECKING([if __get_cpuid available])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <cpuid.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
unsigned int eax, ebx, ecx, edx;
|
||||
__get_cpuid (1, &eax, &ebx, &ecx, &edx);
|
||||
return 1;
|
||||
}
|
||||
# Test compiler support for half precision floating point types (for od)
|
||||
AC_MSG_CHECKING([IEEE 16 bit floating point])
|
||||
AC_CACHE_VAL([utils_cv_ieee_16_bit_supported],[
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
volatile _Float16 hf = 1;
|
||||
float f = hf; /* Ensure compiler can promote to float. */
|
||||
return !(f == 1.0f);
|
||||
}
|
||||
]])
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([HAVE_CPUID], [1], [__get_cpuid available])
|
||||
cpuid_exists=yes
|
||||
utils_cv_ieee_16_bit_supported=yes
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
utils_cv_ieee_16_bit_supported=no
|
||||
],[
|
||||
utils_cv_ieee_16_bit_supported=no
|
||||
])])
|
||||
AC_MSG_RESULT([$utils_cv_ieee_16_bit_supported])
|
||||
if test $utils_cv_ieee_16_bit_supported = yes; then
|
||||
AC_DEFINE([FLOAT16_SUPPORTED], [1], [IEEE 16 bit float supported])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([Brain 16 bit floating point])
|
||||
AC_CACHE_VAL([utils_cv_brain_16_bit_supported],[
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
volatile __bf16 hf = 1;
|
||||
float f = hf; /* Ensure compiler can promote to float. */
|
||||
return !(f == 1.0f);
|
||||
}
|
||||
]])
|
||||
],[
|
||||
utils_cv_brain_16_bit_supported=yes
|
||||
],[
|
||||
utils_cv_brain_16_bit_supported=no
|
||||
],[
|
||||
utils_cv_brain_16_bit_supported=no
|
||||
])])
|
||||
AC_MSG_RESULT([$utils_cv_brain_16_bit_supported])
|
||||
if test $utils_cv_brain_16_bit_supported = yes; then
|
||||
AC_DEFINE([BF16_SUPPORTED], [1], [Brain 16 bit float supported])
|
||||
fi
|
||||
|
||||
ac_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="-mavx -mpclmul $CFLAGS"
|
||||
AC_MSG_CHECKING([if pclmul intrinsic exists])
|
||||
AC_COMPILE_IFELSE(
|
||||
AC_CACHE_VAL([utils_cv_pclmul_intrinsic_exists],[
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <x86intrin.h>
|
||||
|
||||
@@ -578,49 +630,28 @@ AC_COMPILE_IFELSE(
|
||||
{
|
||||
__m128i a, b;
|
||||
a = _mm_clmulepi64_si128 (a, b, 0x00);
|
||||
return 1;
|
||||
a = _mm_shuffle_epi8 (a, b);
|
||||
return __builtin_cpu_supports ("pclmul");
|
||||
}
|
||||
]])
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([HAVE_PCLMUL_INTRINSIC], [1], [pclmul intrinsic exists])
|
||||
pclmul_intrinsic_exists=yes
|
||||
utils_cv_pclmul_intrinsic_exists=yes
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
if test "x$cpuid_exists" = "xyes" &&
|
||||
test "x$pclmul_intrinsic_exists" = "xyes"; then
|
||||
utils_cv_pclmul_intrinsic_exists=no
|
||||
])])
|
||||
AC_MSG_RESULT([$utils_cv_pclmul_intrinsic_exists])
|
||||
if test $utils_cv_pclmul_intrinsic_exists = yes; then
|
||||
AC_DEFINE([USE_PCLMUL_CRC32], [1],
|
||||
[CRC32 calculation by pclmul hardware instruction enabled])
|
||||
fi
|
||||
AM_CONDITIONAL([USE_PCLMUL_CRC32],
|
||||
[test "x$cpuid_exists" = "xyes" &&
|
||||
test "x$pclmul_intrinsic_exists" = "xyes"])
|
||||
[test $utils_cv_pclmul_intrinsic_exists = yes])
|
||||
CFLAGS=$ac_save_CFLAGS
|
||||
|
||||
AC_MSG_CHECKING([if __get_cpuid_count exists])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <cpuid.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
|
||||
__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx);
|
||||
return 1;
|
||||
}
|
||||
]])
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
get_cpuid_count_exists=yes
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
|
||||
CFLAGS="-mavx2 $CFLAGS"
|
||||
AC_MSG_CHECKING([if avx2 intrinstics exists])
|
||||
AC_COMPILE_IFELSE(
|
||||
AC_MSG_CHECKING([for avx2 intrinsics])
|
||||
AC_CACHE_VAL([utils_cv_avx2_intrinsic_exists],[
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <x86intrin.h>
|
||||
|
||||
@@ -629,23 +660,20 @@ AC_COMPILE_IFELSE(
|
||||
{
|
||||
__m256i a, b;
|
||||
a = _mm256_sad_epu8 (a, b);
|
||||
return 1;
|
||||
return __builtin_cpu_supports ("avx2");
|
||||
}
|
||||
]])
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([HAVE_AVX2_INTRINSIC], [1], [avx2 intrinsics exists])
|
||||
avx2_intrinsic_exists=yes
|
||||
utils_cv_avx2_intrinsic_exists=yes
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
if test "x$get_cpuid_count_exists" = "xyes" &&
|
||||
test "x$avx2_intrinsic_exists" = "xyes"; then
|
||||
utils_cv_avx2_intrinsic_exists=no
|
||||
])])
|
||||
AC_MSG_RESULT([$utils_cv_avx2_intrinsic_exists])
|
||||
if test $utils_cv_avx2_intrinsic_exists = yes; then
|
||||
AC_DEFINE([USE_AVX2_WC_LINECOUNT], [1], [Counting lines with AVX2 enabled])
|
||||
fi
|
||||
AM_CONDITIONAL([USE_AVX2_WC_LINECOUNT],
|
||||
[test "x$get_cpuid_count_exists" = "xyes" &&
|
||||
test "x$avx2_intrinsic_exists" = "xyes"])
|
||||
[test $utils_cv_avx2_intrinsic_exists = yes])
|
||||
|
||||
CFLAGS=$ac_save_CFLAGS
|
||||
|
||||
|
||||
1065
doc/coreutils.texi
1065
doc/coreutils.texi
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
# Make coreutils documentation. -*-Makefile-*-
|
||||
# This is included by the top-level Makefile.am.
|
||||
|
||||
# Copyright (C) 1995-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1995-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -25,6 +25,10 @@ doc_coreutils_TEXINFOS = \
|
||||
doc/fdl.texi \
|
||||
doc/sort-version.texi
|
||||
|
||||
# The customization variable CHECK_NORMAL_MENU_STRUCTURE is necessary with
|
||||
# makeinfo versions ≥ 6.8.
|
||||
MAKEINFO = @MAKEINFO@ -c CHECK_NORMAL_MENU_STRUCTURE=1
|
||||
|
||||
# The following is necessary if the package name is 8 characters or longer.
|
||||
# If the info documentation would be split into 10 or more separate files,
|
||||
# then this is necessary even if the package name is 7 characters long.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@c File mode bits
|
||||
|
||||
@c Copyright (C) 1994--2023 Free Software Foundation, Inc.
|
||||
@c Copyright (C) 1994--2024 Free Software Foundation, Inc.
|
||||
|
||||
@c Permission is granted to copy, distribute and/or modify this document
|
||||
@c under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@c GNU Version-sort ordering documentation
|
||||
|
||||
@c Copyright (C) 2019--2023 Free Software Foundation, Inc.
|
||||
@c Copyright (C) 2019--2024 Free Software Foundation, Inc.
|
||||
|
||||
@c Permission is granted to copy, distribute and/or modify this document
|
||||
@c under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
@@ -843,7 +843,7 @@ natsort -- how it works}).
|
||||
Ruby's @uref{https://github.com/github/version_sorter,version_sorter}.
|
||||
|
||||
@item
|
||||
Perl has multiple packages for natual and version sorts
|
||||
Perl has multiple packages for natural and version sorts
|
||||
(each likely with its own rules and nuances):
|
||||
@uref{https://metacpan.org/pod/Sort::Naturally,Sort::Naturally},
|
||||
@uref{https://metacpan.org/pod/Sort::Versions,Sort::Versions},
|
||||
@@ -865,7 +865,7 @@ glob modifier} @samp{*(n)} will expand to files in natural sort order.
|
||||
When writing C programs, the GNU libc library (@samp{glibc})
|
||||
provides the
|
||||
@uref{https://man7.org/linux/man-pages/man3/strverscmp.3.html,
|
||||
strvercmp(3)} function to compare two strings, and
|
||||
strverscmp(3)} function to compare two strings, and
|
||||
@uref{https://man7.org/linux/man-pages/man3/versionsort.3.html,versionsort(3)}
|
||||
function to compare two directory entries (despite the names, they are
|
||||
not identical to GNU Coreutils version sort ordering).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* buffer-lcm.c - compute a good buffer size for dealing with two files
|
||||
|
||||
Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Convert string to double in the current locale, falling back on the C locale.
|
||||
|
||||
Copyright 2019-2023 Free Software Foundation, Inc.
|
||||
Copyright 2019-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -46,7 +46,7 @@
|
||||
Parse the initial prefix of NPTR as a floating-point number in the
|
||||
current locale or in the C locale (preferring the locale that
|
||||
yields the longer parse, or the current locale if there is a tie).
|
||||
If ENDPTR is not NULL, set *ENDPTR to the first unused byte, or to
|
||||
If ENDPTR is non-null, set *ENDPTR to the first unused byte, or to
|
||||
NPTR if the prefix cannot be parsed.
|
||||
|
||||
If successful, return a number without changing errno.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declare an access pattern hint for files.
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 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
|
||||
@@ -14,12 +14,6 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Without this pragma, gcc suggests that (given !HAVE_POSIX_FADVISE)
|
||||
the fdadvise function might be a candidate for attribute 'const'. */
|
||||
#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
#include "fadvise.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declare an access pattern hint for files.
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Invoke open, but return either a desired file descriptor or -1.
|
||||
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Invoke open, but return either a desired file descriptor or -1.
|
||||
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Barebones heap implementation supporting only insert and pop.
|
||||
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 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
|
||||
@@ -50,7 +50,7 @@ heap_alloc (int (*compare) (void const *, void const *), size_t n_reserve)
|
||||
|
||||
heap->array = xnmalloc (n_reserve, sizeof *(heap->array));
|
||||
|
||||
heap->array[0] = NULL;
|
||||
heap->array[0] = nullptr;
|
||||
heap->capacity = n_reserve;
|
||||
heap->count = 0;
|
||||
heap->compare = compare ? compare : heap_default_compare;
|
||||
@@ -96,7 +96,7 @@ heap_remove_top (struct heap *heap)
|
||||
void *top;
|
||||
|
||||
if (heap->count == 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
top = heap->array[1];
|
||||
heap->array[1] = heap->array[heap->count--];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Barebones heap implementation supporting only insert and pop.
|
||||
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
/* Align/Truncate a string in a given screen width
|
||||
Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Pádraig Brady. */
|
||||
|
||||
#include <config.h>
|
||||
#include "mbsalign.h"
|
||||
|
||||
#include "minmax.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
/* Replace non printable chars.
|
||||
Note \t and \n etc. are non printable.
|
||||
Return 1 if replacement made, 0 otherwise. */
|
||||
|
||||
static bool
|
||||
wc_ensure_printable (wchar_t *wchars)
|
||||
{
|
||||
bool replaced = false;
|
||||
wchar_t *wc = wchars;
|
||||
while (*wc)
|
||||
{
|
||||
if (!iswprint ((wint_t) *wc))
|
||||
{
|
||||
*wc = 0xFFFD; /* L'\uFFFD' (replacement char) */
|
||||
replaced = true;
|
||||
}
|
||||
wc++;
|
||||
}
|
||||
return replaced;
|
||||
}
|
||||
|
||||
/* Truncate wchar string to width cells.
|
||||
* Returns number of cells used. */
|
||||
|
||||
static size_t
|
||||
wc_truncate (wchar_t *wc, size_t width)
|
||||
{
|
||||
size_t cells = 0;
|
||||
int next_cells = 0;
|
||||
|
||||
while (*wc)
|
||||
{
|
||||
next_cells = wcwidth (*wc);
|
||||
if (next_cells == -1) /* non printable */
|
||||
{
|
||||
*wc = 0xFFFD; /* L'\uFFFD' (replacement char) */
|
||||
next_cells = 1;
|
||||
}
|
||||
if (cells + next_cells > width)
|
||||
break;
|
||||
cells += next_cells;
|
||||
wc++;
|
||||
}
|
||||
*wc = L'\0';
|
||||
return cells;
|
||||
}
|
||||
|
||||
/* Write N_SPACES space characters to DEST while ensuring
|
||||
nothing is written beyond DEST_END. A terminating NUL
|
||||
is always added to DEST.
|
||||
A pointer to the terminating NUL is returned. */
|
||||
|
||||
static char *
|
||||
mbs_align_pad (char *dest, char const *dest_end, size_t n_spaces)
|
||||
{
|
||||
/* FIXME: Should we pad with "figure space" (\u2007)
|
||||
if non ascii data present? */
|
||||
while (n_spaces-- && (dest < dest_end))
|
||||
*dest++ = ' ';
|
||||
*dest = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* Align a string, SRC, in a field of *WIDTH columns, handling multi-byte
|
||||
characters; write the result into the DEST_SIZE-byte buffer, DEST.
|
||||
ALIGNMENT specifies whether to left- or right-justify or to center.
|
||||
If SRC requires more than *WIDTH columns, truncate it to fit.
|
||||
When centering, the number of trailing spaces may be one less than the
|
||||
number of leading spaces.
|
||||
Return the length in bytes required for the final result, not counting
|
||||
the trailing NUL. A return value of DEST_SIZE or larger means there
|
||||
wasn't enough space. DEST will be NUL terminated in any case.
|
||||
Return SIZE_MAX upon error (invalid multi-byte sequence in SRC,
|
||||
or malloc failure), unless MBA_UNIBYTE_FALLBACK is specified.
|
||||
Update *WIDTH to indicate how many columns were used before padding. */
|
||||
|
||||
size_t
|
||||
mbsalign (char const *src, char *dest, size_t dest_size,
|
||||
size_t *width, mbs_align_t align, int flags)
|
||||
{
|
||||
size_t ret = SIZE_MAX;
|
||||
size_t src_size = strlen (src) + 1;
|
||||
char *newstr = NULL;
|
||||
wchar_t *str_wc = NULL;
|
||||
char const *str_to_print = src;
|
||||
size_t n_cols = src_size - 1;
|
||||
size_t n_used_bytes = n_cols; /* Not including NUL */
|
||||
size_t n_spaces = 0;
|
||||
bool conversion = false;
|
||||
bool wc_enabled = false;
|
||||
|
||||
/* In multi-byte locales convert to wide characters
|
||||
to allow easy truncation. Also determine number
|
||||
of screen columns used. */
|
||||
if (!(flags & MBA_UNIBYTE_ONLY) && MB_CUR_MAX > 1)
|
||||
{
|
||||
size_t src_chars = mbstowcs (NULL, src, 0);
|
||||
if (src_chars == SIZE_MAX)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
else
|
||||
goto mbsalign_cleanup;
|
||||
}
|
||||
src_chars += 1; /* make space for NUL */
|
||||
str_wc = malloc (src_chars * sizeof (wchar_t));
|
||||
if (str_wc == NULL)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
else
|
||||
goto mbsalign_cleanup;
|
||||
}
|
||||
if (mbstowcs (str_wc, src, src_chars) != 0)
|
||||
{
|
||||
str_wc[src_chars - 1] = L'\0';
|
||||
wc_enabled = true;
|
||||
conversion = wc_ensure_printable (str_wc);
|
||||
n_cols = wcswidth (str_wc, src_chars);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we transformed or need to truncate the source string
|
||||
then create a modified copy of it. */
|
||||
if (wc_enabled && (conversion || (n_cols > *width)))
|
||||
{
|
||||
if (conversion)
|
||||
{
|
||||
/* May have increased the size by converting
|
||||
\t to \uFFFD for example. */
|
||||
src_size = wcstombs (NULL, str_wc, 0) + 1;
|
||||
}
|
||||
newstr = malloc (src_size);
|
||||
if (newstr == NULL)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
else
|
||||
goto mbsalign_cleanup;
|
||||
}
|
||||
str_to_print = newstr;
|
||||
n_cols = wc_truncate (str_wc, *width);
|
||||
n_used_bytes = wcstombs (newstr, str_wc, src_size);
|
||||
}
|
||||
|
||||
mbsalign_unibyte:
|
||||
|
||||
if (n_cols > *width) /* Unibyte truncation required. */
|
||||
{
|
||||
n_cols = *width;
|
||||
n_used_bytes = n_cols;
|
||||
}
|
||||
|
||||
if (*width > n_cols) /* Padding required. */
|
||||
n_spaces = *width - n_cols;
|
||||
|
||||
/* indicate to caller how many cells needed (not including padding). */
|
||||
*width = n_cols;
|
||||
|
||||
{
|
||||
size_t start_spaces, end_spaces;
|
||||
|
||||
switch (align)
|
||||
{
|
||||
case MBS_ALIGN_LEFT:
|
||||
start_spaces = 0;
|
||||
end_spaces = n_spaces;
|
||||
break;
|
||||
case MBS_ALIGN_RIGHT:
|
||||
start_spaces = n_spaces;
|
||||
end_spaces = 0;
|
||||
break;
|
||||
case MBS_ALIGN_CENTER:
|
||||
default:
|
||||
start_spaces = n_spaces / 2 + n_spaces % 2;
|
||||
end_spaces = n_spaces / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (flags & MBA_NO_LEFT_PAD)
|
||||
start_spaces = 0;
|
||||
if (flags & MBA_NO_RIGHT_PAD)
|
||||
end_spaces = 0;
|
||||
|
||||
/* Write as much NUL terminated output to DEST as possible. */
|
||||
if (dest_size != 0)
|
||||
{
|
||||
size_t space_left;
|
||||
char *dest_end = dest + dest_size - 1;
|
||||
|
||||
dest = mbs_align_pad (dest, dest_end, start_spaces);
|
||||
space_left = dest_end - dest;
|
||||
dest = mempcpy (dest, str_to_print, MIN (n_used_bytes, space_left));
|
||||
mbs_align_pad (dest, dest_end, end_spaces);
|
||||
}
|
||||
|
||||
/* indicate to caller how many bytes needed (not including NUL). */
|
||||
ret = n_used_bytes + ((start_spaces + end_spaces) * 1);
|
||||
}
|
||||
|
||||
mbsalign_cleanup:
|
||||
|
||||
free (str_wc);
|
||||
free (newstr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* A wrapper around mbsalign() to dynamically allocate the
|
||||
minimum amount of memory to store the result.
|
||||
Return NULL on failure. */
|
||||
|
||||
char *
|
||||
ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
|
||||
{
|
||||
size_t orig_width = *width;
|
||||
size_t size = *width; /* Start with enough for unibyte mode. */
|
||||
size_t req = size;
|
||||
char *buf = NULL;
|
||||
|
||||
while (req >= size)
|
||||
{
|
||||
char *nbuf;
|
||||
size = req + 1; /* Space for NUL. */
|
||||
nbuf = realloc (buf, size);
|
||||
if (nbuf == NULL)
|
||||
{
|
||||
free (buf);
|
||||
buf = NULL;
|
||||
break;
|
||||
}
|
||||
buf = nbuf;
|
||||
*width = orig_width;
|
||||
req = mbsalign (src, buf, size, width, align, flags);
|
||||
if (req == SIZE_MAX)
|
||||
{
|
||||
free (buf);
|
||||
buf = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/* Align/Truncate a string in a given screen width
|
||||
Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
|
||||
|
||||
enum {
|
||||
/* Use unibyte mode for invalid multibyte strings
|
||||
or when heap memory is exhausted. */
|
||||
MBA_UNIBYTE_FALLBACK = 0x0001,
|
||||
|
||||
/* As an optimization, don't do multibyte processing
|
||||
when we know no multibyte characters are present. */
|
||||
MBA_UNIBYTE_ONLY = 0x0002,
|
||||
|
||||
/* Don't add leading padding. */
|
||||
MBA_NO_LEFT_PAD = 0x0004,
|
||||
|
||||
/* Don't add trailing padding. */
|
||||
MBA_NO_RIGHT_PAD = 0x0008
|
||||
|
||||
#if 0 /* Other possible options. */
|
||||
/* Skip invalid multibyte chars rather than failing. */
|
||||
MBA_IGNORE_INVALID
|
||||
|
||||
/* Align multibyte strings using "figure space" (\u2007). */
|
||||
MBA_USE_FIGURE_SPACE
|
||||
|
||||
/* Don't truncate. */
|
||||
MBA_NO_TRUNCATE
|
||||
|
||||
/* Ensure no leading whitespace. */
|
||||
MBA_LSTRIP
|
||||
|
||||
/* Ensure no trailing whitespace. */
|
||||
MBA_RSTRIP
|
||||
#endif
|
||||
};
|
||||
|
||||
size_t
|
||||
mbsalign (char const *src, char *dest, size_t dest_size,
|
||||
size_t *width, mbs_align_t align, int flags)
|
||||
_GL_ATTRIBUTE_NONNULL ();
|
||||
|
||||
char *
|
||||
ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
|
||||
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
|
||||
_GL_ATTRIBUTE_NONNULL ();
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
|
||||
|
||||
Copyright (C) 1999-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998, 1999 Colin Plumb.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
|
||||
|
||||
Copyright (C) 1999-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998, 1999 Colin Plumb.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random integers.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -35,13 +35,13 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
randint i;
|
||||
randint n = strtoumax (argv[1], NULL, 10);
|
||||
randint choices = strtoumax (argv[2], NULL, 10);
|
||||
randint n = strtoumax (argv[1], nullptr, 10);
|
||||
randint choices = strtoumax (argv[2], nullptr, 10);
|
||||
char const *name = argv[3];
|
||||
struct randint_source *ints = randint_all_new (name, SIZE_MAX);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
printf ("%"PRIuMAX"\n", randint_choose (ints, choices));
|
||||
printf ("%ju\n", randint_choose (ints, choices));
|
||||
|
||||
return (randint_all_free (ints) == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
@@ -77,14 +77,14 @@ randint_new (struct randread_source *source)
|
||||
}
|
||||
|
||||
/* Create a new randint_source by creating a randread_source from
|
||||
NAME and ESTIMATED_BYTES. Return NULL (setting errno) if
|
||||
NAME and ESTIMATED_BYTES. Return nullptr (setting errno) if
|
||||
unsuccessful. */
|
||||
|
||||
struct randint_source *
|
||||
randint_all_new (char const *name, size_t bytes_bound)
|
||||
{
|
||||
struct randread_source *source = randread_new (name, bytes_bound);
|
||||
return (source ? randint_new (source) : NULL);
|
||||
return (source ? randint_new (source) : nullptr);
|
||||
}
|
||||
|
||||
/* Return the random data source of *S. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random integers.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random permutations.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 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
|
||||
@@ -109,7 +109,7 @@ typedef Hash_table sparse_map;
|
||||
static sparse_map *
|
||||
sparse_new (size_t size_hint)
|
||||
{
|
||||
return hash_initialize (size_hint, NULL, sparse_hash_, sparse_cmp_, free);
|
||||
return hash_initialize (size_hint, nullptr, sparse_hash_, sparse_cmp_, free);
|
||||
}
|
||||
|
||||
/* Swap the values for I and J. If a value is not already present
|
||||
@@ -154,7 +154,7 @@ sparse_free (sparse_map *sv)
|
||||
|
||||
/* 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. */
|
||||
Return nullptr if H is zero. */
|
||||
|
||||
size_t *
|
||||
randperm_new (struct randint_source *r, size_t h, size_t n)
|
||||
@@ -164,7 +164,7 @@ randperm_new (struct randint_source *r, size_t h, size_t n)
|
||||
switch (h)
|
||||
{
|
||||
case 0:
|
||||
v = NULL;
|
||||
v = nullptr;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -209,13 +209,13 @@ randperm_new (struct randint_source *r, size_t h, size_t n)
|
||||
if (sparse)
|
||||
{
|
||||
sv = sparse_new (h * 2);
|
||||
if (sv == NULL)
|
||||
if (sv == nullptr)
|
||||
xalloc_die ();
|
||||
v = xnmalloc (h, sizeof *v);
|
||||
}
|
||||
else
|
||||
{
|
||||
sv = NULL; /* To placate GCC's -Wuninitialized. */
|
||||
sv = nullptr; /* To placate GCC's -Wuninitialized. */
|
||||
v = xnmalloc (n, sizeof *v);
|
||||
for (i = 0; i < n; i++)
|
||||
v[i] = i;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate buffers of random data.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
|
||||
#include "assure.h"
|
||||
#include "minmax.h"
|
||||
#include "rand-isaac.h"
|
||||
#include "stdio-safer.h"
|
||||
@@ -45,9 +46,9 @@
|
||||
#include "xalloc.h"
|
||||
|
||||
#if _STRING_ARCH_unaligned || _STRING_INLINE_unaligned
|
||||
# define ALIGNED_POINTER(ptr, type) true
|
||||
# define POINTER_IS_ALIGNED(ptr, type) true
|
||||
#else
|
||||
# define ALIGNED_POINTER(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
|
||||
# define POINTER_IS_ALIGNED(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
|
||||
#endif
|
||||
|
||||
/* The maximum buffer size used for reads of random data. Using the
|
||||
@@ -103,11 +104,10 @@ struct randread_source
|
||||
static void
|
||||
randread_error (void const *file_name)
|
||||
{
|
||||
if (file_name)
|
||||
error (exit_failure, errno,
|
||||
errno == 0 ? _("%s: end of file") : _("%s: read error"),
|
||||
quote (file_name));
|
||||
abort ();
|
||||
affirm (exit_failure);
|
||||
error (exit_failure, errno,
|
||||
errno == 0 ? _("%s: end of file") : _("%s: read error"),
|
||||
quote (file_name));
|
||||
}
|
||||
|
||||
/* Simply return a new randread_source object with the default error
|
||||
@@ -132,7 +132,13 @@ get_nonce (void *buffer, size_t bufsize)
|
||||
char *buf = buffer, *buflim = buf + bufsize;
|
||||
while (buf < buflim)
|
||||
{
|
||||
ssize_t nbytes = getrandom (buf, buflim - buf, 0);
|
||||
#if defined __sun
|
||||
# define MAX_GETRANDOM 1024
|
||||
#else
|
||||
# define MAX_GETRANDOM SIZE_MAX
|
||||
#endif
|
||||
size_t max_bytes = MIN (buflim - buf, MAX_GETRANDOM);
|
||||
ssize_t nbytes = getrandom (buf, max_bytes, 0);
|
||||
if (0 <= nbytes)
|
||||
buf += nbytes;
|
||||
else if (errno != EINTR)
|
||||
@@ -161,21 +167,21 @@ randread_free_body (struct randread_source *s)
|
||||
default handler. Unless a non-default handler is used, NAME's
|
||||
lifetime should be at least that of the returned value.
|
||||
|
||||
Return NULL (setting errno) on failure. */
|
||||
Return nullptr (setting errno) on failure. */
|
||||
|
||||
struct randread_source *
|
||||
randread_new (char const *name, size_t bytes_bound)
|
||||
{
|
||||
if (bytes_bound == 0)
|
||||
return simple_new (NULL, NULL);
|
||||
return simple_new (nullptr, nullptr);
|
||||
else
|
||||
{
|
||||
FILE *source = NULL;
|
||||
FILE *source = nullptr;
|
||||
struct randread_source *s;
|
||||
|
||||
if (name)
|
||||
if (! (source = fopen_safer (name, "rb")))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
s = simple_new (source, name);
|
||||
|
||||
@@ -190,7 +196,7 @@ randread_new (char const *name, size_t bytes_bound)
|
||||
int e = errno;
|
||||
randread_free_body (s);
|
||||
errno = e;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
isaac_seed (&s->buf.isaac.state);
|
||||
}
|
||||
@@ -265,7 +271,7 @@ readisaac (struct isaac *isaac, void *p, size_t size)
|
||||
|
||||
/* If P is aligned, write to *P directly to avoid the overhead
|
||||
of copying from the buffer. */
|
||||
if (ALIGNED_POINTER (p, isaac_word))
|
||||
if (POINTER_IS_ALIGNED (p, isaac_word))
|
||||
{
|
||||
isaac_word *wp = p;
|
||||
while (ISAAC_BYTES <= size)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate buffers of random data.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* root-dev-ino.c -- get the device and inode numbers for '/'.
|
||||
Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2024 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,14 +23,14 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Call lstat to get the device and inode numbers for '/'.
|
||||
Upon failure, return NULL. Otherwise, set the members of
|
||||
Upon failure, return nullptr. Otherwise, set the members of
|
||||
*ROOT_D_I accordingly and return ROOT_D_I. */
|
||||
struct dev_ino *
|
||||
get_root_dev_ino (struct dev_ino *root_d_i)
|
||||
{
|
||||
struct stat statbuf;
|
||||
if (lstat ("/", &statbuf))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
root_d_i->st_ino = statbuf.st_ino;
|
||||
root_d_i->st_dev = statbuf.st_dev;
|
||||
return root_d_i;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Root device and inode number checking.
|
||||
|
||||
Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,7 +28,7 @@ get_root_dev_ino (struct dev_ino *root_d_i) _GL_ATTRIBUTE_NONNULL ();
|
||||
--preserve-root and --no-preserve-root options. */
|
||||
|
||||
# define ROOT_DEV_INO_CHECK(Root_dev_ino, Dir_statbuf) \
|
||||
(Root_dev_ino && SAME_INODE (*Dir_statbuf, *Root_dev_ino))
|
||||
(Root_dev_ino && PSAME_INODE (Dir_statbuf, Root_dev_ino))
|
||||
|
||||
# define ROOT_DEV_INO_WARN(Dirname) \
|
||||
do \
|
||||
|
||||
3
gl/lib/skipchars.c
Normal file
3
gl/lib/skipchars.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <config.h>
|
||||
#define SKIPCHARS_INLINE _GL_EXTERN_INLINE
|
||||
#include <skipchars.h>
|
||||
56
gl/lib/skipchars.h
Normal file
56
gl/lib/skipchars.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* Skipping sequences of characters satisfying a predicate
|
||||
|
||||
Copyright 2023-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "mcel.h"
|
||||
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
#ifndef SKIPCHARS_INLINE
|
||||
# define SKIPCHARS_INLINE _GL_INLINE
|
||||
#endif
|
||||
|
||||
/* Return the address just past the leading sequence of possibly
|
||||
multi-byte characters or encoding errors G in STR that satisfy
|
||||
PREDICATE (G) if OK is true, or that do not satisfy the predicate
|
||||
call if OK is false. */
|
||||
|
||||
SKIPCHARS_INLINE char *
|
||||
skip_str_matching (char const *str, bool (*predicate) (mcel_t), bool ok)
|
||||
{
|
||||
char const *s = str;
|
||||
for (mcel_t g; *s && predicate (g = mcel_scanz (s)) == ok;
|
||||
s += g.len)
|
||||
continue;
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
/* Return the address just past the leading sequence of possibly
|
||||
multi-byte characters or encoding errors G in BUF (which ends at LIM)
|
||||
that satisfy PREDICATE (G) if OK is true, or that do not satisfy
|
||||
the predicate call if OK is false. */
|
||||
|
||||
SKIPCHARS_INLINE char *
|
||||
skip_buf_matching (char const *buf, char const *lim,
|
||||
bool (*predicate) (mcel_t), bool ok)
|
||||
{
|
||||
char const *s = buf;
|
||||
for (mcel_t g; s < lim && predicate (g = mcel_scan (s, lim)) == ok;
|
||||
s += g.len)
|
||||
continue;
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
_GL_INLINE_HEADER_END
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Include and determine availability of smack routines
|
||||
Copyright (C) 2013-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2013-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -37,7 +37,7 @@ static inline bool
|
||||
is_smack_enabled (void)
|
||||
{
|
||||
#ifdef HAVE_SMACK
|
||||
return smack_smackfs_path () != NULL;
|
||||
return smack_smackfs_path () != nullptr;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Compare integer strings.
|
||||
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Compare numeric strings. This is an internal include file.
|
||||
|
||||
Copyright (C) 1988-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2024 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
|
||||
@@ -114,8 +114,8 @@ static inline int _GL_ATTRIBUTE_PURE
|
||||
numcompare (char const *a, char const *b,
|
||||
int decimal_point, int thousands_sep)
|
||||
{
|
||||
unsigned char tmpa = *a;
|
||||
unsigned char tmpb = *b;
|
||||
char tmpa = *a;
|
||||
char tmpb = *b;
|
||||
int tmp;
|
||||
size_t log_a;
|
||||
size_t log_b;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Compare numeric strings.
|
||||
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Target directory operands for coreutils
|
||||
|
||||
Copyright 2004-2023 Free Software Foundation, Inc.
|
||||
Copyright 2004-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Target directory operands for coreutils
|
||||
|
||||
Copyright 2022-2023 Free Software Foundation, Inc.
|
||||
Copyright 2022-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Convert decimal strings with bounds checking and exit on error.
|
||||
|
||||
Copyright (C) 2014-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2014-2024 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,12 +21,12 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "verify.h"
|
||||
#include "xstrtol.h"
|
||||
#include <error.h>
|
||||
#include <quote.h>
|
||||
#include <xstrtol.h>
|
||||
|
||||
/* Parse numeric string N_STR of base BASE, and return the value.
|
||||
Exit on parse error or if MIN or MAX are exceeded.
|
||||
@@ -40,7 +40,7 @@ __xnumtoint (char const *n_str, int base, __xdectoint_t min, __xdectoint_t max,
|
||||
strtol_error s_err;
|
||||
|
||||
__xdectoint_t tnum;
|
||||
s_err = __xstrtol (n_str, NULL, base, &tnum, suffixes);
|
||||
s_err = __xstrtol (n_str, nullptr, base, &tnum, suffixes);
|
||||
|
||||
if (s_err == LONGINT_OK)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ __xnumtoint (char const *n_str, int base, __xdectoint_t min, __xdectoint_t max,
|
||||
/* EINVAL error message is redundant in this context. */
|
||||
error (err_exit ? err_exit : EXIT_FAILURE, errno == EINVAL ? 0 : errno,
|
||||
"%s: %s", err, quote (n_str));
|
||||
assume (false);
|
||||
unreachable ();
|
||||
}
|
||||
|
||||
return tnum;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Convert decimal strings with bounds checking and exit on error.
|
||||
|
||||
Copyright (C) 2014-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2014-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* xfts.c -- a wrapper for fts_open
|
||||
|
||||
Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2024 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 <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "assure.h"
|
||||
#include "xalloc.h"
|
||||
#include "xfts.h"
|
||||
|
||||
@@ -33,11 +33,11 @@ xfts_open (char * const *argv, int options,
|
||||
int (*compar) (const FTSENT **, const FTSENT **))
|
||||
{
|
||||
FTS *fts = fts_open (argv, options | FTS_CWDFD, compar);
|
||||
if (fts == NULL)
|
||||
if (fts == nullptr)
|
||||
{
|
||||
/* This can fail in two ways: out of memory or with errno==EINVAL,
|
||||
which indicates it was called with invalid bit_flags. */
|
||||
assert (errno != EINVAL);
|
||||
affirm (errno != EINVAL);
|
||||
xalloc_die ();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
Description:
|
||||
Align/Truncate a string in a given screen width.
|
||||
|
||||
Files:
|
||||
lib/mbsalign.c
|
||||
lib/mbsalign.h
|
||||
|
||||
Depends-on:
|
||||
minmax
|
||||
wchar
|
||||
wctype
|
||||
wcwidth
|
||||
mempcpy
|
||||
stdint
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
lib_SOURCES += mbsalign.c mbsalign.h
|
||||
|
||||
Include:
|
||||
"mbsalign.h"
|
||||
|
||||
License:
|
||||
LGPL
|
||||
|
||||
Maintainer:
|
||||
Pádraig Brady
|
||||
@@ -1,11 +0,0 @@
|
||||
Files:
|
||||
tests/test-mbsalign.c
|
||||
tests/macros.h
|
||||
|
||||
Depends-on:
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
TESTS += test-mbsalign
|
||||
check_PROGRAMS += test-mbsalign
|
||||
24
gl/modules/skipchars
Normal file
24
gl/modules/skipchars
Normal file
@@ -0,0 +1,24 @@
|
||||
Description:
|
||||
Skip sequences of multi-byte characters or encoding errors
|
||||
|
||||
Files:
|
||||
lib/skipchars.c
|
||||
lib/skipchars.h
|
||||
|
||||
Depends-on:
|
||||
extern-inline
|
||||
mcel
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
lib_SOURCES += skipchars.c
|
||||
|
||||
Include:
|
||||
"skipchars.h"
|
||||
|
||||
License:
|
||||
GPL
|
||||
|
||||
Maintainer:
|
||||
all
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Test that fadvise works as advertised.
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 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
|
||||
@@ -36,7 +36,7 @@ main (void)
|
||||
fdadvise (fileno (stdin), 0, 0, FADVISE_RANDOM);
|
||||
|
||||
/* Ignored. */
|
||||
fadvise (NULL, FADVISE_RANDOM);
|
||||
fadvise (nullptr, FADVISE_RANDOM);
|
||||
|
||||
/* Invalid. */
|
||||
fdadvise (42, 0, 0, FADVISE_RANDOM);
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
/* Test that mbsalign works as advertised.
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Pádraig Brady. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "mbsalign.h"
|
||||
#include "macros.h"
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char dest[4 * 16 + 1];
|
||||
size_t width, n;
|
||||
|
||||
/* Test unibyte truncation. */
|
||||
width = 4;
|
||||
n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 4);
|
||||
|
||||
/* Test center alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
|
||||
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
|
||||
ASSERT (n == 4);
|
||||
|
||||
/* Test center alignment, with no trailing padding. */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
|
||||
MBA_NO_RIGHT_PAD);
|
||||
ASSERT (n == 3);
|
||||
ASSERT (*dest == ' ' && *(dest + n - 1) == 's');
|
||||
|
||||
/* Test left alignment, with no trailing padding. (truncate only). */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_LEFT,
|
||||
MBA_NO_RIGHT_PAD);
|
||||
ASSERT (n == 2);
|
||||
ASSERT (*dest == 'e' && *(dest + n - 1) == 's');
|
||||
|
||||
/* Test center alignment, with no padding. (truncate only). */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
|
||||
MBA_NO_LEFT_PAD | MBA_NO_RIGHT_PAD);
|
||||
ASSERT (n == 2);
|
||||
ASSERT (*dest == 'e' && *(dest + n - 1) == 's');
|
||||
|
||||
/* Test center alignment, with no left padding. (may be useful for RTL?) */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
|
||||
MBA_NO_LEFT_PAD);
|
||||
ASSERT (n == 3);
|
||||
ASSERT (*dest == 'e' && *(dest + n - 1) == ' ');
|
||||
|
||||
if (setlocale (LC_ALL, "en_US.UTF8"))
|
||||
{
|
||||
/* Check invalid input is flagged. */
|
||||
width = 4;
|
||||
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == (size_t) -1);
|
||||
|
||||
/* Check invalid input is treated as unibyte */
|
||||
width = 4;
|
||||
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width,
|
||||
MBS_ALIGN_LEFT, MBA_UNIBYTE_FALLBACK);
|
||||
ASSERT (n == 4);
|
||||
|
||||
/* Test multibyte center alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
|
||||
ASSERT (n == 5);
|
||||
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
|
||||
|
||||
/* Test multibyte left alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 5);
|
||||
ASSERT (*(dest + n - 1) == ' ' && *(dest + n - 2) == ' ');
|
||||
|
||||
/* Test multibyte right alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_RIGHT, 0);
|
||||
ASSERT (n == 5);
|
||||
ASSERT (*(dest) == ' ' && *(dest + 1) == ' ');
|
||||
|
||||
/* multibyte multicell truncation. */
|
||||
width = 4; /* cells */
|
||||
n = mbsalign ("日月火水", dest, sizeof dest, &width,
|
||||
MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 6); /* 2 characters */
|
||||
|
||||
/* multibyte unicell truncation. */
|
||||
width = 3; /* cells */
|
||||
n = mbsalign ("¹²³⁴", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 6); /* 3 characters */
|
||||
|
||||
/* Check independence from dest buffer. */
|
||||
width = 4; /* cells */
|
||||
n = mbsalign ("¹²³⁴", dest, 0, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 9); /* 4 characters */
|
||||
|
||||
/* Check that width is updated with cells required before padding. */
|
||||
width = 4; /* cells */
|
||||
n = mbsalign ("¹²³", dest, 0, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (width == 3);
|
||||
|
||||
/* Test case where output is larger than input
|
||||
(as tab converted to multi byte replacement char). */
|
||||
width = 4;
|
||||
n = mbsalign ("t\tés" /* 6 including NUL */ , dest, sizeof dest,
|
||||
&width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 7);
|
||||
|
||||
/* Test forced unibyte truncation. */
|
||||
width = 4;
|
||||
n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT,
|
||||
MBA_UNIBYTE_ONLY);
|
||||
ASSERT (n == 4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Test the ISAAC or ISAAC64 pseudorandom number generator.
|
||||
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 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
|
||||
@@ -581,7 +581,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* If invoked with a positive argument, run a benchmark;
|
||||
if with a negative, run a do-nothing benchmark. */
|
||||
for (iterations = argc <= 1 ? 0 : strtol (argv[1], NULL, 10);
|
||||
for (iterations = argc <= 1 ? 0 : strtol (argv[1], nullptr, 10);
|
||||
iterations != 0;
|
||||
iterations += (iterations < 0 ? 1 : -1))
|
||||
if (0 <= iterations)
|
||||
|
||||
2
gnulib
2
gnulib
Submodule gnulib updated: 4b60490554...259829e78b
6
init.cfg
6
init.cfg
@@ -1,6 +1,6 @@
|
||||
# This file is sourced by init.sh, *before* its initialization.
|
||||
|
||||
# Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2010-2024 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
|
||||
@@ -275,7 +275,7 @@ require_valgrind_()
|
||||
# If the given ACL spec would not change the ACLs on the file, then setfacl
|
||||
# does not invoke the underlying system call - setxattr(). Therefore, to test
|
||||
# if setting ACLs really works on the current file system, call setfacl twice
|
||||
# with conflictive ACL specs.
|
||||
# with conflicting ACL specs.
|
||||
require_setfacl_()
|
||||
{
|
||||
local d='acltestdir_'
|
||||
@@ -539,7 +539,7 @@ require_trap_signame_()
|
||||
# dash 0.5.8 at least does not.
|
||||
require_kill_group_()
|
||||
{
|
||||
kill -0 -- -1 || skip_ 'requires kill with group signalling support'
|
||||
kill -0 -- -1 || skip_ 'requires kill with group signaling support'
|
||||
}
|
||||
|
||||
# Return nonzero if the specified path is on a file system for
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Exercise chdir-long's sample main program.
|
||||
|
||||
# Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
# boottime.m4 serial 4
|
||||
# Determine whether this system has infrastructure for obtaining the boot time.
|
||||
|
||||
# Copyright (C) 1996-2023 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# GNULIB_BOOT_TIME([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
* ----------------------------------------------------------
|
||||
AC_DEFUN([GNULIB_BOOT_TIME],
|
||||
[
|
||||
AC_CHECK_FUNCS([sysctl])
|
||||
AC_CHECK_HEADERS_ONCE([sys/param.h])
|
||||
AC_CHECK_HEADERS([sys/sysctl.h], [], [],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
[#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif]])
|
||||
AC_CHECK_HEADERS_ONCE([utmpx.h OS.h])
|
||||
AC_CACHE_CHECK(
|
||||
[whether we can get the system boot time],
|
||||
[gnulib_cv_have_boot_time],
|
||||
[
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#if HAVE_SYSCTL && HAVE_SYS_SYSCTL_H
|
||||
# if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h> /* needed for OpenBSD 3.0 */
|
||||
# endif
|
||||
# include <sys/sysctl.h>
|
||||
#endif
|
||||
#if HAVE_UTMPX_H
|
||||
# include <utmpx.h>
|
||||
#endif
|
||||
#include <utmp.h>
|
||||
#if HAVE_OS_H
|
||||
# include <OS.h>
|
||||
#endif
|
||||
],
|
||||
[[
|
||||
#if (defined BOOT_TIME \
|
||||
|| (defined CTL_KERN && defined KERN_BOOTTIME) \
|
||||
|| HAVE_OS_H)
|
||||
/* your system *does* have the infrastructure to determine boot time */
|
||||
#else
|
||||
please_tell_us_how_to_determine_boot_time_on_your_system
|
||||
#endif
|
||||
]])],
|
||||
[gnulib_cv_have_boot_time=yes],
|
||||
[gnulib_cv_have_boot_time=no])
|
||||
])
|
||||
AS_IF([test $gnulib_cv_have_boot_time = yes], [$1], [$2])
|
||||
])
|
||||
@@ -1,7 +1,7 @@
|
||||
#serial 27
|
||||
# Check declarations for this package.
|
||||
|
||||
dnl Copyright (C) 1997-2023 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#serial 2
|
||||
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2007-2024 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.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#serial 114 -*- autoconf -*-
|
||||
#serial 115 -*- autoconf -*-
|
||||
|
||||
dnl Misc type-related macros for coreutils.
|
||||
|
||||
# Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -67,16 +67,11 @@ AC_DEFUN([coreutils_MACROS],
|
||||
fallocate
|
||||
fchown
|
||||
fchmod
|
||||
ftruncate
|
||||
iswspace
|
||||
mkfifo
|
||||
mbrlen
|
||||
setgroups
|
||||
sethostname
|
||||
siginterrupt
|
||||
sync
|
||||
syncfs
|
||||
sysctl
|
||||
sysinfo
|
||||
tcgetpgrp
|
||||
])
|
||||
@@ -94,22 +89,6 @@ AC_DEFUN([coreutils_MACROS],
|
||||
dnl This can't use AC_REQUIRE; I'm not quite sure why.
|
||||
cu_PREREQ_STAT_PROG
|
||||
|
||||
# for dd.c and shred.c
|
||||
#
|
||||
# Use fdatasync only if declared. On MacOS X 10.7, fdatasync exists but
|
||||
# is not declared, and is ineffective.
|
||||
LIB_FDATASYNC=
|
||||
AC_SUBST([LIB_FDATASYNC])
|
||||
AC_CHECK_DECLS_ONCE([fdatasync])
|
||||
if test $ac_cv_have_decl_fdatasync = yes; then
|
||||
coreutils_saved_libs=$LIBS
|
||||
AC_SEARCH_LIBS([fdatasync], [rt posix4],
|
||||
[test "$ac_cv_search_fdatasync" = "none required" ||
|
||||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
|
||||
AC_CHECK_FUNCS([fdatasync])
|
||||
LIBS=$coreutils_saved_libs
|
||||
fi
|
||||
|
||||
# Check whether libcap is usable -- for ls --color support
|
||||
LIB_CAP=
|
||||
AC_ARG_ENABLE([libcap],
|
||||
|
||||
@@ -7,7 +7,7 @@ m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
|
||||
# directory of the coreutils package.
|
||||
|
||||
|
||||
# Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# stat-prog.m4 serial 7
|
||||
# Record the prerequisites of src/stat.c from the coreutils package.
|
||||
|
||||
# Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 2018-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 2018-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
@@ -7,7 +7,7 @@
|
||||
basenc \- Encode/decode data and print to standard output
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[ENCODINGS EXAMPLES]
|
||||
[ENCODING EXAMPLES]
|
||||
.PP
|
||||
.nf
|
||||
.RS
|
||||
|
||||
12
man/chmod.x
12
man/chmod.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
@@ -60,17 +60,19 @@ file's group, with the same values; and the fourth for other users not
|
||||
in the file's group, with the same values.
|
||||
.PP
|
||||
.B chmod
|
||||
never changes the permissions of symbolic links; the
|
||||
doesn't change the permissions of symbolic links; the
|
||||
.B chmod
|
||||
system call cannot change their permissions. This is not a problem
|
||||
since the permissions of symbolic links are never used.
|
||||
system call cannot change their permissions on most systems,
|
||||
and most systems ignore permissions of symbolic links.
|
||||
However, for each symbolic link listed on the command line,
|
||||
.B chmod
|
||||
changes the permissions of the pointed-to file.
|
||||
In contrast,
|
||||
.B chmod
|
||||
ignores symbolic links encountered during recursive directory
|
||||
traversals.
|
||||
traversals. Options that modify this behavior are described in the
|
||||
.B OPTIONS
|
||||
section.
|
||||
.SH "SETUID AND SETGID BITS"
|
||||
.B chmod
|
||||
clears the set-group-ID bit of a
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
2
man/cp.x
2
man/cp.x
@@ -2,3 +2,5 @@
|
||||
cp \- copy files and directories
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
install(1)
|
||||
|
||||
4
man/df.x
4
man/df.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
@@ -24,6 +24,6 @@ shows the space available on that file system rather than on the
|
||||
file system containing the device node. This version of
|
||||
.B df
|
||||
cannot show the space available on unmounted file systems, because on
|
||||
most kinds of systems doing so requires very nonportable intimate
|
||||
most kinds of systems doing so requires non-portable intimate
|
||||
knowledge of file system structures.
|
||||
.SH OPTIONS
|
||||
|
||||
2
man/du.x
2
man/du.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
install \- copy files and set attributes
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
cp(1)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Make coreutils man pages. -*-Makefile-*-
|
||||
# This is included by the top-level Makefile.am.
|
||||
|
||||
# Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2024 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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
readlink \- print resolved symbolic links or canonical file names
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
Note realpath(1) is the preferred command to use
|
||||
realpath(1) is a better command
|
||||
for canonicalization functionality.
|
||||
[SEE ALSO]
|
||||
readlink(2), realpath(1), realpath(3)
|
||||
|
||||
2
man/rm.x
2
man/rm.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -10,5 +10,4 @@ the first argument is used as the complete context. Any additional
|
||||
arguments after \fICOMMAND\fR are interpreted as arguments to the
|
||||
command.
|
||||
.PP
|
||||
Note that only carefully-chosen contexts are likely to successfully
|
||||
run.
|
||||
Only carefully-chosen contexts are likely to run successfully.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# List of files which contain translatable strings.
|
||||
# Copyright (C) 1996-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
|
||||
# These are nominally temporary...
|
||||
lib/argmatch.c
|
||||
lib/argmatch.h
|
||||
lib/c-file-type.c
|
||||
lib/closein.c
|
||||
lib/closeout.c
|
||||
lib/copy-acl.c
|
||||
lib/error.c
|
||||
lib/file-type.c
|
||||
lib/gai_strerror.c
|
||||
lib/getopt.c
|
||||
lib/mkdir-p.c
|
||||
@@ -38,7 +38,6 @@ src/basename.c
|
||||
src/basenc.c
|
||||
src/cat.c
|
||||
src/chcon.c
|
||||
src/chgrp.c
|
||||
src/chmod.c
|
||||
src/chown-core.c
|
||||
src/chown.c
|
||||
@@ -125,6 +124,7 @@ src/tac-pipe.c
|
||||
src/tac.c
|
||||
src/tail.c
|
||||
src/tee.c
|
||||
src/temp-stream.c
|
||||
src/test.c
|
||||
src/timeout.c
|
||||
src/touch.c
|
||||
|
||||
@@ -32,7 +32,7 @@ Older version (pre 7.2) mention 'tee','eaccess','futimens'.
|
||||
Details
|
||||
-------
|
||||
|
||||
GLibC version 2.28 removed non-standed headre file (libio.h) and some
|
||||
GLibC version 2.28 removed a non-standard header file (libio.h) and some
|
||||
internal symbols which were used by gnulib (a core component of GNU coreutils).
|
||||
|
||||
These were announced as 'deprecated' in version 2.27 [1], and removed in
|
||||
@@ -164,7 +164,7 @@ By adding the directory to your $PATH, older versions can be easily used:
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 2019-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2019-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2019-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2019-2024 Free Software Foundation, Inc.
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification,
|
||||
# are permitted in any medium without royalty provided the copyright
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename -- strip directory and suffix from file names
|
||||
Copyright (C) 1990-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no 'g' prefix). */
|
||||
@@ -30,12 +29,12 @@
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"multiple", no_argument, NULL, 'a'},
|
||||
{"suffix", required_argument, NULL, 's'},
|
||||
{"zero", no_argument, NULL, 'z'},
|
||||
{"multiple", no_argument, nullptr, 'a'},
|
||||
{"suffix", required_argument, nullptr, 's'},
|
||||
{"zero", no_argument, nullptr, 'z'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -97,7 +96,7 @@ remove_suffix (char *name, char const *suffix)
|
||||
*np = '\0';
|
||||
}
|
||||
|
||||
/* Perform the basename operation on STRING. If SUFFIX is non-NULL, remove
|
||||
/* Perform the basename operation on STRING. If SUFFIX is non-null, remove
|
||||
the trailing SUFFIX. Finally, output the result string. */
|
||||
|
||||
static void
|
||||
@@ -125,7 +124,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
bool multiple_names = false;
|
||||
bool use_nuls = false;
|
||||
char const *suffix = NULL;
|
||||
char const *suffix = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -137,7 +136,7 @@ main (int argc, char **argv)
|
||||
|
||||
while (true)
|
||||
{
|
||||
int c = getopt_long (argc, argv, "+as:z", longopts, NULL);
|
||||
int c = getopt_long (argc, argv, "+as:z", longopts, nullptr);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
@@ -184,7 +183,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
perform_basename (argv[optind],
|
||||
optind + 2 == argc ? argv[optind + 1] : NULL, use_nuls);
|
||||
optind + 2 == argc ? argv[optind + 1] : nullptr,
|
||||
use_nuls);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
312
src/basenc.c
312
src/basenc.c
@@ -1,5 +1,5 @@
|
||||
/* Base64, base32, and similar encoding/decoding strings or files.
|
||||
Copyright (C) 2004-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004-2024 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,11 +23,9 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "assure.h"
|
||||
#include "c-ctype.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "idx.h"
|
||||
#include "quote.h"
|
||||
#include "xstrtol.h"
|
||||
#include "xdectoint.h"
|
||||
@@ -50,7 +48,7 @@
|
||||
#elif BASE_TYPE == 42
|
||||
# include "base32.h"
|
||||
# include "base64.h"
|
||||
# include <assert.h>
|
||||
# include "assure.h"
|
||||
# define PROGRAM_NAME "basenc"
|
||||
#else
|
||||
# error missing/invalid BASE_TYPE definition
|
||||
@@ -89,7 +87,7 @@ static struct option const long_options[] =
|
||||
#endif
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -175,10 +173,37 @@ from any other non-alphabet bytes in the encoded stream.\n"),
|
||||
exit (status);
|
||||
}
|
||||
|
||||
#if BASE_TYPE != 64
|
||||
static int
|
||||
base32_required_padding (int len)
|
||||
{
|
||||
int partial = len % 8;
|
||||
return partial ? 8 - partial : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BASE_TYPE != 32
|
||||
static int
|
||||
base64_required_padding (int len)
|
||||
{
|
||||
int partial = len % 4;
|
||||
return partial ? 4 - partial : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BASE_TYPE == 42
|
||||
static int
|
||||
no_required_padding (int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ENC_BLOCKSIZE (1024 * 3 * 10)
|
||||
|
||||
#if BASE_TYPE == 32
|
||||
# define BASE_LENGTH BASE32_LENGTH
|
||||
# define REQUIRED_PADDING base32_required_padding
|
||||
/* Note that increasing this may decrease performance if --ignore-garbage
|
||||
is used, because of the memmove operation below. */
|
||||
# define DEC_BLOCKSIZE (1024 * 5)
|
||||
@@ -191,9 +216,10 @@ static_assert (DEC_BLOCKSIZE % 40 == 0); /* Complete encoded blocks are used. */
|
||||
# define base_decode_context base32_decode_context
|
||||
# define base_decode_ctx_init base32_decode_ctx_init
|
||||
# define base_decode_ctx base32_decode_ctx
|
||||
# define isbase isbase32
|
||||
# define isubase isubase32
|
||||
#elif BASE_TYPE == 64
|
||||
# define BASE_LENGTH BASE64_LENGTH
|
||||
# define REQUIRED_PADDING base64_required_padding
|
||||
/* Note that increasing this may decrease performance if --ignore-garbage
|
||||
is used, because of the memmove operation below. */
|
||||
# define DEC_BLOCKSIZE (1024 * 3)
|
||||
@@ -206,11 +232,12 @@ static_assert (DEC_BLOCKSIZE % 12 == 0); /* Complete encoded blocks are used. */
|
||||
# define base_decode_context base64_decode_context
|
||||
# define base_decode_ctx_init base64_decode_ctx_init
|
||||
# define base_decode_ctx base64_decode_ctx
|
||||
# define isbase isbase64
|
||||
# define isubase isubase64
|
||||
#elif BASE_TYPE == 42
|
||||
|
||||
|
||||
# define BASE_LENGTH base_length
|
||||
# define REQUIRED_PADDING required_padding
|
||||
|
||||
/* Note that increasing this may decrease performance if --ignore-garbage
|
||||
is used, because of the memmove operation below. */
|
||||
@@ -219,14 +246,15 @@ static_assert (DEC_BLOCKSIZE % 40 == 0); /* complete encoded blocks for base32*/
|
||||
static_assert (DEC_BLOCKSIZE % 12 == 0); /* complete encoded blocks for base64*/
|
||||
|
||||
static int (*base_length) (int i);
|
||||
static bool (*isbase) (char ch);
|
||||
static int (*required_padding) (int i);
|
||||
static bool (*isubase) (unsigned char ch);
|
||||
static void (*base_encode) (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen);
|
||||
|
||||
struct base16_decode_context
|
||||
{
|
||||
char nibble;
|
||||
bool have_nibble;
|
||||
/* Either a 4-bit nibble, or negative if we have no nibble. */
|
||||
signed char nibble;
|
||||
};
|
||||
|
||||
struct z85_decode_context
|
||||
@@ -322,10 +350,10 @@ base64url_encode (char const *restrict in, idx_t inlen,
|
||||
}
|
||||
|
||||
static bool
|
||||
isbase64url (char ch)
|
||||
isubase64url (unsigned char ch)
|
||||
{
|
||||
return (ch == '-' || ch == '_'
|
||||
|| (ch != '+' && ch != '/' && isbase64 (ch)));
|
||||
|| (ch != '+' && ch != '/' && isubase64 (ch)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -435,7 +463,7 @@ static const char base32_hex_to_norm[32 + 9] = {
|
||||
|
||||
|
||||
inline static bool
|
||||
isbase32hex (char ch)
|
||||
isubase32hex (unsigned char ch)
|
||||
{
|
||||
return ('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'V');
|
||||
}
|
||||
@@ -449,7 +477,7 @@ base32hex_encode (char const *restrict in, idx_t inlen,
|
||||
|
||||
for (char *p = out; outlen--; p++)
|
||||
{
|
||||
assert (0x32 <= *p && *p <= 0x5a); /* LCOV_EXCL_LINE */
|
||||
affirm (0x32 <= *p && *p <= 0x5a); /* LCOV_EXCL_LINE */
|
||||
*p = base32_norm_to_hex[*p - 0x32];
|
||||
}
|
||||
}
|
||||
@@ -474,8 +502,8 @@ base32hex_decode_ctx_wrapper (struct base_decode_context *ctx,
|
||||
char *p = ctx->inbuf;
|
||||
while (i--)
|
||||
{
|
||||
if (isbase32hex (*in))
|
||||
*p = base32_hex_to_norm[ (int)*in - 0x30];
|
||||
if (isubase32hex (*in))
|
||||
*p = base32_hex_to_norm[*in - 0x30];
|
||||
else
|
||||
*p = *in;
|
||||
++p;
|
||||
@@ -488,12 +516,105 @@ base32hex_decode_ctx_wrapper (struct base_decode_context *ctx,
|
||||
|
||||
return b;
|
||||
}
|
||||
/* With this approach this file works independent of the charset used
|
||||
(think EBCDIC). However, it does assume that the characters in the
|
||||
Base32 alphabet (A-Z2-7) 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 B32(x) ...'x'...", so use "_"
|
||||
as the formal parameter rather than "x". */
|
||||
# define B16(_) \
|
||||
((_) == '0' ? 0 \
|
||||
: (_) == '1' ? 1 \
|
||||
: (_) == '2' ? 2 \
|
||||
: (_) == '3' ? 3 \
|
||||
: (_) == '4' ? 4 \
|
||||
: (_) == '5' ? 5 \
|
||||
: (_) == '6' ? 6 \
|
||||
: (_) == '7' ? 7 \
|
||||
: (_) == '8' ? 8 \
|
||||
: (_) == '9' ? 9 \
|
||||
: (_) == 'A' || (_) == 'a' ? 10 \
|
||||
: (_) == 'B' || (_) == 'b' ? 11 \
|
||||
: (_) == 'C' || (_) == 'c' ? 12 \
|
||||
: (_) == 'D' || (_) == 'd' ? 13 \
|
||||
: (_) == 'E' || (_) == 'e' ? 14 \
|
||||
: (_) == 'F' || (_) == 'f' ? 15 \
|
||||
: -1)
|
||||
|
||||
static signed char const base16_to_int[256] = {
|
||||
B16 (0), B16 (1), B16 (2), B16 (3),
|
||||
B16 (4), B16 (5), B16 (6), B16 (7),
|
||||
B16 (8), B16 (9), B16 (10), B16 (11),
|
||||
B16 (12), B16 (13), B16 (14), B16 (15),
|
||||
B16 (16), B16 (17), B16 (18), B16 (19),
|
||||
B16 (20), B16 (21), B16 (22), B16 (23),
|
||||
B16 (24), B16 (25), B16 (26), B16 (27),
|
||||
B16 (28), B16 (29), B16 (30), B16 (31),
|
||||
B16 (32), B16 (33), B16 (34), B16 (35),
|
||||
B16 (36), B16 (37), B16 (38), B16 (39),
|
||||
B16 (40), B16 (41), B16 (42), B16 (43),
|
||||
B16 (44), B16 (45), B16 (46), B16 (47),
|
||||
B16 (48), B16 (49), B16 (50), B16 (51),
|
||||
B16 (52), B16 (53), B16 (54), B16 (55),
|
||||
B16 (56), B16 (57), B16 (58), B16 (59),
|
||||
B16 (60), B16 (61), B16 (62), B16 (63),
|
||||
B16 (32), B16 (65), B16 (66), B16 (67),
|
||||
B16 (68), B16 (69), B16 (70), B16 (71),
|
||||
B16 (72), B16 (73), B16 (74), B16 (75),
|
||||
B16 (76), B16 (77), B16 (78), B16 (79),
|
||||
B16 (80), B16 (81), B16 (82), B16 (83),
|
||||
B16 (84), B16 (85), B16 (86), B16 (87),
|
||||
B16 (88), B16 (89), B16 (90), B16 (91),
|
||||
B16 (92), B16 (93), B16 (94), B16 (95),
|
||||
B16 (96), B16 (97), B16 (98), B16 (99),
|
||||
B16 (100), B16 (101), B16 (102), B16 (103),
|
||||
B16 (104), B16 (105), B16 (106), B16 (107),
|
||||
B16 (108), B16 (109), B16 (110), B16 (111),
|
||||
B16 (112), B16 (113), B16 (114), B16 (115),
|
||||
B16 (116), B16 (117), B16 (118), B16 (119),
|
||||
B16 (120), B16 (121), B16 (122), B16 (123),
|
||||
B16 (124), B16 (125), B16 (126), B16 (127),
|
||||
B16 (128), B16 (129), B16 (130), B16 (131),
|
||||
B16 (132), B16 (133), B16 (134), B16 (135),
|
||||
B16 (136), B16 (137), B16 (138), B16 (139),
|
||||
B16 (140), B16 (141), B16 (142), B16 (143),
|
||||
B16 (144), B16 (145), B16 (146), B16 (147),
|
||||
B16 (148), B16 (149), B16 (150), B16 (151),
|
||||
B16 (152), B16 (153), B16 (154), B16 (155),
|
||||
B16 (156), B16 (157), B16 (158), B16 (159),
|
||||
B16 (160), B16 (161), B16 (162), B16 (163),
|
||||
B16 (132), B16 (165), B16 (166), B16 (167),
|
||||
B16 (168), B16 (169), B16 (170), B16 (171),
|
||||
B16 (172), B16 (173), B16 (174), B16 (175),
|
||||
B16 (176), B16 (177), B16 (178), B16 (179),
|
||||
B16 (180), B16 (181), B16 (182), B16 (183),
|
||||
B16 (184), B16 (185), B16 (186), B16 (187),
|
||||
B16 (188), B16 (189), B16 (190), B16 (191),
|
||||
B16 (192), B16 (193), B16 (194), B16 (195),
|
||||
B16 (196), B16 (197), B16 (198), B16 (199),
|
||||
B16 (200), B16 (201), B16 (202), B16 (203),
|
||||
B16 (204), B16 (205), B16 (206), B16 (207),
|
||||
B16 (208), B16 (209), B16 (210), B16 (211),
|
||||
B16 (212), B16 (213), B16 (214), B16 (215),
|
||||
B16 (216), B16 (217), B16 (218), B16 (219),
|
||||
B16 (220), B16 (221), B16 (222), B16 (223),
|
||||
B16 (224), B16 (225), B16 (226), B16 (227),
|
||||
B16 (228), B16 (229), B16 (230), B16 (231),
|
||||
B16 (232), B16 (233), B16 (234), B16 (235),
|
||||
B16 (236), B16 (237), B16 (238), B16 (239),
|
||||
B16 (240), B16 (241), B16 (242), B16 (243),
|
||||
B16 (244), B16 (245), B16 (246), B16 (247),
|
||||
B16 (248), B16 (249), B16 (250), B16 (251),
|
||||
B16 (252), B16 (253), B16 (254), B16 (255)
|
||||
};
|
||||
|
||||
static bool
|
||||
isbase16 (char ch)
|
||||
isubase16 (unsigned char ch)
|
||||
{
|
||||
return ('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'F');
|
||||
return ch < sizeof base16_to_int && 0 <= base16_to_int[ch];
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -502,18 +623,21 @@ base16_length (int len)
|
||||
return len * 2;
|
||||
}
|
||||
|
||||
static const char base16[16] = "0123456789ABCDEF";
|
||||
|
||||
static void
|
||||
base16_encode (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen)
|
||||
{
|
||||
while (inlen--)
|
||||
static const char base16[16] = "0123456789ABCDEF";
|
||||
|
||||
while (inlen && outlen)
|
||||
{
|
||||
unsigned char c = *in;
|
||||
*out++ = base16[c >> 4];
|
||||
*out++ = base16[c & 0x0F];
|
||||
++in;
|
||||
inlen--;
|
||||
outlen -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,7 +646,7 @@ static void
|
||||
base16_decode_ctx_init (struct base_decode_context *ctx)
|
||||
{
|
||||
init_inbuf (ctx);
|
||||
ctx->ctx.base16.have_nibble = false;
|
||||
ctx->ctx.base16.nibble = -1;
|
||||
ctx->i = 1;
|
||||
}
|
||||
|
||||
@@ -533,44 +657,42 @@ base16_decode_ctx (struct base_decode_context *ctx,
|
||||
char *restrict out, idx_t *outlen)
|
||||
{
|
||||
bool ignore_lines = true; /* for now, always ignore them */
|
||||
|
||||
*outlen = 0;
|
||||
char *out0 = out;
|
||||
signed char nibble = ctx->ctx.base16.nibble;
|
||||
|
||||
/* inlen==0 is request to flush output.
|
||||
if there is a dangling high nibble - we are missing the low nibble,
|
||||
so return false - indicating an invalid input. */
|
||||
if (inlen == 0)
|
||||
return !ctx->ctx.base16.have_nibble;
|
||||
{
|
||||
*outlen = 0;
|
||||
return nibble < 0;
|
||||
}
|
||||
|
||||
while (inlen--)
|
||||
{
|
||||
if (ignore_lines && *in == '\n')
|
||||
unsigned char c = *in++;
|
||||
if (ignore_lines && c == '\n')
|
||||
continue;
|
||||
|
||||
if (sizeof base16_to_int <= c || base16_to_int[c] < 0)
|
||||
{
|
||||
++in;
|
||||
continue;
|
||||
*outlen = out - out0;
|
||||
return false; /* garbage - return false */
|
||||
}
|
||||
|
||||
int nib = *in++;
|
||||
if ('0' <= nib && nib <= '9')
|
||||
nib -= '0';
|
||||
else if ('A' <= nib && nib <= 'F')
|
||||
nib -= 'A' - 10;
|
||||
if (nibble < 0)
|
||||
nibble = base16_to_int[c];
|
||||
else
|
||||
return false; /* garbage - return false */
|
||||
|
||||
if (ctx->ctx.base16.have_nibble)
|
||||
{
|
||||
/* have both nibbles, write octet */
|
||||
*out++ = (ctx->ctx.base16.nibble << 4) + nib;
|
||||
++(*outlen);
|
||||
*out++ = (nibble << 4) + base16_to_int[c];
|
||||
nibble = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Store higher nibble until next one arrives */
|
||||
ctx->ctx.base16.nibble = nib;
|
||||
}
|
||||
ctx->ctx.base16.have_nibble = !ctx->ctx.base16.have_nibble;
|
||||
}
|
||||
|
||||
ctx->ctx.base16.nibble = nibble;
|
||||
*outlen = out - out0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -586,9 +708,9 @@ z85_length (int len)
|
||||
}
|
||||
|
||||
static bool
|
||||
isz85 (char ch)
|
||||
isuz85 (unsigned char ch)
|
||||
{
|
||||
return c_isalnum (ch) || (strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != NULL);
|
||||
return c_isalnum (ch) || strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != nullptr;
|
||||
}
|
||||
|
||||
static char const z85_encoding[85] =
|
||||
@@ -614,8 +736,8 @@ z85_encode (char const *restrict in, idx_t inlen,
|
||||
return;
|
||||
|
||||
/* currently, there's no way to return an error in encoding. */
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid input (length must be multiple of 4 characters)"));
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid input (length must be multiple of 4 characters)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -768,7 +890,7 @@ z85_decode_ctx (struct base_decode_context *ctx,
|
||||
|
||||
|
||||
inline static bool
|
||||
isbase2 (char ch)
|
||||
isubase2 (unsigned char ch)
|
||||
{
|
||||
return ch == '0' || ch == '1';
|
||||
}
|
||||
@@ -784,7 +906,7 @@ inline static void
|
||||
base2msbf_encode (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen)
|
||||
{
|
||||
while (inlen--)
|
||||
while (inlen && outlen)
|
||||
{
|
||||
unsigned char c = *in;
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -792,6 +914,7 @@ base2msbf_encode (char const *restrict in, idx_t inlen,
|
||||
*out++ = c & 0x80 ? '1' : '0';
|
||||
c <<= 1;
|
||||
}
|
||||
inlen--;
|
||||
outlen -= 8;
|
||||
++in;
|
||||
}
|
||||
@@ -801,7 +924,7 @@ inline static void
|
||||
base2lsbf_encode (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen)
|
||||
{
|
||||
while (inlen--)
|
||||
while (inlen && outlen)
|
||||
{
|
||||
unsigned char c = *in;
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -809,6 +932,7 @@ base2lsbf_encode (char const *restrict in, idx_t inlen,
|
||||
*out++ = c & 0x01 ? '1' : '0';
|
||||
c >>= 1;
|
||||
}
|
||||
inlen--;
|
||||
outlen -= 8;
|
||||
++in;
|
||||
}
|
||||
@@ -847,7 +971,7 @@ base2lsbf_decode_ctx (struct base_decode_context *ctx,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isbase2 (*in))
|
||||
if (!isubase2 (*in))
|
||||
return false;
|
||||
|
||||
bool bit = (*in == '1');
|
||||
@@ -891,7 +1015,7 @@ base2msbf_decode_ctx (struct base_decode_context *ctx,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isbase2 (*in))
|
||||
if (!isubase2 (*in))
|
||||
return false;
|
||||
|
||||
bool bit = (*in == '1');
|
||||
@@ -926,7 +1050,7 @@ wrap_write (char const *buffer, idx_t len,
|
||||
{
|
||||
/* Simple write. */
|
||||
if (fwrite (buffer, 1, len, stdout) < len)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
write_error ();
|
||||
}
|
||||
else
|
||||
for (idx_t written = 0; written < len; )
|
||||
@@ -936,13 +1060,13 @@ wrap_write (char const *buffer, idx_t len,
|
||||
if (to_write == 0)
|
||||
{
|
||||
if (fputc ('\n', out) == EOF)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
write_error ();
|
||||
*current_column = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fwrite (buffer + written, 1, to_write, stdout) < to_write)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
write_error ();
|
||||
*current_column += to_write;
|
||||
written += to_write;
|
||||
}
|
||||
@@ -955,9 +1079,9 @@ finish_and_exit (FILE *in, char const *infile)
|
||||
if (fclose (in) != 0)
|
||||
{
|
||||
if (STREQ (infile, "-"))
|
||||
die (EXIT_FAILURE, errno, _("closing standard input"));
|
||||
error (EXIT_FAILURE, errno, _("closing standard input"));
|
||||
else
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
}
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
@@ -999,10 +1123,10 @@ do_encode (FILE *in, char const *infile, FILE *out, idx_t wrap_column)
|
||||
|
||||
/* When wrapping, terminate last line. */
|
||||
if (wrap_column && current_column > 0 && fputc ('\n', out) == EOF)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
write_error ();
|
||||
|
||||
if (ferror (in))
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
|
||||
finish_and_exit (in, infile);
|
||||
}
|
||||
@@ -1014,11 +1138,12 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
|
||||
idx_t sum;
|
||||
struct base_decode_context ctx;
|
||||
|
||||
char padbuf[8] = "========";
|
||||
inbuf = xmalloc (BASE_LENGTH (DEC_BLOCKSIZE));
|
||||
outbuf = xmalloc (DEC_BLOCKSIZE);
|
||||
|
||||
#if BASE_TYPE == 42
|
||||
ctx.inbuf = NULL;
|
||||
ctx.inbuf = nullptr;
|
||||
#endif
|
||||
base_decode_ctx_init (&ctx);
|
||||
|
||||
@@ -1036,7 +1161,7 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
|
||||
{
|
||||
for (idx_t i = 0; n > 0 && i < n;)
|
||||
{
|
||||
if (isbase (inbuf[sum + i]) || inbuf[sum + i] == '=')
|
||||
if (isubase (inbuf[sum + i]) || inbuf[sum + i] == '=')
|
||||
i++;
|
||||
else
|
||||
memmove (inbuf + sum + i, inbuf + sum + i + 1, --n - i);
|
||||
@@ -1046,7 +1171,7 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
|
||||
sum += n;
|
||||
|
||||
if (ferror (in))
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
}
|
||||
while (sum < BASE_LENGTH (DEC_BLOCKSIZE) && !feof (in));
|
||||
|
||||
@@ -1056,16 +1181,31 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
|
||||
telling it to flush what is in CTX. */
|
||||
for (int k = 0; k < 1 + !!feof (in); k++)
|
||||
{
|
||||
if (k == 1 && ctx.i == 0)
|
||||
break;
|
||||
if (k == 1)
|
||||
{
|
||||
if (ctx.i == 0)
|
||||
break;
|
||||
|
||||
/* auto pad input (at eof). */
|
||||
idx_t auto_padding = REQUIRED_PADDING (ctx.i);
|
||||
if (auto_padding && (sum == 0 || inbuf[sum - 1] != '='))
|
||||
{
|
||||
affirm (auto_padding <= sizeof (padbuf));
|
||||
IF_LINT (free (inbuf));
|
||||
sum = auto_padding;
|
||||
inbuf = padbuf;
|
||||
}
|
||||
else
|
||||
sum = 0; /* process ctx buffer only */
|
||||
}
|
||||
idx_t n = DEC_BLOCKSIZE;
|
||||
ok = base_decode_ctx (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);
|
||||
ok = base_decode_ctx (&ctx, inbuf, sum, outbuf, &n);
|
||||
|
||||
if (fwrite (outbuf, 1, n, out) < n)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
write_error ();
|
||||
|
||||
if (!ok)
|
||||
die (EXIT_FAILURE, 0, _("invalid input"));
|
||||
error (EXIT_FAILURE, 0, _("invalid input"));
|
||||
}
|
||||
}
|
||||
while (!feof (in));
|
||||
@@ -1099,7 +1239,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((opt = getopt_long (argc, argv, "diw:", long_options, NULL)) != -1)
|
||||
while ((opt = getopt_long (argc, argv, "diw:", long_options, nullptr)) != -1)
|
||||
switch (opt)
|
||||
{
|
||||
case 'd':
|
||||
@@ -1109,10 +1249,10 @@ main (int argc, char **argv)
|
||||
case 'w':
|
||||
{
|
||||
intmax_t w;
|
||||
strtol_error s_err = xstrtoimax (optarg, NULL, 10, &w, "");
|
||||
strtol_error s_err = xstrtoimax (optarg, nullptr, 10, &w, "");
|
||||
if (LONGINT_OVERFLOW < s_err || w < 0)
|
||||
die (EXIT_FAILURE, 0, "%s: %s",
|
||||
_("invalid wrap size"), quote (optarg));
|
||||
error (EXIT_FAILURE, 0, "%s: %s",
|
||||
_("invalid wrap size"), quote (optarg));
|
||||
wrap_column = s_err == LONGINT_OVERFLOW || IDX_MAX < w ? 0 : w;
|
||||
}
|
||||
break;
|
||||
@@ -1148,7 +1288,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
case BASE64_OPTION:
|
||||
base_length = base64_length_wrapper;
|
||||
isbase = isbase64;
|
||||
required_padding = base64_required_padding;
|
||||
isubase = isubase64;
|
||||
base_encode = base64_encode;
|
||||
base_decode_ctx_init = base64_decode_ctx_init_wrapper;
|
||||
base_decode_ctx = base64_decode_ctx_wrapper;
|
||||
@@ -1156,7 +1297,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE64URL_OPTION:
|
||||
base_length = base64_length_wrapper;
|
||||
isbase = isbase64url;
|
||||
required_padding = base64_required_padding;
|
||||
isubase = isubase64url;
|
||||
base_encode = base64url_encode;
|
||||
base_decode_ctx_init = base64url_decode_ctx_init_wrapper;
|
||||
base_decode_ctx = base64url_decode_ctx_wrapper;
|
||||
@@ -1164,7 +1306,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE32_OPTION:
|
||||
base_length = base32_length_wrapper;
|
||||
isbase = isbase32;
|
||||
required_padding = base32_required_padding;
|
||||
isubase = isubase32;
|
||||
base_encode = base32_encode;
|
||||
base_decode_ctx_init = base32_decode_ctx_init_wrapper;
|
||||
base_decode_ctx = base32_decode_ctx_wrapper;
|
||||
@@ -1172,7 +1315,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE32HEX_OPTION:
|
||||
base_length = base32_length_wrapper;
|
||||
isbase = isbase32hex;
|
||||
required_padding = base32_required_padding;
|
||||
isubase = isubase32hex;
|
||||
base_encode = base32hex_encode;
|
||||
base_decode_ctx_init = base32hex_decode_ctx_init_wrapper;
|
||||
base_decode_ctx = base32hex_decode_ctx_wrapper;
|
||||
@@ -1180,7 +1324,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE16_OPTION:
|
||||
base_length = base16_length;
|
||||
isbase = isbase16;
|
||||
required_padding = no_required_padding;
|
||||
isubase = isubase16;
|
||||
base_encode = base16_encode;
|
||||
base_decode_ctx_init = base16_decode_ctx_init;
|
||||
base_decode_ctx = base16_decode_ctx;
|
||||
@@ -1188,7 +1333,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE2MSBF_OPTION:
|
||||
base_length = base2_length;
|
||||
isbase = isbase2;
|
||||
required_padding = no_required_padding;
|
||||
isubase = isubase2;
|
||||
base_encode = base2msbf_encode;
|
||||
base_decode_ctx_init = base2_decode_ctx_init;
|
||||
base_decode_ctx = base2msbf_decode_ctx;
|
||||
@@ -1196,7 +1342,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE2LSBF_OPTION:
|
||||
base_length = base2_length;
|
||||
isbase = isbase2;
|
||||
required_padding = no_required_padding;
|
||||
isubase = isubase2;
|
||||
base_encode = base2lsbf_encode;
|
||||
base_decode_ctx_init = base2_decode_ctx_init;
|
||||
base_decode_ctx = base2lsbf_decode_ctx;
|
||||
@@ -1204,7 +1351,8 @@ main (int argc, char **argv)
|
||||
|
||||
case Z85_OPTION:
|
||||
base_length = z85_length;
|
||||
isbase = isz85;
|
||||
required_padding = no_required_padding;
|
||||
isubase = isuz85;
|
||||
base_encode = z85_encode;
|
||||
base_decode_ctx_init = z85_decode_ctx_init;
|
||||
base_decode_ctx = z85_decode_ctx;
|
||||
@@ -1235,8 +1383,8 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
input_fh = fopen (infile, "rb");
|
||||
if (input_fh == NULL)
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
if (input_fh == nullptr)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
}
|
||||
|
||||
fadvise (input_fh, FADVISE_SEQUENTIAL);
|
||||
|
||||
@@ -19,13 +19,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "blake2.h"
|
||||
|
||||
@@ -134,6 +127,11 @@ cleanup_buffer:
|
||||
|
||||
#if 0
|
||||
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int blake2sp_stream( FILE *stream, void *resstream, size_t outbytes )
|
||||
{
|
||||
int ret = -1;
|
||||
@@ -269,12 +267,12 @@ int main( int argc, char **argv )
|
||||
while( 1 )
|
||||
{
|
||||
int option_index = 0;
|
||||
char *end = NULL;
|
||||
char *end = nullptr;
|
||||
unsigned long outbits;
|
||||
static struct option long_options[] = {
|
||||
{ "help", no_argument, 0, 0 },
|
||||
{ "tag", no_argument, 0, 0 },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
{ nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
c = getopt_long( argc, argv, "a:l:", long_options, &option_index );
|
||||
@@ -351,7 +349,7 @@ int main( int argc, char **argv )
|
||||
|
||||
for( i = optind; i < argc; ++i )
|
||||
{
|
||||
FILE *f = NULL;
|
||||
FILE *f = nullptr;
|
||||
if( argv[i][0] == '-' && argv[i][1] == '\0' )
|
||||
f = stdin;
|
||||
else
|
||||
|
||||
53
src/cat.c
53
src/cat.c
@@ -1,5 +1,5 @@
|
||||
/* cat -- concatenate files and print on the standard output.
|
||||
Copyright (C) 1988-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -19,7 +19,7 @@
|
||||
* Usually much faster than other versions of cat, the difference
|
||||
is especially apparent when using the -v option.
|
||||
|
||||
By tege@sics.se, Torbjorn Granlund, advised by rms, Richard Stallman. */
|
||||
By tege@sics.se, Torbjörn Granlund, advised by rms, Richard Stallman. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -34,10 +34,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "alignalloc.h"
|
||||
#include "idx.h"
|
||||
#include "ioblksize.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "full-write.h"
|
||||
#include "safe-read.h"
|
||||
@@ -47,7 +44,7 @@
|
||||
#define PROGRAM_NAME "cat"
|
||||
|
||||
#define AUTHORS \
|
||||
proper_name ("Torbjorn Granlund"), \
|
||||
proper_name_lite ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \
|
||||
proper_name ("Richard M. Stallman")
|
||||
|
||||
/* Name of input file. May be "-". */
|
||||
@@ -179,7 +176,7 @@ simple_cat (char *buf, idx_t bufsize)
|
||||
/* Write this block out. */
|
||||
|
||||
if (full_write (STDOUT_FILENO, buf, n_read) != n_read)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
write_error ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +191,7 @@ write_pending (char *outbuf, char **bpout)
|
||||
if (0 < n_write)
|
||||
{
|
||||
if (full_write (STDOUT_FILENO, outbuf, n_write) != n_write)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
write_error ();
|
||||
*bpout = outbuf;
|
||||
}
|
||||
}
|
||||
@@ -258,7 +255,7 @@ cat (char *inbuf, idx_t insize, char *outbuf, idx_t outsize,
|
||||
do
|
||||
{
|
||||
if (full_write (STDOUT_FILENO, wp, outsize) != outsize)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
write_error ();
|
||||
wp += outsize;
|
||||
remaining_bytes = bpout - wp;
|
||||
}
|
||||
@@ -518,7 +515,7 @@ copy_cat (void)
|
||||
unsupported or the input file seems empty. */
|
||||
|
||||
for (bool some_copied = false; ; some_copied = true)
|
||||
switch (copy_file_range (input_desc, NULL, STDOUT_FILENO, NULL,
|
||||
switch (copy_file_range (input_desc, nullptr, STDOUT_FILENO, nullptr,
|
||||
copy_max, 0))
|
||||
{
|
||||
case 0:
|
||||
@@ -554,16 +551,16 @@ main (int argc, char **argv)
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"number-nonblank", no_argument, NULL, 'b'},
|
||||
{"number", no_argument, NULL, 'n'},
|
||||
{"squeeze-blank", no_argument, NULL, 's'},
|
||||
{"show-nonprinting", no_argument, NULL, 'v'},
|
||||
{"show-ends", no_argument, NULL, 'E'},
|
||||
{"show-tabs", no_argument, NULL, 'T'},
|
||||
{"show-all", no_argument, NULL, 'A'},
|
||||
{"number-nonblank", no_argument, nullptr, 'b'},
|
||||
{"number", no_argument, nullptr, 'n'},
|
||||
{"squeeze-blank", no_argument, nullptr, 's'},
|
||||
{"show-nonprinting", no_argument, nullptr, 'v'},
|
||||
{"show-ends", no_argument, nullptr, 'E'},
|
||||
{"show-tabs", no_argument, nullptr, 'T'},
|
||||
{"show-all", no_argument, nullptr, 'A'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -581,7 +578,7 @@ main (int argc, char **argv)
|
||||
/* Parse command line options. */
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long (argc, argv, "benstuvAET", long_options, NULL))
|
||||
while ((c = getopt_long (argc, argv, "benstuvAET", long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -643,10 +640,10 @@ main (int argc, char **argv)
|
||||
/* Get device, i-node number, and optimal blocksize of output. */
|
||||
|
||||
if (fstat (STDOUT_FILENO, &stat_buf) < 0)
|
||||
die (EXIT_FAILURE, errno, _("standard output"));
|
||||
error (EXIT_FAILURE, errno, _("standard output"));
|
||||
|
||||
/* Optimal size of i/o operations of output. */
|
||||
idx_t outsize = io_blksize (stat_buf);
|
||||
idx_t outsize = io_blksize (&stat_buf);
|
||||
|
||||
/* Device and I-node number of the output. */
|
||||
dev_t out_dev = stat_buf.st_dev;
|
||||
@@ -700,7 +697,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Optimal size of i/o operations of input. */
|
||||
idx_t insize = io_blksize (stat_buf);
|
||||
idx_t insize = io_blksize (&stat_buf);
|
||||
|
||||
fdadvise (input_desc, 0, 0, FADVISE_SEQUENTIAL);
|
||||
|
||||
@@ -731,7 +728,7 @@ main (int argc, char **argv)
|
||||
out_isreg && S_ISREG (stat_buf.st_mode) ? copy_cat () : 0;
|
||||
if (copy_cat_status != 0)
|
||||
{
|
||||
inbuf = NULL;
|
||||
inbuf = nullptr;
|
||||
ok &= 0 < copy_cat_status;
|
||||
}
|
||||
else
|
||||
@@ -768,9 +765,9 @@ main (int argc, char **argv)
|
||||
on some paging implementations. */
|
||||
|
||||
idx_t bufsize;
|
||||
if (INT_MULTIPLY_WRAPV (insize, 4, &bufsize)
|
||||
|| INT_ADD_WRAPV (bufsize, outsize, &bufsize)
|
||||
|| INT_ADD_WRAPV (bufsize, LINE_COUNTER_BUF_LEN - 1, &bufsize))
|
||||
if (ckd_mul (&bufsize, insize, 4)
|
||||
|| ckd_add (&bufsize, bufsize, outsize)
|
||||
|| ckd_add (&bufsize, bufsize, LINE_COUNTER_BUF_LEN - 1))
|
||||
xalloc_die ();
|
||||
char *outbuf = xalignalloc (page_size, bufsize);
|
||||
|
||||
@@ -795,11 +792,11 @@ main (int argc, char **argv)
|
||||
if (pending_cr)
|
||||
{
|
||||
if (full_write (STDOUT_FILENO, "\r", 1) != 1)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
write_error ();
|
||||
}
|
||||
|
||||
if (have_read_stdin && close (STDIN_FILENO) < 0)
|
||||
die (EXIT_FAILURE, errno, _("closing standard input"));
|
||||
error (EXIT_FAILURE, errno, _("closing standard input"));
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
77
src/chcon.c
77
src/chcon.c
@@ -1,5 +1,5 @@
|
||||
/* chcon -- change security context of files
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "dev-ino.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "ignore-value.h"
|
||||
#include "quote.h"
|
||||
#include "root-dev-ino.h"
|
||||
@@ -48,7 +46,7 @@ static bool recurse;
|
||||
static bool verbose;
|
||||
|
||||
/* Pointer to the device and inode numbers of '/', when --recursive.
|
||||
Otherwise NULL. */
|
||||
Otherwise nullptr. */
|
||||
static struct dev_ino *root_dev_ino;
|
||||
|
||||
/* The name of the context file is being given. */
|
||||
@@ -72,20 +70,20 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, NULL, 'R'},
|
||||
{"dereference", no_argument, NULL, DEREFERENCE_OPTION},
|
||||
{"no-dereference", no_argument, NULL, 'h'},
|
||||
{"no-preserve-root", no_argument, NULL, NO_PRESERVE_ROOT},
|
||||
{"preserve-root", no_argument, NULL, PRESERVE_ROOT},
|
||||
{"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
|
||||
{"user", required_argument, NULL, 'u'},
|
||||
{"role", required_argument, NULL, 'r'},
|
||||
{"type", required_argument, NULL, 't'},
|
||||
{"range", required_argument, NULL, 'l'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"recursive", no_argument, nullptr, 'R'},
|
||||
{"dereference", no_argument, nullptr, DEREFERENCE_OPTION},
|
||||
{"no-dereference", no_argument, nullptr, 'h'},
|
||||
{"no-preserve-root", no_argument, nullptr, NO_PRESERVE_ROOT},
|
||||
{"preserve-root", no_argument, nullptr, PRESERVE_ROOT},
|
||||
{"reference", required_argument, nullptr, REFERENCE_FILE_OPTION},
|
||||
{"user", required_argument, nullptr, 'u'},
|
||||
{"role", required_argument, nullptr, 'r'},
|
||||
{"type", required_argument, nullptr, 't'},
|
||||
{"range", required_argument, nullptr, 'l'},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Given a security context, CONTEXT, derive a context_t (*RET),
|
||||
@@ -141,12 +139,12 @@ compute_context_from_mask (char const *context, context_t *ret)
|
||||
static int
|
||||
change_file_context (int fd, char const *file)
|
||||
{
|
||||
char *file_context = NULL;
|
||||
char *file_context = nullptr;
|
||||
context_t context IF_LINT (= 0);
|
||||
char const * context_string;
|
||||
int errors = 0;
|
||||
|
||||
if (specified_context == NULL)
|
||||
if (specified_context == nullptr)
|
||||
{
|
||||
int status = (affect_symlink_referent
|
||||
? getfileconat (fd, file, &file_context)
|
||||
@@ -162,7 +160,7 @@ change_file_context (int fd, char const *file)
|
||||
/* If the file doesn't have a context, and we're not setting all of
|
||||
the context components, there isn't really an obvious default.
|
||||
Thus, we just give up. */
|
||||
if (file_context == NULL)
|
||||
if (file_context == nullptr)
|
||||
{
|
||||
error (0, 0, _("can't apply partial context to unlabeled file %s"),
|
||||
quoteaf (file));
|
||||
@@ -179,7 +177,7 @@ change_file_context (int fd, char const *file)
|
||||
context_string = specified_context;
|
||||
}
|
||||
|
||||
if (file_context == NULL || ! STREQ (context_string, file_context))
|
||||
if (file_context == nullptr || ! STREQ (context_string, file_context))
|
||||
{
|
||||
int fail = (affect_symlink_referent
|
||||
? setfileconat (fd, file, context_string)
|
||||
@@ -193,7 +191,7 @@ change_file_context (int fd, char const *file)
|
||||
}
|
||||
}
|
||||
|
||||
if (specified_context == NULL)
|
||||
if (specified_context == nullptr)
|
||||
{
|
||||
context_free (context);
|
||||
freecon (file_context);
|
||||
@@ -305,7 +303,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
}
|
||||
|
||||
/* Recursively operate on the specified FILES (the last entry
|
||||
of which is NULL). BIT_FLAGS controls how fts works.
|
||||
of which is null). BIT_FLAGS controls how fts works.
|
||||
Return true if successful. */
|
||||
|
||||
static bool
|
||||
@@ -313,14 +311,14 @@ process_files (char **files, int bit_flags)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
FTS *fts = xfts_open (files, bit_flags, NULL);
|
||||
FTS *fts = xfts_open (files, bit_flags, nullptr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
FTSENT *ent;
|
||||
|
||||
ent = fts_read (fts);
|
||||
if (ent == NULL)
|
||||
if (ent == nullptr)
|
||||
{
|
||||
if (errno != 0)
|
||||
{
|
||||
@@ -421,7 +419,7 @@ main (int argc, char **argv)
|
||||
bool ok;
|
||||
bool preserve_root = false;
|
||||
bool component_specified = false;
|
||||
char *reference_file = NULL;
|
||||
char *reference_file = nullptr;
|
||||
int optc;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -432,7 +430,8 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "HLPRhvu:r:t:l:", long_options, NULL))
|
||||
while ((optc = getopt_long (argc, argv, "HLPRhvu:r:t:l:",
|
||||
long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -514,14 +513,14 @@ main (int argc, char **argv)
|
||||
if (bit_flags == FTS_PHYSICAL)
|
||||
{
|
||||
if (dereference == 1)
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
affect_symlink_referent = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dereference == 0)
|
||||
die (EXIT_FAILURE, 0, _("-R -h requires -P"));
|
||||
error (EXIT_FAILURE, 0, _("-R -h requires -P"));
|
||||
affect_symlink_referent = true;
|
||||
}
|
||||
}
|
||||
@@ -542,26 +541,26 @@ main (int argc, char **argv)
|
||||
|
||||
if (reference_file)
|
||||
{
|
||||
char *ref_context = NULL;
|
||||
char *ref_context = nullptr;
|
||||
|
||||
if (getfilecon (reference_file, &ref_context) < 0)
|
||||
die (EXIT_FAILURE, errno, _("failed to get security context of %s"),
|
||||
quoteaf (reference_file));
|
||||
error (EXIT_FAILURE, errno, _("failed to get security context of %s"),
|
||||
quoteaf (reference_file));
|
||||
|
||||
specified_context = ref_context;
|
||||
}
|
||||
else if (component_specified)
|
||||
{
|
||||
/* FIXME: it's already null, so this is a no-op. */
|
||||
specified_context = NULL;
|
||||
specified_context = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
specified_context = argv[optind++];
|
||||
if (0 < is_selinux_enabled ()
|
||||
&& security_check_context (specified_context) < 0)
|
||||
die (EXIT_FAILURE, errno, _("invalid context: %s"),
|
||||
quote (specified_context));
|
||||
error (EXIT_FAILURE, errno, _("invalid context: %s"),
|
||||
quote (specified_context));
|
||||
}
|
||||
|
||||
if (reference_file && component_specified)
|
||||
@@ -574,13 +573,13 @@ main (int argc, char **argv)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (root_dev_ino == NULL)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
if (root_dev_ino == nullptr)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
else
|
||||
{
|
||||
root_dev_ino = NULL;
|
||||
root_dev_ino = nullptr;
|
||||
}
|
||||
|
||||
ok = process_files (argv + optind, bit_flags | FTS_NOSTAT);
|
||||
|
||||
317
src/chgrp.c
317
src/chgrp.c
@@ -1,317 +0,0 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 1989-2023 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <grp.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "chown-core.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fts_.h"
|
||||
#include "quote.h"
|
||||
#include "root-dev-ino.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no 'g' prefix). */
|
||||
#define PROGRAM_NAME "chgrp"
|
||||
|
||||
#define AUTHORS \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
#if ! HAVE_ENDGRENT
|
||||
# define endgrent() ((void) 0)
|
||||
#endif
|
||||
|
||||
/* The argument to the --reference option. Use the group ID of this file.
|
||||
This file must exist. */
|
||||
static char *reference_file;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
DEREFERENCE_OPTION = CHAR_MAX + 1,
|
||||
NO_PRESERVE_ROOT,
|
||||
PRESERVE_ROOT,
|
||||
REFERENCE_FILE_OPTION
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, NULL, 'R'},
|
||||
{"changes", no_argument, NULL, 'c'},
|
||||
{"dereference", no_argument, NULL, DEREFERENCE_OPTION},
|
||||
{"no-dereference", no_argument, NULL, 'h'},
|
||||
{"no-preserve-root", no_argument, NULL, NO_PRESERVE_ROOT},
|
||||
{"preserve-root", no_argument, NULL, PRESERVE_ROOT},
|
||||
{"quiet", no_argument, NULL, 'f'},
|
||||
{"silent", no_argument, NULL, 'f'},
|
||||
{"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
/* Return the group ID of NAME, or -1 if no name was specified. */
|
||||
|
||||
static gid_t
|
||||
parse_group (char const *name)
|
||||
{
|
||||
gid_t gid = -1;
|
||||
|
||||
if (*name)
|
||||
{
|
||||
struct group *grp = getgrnam (name);
|
||||
if (grp)
|
||||
gid = grp->gr_gid;
|
||||
else
|
||||
{
|
||||
uintmax_t tmp;
|
||||
if (! (xstrtoumax (name, NULL, 10, &tmp, "") == LONGINT_OK
|
||||
&& tmp <= GID_T_MAX))
|
||||
die (EXIT_FAILURE, 0, _("invalid group: %s"),
|
||||
quote (name));
|
||||
gid = tmp;
|
||||
}
|
||||
endgrent (); /* Save a file descriptor. */
|
||||
}
|
||||
|
||||
return gid;
|
||||
}
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != EXIT_SUCCESS)
|
||||
emit_try_help ();
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... GROUP FILE...\n\
|
||||
or: %s [OPTION]... --reference=RFILE FILE...\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
fputs (_("\
|
||||
Change the group of each FILE to GROUP.\n\
|
||||
With --reference, change the group of each FILE to that of RFILE.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
-v, --verbose output a diagnostic for every file processed\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--dereference affect the referent of each symbolic link (this is\n\
|
||||
the default), rather than the symbolic link itself\n\
|
||||
-h, --no-dereference affect symbolic links instead of any referenced file\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
(useful only on systems that can change the\n\
|
||||
ownership of a symlink)\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--no-preserve-root do not treat '/' specially (the default)\n\
|
||||
--preserve-root fail to operate recursively on '/'\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--reference=RFILE use RFILE's group rather than specifying a GROUP.\n\
|
||||
RFILE is always dereferenced if a symbolic link.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-R, --recursive operate on files and directories recursively\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
The following options modify how a hierarchy is traversed when the -R\n\
|
||||
option is also specified. If more than one is specified, only the final\n\
|
||||
one takes effect.\n\
|
||||
\n\
|
||||
-H if a command line argument is a symbolic link\n\
|
||||
to a directory, traverse it\n\
|
||||
-L traverse every symbolic link to a directory\n\
|
||||
encountered\n\
|
||||
-P do not traverse any symbolic links (default)\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
printf (_("\
|
||||
\n\
|
||||
Examples:\n\
|
||||
%s staff /u Change the group of /u to \"staff\".\n\
|
||||
%s -hR staff /u Change the group of /u and subfiles to \"staff\".\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
emit_ancillary_info (PROGRAM_NAME);
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
bool preserve_root = false;
|
||||
gid_t gid;
|
||||
|
||||
/* Bit flags that control how fts works. */
|
||||
int bit_flags = FTS_PHYSICAL;
|
||||
|
||||
/* 1 if --dereference, 0 if --no-dereference, -1 if neither has been
|
||||
specified. */
|
||||
int dereference = -1;
|
||||
|
||||
struct Chown_option chopt;
|
||||
bool ok;
|
||||
int optc;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
chopt_init (&chopt);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 'H': /* Traverse command-line symlinks-to-directories. */
|
||||
bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL;
|
||||
break;
|
||||
|
||||
case 'L': /* Traverse all symlinks-to-directories. */
|
||||
bit_flags = FTS_LOGICAL;
|
||||
break;
|
||||
|
||||
case 'P': /* Traverse no symlinks-to-directories. */
|
||||
bit_flags = FTS_PHYSICAL;
|
||||
break;
|
||||
|
||||
case 'h': /* --no-dereference: affect symlinks */
|
||||
dereference = 0;
|
||||
break;
|
||||
|
||||
case DEREFERENCE_OPTION: /* --dereference: affect the referent
|
||||
of each symlink */
|
||||
dereference = 1;
|
||||
break;
|
||||
|
||||
case NO_PRESERVE_ROOT:
|
||||
preserve_root = false;
|
||||
break;
|
||||
|
||||
case PRESERVE_ROOT:
|
||||
preserve_root = true;
|
||||
break;
|
||||
|
||||
case REFERENCE_FILE_OPTION:
|
||||
reference_file = optarg;
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
chopt.recurse = true;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
chopt.verbosity = V_changes_only;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
chopt.force_silent = true;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
chopt.verbosity = V_high;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (chopt.recurse)
|
||||
{
|
||||
if (bit_flags == FTS_PHYSICAL)
|
||||
{
|
||||
if (dereference == 1)
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
dereference = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bit_flags = FTS_PHYSICAL;
|
||||
}
|
||||
chopt.affect_symlink_referent = (dereference != 0);
|
||||
|
||||
if (argc - optind < (reference_file ? 1 : 2))
|
||||
{
|
||||
if (argc <= optind)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (reference_file)
|
||||
{
|
||||
struct stat ref_stats;
|
||||
if (stat (reference_file, &ref_stats))
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
|
||||
gid = ref_stats.st_gid;
|
||||
chopt.group_name = gid_to_name (ref_stats.st_gid);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *group_name = argv[optind++];
|
||||
chopt.group_name = (*group_name ? xstrdup (group_name) : NULL);
|
||||
gid = parse_group (group_name);
|
||||
}
|
||||
|
||||
if (chopt.recurse && preserve_root)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (chopt.root_dev_ino == NULL)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
|
||||
bit_flags |= FTS_DEFER_STAT;
|
||||
ok = chown_files (argv + optind, bit_flags,
|
||||
(uid_t) -1, gid,
|
||||
(uid_t) -1, (gid_t) -1, &chopt);
|
||||
|
||||
main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
184
src/chmod.c
184
src/chmod.c
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 1989-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -22,9 +22,8 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "assure.h"
|
||||
#include "dev-ino.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "filemode.h"
|
||||
#include "ignore-value.h"
|
||||
#include "modechange.h"
|
||||
@@ -75,6 +74,10 @@ static mode_t umask_value;
|
||||
/* If true, change the modes of directories recursively. */
|
||||
static bool recurse;
|
||||
|
||||
/* 1 if --dereference, 0 if --no-dereference, -1 if neither has been
|
||||
specified. */
|
||||
static int dereference = -1;
|
||||
|
||||
/* If true, force silence (suppress most of error messages). */
|
||||
static bool force_silent;
|
||||
|
||||
@@ -87,31 +90,34 @@ static bool diagnose_surprises;
|
||||
static enum Verbosity verbosity = V_off;
|
||||
|
||||
/* Pointer to the device and inode numbers of '/', when --recursive.
|
||||
Otherwise NULL. */
|
||||
Otherwise nullptr. */
|
||||
static struct dev_ino *root_dev_ino;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
NO_PRESERVE_ROOT = CHAR_MAX + 1,
|
||||
DEREFERENCE_OPTION = CHAR_MAX + 1,
|
||||
NO_PRESERVE_ROOT,
|
||||
PRESERVE_ROOT,
|
||||
REFERENCE_FILE_OPTION
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"changes", no_argument, NULL, 'c'},
|
||||
{"recursive", no_argument, NULL, 'R'},
|
||||
{"no-preserve-root", no_argument, NULL, NO_PRESERVE_ROOT},
|
||||
{"preserve-root", no_argument, NULL, PRESERVE_ROOT},
|
||||
{"quiet", no_argument, NULL, 'f'},
|
||||
{"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
|
||||
{"silent", no_argument, NULL, 'f'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"changes", no_argument, nullptr, 'c'},
|
||||
{"dereference", no_argument, nullptr, DEREFERENCE_OPTION},
|
||||
{"recursive", no_argument, nullptr, 'R'},
|
||||
{"no-dereference", no_argument, nullptr, 'h'},
|
||||
{"no-preserve-root", no_argument, nullptr, NO_PRESERVE_ROOT},
|
||||
{"preserve-root", no_argument, nullptr, PRESERVE_ROOT},
|
||||
{"quiet", no_argument, nullptr, 'f'},
|
||||
{"reference", required_argument, nullptr, REFERENCE_FILE_OPTION},
|
||||
{"silent", no_argument, nullptr, 'f'},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Return true if the chmodable permission bits of FILE changed.
|
||||
@@ -191,7 +197,7 @@ describe_change (char const *file, struct change_status const *ch)
|
||||
printf (fmt, quoted_file, m, &perms[1]);
|
||||
return;
|
||||
default:
|
||||
abort ();
|
||||
affirm (false);
|
||||
}
|
||||
printf (fmt, quoted_file, old_m, &old_perms[1], m, &perms[1]);
|
||||
}
|
||||
@@ -206,8 +212,9 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
char const *file_full_name = ent->fts_path;
|
||||
char const *file = ent->fts_accpath;
|
||||
const struct stat *file_stats = ent->fts_statp;
|
||||
struct change_status ch = { 0, };
|
||||
struct change_status ch = {0};
|
||||
ch.status = CH_NO_STAT;
|
||||
struct stat stat_buf;
|
||||
|
||||
switch (ent->fts_info)
|
||||
{
|
||||
@@ -245,9 +252,30 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
break;
|
||||
|
||||
case FTS_SLNONE:
|
||||
if (! force_silent)
|
||||
error (0, 0, _("cannot operate on dangling symlink %s"),
|
||||
quoteaf (file_full_name));
|
||||
if (dereference)
|
||||
{
|
||||
if (! force_silent)
|
||||
error (0, 0, _("cannot operate on dangling symlink %s"),
|
||||
quoteaf (file_full_name));
|
||||
break;
|
||||
}
|
||||
ch.status = CH_NOT_APPLIED;
|
||||
break;
|
||||
|
||||
case FTS_SL:
|
||||
if (dereference == 1)
|
||||
{
|
||||
if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0)
|
||||
{
|
||||
if (! force_silent)
|
||||
error (0, errno, _("cannot dereference %s"),
|
||||
quoteaf (file_full_name));
|
||||
break;
|
||||
}
|
||||
|
||||
file_stats = &stat_buf;
|
||||
}
|
||||
ch.status = CH_NOT_APPLIED;
|
||||
break;
|
||||
|
||||
case FTS_DC: /* directory that causes cycles */
|
||||
@@ -273,19 +301,28 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ch.status == CH_NOT_APPLIED && ! S_ISLNK (file_stats->st_mode))
|
||||
if (ch.status == CH_NOT_APPLIED)
|
||||
{
|
||||
ch.old_mode = file_stats->st_mode;
|
||||
ch.new_mode = mode_adjust (ch.old_mode, S_ISDIR (ch.old_mode) != 0,
|
||||
umask_value, change, NULL);
|
||||
if (chmodat (fts->fts_cwd_fd, file, ch.new_mode) == 0)
|
||||
umask_value, change, nullptr);
|
||||
bool follow_symlink = !!dereference;
|
||||
if (dereference == -1) /* -H with/without -R, -P without -R. */
|
||||
follow_symlink = ent->fts_level == 0;
|
||||
if (fchmodat (fts->fts_cwd_fd, file, ch.new_mode,
|
||||
follow_symlink ? 0 : AT_SYMLINK_NOFOLLOW) == 0)
|
||||
ch.status = CH_SUCCEEDED;
|
||||
else
|
||||
{
|
||||
if (! force_silent)
|
||||
error (0, errno, _("changing permissions of %s"),
|
||||
quoteaf (file_full_name));
|
||||
ch.status = CH_FAILED;
|
||||
if (! is_ENOTSUP (errno))
|
||||
{
|
||||
if (! force_silent)
|
||||
error (0, errno, _("changing permissions of %s"),
|
||||
quoteaf (file_full_name));
|
||||
|
||||
ch.status = CH_FAILED;
|
||||
}
|
||||
/* else treat not supported as not applied. */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +340,8 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
if (CH_NO_CHANGE_REQUESTED <= ch.status && diagnose_surprises)
|
||||
{
|
||||
mode_t naively_expected_mode =
|
||||
mode_adjust (ch.old_mode, S_ISDIR (ch.old_mode) != 0, 0, change, NULL);
|
||||
mode_adjust (ch.old_mode, S_ISDIR (ch.old_mode) != 0,
|
||||
0, change, nullptr);
|
||||
if (ch.new_mode & ~naively_expected_mode)
|
||||
{
|
||||
char new_perms[12];
|
||||
@@ -326,7 +364,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
}
|
||||
|
||||
/* Recursively change the modes of the specified FILES (the last entry
|
||||
of which is NULL). BIT_FLAGS controls how fts works.
|
||||
of which is null). BIT_FLAGS controls how fts works.
|
||||
Return true if successful. */
|
||||
|
||||
static bool
|
||||
@@ -334,14 +372,14 @@ process_files (char **files, int bit_flags)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
FTS *fts = xfts_open (files, bit_flags, NULL);
|
||||
FTS *fts = xfts_open (files, bit_flags, nullptr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
FTSENT *ent;
|
||||
|
||||
ent = fts_read (fts);
|
||||
if (ent == NULL)
|
||||
if (ent == nullptr)
|
||||
{
|
||||
if (errno != 0)
|
||||
{
|
||||
@@ -387,6 +425,11 @@ With --reference, change the mode of each FILE to that of RFILE.\n\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
-v, --verbose output a diagnostic for every file processed\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--dereference affect the referent of each symbolic link,\n\
|
||||
rather than the symbolic link itself\n\
|
||||
-h, --no-dereference affect each symbolic link, rather than the referent\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--no-preserve-root do not treat '/' specially (the default)\n\
|
||||
@@ -399,6 +442,7 @@ With --reference, change the mode of each FILE to that of RFILE.\n\
|
||||
fputs (_("\
|
||||
-R, --recursive change files and directories recursively\n\
|
||||
"), stdout);
|
||||
emit_symlink_recurse_options ("-H");
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
fputs (_("\
|
||||
@@ -416,13 +460,14 @@ Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.\n\
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char *mode = NULL;
|
||||
size_t mode_len = 0;
|
||||
size_t mode_alloc = 0;
|
||||
char *mode = nullptr;
|
||||
idx_t mode_len = 0;
|
||||
idx_t mode_alloc = 0;
|
||||
bool ok;
|
||||
bool preserve_root = false;
|
||||
char const *reference_file = NULL;
|
||||
char const *reference_file = nullptr;
|
||||
int c;
|
||||
int bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -435,13 +480,35 @@ main (int argc, char **argv)
|
||||
recurse = force_silent = diagnose_surprises = false;
|
||||
|
||||
while ((c = getopt_long (argc, argv,
|
||||
("Rcfvr::w::x::X::s::t::u::g::o::a::,::+::=::"
|
||||
("HLPRcfhvr::w::x::X::s::t::u::g::o::a::,::+::=::"
|
||||
"0::1::2::3::4::5::6::7::"),
|
||||
long_options, NULL))
|
||||
long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
|
||||
case 'H': /* Traverse command-line symlinks-to-directories. */
|
||||
bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL;
|
||||
break;
|
||||
|
||||
case 'L': /* Traverse all symlinks-to-directories. */
|
||||
bit_flags = FTS_LOGICAL;
|
||||
break;
|
||||
|
||||
case 'P': /* Traverse no symlinks-to-directories. */
|
||||
bit_flags = FTS_PHYSICAL;
|
||||
break;
|
||||
|
||||
case 'h': /* --no-dereference: affect symlinks */
|
||||
dereference = 0;
|
||||
break;
|
||||
|
||||
case DEREFERENCE_OPTION: /* --dereference: affect the referent
|
||||
of each symlink */
|
||||
dereference = 1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
case 'w':
|
||||
case 'x':
|
||||
@@ -457,7 +524,7 @@ main (int argc, char **argv)
|
||||
case '=':
|
||||
case '0': case '1': case '2': case '3':
|
||||
case '4': case '5': case '6': case '7':
|
||||
/* Support nonportable uses like "chmod -w", but diagnose
|
||||
/* Support non-portable uses like "chmod -w", but diagnose
|
||||
surprises due to umask confusion. Even though "--", "--r",
|
||||
etc., are valid modes, there is no "case '-'" here since
|
||||
getopt_long reserves leading "--" for long options. */
|
||||
@@ -468,14 +535,13 @@ main (int argc, char **argv)
|
||||
comma, and the new string (e.g., "-s,-rwx"). */
|
||||
|
||||
char const *arg = argv[optind - 1];
|
||||
size_t arg_len = strlen (arg);
|
||||
size_t mode_comma_len = mode_len + !!mode_len;
|
||||
size_t new_mode_len = mode_comma_len + arg_len;
|
||||
idx_t arg_len = strlen (arg);
|
||||
idx_t mode_comma_len = mode_len + !!mode_len;
|
||||
idx_t new_mode_len = mode_comma_len + arg_len;
|
||||
assume (0 <= new_mode_len); /* Pacify GCC bug #109613. */
|
||||
if (mode_alloc <= new_mode_len)
|
||||
{
|
||||
mode_alloc = new_mode_len + 1;
|
||||
mode = X2REALLOC (mode, &mode_alloc);
|
||||
}
|
||||
mode = xpalloc (mode, &mode_alloc,
|
||||
new_mode_len + 1 - mode_alloc, -1, 1);
|
||||
mode[mode_len] = ',';
|
||||
memcpy (mode + mode_comma_len, arg, arg_len + 1);
|
||||
mode_len = new_mode_len;
|
||||
@@ -511,6 +577,20 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (recurse)
|
||||
{
|
||||
if (bit_flags == FTS_PHYSICAL)
|
||||
{
|
||||
if (dereference == 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
dereference = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (dereference == -1 && bit_flags == FTS_LOGICAL)
|
||||
dereference = 1;
|
||||
|
||||
if (reference_file)
|
||||
{
|
||||
if (mode)
|
||||
@@ -538,8 +618,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
change = mode_create_from_ref (reference_file);
|
||||
if (!change)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -556,17 +636,17 @@ main (int argc, char **argv)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (root_dev_ino == NULL)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
if (root_dev_ino == nullptr)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
else
|
||||
{
|
||||
root_dev_ino = NULL;
|
||||
root_dev_ino = nullptr;
|
||||
}
|
||||
|
||||
ok = process_files (argv + optind,
|
||||
FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT);
|
||||
bit_flags |= FTS_DEFER_STAT;
|
||||
ok = process_files (argv + optind, bit_flags);
|
||||
|
||||
main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
2
src/chown-chgrp.c
Normal file
2
src/chown-chgrp.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "chown.h"
|
||||
int chown_mode = CHOWN_CHGRP;
|
||||
2
src/chown-chown.c
Normal file
2
src/chown-chown.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "chown.h"
|
||||
int chown_mode = CHOWN_CHOWN;
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chown-core.c -- core functions for changing ownership.
|
||||
Copyright (C) 2000-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2024 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,8 +23,8 @@
|
||||
#include <grp.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "assure.h"
|
||||
#include "chown-core.h"
|
||||
#include "error.h"
|
||||
#include "ignore-value.h"
|
||||
#include "root-dev-ino.h"
|
||||
#include "xfts.h"
|
||||
@@ -43,7 +43,7 @@ enum RCH_status
|
||||
/* required_uid and/or required_gid are specified, but don't match */
|
||||
RC_excluded,
|
||||
|
||||
/* SAME_INODE check failed */
|
||||
/* The file was replaced by another file during the requested change. */
|
||||
RC_inode_changed,
|
||||
|
||||
/* open/fchown isn't needed, isn't safe, or doesn't work due to
|
||||
@@ -58,12 +58,12 @@ extern void
|
||||
chopt_init (struct Chown_option *chopt)
|
||||
{
|
||||
chopt->verbosity = V_off;
|
||||
chopt->root_dev_ino = NULL;
|
||||
chopt->root_dev_ino = nullptr;
|
||||
chopt->affect_symlink_referent = true;
|
||||
chopt->recurse = false;
|
||||
chopt->force_silent = false;
|
||||
chopt->user_name = NULL;
|
||||
chopt->group_name = NULL;
|
||||
chopt->user_name = nullptr;
|
||||
chopt->group_name = nullptr;
|
||||
}
|
||||
|
||||
extern void
|
||||
@@ -122,7 +122,7 @@ uid_to_name (uid_t uid)
|
||||
static char *
|
||||
user_group_str (char const *user, char const *group)
|
||||
{
|
||||
char *spec = NULL;
|
||||
char *spec = nullptr;
|
||||
|
||||
if (user)
|
||||
{
|
||||
@@ -145,7 +145,7 @@ user_group_str (char const *user, char const *group)
|
||||
}
|
||||
|
||||
/* Tell the user how/if the user and group of FILE have been changed.
|
||||
If USER is NULL, give the group-oriented messages.
|
||||
If USER is null, give the group-oriented messages.
|
||||
CHANGED describes what (if anything) has happened. */
|
||||
|
||||
static void
|
||||
@@ -165,7 +165,8 @@ describe_change (char const *file, enum Change_status changed,
|
||||
}
|
||||
|
||||
spec = user_group_str (user, group);
|
||||
old_spec = user_group_str (user ? old_user : NULL, group ? old_group : NULL);
|
||||
old_spec = user_group_str (user ? old_user : nullptr,
|
||||
group ? old_group : nullptr);
|
||||
|
||||
switch (changed)
|
||||
{
|
||||
@@ -188,7 +189,7 @@ describe_change (char const *file, enum Change_status changed,
|
||||
: _("failed to change ownership of %s\n"));
|
||||
free (old_spec);
|
||||
old_spec = spec;
|
||||
spec = NULL;
|
||||
spec = nullptr;
|
||||
}
|
||||
break;
|
||||
case CH_NO_CHANGE_REQUESTED:
|
||||
@@ -197,7 +198,7 @@ describe_change (char const *file, enum Change_status changed,
|
||||
: _("ownership of %s retained\n"));
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
affirm (false);
|
||||
}
|
||||
|
||||
printf (fmt, quoteaf (file), old_spec, spec);
|
||||
@@ -254,21 +255,16 @@ restricted_chown (int cwd_fd, char const *file,
|
||||
|
||||
if (fstat (fd, &st) != 0)
|
||||
status = RC_error;
|
||||
else if (! SAME_INODE (*orig_st, st))
|
||||
else if (! psame_inode (orig_st, &st))
|
||||
status = RC_inode_changed;
|
||||
else if ((required_uid == (uid_t) -1 || required_uid == st.st_uid)
|
||||
&& (required_gid == (gid_t) -1 || required_gid == st.st_gid))
|
||||
{
|
||||
#if HAVE_FCHOWN
|
||||
if (fchown (fd, uid, gid) == 0)
|
||||
{
|
||||
status = (close (fd) == 0
|
||||
? RC_ok : RC_error);
|
||||
return status;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = RC_error;
|
||||
}
|
||||
return close (fd) < 0 ? RC_error : RC_ok;
|
||||
#endif
|
||||
status = RC_error;
|
||||
}
|
||||
|
||||
int saved_errno = errno;
|
||||
@@ -370,7 +366,7 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
if (!ok)
|
||||
{
|
||||
do_chown = false;
|
||||
file_stats = NULL;
|
||||
file_stats = nullptr;
|
||||
}
|
||||
else if (required_uid == (uid_t) -1 && required_gid == (gid_t) -1
|
||||
&& chopt->verbosity == V_off
|
||||
@@ -424,7 +420,7 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
/* Ignore any error due to lack of support; POSIX requires
|
||||
this behavior for top-level symbolic links with -h, and
|
||||
implies that it's required for all symbolic links. */
|
||||
if (!ok && errno == EOPNOTSUPP)
|
||||
if (!ok && is_ENOTSUP (errno))
|
||||
{
|
||||
ok = true;
|
||||
symlink_changed = false;
|
||||
@@ -466,7 +462,7 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
unreachable ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,14 +494,16 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
: !symlink_changed ? CH_NOT_APPLIED
|
||||
: !changed ? CH_NO_CHANGE_REQUESTED
|
||||
: CH_SUCCEEDED);
|
||||
char *old_usr = file_stats ? uid_to_name (file_stats->st_uid) : NULL;
|
||||
char *old_grp = file_stats ? gid_to_name (file_stats->st_gid) : NULL;
|
||||
char *old_usr = (file_stats
|
||||
? uid_to_name (file_stats->st_uid) : nullptr);
|
||||
char *old_grp = (file_stats
|
||||
? gid_to_name (file_stats->st_gid) : nullptr);
|
||||
char *new_usr = chopt->user_name
|
||||
? chopt->user_name : uid != -1
|
||||
? uid_to_str (uid) : NULL;
|
||||
? uid_to_str (uid) : nullptr;
|
||||
char *new_grp = chopt->group_name
|
||||
? chopt->group_name : gid != -1
|
||||
? gid_to_str (gid) : NULL;
|
||||
? gid_to_str (gid) : nullptr;
|
||||
describe_change (file_full_name, ch_status,
|
||||
old_usr, old_grp,
|
||||
new_usr, new_grp);
|
||||
@@ -548,14 +546,14 @@ chown_files (char **files, int bit_flags,
|
||||
? 0
|
||||
: FTS_NOSTAT);
|
||||
|
||||
FTS *fts = xfts_open (files, bit_flags | stat_flags, NULL);
|
||||
FTS *fts = xfts_open (files, bit_flags | stat_flags, nullptr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
FTSENT *ent;
|
||||
|
||||
ent = fts_read (fts);
|
||||
if (ent == NULL)
|
||||
if (ent == nullptr)
|
||||
{
|
||||
if (errno != 0)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* chown-core.h -- types and prototypes shared by chown and chgrp.
|
||||
|
||||
Copyright (C) 2000-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2024 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
|
||||
@@ -50,7 +50,7 @@ struct Chown_option
|
||||
bool recurse;
|
||||
|
||||
/* Pointer to the device and inode numbers of '/', when --recursive.
|
||||
Need not be freed. Otherwise NULL. */
|
||||
Need not be freed. Otherwise nullptr. */
|
||||
struct dev_ino *root_dev_ino;
|
||||
|
||||
/* This corresponds to the --dereference (opposite of -h) option. */
|
||||
|
||||
125
src/chown.c
125
src/chown.c
@@ -1,5 +1,5 @@
|
||||
/* chown -- change user and group ownership of files
|
||||
Copyright (C) 1989-2023 Free Software Foundation, Inc.
|
||||
/* chown, chgrp -- change user and group ownership of files
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -22,16 +22,15 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "chown.h"
|
||||
#include "chown-core.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fts_.h"
|
||||
#include "quote.h"
|
||||
#include "root-dev-ino.h"
|
||||
#include "userspec.h"
|
||||
|
||||
/* The official name of this program (e.g., no 'g' prefix). */
|
||||
#define PROGRAM_NAME "chown"
|
||||
#define PROGRAM_NAME (chown_mode == CHOWN_CHOWN ? "chown" : "chgrp")
|
||||
|
||||
#define AUTHORS \
|
||||
proper_name ("David MacKenzie"), \
|
||||
@@ -54,20 +53,20 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, NULL, 'R'},
|
||||
{"changes", no_argument, NULL, 'c'},
|
||||
{"dereference", no_argument, NULL, DEREFERENCE_OPTION},
|
||||
{"from", required_argument, NULL, FROM_OPTION},
|
||||
{"no-dereference", no_argument, NULL, 'h'},
|
||||
{"no-preserve-root", no_argument, NULL, NO_PRESERVE_ROOT},
|
||||
{"preserve-root", no_argument, NULL, PRESERVE_ROOT},
|
||||
{"quiet", no_argument, NULL, 'f'},
|
||||
{"silent", no_argument, NULL, 'f'},
|
||||
{"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"recursive", no_argument, nullptr, 'R'},
|
||||
{"changes", no_argument, nullptr, 'c'},
|
||||
{"dereference", no_argument, nullptr, DEREFERENCE_OPTION},
|
||||
{"from", required_argument, nullptr, FROM_OPTION},
|
||||
{"no-dereference", no_argument, nullptr, 'h'},
|
||||
{"no-preserve-root", no_argument, nullptr, NO_PRESERVE_ROOT},
|
||||
{"preserve-root", no_argument, nullptr, PRESERVE_ROOT},
|
||||
{"quiet", no_argument, nullptr, 'f'},
|
||||
{"silent", no_argument, nullptr, 'f'},
|
||||
{"reference", required_argument, nullptr, REFERENCE_FILE_OPTION},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -78,14 +77,23 @@ usage (int status)
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... [OWNER][:[GROUP]] FILE...\n\
|
||||
Usage: %s [OPTION]... %s FILE...\n\
|
||||
or: %s [OPTION]... --reference=RFILE FILE...\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
fputs (_("\
|
||||
program_name,
|
||||
chown_mode == CHOWN_CHOWN ? _("[OWNER][:[GROUP]]") : _("GROUP"),
|
||||
program_name);
|
||||
if (chown_mode == CHOWN_CHOWN)
|
||||
fputs (_("\
|
||||
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\
|
||||
"), stdout);
|
||||
else
|
||||
fputs (_("\
|
||||
Change the group of each FILE to GROUP.\n\
|
||||
With --reference, change the group of each FILE to that of RFILE.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
@@ -103,9 +111,9 @@ With --reference, change the owner and group of each FILE to those of RFILE.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--from=CURRENT_OWNER:CURRENT_GROUP\n\
|
||||
change the owner and/or group of each file only if\n\
|
||||
change the ownership of each file only if\n\
|
||||
its current owner and/or group match those specified\n\
|
||||
here. Either may be omitted, in which case a match\n\
|
||||
here. Either may be omitted, in which case a match\n\
|
||||
is not required for the omitted attribute\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
@@ -113,34 +121,25 @@ With --reference, change the owner and group of each FILE to those of RFILE.\n\
|
||||
--preserve-root fail to operate recursively on '/'\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--reference=RFILE use RFILE's owner and group rather than specifying\n\
|
||||
OWNER:GROUP values. RFILE is always dereferenced.\n\
|
||||
--reference=RFILE use RFILE's ownership rather than specifying values\n\
|
||||
RFILE is always dereferenced if a symbolic link.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-R, --recursive operate on files and directories recursively\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
The following options modify how a hierarchy is traversed when the -R\n\
|
||||
option is also specified. If more than one is specified, only the final\n\
|
||||
one takes effect.\n\
|
||||
\n\
|
||||
-H if a command line argument is a symbolic link\n\
|
||||
to a directory, traverse it\n\
|
||||
-L traverse every symbolic link to a directory\n\
|
||||
encountered\n\
|
||||
-P do not traverse any symbolic links (default)\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
emit_symlink_recurse_options ("-P");
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
fputs (_("\
|
||||
if (chown_mode == CHOWN_CHOWN)
|
||||
fputs (_("\
|
||||
\n\
|
||||
Owner is unchanged if missing. Group is unchanged if missing, but changed\n\
|
||||
to login group if implied by a ':' following a symbolic OWNER.\n\
|
||||
OWNER and GROUP may be numeric as well as symbolic.\n\
|
||||
"), stdout);
|
||||
printf (_("\
|
||||
|
||||
if (chown_mode == CHOWN_CHOWN)
|
||||
printf (_("\
|
||||
\n\
|
||||
Examples:\n\
|
||||
%s root /u Change the owner of /u to \"root\".\n\
|
||||
@@ -148,6 +147,14 @@ Examples:\n\
|
||||
%s -hR root /u Change the owner of /u and subfiles to \"root\".\n\
|
||||
"),
|
||||
program_name, program_name, program_name);
|
||||
else
|
||||
printf (_("\
|
||||
\n\
|
||||
Examples:\n\
|
||||
%s staff /u Change the group of /u to \"staff\".\n\
|
||||
%s -hR staff /u Change the group of /u and subfiles to \"staff\".\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
emit_ancillary_info (PROGRAM_NAME);
|
||||
}
|
||||
exit (status);
|
||||
@@ -187,7 +194,7 @@ main (int argc, char **argv)
|
||||
|
||||
chopt_init (&chopt);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, NULL))
|
||||
while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -230,7 +237,7 @@ main (int argc, char **argv)
|
||||
bool warn;
|
||||
char const *e = parse_user_spec_warn (optarg,
|
||||
&required_uid, &required_gid,
|
||||
NULL, NULL, &warn);
|
||||
nullptr, nullptr, &warn);
|
||||
if (e)
|
||||
error (warn ? 0 : EXIT_FAILURE, 0, "%s: %s", e, quote (optarg));
|
||||
break;
|
||||
@@ -264,8 +271,8 @@ main (int argc, char **argv)
|
||||
if (bit_flags == FTS_PHYSICAL)
|
||||
{
|
||||
if (dereference == 1)
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
dereference = 0;
|
||||
}
|
||||
}
|
||||
@@ -288,27 +295,41 @@ main (int argc, char **argv)
|
||||
{
|
||||
struct stat ref_stats;
|
||||
if (stat (reference_file, &ref_stats))
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
|
||||
uid = ref_stats.st_uid;
|
||||
if (chown_mode == CHOWN_CHOWN)
|
||||
{
|
||||
uid = ref_stats.st_uid;
|
||||
chopt.user_name = uid_to_name (ref_stats.st_uid);
|
||||
}
|
||||
gid = ref_stats.st_gid;
|
||||
chopt.user_name = uid_to_name (ref_stats.st_uid);
|
||||
chopt.group_name = gid_to_name (ref_stats.st_gid);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *ug = argv[optind];
|
||||
if (chown_mode == CHOWN_CHGRP)
|
||||
{
|
||||
ug = xmalloc (1 + strlen (argv[optind]) + 1);
|
||||
stpcpy (stpcpy (ug, ":"), argv[optind]);
|
||||
}
|
||||
|
||||
bool warn;
|
||||
char const *e = parse_user_spec_warn (argv[optind], &uid, &gid,
|
||||
char const *e = parse_user_spec_warn (ug, &uid, &gid,
|
||||
&chopt.user_name,
|
||||
&chopt.group_name, &warn);
|
||||
|
||||
if (ug != argv[optind])
|
||||
free (ug);
|
||||
|
||||
if (e)
|
||||
error (warn ? 0 : EXIT_FAILURE, 0, "%s: %s", e, quote (argv[optind]));
|
||||
|
||||
/* If a group is specified but no user, set the user name to the
|
||||
empty string so that diagnostics say "ownership :GROUP"
|
||||
rather than "group GROUP". */
|
||||
if (!chopt.user_name && chopt.group_name)
|
||||
if (chown_mode == CHOWN_CHOWN && !chopt.user_name && chopt.group_name)
|
||||
chopt.user_name = xstrdup ("");
|
||||
|
||||
optind++;
|
||||
@@ -318,9 +339,9 @@ main (int argc, char **argv)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (chopt.root_dev_ino == NULL)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
if (chopt.root_dev_ino == nullptr)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
|
||||
bit_flags |= FTS_DEFER_STAT;
|
||||
|
||||
7
src/chown.h
Normal file
7
src/chown.h
Normal file
@@ -0,0 +1,7 @@
|
||||
/* This is for the 'chown' program. */
|
||||
#define CHOWN_CHOWN 1
|
||||
|
||||
/* This is for the 'chgrp' program. */
|
||||
#define CHOWN_CHGRP 2
|
||||
|
||||
extern int chown_mode;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user