mirror of
https://https.git.savannah.gnu.org/git/patch.git
synced 2026-01-27 18:05:02 +00:00
Compare commits
529 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d161c9a9db | ||
|
|
4c302306a8 | ||
|
|
aea66268c9 | ||
|
|
77c27209f6 | ||
|
|
48ceda8200 | ||
|
|
b3d0c93338 | ||
|
|
29fced6251 | ||
|
|
b5d2124e2e | ||
|
|
86ac7e2d7b | ||
|
|
7d876522e9 | ||
|
|
86baf979f4 | ||
|
|
1ba2c1bdf8 | ||
|
|
1da6bf84db | ||
|
|
30ee6103a5 | ||
|
|
6dbc381055 | ||
|
|
05ac924fef | ||
|
|
95e0092f97 | ||
|
|
5bac274507 | ||
|
|
910fecf695 | ||
|
|
be8b3c68b0 | ||
|
|
c61485bd05 | ||
|
|
499916fdd8 | ||
|
|
adb1ebce7f | ||
|
|
6bdae94eb3 | ||
|
|
72a146cfaf | ||
|
|
e2e6820f71 | ||
|
|
606c09176c | ||
|
|
ee3cc4016d | ||
|
|
8cae4fc221 | ||
|
|
164b529f53 | ||
|
|
91c1e4f071 | ||
|
|
a03e1bac4a | ||
|
|
9ba5eb00b3 | ||
|
|
79dd5e762c | ||
|
|
8492a6a212 | ||
|
|
f6f2c6f31a | ||
|
|
0525681eb5 | ||
|
|
301411d927 | ||
|
|
461520693e | ||
|
|
923e0ef280 | ||
|
|
5d17ca0e5f | ||
|
|
5f4edd389e | ||
|
|
802511c09b | ||
|
|
a93b50de71 | ||
|
|
55e224bd73 | ||
|
|
33a7fd89ec | ||
|
|
2313b37f6a | ||
|
|
37fec39c58 | ||
|
|
cc87173e46 | ||
|
|
7887622b77 | ||
|
|
18f4dd67ad | ||
|
|
638675c19a | ||
|
|
53400a17ed | ||
|
|
e8e1bcb7a0 | ||
|
|
b963510dcd | ||
|
|
85949fb4ac | ||
|
|
448ff9bc72 | ||
|
|
b95a603908 | ||
|
|
2663228379 | ||
|
|
fc779640b0 | ||
|
|
470699c8f2 | ||
|
|
f696e4ef12 | ||
|
|
4d3a4ab09a | ||
|
|
b3bb925cee | ||
|
|
070d859e07 | ||
|
|
f46a90f137 | ||
|
|
2e64cfd98c | ||
|
|
45de0d99c8 | ||
|
|
82c4940a2e | ||
|
|
eceea619a6 | ||
|
|
9c55d3f541 | ||
|
|
61c72f07b3 | ||
|
|
705c9bcdc1 | ||
|
|
77f21a6068 | ||
|
|
fe8ffd9ba4 | ||
|
|
5e84bda3ff | ||
|
|
8d4ca493ed | ||
|
|
fe5d4a06f7 | ||
|
|
ca4c431f8a | ||
|
|
0ad4347277 | ||
|
|
c49a16d0ca | ||
|
|
22efdeebaa | ||
|
|
5a70a1b6b9 | ||
|
|
c0d465f21b | ||
|
|
b91aab2c88 | ||
|
|
55c8a5c494 | ||
|
|
e0e121efe5 | ||
|
|
241e57ea5b | ||
|
|
0f8c62835f | ||
|
|
f2c3676393 | ||
|
|
cec6407930 | ||
|
|
6b7b01b89b | ||
|
|
043355371a | ||
|
|
0a66dee829 | ||
|
|
36ff2c9296 | ||
|
|
3951496739 | ||
|
|
6429630c0c | ||
|
|
03cb187db6 | ||
|
|
cc7cde7a2c | ||
|
|
4c6650b507 | ||
|
|
abe92e8010 | ||
|
|
30449e294b | ||
|
|
9228a8cf28 | ||
|
|
c1c438d3a8 | ||
|
|
5d3f41f6fc | ||
|
|
fb056f23ac | ||
|
|
84b5f34f2a | ||
|
|
d2e113e9a4 | ||
|
|
f73718b634 | ||
|
|
79eef3e014 | ||
|
|
11588d0fa2 | ||
|
|
e16037d11f | ||
|
|
388926ffa7 | ||
|
|
3582fdb953 | ||
|
|
4a47c002fa | ||
|
|
4f8c4b8842 | ||
|
|
0a810b6e27 | ||
|
|
bac3b6d06a | ||
|
|
8fb784b7d0 | ||
|
|
e10f3ca472 | ||
|
|
57e2165767 | ||
|
|
eb18b39cc7 | ||
|
|
d60cb724bd | ||
|
|
05ef886471 | ||
|
|
1f8d192897 | ||
|
|
ba92722539 | ||
|
|
0f98e033f2 | ||
|
|
1235ccc55b | ||
|
|
43ee674679 | ||
|
|
e3819470dc | ||
|
|
2c2a83b77a | ||
|
|
a13c2eaf16 | ||
|
|
6eb2d138e6 | ||
|
|
d1a6847368 | ||
|
|
d6631b3125 | ||
|
|
bc6899dc6f | ||
|
|
da259855ca | ||
|
|
248ef134f8 | ||
|
|
6cb321aff4 | ||
|
|
47bc09dc6a | ||
|
|
7608746040 | ||
|
|
323da0da04 | ||
|
|
53d10143f2 | ||
|
|
59681c8e9a | ||
|
|
4278b91942 | ||
|
|
34b45bc78b | ||
|
|
d18c05d5bd | ||
|
|
af828e563c | ||
|
|
b3a6c95537 | ||
|
|
9abc949979 | ||
|
|
90e62d5195 | ||
|
|
2b87c1eb7f | ||
|
|
7aa1c3bc32 | ||
|
|
99c0c0b7b8 | ||
|
|
1c087d6fcb | ||
|
|
7214f8d44b | ||
|
|
6785b2c42c | ||
|
|
72d7ed09bc | ||
|
|
abf6fb176b | ||
|
|
d3816ac315 | ||
|
|
346d3aca37 | ||
|
|
ff2317b2cb | ||
|
|
c2d9792e92 | ||
|
|
8c27a03b2e | ||
|
|
d46d729c0c | ||
|
|
924698bfd6 | ||
|
|
8939519c06 | ||
|
|
531cc2b9c6 | ||
|
|
ff13fea205 | ||
|
|
3d5c0d1fd9 | ||
|
|
56788ce462 | ||
|
|
c10da772ef | ||
|
|
1e217677df | ||
|
|
39005cfce9 | ||
|
|
755712d85e | ||
|
|
04f0eeb438 | ||
|
|
f06c1230d7 | ||
|
|
aab6e7bc8a | ||
|
|
d1d32c9747 | ||
|
|
7575694ee8 | ||
|
|
8f78b098c2 | ||
|
|
bb841fd7b0 | ||
|
|
4887683ab0 | ||
|
|
5b8ecde1a2 | ||
|
|
009a424a74 | ||
|
|
299167f059 | ||
|
|
3ec44a42c4 | ||
|
|
68cb5293f7 | ||
|
|
f144b35425 | ||
|
|
faafc79f8d | ||
|
|
c835ecc67b | ||
|
|
24f81beb27 | ||
|
|
7623b2dc0d | ||
|
|
0993940034 | ||
|
|
78ed9decdf | ||
|
|
76e775847f | ||
|
|
15b158db3a | ||
|
|
dce4683cbb | ||
|
|
61d7788b83 | ||
|
|
b7b028a77b | ||
|
|
a5b442ce01 | ||
|
|
2b584aec9e | ||
|
|
9c986353e4 | ||
|
|
ff81775f4e | ||
|
|
369dcccdfa | ||
|
|
19599883ff | ||
|
|
f322a7e0e5 | ||
|
|
458ac51a05 | ||
|
|
1e9104c180 | ||
|
|
ae81be0024 | ||
|
|
2a32bf09f5 | ||
|
|
ff1d3a67da | ||
|
|
3fcd042d26 | ||
|
|
123eaff0d5 | ||
|
|
b5a91a01e5 | ||
|
|
f290f48a62 | ||
|
|
074e2395f8 | ||
|
|
f6bc5b14bd | ||
|
|
3bbebbb29f | ||
|
|
40b387de08 | ||
|
|
66f9fa2690 | ||
|
|
107e1cecfc | ||
|
|
e6da0b81bf | ||
|
|
9ab866d562 | ||
|
|
6a737fca57 | ||
|
|
592e1f9163 | ||
|
|
15cc7d44d4 | ||
|
|
5bf48c87ca | ||
|
|
00947f4111 | ||
|
|
61b6ec8857 | ||
|
|
a2b6fb1672 | ||
|
|
817d7d1767 | ||
|
|
49705d1d8d | ||
|
|
a0d7fe4589 | ||
|
|
4c43a0b1cb | ||
|
|
d874c38335 | ||
|
|
b6c4780f73 | ||
|
|
9ca38fa1e6 | ||
|
|
66fdcf0e7c | ||
|
|
83a3ed012c | ||
|
|
70532e21a8 | ||
|
|
4f4fd1b41d | ||
|
|
3270d221a9 | ||
|
|
98b86e970a | ||
|
|
68049159f2 | ||
|
|
871f87824a | ||
|
|
5c6625bf62 | ||
|
|
6a55099e7a | ||
|
|
3b698ab6a1 | ||
|
|
3cd040cf4c | ||
|
|
7a77ae9f81 | ||
|
|
274c66c775 | ||
|
|
99d3b514e9 | ||
|
|
a6615bcb83 | ||
|
|
914d06b7c3 | ||
|
|
c5705fd476 | ||
|
|
ca9df22fe6 | ||
|
|
0d3df382d6 | ||
|
|
9f92e52c9f | ||
|
|
6fbdcefe7d | ||
|
|
a025a51ca5 | ||
|
|
ef609c26b2 | ||
|
|
3c58eb50ce | ||
|
|
e1f0aa0a9d | ||
|
|
c5da382c0b | ||
|
|
d55ab5b941 | ||
|
|
db9f39507e | ||
|
|
8d12036047 | ||
|
|
7297352e16 | ||
|
|
69434de2d5 | ||
|
|
ddf16e1209 | ||
|
|
8a9f5432d4 | ||
|
|
b73c1f95cb | ||
|
|
709458d9d9 | ||
|
|
de89dde09e | ||
|
|
38d87ecb9e | ||
|
|
82b800c955 | ||
|
|
68d39ff29f | ||
|
|
c80b1a06a9 | ||
|
|
8d621e8819 | ||
|
|
290ffcb488 | ||
|
|
b72e3be5c8 | ||
|
|
71a3172c7e | ||
|
|
025a54b789 | ||
|
|
6a56d401d2 | ||
|
|
75fcb4b560 | ||
|
|
3e7113a6b5 | ||
|
|
41688ad8ef | ||
|
|
17953b5893 | ||
|
|
0c08d7a902 | ||
|
|
19285e563a | ||
|
|
ae88d1c270 | ||
|
|
4e9269a5fc | ||
|
|
44a987e02f | ||
|
|
f22e47d873 | ||
|
|
e4c6511f46 | ||
|
|
3fd4144ae9 | ||
|
|
65193f1cc1 | ||
|
|
e25e622dec | ||
|
|
f926295f4f | ||
|
|
dc63883f08 | ||
|
|
a2f4bfe0f3 | ||
|
|
89dbba7229 | ||
|
|
afdfa9ec8e | ||
|
|
aac14e3187 | ||
|
|
60c9d4838f | ||
|
|
2f40ef66be | ||
|
|
082baa326a | ||
|
|
291ec17581 | ||
|
|
47191c287d | ||
|
|
bbb840edca | ||
|
|
6214f5e222 | ||
|
|
fc5ddce20e | ||
|
|
ac59899327 | ||
|
|
c9de555284 | ||
|
|
e8bfce6547 | ||
|
|
1d9ed51e9c | ||
|
|
b272c2d535 | ||
|
|
89e5f702eb | ||
|
|
3ccb16e10b | ||
|
|
db1bd7f693 | ||
|
|
d24f630fbc | ||
|
|
1d9d403394 | ||
|
|
293415dbcf | ||
|
|
59609b50c5 | ||
|
|
b578985c3c | ||
|
|
3b934d6903 | ||
|
|
99f2638763 | ||
|
|
0f22a35cec | ||
|
|
4c7c0976ac | ||
|
|
95f6823325 | ||
|
|
1ea53aae17 | ||
|
|
20c9d7d5ab | ||
|
|
2b2fb1f36c | ||
|
|
543906f1a4 | ||
|
|
f0388d2dbf | ||
|
|
281537bcd9 | ||
|
|
dc3cdeebca | ||
|
|
474bb7d333 | ||
|
|
58ec5b5643 | ||
|
|
e4b9ff4cfe | ||
|
|
66aeedee12 | ||
|
|
9a37354cc6 | ||
|
|
a18960d31e | ||
|
|
e294241b86 | ||
|
|
3980c923dc | ||
|
|
a3f2ca32c3 | ||
|
|
81d006fe4b | ||
|
|
1e6c0d07ab | ||
|
|
cdc94fade3 | ||
|
|
120927804d | ||
|
|
46e58be9cc | ||
|
|
1118f832ef | ||
|
|
386ae15bce | ||
|
|
6be1a126bd | ||
|
|
57eb3007ab | ||
|
|
ea4212ee51 | ||
|
|
b0c22022be | ||
|
|
6e21796422 | ||
|
|
90d4e1f3d5 | ||
|
|
709688a8d9 | ||
|
|
e0a7877a6e | ||
|
|
9a26fde226 | ||
|
|
b9a1ff0cfa | ||
|
|
c43eeb22a4 | ||
|
|
309ece2e5a | ||
|
|
5081f42226 | ||
|
|
9ff0689857 | ||
|
|
3b4824fb33 | ||
|
|
73184a17e2 | ||
|
|
02548c1549 | ||
|
|
8de9b7b036 | ||
|
|
ed081db4b1 | ||
|
|
a8699f834b | ||
|
|
f4accb062b | ||
|
|
297f9e7dd6 | ||
|
|
d0745f417c | ||
|
|
d504183866 | ||
|
|
2d38b11799 | ||
|
|
5cb38ce390 | ||
|
|
5ca55b8414 | ||
|
|
17086c5cf2 | ||
|
|
4e595c3b6d | ||
|
|
46ad06707c | ||
|
|
2231959c18 | ||
|
|
b083f881f1 | ||
|
|
586239e353 | ||
|
|
5853a727de | ||
|
|
0649fbf212 | ||
|
|
209af7ee4b | ||
|
|
bb2fef06eb | ||
|
|
6526aec61f | ||
|
|
b4c6b7086b | ||
|
|
5a634c3834 | ||
|
|
aa85679b9a | ||
|
|
c9f9680fd1 | ||
|
|
d08c6262c7 | ||
|
|
df2831fbdf | ||
|
|
8b78759a8b | ||
|
|
4a7efc3791 | ||
|
|
db2fb7cdba | ||
|
|
d8fdb88440 | ||
|
|
38cecf52b6 | ||
|
|
7db2653124 | ||
|
|
2876ed918f | ||
|
|
02e3376350 | ||
|
|
07d4792620 | ||
|
|
8d6290df9f | ||
|
|
f266434caf | ||
|
|
94e032f941 | ||
|
|
7d41c04e7b | ||
|
|
d96503d66a | ||
|
|
764d0ea12e | ||
|
|
8678ae92ea | ||
|
|
e0f707523c | ||
|
|
f663762bf0 | ||
|
|
dcfb493578 | ||
|
|
3fc5b24073 | ||
|
|
3c776b0844 | ||
|
|
4c3004c17f | ||
|
|
685a78b605 | ||
|
|
7fae6755f4 | ||
|
|
77e15c7286 | ||
|
|
76d0e43140 | ||
|
|
28113637f5 | ||
|
|
03f337dabc | ||
|
|
1119764035 | ||
|
|
5b460672d7 | ||
|
|
3e234c40d2 | ||
|
|
86e12910c6 | ||
|
|
7e6d1e6718 | ||
|
|
19aecf8108 | ||
|
|
b73bec8e45 | ||
|
|
fdafb60cc0 | ||
|
|
a1a66e6032 | ||
|
|
93129f45a1 | ||
|
|
76649aba9e | ||
|
|
51147ca57d | ||
|
|
4b6267d62f | ||
|
|
0eef74e981 | ||
|
|
206e87000c | ||
|
|
9f1beb577a | ||
|
|
94d856cfd3 | ||
|
|
2475341173 | ||
|
|
423d17d562 | ||
|
|
d94b00785d | ||
|
|
7e9296614a | ||
|
|
99d75edf46 | ||
|
|
5b68db86ce | ||
|
|
a78d3c405b | ||
|
|
ad76f67285 | ||
|
|
9dbdc0e748 | ||
|
|
80cfee88e6 | ||
|
|
4ded52f912 | ||
|
|
bcf08ba042 | ||
|
|
481768b9d7 | ||
|
|
dbb26b7e99 | ||
|
|
1b2ed3de07 | ||
|
|
4e1404fe82 | ||
|
|
8462be2ed0 | ||
|
|
a93dea1dce | ||
|
|
76aa1070c8 | ||
|
|
0e952c6d34 | ||
|
|
0403787317 | ||
|
|
0c837fd075 | ||
|
|
47622c1e46 | ||
|
|
cabd1add57 | ||
|
|
9e39d9c995 | ||
|
|
502d77b81b | ||
|
|
5f3b6a06a1 | ||
|
|
b68294e3e1 | ||
|
|
f9db7450fa | ||
|
|
12fdbd5cec | ||
|
|
a41a918fe7 | ||
|
|
53fdc8e340 | ||
|
|
dc0a3e09a8 | ||
|
|
7f35c90cf7 | ||
|
|
ba67864c2a | ||
|
|
cd0ea8e786 | ||
|
|
b610c25e84 | ||
|
|
baaa92c25d | ||
|
|
444decd3f2 | ||
|
|
cfe068672d | ||
|
|
9807e6160f | ||
|
|
133f2820b3 | ||
|
|
69f5ebc2d2 | ||
|
|
7e98397ab2 | ||
|
|
d7020ed1a9 | ||
|
|
e3cfef7f99 | ||
|
|
f558fff533 | ||
|
|
3aceaac307 | ||
|
|
a11bfc85e5 | ||
|
|
37f7c8faec | ||
|
|
de38f4acfb | ||
|
|
3288f660a0 | ||
|
|
310f4c406a | ||
|
|
30a7405dfb | ||
|
|
3bccc730eb | ||
|
|
a64a20d0ab | ||
|
|
c4f28f6efb | ||
|
|
05400c5689 | ||
|
|
d909eee7c9 | ||
|
|
f81fe080e5 | ||
|
|
3693996297 | ||
|
|
68e9980cce | ||
|
|
9486a75e1a | ||
|
|
3b60c20c17 | ||
|
|
02ee1d4e01 | ||
|
|
3bde83e95e | ||
|
|
f97abc39d2 | ||
|
|
130f11008d | ||
|
|
b1c58bd212 | ||
|
|
57d468b7a4 | ||
|
|
65a8f0f278 | ||
|
|
c86f4a2c80 | ||
|
|
7fa8417c05 | ||
|
|
8d5ea52c7a | ||
|
|
231e52e985 | ||
|
|
d300ec9bb8 | ||
|
|
70c5b3126f | ||
|
|
f376c5db4a | ||
|
|
91e027ab1a | ||
|
|
819b4a5c1f | ||
|
|
3473a896bb | ||
|
|
d868be8cdf | ||
|
|
c3052e896b | ||
|
|
fcdaaaac28 | ||
|
|
2c4e3ecdde | ||
|
|
aa7ae95324 |
7
.gitattributes
vendored
Normal file
7
.gitattributes
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
# Run this to make 'git diff' on texinfo files give nicer hunk context:
|
||||
# git config diff.texinfo.funcname '^@node[ ][ ]*\\([^,][^,]*\\)'
|
||||
*.texi* diff=texinfo
|
||||
|
||||
# Run this to make 'git diff' on .m4 files give nicer hunk context:
|
||||
# git config diff.m4.xfuncname '^((AC_DEFUN|m4_define)[^,)]*)'
|
||||
*.m4 diff=m4
|
||||
37
.gitignore
vendored
37
.gitignore
vendored
@ -1,19 +1,36 @@
|
||||
*.log
|
||||
*.o
|
||||
/Makefile
|
||||
*.trs
|
||||
*~
|
||||
.deps/
|
||||
/.pc/
|
||||
/.version
|
||||
/ChangeLog
|
||||
/GNUmakefile
|
||||
/ID
|
||||
/INSTALL
|
||||
/VERSION
|
||||
/[0-9]*.patch
|
||||
/aclocal.m4
|
||||
/autom4te.cache/
|
||||
/build-aux/
|
||||
/config.cache
|
||||
/config.h
|
||||
/config.hin
|
||||
/config.hin~
|
||||
/config.log
|
||||
/config.status
|
||||
/configure
|
||||
/doc/
|
||||
/lib/
|
||||
!/lib/Makefile.am
|
||||
/m4/*.m4
|
||||
/m4/.gitignore
|
||||
!/m4/setmode.m4
|
||||
!/m4/xattr.m4
|
||||
/maint.mk
|
||||
/patch-*.tar.*
|
||||
/src/patch
|
||||
/.pc/
|
||||
/VERSION
|
||||
/patch-*.tar.bz2
|
||||
/patch-*.tar.bz2.sig
|
||||
/patch-*.tar.gz
|
||||
/patch-*.tar.gz.sig
|
||||
/patch-*.tar.xz
|
||||
/patch-*.tar.xz.sig
|
||||
/stamp-h1
|
||||
Makefile
|
||||
Makefile.in
|
||||
TAGS
|
||||
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "gnulib"]
|
||||
path = gnulib
|
||||
url = git://git.sv.gnu.org/gnulib.git
|
||||
@ -1,9 +1,618 @@
|
||||
2011-03-17 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
don't version-control ChangeLog; instead, generate it from git log
|
||||
* Makefile.am (gen-ChangeLog): New rule.
|
||||
* .gitignore: List ChangeLog.
|
||||
|
||||
2011-02-20 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
maint: remove unnecessary tests before free
|
||||
There is no longer any need to avoid "free(NULL)" (since SunOS 4),
|
||||
so replace each "if (P) free (P);" with "free (P);".
|
||||
* src/inp.c (get_input_file): Remove unnecessary test-before-free.
|
||||
* src/patch.c (get_some_switches): Likewise.
|
||||
* src/pch.c (intuit_diff_type, pch_swap): Likewise.
|
||||
|
||||
2011-02-17 Jim Meyering <meyering@redhat.com>
|
||||
and Andreas Gruenbacher <agruen@linbit.com>
|
||||
|
||||
don't warn twice about the same invalid file name
|
||||
* src/pch.c (name_is_valid): Don't warn about the same name twice.
|
||||
* tests/bad-filenames (emit_patch): Exercise the new code.
|
||||
|
||||
2011-02-16 Andreas Gruenbacher <agruen@linbit.com>
|
||||
|
||||
* src/pch.c (name_is_valid): New function.
|
||||
(intuit_diff_type, best_name): Use name_is_valid() here.
|
||||
(strip_leading_slashes): Remove name validation tests from here.
|
||||
* tests/bad-filenames: Add more tests for covering more of the
|
||||
file name guessing corner cases in intuit_diff_type(), update the
|
||||
existing tests.
|
||||
* NEWS: Update.
|
||||
|
||||
2011-02-15 Andreas Gruenbacher <agruen@linbit.com>
|
||||
|
||||
* src/patch.c (main): Fix use of initialized outst and add an
|
||||
additional assert. Reported by Jim Meyering.
|
||||
|
||||
2011-02-03 Ozan Çağlayan <ozan@pardus.org.tr>
|
||||
|
||||
Create directory test case
|
||||
* tests/create-delete: New test case creating a file in a new
|
||||
sub-directory (bug fixed on 2010-12-04).
|
||||
|
||||
2011-02-03 Andreas Gruenbacher <agruen@linbit.com>
|
||||
|
||||
Also check if the input file is seekable if a filename is given (-i)
|
||||
* src/pch.c (open_patch_file): Also check if the input file is
|
||||
seekable if a filename is given (-i).
|
||||
* tests/pipe: New file. Test this.
|
||||
* tests/Makefile.am (TESTS): Add it.
|
||||
|
||||
2011-02-03 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
doc: mention the fix for CVE-2010-4651
|
||||
* NEWS: Mention the fix.
|
||||
|
||||
2011-02-01 Jim Meyering <meyering@redhat.com>
|
||||
and Andreas Gruenbacher <agruen@linbit.com>
|
||||
|
||||
Do not let a malicious patch create files above current directory
|
||||
This addresses CVE-2010-4651, reported by Jakub Wilk.
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2010-4651
|
||||
* src/util.c (strip_leading_slashes): Reject absolute file names and
|
||||
file names containing a component of "..".
|
||||
* tests/bad-filenames: New file. Test for this.
|
||||
* tests/Makefile.am (TESTS): Add it.
|
||||
|
||||
2010-12-04 Andreas Gruenbacher <agruen@linbit.com>
|
||||
|
||||
* src/util.c (make_tempfile): Create missing directories when
|
||||
necessary.
|
||||
|
||||
2010-10-29 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/util.c: USE_XATTR is defined to 0 or 1, so we need to use #if
|
||||
instead of #ifdef.
|
||||
|
||||
2010-10-27 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/util.c (set_file_attributes): Always expect the mode argument to
|
||||
be set when FA_MODE is specified.
|
||||
(create_backup_copy): Update accordingly.
|
||||
|
||||
* src/patch.c (main): Set all file attributes of the temporary output
|
||||
file before renaming it over the final output file (possibly replacing
|
||||
the input file). Pass the input file name to set_file_attributes().
|
||||
* src/util.c (set_file_attributes): When enabled (USE_XATTR), also
|
||||
copy extended attributes including attributes which define
|
||||
permissions.
|
||||
(copy_attr_error, copy_attr_quote, copy_attr_free, copy_attr_check,
|
||||
copy_attr): Helper functions for copying extended attributes.
|
||||
* m4/xattr.m4 (gl_FUNC_XATTR): Import from coreutils.
|
||||
* src/Makefile.am (patch_LDADD): Add $(LIB_XATTR) here.
|
||||
* bootstrap.conf: Use the gnulib verror module.
|
||||
|
||||
2010-10-26 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* configure.ac: Remove obsolete checks for mktemp.
|
||||
|
||||
2010-10-20 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/patch.c (print_header_line): Remove obsolete comment.
|
||||
|
||||
2010-10-14 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/pch.c (there_is_another_patch): Set p_strip_trailing_cr
|
||||
to false if no_strip_trailing_cr is set independent of the verbosity.
|
||||
This broke the --binary option in combination with --silent.
|
||||
|
||||
2010-10-05 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/util.c: Add a maybe_quoted parameter to fetchname.
|
||||
* src/pch.c: Only recognize quited filename in the "diff --git"
|
||||
format, at least for now.
|
||||
* tests/quoted-filenames: Update accordingly.
|
||||
* NEWS: Update accordingly.
|
||||
|
||||
2010-09-17 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/inp.c (scan_input): Remove double quotearg().
|
||||
|
||||
* src/patch.c (main): Generate the "patching file" message here. When
|
||||
the input and output file name is not he same, include both names in
|
||||
the message.
|
||||
* src/inp.c (scan_input): Previously the "patching file" message was
|
||||
generated here.
|
||||
* tests/unmodified-files, tests/copy-rename: Update.
|
||||
|
||||
* NEWS: Document that "diff --git" criss-cross renames are broken
|
||||
still.
|
||||
* tests/criss-cross: Test case currently expected to fail.
|
||||
|
||||
* tests/criss-cross: Add copy-after-modify test case.
|
||||
|
||||
2010-09-16 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/patch.c (open_outfile): New function.
|
||||
(init_output): Split into open_outfile() and the rest.
|
||||
|
||||
* src/pch.c (do_ed_script): Add inname, outname, and
|
||||
outname_needs_removal arguments. This isolates TMPOUTNAME and
|
||||
TMPOUTNAME_needs_removal to patch.c.
|
||||
* src/patch.c (main): Update do_ed_script() call.
|
||||
|
||||
* bootstrap.conf: Use the gnulib tempname module.
|
||||
* src/util.c (make_tempfile): New function.
|
||||
|
||||
* src/inp.c (plan_b): Compute TMPINNAME with make_tempfile() if needed
|
||||
instead of precomputing it in src/patch.c (main).
|
||||
|
||||
* src/pch.c (open_patch_file): Compute TMPPATNAME with make_tempfile()
|
||||
if needed instead of precomputing it in src/patch.c (main).
|
||||
|
||||
* src/patch.c (abort_hunk_unified): Replace unnecessary local variable.
|
||||
|
||||
* src/patch.c (main): Compute TMPREJNAME with make_tempfile() only if
|
||||
needed.
|
||||
(abort_hunk, init_reject): Pass through the output file name, and base
|
||||
TMPREJNAME on it.
|
||||
|
||||
* src/patch.c (main): Compute TMPOUTNAME with make_tempfile().
|
||||
(make_temp): Remove obsolete function.
|
||||
|
||||
2010-07-27 Tim Waugh <twaugh@redhat.com>
|
||||
|
||||
* src/patch.c: Stops "patch --get 1" from segfaulting.
|
||||
|
||||
2010-05-11 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/patch.c: The read-only file check was not done for ed scripts;
|
||||
fix this.
|
||||
|
||||
2010-05-06 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* tests/corrupt-reject-files, tests/crlf-handling: On Solaris, cat's
|
||||
-e option is only effective if -v is specified as well.
|
||||
|
||||
* tests/test-lib.sh: Ignore error messages when cleaning up after a
|
||||
test has finished.
|
||||
|
||||
2010-05-05 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* tests/test-lib.sh: Only use GNU diff when available.
|
||||
* tests/dash-o-append: Fix the expected result.
|
||||
|
||||
* tests/create-delete: Do not use 'diff' here.
|
||||
* tests/merge: Require GNU diff.
|
||||
|
||||
* bootstrap.conf: Use the gnulib unistd module.
|
||||
|
||||
* bootstrap.conf: Use the gnulib mkdir module.
|
||||
* m4/mkdir.m4: Delete.
|
||||
|
||||
2010-05-04 Eric Blake <eblake@redhat.com>
|
||||
|
||||
* src/pch.c (includes): Add <io.h> for setmode.
|
||||
(intuit_diff_type): Avoid 8-bit problems.
|
||||
* src/util.c (parse_name): Likewise.
|
||||
* src/util.h (skip_spaces): Likewise.
|
||||
|
||||
2010-05-04 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* tests/read-only-files: Remove the superuser test, and instead try
|
||||
out if a read-only file can be written to.
|
||||
|
||||
* tests/test-lib.sh: Create temporary directories in builddir; this
|
||||
removes the need to do it safely: some systems do not have mktemp -d.
|
||||
|
||||
* configure.ac, tests/Makefile: Remove $(TEST_SHELL) and use $(SHELL)
|
||||
instead.
|
||||
|
||||
* src/version.c: Put the Free Software Foundation copyright first.
|
||||
* tests/read-only-files: Skip when run as superuser: even files
|
||||
without write permissions would be writable.
|
||||
|
||||
* src/util.c (create_backup): Document patch's backup file logic.
|
||||
(create_backup, create_backup_copy): Add a flag to remember the backup
|
||||
file; use when a patch deletes a file.
|
||||
(move_file, copy_file): Better error messages.
|
||||
* tests/Makefile.am (TESTS): Remove remember-backup-files-2.
|
||||
* tests/remember-backup-files: Add tests from remember-backup-files-2.
|
||||
* tests/symlinks: Add a symlink backup file test.
|
||||
|
||||
* tests/test-lib.sh: Flag tests with missing pre-requirements as
|
||||
SKIPped instead of PASSed. Do not use GNU diff extensions, but
|
||||
still require a diff that understands "-u".
|
||||
* tests: Do not unnecessarily require GNU diff in a lot of tests.
|
||||
Make the sed utility optional.
|
||||
|
||||
* src/pch.c (intuit_diff_type): Remove left-over debugging code.
|
||||
|
||||
* src/pch.c (maybe_reverse): Allow to create and delete empty files.
|
||||
(sha1_says_nonexistent): New function for recognizing the sha1
|
||||
checksums of nonexistent and empty files.
|
||||
(skip_hex_digits): New helper function for skipping [0-9a-z].
|
||||
(intuit_diff_type): Parse the sha1 checksums in index lines.
|
||||
* tests/Makefile.am (XFAIL_TESTS): Remove empty-files.
|
||||
|
||||
2010-05-03 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/pch.c (intuit_diff_type): Fix a bug where the reversed-patch
|
||||
check would wrongly pick the last name instead of the best name.
|
||||
* src/create-delete: Add test cases for that.
|
||||
|
||||
2010-05-02 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/pch.c (fetchmode): Document that the "diff --git" format does
|
||||
not store file permissions of symlinks.
|
||||
* src/util.c (set_file_attributes): Since we don't have symlink file
|
||||
permissions, don't try to set them even on systems where we could.
|
||||
|
||||
* tests/symlinks: Improve the backup file tests.
|
||||
|
||||
2010-05-02 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/Makefile.am (patch_LDADD): Add $(LIB_CLOCK_GETTIME) here, after
|
||||
libpatch.a, so that clock_gettime is properly resolved on systems on
|
||||
which the library order matters.
|
||||
|
||||
* NEWS: Update.
|
||||
* gnulib: Update to latest.
|
||||
* bootstrap: Update from gnulib.
|
||||
|
||||
* src/patch.c (main): Refuse to patch read-only files, or at least warn
|
||||
when patching such files with --force or --batch.
|
||||
* patch.man: Document the changed behavior.
|
||||
* tests/read-only-files: Split read-only file test case off from
|
||||
tests/remember-backup-files.
|
||||
* tests/Makefile.am: Add new test case.
|
||||
|
||||
2010-04-29 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/patch.c (main): Support git diffs which copy or rename files.
|
||||
* tests/copy-rename: New test case.
|
||||
* tests/Makefile.am (TESTS): Add test case.
|
||||
|
||||
* src/patch.c (main): Convert outname into a char const *.
|
||||
* src/util.ch (create_backup, move_file, removedirs): Take char const *
|
||||
filenames.
|
||||
* src/util.c (makedirs): Take a char const * filename.
|
||||
(makedirs, removedirs): Take char const * filenames. Create and
|
||||
modify a copy of the filename.
|
||||
|
||||
* src/pch.c (p_copy, p_rename): New variables.
|
||||
(pch_copy, pch_rename): New functions.
|
||||
(intuit_diff_type): Parse the "copy from", "copy to", "rename from",
|
||||
and "rename to" headers.
|
||||
* src/util.c (fetchname): Return the fetched name per reference (after
|
||||
freeing the previous name if any). Also free the previous timestamp
|
||||
string if any.
|
||||
|
||||
* src/patch.c (main): When a git diff includes a file mode change,
|
||||
change to the new mode.
|
||||
* src/util.c (set_file_attributes): Add a mode parameter.
|
||||
* tests/file-modes: New test case.
|
||||
* tests/Makefile.am (TESTS): Add test case.
|
||||
|
||||
* src/patch.c (main): Support git symlink diffs.
|
||||
* tests/symlinks: Add git symlink diff test cases.
|
||||
|
||||
* src/pch.c (intuit_diff_type, there_is_another_patch): Pass up the
|
||||
file type.
|
||||
* src/patch.c (main): Check for consistent file types.
|
||||
|
||||
* src/pch.c (intuit_diff_type): Only check for reversed patches when
|
||||
the input file type matches the patch file type.
|
||||
|
||||
* src/util.c (move_file): Remove test which is always true.
|
||||
|
||||
2010-04-28 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/pch.c (p_mode): New variable.
|
||||
(fetchmode, pch_mode): New functions.
|
||||
(intuit_diff_type): Recognize git diffs which contain no hunks.
|
||||
Parse and store the file modes in the "index", "old mode",
|
||||
"new mode", "deleted file mode", and "new file mode" headers.
|
||||
|
||||
* src/util.c (copy_file): Require the mode parameter to include the
|
||||
file type. Use that to decide whether to copy a regular file or a
|
||||
symlink.
|
||||
(create_backup): Refuse to back up files which are neither a regular
|
||||
file nor a symlink.
|
||||
(move_file): Add support for turning a temporary output file into a
|
||||
symlink.
|
||||
* src/patch.c (move_file, copy_file): Pass down the file type.
|
||||
* src/pch.h (prefix_components): Do not follow symlinks.
|
||||
|
||||
* src/inp.c (get_input_file): Add a mode parameter specifying the
|
||||
input file type (which can be either S_IFREG or S_IFLNK). The file
|
||||
type must match this mode parameter; for symbolic links, the --get
|
||||
option is not supported.
|
||||
(scan_input): Abort when plan_a() cannot handle a symbolic link.
|
||||
Say when patching a symbolic link instead of a regular file.
|
||||
(plan_a): Add support for reading symbolic links.
|
||||
* src/patch.c: For now, always tell get_input_file() to read regular
|
||||
files.
|
||||
* bootstrap.conf: Use the gnulib readlink module.
|
||||
|
||||
* src/util.h (enum file_attributes): New type.
|
||||
(set_file_attributes): New function.
|
||||
* src/util.c (set_file_attributes): Move the code for setting file
|
||||
attributes here from create_backup_copy() and make it usable from
|
||||
patch.c as well. Make it symlink safe. In addition, also preserve
|
||||
the file owner when permitted.
|
||||
(create_backup_copy): Use set_file_attributes().
|
||||
* src/patch.c (main): Use set_file_attributes().
|
||||
* bootstrap.conf: Use the gnulib lchmod module.
|
||||
|
||||
2010-04-27 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* bootstrap: Update from gnulib.
|
||||
|
||||
* tests/Makefile.am (TESTS_ENVIRONMENT): Portability fix.
|
||||
|
||||
* src/bestmatch.h (bestmatch): Fix an off-by-one error causing an
|
||||
out-of-bounds array access.
|
||||
|
||||
* configure.ac (gl_CHECK_TYPE_STRUCT_UTIMBUF), m4/utimbuf.m4: Remove;
|
||||
utimbuf is no longer used.
|
||||
|
||||
* src/util.h: Include <backupfile.h> here and not in each C file
|
||||
individually; this avoids a warning in merge.c with some compilers.
|
||||
|
||||
* src/common.h: Do not redefine __attribute__ when it is already
|
||||
defined.
|
||||
|
||||
* configure.ac: Do not use grep -q.
|
||||
|
||||
2010-04-27 Daniel Richard G. <skunk@iskunk.org>
|
||||
|
||||
* src/common.h (enum diff): Remove the trailing comma.
|
||||
* src/patch.c (main): Do not use non-constant expressions in an array
|
||||
initializer.
|
||||
|
||||
* src/bestmatch.h: Do not use variable-length arrays.
|
||||
|
||||
2010-04-26 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/inp.c (get_input_file), src/pch.c (there_is_another_patch,
|
||||
intuit_diff_type): Use lstat instead of stat. This causes patch to
|
||||
refuse patching symlinks (get_input_file() will refuse to read them).
|
||||
* src/util.c (create_backup): Refuse to create backups of symlinks.
|
||||
* tests/symlinks: New test case.
|
||||
* tests/Makefile.am (TESTS): Add test case.
|
||||
* bootstrap.conf: Use the gnulib lstat module.
|
||||
|
||||
* src/pch.c (intuit_diff_type): Only check for reversed patches when
|
||||
the input file is patchable in the first place.
|
||||
|
||||
* src/pch.c (get_input_file): If an input file is not a regular file,
|
||||
only skip the patch instead of aborting.
|
||||
* src/patch.c (main): If get_input_file() fails, skip the patch.
|
||||
|
||||
2010-04-25 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* bootstrap.conf: Use the gnulib fcntl-h and sys_stat modules.
|
||||
* src/common.h: Remove the declarations provided by gnulib sys_stat.
|
||||
Always include fcntl.h (and depend on gnulib fcntl-h).
|
||||
* src/util.h: Remove duplicate include of <timespec.h>.
|
||||
* configure.ac: Remove obsolete checks for fcntl.h and utime.h.
|
||||
|
||||
* src/common.h, src/patch.c, src/util.c, src/util.h: Do not declare
|
||||
variables as "volatile" unnecessarily.
|
||||
|
||||
2010-04-24 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/inp.c, src/patch.c, src/pch.c, src/util.c: Stop declaring
|
||||
local variables as "register" all over the place: a decent compiler
|
||||
will do a good enough job of place variables into registers where it
|
||||
makes sense.
|
||||
|
||||
2010-04-23 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* patch.man: Describe the fixed behavior of --set-time and --set-utc
|
||||
for timestamps that include time zones.
|
||||
* NEWS: Update.
|
||||
|
||||
2010-04-22 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/common.h (enum diff): New enumeration GIT_BINARY_DIFF.
|
||||
* src/pch.c (intuit_diff_type): Recognize git binary patches.
|
||||
* src/patch.c (main): Complain when fed git binary patches.
|
||||
* tests/git-binary-diff: New test case.
|
||||
* tests/Makefile.am (TESTS): Add test case.
|
||||
|
||||
* src/pch.c (intuit_diff_type): Parse filenames in "diff --git" lines.
|
||||
* src/util.c (parse_name): New helper function for parsing unquoted or
|
||||
quoted filenames.
|
||||
* src/util.h (parse_name): Declare.
|
||||
(skip_spaces): New helper function for skipping spaces in a string.
|
||||
|
||||
* src/pch.c (intuit_diff_type): Make sure we don't leak file names
|
||||
even when fed weird input.
|
||||
|
||||
* src/util.c (parse_c_string): New function.
|
||||
(fetchname): Add support for quoted filenames.
|
||||
* tests/quoted-filenames: New test case.
|
||||
* tests/Makefile.am (TESTS): Add test case.
|
||||
|
||||
* src/util.c (fetchname): Untangle the name and timestamp parsing.
|
||||
|
||||
* src/util.c (strip_leading_slashes): Make this a separate function.
|
||||
(fetchname): Use strip_leading_slashes() here.
|
||||
|
||||
2010-04-21 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/patch.c (main): Support nanosecond timestamps. Replaqce utime()
|
||||
with utimens().
|
||||
* src/util.c (create_backup_copy): Preserve nanosecond timestamps.
|
||||
Replace utime() with utimens().
|
||||
* src/util.h: Remove the utime() related declarations, and include
|
||||
the utimens() and nanosecond related headers instead.
|
||||
* bootstrap.conf: Add the stat-time and utimens modules.
|
||||
|
||||
* src/Makefile.am (patch_SOURCES): Remove maketime.c, maketime.h,
|
||||
partime.c, and partime.h.
|
||||
(patch_LDFLAGS): Add LIB_CLOCK_GETTIME for clock_gettime().
|
||||
* src/util.c: Replace maketime.h and partime.h with getdate.h.
|
||||
(fetchname): Replace str2time() with get_date(). Sanitize the test
|
||||
for epoch timestamps.
|
||||
* src/patch.c (main): When --set-utc is given, set the TZ environment
|
||||
variable to UTC so that get_date() will default to UTC timestamps.
|
||||
* tests/preserve-mode-and-timestamp: Switching to get_date() revealed
|
||||
that str2time() was ignoring timezones. In order to test --set-utc
|
||||
now that get_date() fixes this, we must use timestamps that do not
|
||||
include timestamps here.
|
||||
* bootstrap.conf: Add the clock-time, getdate, gettime, and setenv
|
||||
modules.
|
||||
|
||||
2010-04-20 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/pch.h (pch_timestamp): Return timestamp as struct timespec
|
||||
instead of time_t.
|
||||
* src/pch.c: Use struct timespec instead of time_t. A tv_sec value
|
||||
of -1 indicates "no timestamp".
|
||||
* src/util.h (fetchname): Return timestamp as struct timespec
|
||||
instead of time_t.
|
||||
* src/util.c (fetchname): str2time() does not give us nanoseconds; set
|
||||
them to zero for now.
|
||||
* src/patch.c (main): Only use the seconds in timestamps for now.
|
||||
* bootstrap.conf: Add the time module for getting struct timespec
|
||||
declared on old hosts.
|
||||
|
||||
* src/util.c (quote_system_arg): Add a replacement for
|
||||
quote_system_arg() which uses quotearg's shell quoting style.
|
||||
* src/Makefile.am (patch_SOURCES): Remove quotesys.c and quotesys.h.
|
||||
* src/quotesys.c, src/quotesys.h: Delete.
|
||||
|
||||
* src/util.c (fetchname): Cosmetic fix.
|
||||
|
||||
2010-04-19 Ludovic Courtès <ludo@gnu.org>
|
||||
|
||||
* src/Makefile.am (patch_SOURCES): Remove the obsolete diffseq.h to
|
||||
fix "make dist".
|
||||
|
||||
2010-04-18 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* Globally rename type LINENUM to lin (as in diffutils).
|
||||
|
||||
* src/patch.c (Argv): Change type to char ** so that we can pass Argv
|
||||
to getopt_long without warning.
|
||||
* src/maketime.c (maketime): Fix year overflow check.
|
||||
|
||||
* diffseq: Use the gnulib version instead of a private copy.
|
||||
|
||||
* gnulib: Update to latest.
|
||||
|
||||
2010-04-15 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* tests/merge: Use the sed commands i, a, and c in their standard form
|
||||
instead of relying on a GNU extension, and pass sed a script (-f)
|
||||
instead of a list of commands via -e.
|
||||
Some versions of sed don't support expressions like /^\(\|foo\)$/.
|
||||
* tests/corrupt-reject-files: Use the more widely available -e switch
|
||||
instead of -A.
|
||||
* tests/crlf-handling: Likewise.
|
||||
* tests/preserve-mode-and-timestamp: Use touch -t instead of touch -d.
|
||||
Some non-GNU versions of date can't show a file's timestamp.
|
||||
|
||||
* Makefile.am: Add rules for generating .version and for including
|
||||
.tarball-version in dist tarballs.
|
||||
|
||||
2010-04-12 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/util.c: Fix the use of HAVE_UTIME_H.
|
||||
* src/pch.c (EDITOR_PROGRAM): Rename from ed_PROGRAM.
|
||||
* configure.ac (EDITOR_PROGRAM): Rename from ed_PROGRAM.
|
||||
|
||||
* configure.ac: Add automake and gnulib macros, replace several
|
||||
obsolete macros.
|
||||
* Makefile.am, lib/Makefile.am, src/Makefile.am, tests/Makefile.am:
|
||||
Add for automake.
|
||||
* autogen.sh, INSTALL, Makefile.in, mkinstalldirs, update-version.sh:
|
||||
Obsolete; remove.
|
||||
* README-hacking: Import from diffutils, replace cvs with git.
|
||||
* build-aux: Move gnulib auxiliary files here from the top-level
|
||||
directory.
|
||||
* gnulib: Add gnulib git submodule.
|
||||
* bootstrap, bootstrap.conf: Import from gnulib and adjust.
|
||||
* gl/lib: Remove gnulib files from the repository; they are now
|
||||
imported into lib/ from gnulib as needed.
|
||||
* tests/test-lib.sh: Use $abs_top_builddir exported from
|
||||
tests/Makefile.am here instead of $PWD.
|
||||
* m4/utimbuf.m4: This macro has been removed from gnulib. Add it here
|
||||
for now; this will be replaced by gnulib's utimens module soon.
|
||||
|
||||
* tests/test-lib.sh: Some versions of mktemp require a filename
|
||||
template; use one. Provide a seq replacement on platforms which don't
|
||||
have seq.
|
||||
|
||||
* configure.ac: Minimum versions required: automake-1.11.1,
|
||||
autoconf-2.65.
|
||||
|
||||
2010-02-21 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/merge.c: When a hunk has fewer suffix than prefix context lines,
|
||||
try matching to the end of the file instead of doing a "greedy match":
|
||||
this allows to detect already-applied inserts at the end of the file.
|
||||
* tests/merge: Add test cases for this.
|
||||
|
||||
2010-02-17 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* patch.man: Clarify the description of the -N option.
|
||||
|
||||
2010-01-15 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/bestmatch.h, src/diffseq.h, src/inp.c, src/maketime.c,
|
||||
src/merge.c, src/partime.c, src/pch.c, src/util.c: No longer use
|
||||
"continue" as the only instruction in a loop body: at least one
|
||||
compiler chokes on this in combination with variable-length arrays
|
||||
as in src/bestmatch.h.
|
||||
|
||||
* gl/lib/strndup.c: HAVE_DECL_STRNLEN is either 0 or 1 so we need
|
||||
to test for it with #if, not #ifdef.
|
||||
* gl/lib/xstrndup.c: Likewise for HAVE_DECL_STRNDUP.
|
||||
|
||||
2010-01-11 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/util.c (fetchname): Do not allow timestamps in Index lines.
|
||||
|
||||
2010-01-04 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/util.c (create_backup_copy): Try to preserve the owning group
|
||||
in backup files.
|
||||
|
||||
2010-01-03 Matthew Burgess <matthew@linuxfromscratch.org>
|
||||
|
||||
* tests/crlf-handling: Skip another ed-dependent test.
|
||||
|
||||
2010-01-02 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/bestmatch.h, src/common.h, src/diffseq.h, src/inp.c, src/inp.h,
|
||||
src/maketime.c, src/maketime.h, src/merge.c, src/partime.c,
|
||||
src/partime.h, src/patch.c, src/pch.c, src/pch.h, src/quotesys.c,
|
||||
src/util.c, src/util.h, src/version.c: Add year 2010 to copyright
|
||||
notice. Replace the GPLv2 license template with the GPLv3 license
|
||||
template.
|
||||
|
||||
* src/patch.c (main): Compare the input file's group ID with the
|
||||
effective group ID to determine if a chown() is necessary, not the
|
||||
effective user ID.
|
||||
|
||||
2010-01-01 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* Makefile.in (LIBSRCS, LIBM4FILES): Add the missing files strnlen.c,
|
||||
strnlen.m4, and safe-read.m4.
|
||||
|
||||
2009-12-30 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* patch.man: Clarify the description of the -F / --fuzz option.
|
||||
|
||||
* NEWS: Version 2.6.1 released.
|
||||
|
||||
* src/pch.c: coding style fix (syntactic).
|
||||
|
||||
2009-12-29 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* src/patch.c (longopts, get_some_switches): Add an optional argument
|
||||
@ -430,7 +1039,7 @@
|
||||
* tests/asymmetric-hunks: New test case.
|
||||
* Makefile.in (TESTS): Add test case.
|
||||
|
||||
* util.c (move_file): Create backup files of nonexisting files with
|
||||
* util.c (move_file): Create backup files of nonexistent files with
|
||||
the default mode instead of mode 0: files with mode 0 cause too many
|
||||
problems with applications which do not expect unreadable files.
|
||||
* tests/create-delete: Test for this.
|
||||
@ -1421,7 +2030,7 @@
|
||||
|
||||
* util.c (move_file): Don't assume that ENOENT is reported when both
|
||||
ENOENT and EXDEV apply; this isn't true with DJGPP, and
|
||||
Posix doesn't require it.
|
||||
POSIX doesn't require it.
|
||||
|
||||
* pch.c (there_is_another_patch):
|
||||
Suggest -p when we can't intuit a file.
|
||||
@ -1576,7 +2185,7 @@
|
||||
verbosity.
|
||||
(fetchname): Change argument head_says_nonexistent to pstamp, and
|
||||
store header timestamp into *pstamp.
|
||||
If -T or -Z option is given, match time stamps more precisely.
|
||||
If -T or -Z option is given, match timestamps more precisely.
|
||||
(ask): Remove unnecessary close of ttyfd.
|
||||
When there is no terminal at all, output a newline to make the
|
||||
output look nicer. After reporting EOF, flush stdout;
|
||||
@ -3049,24 +3658,20 @@ Sun Dec 17 17:29:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
|
||||
* patch.c: Initial revision
|
||||
|
||||
|
||||
Copyright (C) 1984, 1985, 1986, 1987, 1988 Larry Wall.
|
||||
|
||||
Copyright (C) 1989, 1990, 1991, 1992, 1993, 1997, 1998, 1999, 2000, 2001,
|
||||
2002, 2009 Free Software Foundation, Inc.
|
||||
Copyright 1989-2025 Free Software Foundation, Inc.
|
||||
Copyright 1984-1988 Larry Wall.
|
||||
|
||||
This file is part of GNU Patch.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
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 they will be useful,
|
||||
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; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
228
INSTALL
228
INSTALL
@ -1,228 +0,0 @@
|
||||
Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for variables by setting
|
||||
them in the environment. You can do that on the command line like this:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
55
Makefile.am
Normal file
55
Makefile.am
Normal file
@ -0,0 +1,55 @@
|
||||
# Copyright 1989-2025 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = lib src tests
|
||||
dist_man1_MANS = patch.man
|
||||
EXTRA_DIST = \
|
||||
ChangeLog-2011 \
|
||||
cfg.mk \
|
||||
m4/gnulib-cache.m4 \
|
||||
m4/mkdir.m4 \
|
||||
m4/setmode.m4 \
|
||||
bootstrap \
|
||||
pc
|
||||
|
||||
if ALPHA_VERSION
|
||||
EXTRA_DIST += README-alpha
|
||||
GNU_SERVER = alpha.gnu.org
|
||||
RELEASE_TYPE = alpha
|
||||
else
|
||||
GNU_SERVER = ftp.gnu.org
|
||||
RELEASE_TYPE = stable
|
||||
endif
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/.version
|
||||
BUILT_SOURCES = $(top_srcdir)/.version
|
||||
$(top_srcdir)/.version:
|
||||
echo $(VERSION) > $@-t && mv $@-t $@
|
||||
dist-hook: gen-ChangeLog
|
||||
echo $(VERSION) > $(distdir)/.tarball-version
|
||||
|
||||
gen_start_date = 2011-02-22
|
||||
.PHONY: gen-ChangeLog
|
||||
gen-ChangeLog:
|
||||
$(AM_V_GEN)if test -d .git; then \
|
||||
$(top_srcdir)/build-aux/gitlog-to-changelog \
|
||||
--since=$(gen_start_date) > $(distdir)/cl-t; \
|
||||
rm -f $(distdir)/ChangeLog; \
|
||||
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
|
||||
fi
|
||||
406
Makefile.in
406
Makefile.in
@ -1,406 +0,0 @@
|
||||
# Makefile for GNU patch.
|
||||
|
||||
# Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003, 2009
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
CC = @CC@
|
||||
ed_PROGRAM = @ed_PROGRAM@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
TEST_SHELL = @TEST_SHELL@
|
||||
transform = @program_transform_name@
|
||||
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
DEFS = @DEFS@
|
||||
EXEEXT = @EXEEXT@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJDIR = gl/lib/
|
||||
LIBOBJS = @LIBOBJS@ ${LIBOBJDIR}full-write$U.o
|
||||
LIBS = @LIBS@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
STDBOOL_H = @STDBOOL_H@
|
||||
GETOPT_H = @GETOPT_H@
|
||||
HAVE__BOOL = @HAVE__BOOL@
|
||||
ENABLE_MERGE = @ENABLE_MERGE@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
|
||||
# Where to put the manual pages.
|
||||
datarootdir = @datarootdir@
|
||||
mandir = @mandir@
|
||||
man1dir = $(mandir)/man1
|
||||
# Extension (including `.') for the manual page filenames.
|
||||
man1ext = .1
|
||||
|
||||
# Hook for nonstandard builds.
|
||||
CONFIG_STATUS = config.status
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
LIBSRCS = \
|
||||
gl/lib/argmatch.c \
|
||||
gl/lib/backupfile.c \
|
||||
gl/lib/basename.c \
|
||||
gl/lib/dirname.c \
|
||||
gl/lib/error.c \
|
||||
gl/lib/exitfail.c \
|
||||
gl/lib/full-write.c \
|
||||
gl/lib/getopt1.c \
|
||||
gl/lib/getopt.c \
|
||||
gl/lib/hash.c \
|
||||
gl/lib/malloc.c \
|
||||
gl/lib/mbrtowc.c \
|
||||
gl/lib/memchr.c \
|
||||
gl/lib/quotearg.c \
|
||||
gl/lib/quote.c \
|
||||
gl/lib/realloc.c \
|
||||
gl/lib/rename.c \
|
||||
gl/lib/safe-read.c \
|
||||
gl/lib/safe-write.c \
|
||||
gl/lib/strcasecmp.c \
|
||||
gl/lib/stripslash.c \
|
||||
gl/lib/strncasecmp.c \
|
||||
gl/lib/strndup.c \
|
||||
gl/lib/xmalloc.c \
|
||||
gl/lib/xstrndup.c
|
||||
|
||||
SRCS = $(LIBSRCS) \
|
||||
src/inp.c \
|
||||
src/maketime.c \
|
||||
src/merge.c \
|
||||
src/partime.c \
|
||||
src/patch.c \
|
||||
src/pch.c \
|
||||
src/quotesys.c \
|
||||
src/util.c \
|
||||
src/version.c
|
||||
|
||||
ifeq ($(ENABLE_MERGE),1)
|
||||
MERGEOBJ = src/merge.$(OBJEXT)
|
||||
endif
|
||||
|
||||
OBJS = $(LIBOBJS) $(MERGEOBJ) \
|
||||
src/inp.$(OBJEXT) \
|
||||
src/maketime.$(OBJEXT) \
|
||||
src/partime.$(OBJEXT) \
|
||||
src/patch.$(OBJEXT) \
|
||||
src/pch.$(OBJEXT) \
|
||||
src/quotesys.$(OBJEXT) \
|
||||
src/util.$(OBJEXT) \
|
||||
src/version.$(OBJEXT)
|
||||
|
||||
LIBHDRS = \
|
||||
gl/lib/argmatch.h \
|
||||
gl/lib/backupfile.h \
|
||||
gl/lib/dirname.h \
|
||||
gl/lib/error.h \
|
||||
gl/lib/exitfail.h \
|
||||
gl/lib/full-write.h \
|
||||
gl/lib/getopt.hin \
|
||||
gl/lib/getopt_int.h \
|
||||
gl/lib/gettext.h \
|
||||
gl/lib/hash.h \
|
||||
gl/lib/minmax.h \
|
||||
gl/lib/quotearg.h \
|
||||
gl/lib/quote.h \
|
||||
gl/lib/safe-write.h \
|
||||
gl/lib/stdbool.hin \
|
||||
gl/lib/unlocked-io.h \
|
||||
gl/lib/verify.h \
|
||||
gl/lib/xalloc.h \
|
||||
gl/lib/xstrndup.h
|
||||
|
||||
HDRS = $(LIBHDRS) \
|
||||
src/bestmatch.h \
|
||||
src/common.h \
|
||||
src/diffseq.h \
|
||||
src/inp.h \
|
||||
src/maketime.h \
|
||||
src/partime.h \
|
||||
src/pch.h \
|
||||
src/quotesys.h \
|
||||
src/util.h \
|
||||
src/version.h
|
||||
|
||||
MISC = \
|
||||
AUTHORS \
|
||||
COPYING \
|
||||
ChangeLog \
|
||||
INSTALL \
|
||||
Makefile.in \
|
||||
NEWS \
|
||||
README \
|
||||
VERSION \
|
||||
aclocal.m4 \
|
||||
config.guess\
|
||||
config.hin \
|
||||
config.sub \
|
||||
configure \
|
||||
configure.ac \
|
||||
install-sh \
|
||||
mkinstalldirs \
|
||||
patch.man \
|
||||
tests/test-lib.sh \
|
||||
update-version.sh
|
||||
|
||||
DISTFILES = $(MISC) $(SRCS) $(HDRS) $(M4FILES) \
|
||||
pc/chdirsaf.c \
|
||||
pc/djgpp/config.sed \
|
||||
pc/djgpp/configure.bat \
|
||||
pc/djgpp/configure.sed \
|
||||
pc/djgpp/README
|
||||
|
||||
MORE_DISTFILES = $(TESTS) $(BROKEN_TESTS)
|
||||
|
||||
patch_name = `echo patch | sed '$(transform)'`
|
||||
|
||||
all:: src/patch$(EXEEXT)
|
||||
|
||||
info::
|
||||
installcheck::
|
||||
|
||||
TESTS = \
|
||||
tests/asymmetric-hunks \
|
||||
tests/backup-prefix-suffix \
|
||||
tests/corrupt-reject-files \
|
||||
tests/create-delete \
|
||||
tests/crlf-handling \
|
||||
tests/filename-choice \
|
||||
tests/global-reject-files \
|
||||
tests/inname \
|
||||
tests/line-numbers \
|
||||
tests/merge \
|
||||
tests/munged-context-format \
|
||||
tests/need-filename \
|
||||
tests/no-newline-triggers-assert \
|
||||
tests/preserve-c-function-names \
|
||||
tests/preserve-mode-and-timestamp \
|
||||
tests/reject-format \
|
||||
tests/remember-backup-files \
|
||||
tests/remember-reject-files \
|
||||
tests/unmodified-files
|
||||
|
||||
BROKEN_TESTS = \
|
||||
tests/dash-o-append
|
||||
|
||||
check:: $(TESTS)
|
||||
@echo All tests succeeded!
|
||||
|
||||
.PHONY: $(TESTS) $(BROKEN_TESTS)
|
||||
$(TESTS) $(BROKEN_TESTS): all
|
||||
@echo "[$@]"
|
||||
@srcdir=$(srcdir)/tests $(TEST_SHELL) $(srcdir)/$@
|
||||
|
||||
ifeq ($(ENABLE_MERGE),1)
|
||||
DEFINE_ENABLE_MERGE = -DENABLE_MERGE
|
||||
endif
|
||||
COMPILE = $(CC) -c $(CPPFLAGS) $(DEFS) -Ded_PROGRAM=\"$(ed_PROGRAM)\" \
|
||||
$(DEFINE_ENABLE_MERGE) -I. -I$(srcdir)/src -I$(srcdir)/gl/lib $(CFLAGS)
|
||||
|
||||
.c.$(OBJEXT):
|
||||
@mkdir -p $(@D)
|
||||
$(COMPILE) -o $@ $<
|
||||
|
||||
src/patch$(EXEEXT): $(OBJS)
|
||||
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
|
||||
install:: all
|
||||
$(SHELL) $(srcdir)/mkinstalldirs $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
|
||||
$(INSTALL_PROGRAM) src/patch$(EXEEXT) $(DESTDIR)$(bindir)/$(patch_name)$(EXEEXT)
|
||||
$(INSTALL_DATA) $(srcdir)/patch.man $(DESTDIR)$(man1dir)/$(patch_name)$(man1ext)
|
||||
|
||||
install-strip::
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
||||
|
||||
uninstall::
|
||||
rm -f $(DESTDIR)$(bindir)/$(patch_name)$(EXEEXT) \
|
||||
$(DESTDIR)$(man1dir)/$(patch_name)$(man1ext)
|
||||
|
||||
Makefile: Makefile.in $(CONFIG_STATUS)
|
||||
$(SHELL) $(CONFIG_STATUS)
|
||||
FORCE:
|
||||
VERSION: FORCE
|
||||
@cd $(srcdir) && $(SHELL) ./update-version.sh VERSION
|
||||
config.status: configure
|
||||
$(SHELL) $(CONFIG_STATUS) --recheck
|
||||
configure: configure.ac $(srcdir)/aclocal.m4 $(srcdir)/VERSION
|
||||
cd $(srcdir) && autoconf --force
|
||||
config.hin: configure.ac $(srcdir)/aclocal.m4
|
||||
cd $(srcdir) && autoheader --force
|
||||
|
||||
# We need the following in order to create <getopt.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
getopt.h: gl/lib/getopt.hin
|
||||
rm -f $@-t $@
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
cat $(srcdir)/gl/lib/getopt.hin; \
|
||||
} > $@-t
|
||||
mv -f $@-t $@
|
||||
|
||||
# We need the following in order to create <stdbool.h> when the system
|
||||
# doesn't have one that works.
|
||||
#gl/lib/stdbool.h: gl/lib/stdbool.hin
|
||||
stdbool.h: gl/lib/stdbool.hin
|
||||
rm -f $@-t $@
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' \
|
||||
< $(srcdir)/gl/lib/stdbool.hin; \
|
||||
} > $@-t
|
||||
mv $@-t $@
|
||||
|
||||
LIBM4FILES = \
|
||||
gl/m4/argmatch.m4 \
|
||||
gl/m4/backupfile.m4 \
|
||||
gl/m4/d-ino.m4 \
|
||||
gl/m4/dirname.m4 \
|
||||
gl/m4/dos.m4 \
|
||||
gl/m4/double-slash-root.m4 \
|
||||
gl/m4/error.m4 \
|
||||
gl/m4/exitfail.m4 \
|
||||
gl/m4/extensions.m4 \
|
||||
gl/m4/getopt.m4 \
|
||||
gl/m4/gettext.m4 \
|
||||
gl/m4/hash.m4 \
|
||||
gl/m4/inline.m4 \
|
||||
gl/m4/malloc.m4 \
|
||||
gl/m4/mbrtowc.m4 \
|
||||
gl/m4/mbstate_t.m4 \
|
||||
gl/m4/memchr.m4 \
|
||||
gl/m4/minmax.m4 \
|
||||
gl/m4/onceonly.m4 \
|
||||
gl/m4/quotearg.m4 \
|
||||
gl/m4/quote.m4 \
|
||||
gl/m4/realloc.m4 \
|
||||
gl/m4/rename.m4 \
|
||||
gl/m4/safe-write.m4 \
|
||||
gl/m4/ssize_t.m4 \
|
||||
gl/m4/stdbool.m4 \
|
||||
gl/m4/strcase.m4 \
|
||||
gl/m4/strndup.m4 \
|
||||
gl/m4/unlocked-io.m4 \
|
||||
gl/m4/utimbuf.m4 \
|
||||
gl/m4/xalloc.m4 \
|
||||
gl/m4/xstrndup.m4
|
||||
|
||||
M4FILES = $(LIBM4FILES) \
|
||||
m4/mkdir.m4 \
|
||||
m4/setmode.m4
|
||||
|
||||
$(srcdir)/aclocal.m4: $(M4FILES)
|
||||
aclocal -I m4 -I gl/m4
|
||||
|
||||
TAGS: $(HDRS) $(SRCS)
|
||||
etags $(HDRS) $(SRCS)
|
||||
|
||||
mostlyclean::
|
||||
rm -f core* *core src/*.$(OBJEXT) gl/lib/*.$(OBJEXT) \
|
||||
stdbool.h getopt.h gl/lib/*.h-t
|
||||
|
||||
clean:: mostlyclean
|
||||
rm -f src/patch$(EXEEXT)
|
||||
|
||||
distclean:: clean
|
||||
rm -f Makefile config.cache config.hin~ config.log config.status \
|
||||
config.h
|
||||
rm -rf autom4te.cache/
|
||||
|
||||
maintainer-clean::
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "rebuilding the deleted files requires special tools."
|
||||
$(MAKE) distclean
|
||||
rm -f TAGS VERSION aclocal.m4 config.hin configure \
|
||||
patch-*.tar.gz patch-*.tar.gz.sig
|
||||
|
||||
PV = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
|
||||
|
||||
dist:: $(DISTFILES)
|
||||
@rm -rf $(PV)
|
||||
@ln -s . $(PV)
|
||||
@tar -cf - `( printf "%s\n" $(DISTFILES) $(MORE_DISTFILES); \
|
||||
grep -q -E -- '-[0-9]+-[0-9a-z]+(-dirty)?$$' VERSION \
|
||||
&& echo README-alpha \
|
||||
) | sed -e 's,^$(srcdir)/,,' -e "s,^,$(PV)/," \
|
||||
| LC_ALL=C sort` \
|
||||
| gzip -9 > $(PV).tar.gz
|
||||
@if which bzip2 >/dev/null 2>/dev/null; then \
|
||||
gzip -d < $(PV).tar.gz | bzip2 -9 > $(PV).tar.bz2; fi
|
||||
@if which xz >/dev/null 2>/dev/null; then \
|
||||
gzip -d < $(PV).tar.gz | xz -9 > $(PV).tar.xz; fi
|
||||
@rm -rf $(PV)
|
||||
@whereto=$$(if grep -q -E -- '-[0-9]+-[0-9a-z]+(-dirty)?$$' VERSION; \
|
||||
then echo alpha; else echo ftp; fi); \
|
||||
echo; \
|
||||
echo "# gnupload --to $$whereto.gnu.org:patch $(PV).tar.gz"; \
|
||||
test ! -e $(PV).tar.bz2 || echo "# gnupload" \
|
||||
"--to $$whereto.gnu.org:patch $(PV).tar.bz2"; \
|
||||
test ! -e $(PV).tar.xz || echo "# gnupload" \
|
||||
"--to $$whereto.gnu.org:patch $(PV).tar.xz"; \
|
||||
echo
|
||||
|
||||
$(OBJS): config.h
|
||||
COMMON = src/common.h $(STDBOOL_H)
|
||||
|
||||
gl/lib/addext.$(OBJEXT): gl/lib/backupfile.h gl/lib/dirname.h
|
||||
gl/lib/argmatch.$(OBJEXT): $(STDBOOL_H) gl/lib/argmatch.h gl/lib/gettext.h \
|
||||
gl/lib/error.h gl/lib/quote.h gl/lib/quotearg.h gl/lib/unlocked-io.h
|
||||
gl/lib/backupfile.$(OBJEXT): gl/lib/argmatch.h gl/lib/backupfile.h \
|
||||
gl/lib/dirname.h
|
||||
gl/lib/basename.$(OBJEXT): gl/lib/dirname.h
|
||||
gl/lib/dirname.$(OBJEXT): gl/lib/dirname.h gl/lib/xalloc.h
|
||||
gl/lib/error.$(OBJEXT): gl/lib/error.h gl/lib/gettext.h gl/lib/unlocked-io.h
|
||||
gl/lib/exitfail.$(OBJEXT): gl/lib/exitfail.h
|
||||
gl/lib/full-write.$(OBJEXT): gl/lib/full-write.h gl/lib/safe-write.h
|
||||
gl/lib/getopt.$(OBJEXT) gl/lib/getopt1.$(OBJEXT): getopt.h
|
||||
gl/lib/hash.$(OBJEXT): $(STDBOOL_H) gl/lib/hash.h
|
||||
gl/lib/safe-read.$(OBJEXT): gl/lib/safe-write.h
|
||||
gl/lib/safe-write.$(OBJEXT): gl/lib/safe-read.c
|
||||
|
||||
src/inp.$(OBJEXT): gl/lib/backupfile.h $(COMMON) src/inp.h src/pch.h \
|
||||
gl/lib/quotearg.h src/util.h gl/lib/xalloc.h
|
||||
src/maketime.$(OBJEXT): src/maketime.h src/partime.h
|
||||
src/partime.$(OBJEXT): src/partime.h
|
||||
src/patch.$(OBJEXT): gl/lib/argmatch.h gl/lib/backupfile.h $(COMMON) \
|
||||
gl/lib/exitfail.h $(GETOPT_H) src/inp.h src/pch.h \
|
||||
gl/lib/quotearg.h src/util.h src/version.h gl/lib/xalloc.h
|
||||
src/pch.$(OBJEXT): gl/lib/backupfile.h $(COMMON) gl/lib/dirname.h src/inp.h \
|
||||
src/pch.h gl/lib/quotearg.h src/util.h
|
||||
gl/lib/quote.$(OBJECT): gl/lib/quote.h gl/lib/quotearg.h
|
||||
gl/lib/quotearg.$(OBJEXT): gl/lib/gettext.h gl/lib/quotearg.h gl/lib/xalloc.h
|
||||
src/quotesys.$(OBJEXT): src/quotesys.h
|
||||
gl/lib/strncasecmp.$(OBJEXT): gl/lib/strcasecmp.c
|
||||
src/util.$(OBJEXT): gl/lib/backupfile.h $(COMMON) gl/lib/dirname.h gl/lib/full-write.h \
|
||||
gl/lib/hash.h src/maketime.h src/partime.h gl/lib/quotearg.h \
|
||||
src/quotesys.h src/util.h src/version.h gl/lib/xalloc.h
|
||||
src/version.$(OBJEXT): $(COMMON) src/version.h
|
||||
gl/lib/xmalloc.$(OBJEXT): gl/lib/error.h gl/lib/exitfail.h gl/lib/gettext.h \
|
||||
gl/lib/xalloc.h
|
||||
108
NEWS
108
NEWS
@ -1,3 +1,91 @@
|
||||
Unreleased changes:
|
||||
|
||||
Changes in version 2.8:
|
||||
|
||||
* The --follow-symlinks option now applies to output files as well as input.
|
||||
* 'patch' now supports file timestamps after 2038 even on traditional
|
||||
GNU/Linux platforms where time_t defaults to 32 bits.
|
||||
* 'patch' no longer creates files with names containing newlines,
|
||||
as encouraged by POSIX.1-2024.
|
||||
* Patches can no longer contain NUL ('\0') bytes in diff directive lines.
|
||||
These bytes would otherwise cause unpredictable behavior.
|
||||
* Patches can now contain sequences of spaces and tabs around line numbers
|
||||
and in other places where POSIX requires support for these sequences.
|
||||
* --enable-gcc-warnings no longer uses expensive static checking.
|
||||
Use --enable-gcc-warnings=expensive if you still want it.
|
||||
* Fix undefined or ill-defined behavior in unusual cases, such as very
|
||||
large sizes, possible stack overflow, I/O errors, memory exhaustion,
|
||||
races with other processes, and signals arriving at inopportune moments.
|
||||
* Remove old "Plan B" code, designed for machines with 16-bit pointers.
|
||||
* Assume C99 or later; previously it assumed C89 or later.
|
||||
* Port to current GCC, Autoconf, Gnulib, etc.
|
||||
|
||||
Changes in version 2.7.6:
|
||||
|
||||
* Files specified on the command line are no longer verified to be inside the
|
||||
current working directory, so commands like "patch -i foo.diff ../foo" will
|
||||
work again.
|
||||
* Various fixes.
|
||||
|
||||
Changes in version 2.7.5:
|
||||
|
||||
* There are users which expect patch to follow symbolic links in the working
|
||||
directory, so patch now again follows symbolic links as long as they do not
|
||||
leave the working directory.
|
||||
|
||||
Changes until version 2.7.4:
|
||||
|
||||
* When a file isn't being deleted because the file contents don't match the
|
||||
patch, the resulting message is now "Not deleting file ... as content
|
||||
differs from patch" instead of "File ... is not empty after patch; not
|
||||
deleting".
|
||||
* Function names in hunks (from diff -p) are now preserved in reject files.
|
||||
* Patch no longer follows symbolic links to input and output files. This
|
||||
ensures that symbolic links created by git-style patches cannot cause
|
||||
patch to write outside the working directory (CVE-2015-1196).
|
||||
* Various fixes.
|
||||
|
||||
Changes in version 2.7.1:
|
||||
|
||||
* Two critical bug fixes in the "diff --git" format support.
|
||||
* Clarify the message printed when a patch is expected to empty out and delete
|
||||
a file, but the file does not become empty.
|
||||
* Various improvements to messages when applying a patch to a file of different
|
||||
type (regular file vs. symlink), when there are line ending differences (LF
|
||||
vs. CRLF), and when in --dry-run mode.
|
||||
* When in the root directory, allow file names that are absolute or that
|
||||
contain a component of "..".
|
||||
* New --follow-symlinks option to allow to treat symlinks as files: this was
|
||||
patch's behavior before version 2.7.
|
||||
* Ignore when extended attributes cannot be preserved because they are
|
||||
unsupported or because permission to set them is denied.
|
||||
* License clarifications in NEWS and README.
|
||||
* Portability bug fixes.
|
||||
|
||||
Changes in version 2.7:
|
||||
|
||||
* Patch no longer gets a failed assertion for certain mangled patches.
|
||||
* Ignore destination file names that are absolute or that contain a component
|
||||
of "..". This addresses CVE-2010-4651.
|
||||
* Support for most features of the "diff --git" format, including renames and
|
||||
copies, permission changes, and symlink diffs. Binary diffs are not
|
||||
supported yet; patch will complain and skip them.
|
||||
* Support for double-quoted filenames: when a filename starts with a double
|
||||
quote, it is interpreted as a C string literal. The escape sequences \\, \",
|
||||
\a, \b, \f, \n, \r, \t, \v, and \ooo (a three-digit octal number between 0
|
||||
and 255) are recognized.
|
||||
* Refuse to apply a normal patch to a symlink. (Previous versions of patch
|
||||
were replacing the symlink with a regular file.)
|
||||
* When trying to modify a read-only file, warn about the potential problem
|
||||
by default. The --read-only command line option allows to change this
|
||||
behavior.
|
||||
* Files to be deleted are deleted once the entire input has been processed, not
|
||||
immediately. This fixes a bug with numbered backup files.
|
||||
* When a timestamp specifies a time zone, honor that instead of assuming the
|
||||
local time zone (--set-date) or Universal Coordinated Time (--set-utc).
|
||||
* Support for nanosecond precision timestamps.
|
||||
* Many portability and bug fixes.
|
||||
|
||||
Changes in version 2.6.1:
|
||||
|
||||
* Support for diff3(1) style merges which show the old, original, and new lines
|
||||
@ -43,7 +131,7 @@ Changes in version 2.6:
|
||||
line endings in patches. This allows to preserve CRs even in mangled
|
||||
patches, or in patches generated on non-POSIX systems and without the
|
||||
--binary option.
|
||||
* Backup files for nonexisting files are now created with default
|
||||
* Backup files for nonexistent files are now created with default
|
||||
permissions rather than with mode 0: backup files with mode 0 were
|
||||
causing problems with applications which do not expect unreadable
|
||||
files.
|
||||
@ -56,6 +144,7 @@ Changes in version 2.6:
|
||||
particularly with Perforce.)
|
||||
* Handle missing timestamps better.
|
||||
* Various bug fixes.
|
||||
* Switch to GNU General Public License version 3.
|
||||
|
||||
Changes in versions 2.5.8 and 2.5.9: bug fixes only.
|
||||
|
||||
@ -68,7 +157,7 @@ Changes in version 2.5.6:
|
||||
|
||||
* File names in context patches may now contain spaces, so long
|
||||
as the context patch headers use a tab to separate the file name
|
||||
from the time stamp.
|
||||
from the timestamp.
|
||||
* Perforce is now supported.
|
||||
* Patch lines beginning with "#" are comments and are ignored.
|
||||
|
||||
@ -275,22 +364,19 @@ Changes in version 2.0.12g8:
|
||||
|
||||
|
||||
|
||||
Copyright (C) 1992, 1993, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2009
|
||||
Free Software Foundation, Inc.
|
||||
Copyright 1992-2025 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Patch.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
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 they will be useful,
|
||||
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; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
38
README
38
README
@ -1,4 +1,6 @@
|
||||
This version of `patch' has many changes made by the Free Software Foundation.
|
||||
This is GNU patch, which applies diff files to original files.
|
||||
|
||||
This version of patch has many changes made by the Free Software Foundation.
|
||||
They add support for:
|
||||
* handling arbitrary binary data and large files
|
||||
* the unified context diff format that GNU diff can produce
|
||||
@ -7,13 +9,20 @@ They add support for:
|
||||
* improved interaction with RCS and SCCS
|
||||
* the GNU conventions for option parsing and configuring and compilation.
|
||||
* better POSIX compliance
|
||||
They also fix some bugs. See the NEWS and ChangeLog files for details.
|
||||
They also fix some bugs.
|
||||
|
||||
If you obtained this file as part of a "git clone", then see the
|
||||
README-hacking file. If this file came to you as part of a tar archive,
|
||||
then see the file INSTALL for compilation and installation instructions.
|
||||
|
||||
See the file NEWS for a list of major changes in the current release.
|
||||
A more detailed description of all changes can be found in the file ChangeLog
|
||||
in tar archives, and with "git log" which shows the version control history.
|
||||
|
||||
Tutorial-style documentation for patch is included in the GNU
|
||||
Diffutils package; get GNU Diffutils 2.8 or later for up-to-date
|
||||
documentation for patch.
|
||||
|
||||
For GNU and Unix build and installation instructions, see the file INSTALL.
|
||||
Use `configure --disable-largefile' to disable large file support;
|
||||
this is reportedly necessary on Red Hat GNU/Linux 6.0 to avoid a C library bug.
|
||||
For MS-DOS using DJGPP tools, see the file pc/djgpp/README.
|
||||
@ -32,24 +41,25 @@ too busy working on other things, like Perl. He has graciously agreed
|
||||
to let GNU `patch' be distributed under the terms of the GNU General
|
||||
Public License.
|
||||
|
||||
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) 1984, 1985, 1986, 1987, 1988 Larry Wall
|
||||
|
||||
Copyright (C) 1989, 1990, 1991, 1992, 1993, 1997, 1999, 2002, 2009
|
||||
Free Software Foundation, Inc.
|
||||
Copyright 1989-2025 Free Software Foundation, Inc.
|
||||
Copyright 1984-1988 Larry Wall
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
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.
|
||||
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 file; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
117
README-hacking
Normal file
117
README-hacking
Normal file
@ -0,0 +1,117 @@
|
||||
Building from a Git repository -*- outline -*-
|
||||
|
||||
These notes intend to help people working on the checked-out sources.
|
||||
These requirements do not apply when building from a distribution tarball.
|
||||
If this package has a file HACKING, please also read that file for
|
||||
more detailed contribution guidelines.
|
||||
|
||||
* Requirements
|
||||
|
||||
We've opted to keep only the highest-level sources in the Git repository.
|
||||
This eases our maintenance burden (fewer merges etc.), but imposes more
|
||||
requirements on anyone wishing to build from the just-checked-out sources.
|
||||
(The requirements to build from a release are much less and are just
|
||||
the requirements of the standard './configure && make' procedure.)
|
||||
Specific development tools and versions will be checked for and listed by
|
||||
the bootstrap script. See README-prereq for specific notes on obtaining
|
||||
these prerequisite tools.
|
||||
|
||||
Valgrind <http://valgrind.org/> is also highly recommended, if
|
||||
Valgrind supports your architecture. See also README-valgrind
|
||||
(if present).
|
||||
|
||||
While building from a just-cloned source tree may require installing a
|
||||
few prerequisites, later, a plain 'git pull && make' typically suffices.
|
||||
|
||||
* First Git checkout
|
||||
|
||||
You can get a copy of the source repository like this:
|
||||
|
||||
$ git clone git://git.sv.gnu.org/<packagename>
|
||||
$ cd <packagename>
|
||||
|
||||
where '<packagename>' stands for 'coreutils' or whatever other package
|
||||
you are building.
|
||||
|
||||
To use the most-recent Gnulib (as opposed to the Gnulib version that
|
||||
the package last synchronized to), do this next:
|
||||
|
||||
$ git submodule foreach git pull origin master
|
||||
$ git commit -m 'build: update gnulib submodule to latest' gnulib
|
||||
|
||||
As an optional step, if you already have a copy of the Gnulib Git
|
||||
repository, then you can use it as a reference to reduce download
|
||||
time and file system space requirements:
|
||||
|
||||
$ export GNULIB_SRCDIR=/path/to/gnulib
|
||||
|
||||
The next step is to get and check other files needed to build,
|
||||
which are extracted from other source packages:
|
||||
|
||||
$ ./bootstrap
|
||||
|
||||
And there you are! Just
|
||||
|
||||
$ ./configure --quiet #[--disable-gcc-warnings] [*]
|
||||
$ make
|
||||
$ make check
|
||||
|
||||
At this point, there should be no difference between your local copy,
|
||||
and the Git master copy:
|
||||
|
||||
$ git diff
|
||||
|
||||
should output no difference.
|
||||
|
||||
Enjoy!
|
||||
|
||||
[*] By default GCC warnings are enabled when building from Git.
|
||||
If you get warnings with recent GCC and Glibc with default
|
||||
configure-time options, please report the warnings to the bug
|
||||
reporting address of this package instead of to bug-gnulib,
|
||||
even if the problem seems to originate in a Gnulib-provided file.
|
||||
If you get warnings with other configurations, you can run
|
||||
'./configure --disable-gcc-warnings' or 'make WERROR_CFLAGS='
|
||||
to build quietly or verbosely, respectively.
|
||||
-----
|
||||
|
||||
* Submitting patches
|
||||
|
||||
If you develop a fix or a new feature, please send it to the
|
||||
appropriate bug-reporting address as reported by the --help option of
|
||||
each program. One way to do this is to use vc-dwim
|
||||
<https://www.gnu.org/software/vc-dwim/>), as follows.
|
||||
|
||||
Run the command "vc-dwim --initialize" from the top-level directory
|
||||
of this package's git-cloned hierarchy.
|
||||
|
||||
Edit the (empty) ChangeLog file that this command creates, creating a
|
||||
properly-formatted entry according to the GNU coding standards
|
||||
<https://www.gnu.org/prep/standards/html_node/Change-Logs.html>.
|
||||
|
||||
Make your changes.
|
||||
|
||||
Run the command "vc-dwim" and make sure its output (the diff of all
|
||||
your changes) looks good.
|
||||
|
||||
Run "vc-dwim --commit".
|
||||
|
||||
Run the command "git format-patch --stdout -1", and email its output
|
||||
in, using the output's subject line.
|
||||
|
||||
-----
|
||||
|
||||
Copyright 2002-2025 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/>.
|
||||
36
README-prereq
Normal file
36
README-prereq
Normal file
@ -0,0 +1,36 @@
|
||||
This gives some notes on obtaining the tools required for development.
|
||||
These tools can be used by the 'bootstrap' and 'configure' scripts,
|
||||
as well as by 'make'. They include:
|
||||
|
||||
- Autoconf <https://www.gnu.org/software/autoconf/>
|
||||
- Automake <https://www.gnu.org/software/automake/>
|
||||
- Git <https://git-scm.com/>
|
||||
- Gzip <https://www.gnu.org/software/gzip/>
|
||||
- M4 <https://www.gnu.org/software/m4/>
|
||||
- Make <https://www.gnu.org/software/make/>
|
||||
- Tar <https://www.gnu.org/software/tar/>
|
||||
- Texinfo <https://www.gnu.org/software/texinfo/>
|
||||
- Wget <http://www.gnu.org/software/wget/>
|
||||
- XZ Utils <https://tukaani.org/xz/>
|
||||
|
||||
It is generally better to use official packages for your system.
|
||||
If a package is not officially available you can build it from source
|
||||
and install it into a directory that you can then use to build this
|
||||
package. If some packages are available but are too old, install the
|
||||
too-old versions first as they may be needed to build newer versions.
|
||||
|
||||
Here is an example of how to build a program from source. This
|
||||
example is for Autoconf; a similar approach should work for the other
|
||||
developer prerequisites. This example assumes Autoconf 2.it; 72
|
||||
should be OK to use a later version of Autoconf, if available.
|
||||
|
||||
prefix=$HOME/prefix # (or wherever else you choose)
|
||||
export PATH=$prefix/bin:$PATH
|
||||
wget https://ftp.gnu.org/pub/gnu/autoconf/autoconf-2.72.tar.gz
|
||||
gzip -d <autoconf-2.72.tar.gz | tar xf -
|
||||
cd autoconf-2.72
|
||||
./configure --prefix=$prefix
|
||||
make install
|
||||
|
||||
Once the prerequisites are installed, you can build this package as
|
||||
described in README-hacking.
|
||||
@ -1,6 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
aclocal -I m4 -I gl/m4 --force
|
||||
autoheader --force
|
||||
autoconf --force
|
||||
echo Run ./configure now ...
|
||||
104
bootstrap.conf
Normal file
104
bootstrap.conf
Normal file
@ -0,0 +1,104 @@
|
||||
# Bootstrap configuration. -*- sh -*-
|
||||
|
||||
# Copyright 2006-2025 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 modules used by this package.
|
||||
gnulib_modules="
|
||||
announce-gen
|
||||
argmatch
|
||||
assert-h
|
||||
attribute
|
||||
backupfile
|
||||
basename-lgpl
|
||||
bool
|
||||
c-ctype
|
||||
closeout
|
||||
diffseq
|
||||
dup2
|
||||
errno-h
|
||||
exitfail
|
||||
extensions
|
||||
faccessat
|
||||
fchownat
|
||||
fchmodat
|
||||
fcntl-h
|
||||
filename
|
||||
fseeko
|
||||
fstatat
|
||||
ftello
|
||||
futimens
|
||||
getopt-gnu
|
||||
gettime
|
||||
gitlog-to-changelog
|
||||
git-version-gen
|
||||
gnupload
|
||||
hash
|
||||
idx
|
||||
ignore-value
|
||||
intprops
|
||||
inttypes-h
|
||||
largefile
|
||||
maintainer-makefile
|
||||
malloc-gnu
|
||||
manywarnings
|
||||
memchr
|
||||
mempcpy
|
||||
minmax
|
||||
mkdirat
|
||||
nullptr
|
||||
openat
|
||||
parse-datetime
|
||||
progname
|
||||
quotearg
|
||||
raise
|
||||
readlinkat
|
||||
realloc-posix
|
||||
renameat
|
||||
setenv
|
||||
signal-h
|
||||
ssize_t
|
||||
stat-time
|
||||
stdckdint-h
|
||||
stdlib-h
|
||||
stpcpy
|
||||
symlinkat
|
||||
sys_stat-h
|
||||
tempname
|
||||
test-xfail
|
||||
unistd-h
|
||||
unlinkat
|
||||
update-copyright
|
||||
utimensat
|
||||
verror
|
||||
xalloc
|
||||
xstdopen
|
||||
year2038-recommended
|
||||
"
|
||||
|
||||
# Build prerequisites
|
||||
buildreq="\
|
||||
autoconf 2.59
|
||||
automake 1.9.6
|
||||
git 1.5.5
|
||||
tar -
|
||||
"
|
||||
|
||||
bootstrap_post_import_hook ()
|
||||
{
|
||||
# Automake requires that ChangeLog exist.
|
||||
touch ChangeLog || exit 1
|
||||
}
|
||||
45
cfg.mk
Normal file
45
cfg.mk
Normal file
@ -0,0 +1,45 @@
|
||||
# Customize maint.mk -*- makefile -*-
|
||||
# Copyright 2011-2025 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
config_h_header = <(common|config)\.h>
|
||||
|
||||
ifeq ($(RELEASE_TYPE),alpha)
|
||||
news-check-regexp = "Unreleased changes"
|
||||
else
|
||||
news-check-regexp = '^Changes in version $(VERSION_REGEXP):'
|
||||
endif
|
||||
|
||||
release-prep-hook =
|
||||
|
||||
update-copyright-env = \
|
||||
UPDATE_COPYRIGHT_FORCE=1 \
|
||||
UPDATE_COPYRIGHT_USE_INTERVALS=2 \
|
||||
UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
|
||||
|
||||
local-checks-to-skip = \
|
||||
sc_GPL_version \
|
||||
sc_bindtextdomain \
|
||||
sc_file_system \
|
||||
sc_immutable_NEWS \
|
||||
sc_obsolete_symbols \
|
||||
sc_prohibit_always_true_header_tests \
|
||||
sc_prohibit_magic_number_exit \
|
||||
sc_prohibit_strcmp \
|
||||
sc_prohibit_test_minus_ao \
|
||||
sc_require_test_exit_idiom
|
||||
|
||||
exclude_file_name_regexp--sc_prohibit_doubled_word = ^src/util\.c$$
|
||||
exclude_file_name_regexp--sc_unmarked_diagnostics = ^src/util\.c$$
|
||||
1555
config.guess
vendored
1555
config.guess
vendored
File diff suppressed because it is too large
Load Diff
1685
config.sub
vendored
1685
config.sub
vendored
File diff suppressed because it is too large
Load Diff
188
configure.ac
188
configure.ac
@ -1,12 +1,9 @@
|
||||
# Configure `patch'.
|
||||
# Copyright 1993-2025 Free Software Foundation, Inc.
|
||||
|
||||
# Copyright (C) 1993, 1997, 1998, 1999, 2002, 2003, 2006, 2009
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
# 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
|
||||
@ -14,88 +11,115 @@
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
define(AC_PACKAGE_VERSION, m4_normalize(esyscmd(
|
||||
[
|
||||
sh ./update-version.sh VERSION
|
||||
cat VERSION
|
||||
])))
|
||||
AC_INIT(patch, AC_PACKAGE_VERSION, bug-patch@gnu.org)
|
||||
AC_CONFIG_SRCDIR(src/patch.c)
|
||||
AC_CONFIG_HEADER(config.h:config.hin)
|
||||
AC_ARG_PROGRAM
|
||||
AC_PREREQ([2.65])
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
# Use ed_PROGRAM, not ED_PROGRAM,
|
||||
# because <errno.h> reserves symbols starting with `E'.
|
||||
AC_PATH_PROG(ed_PROGRAM, ed, ed)
|
||||
AC_INIT([GNU patch],
|
||||
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
||||
[bug-patch@gnu.org])
|
||||
|
||||
AC_PATH_PROG(TEST_SHELL, [bash sh])
|
||||
|
||||
gl_USE_SYSTEM_EXTENSIONS
|
||||
AC_PROG_CC_STDC
|
||||
AC_SYS_LARGEFILE
|
||||
AC_EXEEXT
|
||||
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h utime.h)
|
||||
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_OFF_T
|
||||
AM_STDBOOL_H
|
||||
gl_CHECK_TYPE_STRUCT_UTIMBUF
|
||||
|
||||
gl_ARGMATCH
|
||||
gl_BACKUPFILE
|
||||
gl_DIRNAME
|
||||
gl_ERROR
|
||||
gl_EXITFAIL
|
||||
gl_FUNC_MEMCHR
|
||||
gl_FUNC_STRNDUP
|
||||
gl_FUNC_STRNLEN
|
||||
gl_GETOPT
|
||||
gl_HASH
|
||||
gl_PREREQ_XMALLOC
|
||||
gl_QUOTE
|
||||
gl_QUOTEARG
|
||||
gl_SAFE_WRITE
|
||||
gl_STRCASE
|
||||
gl_XALLOC
|
||||
gl_XSTRNDUP
|
||||
|
||||
dnl lib/basename.c requires xstrndup.
|
||||
AC_LIBOBJ([xstrndup])
|
||||
|
||||
dnl m4/error.m4 does not do this:
|
||||
AC_LIBOBJ([error])
|
||||
|
||||
AC_CHECK_DECLS([mktemp])
|
||||
AC_CHECK_FUNCS(geteuid getuid mktemp raise sigaction sigprocmask sigsetmask)
|
||||
AC_FUNC_FSEEKO
|
||||
gl_FUNC_GLIBC_UNLOCKED_IO
|
||||
gl_FUNC_MALLOC_POSIX
|
||||
gl_FUNC_REALLOC_POSIX
|
||||
AC_FUNC_CLOSEDIR_VOID
|
||||
AC_FUNC_SETMODE_DOS
|
||||
AC_FUNC_VPRINTF
|
||||
PATCH_FUNC_MKDIR_TAKES_ONE_ARG
|
||||
|
||||
gl_AC_DOS
|
||||
AC_SYS_LONG_FILE_NAMES
|
||||
AC_CONFIG_SRCDIR([src/patch.c])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AC_ARG_ENABLE([merge],
|
||||
[AS_HELP_STRING([--disable-merge],
|
||||
[disable support for merging])])
|
||||
if test "$enableval" != no ; then
|
||||
AC_SUBST(ENABLE_MERGE, 1)
|
||||
AM_CONDITIONAL([ENABLE_MERGE], [test "$enableval" != no])
|
||||
AM_CONDITIONAL([ALPHA_VERSION],
|
||||
[[echo "$PACKAGE_VERSION" | grep -- "-[0-9a-f][0-9a-f]*\\(-dirty\\)\\?$" >/dev/null]])
|
||||
|
||||
AM_INIT_AUTOMAKE([1.11.2 -Wall gnu dist-bzip2 dist-xz color-tests parallel-tests subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
|
||||
AC_CONFIG_HEADERS([config.h:config.hin])
|
||||
|
||||
AC_PROG_CC
|
||||
gl_EARLY
|
||||
gl_INIT
|
||||
AM_PROG_AR
|
||||
|
||||
AC_ARG_ENABLE([gcc-warnings],
|
||||
[AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
|
||||
[control generation of GCC warnings. The TYPE 'no' disables
|
||||
warnings (default for non-developer builds); 'yes' generates
|
||||
cheap warnings if available;
|
||||
'expensive' in addition generates expensive-to-compute warnings
|
||||
if available.])],
|
||||
[case $enableval in
|
||||
no|yes|expensive) ;;
|
||||
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
|
||||
esac
|
||||
gl_gcc_warnings=$enableval],
|
||||
[gl_gcc_warnings=no]
|
||||
)
|
||||
|
||||
if test $gl_gcc_warnings != no; then
|
||||
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
|
||||
AC_SUBST([WERROR_CFLAGS])
|
||||
|
||||
ew=
|
||||
AS_IF([test $gl_gcc_warnings != expensive],
|
||||
[# -fanalyzer and related options slow GCC considerably.
|
||||
ew="$ew -fanalyzer -Wno-analyzer-malloc-leak"])
|
||||
|
||||
# This, $nw, is the list of warnings we disable.
|
||||
nw=$ew
|
||||
nw="$nw -Winline" # It's OK for a compiler to not inline.
|
||||
|
||||
# Using -Wstrict-overflow is a pain, but the alternative is worse.
|
||||
# For an example, see the code that provoked this report:
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
|
||||
# Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
|
||||
|
||||
gl_MANYWARN_ALL_GCC([ws])
|
||||
gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
|
||||
for w in $ws; do
|
||||
gl_WARN_ADD([$w])
|
||||
done
|
||||
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
|
||||
|
||||
gl_WARN_ADD([-fdiagnostics-show-option])
|
||||
|
||||
AC_SUBST([WARN_CFLAGS])
|
||||
|
||||
AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
|
||||
AH_VERBATIM([FORTIFY_SOURCE],
|
||||
[/* Enable compile-time and run-time bounds-checking, and some warnings,
|
||||
without upsetting glibc 2.15+. */
|
||||
#if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
|
||||
# define _FORTIFY_SOURCE 2
|
||||
#endif
|
||||
])
|
||||
AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
|
||||
|
||||
# We also use a smaller set of warning options for lib/.
|
||||
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
|
||||
nw=$ew
|
||||
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
||||
AC_SUBST([GNULIB_WARN_CFLAGS])
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
# Ensure VLAs are not used.
|
||||
# Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
|
||||
AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
|
||||
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_OFF_T
|
||||
|
||||
gl_FUNC_XATTR
|
||||
|
||||
AC_CHECK_FUNCS_ONCE([geteuid getuid sigaction sigfillset])
|
||||
AC_FUNC_SETMODE_DOS
|
||||
|
||||
AC_PATH_PROG([ED], [ed], [ed])
|
||||
AC_DEFINE_UNQUOTED([EDITOR_PROGRAM], ["$ED"], [Name of editor program.])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
lib/Makefile
|
||||
src/Makefile
|
||||
tests/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
@ -1,277 +0,0 @@
|
||||
/* argmatch.c -- find a match for a string in an array
|
||||
|
||||
Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by David MacKenzie <djm@ai.mit.edu>
|
||||
Modified by Akim Demaille <demaille@inf.enst.fr> */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "argmatch.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
|
||||
#include "error.h"
|
||||
#include "quotearg.h"
|
||||
#include "quote.h"
|
||||
|
||||
#if USE_UNLOCKED_IO
|
||||
# include "unlocked-io.h"
|
||||
#endif
|
||||
|
||||
/* When reporting an invalid argument, show nonprinting characters
|
||||
by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
|
||||
literal_quoting_style. */
|
||||
#ifndef ARGMATCH_QUOTING_STYLE
|
||||
# define ARGMATCH_QUOTING_STYLE locale_quoting_style
|
||||
#endif
|
||||
|
||||
/* Non failing version of argmatch call this function after failing. */
|
||||
#ifndef ARGMATCH_DIE
|
||||
# include "exitfail.h"
|
||||
# define ARGMATCH_DIE exit (exit_failure)
|
||||
#endif
|
||||
|
||||
#ifdef ARGMATCH_DIE_DECL
|
||||
ARGMATCH_DIE_DECL;
|
||||
#endif
|
||||
|
||||
static void
|
||||
__argmatch_die (void)
|
||||
{
|
||||
ARGMATCH_DIE;
|
||||
}
|
||||
|
||||
/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h.
|
||||
Default to __argmatch_die, but allow caller to change this at run-time. */
|
||||
argmatch_exit_fn argmatch_die = __argmatch_die;
|
||||
|
||||
|
||||
/* If ARG is an unambiguous match for an element of the
|
||||
NULL-terminated array ARGLIST, return the index in ARGLIST
|
||||
of the matched element, else -1 if it does not match any element
|
||||
or -2 if it is ambiguous (is a prefix of more than one element).
|
||||
|
||||
If VALLIST is none null, use it to resolve ambiguities limited to
|
||||
synonyms, i.e., for
|
||||
"yes", "yop" -> 0
|
||||
"no", "nope" -> 1
|
||||
"y" is a valid argument, for `0', and "n" for `1'. */
|
||||
|
||||
ptrdiff_t
|
||||
argmatch (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
size_t i; /* Temporary index in ARGLIST. */
|
||||
size_t arglen; /* Length of ARG. */
|
||||
ptrdiff_t matchind = -1; /* Index of first nonexact match. */
|
||||
bool ambiguous = false; /* If true, multiple nonexact match(es). */
|
||||
|
||||
arglen = strlen (arg);
|
||||
|
||||
/* Test all elements for either exact match or abbreviated matches. */
|
||||
for (i = 0; arglist[i]; i++)
|
||||
{
|
||||
if (!strncmp (arglist[i], arg, arglen))
|
||||
{
|
||||
if (strlen (arglist[i]) == arglen)
|
||||
/* Exact match found. */
|
||||
return i;
|
||||
else if (matchind == -1)
|
||||
/* First nonexact match found. */
|
||||
matchind = i;
|
||||
else
|
||||
{
|
||||
/* Second nonexact match found. */
|
||||
if (vallist == NULL
|
||||
|| memcmp (vallist + valsize * matchind,
|
||||
vallist + valsize * i, valsize))
|
||||
{
|
||||
/* There is a real ambiguity, or we could not
|
||||
disambiguate. */
|
||||
ambiguous = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ambiguous)
|
||||
return -2;
|
||||
else
|
||||
return matchind;
|
||||
}
|
||||
|
||||
/* Error reporting for argmatch.
|
||||
CONTEXT is a description of the type of entity that was being matched.
|
||||
VALUE is the invalid value that was given.
|
||||
PROBLEM is the return value from argmatch. */
|
||||
|
||||
void
|
||||
argmatch_invalid (const char *context, const char *value, ptrdiff_t problem)
|
||||
{
|
||||
char const *format = (problem == -1
|
||||
? _("invalid argument %s for %s")
|
||||
: _("ambiguous argument %s for %s"));
|
||||
|
||||
error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value),
|
||||
quote_n (1, context));
|
||||
}
|
||||
|
||||
/* List the valid arguments for argmatch.
|
||||
ARGLIST is the same as in argmatch.
|
||||
VALLIST is a pointer to an array of values.
|
||||
VALSIZE is the size of the elements of VALLIST */
|
||||
void
|
||||
argmatch_valid (const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
size_t i;
|
||||
const char *last_val = NULL;
|
||||
|
||||
/* We try to put synonyms on the same line. The assumption is that
|
||||
synonyms follow each other */
|
||||
fprintf (stderr, _("Valid arguments are:"));
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if ((i == 0)
|
||||
|| memcmp (last_val, vallist + valsize * i, valsize))
|
||||
{
|
||||
fprintf (stderr, "\n - `%s'", arglist[i]);
|
||||
last_val = vallist + valsize * i;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, ", `%s'", arglist[i]);
|
||||
}
|
||||
putc ('\n', stderr);
|
||||
}
|
||||
|
||||
/* Never failing versions of the previous functions.
|
||||
|
||||
CONTEXT is the context for which argmatch is called (e.g.,
|
||||
"--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
|
||||
calls the (supposed never to return) function EXIT_FN. */
|
||||
|
||||
ptrdiff_t
|
||||
__xargmatch_internal (const char *context,
|
||||
const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
argmatch_exit_fn exit_fn)
|
||||
{
|
||||
ptrdiff_t res = argmatch (arg, arglist, vallist, valsize);
|
||||
if (res >= 0)
|
||||
/* Success. */
|
||||
return res;
|
||||
|
||||
/* We failed. Explain why. */
|
||||
argmatch_invalid (context, arg, res);
|
||||
argmatch_valid (arglist, vallist, valsize);
|
||||
(*exit_fn) ();
|
||||
|
||||
return -1; /* To please the compilers. */
|
||||
}
|
||||
|
||||
/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
|
||||
return the first corresponding argument in ARGLIST */
|
||||
const char *
|
||||
argmatch_to_argument (const char *value,
|
||||
const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if (!memcmp (value, vallist + valsize * i, valsize))
|
||||
return arglist[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
/*
|
||||
* Based on "getversion.c" by David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
*/
|
||||
char *program_name;
|
||||
|
||||
/* When to make backup files. */
|
||||
enum backup_type
|
||||
{
|
||||
/* Never make backups. */
|
||||
no_backups,
|
||||
|
||||
/* Make simple backups of every file. */
|
||||
simple_backups,
|
||||
|
||||
/* Make numbered backups of files that already have numbered backups,
|
||||
and simple backups of the others. */
|
||||
numbered_existing_backups,
|
||||
|
||||
/* Make numbered backups of every file. */
|
||||
numbered_backups
|
||||
};
|
||||
|
||||
/* Two tables describing arguments (keys) and their corresponding
|
||||
values */
|
||||
static const char *const backup_args[] =
|
||||
{
|
||||
"no", "none", "off",
|
||||
"simple", "never",
|
||||
"existing", "nil",
|
||||
"numbered", "t",
|
||||
0
|
||||
};
|
||||
|
||||
static const enum backup_type backup_vals[] =
|
||||
{
|
||||
no_backups, no_backups, no_backups,
|
||||
simple_backups, simple_backups,
|
||||
numbered_existing_backups, numbered_existing_backups,
|
||||
numbered_backups, numbered_backups
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, const char *const *argv)
|
||||
{
|
||||
const char *cp;
|
||||
enum backup_type backup_type = no_backups;
|
||||
|
||||
program_name = (char *) argv[0];
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if ((cp = getenv ("VERSION_CONTROL")))
|
||||
backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
|
||||
backup_args, backup_vals);
|
||||
|
||||
if (argc == 2)
|
||||
backup_type = XARGMATCH (program_name, argv[1],
|
||||
backup_args, backup_vals);
|
||||
|
||||
printf ("The version control is `%s'\n",
|
||||
ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -1,102 +0,0 @@
|
||||
/* argmatch.h -- definitions and prototypes for argmatch.c
|
||||
|
||||
Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004, 2005 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by David MacKenzie <djm@ai.mit.edu>
|
||||
Modified by Akim Demaille <demaille@inf.enst.fr> */
|
||||
|
||||
#ifndef ARGMATCH_H_
|
||||
# define ARGMATCH_H_ 1
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
# include "verify.h"
|
||||
|
||||
# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
|
||||
|
||||
/* Assert there are as many real arguments as there are values
|
||||
(argument list ends with a NULL guard). */
|
||||
|
||||
# define ARGMATCH_VERIFY(Arglist, Vallist) \
|
||||
verify (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1)
|
||||
|
||||
/* Return the index of the element of ARGLIST (NULL terminated) that
|
||||
matches with ARG. If VALLIST is not NULL, then use it to resolve
|
||||
false ambiguities (i.e., different matches of ARG but corresponding
|
||||
to the same values in VALLIST). */
|
||||
|
||||
ptrdiff_t argmatch (char const *arg, char const *const *arglist,
|
||||
char const *vallist, size_t valsize);
|
||||
|
||||
# define ARGMATCH(Arg, Arglist, Vallist) \
|
||||
argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist))
|
||||
|
||||
/* xargmatch calls this function when it fails. This function should not
|
||||
return. By default, this is a function that calls ARGMATCH_DIE which
|
||||
in turn defaults to `exit (exit_failure)'. */
|
||||
typedef void (*argmatch_exit_fn) (void);
|
||||
extern argmatch_exit_fn argmatch_die;
|
||||
|
||||
/* Report on stderr why argmatch failed. Report correct values. */
|
||||
|
||||
void argmatch_invalid (char const *context, char const *value,
|
||||
ptrdiff_t problem);
|
||||
|
||||
/* Left for compatibility with the old name invalid_arg */
|
||||
|
||||
# define invalid_arg(Context, Value, Problem) \
|
||||
argmatch_invalid (Context, Value, Problem)
|
||||
|
||||
|
||||
|
||||
/* Report on stderr the list of possible arguments. */
|
||||
|
||||
void argmatch_valid (char const *const *arglist,
|
||||
char const *vallist, size_t valsize);
|
||||
|
||||
# define ARGMATCH_VALID(Arglist, Vallist) \
|
||||
argmatch_valid (Arglist, (char const *) (Vallist), sizeof *(Vallist))
|
||||
|
||||
|
||||
|
||||
/* Same as argmatch, but upon failure, reports a explanation on the
|
||||
failure, and exits using the function EXIT_FN. */
|
||||
|
||||
ptrdiff_t __xargmatch_internal (char const *context,
|
||||
char const *arg, char const *const *arglist,
|
||||
char const *vallist, size_t valsize,
|
||||
argmatch_exit_fn exit_fn);
|
||||
|
||||
/* Programmer friendly interface to __xargmatch_internal. */
|
||||
|
||||
# define XARGMATCH(Context, Arg, Arglist, Vallist) \
|
||||
((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \
|
||||
(char const *) (Vallist), \
|
||||
sizeof *(Vallist), \
|
||||
argmatch_die)])
|
||||
|
||||
/* Convert a value into a corresponding argument. */
|
||||
|
||||
char const *argmatch_to_argument (char const *value,
|
||||
char const *const *arglist,
|
||||
char const *vallist, size_t valsize);
|
||||
|
||||
# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \
|
||||
argmatch_to_argument (Value, Arglist, \
|
||||
(char const *) (Vallist), sizeof *(Vallist))
|
||||
|
||||
#endif /* ARGMATCH_H_ */
|
||||
@ -1,362 +0,0 @@
|
||||
/* backupfile.c -- make Emacs style backup file names
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert and David MacKenzie.
|
||||
Some algorithms adapted from GNU Emacs. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "backupfile.h"
|
||||
|
||||
#include "argmatch.h"
|
||||
#include "dirname.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#ifndef _D_EXACT_NAMLEN
|
||||
# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name)
|
||||
#endif
|
||||
#if D_INO_IN_DIRENT
|
||||
# define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0)
|
||||
#else
|
||||
# define REAL_DIR_ENTRY(dp) 1
|
||||
#endif
|
||||
|
||||
#if ! (HAVE_PATHCONF && defined _PC_NAME_MAX)
|
||||
# define pathconf(file, option) (errno = -1)
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_NAME_MAX
|
||||
# define _POSIX_NAME_MAX 14
|
||||
#endif
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#if defined _XOPEN_NAME_MAX
|
||||
# define NAME_MAX_MINIMUM _XOPEN_NAME_MAX
|
||||
#else
|
||||
# define NAME_MAX_MINIMUM _POSIX_NAME_MAX
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DOS_FILE_NAMES
|
||||
# define HAVE_DOS_FILE_NAMES 0
|
||||
#endif
|
||||
#ifndef HAVE_LONG_FILE_NAMES
|
||||
# define HAVE_LONG_FILE_NAMES 0
|
||||
#endif
|
||||
|
||||
/* ISDIGIT differs from isdigit, as follows:
|
||||
- Its arg may be any int or unsigned int; it need not be an unsigned char
|
||||
or EOF.
|
||||
- It's typically faster.
|
||||
POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
|
||||
ISDIGIT unless it's important to use the locale's definition
|
||||
of `digit' even when the host does not conform to POSIX. */
|
||||
#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
|
||||
|
||||
/* The results of opendir() in this file are not used with dirfd and fchdir,
|
||||
therefore save some unnecessary work in fchdir.c. */
|
||||
#undef opendir
|
||||
#undef closedir
|
||||
|
||||
/* The extension added to file names to produce a simple (as opposed
|
||||
to numbered) backup file name. */
|
||||
char const *simple_backup_suffix = "~";
|
||||
|
||||
|
||||
/* If FILE (which was of length FILELEN before an extension was
|
||||
appended to it) is too long, replace the extension with the single
|
||||
char E. If the result is still too long, remove the char just
|
||||
before E. */
|
||||
|
||||
static void
|
||||
check_extension (char *file, size_t filelen, char e)
|
||||
{
|
||||
char *base = last_component (file);
|
||||
size_t baselen = base_len (base);
|
||||
size_t baselen_max = HAVE_LONG_FILE_NAMES ? 255 : NAME_MAX_MINIMUM;
|
||||
|
||||
if (HAVE_DOS_FILE_NAMES || NAME_MAX_MINIMUM < baselen)
|
||||
{
|
||||
/* The new base name is long enough to require a pathconf check. */
|
||||
long name_max;
|
||||
|
||||
/* Temporarily modify the buffer into its parent directory name,
|
||||
invoke pathconf on the directory, and then restore the buffer. */
|
||||
char tmp[sizeof "."];
|
||||
memcpy (tmp, base, sizeof ".");
|
||||
strcpy (base, ".");
|
||||
errno = 0;
|
||||
name_max = pathconf (file, _PC_NAME_MAX);
|
||||
if (0 <= name_max || errno == 0)
|
||||
{
|
||||
long size = baselen_max = name_max;
|
||||
if (name_max != size)
|
||||
baselen_max = SIZE_MAX;
|
||||
}
|
||||
memcpy (base, tmp, sizeof ".");
|
||||
}
|
||||
|
||||
if (HAVE_DOS_FILE_NAMES && baselen_max <= 12)
|
||||
{
|
||||
/* Live within DOS's 8.3 limit. */
|
||||
char *dot = strchr (base, '.');
|
||||
if (!dot)
|
||||
baselen_max = 8;
|
||||
else
|
||||
{
|
||||
char const *second_dot = strchr (dot + 1, '.');
|
||||
baselen_max = (second_dot
|
||||
? second_dot - base
|
||||
: dot + 1 - base + 3);
|
||||
}
|
||||
}
|
||||
|
||||
if (baselen_max < baselen)
|
||||
{
|
||||
baselen = file + filelen - base;
|
||||
if (baselen_max <= baselen)
|
||||
baselen = baselen_max - 1;
|
||||
base[baselen] = e;
|
||||
base[baselen + 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* Returned values for NUMBERED_BACKUP. */
|
||||
|
||||
enum numbered_backup_result
|
||||
{
|
||||
/* The new backup name is the same length as an existing backup
|
||||
name, so it's valid for that directory. */
|
||||
BACKUP_IS_SAME_LENGTH,
|
||||
|
||||
/* Some backup names already exist, but the returned name is longer
|
||||
than any of them, and its length should be checked. */
|
||||
BACKUP_IS_LONGER,
|
||||
|
||||
/* There are no existing backup names. The new name's length
|
||||
should be checked. */
|
||||
BACKUP_IS_NEW
|
||||
};
|
||||
|
||||
/* *BUFFER contains a file name. Store into *BUFFER the next backup
|
||||
name for the named file, with a version number greater than all the
|
||||
existing numbered backups. Reallocate *BUFFER as necessary; its
|
||||
initial allocated size is BUFFER_SIZE, which must be at least 4
|
||||
bytes longer than the file name to make room for the initially
|
||||
appended ".~1". FILELEN is the length of the original file name.
|
||||
The returned value indicates what kind of backup was found. If an
|
||||
I/O or other read error occurs, use the highest backup number that
|
||||
was found. */
|
||||
|
||||
static enum numbered_backup_result
|
||||
numbered_backup (char **buffer, size_t buffer_size, size_t filelen)
|
||||
{
|
||||
enum numbered_backup_result result = BACKUP_IS_NEW;
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char *buf = *buffer;
|
||||
size_t versionlenmax = 1;
|
||||
char *base = last_component (buf);
|
||||
size_t base_offset = base - buf;
|
||||
size_t baselen = base_len (base);
|
||||
|
||||
/* Temporarily modify the buffer into its parent directory name,
|
||||
open the directory, and then restore the buffer. */
|
||||
char tmp[sizeof "."];
|
||||
memcpy (tmp, base, sizeof ".");
|
||||
strcpy (base, ".");
|
||||
dirp = opendir (buf);
|
||||
memcpy (base, tmp, sizeof ".");
|
||||
strcpy (base + baselen, ".~1~");
|
||||
|
||||
if (!dirp)
|
||||
return result;
|
||||
|
||||
while ((dp = readdir (dirp)) != NULL)
|
||||
{
|
||||
char const *p;
|
||||
char *q;
|
||||
bool all_9s;
|
||||
size_t versionlen;
|
||||
size_t new_buflen;
|
||||
|
||||
if (! REAL_DIR_ENTRY (dp) || _D_EXACT_NAMLEN (dp) < baselen + 4)
|
||||
continue;
|
||||
|
||||
if (memcmp (buf + base_offset, dp->d_name, baselen + 2) != 0)
|
||||
continue;
|
||||
|
||||
p = dp->d_name + baselen + 2;
|
||||
|
||||
/* Check whether this file has a version number and if so,
|
||||
whether it is larger. Use string operations rather than
|
||||
integer arithmetic, to avoid problems with integer overflow. */
|
||||
|
||||
if (! ('1' <= *p && *p <= '9'))
|
||||
continue;
|
||||
all_9s = (*p == '9');
|
||||
for (versionlen = 1; ISDIGIT (p[versionlen]); versionlen++)
|
||||
all_9s &= (p[versionlen] == '9');
|
||||
|
||||
if (! (p[versionlen] == '~' && !p[versionlen + 1]
|
||||
&& (versionlenmax < versionlen
|
||||
|| (versionlenmax == versionlen
|
||||
&& memcmp (buf + filelen + 2, p, versionlen) <= 0))))
|
||||
continue;
|
||||
|
||||
/* This directory has the largest version number seen so far.
|
||||
Append this highest numbered extension to the file name,
|
||||
prepending '0' to the number if it is all 9s. */
|
||||
|
||||
versionlenmax = all_9s + versionlen;
|
||||
result = (all_9s ? BACKUP_IS_LONGER : BACKUP_IS_SAME_LENGTH);
|
||||
new_buflen = filelen + 2 + versionlenmax + 1;
|
||||
if (buffer_size <= new_buflen)
|
||||
{
|
||||
buf = xnrealloc (buf, 2, new_buflen);
|
||||
buffer_size = new_buflen * 2;
|
||||
}
|
||||
q = buf + filelen;
|
||||
*q++ = '.';
|
||||
*q++ = '~';
|
||||
*q = '0';
|
||||
q += all_9s;
|
||||
memcpy (q, p, versionlen + 2);
|
||||
|
||||
/* Add 1 to the version number. */
|
||||
|
||||
q += versionlen;
|
||||
while (*--q == '9')
|
||||
*q = '0';
|
||||
++*q;
|
||||
}
|
||||
|
||||
closedir (dirp);
|
||||
*buffer = buf;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Return the name of the new backup file for the existing file FILE,
|
||||
allocated with malloc. Report an error and fail if out of memory.
|
||||
Do not call this function if backup_type == no_backups. */
|
||||
|
||||
char *
|
||||
find_backup_file_name (char const *file, enum backup_type backup_type)
|
||||
{
|
||||
size_t filelen = strlen (file);
|
||||
char *s;
|
||||
size_t ssize;
|
||||
bool simple = true;
|
||||
|
||||
/* Allow room for simple or ".~N~" backups. The guess must be at
|
||||
least sizeof ".~1~", but otherwise will be adjusted as needed. */
|
||||
size_t simple_backup_suffix_size = strlen (simple_backup_suffix) + 1;
|
||||
size_t backup_suffix_size_guess = simple_backup_suffix_size;
|
||||
enum { GUESS = sizeof ".~12345~" };
|
||||
if (backup_suffix_size_guess < GUESS)
|
||||
backup_suffix_size_guess = GUESS;
|
||||
|
||||
ssize = filelen + backup_suffix_size_guess + 1;
|
||||
s = xmalloc (ssize);
|
||||
memcpy (s, file, filelen + 1);
|
||||
|
||||
if (backup_type != simple_backups)
|
||||
switch (numbered_backup (&s, ssize, filelen))
|
||||
{
|
||||
case BACKUP_IS_SAME_LENGTH:
|
||||
return s;
|
||||
|
||||
case BACKUP_IS_LONGER:
|
||||
simple = false;
|
||||
break;
|
||||
|
||||
case BACKUP_IS_NEW:
|
||||
simple = (backup_type == numbered_existing_backups);
|
||||
break;
|
||||
}
|
||||
|
||||
if (simple)
|
||||
memcpy (s + filelen, simple_backup_suffix, simple_backup_suffix_size);
|
||||
check_extension (s, filelen, '~');
|
||||
return s;
|
||||
}
|
||||
|
||||
static char const * const backup_args[] =
|
||||
{
|
||||
/* In a series of synonyms, present the most meaningful first, so
|
||||
that argmatch_valid be more readable. */
|
||||
"none", "off",
|
||||
"simple", "never",
|
||||
"existing", "nil",
|
||||
"numbered", "t",
|
||||
NULL
|
||||
};
|
||||
|
||||
static const enum backup_type backup_types[] =
|
||||
{
|
||||
no_backups, no_backups,
|
||||
simple_backups, simple_backups,
|
||||
numbered_existing_backups, numbered_existing_backups,
|
||||
numbered_backups, numbered_backups
|
||||
};
|
||||
|
||||
/* Ensure that these two vectors have the same number of elements,
|
||||
not counting the final NULL in the first one. */
|
||||
ARGMATCH_VERIFY (backup_args, backup_types);
|
||||
|
||||
/* Return the type of backup specified by VERSION.
|
||||
If VERSION is NULL or the empty string, return numbered_existing_backups.
|
||||
If VERSION is invalid or ambiguous, fail with a diagnostic appropriate
|
||||
for the specified CONTEXT. Unambiguous abbreviations are accepted. */
|
||||
|
||||
enum backup_type
|
||||
get_version (char const *context, char const *version)
|
||||
{
|
||||
if (version == 0 || *version == 0)
|
||||
return numbered_existing_backups;
|
||||
else
|
||||
return XARGMATCH (context, version, backup_args, backup_types);
|
||||
}
|
||||
|
||||
|
||||
/* Return the type of backup specified by VERSION.
|
||||
If VERSION is NULL, use the value of the envvar VERSION_CONTROL.
|
||||
If the specified string is invalid or ambiguous, fail with a diagnostic
|
||||
appropriate for the specified CONTEXT.
|
||||
Unambiguous abbreviations are accepted. */
|
||||
|
||||
enum backup_type
|
||||
xget_version (char const *context, char const *version)
|
||||
{
|
||||
if (version && *version)
|
||||
return get_version (context, version);
|
||||
else
|
||||
return get_version ("$VERSION_CONTROL", getenv ("VERSION_CONTROL"));
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
/* backupfile.h -- declarations for making Emacs style backup file names
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1997, 1998, 1999, 2003, 2004 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef BACKUPFILE_H_
|
||||
# define BACKUPFILE_H_
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
|
||||
/* When to make backup files. */
|
||||
enum backup_type
|
||||
{
|
||||
/* Never make backups. */
|
||||
no_backups,
|
||||
|
||||
/* Make simple backups of every file. */
|
||||
simple_backups,
|
||||
|
||||
/* Make numbered backups of files that already have numbered backups,
|
||||
and simple backups of the others. */
|
||||
numbered_existing_backups,
|
||||
|
||||
/* Make numbered backups of every file. */
|
||||
numbered_backups
|
||||
};
|
||||
|
||||
# define VALID_BACKUP_TYPE(Type) \
|
||||
((unsigned int) (Type) <= numbered_backups)
|
||||
|
||||
extern char const *simple_backup_suffix;
|
||||
|
||||
char *find_backup_file_name (char const *, enum backup_type);
|
||||
enum backup_type get_version (char const *context, char const *arg);
|
||||
enum backup_type xget_version (char const *context, char const *arg);
|
||||
void addext (char *, char const *, int);
|
||||
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* ! BACKUPFILE_H_ */
|
||||
@ -1,128 +0,0 @@
|
||||
/* basename.c -- return the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "xalloc.h"
|
||||
#include "xstrndup.h"
|
||||
|
||||
/* Return the address of the last file name component of NAME. If
|
||||
NAME has no relative file name components because it is a file
|
||||
system root, return the empty string. */
|
||||
|
||||
char *
|
||||
last_component (char const *name)
|
||||
{
|
||||
char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
|
||||
char const *p;
|
||||
bool saw_slash = false;
|
||||
|
||||
while (ISSLASH (*base))
|
||||
base++;
|
||||
|
||||
for (p = base; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
saw_slash = true;
|
||||
else if (saw_slash)
|
||||
{
|
||||
base = p;
|
||||
saw_slash = false;
|
||||
}
|
||||
}
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `basename' modifies its argument.
|
||||
|
||||
Return the last file name component of NAME, allocated with
|
||||
xmalloc. On systems with drive letters, a leading "./"
|
||||
distinguishes relative names that would otherwise look like a drive
|
||||
letter. Unlike POSIX basename(), NAME cannot be NULL,
|
||||
base_name("") returns "", and the first trailing slash is not
|
||||
stripped.
|
||||
|
||||
If lstat (NAME) would succeed, then { chdir (dir_name (NAME));
|
||||
lstat (base_name (NAME)); } will access the same file. Likewise,
|
||||
if the sequence { chdir (dir_name (NAME));
|
||||
rename (base_name (NAME), "foo"); } succeeds, you have renamed NAME
|
||||
to "foo" in the same directory NAME was in. */
|
||||
|
||||
char *
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = last_component (name);
|
||||
size_t length;
|
||||
|
||||
/* If there is no last component, then name is a file system root or the
|
||||
empty string. */
|
||||
if (! *base)
|
||||
return xstrndup (name, base_len (name));
|
||||
|
||||
/* Collapse a sequence of trailing slashes into one. */
|
||||
length = base_len (base);
|
||||
if (ISSLASH (base[length]))
|
||||
length++;
|
||||
|
||||
/* On systems with drive letters, `a/b:c' must return `./b:c' rather
|
||||
than `b:c' to avoid confusion with a drive letter. On systems
|
||||
with pure POSIX semantics, this is not an issue. */
|
||||
if (FILE_SYSTEM_PREFIX_LEN (base))
|
||||
{
|
||||
char *p = xmalloc (length + 3);
|
||||
p[0] = '.';
|
||||
p[1] = '/';
|
||||
memcpy (p + 2, base, length);
|
||||
p[length + 2] = '\0';
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Finally, copy the basename. */
|
||||
return xstrndup (base, length);
|
||||
}
|
||||
|
||||
/* Return the length of the basename NAME. Typically NAME is the
|
||||
value returned by base_name or last_component. Act like strlen
|
||||
(NAME), except omit all trailing slashes. */
|
||||
|
||||
size_t
|
||||
base_len (char const *name)
|
||||
{
|
||||
size_t len;
|
||||
size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
|
||||
|
||||
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
|
||||
continue;
|
||||
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1
|
||||
&& ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
|
||||
return 2;
|
||||
|
||||
if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
|
||||
&& len == prefix_len && ISSLASH (name[prefix_len]))
|
||||
return prefix_len + 1;
|
||||
|
||||
return len;
|
||||
}
|
||||
@ -1,84 +0,0 @@
|
||||
/* dirname.c -- return all but the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998, 2000, 2001, 2003, 2004, 2005, 2006 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "xalloc.h"
|
||||
|
||||
/* Return the length of the prefix of FILE that will be used by
|
||||
dir_name. If FILE is in the working directory, this returns zero
|
||||
even though `dir_name (FILE)' will return ".". Works properly even
|
||||
if there are trailing slashes (by effectively ignoring them). */
|
||||
|
||||
size_t
|
||||
dir_len (char const *file)
|
||||
{
|
||||
size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
|
||||
size_t length;
|
||||
|
||||
/* Advance prefix_length beyond important leading slashes. */
|
||||
prefix_length += (prefix_length != 0
|
||||
? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
&& ISSLASH (file[prefix_length]))
|
||||
: (ISSLASH (file[0])
|
||||
? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||
&& ISSLASH (file[1]) && ! ISSLASH (file[2])
|
||||
? 2 : 1))
|
||||
: 0));
|
||||
|
||||
/* Strip the basename and any redundant slashes before it. */
|
||||
for (length = last_component (file) - file;
|
||||
prefix_length < length; length--)
|
||||
if (! ISSLASH (file[length - 1]))
|
||||
break;
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
/* In general, we can't use the builtin `dirname' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `dirname' modifies its argument.
|
||||
|
||||
Return the leading directories part of FILE, allocated with xmalloc.
|
||||
Works properly even if there are trailing slashes (by effectively
|
||||
ignoring them). Unlike POSIX dirname(), FILE cannot be NULL.
|
||||
|
||||
If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
|
||||
lstat (base_name (FILE)); } will access the same file. Likewise,
|
||||
if the sequence { chdir (dir_name (FILE));
|
||||
rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
|
||||
to "foo" in the same directory FILE was in. */
|
||||
|
||||
char *
|
||||
dir_name (char const *file)
|
||||
{
|
||||
size_t length = dir_len (file);
|
||||
bool append_dot = (length == 0
|
||||
|| (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
&& length == FILE_SYSTEM_PREFIX_LEN (file)
|
||||
&& file[2] != '\0' && ! ISSLASH (file[2])));
|
||||
char *dir = xmalloc (length + append_dot + 1);
|
||||
memcpy (dir, file, length);
|
||||
if (append_dot)
|
||||
dir[length++] = '.';
|
||||
dir[length] = '\0';
|
||||
return dir;
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
/* Take file names apart into directory and base names.
|
||||
|
||||
Copyright (C) 1998, 2001, 2003-2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef DIRNAME_H_
|
||||
# define DIRNAME_H_ 1
|
||||
|
||||
# include <stdbool.h>
|
||||
# include <stddef.h>
|
||||
|
||||
# ifndef DIRECTORY_SEPARATOR
|
||||
# define DIRECTORY_SEPARATOR '/'
|
||||
# endif
|
||||
|
||||
# ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
|
||||
# endif
|
||||
|
||||
# ifndef FILE_SYSTEM_PREFIX_LEN
|
||||
# if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
|
||||
/* This internal macro assumes ASCII, but all hosts that support drive
|
||||
letters use ASCII. */
|
||||
# define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
|
||||
<= 'z' - 'a')
|
||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) \
|
||||
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
|
||||
# else
|
||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
|
||||
# endif
|
||||
|
||||
# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||
# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
|
||||
# endif
|
||||
|
||||
# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
|
||||
# else
|
||||
# define IS_ABSOLUTE_FILE_NAME(F) \
|
||||
(ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
|
||||
# endif
|
||||
# define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
|
||||
|
||||
char *base_name (char const *file);
|
||||
char *dir_name (char const *file);
|
||||
size_t base_len (char const *file);
|
||||
size_t dir_len (char const *file);
|
||||
char *last_component (char const *file);
|
||||
|
||||
bool strip_trailing_slashes (char *file);
|
||||
|
||||
#endif /* not DIRNAME_H_ */
|
||||
@ -1,57 +0,0 @@
|
||||
/* Duplicate an open file descriptor to a specified file descriptor.
|
||||
|
||||
Copyright (C) 1999, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Paul Eggert */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <unistd.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef F_DUPFD
|
||||
static int
|
||||
dupfd (int fd, int desired_fd)
|
||||
{
|
||||
int duplicated_fd = dup (fd);
|
||||
if (duplicated_fd < 0 || duplicated_fd == desired_fd)
|
||||
return duplicated_fd;
|
||||
else
|
||||
{
|
||||
int r = dupfd (fd, desired_fd);
|
||||
int e = errno;
|
||||
close (duplicated_fd);
|
||||
errno = e;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
dup2 (int fd, int desired_fd)
|
||||
{
|
||||
if (fd == desired_fd)
|
||||
return fd;
|
||||
close (desired_fd);
|
||||
#ifdef F_DUPFD
|
||||
return fcntl (fd, F_DUPFD, desired_fd);
|
||||
#else
|
||||
return dupfd (fd, desired_fd);
|
||||
#endif
|
||||
}
|
||||
338
gl/lib/error.c
338
gl/lib/error.c
@ -1,338 +0,0 @@
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-1998, 2000-2007 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#if !_LIBC
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !_LIBC && ENABLE_NLS
|
||||
# include "gettext.h"
|
||||
# define _(msgid) gettext (msgid)
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <libintl.h>
|
||||
# include <stdbool.h>
|
||||
# include <stdint.h>
|
||||
# include <wchar.h>
|
||||
# define mbsrtowcs __mbsrtowcs
|
||||
#endif
|
||||
|
||||
#if USE_UNLOCKED_IO
|
||||
# include "unlocked-io.h"
|
||||
#endif
|
||||
|
||||
#ifndef _
|
||||
# define _(String) String
|
||||
#endif
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
void (*error_print_progname) (void);
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
unsigned int error_message_count;
|
||||
|
||||
#ifdef _LIBC
|
||||
/* In the GNU C library, there is a predefined variable for this. */
|
||||
|
||||
# define program_name program_invocation_name
|
||||
# include <errno.h>
|
||||
# include <limits.h>
|
||||
# include <libio/libioP.h>
|
||||
|
||||
/* In GNU libc we want do not want to use the common name `error' directly.
|
||||
Instead make it a weak alias. */
|
||||
extern void __error (int status, int errnum, const char *message, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message,
|
||||
...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));;
|
||||
# define error __error
|
||||
# define error_at_line __error_at_line
|
||||
|
||||
# include <libio/iolibio.h>
|
||||
# define fflush(s) INTUSE(_IO_fflush) (s)
|
||||
# undef putc
|
||||
# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
|
||||
|
||||
# include <bits/libc-lock.h>
|
||||
|
||||
#else /* not _LIBC */
|
||||
|
||||
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||
# ifndef HAVE_DECL_STRERROR_R
|
||||
"this configure-time declaration test was not run"
|
||||
# endif
|
||||
char *strerror_r ();
|
||||
# endif
|
||||
|
||||
/* The calling program should define program_name and set it to the
|
||||
name of the executing program. */
|
||||
extern char *program_name;
|
||||
|
||||
# if HAVE_STRERROR_R || defined strerror_r
|
||||
# define __strerror_r strerror_r
|
||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||
#endif /* not _LIBC */
|
||||
|
||||
static void
|
||||
print_errno_message (int errnum)
|
||||
{
|
||||
char const *s;
|
||||
|
||||
#if defined HAVE_STRERROR_R || _LIBC
|
||||
char errbuf[1024];
|
||||
# if STRERROR_R_CHAR_P || _LIBC
|
||||
s = __strerror_r (errnum, errbuf, sizeof errbuf);
|
||||
# else
|
||||
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
|
||||
s = errbuf;
|
||||
else
|
||||
s = 0;
|
||||
# endif
|
||||
#else
|
||||
s = strerror (errnum);
|
||||
#endif
|
||||
|
||||
#if !_LIBC
|
||||
if (! s)
|
||||
s = _("Unknown system error");
|
||||
#endif
|
||||
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, ": %s", s);
|
||||
#else
|
||||
fprintf (stderr, ": %s", s);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
error_tail (int status, int errnum, const char *message, va_list args)
|
||||
{
|
||||
#if _LIBC
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
{
|
||||
# define ALLOCA_LIMIT 2000
|
||||
size_t len = strlen (message) + 1;
|
||||
wchar_t *wmessage = NULL;
|
||||
mbstate_t st;
|
||||
size_t res;
|
||||
const char *tmp;
|
||||
bool use_malloc = false;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (__libc_use_alloca (len * sizeof (wchar_t)))
|
||||
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||
else
|
||||
{
|
||||
if (!use_malloc)
|
||||
wmessage = NULL;
|
||||
|
||||
wchar_t *p = (wchar_t *) realloc (wmessage,
|
||||
len * sizeof (wchar_t));
|
||||
if (p == NULL)
|
||||
{
|
||||
free (wmessage);
|
||||
fputws_unlocked (L"out of memory\n", stderr);
|
||||
return;
|
||||
}
|
||||
wmessage = p;
|
||||
use_malloc = true;
|
||||
}
|
||||
|
||||
memset (&st, '\0', sizeof (st));
|
||||
tmp = message;
|
||||
|
||||
res = mbsrtowcs (wmessage, &tmp, len, &st);
|
||||
if (res != len)
|
||||
break;
|
||||
|
||||
if (__builtin_expect (len >= SIZE_MAX / 2, 0))
|
||||
{
|
||||
/* This really should not happen if everything is fine. */
|
||||
res = (size_t) -1;
|
||||
break;
|
||||
}
|
||||
|
||||
len *= 2;
|
||||
}
|
||||
|
||||
if (res == (size_t) -1)
|
||||
{
|
||||
/* The string cannot be converted. */
|
||||
if (use_malloc)
|
||||
{
|
||||
free (wmessage);
|
||||
use_malloc = false;
|
||||
}
|
||||
wmessage = (wchar_t *) L"???";
|
||||
}
|
||||
|
||||
__vfwprintf (stderr, wmessage, args);
|
||||
|
||||
if (use_malloc)
|
||||
free (wmessage);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
vfprintf (stderr, message, args);
|
||||
va_end (args);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
print_errno_message (errnum);
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, "\n");
|
||||
#else
|
||||
putc ('\n', stderr);
|
||||
#endif
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
}
|
||||
|
||||
|
||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||
format string with optional args.
|
||||
If ERRNUM is nonzero, print its corresponding system error message.
|
||||
Exit with status STATUS if it is nonzero. */
|
||||
void
|
||||
error (int status, int errnum, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
#if defined _LIBC && defined __libc_ptf_call
|
||||
/* We do not want this call to be cut short by a thread
|
||||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
_IO_flockfile (stderr);
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, "%s: ", program_name);
|
||||
#else
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
va_start (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
|
||||
#ifdef _LIBC
|
||||
_IO_funlockfile (stderr);
|
||||
# ifdef __libc_ptf_call
|
||||
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
int error_one_per_line;
|
||||
|
||||
void
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (error_one_per_line)
|
||||
{
|
||||
static const char *old_file_name;
|
||||
static unsigned int old_line_number;
|
||||
|
||||
if (old_line_number == line_number
|
||||
&& (file_name == old_file_name
|
||||
|| strcmp (old_file_name, file_name) == 0))
|
||||
/* Simply return and print nothing. */
|
||||
return;
|
||||
|
||||
old_file_name = file_name;
|
||||
old_line_number = line_number;
|
||||
}
|
||||
|
||||
#if defined _LIBC && defined __libc_ptf_call
|
||||
/* We do not want this call to be cut short by a thread
|
||||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
_IO_flockfile (stderr);
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, "%s:", program_name);
|
||||
#else
|
||||
fprintf (stderr, "%s:", program_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
|
||||
file_name, line_number);
|
||||
#else
|
||||
fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
|
||||
file_name, line_number);
|
||||
#endif
|
||||
|
||||
va_start (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
|
||||
#ifdef _LIBC
|
||||
_IO_funlockfile (stderr);
|
||||
# ifdef __libc_ptf_call
|
||||
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Make the weak alias. */
|
||||
# undef error
|
||||
# undef error_at_line
|
||||
weak_alias (__error, error)
|
||||
weak_alias (__error_at_line, error_at_line)
|
||||
#endif
|
||||
@ -1,65 +0,0 @@
|
||||
/* Declaration for error-reporting function
|
||||
Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _ERROR_H
|
||||
#define _ERROR_H 1
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Print a message with `fprintf (stderr, FORMAT, ...)';
|
||||
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
|
||||
|
||||
extern void error (int __status, int __errnum, const char *__format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
|
||||
extern void error_at_line (int __status, int __errnum, const char *__fname,
|
||||
unsigned int __lineno, const char *__format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
extern void (*error_print_progname) (void);
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
extern unsigned int error_message_count;
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
extern int error_one_per_line;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* error.h */
|
||||
@ -1,24 +0,0 @@
|
||||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "exitfail.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int volatile exit_failure = EXIT_FAILURE;
|
||||
@ -1,18 +0,0 @@
|
||||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
extern int volatile exit_failure;
|
||||
@ -1,80 +0,0 @@
|
||||
/* An interface to read and write that retries (if necessary) until complete.
|
||||
|
||||
Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||
2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#ifdef FULL_READ
|
||||
# include "full-read.h"
|
||||
#else
|
||||
# include "full-write.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef FULL_READ
|
||||
# include "safe-read.h"
|
||||
# define safe_rw safe_read
|
||||
# define full_rw full_read
|
||||
# undef const
|
||||
# define const /* empty */
|
||||
#else
|
||||
# include "safe-write.h"
|
||||
# define safe_rw safe_write
|
||||
# define full_rw full_write
|
||||
#endif
|
||||
|
||||
#ifdef FULL_READ
|
||||
/* Set errno to zero upon EOF. */
|
||||
# define ZERO_BYTE_TRANSFER_ERRNO 0
|
||||
#else
|
||||
/* Some buggy drivers return 0 when one tries to write beyond
|
||||
a device's end. (Example: Linux 1.2.13 on /dev/fd0.)
|
||||
Set errno to ENOSPC so they get a sensible diagnostic. */
|
||||
# define ZERO_BYTE_TRANSFER_ERRNO ENOSPC
|
||||
#endif
|
||||
|
||||
/* Write(read) COUNT bytes at BUF to(from) descriptor FD, retrying if
|
||||
interrupted or if a partial write(read) occurs. Return the number
|
||||
of bytes transferred.
|
||||
When writing, set errno if fewer than COUNT bytes are written.
|
||||
When reading, if fewer than COUNT bytes are read, you must examine
|
||||
errno to distinguish failure from EOF (errno == 0). */
|
||||
size_t
|
||||
full_rw (int fd, const void *buf, size_t count)
|
||||
{
|
||||
size_t total = 0;
|
||||
const char *ptr = (const char *) buf;
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
size_t n_rw = safe_rw (fd, ptr, count);
|
||||
if (n_rw == (size_t) -1)
|
||||
break;
|
||||
if (n_rw == 0)
|
||||
{
|
||||
errno = ZERO_BYTE_TRANSFER_ERRNO;
|
||||
break;
|
||||
}
|
||||
total += n_rw;
|
||||
ptr += n_rw;
|
||||
count -= n_rw;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
/* An interface to write() that writes all it is asked to write.
|
||||
|
||||
Copyright (C) 2002-2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Write COUNT bytes at BUF to descriptor FD, retrying if interrupted
|
||||
or if partial writes occur. Return the number of bytes successfully
|
||||
written, setting errno if that is less than COUNT. */
|
||||
extern size_t full_write (int fd, const void *buf, size_t count);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
1186
gl/lib/getopt.c
1186
gl/lib/getopt.c
File diff suppressed because it is too large
Load Diff
@ -1,225 +0,0 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
|
||||
#ifndef __need_getopt
|
||||
# define _GETOPT_H 1
|
||||
#endif
|
||||
|
||||
/* Standalone applications should #define __GETOPT_PREFIX to an
|
||||
identifier that prefixes the external functions and variables
|
||||
defined in this header. When this happens, include the
|
||||
headers that might declare getopt so that they will not cause
|
||||
confusion if included after this file. Then systematically rename
|
||||
identifiers so that they do not collide with the system functions
|
||||
and variables. Renaming avoids problems with some compilers and
|
||||
linkers. */
|
||||
#if defined __GETOPT_PREFIX && !defined __need_getopt
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
# undef __need_getopt
|
||||
# undef getopt
|
||||
# undef getopt_long
|
||||
# undef getopt_long_only
|
||||
# undef optarg
|
||||
# undef opterr
|
||||
# undef optind
|
||||
# undef optopt
|
||||
# define __GETOPT_CONCAT(x, y) x ## y
|
||||
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
|
||||
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
|
||||
# define getopt __GETOPT_ID (getopt)
|
||||
# define getopt_long __GETOPT_ID (getopt_long)
|
||||
# define getopt_long_only __GETOPT_ID (getopt_long_only)
|
||||
# define optarg __GETOPT_ID (optarg)
|
||||
# define opterr __GETOPT_ID (opterr)
|
||||
# define optind __GETOPT_ID (optind)
|
||||
# define optopt __GETOPT_ID (optopt)
|
||||
#endif
|
||||
|
||||
/* Standalone applications get correct prototypes for getopt_long and
|
||||
getopt_long_only; they declare "char **argv". libc uses prototypes
|
||||
with "char *const *argv" that are incorrect because getopt_long and
|
||||
getopt_long_only can permute argv; this is required for backward
|
||||
compatibility (e.g., for LSB 2.0.1).
|
||||
|
||||
This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
|
||||
but it caused redefinition warnings if both unistd.h and getopt.h were
|
||||
included, since unistd.h includes getopt.h having previously defined
|
||||
__need_getopt.
|
||||
|
||||
The only place where __getopt_argv_const is used is in definitions
|
||||
of getopt_long and getopt_long_only below, but these are visible
|
||||
only if __need_getopt is not defined, so it is quite safe to rewrite
|
||||
the conditional as follows:
|
||||
*/
|
||||
#if !defined __need_getopt
|
||||
# if defined __GETOPT_PREFIX
|
||||
# define __getopt_argv_const /* empty */
|
||||
# else
|
||||
# define __getopt_argv_const const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If __GNU_LIBRARY__ is not already defined, either we are being used
|
||||
standalone, or this is the first header included in the source file.
|
||||
If we are being used with glibc, we need to include <features.h>, but
|
||||
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
||||
not defined, include <ctype.h>, which will pull in <features.h> for us
|
||||
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
||||
doesn't flood the namespace with stuff the way some other headers do.) */
|
||||
#if !defined __GNU_LIBRARY__
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifndef __THROW
|
||||
# ifndef __GNUC_PREREQ
|
||||
# define __GNUC_PREREQ(maj, min) (0)
|
||||
# endif
|
||||
# if defined __cplusplus && __GNUC_PREREQ (2,8)
|
||||
# define __THROW throw ()
|
||||
# else
|
||||
# define __THROW
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
#ifndef __need_getopt
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
const char *name;
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#endif /* need getopt */
|
||||
|
||||
|
||||
/* Get definitions and prototypes for functions to process the
|
||||
arguments in ARGV (ARGC of them, minus the program name) for
|
||||
options given in OPTS.
|
||||
|
||||
Return the option character from OPTS just read. Return -1 when
|
||||
there are no more options. For unrecognized options, or options
|
||||
missing arguments, `optopt' is set to the option letter, and '?' is
|
||||
returned.
|
||||
|
||||
The OPTS string is a list of characters which are recognized option
|
||||
letters, optionally followed by colons, specifying that that letter
|
||||
takes an argument, to be placed in `optarg'.
|
||||
|
||||
If a letter in OPTS is followed by two colons, its argument is
|
||||
optional. This behavior is specific to the GNU `getopt'.
|
||||
|
||||
The argument `--' causes premature termination of argument
|
||||
scanning, explicitly telling `getopt' that there are no more
|
||||
options.
|
||||
|
||||
If OPTS begins with `-', then non-option arguments are treated as
|
||||
arguments to the option '\1'. This behavior is specific to the GNU
|
||||
`getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in
|
||||
the environment, then do not permute arguments. */
|
||||
|
||||
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
|
||||
__THROW;
|
||||
|
||||
#ifndef __need_getopt
|
||||
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we later can get all the definitions and declarations. */
|
||||
#undef __need_getopt
|
||||
|
||||
#endif /* getopt.h */
|
||||
170
gl/lib/getopt1.c
170
gl/lib/getopt1.c
@ -1,170 +0,0 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <getopt.h>
|
||||
#else
|
||||
# include <config.h>
|
||||
# include "getopt.h"
|
||||
#endif
|
||||
#include "getopt_int.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||
opt_index, 0, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_r (int argc, char **argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
{
|
||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||
0, 0, d);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (int argc, char *__getopt_argv_const *argv,
|
||||
const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||
opt_index, 1, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_only_r (int argc, char **argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
{
|
||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||
1, 0, d);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
@ -1,130 +0,0 @@
|
||||
/* Internal declarations for getopt.
|
||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_INT_H
|
||||
#define _GETOPT_INT_H 1
|
||||
|
||||
extern int _getopt_internal (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, int __posixly_correct);
|
||||
|
||||
|
||||
/* Reentrant versions which can handle parsing multiple argument
|
||||
vectors at the same time. */
|
||||
|
||||
/* Data type for reentrant functions. */
|
||||
struct _getopt_data
|
||||
{
|
||||
/* These have exactly the same meaning as the corresponding global
|
||||
variables, except that they are used for the reentrant
|
||||
versions of getopt. */
|
||||
int optind;
|
||||
int opterr;
|
||||
int optopt;
|
||||
char *optarg;
|
||||
|
||||
/* Internal members. */
|
||||
|
||||
/* True if the internal members have been initialized. */
|
||||
int __initialized;
|
||||
|
||||
/* The next char to be scanned in the option-element
|
||||
in which the last option character we returned was found.
|
||||
This allows us to pick up the scan where we left off.
|
||||
|
||||
If this is zero, or a null string, it means resume the scan
|
||||
by advancing to the next ARGV-element. */
|
||||
char *__nextchar;
|
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
This is what Unix does.
|
||||
This mode of operation is selected by either setting the environment
|
||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
||||
of the list of option characters, or by calling getopt.
|
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we
|
||||
scan, so that eventually all the non-options are at the end.
|
||||
This allows options to be given in any order, even with programs
|
||||
that were not written to expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were
|
||||
written to expect options and other ARGV-elements in any order
|
||||
and that care about the ordering of the two. We describe each
|
||||
non-option ARGV-element as if it were the argument of an option
|
||||
with character code 1. Using `-' as the first character of the
|
||||
list of option characters selects this mode of operation.
|
||||
|
||||
The special argument `--' forces an end of option-scanning regardless
|
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
||||
|
||||
enum
|
||||
{
|
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||
} __ordering;
|
||||
|
||||
/* If the POSIXLY_CORRECT environment variable is set
|
||||
or getopt was called. */
|
||||
int __posixly_correct;
|
||||
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
been skipped. `first_nonopt' is the index in ARGV of the first
|
||||
of them; `last_nonopt' is the index after the last of them. */
|
||||
|
||||
int __first_nonopt;
|
||||
int __last_nonopt;
|
||||
|
||||
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||
int __nonoption_flags_max_len;
|
||||
int __nonoption_flags_len;
|
||||
# endif
|
||||
};
|
||||
|
||||
/* The initializer is necessary to set OPTIND and OPTERR to their
|
||||
default values and to clear the initialization flag. */
|
||||
#define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
||||
|
||||
extern int _getopt_internal_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, int __posixly_correct,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
extern int _getopt_long_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
extern int _getopt_long_only_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts,
|
||||
int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
#endif /* getopt_int.h */
|
||||
270
gl/lib/gettext.h
270
gl/lib/gettext.h
@ -1,270 +0,0 @@
|
||||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002, 2004-2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
|
||||
/* NLS can be disabled through the configure --disable-nls option. */
|
||||
#if ENABLE_NLS
|
||||
|
||||
/* Get declarations of GNU message catalog functions. */
|
||||
# include <libintl.h>
|
||||
|
||||
/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
|
||||
the gettext() and ngettext() macros. This is an alternative to calling
|
||||
textdomain(), and is useful for libraries. */
|
||||
# ifdef DEFAULT_TEXT_DOMAIN
|
||||
# undef gettext
|
||||
# define gettext(Msgid) \
|
||||
dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
|
||||
# undef ngettext
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
|
||||
chokes if dcgettext is defined as a macro. So include it now, to make
|
||||
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
|
||||
as well because people using "gettext.h" will not include <libintl.h>,
|
||||
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
|
||||
is OK. */
|
||||
#if defined(__sun)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
|
||||
<libintl.h>, which chokes if dcgettext is defined as a macro. So include
|
||||
it now, to make later inclusions of <libintl.h> a NOP. */
|
||||
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
|
||||
# include <cstdlib>
|
||||
# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
|
||||
# define dcgettext(Domainname, Msgid, Category) \
|
||||
((void) (Category), dgettext (Domainname, Msgid))
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 \
|
||||
? ((void) (Msgid2), (const char *) (Msgid1)) \
|
||||
: ((void) (Msgid1), (const char *) (Msgid2)))
|
||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||
((void) (Domainname), ngettext (Msgid1, Msgid2, N))
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
|
||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
# define bindtextdomain(Domainname, Dirname) \
|
||||
((void) (Domainname), (const char *) (Dirname))
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) \
|
||||
((void) (Domainname), (const char *) (Codeset))
|
||||
|
||||
#endif
|
||||
|
||||
/* A pseudo function call that serves as a marker for the automated
|
||||
extraction of messages, but does not call gettext(). The run-time
|
||||
translation is done at a different place in the code.
|
||||
The argument, String, should be a literal string. Concatenated strings
|
||||
and other string expressions won't work.
|
||||
The macro's expansion is not parenthesized, so that it is suitable as
|
||||
initializer for static 'char[]' or 'const char[]' variables. */
|
||||
#define gettext_noop(String) String
|
||||
|
||||
/* The separator between msgctxt and msgid in a .mo file. */
|
||||
#define GETTEXT_CONTEXT_GLUE "\004"
|
||||
|
||||
/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
|
||||
MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
|
||||
short and rarely need to change.
|
||||
The letter 'p' stands for 'particular' or 'special'. */
|
||||
#ifdef DEFAULT_TEXT_DOMAIN
|
||||
# define pgettext(Msgctxt, Msgid) \
|
||||
pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
|
||||
#else
|
||||
# define pgettext(Msgctxt, Msgid) \
|
||||
pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
|
||||
#endif
|
||||
#define dpgettext(Domainname, Msgctxt, Msgid) \
|
||||
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
|
||||
#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
|
||||
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
|
||||
#ifdef DEFAULT_TEXT_DOMAIN
|
||||
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
|
||||
npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
#else
|
||||
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
|
||||
npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
#endif
|
||||
#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
|
||||
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
|
||||
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
inline
|
||||
#endif
|
||||
#endif
|
||||
static const char *
|
||||
pgettext_aux (const char *domain,
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
int category)
|
||||
{
|
||||
const char *translation = dcgettext (domain, msg_ctxt_id, category);
|
||||
if (translation == msg_ctxt_id)
|
||||
return msgid;
|
||||
else
|
||||
return translation;
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
inline
|
||||
#endif
|
||||
#endif
|
||||
static const char *
|
||||
npgettext_aux (const char *domain,
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
{
|
||||
const char *translation =
|
||||
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||
if (translation == msg_ctxt_id || translation == msgid_plural)
|
||||
return (n == 1 ? msgid : msgid_plural);
|
||||
else
|
||||
return translation;
|
||||
}
|
||||
|
||||
/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
|
||||
can be arbitrary expressions. But for string literals these macros are
|
||||
less efficient than those above. */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
|
||||
(((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
|
||||
/* || __STDC_VERSION__ >= 199901L */ )
|
||||
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#define pgettext_expr(Msgctxt, Msgid) \
|
||||
dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
|
||||
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
|
||||
dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
inline
|
||||
#endif
|
||||
#endif
|
||||
static const char *
|
||||
dcpgettext_expr (const char *domain,
|
||||
const char *msgctxt, const char *msgid,
|
||||
int category)
|
||||
{
|
||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||
size_t msgid_len = strlen (msgid) + 1;
|
||||
const char *translation;
|
||||
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
char msg_ctxt_id[msgctxt_len + msgid_len];
|
||||
#else
|
||||
char buf[1024];
|
||||
char *msg_ctxt_id =
|
||||
(msgctxt_len + msgid_len <= sizeof (buf)
|
||||
? buf
|
||||
: (char *) malloc (msgctxt_len + msgid_len));
|
||||
if (msg_ctxt_id != NULL)
|
||||
#endif
|
||||
{
|
||||
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
|
||||
msg_ctxt_id[msgctxt_len - 1] = '\004';
|
||||
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
|
||||
translation = dcgettext (domain, msg_ctxt_id, category);
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
if (msg_ctxt_id != buf)
|
||||
free (msg_ctxt_id);
|
||||
#endif
|
||||
if (translation != msg_ctxt_id)
|
||||
return translation;
|
||||
}
|
||||
return msgid;
|
||||
}
|
||||
|
||||
#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
|
||||
dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
|
||||
dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
inline
|
||||
#endif
|
||||
#endif
|
||||
static const char *
|
||||
dcnpgettext_expr (const char *domain,
|
||||
const char *msgctxt, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
{
|
||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||
size_t msgid_len = strlen (msgid) + 1;
|
||||
const char *translation;
|
||||
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
char msg_ctxt_id[msgctxt_len + msgid_len];
|
||||
#else
|
||||
char buf[1024];
|
||||
char *msg_ctxt_id =
|
||||
(msgctxt_len + msgid_len <= sizeof (buf)
|
||||
? buf
|
||||
: (char *) malloc (msgctxt_len + msgid_len));
|
||||
if (msg_ctxt_id != NULL)
|
||||
#endif
|
||||
{
|
||||
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
|
||||
msg_ctxt_id[msgctxt_len - 1] = '\004';
|
||||
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
|
||||
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
if (msg_ctxt_id != buf)
|
||||
free (msg_ctxt_id);
|
||||
#endif
|
||||
if (!(translation == msg_ctxt_id || translation == msgid_plural))
|
||||
return translation;
|
||||
}
|
||||
return (n == 1 ? msgid : msgid_plural);
|
||||
}
|
||||
|
||||
#endif /* _LIBGETTEXT_H */
|
||||
1049
gl/lib/hash.c
1049
gl/lib/hash.c
File diff suppressed because it is too large
Load Diff
@ -1,87 +0,0 @@
|
||||
/* hash - hashing table processing.
|
||||
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
|
||||
Written by Jim Meyering <meyering@ascend.com>, 1998.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* A generic hash table package. */
|
||||
|
||||
/* Make sure USE_OBSTACK is defined to 1 if you want the allocator to use
|
||||
obstacks instead of malloc, and recompile `hash.c' with same setting. */
|
||||
|
||||
#ifndef HASH_H_
|
||||
# define HASH_H_
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdbool.h>
|
||||
|
||||
typedef size_t (*Hash_hasher) (const void *, size_t);
|
||||
typedef bool (*Hash_comparator) (const void *, const void *);
|
||||
typedef void (*Hash_data_freer) (void *);
|
||||
typedef bool (*Hash_processor) (void *, void *);
|
||||
|
||||
struct hash_entry
|
||||
{
|
||||
void *data;
|
||||
struct hash_entry *next;
|
||||
};
|
||||
|
||||
struct hash_tuning
|
||||
{
|
||||
/* This structure is mainly used for `hash_initialize', see the block
|
||||
documentation of `hash_reset_tuning' for more complete comments. */
|
||||
|
||||
float shrink_threshold; /* ratio of used buckets to trigger a shrink */
|
||||
float shrink_factor; /* ratio of new smaller size to original size */
|
||||
float growth_threshold; /* ratio of used buckets to trigger a growth */
|
||||
float growth_factor; /* ratio of new bigger size to original size */
|
||||
bool is_n_buckets; /* if CANDIDATE really means table size */
|
||||
};
|
||||
|
||||
typedef struct hash_tuning Hash_tuning;
|
||||
|
||||
struct hash_table;
|
||||
|
||||
typedef struct hash_table Hash_table;
|
||||
|
||||
/* Information and lookup. */
|
||||
size_t hash_get_n_buckets (const Hash_table *);
|
||||
size_t hash_get_n_buckets_used (const Hash_table *);
|
||||
size_t hash_get_n_entries (const Hash_table *);
|
||||
size_t hash_get_max_bucket_length (const Hash_table *);
|
||||
bool hash_table_ok (const Hash_table *);
|
||||
void hash_print_statistics (const Hash_table *, FILE *);
|
||||
void *hash_lookup (const Hash_table *, const void *);
|
||||
|
||||
/* Walking. */
|
||||
void *hash_get_first (const Hash_table *);
|
||||
void *hash_get_next (const Hash_table *, const void *);
|
||||
size_t hash_get_entries (const Hash_table *, void **, size_t);
|
||||
size_t hash_do_for_each (const Hash_table *, Hash_processor, void *);
|
||||
|
||||
/* Allocation and clean-up. */
|
||||
size_t hash_string (const char *, size_t);
|
||||
void hash_reset_tuning (Hash_tuning *);
|
||||
Hash_table *hash_initialize (size_t, const Hash_tuning *,
|
||||
Hash_hasher, Hash_comparator,
|
||||
Hash_data_freer);
|
||||
void hash_clear (Hash_table *);
|
||||
void hash_free (Hash_table *);
|
||||
|
||||
/* Insertion and deletion. */
|
||||
bool hash_rehash (Hash_table *, size_t);
|
||||
void *hash_insert (Hash_table *, const void *);
|
||||
void *hash_delete (Hash_table *, const void *);
|
||||
|
||||
#endif
|
||||
@ -1,57 +0,0 @@
|
||||
/* malloc() function that is glibc compatible.
|
||||
|
||||
Copyright (C) 1997, 1998, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* written by Jim Meyering and Bruno Haible */
|
||||
|
||||
#include <config.h>
|
||||
/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
|
||||
#ifdef malloc
|
||||
# define NEED_MALLOC_GNU
|
||||
# undef malloc
|
||||
#endif
|
||||
|
||||
/* Specification. */
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* Call the system's malloc below. */
|
||||
#undef malloc
|
||||
|
||||
/* Allocate an N-byte block of memory from the heap.
|
||||
If N is zero, allocate a 1-byte block. */
|
||||
|
||||
void *
|
||||
rpl_malloc (size_t n)
|
||||
{
|
||||
void *result;
|
||||
|
||||
#ifdef NEED_MALLOC_GNU
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
#endif
|
||||
|
||||
result = malloc (n);
|
||||
|
||||
#if !HAVE_MALLOC_POSIX
|
||||
if (result == NULL)
|
||||
errno = ENOMEM;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
386
gl/lib/mbrtowc.c
386
gl/lib/mbrtowc.c
@ -1,386 +0,0 @@
|
||||
/* Convert multibyte character to wide character.
|
||||
Copyright (C) 1999-2002, 2005-2009 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <wchar.h>
|
||||
|
||||
#if GNULIB_defined_mbstate_t
|
||||
/* Implement mbrtowc() on top of mbtowc(). */
|
||||
|
||||
# include <errno.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
# include "localcharset.h"
|
||||
# include "streq.h"
|
||||
# include "verify.h"
|
||||
|
||||
|
||||
verify (sizeof (mbstate_t) >= 4);
|
||||
|
||||
static char internal_state[4];
|
||||
|
||||
size_t
|
||||
mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
||||
{
|
||||
char *pstate = (char *)ps;
|
||||
|
||||
if (pstate == NULL)
|
||||
pstate = internal_state;
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
pwc = NULL;
|
||||
s = "";
|
||||
n = 1;
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
return (size_t)(-2);
|
||||
|
||||
/* Here n > 0. */
|
||||
{
|
||||
size_t nstate = pstate[0];
|
||||
char buf[4];
|
||||
const char *p;
|
||||
size_t m;
|
||||
|
||||
switch (nstate)
|
||||
{
|
||||
case 0:
|
||||
p = s;
|
||||
m = n;
|
||||
break;
|
||||
case 3:
|
||||
buf[2] = pstate[3];
|
||||
/*FALLTHROUGH*/
|
||||
case 2:
|
||||
buf[1] = pstate[2];
|
||||
/*FALLTHROUGH*/
|
||||
case 1:
|
||||
buf[0] = pstate[1];
|
||||
p = buf;
|
||||
m = nstate;
|
||||
buf[m++] = s[0];
|
||||
if (n >= 2 && m < 4)
|
||||
{
|
||||
buf[m++] = s[1];
|
||||
if (n >= 3 && m < 4)
|
||||
buf[m++] = s[2];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return (size_t)(-1);
|
||||
}
|
||||
|
||||
/* Here m > 0. */
|
||||
|
||||
# if __GLIBC__
|
||||
/* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
|
||||
mbtowc (NULL, NULL, 0);
|
||||
# endif
|
||||
{
|
||||
int res = mbtowc (pwc, p, m);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
if (pwc != NULL && ((*pwc == 0) != (res == 0)))
|
||||
abort ();
|
||||
if (nstate >= (res > 0 ? res : 1))
|
||||
abort ();
|
||||
res -= nstate;
|
||||
pstate[0] = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* mbtowc does not distinguish between invalid and incomplete multibyte
|
||||
sequences. But mbrtowc needs to make this distinction.
|
||||
There are two possible approaches:
|
||||
- Use iconv() and its return value.
|
||||
- Use built-in knowledge about the possible encodings.
|
||||
Given the low quality of implementation of iconv() on the systems that
|
||||
lack mbrtowc(), we use the second approach.
|
||||
The possible encodings are:
|
||||
- 8-bit encodings,
|
||||
- EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
|
||||
- UTF-8.
|
||||
Use specialized code for each. */
|
||||
if (m >= 4 || m >= MB_CUR_MAX)
|
||||
goto invalid;
|
||||
/* Here MB_CUR_MAX > 1 and 0 < m < 4. */
|
||||
{
|
||||
const char *encoding = locale_charset ();
|
||||
|
||||
if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
{
|
||||
/* Cf. unistr/u8-mblen.c. */
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || c2 >= 0xa0)
|
||||
&& (c != 0xed || c2 < 0xa0))
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
else if (c <= 0xf4)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || c2 >= 0x90)
|
||||
&& (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m == 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if ((c3 ^ 0x80) < 0x40)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
/* As a reference for this code, you can use the GNU libiconv
|
||||
implementation. Look for uses of the RET_TOOFEW macro. */
|
||||
|
||||
if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
|
||||
goto incomplete;
|
||||
}
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8f)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if (c2 >= 0xa1 && c2 < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|
||||
|| STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
|
||||
|| STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0xa1 && c < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0x90 && c <= 0xe3)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if (c2 >= 0x30 && c2 <= 0x39)
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m == 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if (c3 >= 0x81 && c3 <= 0xfe)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
|
||||
|| (c >= 0xf0 && c <= 0xf9))
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
/* An unknown multibyte encoding. */
|
||||
goto incomplete;
|
||||
}
|
||||
|
||||
incomplete:
|
||||
{
|
||||
size_t k = nstate;
|
||||
/* Here 0 <= k < m < 4. */
|
||||
pstate[++k] = s[0];
|
||||
if (k < m)
|
||||
{
|
||||
pstate[++k] = s[1];
|
||||
if (k < m)
|
||||
pstate[++k] = s[2];
|
||||
}
|
||||
if (k != m)
|
||||
abort ();
|
||||
}
|
||||
pstate[0] = m;
|
||||
return (size_t)(-2);
|
||||
|
||||
invalid:
|
||||
errno = EILSEQ;
|
||||
/* The conversion state is undefined, says POSIX. */
|
||||
return (size_t)(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
/* Override the system's mbrtowc() function. */
|
||||
|
||||
# undef mbrtowc
|
||||
|
||||
size_t
|
||||
rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
||||
{
|
||||
# if MBRTOWC_NULL_ARG_BUG || MBRTOWC_RETVAL_BUG
|
||||
if (s == NULL)
|
||||
{
|
||||
pwc = NULL;
|
||||
s = "";
|
||||
n = 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if MBRTOWC_RETVAL_BUG
|
||||
{
|
||||
static mbstate_t internal_state;
|
||||
|
||||
/* Override mbrtowc's internal state. We can not call mbsinit() on the
|
||||
hidden internal state, but we can call it on our variable. */
|
||||
if (ps == NULL)
|
||||
ps = &internal_state;
|
||||
|
||||
if (!mbsinit (ps))
|
||||
{
|
||||
/* Parse the rest of the multibyte character byte for byte. */
|
||||
size_t count = 0;
|
||||
for (; n > 0; s++, n--)
|
||||
{
|
||||
wchar_t wc;
|
||||
size_t ret = mbrtowc (&wc, s, 1, ps);
|
||||
|
||||
if (ret == (size_t)(-1))
|
||||
return (size_t)(-1);
|
||||
count++;
|
||||
if (ret != (size_t)(-2))
|
||||
{
|
||||
/* The multibyte character has been completed. */
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
return (wc == 0 ? 0 : count);
|
||||
}
|
||||
}
|
||||
return (size_t)(-2);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
# if MBRTOWC_NUL_RETVAL_BUG
|
||||
{
|
||||
wchar_t wc;
|
||||
size_t ret = mbrtowc (&wc, s, n, ps);
|
||||
|
||||
if (ret != (size_t)(-1) && ret != (size_t)(-2))
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
if (wc == 0)
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
# else
|
||||
return mbrtowc (pwc, s, n, ps);
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif
|
||||
172
gl/lib/memchr.c
172
gl/lib/memchr.c
@ -1,172 +0,0 @@
|
||||
/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2006, 2008
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
|
||||
with help from Dan Sahlin (dan@sics.se) and
|
||||
commentary by Jim Blandy (jimb@ai.mit.edu);
|
||||
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
|
||||
and implemented by Roland McGrath (roland@ai.mit.edu).
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
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 any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _LIBC
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined _LIBC
|
||||
# include <memcopy.h>
|
||||
#else
|
||||
# define reg_char char
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#if HAVE_BP_SYM_H || defined _LIBC
|
||||
# include <bp-sym.h>
|
||||
#else
|
||||
# define BP_SYM(sym) sym
|
||||
#endif
|
||||
|
||||
#undef __memchr
|
||||
#ifdef _LIBC
|
||||
# undef memchr
|
||||
#endif
|
||||
|
||||
#ifndef weak_alias
|
||||
# define __memchr memchr
|
||||
#endif
|
||||
|
||||
/* Search no more than N bytes of S for C. */
|
||||
void *
|
||||
__memchr (void const *s, int c_in, size_t n)
|
||||
{
|
||||
/* On 32-bit hardware, choosing longword to be a 32-bit unsigned
|
||||
long instead of a 64-bit uintmax_t tends to give better
|
||||
performance. On 64-bit hardware, unsigned long is generally 64
|
||||
bits already. Change this typedef to experiment with
|
||||
performance. */
|
||||
typedef unsigned long int longword;
|
||||
|
||||
const unsigned char *char_ptr;
|
||||
const longword *longword_ptr;
|
||||
longword repeated_one;
|
||||
longword repeated_c;
|
||||
unsigned reg_char c;
|
||||
|
||||
c = (unsigned char) c_in;
|
||||
|
||||
/* Handle the first few bytes by reading one byte at a time.
|
||||
Do this until CHAR_PTR is aligned on a longword boundary. */
|
||||
for (char_ptr = (const unsigned char *) s;
|
||||
n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
|
||||
--n, ++char_ptr)
|
||||
if (*char_ptr == c)
|
||||
return (void *) char_ptr;
|
||||
|
||||
longword_ptr = (const longword *) char_ptr;
|
||||
|
||||
/* All these elucidatory comments refer to 4-byte longwords,
|
||||
but the theory applies equally well to any size longwords. */
|
||||
|
||||
/* Compute auxiliary longword values:
|
||||
repeated_one is a value which has a 1 in every byte.
|
||||
repeated_c has c in every byte. */
|
||||
repeated_one = 0x01010101;
|
||||
repeated_c = c | (c << 8);
|
||||
repeated_c |= repeated_c << 16;
|
||||
if (0xffffffffU < (longword) -1)
|
||||
{
|
||||
repeated_one |= repeated_one << 31 << 1;
|
||||
repeated_c |= repeated_c << 31 << 1;
|
||||
if (8 < sizeof (longword))
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 64; i < sizeof (longword) * 8; i *= 2)
|
||||
{
|
||||
repeated_one |= repeated_one << i;
|
||||
repeated_c |= repeated_c << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Instead of the traditional loop which tests each byte, we will test a
|
||||
longword at a time. The tricky part is testing if *any of the four*
|
||||
bytes in the longword in question are equal to c. We first use an xor
|
||||
with repeated_c. This reduces the task to testing whether *any of the
|
||||
four* bytes in longword1 is zero.
|
||||
|
||||
We compute tmp =
|
||||
((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
|
||||
That is, we perform the following operations:
|
||||
1. Subtract repeated_one.
|
||||
2. & ~longword1.
|
||||
3. & a mask consisting of 0x80 in every byte.
|
||||
Consider what happens in each byte:
|
||||
- If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
|
||||
and step 3 transforms it into 0x80. A carry can also be propagated
|
||||
to more significant bytes.
|
||||
- If a byte of longword1 is nonzero, let its lowest 1 bit be at
|
||||
position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
|
||||
the byte ends in a single bit of value 0 and k bits of value 1.
|
||||
After step 2, the result is just k bits of value 1: 2^k - 1. After
|
||||
step 3, the result is 0. And no carry is produced.
|
||||
So, if longword1 has only non-zero bytes, tmp is zero.
|
||||
Whereas if longword1 has a zero byte, call j the position of the least
|
||||
significant zero byte. Then the result has a zero at positions 0, ...,
|
||||
j-1 and a 0x80 at position j. We cannot predict the result at the more
|
||||
significant bytes (positions j+1..3), but it does not matter since we
|
||||
already have a non-zero bit at position 8*j+7.
|
||||
|
||||
So, the test whether any byte in longword1 is zero is equivalent to
|
||||
testing whether tmp is nonzero. */
|
||||
|
||||
while (n >= sizeof (longword))
|
||||
{
|
||||
longword longword1 = *longword_ptr ^ repeated_c;
|
||||
|
||||
if ((((longword1 - repeated_one) & ~longword1)
|
||||
& (repeated_one << 7)) != 0)
|
||||
break;
|
||||
longword_ptr++;
|
||||
n -= sizeof (longword);
|
||||
}
|
||||
|
||||
char_ptr = (const unsigned char *) longword_ptr;
|
||||
|
||||
/* At this point, we know that either n < sizeof (longword), or one of the
|
||||
sizeof (longword) bytes starting at char_ptr is == c. On little-endian
|
||||
machines, we could determine the first such byte without any further
|
||||
memory accesses, just by looking at the tmp result from the last loop
|
||||
iteration. But this does not work on big-endian machines. Choose code
|
||||
that works in both cases. */
|
||||
|
||||
for (; n > 0; --n, ++char_ptr)
|
||||
{
|
||||
if (*char_ptr == c)
|
||||
return (void *) char_ptr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__memchr, BP_SYM (memchr))
|
||||
#endif
|
||||
@ -1,60 +0,0 @@
|
||||
/* MIN, MAX macros.
|
||||
Copyright (C) 1995, 1998, 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _MINMAX_H
|
||||
#define _MINMAX_H
|
||||
|
||||
/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
|
||||
(glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
|
||||
MIN, MAX macro redefinitions on some systems; the workaround is to
|
||||
#include this file as the last one among the #include list. */
|
||||
|
||||
/* Before we define the following symbols we get the <limits.h> file
|
||||
since otherwise we get redefinitions on some systems if <limits.h> is
|
||||
included after this file. Likewise for <sys/param.h>.
|
||||
If more than one of these system headers define MIN and MAX, pick just
|
||||
one of the headers (because the definitions most likely are the same). */
|
||||
#if HAVE_MINMAX_IN_LIMITS_H
|
||||
# include <limits.h>
|
||||
#elif HAVE_MINMAX_IN_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
/* Note: MIN and MAX should be used with two arguments of the
|
||||
same type. They might not return the minimum and maximum of their two
|
||||
arguments, if the arguments have different types or have unusual
|
||||
floating-point values. For example, on a typical host with 32-bit 'int',
|
||||
64-bit 'long long', and 64-bit IEEE 754 'double' types:
|
||||
|
||||
MAX (-1, 2147483648) returns 4294967295.
|
||||
MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
|
||||
MAX (NaN, 0.0) returns 0.0.
|
||||
MAX (+0.0, -0.0) returns -0.0.
|
||||
|
||||
and in each case the answer is in some sense bogus. */
|
||||
|
||||
/* MAX(a,b) returns the maximum of A and B. */
|
||||
#ifndef MAX
|
||||
# define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* MIN(a,b) returns the minimum of A and B. */
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#endif /* _MINMAX_H */
|
||||
@ -1,40 +0,0 @@
|
||||
/* quote.c - quote arguments for output
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "quotearg.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* Return an unambiguous printable representation of NAME,
|
||||
allocated in slot N, suitable for diagnostics. */
|
||||
char const *
|
||||
quote_n (int n, char const *name)
|
||||
{
|
||||
return quotearg_n_style (n, locale_quoting_style, name);
|
||||
}
|
||||
|
||||
/* Return an unambiguous printable representation of NAME,
|
||||
suitable for diagnostics. */
|
||||
char const *
|
||||
quote (char const *name)
|
||||
{
|
||||
return quote_n (0, name);
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
/* quote.h - prototypes for quote.c
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
char const *quote_n (int n, char const *name);
|
||||
char const *quote (char const *name);
|
||||
@ -1,799 +0,0 @@
|
||||
/* quotearg.c - quote arguments for output
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007,
|
||||
2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "quotearg.h"
|
||||
|
||||
#include "xalloc.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
#define N_(msgid) msgid
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#define INT_BITS (sizeof (int) * CHAR_BIT)
|
||||
|
||||
struct quoting_options
|
||||
{
|
||||
/* Basic quoting style. */
|
||||
enum quoting_style style;
|
||||
|
||||
/* Additional flags. Bitwise combination of enum quoting_flags. */
|
||||
int flags;
|
||||
|
||||
/* Quote the characters indicated by this bit vector even if the
|
||||
quoting style would not normally require them to be quoted. */
|
||||
unsigned int quote_these_too[(UCHAR_MAX / INT_BITS) + 1];
|
||||
};
|
||||
|
||||
/* Names of quoting styles. */
|
||||
char const *const quoting_style_args[] =
|
||||
{
|
||||
"literal",
|
||||
"shell",
|
||||
"shell-always",
|
||||
"c",
|
||||
"c-maybe",
|
||||
"escape",
|
||||
"locale",
|
||||
"clocale",
|
||||
0
|
||||
};
|
||||
|
||||
/* Correspondences to quoting style names. */
|
||||
enum quoting_style const quoting_style_vals[] =
|
||||
{
|
||||
literal_quoting_style,
|
||||
shell_quoting_style,
|
||||
shell_always_quoting_style,
|
||||
c_quoting_style,
|
||||
c_maybe_quoting_style,
|
||||
escape_quoting_style,
|
||||
locale_quoting_style,
|
||||
clocale_quoting_style
|
||||
};
|
||||
|
||||
/* The default quoting options. */
|
||||
static struct quoting_options default_quoting_options;
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to the default if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *
|
||||
clone_quoting_options (struct quoting_options *o)
|
||||
{
|
||||
int e = errno;
|
||||
struct quoting_options *p = xmemdup (o ? o : &default_quoting_options,
|
||||
sizeof *o);
|
||||
errno = e;
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Get the value of O's quoting style. If O is null, use the default. */
|
||||
enum quoting_style
|
||||
get_quoting_style (struct quoting_options *o)
|
||||
{
|
||||
return (o ? o : &default_quoting_options)->style;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting style to S. */
|
||||
void
|
||||
set_quoting_style (struct quoting_options *o, enum quoting_style s)
|
||||
{
|
||||
(o ? o : &default_quoting_options)->style = s;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int
|
||||
set_char_quoting (struct quoting_options *o, char c, int i)
|
||||
{
|
||||
unsigned char uc = c;
|
||||
unsigned int *p =
|
||||
(o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS;
|
||||
int shift = uc % INT_BITS;
|
||||
int r = (*p >> shift) & 1;
|
||||
*p ^= ((i & 1) ^ r) << shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options flag to I, which can be a
|
||||
bitwise combination of enum quoting_flags, or 0 for default
|
||||
behavior. Return the old value. */
|
||||
int
|
||||
set_quoting_flags (struct quoting_options *o, int i)
|
||||
{
|
||||
int r;
|
||||
if (!o)
|
||||
o = &default_quoting_options;
|
||||
r = o->flags;
|
||||
o->flags = i;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Return quoting options for STYLE, with no extra quoting. */
|
||||
static struct quoting_options
|
||||
quoting_options_from_style (enum quoting_style style)
|
||||
{
|
||||
struct quoting_options o;
|
||||
o.style = style;
|
||||
o.flags = 0;
|
||||
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
||||
return o;
|
||||
}
|
||||
|
||||
/* MSGID approximates a quotation mark. Return its translation if it
|
||||
has one; otherwise, return either it or "\"", depending on S. */
|
||||
static char const *
|
||||
gettext_quote (char const *msgid, enum quoting_style s)
|
||||
{
|
||||
char const *translation = _(msgid);
|
||||
if (translation == msgid && s == clocale_quoting_style)
|
||||
translation = "\"";
|
||||
return translation;
|
||||
}
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using QUOTING_STYLE, FLAGS, and
|
||||
QUOTE_THESE_TOO to control quoting.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE.
|
||||
|
||||
This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG,
|
||||
ARGSIZE, O), except it breaks O into its component pieces and is
|
||||
not careful about errno. */
|
||||
|
||||
static size_t
|
||||
quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
enum quoting_style quoting_style, int flags,
|
||||
unsigned int const *quote_these_too)
|
||||
{
|
||||
size_t i;
|
||||
size_t len = 0;
|
||||
char const *quote_string = 0;
|
||||
size_t quote_string_len = 0;
|
||||
bool backslash_escapes = false;
|
||||
bool unibyte_locale = MB_CUR_MAX == 1;
|
||||
bool elide_outer_quotes = (flags & QA_ELIDE_OUTER_QUOTES) != 0;
|
||||
|
||||
#define STORE(c) \
|
||||
do \
|
||||
{ \
|
||||
if (len < buffersize) \
|
||||
buffer[len] = (c); \
|
||||
len++; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
switch (quoting_style)
|
||||
{
|
||||
case c_maybe_quoting_style:
|
||||
quoting_style = c_quoting_style;
|
||||
elide_outer_quotes = true;
|
||||
/* Fall through. */
|
||||
case c_quoting_style:
|
||||
if (!elide_outer_quotes)
|
||||
STORE ('"');
|
||||
backslash_escapes = true;
|
||||
quote_string = "\"";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
case escape_quoting_style:
|
||||
backslash_escapes = true;
|
||||
elide_outer_quotes = false;
|
||||
break;
|
||||
|
||||
case locale_quoting_style:
|
||||
case clocale_quoting_style:
|
||||
{
|
||||
/* TRANSLATORS:
|
||||
Get translations for open and closing quotation marks.
|
||||
|
||||
The message catalog should translate "`" to a left
|
||||
quotation mark suitable for the locale, and similarly for
|
||||
"'". If the catalog has no translation,
|
||||
locale_quoting_style quotes `like this', and
|
||||
clocale_quoting_style quotes "like this".
|
||||
|
||||
For example, an American English Unicode locale should
|
||||
translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and
|
||||
should translate "'" to U+201D (RIGHT DOUBLE QUOTATION
|
||||
MARK). A British English Unicode locale should instead
|
||||
translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and
|
||||
U+2019 (RIGHT SINGLE QUOTATION MARK), respectively.
|
||||
|
||||
If you don't know what to put here, please see
|
||||
<http://en.wikipedia.org/wiki/Quotation_mark#Glyphs>
|
||||
and use glyphs suitable for your language. */
|
||||
|
||||
char const *left = gettext_quote (N_("`"), quoting_style);
|
||||
char const *right = gettext_quote (N_("'"), quoting_style);
|
||||
if (!elide_outer_quotes)
|
||||
for (quote_string = left; *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
backslash_escapes = true;
|
||||
quote_string = right;
|
||||
quote_string_len = strlen (quote_string);
|
||||
}
|
||||
break;
|
||||
|
||||
case shell_quoting_style:
|
||||
quoting_style = shell_always_quoting_style;
|
||||
elide_outer_quotes = true;
|
||||
/* Fall through. */
|
||||
case shell_always_quoting_style:
|
||||
if (!elide_outer_quotes)
|
||||
STORE ('\'');
|
||||
quote_string = "'";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
case literal_quoting_style:
|
||||
elide_outer_quotes = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
for (i = 0; ! (argsize == SIZE_MAX ? arg[i] == '\0' : i == argsize); i++)
|
||||
{
|
||||
unsigned char c;
|
||||
unsigned char esc;
|
||||
|
||||
if (backslash_escapes
|
||||
&& quote_string_len
|
||||
&& i + quote_string_len <= argsize
|
||||
&& memcmp (arg + i, quote_string, quote_string_len) == 0)
|
||||
{
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\\');
|
||||
}
|
||||
|
||||
c = arg[i];
|
||||
switch (c)
|
||||
{
|
||||
case '\0':
|
||||
if (backslash_escapes)
|
||||
{
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\\');
|
||||
if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9')
|
||||
{
|
||||
STORE ('0');
|
||||
STORE ('0');
|
||||
}
|
||||
c = '0';
|
||||
}
|
||||
else if (flags & QA_ELIDE_NULL_BYTES)
|
||||
continue;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
switch (quoting_style)
|
||||
{
|
||||
case shell_always_quoting_style:
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
break;
|
||||
|
||||
case c_quoting_style:
|
||||
if ((flags & QA_SPLIT_TRIGRAPHS)
|
||||
&& i + 2 < argsize && arg[i + 1] == '?')
|
||||
switch (arg[i + 2])
|
||||
{
|
||||
case '!': case '\'':
|
||||
case '(': case ')': case '-': case '/':
|
||||
case '<': case '=': case '>':
|
||||
/* Escape the second '?' in what would otherwise be
|
||||
a trigraph. */
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
c = arg[i + 2];
|
||||
i += 2;
|
||||
STORE ('?');
|
||||
STORE ('"');
|
||||
STORE ('"');
|
||||
STORE ('?');
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '\a': esc = 'a'; goto c_escape;
|
||||
case '\b': esc = 'b'; goto c_escape;
|
||||
case '\f': esc = 'f'; goto c_escape;
|
||||
case '\n': esc = 'n'; goto c_and_shell_escape;
|
||||
case '\r': esc = 'r'; goto c_and_shell_escape;
|
||||
case '\t': esc = 't'; goto c_and_shell_escape;
|
||||
case '\v': esc = 'v'; goto c_escape;
|
||||
case '\\': esc = c;
|
||||
/* No need to escape the escape if we are trying to elide
|
||||
outer quotes and nothing else is problematic. */
|
||||
if (backslash_escapes && elide_outer_quotes && quote_string_len)
|
||||
goto store_c;
|
||||
|
||||
c_and_shell_escape:
|
||||
if (quoting_style == shell_always_quoting_style
|
||||
&& elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
/* Fall through. */
|
||||
c_escape:
|
||||
if (backslash_escapes)
|
||||
{
|
||||
c = esc;
|
||||
goto store_escape;
|
||||
}
|
||||
break;
|
||||
|
||||
case '{': case '}': /* sometimes special if isolated */
|
||||
if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1))
|
||||
break;
|
||||
/* Fall through. */
|
||||
case '#': case '~':
|
||||
if (i != 0)
|
||||
break;
|
||||
/* Fall through. */
|
||||
case ' ':
|
||||
case '!': /* special in bash */
|
||||
case '"': case '$': case '&':
|
||||
case '(': case ')': case '*': case ';':
|
||||
case '<':
|
||||
case '=': /* sometimes special in 0th or (with "set -k") later args */
|
||||
case '>': case '[':
|
||||
case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
|
||||
case '`': case '|':
|
||||
/* A shell special character. In theory, '$' and '`' could
|
||||
be the first bytes of multibyte characters, which means
|
||||
we should check them with mbrtowc, but in practice this
|
||||
doesn't happen so it's not worth worrying about. */
|
||||
if (quoting_style == shell_always_quoting_style
|
||||
&& elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
if (quoting_style == shell_always_quoting_style)
|
||||
{
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\'');
|
||||
STORE ('\\');
|
||||
STORE ('\'');
|
||||
}
|
||||
break;
|
||||
|
||||
case '%': case '+': case ',': case '-': case '.': case '/':
|
||||
case '0': case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9': case ':':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
|
||||
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
|
||||
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
|
||||
case 'Y': case 'Z': case ']': case '_': case 'a': case 'b':
|
||||
case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
|
||||
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
|
||||
case 'o': case 'p': case 'q': case 'r': case 's': case 't':
|
||||
case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
|
||||
/* These characters don't cause problems, no matter what the
|
||||
quoting style is. They cannot start multibyte sequences. */
|
||||
break;
|
||||
|
||||
default:
|
||||
/* If we have a multibyte sequence, copy it until we reach
|
||||
its end, find an error, or come back to the initial shift
|
||||
state. For C-like styles, if the sequence has
|
||||
unprintable characters, escape the whole sequence, since
|
||||
we can't easily escape single characters within it. */
|
||||
{
|
||||
/* Length of multibyte sequence found so far. */
|
||||
size_t m;
|
||||
|
||||
bool printable;
|
||||
|
||||
if (unibyte_locale)
|
||||
{
|
||||
m = 1;
|
||||
printable = isprint (c) != 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mbstate_t mbstate;
|
||||
memset (&mbstate, 0, sizeof mbstate);
|
||||
|
||||
m = 0;
|
||||
printable = true;
|
||||
if (argsize == SIZE_MAX)
|
||||
argsize = strlen (arg);
|
||||
|
||||
do
|
||||
{
|
||||
wchar_t w;
|
||||
size_t bytes = mbrtowc (&w, &arg[i + m],
|
||||
argsize - (i + m), &mbstate);
|
||||
if (bytes == 0)
|
||||
break;
|
||||
else if (bytes == (size_t) -1)
|
||||
{
|
||||
printable = false;
|
||||
break;
|
||||
}
|
||||
else if (bytes == (size_t) -2)
|
||||
{
|
||||
printable = false;
|
||||
while (i + m < argsize && arg[i + m])
|
||||
m++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Work around a bug with older shells that "see" a '\'
|
||||
that is really the 2nd byte of a multibyte character.
|
||||
In practice the problem is limited to ASCII
|
||||
chars >= '@' that are shell special chars. */
|
||||
if ('[' == 0x5b && elide_outer_quotes
|
||||
&& quoting_style == shell_always_quoting_style)
|
||||
{
|
||||
size_t j;
|
||||
for (j = 1; j < bytes; j++)
|
||||
switch (arg[i + m + j])
|
||||
{
|
||||
case '[': case '\\': case '^':
|
||||
case '`': case '|':
|
||||
goto force_outer_quoting_style;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! iswprint (w))
|
||||
printable = false;
|
||||
m += bytes;
|
||||
}
|
||||
}
|
||||
while (! mbsinit (&mbstate));
|
||||
}
|
||||
|
||||
if (1 < m || (backslash_escapes && ! printable))
|
||||
{
|
||||
/* Output a multibyte sequence, or an escaped
|
||||
unprintable unibyte character. */
|
||||
size_t ilim = i + m;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (backslash_escapes && ! printable)
|
||||
{
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\\');
|
||||
STORE ('0' + (c >> 6));
|
||||
STORE ('0' + ((c >> 3) & 7));
|
||||
c = '0' + (c & 7);
|
||||
}
|
||||
if (ilim <= i + 1)
|
||||
break;
|
||||
STORE (c);
|
||||
c = arg[++i];
|
||||
}
|
||||
|
||||
goto store_c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! ((backslash_escapes || elide_outer_quotes)
|
||||
&& quote_these_too
|
||||
&& quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))))
|
||||
goto store_c;
|
||||
|
||||
store_escape:
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\\');
|
||||
|
||||
store_c:
|
||||
STORE (c);
|
||||
}
|
||||
|
||||
if (len == 0 && quoting_style == shell_always_quoting_style
|
||||
&& elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
|
||||
if (quote_string && !elide_outer_quotes)
|
||||
for (; *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
|
||||
if (len < buffersize)
|
||||
buffer[len] = '\0';
|
||||
return len;
|
||||
|
||||
force_outer_quoting_style:
|
||||
/* Don't reuse quote_these_too, since the addition of outer quotes
|
||||
sufficiently quotes the specified characters. */
|
||||
return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||
quoting_style,
|
||||
flags & ~QA_ELIDE_OUTER_QUOTES, NULL);
|
||||
}
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is SIZE_MAX, use the string length of the argument for
|
||||
ARGSIZE. */
|
||||
size_t
|
||||
quotearg_buffer (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
struct quoting_options const *p = o ? o : &default_quoting_options;
|
||||
int e = errno;
|
||||
size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||
p->style, p->flags, p->quote_these_too);
|
||||
errno = e;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Equivalent to quotearg_alloc (ARG, ARGSIZE, NULL, O). */
|
||||
char *
|
||||
quotearg_alloc (char const *arg, size_t argsize,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
return quotearg_alloc_mem (arg, argsize, NULL, o);
|
||||
}
|
||||
|
||||
/* Like quotearg_buffer (..., ARG, ARGSIZE, O), except return newly
|
||||
allocated storage containing the quoted string, and store the
|
||||
resulting size into *SIZE, if non-NULL. The result can contain
|
||||
embedded null bytes only if ARGSIZE is not SIZE_MAX, SIZE is not
|
||||
NULL, and set_quoting_flags has not set the null byte elision
|
||||
flag. */
|
||||
char *
|
||||
quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
struct quoting_options const *p = o ? o : &default_quoting_options;
|
||||
int e = errno;
|
||||
/* Elide embedded null bytes if we can't return a size. */
|
||||
int flags = p->flags | (size ? 0 : QA_ELIDE_NULL_BYTES);
|
||||
size_t bufsize = quotearg_buffer_restyled (0, 0, arg, argsize, p->style,
|
||||
flags, p->quote_these_too) + 1;
|
||||
char *buf = xcharalloc (bufsize);
|
||||
quotearg_buffer_restyled (buf, bufsize, arg, argsize, p->style, flags,
|
||||
p->quote_these_too);
|
||||
errno = e;
|
||||
if (size)
|
||||
*size = bufsize - 1;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* A storage slot with size and pointer to a value. */
|
||||
struct slotvec
|
||||
{
|
||||
size_t size;
|
||||
char *val;
|
||||
};
|
||||
|
||||
/* Preallocate a slot 0 buffer, so that the caller can always quote
|
||||
one small component of a "memory exhausted" message in slot 0. */
|
||||
static char slot0[256];
|
||||
static unsigned int nslots = 1;
|
||||
static struct slotvec slotvec0 = {sizeof slot0, slot0};
|
||||
static struct slotvec *slotvec = &slotvec0;
|
||||
|
||||
void
|
||||
quotearg_free (void)
|
||||
{
|
||||
struct slotvec *sv = slotvec;
|
||||
unsigned int i;
|
||||
for (i = 1; i < nslots; i++)
|
||||
free (sv[i].val);
|
||||
if (sv[0].val != slot0)
|
||||
{
|
||||
free (sv[0].val);
|
||||
slotvec0.size = sizeof slot0;
|
||||
slotvec0.val = slot0;
|
||||
}
|
||||
if (sv != &slotvec0)
|
||||
{
|
||||
free (sv);
|
||||
slotvec = &slotvec0;
|
||||
}
|
||||
nslots = 1;
|
||||
}
|
||||
|
||||
/* Use storage slot N to return a quoted version of argument ARG.
|
||||
ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a
|
||||
null-terminated string.
|
||||
OPTIONS specifies the quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. N is deliberately declared with type "int"
|
||||
to allow for future extensions (using negative values). */
|
||||
static char *
|
||||
quotearg_n_options (int n, char const *arg, size_t argsize,
|
||||
struct quoting_options const *options)
|
||||
{
|
||||
int e = errno;
|
||||
|
||||
unsigned int n0 = n;
|
||||
struct slotvec *sv = slotvec;
|
||||
|
||||
if (n < 0)
|
||||
abort ();
|
||||
|
||||
if (nslots <= n0)
|
||||
{
|
||||
/* FIXME: technically, the type of n1 should be `unsigned int',
|
||||
but that evokes an unsuppressible warning from gcc-4.0.1 and
|
||||
older. If gcc ever provides an option to suppress that warning,
|
||||
revert to the original type, so that the test in xalloc_oversized
|
||||
is once again performed only at compile time. */
|
||||
size_t n1 = n0 + 1;
|
||||
bool preallocated = (sv == &slotvec0);
|
||||
|
||||
if (xalloc_oversized (n1, sizeof *sv))
|
||||
xalloc_die ();
|
||||
|
||||
slotvec = sv = xrealloc (preallocated ? NULL : sv, n1 * sizeof *sv);
|
||||
if (preallocated)
|
||||
*sv = slotvec0;
|
||||
memset (sv + nslots, 0, (n1 - nslots) * sizeof *sv);
|
||||
nslots = n1;
|
||||
}
|
||||
|
||||
{
|
||||
size_t size = sv[n].size;
|
||||
char *val = sv[n].val;
|
||||
/* Elide embedded null bytes since we don't return a size. */
|
||||
int flags = options->flags | QA_ELIDE_NULL_BYTES;
|
||||
size_t qsize = quotearg_buffer_restyled (val, size, arg, argsize,
|
||||
options->style, flags,
|
||||
options->quote_these_too);
|
||||
|
||||
if (size <= qsize)
|
||||
{
|
||||
sv[n].size = size = qsize + 1;
|
||||
if (val != slot0)
|
||||
free (val);
|
||||
sv[n].val = val = xcharalloc (size);
|
||||
quotearg_buffer_restyled (val, size, arg, argsize, options->style,
|
||||
flags, options->quote_these_too);
|
||||
}
|
||||
|
||||
errno = e;
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n (int n, char const *arg)
|
||||
{
|
||||
return quotearg_n_options (n, arg, SIZE_MAX, &default_quoting_options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_mem (int n, char const *arg, size_t argsize)
|
||||
{
|
||||
return quotearg_n_options (n, arg, argsize, &default_quoting_options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg (char const *arg)
|
||||
{
|
||||
return quotearg_n (0, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_mem (char const *arg, size_t argsize)
|
||||
{
|
||||
return quotearg_n_mem (0, arg, argsize);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style (int n, enum quoting_style s, char const *arg)
|
||||
{
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, SIZE_MAX, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style_mem (int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize)
|
||||
{
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, argsize, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_style (enum quoting_style s, char const *arg)
|
||||
{
|
||||
return quotearg_n_style (0, s, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_style_mem (enum quoting_style s, char const *arg, size_t argsize)
|
||||
{
|
||||
return quotearg_n_style_mem (0, s, arg, argsize);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_char_mem (char const *arg, size_t argsize, char ch)
|
||||
{
|
||||
struct quoting_options options;
|
||||
options = default_quoting_options;
|
||||
set_char_quoting (&options, ch, 1);
|
||||
return quotearg_n_options (0, arg, argsize, &options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_char (char const *arg, char ch)
|
||||
{
|
||||
return quotearg_char_mem (arg, SIZE_MAX, ch);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_colon (char const *arg)
|
||||
{
|
||||
return quotearg_char (arg, ':');
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_colon_mem (char const *arg, size_t argsize)
|
||||
{
|
||||
return quotearg_char_mem (arg, argsize, ':');
|
||||
}
|
||||
@ -1,305 +0,0 @@
|
||||
/* quotearg.h - quote arguments for output
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#ifndef QUOTEARG_H_
|
||||
# define QUOTEARG_H_ 1
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
/* Basic quoting styles. For each style, an example is given on the
|
||||
input strings "simple", "\0 \t\n'\"\033?""?/\\", and "a:b", using
|
||||
quotearg_buffer, quotearg_mem, and quotearg_colon_mem with that
|
||||
style and the default flags and quoted characters. Note that the
|
||||
examples are shown here as valid C strings rather than what
|
||||
displays on a terminal (with "??/" as a trigraph for "\\"). */
|
||||
enum quoting_style
|
||||
{
|
||||
/* Output names as-is (ls --quoting-style=literal). Can result in
|
||||
embedded null bytes if QA_ELIDE_NULL_BYTES is not in
|
||||
effect.
|
||||
|
||||
quotearg_buffer:
|
||||
"simple", "\0 \t\n'\"\033??/\\", "a:b"
|
||||
quotearg:
|
||||
"simple", " \t\n'\"\033??/\\", "a:b"
|
||||
quotearg_colon:
|
||||
"simple", " \t\n'\"\033??/\\", "a:b"
|
||||
*/
|
||||
literal_quoting_style,
|
||||
|
||||
/* Quote names for the shell if they contain shell metacharacters
|
||||
or would cause ambiguous output (ls --quoting-style=shell).
|
||||
Can result in embedded null bytes if QA_ELIDE_NULL_BYTES is not
|
||||
in effect.
|
||||
|
||||
quotearg_buffer:
|
||||
"simple", "'\0 \t\n'\\''\"\033??/\\'", "a:b"
|
||||
quotearg:
|
||||
"simple", "' \t\n'\\''\"\033??/\\'", "a:b"
|
||||
quotearg_colon:
|
||||
"simple", "' \t\n'\\''\"\033??/\\'", "'a:b'"
|
||||
*/
|
||||
shell_quoting_style,
|
||||
|
||||
/* Quote names for the shell, even if they would normally not
|
||||
require quoting (ls --quoting-style=shell-always). Can result
|
||||
in embedded null bytes if QA_ELIDE_NULL_BYTES is not in effect.
|
||||
Behaves like shell_quoting_style if QA_ELIDE_OUTER_QUOTES is in
|
||||
effect.
|
||||
|
||||
quotearg_buffer:
|
||||
"'simple'", "'\0 \t\n'\\''\"\033??/\\'", "'a:b'"
|
||||
quotearg:
|
||||
"'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'"
|
||||
quotearg_colon:
|
||||
"'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'"
|
||||
*/
|
||||
shell_always_quoting_style,
|
||||
|
||||
/* Quote names as for a C language string (ls --quoting-style=c).
|
||||
Behaves like c_maybe_quoting_style if QA_ELIDE_OUTER_QUOTES is
|
||||
in effect. Split into consecutive strings if
|
||||
QA_SPLIT_TRIGRAPHS.
|
||||
|
||||
quotearg_buffer:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
quotearg:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
quotearg_colon:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\""
|
||||
*/
|
||||
c_quoting_style,
|
||||
|
||||
/* Like c_quoting_style except omit the surrounding double-quote
|
||||
characters if no quoted characters are encountered.
|
||||
|
||||
quotearg_buffer:
|
||||
"simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
|
||||
quotearg:
|
||||
"simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
|
||||
quotearg_colon:
|
||||
"simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
*/
|
||||
c_maybe_quoting_style,
|
||||
|
||||
/* Like c_quoting_style except always omit the surrounding
|
||||
double-quote characters (ls --quoting-style=escape).
|
||||
|
||||
quotearg_buffer:
|
||||
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b"
|
||||
quotearg:
|
||||
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b"
|
||||
quotearg_colon:
|
||||
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a\\:b"
|
||||
*/
|
||||
escape_quoting_style,
|
||||
|
||||
/* Like clocale_quoting_style, but quote `like this' instead of
|
||||
"like this" in the default C locale (ls --quoting-style=locale).
|
||||
|
||||
LC_MESSAGES=C
|
||||
quotearg_buffer:
|
||||
"`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'"
|
||||
quotearg:
|
||||
"`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'"
|
||||
quotearg_colon:
|
||||
"`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a\\:b'"
|
||||
|
||||
LC_MESSAGES=pt_PT.utf8
|
||||
quotearg_buffer:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
|
||||
quotearg:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
|
||||
quotearg_colon:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273"
|
||||
*/
|
||||
locale_quoting_style,
|
||||
|
||||
/* Like c_quoting_style except use quotation marks appropriate for
|
||||
the locale (ls --quoting-style=clocale).
|
||||
|
||||
LC_MESSAGES=C
|
||||
quotearg_buffer:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
quotearg:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
quotearg_colon:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\""
|
||||
|
||||
LC_MESSAGES=pt_PT.utf8
|
||||
quotearg_buffer:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
|
||||
quotearg:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
|
||||
quotearg_colon:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273"
|
||||
*/
|
||||
clocale_quoting_style
|
||||
};
|
||||
|
||||
/* Flags for use in set_quoting_flags. */
|
||||
enum quoting_flags
|
||||
{
|
||||
/* Always elide null bytes from styles that do not quote them,
|
||||
even when the length of the result is available to the
|
||||
caller. */
|
||||
QA_ELIDE_NULL_BYTES = 0x01,
|
||||
|
||||
/* Omit the surrounding quote characters if no escaped characters
|
||||
are encountered. Note that if no other character needs
|
||||
escaping, then neither does the escape character. */
|
||||
QA_ELIDE_OUTER_QUOTES = 0x02,
|
||||
|
||||
/* In the c_quoting_style and c_maybe_quoting_style, split ANSI
|
||||
trigraph sequences into concatenated strings (for example,
|
||||
"?""?/" rather than "??/", which could be confused with
|
||||
"\\"). */
|
||||
QA_SPLIT_TRIGRAPHS = 0x04
|
||||
};
|
||||
|
||||
/* For now, --quoting-style=literal is the default, but this may change. */
|
||||
# ifndef DEFAULT_QUOTING_STYLE
|
||||
# define DEFAULT_QUOTING_STYLE literal_quoting_style
|
||||
# endif
|
||||
|
||||
/* Names of quoting styles and their corresponding values. */
|
||||
extern char const *const quoting_style_args[];
|
||||
extern enum quoting_style const quoting_style_vals[];
|
||||
|
||||
struct quoting_options;
|
||||
|
||||
/* The functions listed below set and use a hidden variable
|
||||
that contains the default quoting style options. */
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to the default if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *clone_quoting_options (struct quoting_options *o);
|
||||
|
||||
/* Get the value of O's quoting style. If O is null, use the default. */
|
||||
enum quoting_style get_quoting_style (struct quoting_options *o);
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting style to S. */
|
||||
void set_quoting_style (struct quoting_options *o, enum quoting_style s);
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int set_char_quoting (struct quoting_options *o, char c, int i);
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options flag to I, which can be a
|
||||
bitwise combination of enum quoting_flags, or 0 for default
|
||||
behavior. Return the old value. */
|
||||
int set_quoting_flags (struct quoting_options *o, int i);
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE.
|
||||
On output, BUFFER might contain embedded null bytes if ARGSIZE was
|
||||
not -1, the style of O does not use backslash escapes, and the
|
||||
flags of O do not request elision of null bytes.*/
|
||||
size_t quotearg_buffer (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o);
|
||||
|
||||
/* Like quotearg_buffer, except return the result in a newly allocated
|
||||
buffer. It is the caller's responsibility to free the result. The
|
||||
result will not contain embedded null bytes. */
|
||||
char *quotearg_alloc (char const *arg, size_t argsize,
|
||||
struct quoting_options const *o);
|
||||
|
||||
/* Like quotearg_alloc, except that the length of the result,
|
||||
excluding the terminating null byte, is stored into SIZE if it is
|
||||
non-NULL. The result might contain embedded null bytes if ARGSIZE
|
||||
was not -1, SIZE was not NULL, the style of O does not use
|
||||
backslash escapes, and the flags of O do not request elision of
|
||||
null bytes.*/
|
||||
char *quotearg_alloc_mem (char const *arg, size_t argsize,
|
||||
size_t *size, struct quoting_options const *o);
|
||||
|
||||
/* Use storage slot N to return a quoted version of the string ARG.
|
||||
Use the default quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. The output of all functions in the
|
||||
quotearg_n family are guaranteed to not contain embedded null
|
||||
bytes.*/
|
||||
char *quotearg_n (int n, char const *arg);
|
||||
|
||||
/* Equivalent to quotearg_n (0, ARG). */
|
||||
char *quotearg (char const *arg);
|
||||
|
||||
/* Use storage slot N to return a quoted version of the argument ARG
|
||||
of size ARGSIZE. This is like quotearg_n (N, ARG), except it can
|
||||
quote null bytes. */
|
||||
char *quotearg_n_mem (int n, char const *arg, size_t argsize);
|
||||
|
||||
/* Equivalent to quotearg_n_mem (0, ARG, ARGSIZE). */
|
||||
char *quotearg_mem (char const *arg, size_t argsize);
|
||||
|
||||
/* Use style S and storage slot N to return a quoted version of the string ARG.
|
||||
This is like quotearg_n (N, ARG), except that it uses S with no other
|
||||
options to specify the quoting method. */
|
||||
char *quotearg_n_style (int n, enum quoting_style s, char const *arg);
|
||||
|
||||
/* Use style S and storage slot N to return a quoted version of the
|
||||
argument ARG of size ARGSIZE. This is like quotearg_n_style
|
||||
(N, S, ARG), except it can quote null bytes. */
|
||||
char *quotearg_n_style_mem (int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize);
|
||||
|
||||
/* Equivalent to quotearg_n_style (0, S, ARG). */
|
||||
char *quotearg_style (enum quoting_style s, char const *arg);
|
||||
|
||||
/* Equivalent to quotearg_n_style_mem (0, S, ARG, ARGSIZE). */
|
||||
char *quotearg_style_mem (enum quoting_style s,
|
||||
char const *arg, size_t argsize);
|
||||
|
||||
/* Like quotearg (ARG), except also quote any instances of CH. */
|
||||
char *quotearg_char (char const *arg, char ch);
|
||||
|
||||
/* Like quotearg_char (ARG, CH), except it can quote null bytes. */
|
||||
char *quotearg_char_mem (char const *arg, size_t argsize, char ch);
|
||||
|
||||
/* Equivalent to quotearg_char (ARG, ':'). */
|
||||
char *quotearg_colon (char const *arg);
|
||||
|
||||
/* Like quotearg_colon (ARG), except it can quote null bytes. */
|
||||
char *quotearg_colon_mem (char const *arg, size_t argsize);
|
||||
|
||||
/* Free any dynamically allocated memory. */
|
||||
void quotearg_free (void);
|
||||
|
||||
#endif /* !QUOTEARG_H_ */
|
||||
@ -1,87 +0,0 @@
|
||||
/* realloc() function that is glibc compatible.
|
||||
|
||||
Copyright (C) 1997, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Jim Meyering and Bruno Haible */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */
|
||||
#ifdef realloc
|
||||
# define NEED_REALLOC_GNU 1
|
||||
#endif
|
||||
|
||||
/* Infer the properties of the system's malloc function.
|
||||
Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
|
||||
#if GNULIB_MALLOC_GNU && !defined malloc
|
||||
# define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1
|
||||
#endif
|
||||
|
||||
/* Below we want to call the system's malloc and realloc.
|
||||
Undefine the symbols here so that including <stdlib.h> provides a
|
||||
declaration of malloc(), not of rpl_malloc(), and likewise for realloc. */
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
|
||||
/* Specification. */
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* Below we want to call the system's malloc and realloc.
|
||||
Undefine the symbols, if they were defined by gnulib's <stdlib.h>
|
||||
replacement. */
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. If N is zero, change it to 1. If P is NULL,
|
||||
use malloc. */
|
||||
|
||||
void *
|
||||
rpl_realloc (void *p, size_t n)
|
||||
{
|
||||
void *result;
|
||||
|
||||
#if NEED_REALLOC_GNU
|
||||
if (n == 0)
|
||||
{
|
||||
n = 1;
|
||||
|
||||
/* In theory realloc might fail, so don't rely on it to free. */
|
||||
free (p);
|
||||
p = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
#if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
#endif
|
||||
result = malloc (n);
|
||||
}
|
||||
else
|
||||
result = realloc (p, n);
|
||||
|
||||
#if !HAVE_REALLOC_POSIX
|
||||
if (result == NULL)
|
||||
errno = ENOMEM;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
165
gl/lib/rename.c
165
gl/lib/rename.c
@ -1,165 +0,0 @@
|
||||
/* Work around rename bugs in some systems. On SunOS 4.1.1_U1
|
||||
and mips-dec-ultrix4.4, rename fails when the source file has
|
||||
a trailing slash. On mingw, rename fails when the destination
|
||||
exists.
|
||||
|
||||
Copyright (C) 2001, 2002, 2003, 2005, 2006, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Volker Borchert */
|
||||
|
||||
#include <config.h>
|
||||
#undef rename
|
||||
|
||||
#if RENAME_DEST_EXISTS_BUG
|
||||
/* This replacement must come first, otherwise when cross
|
||||
* compiling to Windows we will guess that it has the trailing
|
||||
* slash bug and entirely miss this one. */
|
||||
#include <errno.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
/* Rename the file SRC to DST. This replacement is necessary on
|
||||
Windows, on which the system rename function will not replace
|
||||
an existing DST. */
|
||||
int
|
||||
rpl_rename (char const *src, char const *dst)
|
||||
{
|
||||
int error;
|
||||
|
||||
/* MoveFileEx works if SRC is a directory without any flags,
|
||||
but fails with MOVEFILE_REPLACE_EXISTING, so try without
|
||||
flags first. */
|
||||
if (MoveFileEx (src, dst, 0))
|
||||
return 0;
|
||||
|
||||
/* Retry with MOVEFILE_REPLACE_EXISTING if the move failed
|
||||
* due to the destination already existing. */
|
||||
error = GetLastError ();
|
||||
if (error == ERROR_FILE_EXISTS || error == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
if (MoveFileEx (src, dst, MOVEFILE_REPLACE_EXISTING))
|
||||
return 0;
|
||||
|
||||
error = GetLastError ();
|
||||
}
|
||||
|
||||
switch (error)
|
||||
{
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
case ERROR_BAD_PATHNAME:
|
||||
case ERROR_DIRECTORY:
|
||||
errno = ENOENT;
|
||||
break;
|
||||
|
||||
case ERROR_ACCESS_DENIED:
|
||||
case ERROR_SHARING_VIOLATION:
|
||||
errno = EACCES;
|
||||
break;
|
||||
|
||||
case ERROR_OUTOFMEMORY:
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
|
||||
case ERROR_CURRENT_DIRECTORY:
|
||||
errno = EBUSY;
|
||||
break;
|
||||
|
||||
case ERROR_NOT_SAME_DEVICE:
|
||||
errno = EXDEV;
|
||||
break;
|
||||
|
||||
case ERROR_WRITE_PROTECT:
|
||||
errno = EROFS;
|
||||
break;
|
||||
|
||||
case ERROR_WRITE_FAULT:
|
||||
case ERROR_READ_FAULT:
|
||||
case ERROR_GEN_FAILURE:
|
||||
errno = EIO;
|
||||
break;
|
||||
|
||||
case ERROR_HANDLE_DISK_FULL:
|
||||
case ERROR_DISK_FULL:
|
||||
case ERROR_DISK_TOO_FRAGMENTED:
|
||||
errno = ENOSPC;
|
||||
break;
|
||||
|
||||
case ERROR_FILE_EXISTS:
|
||||
case ERROR_ALREADY_EXISTS:
|
||||
errno = EEXIST;
|
||||
break;
|
||||
|
||||
case ERROR_BUFFER_OVERFLOW:
|
||||
case ERROR_FILENAME_EXCED_RANGE:
|
||||
errno = ENAMETOOLONG;
|
||||
break;
|
||||
|
||||
case ERROR_INVALID_NAME:
|
||||
case ERROR_DELETE_PENDING:
|
||||
errno = EPERM; /* ? */
|
||||
break;
|
||||
|
||||
#ifndef ERROR_FILE_TOO_LARGE
|
||||
/* This value is documented but not defined in all versions of windows.h. */
|
||||
#define ERROR_FILE_TOO_LARGE 223
|
||||
#endif
|
||||
case ERROR_FILE_TOO_LARGE:
|
||||
errno = EFBIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
#elif RENAME_TRAILING_SLASH_BUG
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dirname.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
/* Rename the file SRC to DST, removing any trailing
|
||||
slashes from SRC. Needed for SunOS 4.1.1_U1. */
|
||||
|
||||
int
|
||||
rpl_rename (char const *src, char const *dst)
|
||||
{
|
||||
char *src_temp;
|
||||
int ret_val;
|
||||
size_t s_len = strlen (src);
|
||||
|
||||
if (s_len && src[s_len - 1] == '/')
|
||||
{
|
||||
src_temp = xstrdup (src);
|
||||
strip_trailing_slashes (src_temp);
|
||||
}
|
||||
else
|
||||
src_temp = (char *) src;
|
||||
|
||||
ret_val = rename (src_temp, dst);
|
||||
|
||||
if (src_temp != src)
|
||||
free (src_temp);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
#endif /* RENAME_TRAILING_SLASH_BUG */
|
||||
@ -1,77 +0,0 @@
|
||||
/* An interface to read and write that retries after interrupts.
|
||||
|
||||
Copyright (C) 1993, 1994, 1998, 2002, 2003, 2004, 2005, 2006 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#ifdef SAFE_WRITE
|
||||
# include "safe-write.h"
|
||||
#else
|
||||
# include "safe-read.h"
|
||||
#endif
|
||||
|
||||
/* Get ssize_t. */
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef EINTR
|
||||
# define IS_EINTR(x) ((x) == EINTR)
|
||||
#else
|
||||
# define IS_EINTR(x) 0
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef SAFE_WRITE
|
||||
# define safe_rw safe_write
|
||||
# define rw write
|
||||
#else
|
||||
# define safe_rw safe_read
|
||||
# define rw read
|
||||
# undef const
|
||||
# define const /* empty */
|
||||
#endif
|
||||
|
||||
/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if
|
||||
interrupted. Return the actual number of bytes read(written), zero for EOF,
|
||||
or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error. */
|
||||
size_t
|
||||
safe_rw (int fd, void const *buf, size_t count)
|
||||
{
|
||||
/* Work around a bug in Tru64 5.1. Attempting to read more than
|
||||
INT_MAX bytes fails with errno == EINVAL. See
|
||||
<http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>.
|
||||
When decreasing COUNT, keep it block-aligned. */
|
||||
enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ssize_t result = rw (fd, buf, count);
|
||||
|
||||
if (0 <= result)
|
||||
return result;
|
||||
else if (IS_EINTR (errno))
|
||||
continue;
|
||||
else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
|
||||
count = BUGGY_READ_MAXIMUM;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
/* An interface to write that retries after interrupts.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#define SAFE_WRITE
|
||||
#include "safe-read.c"
|
||||
@ -1,24 +0,0 @@
|
||||
/* An interface to write() that retries after interrupts.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define SAFE_WRITE_ERROR ((size_t) -1)
|
||||
|
||||
/* Write up to COUNT bytes at BUF to descriptor FD, retrying if interrupted.
|
||||
Return the actual number of bytes written, zero for EOF, or SAFE_WRITE_ERROR
|
||||
upon error. */
|
||||
extern size_t safe_write (int fd, const void *buf, size_t count);
|
||||
@ -1,119 +0,0 @@
|
||||
/* Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _GL_STDBOOL_H
|
||||
#define _GL_STDBOOL_H
|
||||
|
||||
/* ISO C 99 <stdbool.h> for platforms that lack it. */
|
||||
|
||||
/* Usage suggestions:
|
||||
|
||||
Programs that use <stdbool.h> should be aware of some limitations
|
||||
and standards compliance issues.
|
||||
|
||||
Standards compliance:
|
||||
|
||||
- <stdbool.h> must be #included before 'bool', 'false', 'true'
|
||||
can be used.
|
||||
|
||||
- You cannot assume that sizeof (bool) == 1.
|
||||
|
||||
- Programs should not undefine the macros bool, true, and false,
|
||||
as C99 lists that as an "obsolescent feature".
|
||||
|
||||
Limitations of this substitute, when used in a C89 environment:
|
||||
|
||||
- <stdbool.h> must be #included before the '_Bool' type can be used.
|
||||
|
||||
- You cannot assume that _Bool is a typedef; it might be a macro.
|
||||
|
||||
- Bit-fields of type 'bool' are not supported. Portable code
|
||||
should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
|
||||
|
||||
- In C99, casts and automatic conversions to '_Bool' or 'bool' are
|
||||
performed in such a way that every nonzero value gets converted
|
||||
to 'true', and zero gets converted to 'false'. This doesn't work
|
||||
with this substitute. With this substitute, only the values 0 and 1
|
||||
give the expected result when converted to _Bool' or 'bool'.
|
||||
|
||||
Also, it is suggested that programs use 'bool' rather than '_Bool';
|
||||
this isn't required, but 'bool' is more common. */
|
||||
|
||||
|
||||
/* 7.16. Boolean type and values */
|
||||
|
||||
/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
|
||||
definitions below, but temporarily we have to #undef them. */
|
||||
#if defined __BEOS__ && !defined __HAIKU__
|
||||
# include <OS.h> /* defines bool but not _Bool */
|
||||
# undef false
|
||||
# undef true
|
||||
#endif
|
||||
|
||||
/* For the sake of symbolic names in gdb, we define true and false as
|
||||
enum constants, not only as macros.
|
||||
It is tempting to write
|
||||
typedef enum { false = 0, true = 1 } _Bool;
|
||||
so that gdb prints values of type 'bool' symbolically. But if we do
|
||||
this, values of type '_Bool' may promote to 'int' or 'unsigned int'
|
||||
(see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
|
||||
(see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
|
||||
enum; this ensures that '_Bool' promotes to 'int'. */
|
||||
#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
|
||||
/* A compiler known to have 'bool'. */
|
||||
/* If the compiler already has both 'bool' and '_Bool', we can assume they
|
||||
are the same types. */
|
||||
# if !@HAVE__BOOL@
|
||||
typedef bool _Bool;
|
||||
# endif
|
||||
#else
|
||||
# if !defined __GNUC__
|
||||
/* If @HAVE__BOOL@:
|
||||
Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
|
||||
the built-in _Bool type is used. See
|
||||
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
|
||||
Similar bugs are likely with other compilers as well; this file
|
||||
wouldn't be used if <stdbool.h> was working.
|
||||
So we override the _Bool type.
|
||||
If !@HAVE__BOOL@:
|
||||
Need to define _Bool ourselves. As 'signed char' or as an enum type?
|
||||
Use of a typedef, with SunPRO C, leads to a stupid
|
||||
"warning: _Bool is a keyword in ISO C99".
|
||||
Use of an enum type, with IRIX cc, leads to a stupid
|
||||
"warning(1185): enumerated type mixed with another type".
|
||||
Even the existence of an enum type, without a typedef,
|
||||
"Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
|
||||
The only benefit of the enum, debuggability, is not important
|
||||
with these compilers. So use 'signed char' and no enum. */
|
||||
# define _Bool signed char
|
||||
# else
|
||||
/* With this compiler, trust the _Bool type if the compiler has it. */
|
||||
# if !@HAVE__BOOL@
|
||||
typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#define bool _Bool
|
||||
|
||||
/* The other macros must be usable in preprocessor directives. */
|
||||
#define false 0
|
||||
#define true 1
|
||||
#define __bool_true_false_are_defined 1
|
||||
|
||||
#endif /* _GL_STDBOOL_H */
|
||||
@ -1,63 +0,0 @@
|
||||
/* Case-insensitive string comparison function.
|
||||
Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <string.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
|
||||
|
||||
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
|
||||
greater than zero if S1 is lexicographically less than, equal to or greater
|
||||
than S2.
|
||||
Note: This function does not work with multibyte strings! */
|
||||
|
||||
int
|
||||
strcasecmp (const char *s1, const char *s2)
|
||||
{
|
||||
const unsigned char *p1 = (const unsigned char *) s1;
|
||||
const unsigned char *p2 = (const unsigned char *) s2;
|
||||
unsigned char c1, c2;
|
||||
|
||||
if (p1 == p2)
|
||||
return 0;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = TOLOWER (*p1);
|
||||
c2 = TOLOWER (*p2);
|
||||
|
||||
if (c1 == '\0')
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
}
|
||||
while (c1 == c2);
|
||||
|
||||
if (UCHAR_MAX <= INT_MAX)
|
||||
return c1 - c2;
|
||||
else
|
||||
/* On machines where 'char' and 'int' are types of the same size, the
|
||||
difference of two 'unsigned char' values - including the sign bit -
|
||||
doesn't fit in an 'int'. */
|
||||
return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
/* stripslash.c -- remove redundant trailing slashes from a file name
|
||||
|
||||
Copyright (C) 1990, 2001, 2003-2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
/* Remove trailing slashes from FILE. Return true if a trailing slash
|
||||
was removed. This is useful when using file name completion from a
|
||||
shell that adds a "/" after directory names (such as tcsh and
|
||||
bash), because on symlinks to directories, several system calls
|
||||
have different semantics according to whether a trailing slash is
|
||||
present. */
|
||||
|
||||
bool
|
||||
strip_trailing_slashes (char *file)
|
||||
{
|
||||
char *base = last_component (file);
|
||||
char *base_lim;
|
||||
bool had_slash;
|
||||
|
||||
/* last_component returns "" for file system roots, but we need to turn
|
||||
`///' into `/'. */
|
||||
if (! *base)
|
||||
base = file;
|
||||
base_lim = base + base_len (base);
|
||||
had_slash = (*base_lim != '\0');
|
||||
*base_lim = '\0';
|
||||
return had_slash;
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
/* strncasecmp.c -- case insensitive string comparator
|
||||
Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <string.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
|
||||
|
||||
/* Compare no more than N bytes of strings S1 and S2, ignoring case,
|
||||
returning less than, equal to or greater than zero if S1 is
|
||||
lexicographically less than, equal to or greater than S2.
|
||||
Note: This function cannot work correctly in multibyte locales. */
|
||||
|
||||
int
|
||||
strncasecmp (const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
register const unsigned char *p1 = (const unsigned char *) s1;
|
||||
register const unsigned char *p2 = (const unsigned char *) s2;
|
||||
unsigned char c1, c2;
|
||||
|
||||
if (p1 == p2 || n == 0)
|
||||
return 0;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = TOLOWER (*p1);
|
||||
c2 = TOLOWER (*p2);
|
||||
|
||||
if (--n == 0 || c1 == '\0')
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
}
|
||||
while (c1 == c2);
|
||||
|
||||
if (UCHAR_MAX <= INT_MAX)
|
||||
return c1 - c2;
|
||||
else
|
||||
/* On machines where 'char' and 'int' are types of the same size, the
|
||||
difference of two 'unsigned char' values - including the sign bit -
|
||||
doesn't fit in an 'int'. */
|
||||
return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
/* A replacement function, for systems that lack strndup.
|
||||
|
||||
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006, 2007
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef HAVE_DECL_STRNLEN
|
||||
extern size_t strnlen (const char *, size_t);
|
||||
#endif
|
||||
|
||||
char *
|
||||
strndup (char const *s, size_t n)
|
||||
{
|
||||
size_t len = strnlen (s, n);
|
||||
char *new = malloc (len + 1);
|
||||
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
|
||||
new[len] = '\0';
|
||||
return memcpy (new, s, len);
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||
Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
Written by Simon Josefsson.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||
If no '\0' terminator is found in that many characters, return MAXLEN. */
|
||||
|
||||
size_t
|
||||
strnlen (const char *string, size_t maxlen)
|
||||
{
|
||||
const char *end = memchr (string, '\0', maxlen);
|
||||
return end ? (size_t) (end - string) : maxlen;
|
||||
}
|
||||
@ -1,136 +0,0 @@
|
||||
/* Prefer faster, non-thread-safe stdio functions if available.
|
||||
|
||||
Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#ifndef UNLOCKED_IO_H
|
||||
# define UNLOCKED_IO_H 1
|
||||
|
||||
/* These are wrappers for functions/macros from the GNU C library, and
|
||||
from other C libraries supporting POSIX's optional thread-safe functions.
|
||||
|
||||
The standard I/O functions are thread-safe. These *_unlocked ones are
|
||||
more efficient but not thread-safe. That they're not thread-safe is
|
||||
fine since all of the applications in this package are single threaded.
|
||||
|
||||
Also, some code that is shared with the GNU C library may invoke
|
||||
the *_unlocked functions directly. On hosts that lack those
|
||||
functions, invoke the non-thread-safe versions instead. */
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
# if HAVE_DECL_CLEARERR_UNLOCKED
|
||||
# undef clearerr
|
||||
# define clearerr(x) clearerr_unlocked (x)
|
||||
# else
|
||||
# define clearerr_unlocked(x) clearerr (x)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_FEOF_UNLOCKED
|
||||
# undef feof
|
||||
# define feof(x) feof_unlocked (x)
|
||||
# else
|
||||
# define feof_unlocked(x) feof (x)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_FERROR_UNLOCKED
|
||||
# undef ferror
|
||||
# define ferror(x) ferror_unlocked (x)
|
||||
# else
|
||||
# define ferror_unlocked(x) ferror (x)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_FFLUSH_UNLOCKED
|
||||
# undef fflush
|
||||
# define fflush(x) fflush_unlocked (x)
|
||||
# else
|
||||
# define fflush_unlocked(x) fflush (x)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_FGETS_UNLOCKED
|
||||
# undef fgets
|
||||
# define fgets(x,y,z) fgets_unlocked (x,y,z)
|
||||
# else
|
||||
# define fgets_unlocked(x,y,z) fgets (x,y,z)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_FPUTC_UNLOCKED
|
||||
# undef fputc
|
||||
# define fputc(x,y) fputc_unlocked (x,y)
|
||||
# else
|
||||
# define fputc_unlocked(x,y) fputc (x,y)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_FPUTS_UNLOCKED
|
||||
# undef fputs
|
||||
# define fputs(x,y) fputs_unlocked (x,y)
|
||||
# else
|
||||
# define fputs_unlocked(x,y) fputs (x,y)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_FREAD_UNLOCKED
|
||||
# undef fread
|
||||
# define fread(w,x,y,z) fread_unlocked (w,x,y,z)
|
||||
# else
|
||||
# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_FWRITE_UNLOCKED
|
||||
# undef fwrite
|
||||
# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
|
||||
# else
|
||||
# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_GETC_UNLOCKED
|
||||
# undef getc
|
||||
# define getc(x) getc_unlocked (x)
|
||||
# else
|
||||
# define getc_unlocked(x) getc (x)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_GETCHAR_UNLOCKED
|
||||
# undef getchar
|
||||
# define getchar() getchar_unlocked ()
|
||||
# else
|
||||
# define getchar_unlocked() getchar ()
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_PUTC_UNLOCKED
|
||||
# undef putc
|
||||
# define putc(x,y) putc_unlocked (x,y)
|
||||
# else
|
||||
# define putc_unlocked(x,y) putc (x,y)
|
||||
# endif
|
||||
|
||||
# if HAVE_DECL_PUTCHAR_UNLOCKED
|
||||
# undef putchar
|
||||
# define putchar(x) putchar_unlocked (x)
|
||||
# else
|
||||
# define putchar_unlocked(x) putchar (x)
|
||||
# endif
|
||||
|
||||
# undef flockfile
|
||||
# define flockfile(x) ((void) 0)
|
||||
|
||||
# undef ftrylockfile
|
||||
# define ftrylockfile(x) 0
|
||||
|
||||
# undef funlockfile
|
||||
# define funlockfile(x) ((void) 0)
|
||||
|
||||
#endif /* UNLOCKED_IO_H */
|
||||
140
gl/lib/verify.h
140
gl/lib/verify.h
@ -1,140 +0,0 @@
|
||||
/* Compile-time assert-like macros.
|
||||
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
|
||||
|
||||
#ifndef VERIFY_H
|
||||
# define VERIFY_H 1
|
||||
|
||||
/* Each of these macros verifies that its argument R is nonzero. To
|
||||
be portable, R should be an integer constant expression. Unlike
|
||||
assert (R), there is no run-time overhead.
|
||||
|
||||
There are two macros, since no single macro can be used in all
|
||||
contexts in C. verify_true (R) is for scalar contexts, including
|
||||
integer constant expression contexts. verify (R) is for declaration
|
||||
contexts, e.g., the top level.
|
||||
|
||||
Symbols ending in "__" are private to this header.
|
||||
|
||||
The code below uses several ideas.
|
||||
|
||||
* The first step is ((R) ? 1 : -1). Given an expression R, of
|
||||
integral or boolean or floating-point type, this yields an
|
||||
expression of integral type, whose value is later verified to be
|
||||
constant and nonnegative.
|
||||
|
||||
* Next this expression W is wrapped in a type
|
||||
struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
|
||||
If W is negative, this yields a compile-time error. No compiler can
|
||||
deal with a bit-field of negative size.
|
||||
|
||||
One might think that an array size check would have the same
|
||||
effect, that is, that the type struct { unsigned int dummy[W]; }
|
||||
would work as well. However, inside a function, some compilers
|
||||
(such as C++ compilers and GNU C) allow local parameters and
|
||||
variables inside array size expressions. With these compilers,
|
||||
an array size check would not properly diagnose this misuse of
|
||||
the verify macro:
|
||||
|
||||
void function (int n) { verify (n < 0); }
|
||||
|
||||
* For the verify macro, the struct verify_type__ will need to
|
||||
somehow be embedded into a declaration. To be portable, this
|
||||
declaration must declare an object, a constant, a function, or a
|
||||
typedef name. If the declared entity uses the type directly,
|
||||
such as in
|
||||
|
||||
struct dummy {...};
|
||||
typedef struct {...} dummy;
|
||||
extern struct {...} *dummy;
|
||||
extern void dummy (struct {...} *);
|
||||
extern struct {...} *dummy (void);
|
||||
|
||||
two uses of the verify macro would yield colliding declarations
|
||||
if the entity names are not disambiguated. A workaround is to
|
||||
attach the current line number to the entity name:
|
||||
|
||||
#define GL_CONCAT0(x, y) x##y
|
||||
#define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
|
||||
extern struct {...} * GL_CONCAT(dummy,__LINE__);
|
||||
|
||||
But this has the problem that two invocations of verify from
|
||||
within the same macro would collide, since the __LINE__ value
|
||||
would be the same for both invocations.
|
||||
|
||||
A solution is to use the sizeof operator. It yields a number,
|
||||
getting rid of the identity of the type. Declarations like
|
||||
|
||||
extern int dummy [sizeof (struct {...})];
|
||||
extern void dummy (int [sizeof (struct {...})]);
|
||||
extern int (*dummy (void)) [sizeof (struct {...})];
|
||||
|
||||
can be repeated.
|
||||
|
||||
* Should the implementation use a named struct or an unnamed struct?
|
||||
Which of the following alternatives can be used?
|
||||
|
||||
extern int dummy [sizeof (struct {...})];
|
||||
extern int dummy [sizeof (struct verify_type__ {...})];
|
||||
extern void dummy (int [sizeof (struct {...})]);
|
||||
extern void dummy (int [sizeof (struct verify_type__ {...})]);
|
||||
extern int (*dummy (void)) [sizeof (struct {...})];
|
||||
extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
|
||||
|
||||
In the second and sixth case, the struct type is exported to the
|
||||
outer scope; two such declarations therefore collide. GCC warns
|
||||
about the first, third, and fourth cases. So the only remaining
|
||||
possibility is the fifth case:
|
||||
|
||||
extern int (*dummy (void)) [sizeof (struct {...})];
|
||||
|
||||
* This implementation exploits the fact that GCC does not warn about
|
||||
the last declaration mentioned above. If a future version of GCC
|
||||
introduces a warning for this, the problem could be worked around
|
||||
by using code specialized to GCC, e.g.,:
|
||||
|
||||
#if 4 <= __GNUC__
|
||||
# define verify(R) \
|
||||
extern int (* verify_function__ (void)) \
|
||||
[__builtin_constant_p (R) && (R) ? 1 : -1]
|
||||
#endif
|
||||
|
||||
* In C++, any struct definition inside sizeof is invalid.
|
||||
Use a template type to work around the problem. */
|
||||
|
||||
|
||||
/* Verify requirement R at compile-time, as an integer constant expression.
|
||||
Return 1. */
|
||||
|
||||
# ifdef __cplusplus
|
||||
template <int w>
|
||||
struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
|
||||
# define verify_true(R) \
|
||||
(!!sizeof (verify_type__<(R) ? 1 : -1>))
|
||||
# else
|
||||
# define verify_true(R) \
|
||||
(!!sizeof \
|
||||
(struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
|
||||
# endif
|
||||
|
||||
/* Verify requirement R at compile-time, as a declaration without a
|
||||
trailing ';'. */
|
||||
|
||||
# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)]
|
||||
|
||||
#endif
|
||||
280
gl/lib/xalloc.h
280
gl/lib/xalloc.h
@ -1,280 +0,0 @@
|
||||
/* xalloc.h -- malloc with out-of-memory checking
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef XALLOC_H_
|
||||
# define XALLOC_H_
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_MALLOC
|
||||
# if __GNUC__ >= 3
|
||||
# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
||||
# else
|
||||
# define ATTRIBUTE_MALLOC
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* This function is always triggered when memory is exhausted.
|
||||
It must be defined by the application, either explicitly
|
||||
or by using gnulib's xalloc-die module. This is the
|
||||
function to call when one wants the program to die because of a
|
||||
memory allocation failure. */
|
||||
extern void xalloc_die (void) ATTRIBUTE_NORETURN;
|
||||
|
||||
void *xmalloc (size_t s) ATTRIBUTE_MALLOC;
|
||||
void *xzalloc (size_t s) ATTRIBUTE_MALLOC;
|
||||
void *xcalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
|
||||
void *xrealloc (void *p, size_t s);
|
||||
void *x2realloc (void *p, size_t *pn);
|
||||
void *xmemdup (void const *p, size_t s) ATTRIBUTE_MALLOC;
|
||||
char *xstrdup (char const *str) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Return 1 if an array of N objects, each of size S, cannot exist due
|
||||
to size arithmetic overflow. S must be positive and N must be
|
||||
nonnegative. This is a macro, not an inline function, so that it
|
||||
works correctly even when SIZE_MAX < N.
|
||||
|
||||
By gnulib convention, SIZE_MAX represents overflow in size
|
||||
calculations, so the conservative dividend to use here is
|
||||
SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
|
||||
However, malloc (SIZE_MAX) fails on all known hosts where
|
||||
sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
|
||||
exactly-SIZE_MAX allocations on such hosts; this avoids a test and
|
||||
branch when S is known to be 1. */
|
||||
# define xalloc_oversized(n, s) \
|
||||
((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
|
||||
|
||||
|
||||
/* In the following macros, T must be an elementary or structure/union or
|
||||
typedef'ed type, or a pointer to such a type. To apply one of the
|
||||
following macros to a function pointer or array type, you need to typedef
|
||||
it first and use the typedef name. */
|
||||
|
||||
/* Allocate an object of type T dynamically, with error checking. */
|
||||
/* extern t *XMALLOC (typename t); */
|
||||
# define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
|
||||
|
||||
/* Allocate memory for N elements of type T, with error checking. */
|
||||
/* extern t *XNMALLOC (size_t n, typename t); */
|
||||
# define XNMALLOC(n, t) \
|
||||
((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
|
||||
|
||||
/* Allocate an object of type T dynamically, with error checking,
|
||||
and zero it. */
|
||||
/* extern t *XZALLOC (typename t); */
|
||||
# define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
|
||||
|
||||
/* Allocate memory for N elements of type T, with error checking,
|
||||
and zero it. */
|
||||
/* extern t *XCALLOC (size_t n, typename t); */
|
||||
# define XCALLOC(n, t) \
|
||||
((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
|
||||
|
||||
|
||||
# if HAVE_INLINE
|
||||
# define static_inline static inline
|
||||
# else
|
||||
void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
|
||||
void *xnrealloc (void *p, size_t n, size_t s);
|
||||
void *x2nrealloc (void *p, size_t *pn, size_t s);
|
||||
char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
|
||||
# endif
|
||||
|
||||
# ifdef static_inline
|
||||
|
||||
/* Allocate an array of N objects, each with S bytes of memory,
|
||||
dynamically, with error checking. S must be nonzero. */
|
||||
|
||||
static_inline void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
|
||||
static_inline void *
|
||||
xnmalloc (size_t n, size_t s)
|
||||
{
|
||||
if (xalloc_oversized (n, s))
|
||||
xalloc_die ();
|
||||
return xmalloc (n * s);
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to an array of N
|
||||
objects each of S bytes, with error checking. S must be nonzero. */
|
||||
|
||||
static_inline void *
|
||||
xnrealloc (void *p, size_t n, size_t s)
|
||||
{
|
||||
if (xalloc_oversized (n, s))
|
||||
xalloc_die ();
|
||||
return xrealloc (p, n * s);
|
||||
}
|
||||
|
||||
/* If P is null, allocate a block of at least *PN such objects;
|
||||
otherwise, reallocate P so that it contains more than *PN objects
|
||||
each of S bytes. *PN must be nonzero unless P is null, and S must
|
||||
be nonzero. Set *PN to the new number of objects, and return the
|
||||
pointer to the new block. *PN is never set to zero, and the
|
||||
returned pointer is never null.
|
||||
|
||||
Repeated reallocations are guaranteed to make progress, either by
|
||||
allocating an initial block with a nonzero size, or by allocating a
|
||||
larger block.
|
||||
|
||||
In the following implementation, nonzero sizes are increased by a
|
||||
factor of approximately 1.5 so that repeated reallocations have
|
||||
O(N) overall cost rather than O(N**2) cost, but the
|
||||
specification for this function does not guarantee that rate.
|
||||
|
||||
Here is an example of use:
|
||||
|
||||
int *p = NULL;
|
||||
size_t used = 0;
|
||||
size_t allocated = 0;
|
||||
|
||||
void
|
||||
append_int (int value)
|
||||
{
|
||||
if (used == allocated)
|
||||
p = x2nrealloc (p, &allocated, sizeof *p);
|
||||
p[used++] = value;
|
||||
}
|
||||
|
||||
This causes x2nrealloc to allocate a block of some nonzero size the
|
||||
first time it is called.
|
||||
|
||||
To have finer-grained control over the initial size, set *PN to a
|
||||
nonzero value before calling this function with P == NULL. For
|
||||
example:
|
||||
|
||||
int *p = NULL;
|
||||
size_t used = 0;
|
||||
size_t allocated = 0;
|
||||
size_t allocated1 = 1000;
|
||||
|
||||
void
|
||||
append_int (int value)
|
||||
{
|
||||
if (used == allocated)
|
||||
{
|
||||
p = x2nrealloc (p, &allocated1, sizeof *p);
|
||||
allocated = allocated1;
|
||||
}
|
||||
p[used++] = value;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
static_inline void *
|
||||
x2nrealloc (void *p, size_t *pn, size_t s)
|
||||
{
|
||||
size_t n = *pn;
|
||||
|
||||
if (! p)
|
||||
{
|
||||
if (! n)
|
||||
{
|
||||
/* The approximate size to use for initial small allocation
|
||||
requests, when the invoking code specifies an old size of
|
||||
zero. 64 bytes is the largest "small" request for the
|
||||
GNU C library malloc. */
|
||||
enum { DEFAULT_MXFAST = 64 };
|
||||
|
||||
n = DEFAULT_MXFAST / s;
|
||||
n += !n;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set N = ceil (1.5 * N) so that progress is made if N == 1.
|
||||
Check for overflow, so that N * S stays in size_t range.
|
||||
The check is slightly conservative, but an exact check isn't
|
||||
worth the trouble. */
|
||||
if ((size_t) -1 / 3 * 2 / s <= n)
|
||||
xalloc_die ();
|
||||
n += (n + 1) / 2;
|
||||
}
|
||||
|
||||
*pn = n;
|
||||
return xrealloc (p, n * s);
|
||||
}
|
||||
|
||||
/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
|
||||
except it returns char *. */
|
||||
|
||||
static_inline char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
|
||||
static_inline char *
|
||||
xcharalloc (size_t n)
|
||||
{
|
||||
return XNMALLOC (n, char);
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
|
||||
/* C++ does not allow conversions from void * to other pointer types
|
||||
without a cast. Use templates to work around the problem when
|
||||
possible. */
|
||||
|
||||
template <typename T> inline T *
|
||||
xrealloc (T *p, size_t s)
|
||||
{
|
||||
return (T *) xrealloc ((void *) p, s);
|
||||
}
|
||||
|
||||
template <typename T> inline T *
|
||||
xnrealloc (T *p, size_t n, size_t s)
|
||||
{
|
||||
return (T *) xnrealloc ((void *) p, n, s);
|
||||
}
|
||||
|
||||
template <typename T> inline T *
|
||||
x2realloc (T *p, size_t *pn)
|
||||
{
|
||||
return (T *) x2realloc ((void *) p, pn);
|
||||
}
|
||||
|
||||
template <typename T> inline T *
|
||||
x2nrealloc (T *p, size_t *pn, size_t s)
|
||||
{
|
||||
return (T *) x2nrealloc ((void *) p, pn, s);
|
||||
}
|
||||
|
||||
template <typename T> inline T *
|
||||
xmemdup (T const *p, size_t s)
|
||||
{
|
||||
return (T *) xmemdup ((void const *) p, s);
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
#endif /* !XALLOC_H_ */
|
||||
118
gl/lib/xmalloc.c
118
gl/lib/xmalloc.c
@ -1,118 +0,0 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2002, 2003, 2004, 2005, 2006, 2008-2009 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if ! HAVE_INLINE
|
||||
# define static_inline
|
||||
#endif
|
||||
#include "xalloc.h"
|
||||
#undef static_inline
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* 1 if calloc is known to be compatible with GNU calloc. This
|
||||
matters if we are not also using the calloc module, which defines
|
||||
HAVE_CALLOC and supports the GNU API even on non-GNU platforms. */
|
||||
#if defined HAVE_CALLOC || defined __GLIBC__
|
||||
enum { HAVE_GNU_CALLOC = 1 };
|
||||
#else
|
||||
enum { HAVE_GNU_CALLOC = 0 };
|
||||
#endif
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
void *
|
||||
xmalloc (size_t n)
|
||||
{
|
||||
void *p = malloc (n);
|
||||
if (!p && n != 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. */
|
||||
|
||||
void *
|
||||
xrealloc (void *p, size_t n)
|
||||
{
|
||||
p = realloc (p, n);
|
||||
if (!p && n != 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* If P is null, allocate a block of at least *PN bytes; otherwise,
|
||||
reallocate P so that it contains more than *PN bytes. *PN must be
|
||||
nonzero unless P is null. Set *PN to the new block's size, and
|
||||
return the pointer to the new block. *PN is never set to zero, and
|
||||
the returned pointer is never null. */
|
||||
|
||||
void *
|
||||
x2realloc (void *p, size_t *pn)
|
||||
{
|
||||
return x2nrealloc (p, pn, 1);
|
||||
}
|
||||
|
||||
/* Allocate S bytes of zeroed memory dynamically, with error checking.
|
||||
There's no need for xnzalloc (N, S), since it would be equivalent
|
||||
to xcalloc (N, S). */
|
||||
|
||||
void *
|
||||
xzalloc (size_t s)
|
||||
{
|
||||
return memset (xmalloc (s), 0, s);
|
||||
}
|
||||
|
||||
/* Allocate zeroed memory for N elements of S bytes, with error
|
||||
checking. S must be nonzero. */
|
||||
|
||||
void *
|
||||
xcalloc (size_t n, size_t s)
|
||||
{
|
||||
void *p;
|
||||
/* Test for overflow, since some calloc implementations don't have
|
||||
proper overflow checks. But omit overflow and size-zero tests if
|
||||
HAVE_GNU_CALLOC, since GNU calloc catches overflow and never
|
||||
returns NULL if successful. */
|
||||
if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s))
|
||||
|| (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0)))
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Clone an object P of size S, with error checking. There's no need
|
||||
for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
|
||||
need for an arithmetic overflow check. */
|
||||
|
||||
void *
|
||||
xmemdup (void const *p, size_t s)
|
||||
{
|
||||
return memcpy (xmalloc (s), p, s);
|
||||
}
|
||||
|
||||
/* Clone STRING. */
|
||||
|
||||
char *
|
||||
xstrdup (char const *string)
|
||||
{
|
||||
return xmemdup (string, strlen (string) + 1);
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
/* Duplicate a bounded initial segment of a string, with out-of-memory
|
||||
checking.
|
||||
Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "xstrndup.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "xalloc.h"
|
||||
|
||||
#ifndef HAVE_DECL_STRNDUP
|
||||
extern char *strndup (const char *, size_t);
|
||||
#endif
|
||||
|
||||
/* Return a newly allocated copy of at most N bytes of STRING.
|
||||
In other words, return a copy of the initial segment of length N of
|
||||
STRING. */
|
||||
char *
|
||||
xstrndup (const char *string, size_t n)
|
||||
{
|
||||
char *s = strndup (string, n);
|
||||
if (! s)
|
||||
xalloc_die ();
|
||||
return s;
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
/* Duplicate a bounded initial segment of a string, with out-of-memory
|
||||
checking.
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Return a newly allocated copy of at most N bytes of STRING.
|
||||
In other words, return a copy of the initial segment of length N of
|
||||
STRING. */
|
||||
extern char *xstrndup (const char *string, size_t n);
|
||||
@ -1,10 +0,0 @@
|
||||
#serial 3
|
||||
dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_ARGMATCH],
|
||||
[
|
||||
AC_LIBOBJ([argmatch])
|
||||
])
|
||||
@ -1,16 +0,0 @@
|
||||
# backupfile.m4 serial 12
|
||||
dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_BACKUPFILE],
|
||||
[
|
||||
AC_LIBOBJ([backupfile])
|
||||
|
||||
dnl Prerequisites of lib/backupfile.c.
|
||||
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
|
||||
AC_REQUIRE([gl_AC_DOS])
|
||||
AC_REQUIRE([AC_SYS_LONG_FILE_NAMES])
|
||||
AC_CHECK_FUNCS_ONCE([pathconf])
|
||||
])
|
||||
@ -1,41 +0,0 @@
|
||||
# serial 11
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl Check whether struct dirent has a member named d_ino.
|
||||
dnl
|
||||
|
||||
# Copyright (C) 1997, 1999-2001, 2003-2004, 2006-2007, 2009 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
|
||||
[AC_CACHE_CHECK([for d_ino member in directory struct],
|
||||
gl_cv_struct_dirent_d_ino,
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
]],
|
||||
[[DIR *dp = opendir (".");
|
||||
struct dirent *e;
|
||||
struct stat st;
|
||||
if (! dp)
|
||||
return 1;
|
||||
e = readdir (dp);
|
||||
return ! (e
|
||||
&& stat (e->d_name, &st) == 0
|
||||
&& e->d_ino == st.st_ino);]])],
|
||||
[gl_cv_struct_dirent_d_ino=yes],
|
||||
[gl_cv_struct_dirent_d_ino=no],
|
||||
[gl_cv_struct_dirent_d_ino=no])])
|
||||
if test $gl_cv_struct_dirent_d_ino = yes; then
|
||||
AC_DEFINE([D_INO_IN_DIRENT], [1],
|
||||
[Define if struct dirent has a member d_ino that actually works.])
|
||||
fi
|
||||
]
|
||||
)
|
||||
@ -1,18 +0,0 @@
|
||||
#serial 7 -*- autoconf -*-
|
||||
dnl Copyright (C) 2002-2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_DIRNAME],
|
||||
[
|
||||
AC_LIBOBJ([basename])
|
||||
AC_LIBOBJ([dirname])
|
||||
AC_LIBOBJ([stripslash])
|
||||
|
||||
dnl Prerequisites of lib/dirname.h.
|
||||
AC_REQUIRE([gl_AC_DOS])
|
||||
AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
|
||||
|
||||
dnl No prerequisites of lib/basename.c, lib/dirname.c, lib/stripslash.c.
|
||||
])
|
||||
71
gl/m4/dos.m4
71
gl/m4/dos.m4
@ -1,71 +0,0 @@
|
||||
#serial 10 -*- autoconf -*-
|
||||
|
||||
# Define some macros required for proper operation of code in lib/*.c
|
||||
# on MSDOS/Windows systems.
|
||||
|
||||
# Copyright (C) 2000, 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# From Jim Meyering.
|
||||
|
||||
AC_DEFUN([gl_AC_DOS],
|
||||
[
|
||||
AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos],
|
||||
[
|
||||
AC_TRY_COMPILE([],
|
||||
[#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
|
||||
neither MSDOS nor Windows
|
||||
#endif],
|
||||
[ac_cv_win_or_dos=yes],
|
||||
[ac_cv_win_or_dos=no])
|
||||
])
|
||||
|
||||
if test x"$ac_cv_win_or_dos" = xyes; then
|
||||
ac_fs_accepts_drive_letter_prefix=1
|
||||
ac_fs_backslash_is_file_name_separator=1
|
||||
AC_CACHE_CHECK([whether drive letter can start relative path],
|
||||
[ac_cv_drive_letter_can_be_relative],
|
||||
[
|
||||
AC_TRY_COMPILE([],
|
||||
[#if defined __CYGWIN__
|
||||
drive letters are always absolute
|
||||
#endif],
|
||||
[ac_cv_drive_letter_can_be_relative=yes],
|
||||
[ac_cv_drive_letter_can_be_relative=no])
|
||||
])
|
||||
if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
|
||||
ac_fs_drive_letter_can_be_relative=1
|
||||
else
|
||||
ac_fs_drive_letter_can_be_relative=0
|
||||
fi
|
||||
else
|
||||
ac_fs_accepts_drive_letter_prefix=0
|
||||
ac_fs_backslash_is_file_name_separator=0
|
||||
ac_fs_drive_letter_can_be_relative=0
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX],
|
||||
$ac_fs_accepts_drive_letter_prefix,
|
||||
[Define on systems for which file names may have a so-called
|
||||
`drive letter' prefix, define this to compute the length of that
|
||||
prefix, including the colon.])
|
||||
|
||||
AH_VERBATIM(ISSLASH,
|
||||
[#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
|
||||
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
|
||||
#else
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
#endif])
|
||||
|
||||
AC_DEFINE_UNQUOTED([FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR],
|
||||
$ac_fs_backslash_is_file_name_separator,
|
||||
[Define if the backslash character may also serve as a file name
|
||||
component separator.])
|
||||
|
||||
AC_DEFINE_UNQUOTED([FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE],
|
||||
$ac_fs_drive_letter_can_be_relative,
|
||||
[Define if a drive letter prefix denotes a relative path if it is
|
||||
not followed by a file name component separator.])
|
||||
])
|
||||
@ -1,38 +0,0 @@
|
||||
# double-slash-root.m4 serial 4 -*- Autoconf -*-
|
||||
dnl Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
|
||||
[
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root],
|
||||
[ if test x"$cross_compiling" = xyes ; then
|
||||
# When cross-compiling, there is no way to tell whether // is special
|
||||
# short of a list of hosts. However, the only known hosts to date
|
||||
# that have a distinct // are Apollo DomainOS (too old to port to),
|
||||
# Cygwin, and z/OS. If anyone knows of another system for which // has
|
||||
# special semantics and is distinct from /, please report it to
|
||||
# <bug-gnulib@gnu.org>.
|
||||
case $host in
|
||||
*-cygwin | i370-ibm-openedition)
|
||||
gl_cv_double_slash_root=yes ;;
|
||||
*)
|
||||
# Be optimistic and assume that / and // are the same when we
|
||||
# don't know.
|
||||
gl_cv_double_slash_root='unknown, assuming no' ;;
|
||||
esac
|
||||
else
|
||||
set x `ls -di / // 2>/dev/null`
|
||||
if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
|
||||
gl_cv_double_slash_root=no
|
||||
else
|
||||
gl_cv_double_slash_root=yes
|
||||
fi
|
||||
fi])
|
||||
if test "$gl_cv_double_slash_root" = yes; then
|
||||
AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1],
|
||||
[Define to 1 if // is a file system root distinct from /.])
|
||||
fi
|
||||
])
|
||||
@ -1,15 +0,0 @@
|
||||
#serial 5
|
||||
dnl Copyright (C) 2002, 2005, 2007 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_DUP2],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
AC_CHECK_FUNCS_ONCE([dup2])
|
||||
if test $ac_cv_func_dup2 = no; then
|
||||
HAVE_DUP2=0
|
||||
AC_LIBOBJ([dup2])
|
||||
fi
|
||||
])
|
||||
@ -1,22 +0,0 @@
|
||||
#serial 11
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004 Free Software
|
||||
# Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_ERROR],
|
||||
[
|
||||
AC_FUNC_ERROR_AT_LINE
|
||||
dnl Note: AC_FUNC_ERROR_AT_LINE does AC_LIBSOURCES([error.h, error.c]).
|
||||
gl_PREREQ_ERROR
|
||||
])
|
||||
|
||||
# Prerequisites of lib/error.c.
|
||||
AC_DEFUN([gl_PREREQ_ERROR],
|
||||
[
|
||||
AC_REQUIRE([AC_FUNC_STRERROR_R])
|
||||
:
|
||||
])
|
||||
@ -1,13 +0,0 @@
|
||||
# exitfail.m4 serial 6
|
||||
dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_EXITFAIL],
|
||||
[
|
||||
AC_LIBOBJ([exitfail])
|
||||
|
||||
dnl No prerequisites of lib/exitfail.c.
|
||||
:
|
||||
])
|
||||
@ -1,104 +0,0 @@
|
||||
# serial 8 -*- Autoconf -*-
|
||||
# Enable extensions on systems that normally disable them.
|
||||
|
||||
# Copyright (C) 2003, 2006-2009 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
|
||||
# Autoconf. Perhaps we can remove this once we can assume Autoconf
|
||||
# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
|
||||
# enough in this area it's likely we'll need to redefine
|
||||
# AC_USE_SYSTEM_EXTENSIONS for quite some time.
|
||||
|
||||
# AC_USE_SYSTEM_EXTENSIONS
|
||||
# ------------------------
|
||||
# Enable extensions on systems that normally disable them,
|
||||
# typically due to standards-conformance issues.
|
||||
# Remember that #undef in AH_VERBATIM gets replaced with #define by
|
||||
# AC_DEFINE. The goal here is to define all known feature-enabling
|
||||
# macros, then, if reports of conflicts are made, disable macros that
|
||||
# cause problems on some platforms (such as __EXTENSIONS__).
|
||||
AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
|
||||
[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
|
||||
AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
|
||||
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
|
||||
AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
|
||||
if test "$MINIX" = yes; then
|
||||
AC_DEFINE([_POSIX_SOURCE], [1],
|
||||
[Define to 1 if you need to in order for `stat' and other
|
||||
things to work.])
|
||||
AC_DEFINE([_POSIX_1_SOURCE], [2],
|
||||
[Define to 2 if the system does not provide POSIX.1 features
|
||||
except with this defined.])
|
||||
AC_DEFINE([_MINIX], [1],
|
||||
[Define to 1 if on MINIX.])
|
||||
fi
|
||||
|
||||
dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
|
||||
dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
|
||||
dnl provided.
|
||||
case "$host_os" in
|
||||
hpux*)
|
||||
AC_DEFINE([_XOPEN_SOURCE], [500],
|
||||
[Define to 500 only on HP-UX.])
|
||||
;;
|
||||
esac
|
||||
|
||||
AH_VERBATIM([__EXTENSIONS__],
|
||||
[/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# undef _ALL_SOURCE
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# undef _GNU_SOURCE
|
||||
#endif
|
||||
/* Enable threading extensions on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# undef _POSIX_PTHREAD_SEMANTICS
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# undef _TANDEM_SOURCE
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# undef __EXTENSIONS__
|
||||
#endif
|
||||
])
|
||||
AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
|
||||
[ac_cv_safe_to_define___extensions__],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
# define __EXTENSIONS__ 1
|
||||
]AC_INCLUDES_DEFAULT])],
|
||||
[ac_cv_safe_to_define___extensions__=yes],
|
||||
[ac_cv_safe_to_define___extensions__=no])])
|
||||
test $ac_cv_safe_to_define___extensions__ = yes &&
|
||||
AC_DEFINE([__EXTENSIONS__])
|
||||
AC_DEFINE([_ALL_SOURCE])
|
||||
AC_DEFINE([_GNU_SOURCE])
|
||||
AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
|
||||
AC_DEFINE([_TANDEM_SOURCE])
|
||||
])# AC_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
# gl_USE_SYSTEM_EXTENSIONS
|
||||
# ------------------------
|
||||
# Enable extensions on systems that normally disable them,
|
||||
# typically due to standards-conformance issues.
|
||||
AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
|
||||
[
|
||||
dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
|
||||
dnl gnulib does not need it. But if it gets required by third-party macros
|
||||
dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
|
||||
dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
|
||||
dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
|
||||
dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
|
||||
AC_REQUIRE([AC_GNU_SOURCE])
|
||||
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
])
|
||||
@ -1,83 +0,0 @@
|
||||
# getopt.m4 serial 14
|
||||
dnl Copyright (C) 2002-2006, 2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# The getopt module assume you want GNU getopt, with getopt_long etc,
|
||||
# rather than vanilla POSIX getopt. This means your code should
|
||||
# always include <getopt.h> for the getopt prototypes.
|
||||
|
||||
AC_DEFUN([gl_GETOPT_SUBSTITUTE],
|
||||
[
|
||||
AC_LIBOBJ([getopt])
|
||||
AC_LIBOBJ([getopt1])
|
||||
gl_GETOPT_SUBSTITUTE_HEADER
|
||||
gl_PREREQ_GETOPT
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
|
||||
[
|
||||
GETOPT_H=getopt.h
|
||||
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
|
||||
[Define to rpl_ if the getopt replacement functions and variables
|
||||
should be used.])
|
||||
AC_SUBST([GETOPT_H])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
|
||||
[
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
|
||||
fi
|
||||
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
|
||||
fi
|
||||
|
||||
dnl BSD getopt_long uses an incompatible method to reset option processing,
|
||||
dnl and (as of 2004-10-15) mishandles optional option-arguments.
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
|
||||
fi
|
||||
|
||||
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
|
||||
dnl option string (as of 2005-05-05).
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([[#include <getopt.h>]],
|
||||
[[
|
||||
char *myargv[3];
|
||||
myargv[0] = "conftest";
|
||||
myargv[1] = "-+";
|
||||
myargv[2] = 0;
|
||||
return getopt (2, myargv, "+a") != '?';
|
||||
]])],
|
||||
[gl_cv_func_gnu_getopt=yes],
|
||||
[gl_cv_func_gnu_getopt=no],
|
||||
[dnl cross compiling - pessimistically guess based on decls
|
||||
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
|
||||
dnl option string (as of 2005-05-05).
|
||||
AC_CHECK_DECL([getopt_clip],
|
||||
[gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes],
|
||||
[#include <getopt.h>])])])
|
||||
if test "$gl_cv_func_gnu_getopt" = "no"; then
|
||||
GETOPT_H=getopt.h
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT_IFELSE],
|
||||
[
|
||||
AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
|
||||
AS_IF([test -n "$GETOPT_H"], [$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT], [gl_GETOPT_IFELSE([gl_GETOPT_SUBSTITUTE])])
|
||||
|
||||
# Prerequisites of lib/getopt*.
|
||||
AC_DEFUN([gl_PREREQ_GETOPT],
|
||||
[
|
||||
AC_CHECK_DECLS_ONCE([getenv])
|
||||
])
|
||||
381
gl/m4/gettext.m4
381
gl/m4/gettext.m4
@ -1,381 +0,0 @@
|
||||
# gettext.m4 serial 62 (gettext-0.18)
|
||||
dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
dnl
|
||||
dnl This file can can be used in projects which are not available under
|
||||
dnl the GNU General Public License or the GNU Library General Public
|
||||
dnl License but which still want to provide support for the GNU gettext
|
||||
dnl functionality.
|
||||
dnl Please note that the actual code of the GNU gettext library is covered
|
||||
dnl by the GNU Library General Public License, and the rest of the GNU
|
||||
dnl gettext package package is covered by the GNU General Public License.
|
||||
dnl They are *not* in the public domain.
|
||||
|
||||
dnl Authors:
|
||||
dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
|
||||
dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006.
|
||||
|
||||
dnl Macro to add for using GNU gettext.
|
||||
|
||||
dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
|
||||
dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
|
||||
dnl default (if it is not specified or empty) is 'no-libtool'.
|
||||
dnl INTLSYMBOL should be 'external' for packages with no intl directory,
|
||||
dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
|
||||
dnl If INTLSYMBOL is 'use-libtool', then a libtool library
|
||||
dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
|
||||
dnl depending on --{enable,disable}-{shared,static} and on the presence of
|
||||
dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
|
||||
dnl $(top_builddir)/intl/libintl.a will be created.
|
||||
dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
|
||||
dnl implementations (in libc or libintl) without the ngettext() function
|
||||
dnl will be ignored. If NEEDSYMBOL is specified and is
|
||||
dnl 'need-formatstring-macros', then GNU gettext implementations that don't
|
||||
dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
|
||||
dnl INTLDIR is used to find the intl libraries. If empty,
|
||||
dnl the value `$(top_builddir)/intl/' is used.
|
||||
dnl
|
||||
dnl The result of the configuration is one of three cases:
|
||||
dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
|
||||
dnl and used.
|
||||
dnl Catalog format: GNU --> install in $(datadir)
|
||||
dnl Catalog extension: .mo after installation, .gmo in source tree
|
||||
dnl 2) GNU gettext has been found in the system's C library.
|
||||
dnl Catalog format: GNU --> install in $(datadir)
|
||||
dnl Catalog extension: .mo after installation, .gmo in source tree
|
||||
dnl 3) No internationalization, always use English msgid.
|
||||
dnl Catalog format: none
|
||||
dnl Catalog extension: none
|
||||
dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
|
||||
dnl The use of .gmo is historical (it was needed to avoid overwriting the
|
||||
dnl GNU format catalogs when building on a platform with an X/Open gettext),
|
||||
dnl but we keep it in order not to force irrelevant filename changes on the
|
||||
dnl maintainers.
|
||||
dnl
|
||||
AC_DEFUN([AM_GNU_GETTEXT],
|
||||
[
|
||||
dnl Argument checking.
|
||||
ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
|
||||
[errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
|
||||
])])])])])
|
||||
ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
|
||||
[errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
|
||||
])])])])
|
||||
define([gt_included_intl],
|
||||
ifelse([$1], [external],
|
||||
ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
|
||||
[yes]))
|
||||
define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
|
||||
gt_NEEDS_INIT
|
||||
AM_GNU_GETTEXT_NEED([$2])
|
||||
|
||||
AC_REQUIRE([AM_PO_SUBDIRS])dnl
|
||||
ifelse(gt_included_intl, yes, [
|
||||
AC_REQUIRE([AM_INTL_SUBDIR])dnl
|
||||
])
|
||||
|
||||
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
|
||||
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
||||
AC_REQUIRE([AC_LIB_RPATH])
|
||||
|
||||
dnl Sometimes libintl requires libiconv, so first search for libiconv.
|
||||
dnl Ideally we would do this search only after the
|
||||
dnl if test "$USE_NLS" = "yes"; then
|
||||
dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
|
||||
dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
|
||||
dnl the configure script would need to contain the same shell code
|
||||
dnl again, outside any 'if'. There are two solutions:
|
||||
dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
|
||||
dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
|
||||
dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
|
||||
dnl documented, we avoid it.
|
||||
ifelse(gt_included_intl, yes, , [
|
||||
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
|
||||
])
|
||||
|
||||
dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation.
|
||||
gt_INTL_MACOSX
|
||||
|
||||
dnl Set USE_NLS.
|
||||
AC_REQUIRE([AM_NLS])
|
||||
|
||||
ifelse(gt_included_intl, yes, [
|
||||
BUILD_INCLUDED_LIBINTL=no
|
||||
USE_INCLUDED_LIBINTL=no
|
||||
])
|
||||
LIBINTL=
|
||||
LTLIBINTL=
|
||||
POSUB=
|
||||
|
||||
dnl Add a version number to the cache macros.
|
||||
case " $gt_needs " in
|
||||
*" need-formatstring-macros "*) gt_api_version=3 ;;
|
||||
*" need-ngettext "*) gt_api_version=2 ;;
|
||||
*) gt_api_version=1 ;;
|
||||
esac
|
||||
gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
|
||||
gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
|
||||
|
||||
dnl If we use NLS figure out what method
|
||||
if test "$USE_NLS" = "yes"; then
|
||||
gt_use_preinstalled_gnugettext=no
|
||||
ifelse(gt_included_intl, yes, [
|
||||
AC_MSG_CHECKING([whether included gettext is requested])
|
||||
AC_ARG_WITH([included-gettext],
|
||||
[ --with-included-gettext use the GNU gettext library included here],
|
||||
nls_cv_force_use_gnu_gettext=$withval,
|
||||
nls_cv_force_use_gnu_gettext=no)
|
||||
AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
|
||||
|
||||
nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
|
||||
if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
|
||||
])
|
||||
dnl User does not insist on using GNU NLS library. Figure out what
|
||||
dnl to use. If GNU gettext is available we use this. Else we have
|
||||
dnl to fall back to GNU NLS library.
|
||||
|
||||
if test $gt_api_version -ge 3; then
|
||||
gt_revision_test_code='
|
||||
#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
|
||||
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
|
||||
#endif
|
||||
changequote(,)dnl
|
||||
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
|
||||
changequote([,])dnl
|
||||
'
|
||||
else
|
||||
gt_revision_test_code=
|
||||
fi
|
||||
if test $gt_api_version -ge 2; then
|
||||
gt_expression_test_code=' + * ngettext ("", "", 0)'
|
||||
else
|
||||
gt_expression_test_code=
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
|
||||
[AC_TRY_LINK([#include <libintl.h>
|
||||
$gt_revision_test_code
|
||||
extern int _nl_msg_cat_cntr;
|
||||
extern int *_nl_domain_bindings;],
|
||||
[bindtextdomain ("", "");
|
||||
return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings],
|
||||
[eval "$gt_func_gnugettext_libc=yes"],
|
||||
[eval "$gt_func_gnugettext_libc=no"])])
|
||||
|
||||
if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
|
||||
dnl Sometimes libintl requires libiconv, so first search for libiconv.
|
||||
ifelse(gt_included_intl, yes, , [
|
||||
AM_ICONV_LINK
|
||||
])
|
||||
dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
|
||||
dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
|
||||
dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
|
||||
dnl even if libiconv doesn't exist.
|
||||
AC_LIB_LINKFLAGS_BODY([intl])
|
||||
AC_CACHE_CHECK([for GNU gettext in libintl],
|
||||
[$gt_func_gnugettext_libintl],
|
||||
[gt_save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $INCINTL"
|
||||
gt_save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $LIBINTL"
|
||||
dnl Now see whether libintl exists and does not depend on libiconv.
|
||||
AC_TRY_LINK([#include <libintl.h>
|
||||
$gt_revision_test_code
|
||||
extern int _nl_msg_cat_cntr;
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
const char *_nl_expand_alias (const char *);],
|
||||
[bindtextdomain ("", "");
|
||||
return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
|
||||
[eval "$gt_func_gnugettext_libintl=yes"],
|
||||
[eval "$gt_func_gnugettext_libintl=no"])
|
||||
dnl Now see whether libintl exists and depends on libiconv.
|
||||
if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
|
||||
LIBS="$LIBS $LIBICONV"
|
||||
AC_TRY_LINK([#include <libintl.h>
|
||||
$gt_revision_test_code
|
||||
extern int _nl_msg_cat_cntr;
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
const char *_nl_expand_alias (const char *);],
|
||||
[bindtextdomain ("", "");
|
||||
return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
|
||||
[LIBINTL="$LIBINTL $LIBICONV"
|
||||
LTLIBINTL="$LTLIBINTL $LTLIBICONV"
|
||||
eval "$gt_func_gnugettext_libintl=yes"
|
||||
])
|
||||
fi
|
||||
CPPFLAGS="$gt_save_CPPFLAGS"
|
||||
LIBS="$gt_save_LIBS"])
|
||||
fi
|
||||
|
||||
dnl If an already present or preinstalled GNU gettext() is found,
|
||||
dnl use it. But if this macro is used in GNU gettext, and GNU
|
||||
dnl gettext is already preinstalled in libintl, we update this
|
||||
dnl libintl. (Cf. the install rule in intl/Makefile.in.)
|
||||
if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
|
||||
|| { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
|
||||
&& test "$PACKAGE" != gettext-runtime \
|
||||
&& test "$PACKAGE" != gettext-tools; }; then
|
||||
gt_use_preinstalled_gnugettext=yes
|
||||
else
|
||||
dnl Reset the values set by searching for libintl.
|
||||
LIBINTL=
|
||||
LTLIBINTL=
|
||||
INCINTL=
|
||||
fi
|
||||
|
||||
ifelse(gt_included_intl, yes, [
|
||||
if test "$gt_use_preinstalled_gnugettext" != "yes"; then
|
||||
dnl GNU gettext is not found in the C library.
|
||||
dnl Fall back on included GNU gettext library.
|
||||
nls_cv_use_gnu_gettext=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$nls_cv_use_gnu_gettext" = "yes"; then
|
||||
dnl Mark actions used to generate GNU NLS library.
|
||||
BUILD_INCLUDED_LIBINTL=yes
|
||||
USE_INCLUDED_LIBINTL=yes
|
||||
LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
|
||||
LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
|
||||
LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
|
||||
fi
|
||||
|
||||
CATOBJEXT=
|
||||
if test "$gt_use_preinstalled_gnugettext" = "yes" \
|
||||
|| test "$nls_cv_use_gnu_gettext" = "yes"; then
|
||||
dnl Mark actions to use GNU gettext tools.
|
||||
CATOBJEXT=.gmo
|
||||
fi
|
||||
])
|
||||
|
||||
if test -n "$INTL_MACOSX_LIBS"; then
|
||||
if test "$gt_use_preinstalled_gnugettext" = "yes" \
|
||||
|| test "$nls_cv_use_gnu_gettext" = "yes"; then
|
||||
dnl Some extra flags are needed during linking.
|
||||
LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
|
||||
LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$gt_use_preinstalled_gnugettext" = "yes" \
|
||||
|| test "$nls_cv_use_gnu_gettext" = "yes"; then
|
||||
AC_DEFINE([ENABLE_NLS], [1],
|
||||
[Define to 1 if translation of program messages to the user's native language
|
||||
is requested.])
|
||||
else
|
||||
USE_NLS=no
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether to use NLS])
|
||||
AC_MSG_RESULT([$USE_NLS])
|
||||
if test "$USE_NLS" = "yes"; then
|
||||
AC_MSG_CHECKING([where the gettext function comes from])
|
||||
if test "$gt_use_preinstalled_gnugettext" = "yes"; then
|
||||
if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
|
||||
gt_source="external libintl"
|
||||
else
|
||||
gt_source="libc"
|
||||
fi
|
||||
else
|
||||
gt_source="included intl directory"
|
||||
fi
|
||||
AC_MSG_RESULT([$gt_source])
|
||||
fi
|
||||
|
||||
if test "$USE_NLS" = "yes"; then
|
||||
|
||||
if test "$gt_use_preinstalled_gnugettext" = "yes"; then
|
||||
if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
|
||||
AC_MSG_CHECKING([how to link with libintl])
|
||||
AC_MSG_RESULT([$LIBINTL])
|
||||
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
|
||||
fi
|
||||
|
||||
dnl For backward compatibility. Some packages may be using this.
|
||||
AC_DEFINE([HAVE_GETTEXT], [1],
|
||||
[Define if the GNU gettext() function is already present or preinstalled.])
|
||||
AC_DEFINE([HAVE_DCGETTEXT], [1],
|
||||
[Define if the GNU dcgettext() function is already present or preinstalled.])
|
||||
fi
|
||||
|
||||
dnl We need to process the po/ directory.
|
||||
POSUB=po
|
||||
fi
|
||||
|
||||
ifelse(gt_included_intl, yes, [
|
||||
dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
|
||||
dnl to 'yes' because some of the testsuite requires it.
|
||||
if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
|
||||
BUILD_INCLUDED_LIBINTL=yes
|
||||
fi
|
||||
|
||||
dnl Make all variables we use known to autoconf.
|
||||
AC_SUBST([BUILD_INCLUDED_LIBINTL])
|
||||
AC_SUBST([USE_INCLUDED_LIBINTL])
|
||||
AC_SUBST([CATOBJEXT])
|
||||
|
||||
dnl For backward compatibility. Some configure.ins may be using this.
|
||||
nls_cv_header_intl=
|
||||
nls_cv_header_libgt=
|
||||
|
||||
dnl For backward compatibility. Some Makefiles may be using this.
|
||||
DATADIRNAME=share
|
||||
AC_SUBST([DATADIRNAME])
|
||||
|
||||
dnl For backward compatibility. Some Makefiles may be using this.
|
||||
INSTOBJEXT=.mo
|
||||
AC_SUBST([INSTOBJEXT])
|
||||
|
||||
dnl For backward compatibility. Some Makefiles may be using this.
|
||||
GENCAT=gencat
|
||||
AC_SUBST([GENCAT])
|
||||
|
||||
dnl For backward compatibility. Some Makefiles may be using this.
|
||||
INTLOBJS=
|
||||
if test "$USE_INCLUDED_LIBINTL" = yes; then
|
||||
INTLOBJS="\$(GETTOBJS)"
|
||||
fi
|
||||
AC_SUBST([INTLOBJS])
|
||||
|
||||
dnl Enable libtool support if the surrounding package wishes it.
|
||||
INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
|
||||
AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
|
||||
])
|
||||
|
||||
dnl For backward compatibility. Some Makefiles may be using this.
|
||||
INTLLIBS="$LIBINTL"
|
||||
AC_SUBST([INTLLIBS])
|
||||
|
||||
dnl Make all documented variables known to autoconf.
|
||||
AC_SUBST([LIBINTL])
|
||||
AC_SUBST([LTLIBINTL])
|
||||
AC_SUBST([POSUB])
|
||||
])
|
||||
|
||||
|
||||
dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
|
||||
m4_define([gt_NEEDS_INIT],
|
||||
[
|
||||
m4_divert_text([DEFAULTS], [gt_needs=])
|
||||
m4_define([gt_NEEDS_INIT], [])
|
||||
])
|
||||
|
||||
|
||||
dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
|
||||
AC_DEFUN([AM_GNU_GETTEXT_NEED],
|
||||
[
|
||||
m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
|
||||
])
|
||||
|
||||
|
||||
dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
|
||||
AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
|
||||
@ -1,13 +0,0 @@
|
||||
# hash.m4 serial 6
|
||||
dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_HASH],
|
||||
[
|
||||
AC_LIBOBJ([hash])
|
||||
|
||||
dnl Prerequisites of lib/hash.c.
|
||||
AC_REQUIRE([AM_STDBOOL_H])
|
||||
])
|
||||
@ -1,40 +0,0 @@
|
||||
# inline.m4 serial 4
|
||||
dnl Copyright (C) 2006, 2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl Test for the 'inline' keyword or equivalent.
|
||||
dnl Define 'inline' to a supported equivalent, or to nothing if not supported,
|
||||
dnl like AC_C_INLINE does. Also, define HAVE_INLINE if 'inline' or an
|
||||
dnl equivalent is effectively supported, i.e. if the compiler is likely to
|
||||
dnl drop unused 'static inline' functions.
|
||||
AC_DEFUN([gl_INLINE],
|
||||
[
|
||||
AC_REQUIRE([AC_C_INLINE])
|
||||
AC_CACHE_CHECK([whether the compiler generally respects inline],
|
||||
[gl_cv_c_inline_effective],
|
||||
[if test $ac_cv_c_inline = no; then
|
||||
gl_cv_c_inline_effective=no
|
||||
else
|
||||
dnl GCC defines __NO_INLINE__ if not optimizing or if -fno-inline is
|
||||
dnl specified.
|
||||
dnl Use AC_COMPILE_IFELSE here, not AC_EGREP_CPP, because the result
|
||||
dnl depends on optimization flags, which can be in CFLAGS.
|
||||
dnl (AC_EGREP_CPP looks only at the CPPFLAGS.)
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[]],
|
||||
[[#ifdef __NO_INLINE__
|
||||
#error "inline is not effective"
|
||||
#endif]])],
|
||||
[gl_cv_c_inline_effective=yes],
|
||||
[gl_cv_c_inline_effective=no])
|
||||
fi
|
||||
])
|
||||
if test $gl_cv_c_inline_effective = yes; then
|
||||
AC_DEFINE([HAVE_INLINE], [1],
|
||||
[Define to 1 if the compiler supports one of the keywords
|
||||
'inline', '__inline__', '__inline' and effectively inlines
|
||||
functions marked as such.])
|
||||
fi
|
||||
])
|
||||
@ -1,41 +0,0 @@
|
||||
# malloc.m4 serial 9
|
||||
dnl Copyright (C) 2007, 2009 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.
|
||||
|
||||
# gl_FUNC_MALLOC_POSIX
|
||||
# --------------------
|
||||
# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it
|
||||
# fails), and replace malloc if it is not.
|
||||
AC_DEFUN([gl_FUNC_MALLOC_POSIX],
|
||||
[
|
||||
AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
|
||||
if test $gl_cv_func_malloc_posix = yes; then
|
||||
HAVE_MALLOC_POSIX=1
|
||||
AC_DEFINE([HAVE_MALLOC_POSIX], [1],
|
||||
[Define if the 'malloc' function is POSIX compliant.])
|
||||
else
|
||||
AC_LIBOBJ([malloc])
|
||||
HAVE_MALLOC_POSIX=0
|
||||
fi
|
||||
AC_SUBST([HAVE_MALLOC_POSIX])
|
||||
])
|
||||
|
||||
# Test whether malloc, realloc, calloc are POSIX compliant,
|
||||
# Set gl_cv_func_malloc_posix to yes or no accordingly.
|
||||
AC_DEFUN([gl_CHECK_MALLOC_POSIX],
|
||||
[
|
||||
AC_CACHE_CHECK([whether malloc, realloc, calloc are POSIX compliant],
|
||||
[gl_cv_func_malloc_posix],
|
||||
[
|
||||
dnl It is too dangerous to try to allocate a large amount of memory:
|
||||
dnl some systems go to their knees when you do that. So assume that
|
||||
dnl all Unix implementations of the function are POSIX compliant.
|
||||
AC_TRY_COMPILE([],
|
||||
[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
choke me
|
||||
#endif
|
||||
], [gl_cv_func_malloc_posix=yes], [gl_cv_func_malloc_posix=no])
|
||||
])
|
||||
])
|
||||
382
gl/m4/mbrtowc.m4
382
gl/m4/mbrtowc.m4
@ -1,382 +0,0 @@
|
||||
# mbrtowc.m4 serial 14
|
||||
dnl Copyright (C) 2001-2002, 2004-2005, 2008, 2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_MBRTOWC],
|
||||
[
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
|
||||
AC_REQUIRE([AC_TYPE_MBSTATE_T])
|
||||
gl_MBSTATE_T_BROKEN
|
||||
if test $REPLACE_MBSTATE_T = 1; then
|
||||
REPLACE_MBRTOWC=1
|
||||
fi
|
||||
AC_CHECK_FUNCS_ONCE([mbrtowc])
|
||||
if test $ac_cv_func_mbrtowc = no; then
|
||||
HAVE_MBRTOWC=0
|
||||
fi
|
||||
if test $HAVE_MBRTOWC != 0 && test $REPLACE_MBRTOWC != 1; then
|
||||
gl_MBRTOWC_NULL_ARG
|
||||
gl_MBRTOWC_RETVAL
|
||||
gl_MBRTOWC_NUL_RETVAL
|
||||
case "$gl_cv_func_mbrtowc_null_arg" in
|
||||
*yes) ;;
|
||||
*) AC_DEFINE([MBRTOWC_NULL_ARG_BUG], [1],
|
||||
[Define if the mbrtowc function has the NULL string argument bug.])
|
||||
REPLACE_MBRTOWC=1
|
||||
;;
|
||||
esac
|
||||
case "$gl_cv_func_mbrtowc_retval" in
|
||||
*yes) ;;
|
||||
*) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
|
||||
[Define if the mbrtowc function returns a wrong return value.])
|
||||
REPLACE_MBRTOWC=1
|
||||
;;
|
||||
esac
|
||||
case "$gl_cv_func_mbrtowc_nul_retval" in
|
||||
*yes) ;;
|
||||
*) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
|
||||
[Define if the mbrtowc function does not return 0 for a NUL character.])
|
||||
REPLACE_MBRTOWC=1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
|
||||
gl_REPLACE_WCHAR_H
|
||||
AC_LIBOBJ([mbrtowc])
|
||||
gl_PREREQ_MBRTOWC
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
|
||||
dnl redefines the semantics of the given mbstate_t type.
|
||||
dnl Result is REPLACE_MBSTATE_T.
|
||||
dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
|
||||
dnl avoid inconsistencies.
|
||||
|
||||
AC_DEFUN([gl_MBSTATE_T_BROKEN],
|
||||
[
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
|
||||
AC_REQUIRE([AC_TYPE_MBSTATE_T])
|
||||
AC_CHECK_FUNCS_ONCE([mbsinit])
|
||||
AC_CHECK_FUNCS_ONCE([mbrtowc])
|
||||
if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
|
||||
gl_MBRTOWC_INCOMPLETE_STATE
|
||||
gl_MBRTOWC_SANITYCHECK
|
||||
REPLACE_MBSTATE_T=0
|
||||
case "$gl_cv_func_mbrtowc_incomplete_state" in
|
||||
*yes) ;;
|
||||
*) REPLACE_MBSTATE_T=1 ;;
|
||||
esac
|
||||
case "$gl_cv_func_mbrtowc_sanitycheck" in
|
||||
*yes) ;;
|
||||
*) REPLACE_MBSTATE_T=1 ;;
|
||||
esac
|
||||
else
|
||||
REPLACE_MBSTATE_T=1
|
||||
fi
|
||||
if test $REPLACE_MBSTATE_T = 1; then
|
||||
gl_REPLACE_WCHAR_H
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc puts the state into non-initial state when parsing an
|
||||
dnl incomplete multibyte character.
|
||||
dnl Result is gl_cv_func_mbrtowc_incomplete_state.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_JA])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
|
||||
[gl_cv_func_mbrtowc_incomplete_state],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on AIX and OSF/1.
|
||||
osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_JA != none; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
|
||||
{
|
||||
const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
|
||||
if (mbsinit (&state))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}],
|
||||
[gl_cv_func_mbrtowc_incomplete_state=yes],
|
||||
[gl_cv_func_mbrtowc_incomplete_state=no],
|
||||
[])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc works not worse than mbtowc.
|
||||
dnl Result is gl_cv_func_mbrtowc_sanitycheck.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_SANITYCHECK],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_ZH_CN])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc],
|
||||
[gl_cv_func_mbrtowc_sanitycheck],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on Solaris 8.
|
||||
solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_ZH_CN != none; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
/* This fails on Solaris 8:
|
||||
mbrtowc returns 2, and sets wc to 0x00F0.
|
||||
mbtowc returns 4 (correct) and sets wc to 0x5EDC. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
|
||||
{
|
||||
char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 3, 6, &state) != 4
|
||||
&& mbtowc (&wc, input + 3, 6) == 4)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}],
|
||||
[gl_cv_func_mbrtowc_sanitycheck=yes],
|
||||
[gl_cv_func_mbrtowc_sanitycheck=no],
|
||||
[])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc supports a NULL string argument correctly.
|
||||
dnl Result is gl_cv_func_mbrtowc_null_arg.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_NULL_ARG],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_FR_UTF8])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
|
||||
[gl_cv_func_mbrtowc_null_arg],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on OSF/1.
|
||||
osf*) gl_cv_func_mbrtowc_null_arg="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_null_arg="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_FR_UTF8 != none; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
|
||||
{
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
int ret;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
wc = (wchar_t) 0xBADFACE;
|
||||
mbrtowc (&wc, NULL, 5, &state);
|
||||
/* Check that wc was not modified. */
|
||||
if (wc != (wchar_t) 0xBADFACE)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}], [gl_cv_func_mbrtowc_null_arg=yes], [gl_cv_func_mbrtowc_null_arg=no], [])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc, when parsing the end of a multibyte character,
|
||||
dnl correctly returns the number of bytes that were needed to complete the
|
||||
dnl character (not the total number of bytes of the multibyte character).
|
||||
dnl Result is gl_cv_func_mbrtowc_retval.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_RETVAL],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_FR_UTF8])
|
||||
AC_REQUIRE([gt_LOCALE_JA])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc has a correct return value],
|
||||
[gl_cv_func_mbrtowc_retval],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on HP-UX and Solaris.
|
||||
hpux* | solaris*) gl_cv_func_mbrtowc_retval="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_retval="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
/* This fails on Solaris. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
|
||||
{
|
||||
char input[] = "B\303\274\303\237er"; /* "Büßer" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
|
||||
{
|
||||
input[1] = '\0';
|
||||
if (mbrtowc (&wc, input + 2, 5, &state) != 1)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* This fails on HP-UX 11.11. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
|
||||
{
|
||||
char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
|
||||
{
|
||||
input[1] = '\0';
|
||||
if (mbrtowc (&wc, input + 2, 5, &state) != 2)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}],
|
||||
[gl_cv_func_mbrtowc_retval=yes],
|
||||
[gl_cv_func_mbrtowc_retval=no],
|
||||
[])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0.
|
||||
dnl Result is gl_cv_func_mbrtowc_nul_retval.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_NUL_RETVAL],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_ZH_CN])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character],
|
||||
[gl_cv_func_mbrtowc_nul_retval],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on Solaris 8 and 9.
|
||||
solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_ZH_CN != none; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
/* This fails on Solaris 8 and 9. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
|
||||
{
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, "", 1, &state) != 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}],
|
||||
[gl_cv_func_mbrtowc_nul_retval=yes],
|
||||
[gl_cv_func_mbrtowc_nul_retval=no],
|
||||
[])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
# Prerequisites of lib/mbrtowc.c.
|
||||
AC_DEFUN([gl_PREREQ_MBRTOWC], [
|
||||
:
|
||||
])
|
||||
|
||||
|
||||
dnl From Paul Eggert
|
||||
|
||||
dnl This override of an autoconf macro can be removed when autoconf 2.60 or
|
||||
dnl newer can be assumed everywhere.
|
||||
|
||||
m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.60]),[-1],[
|
||||
AC_DEFUN([AC_FUNC_MBRTOWC],
|
||||
[
|
||||
dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
|
||||
AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
|
||||
gl_cv_func_mbrtowc,
|
||||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <wchar.h>]],
|
||||
[[wchar_t wc;
|
||||
char const s[] = "";
|
||||
size_t n = 1;
|
||||
mbstate_t state;
|
||||
return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
|
||||
gl_cv_func_mbrtowc=yes,
|
||||
gl_cv_func_mbrtowc=no)])
|
||||
if test $gl_cv_func_mbrtowc = yes; then
|
||||
AC_DEFINE([HAVE_MBRTOWC], [1],
|
||||
[Define to 1 if mbrtowc and mbstate_t are properly declared.])
|
||||
fi
|
||||
])
|
||||
])
|
||||
@ -1,34 +0,0 @@
|
||||
# mbstate_t.m4 serial 12
|
||||
dnl Copyright (C) 2000-2002, 2008, 2009 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.
|
||||
|
||||
# From Paul Eggert.
|
||||
|
||||
# BeOS 5 has <wchar.h> but does not define mbstate_t,
|
||||
# so you can't declare an object of that type.
|
||||
# Check for this incompatibility with Standard C.
|
||||
|
||||
# AC_TYPE_MBSTATE_T
|
||||
# -----------------
|
||||
AC_DEFUN([AC_TYPE_MBSTATE_T],
|
||||
[
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11
|
||||
|
||||
AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[AC_INCLUDES_DEFAULT[
|
||||
# include <wchar.h>]],
|
||||
[[mbstate_t x; return sizeof x;]])],
|
||||
[ac_cv_type_mbstate_t=yes],
|
||||
[ac_cv_type_mbstate_t=no])])
|
||||
if test $ac_cv_type_mbstate_t = yes; then
|
||||
AC_DEFINE([HAVE_MBSTATE_T], [1],
|
||||
[Define to 1 if <wchar.h> declares mbstate_t.])
|
||||
else
|
||||
AC_DEFINE([mbstate_t], [int],
|
||||
[Define to a type if <wchar.h> does not define.])
|
||||
fi
|
||||
])
|
||||
@ -1,18 +0,0 @@
|
||||
# memchr.m4 serial 5
|
||||
dnl Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_MEMCHR],
|
||||
[
|
||||
AC_REPLACE_FUNCS([memchr])
|
||||
if test $ac_cv_func_memchr = no; then
|
||||
gl_PREREQ_MEMCHR
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/memchr.c.
|
||||
AC_DEFUN([gl_PREREQ_MEMCHR], [
|
||||
AC_CHECK_HEADERS([bp-sym.h])
|
||||
])
|
||||
@ -1,41 +0,0 @@
|
||||
# minmax.m4 serial 3
|
||||
dnl Copyright (C) 2005, 2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_PREREQ([2.52])
|
||||
|
||||
AC_DEFUN([gl_MINMAX],
|
||||
[
|
||||
AC_REQUIRE([gl_PREREQ_MINMAX])
|
||||
])
|
||||
|
||||
# Prerequisites of lib/minmax.h.
|
||||
AC_DEFUN([gl_PREREQ_MINMAX],
|
||||
[
|
||||
gl_MINMAX_IN_HEADER([limits.h])
|
||||
gl_MINMAX_IN_HEADER([sys/param.h])
|
||||
])
|
||||
|
||||
dnl gl_MINMAX_IN_HEADER(HEADER)
|
||||
dnl The parameter has to be a literal header name; it cannot be macro,
|
||||
dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
|
||||
dnl invocations with a literal macro name.)
|
||||
AC_DEFUN([gl_MINMAX_IN_HEADER],
|
||||
[
|
||||
m4_pushdef([header], AS_TR_SH([$1]))
|
||||
m4_pushdef([HEADER], AS_TR_CPP([$1]))
|
||||
AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
|
||||
[gl_cv_minmax_in_]header,
|
||||
[AC_TRY_COMPILE([#include <$1>
|
||||
int x = MIN (42, 17);], [],
|
||||
[gl_cv_minmax_in_]header[=yes],
|
||||
[gl_cv_minmax_in_]header[=no])])
|
||||
if test $gl_cv_minmax_in_[]header = yes; then
|
||||
AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
|
||||
[Define to 1 if <$1> defines the MIN and MAX macros.])
|
||||
fi
|
||||
m4_popdef([HEADER])
|
||||
m4_popdef([header])
|
||||
])
|
||||
@ -1,90 +0,0 @@
|
||||
# onceonly.m4 serial 6
|
||||
dnl Copyright (C) 2002-2003, 2005-2006, 2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software, distributed under the terms of the GNU
|
||||
dnl General Public License. As a special exception to the GNU General
|
||||
dnl Public License, this file may be distributed as part of a program
|
||||
dnl that contains a configuration script generated by Autoconf, under
|
||||
dnl the same distribution terms as the rest of that program.
|
||||
|
||||
dnl This file defines some "once only" variants of standard autoconf macros.
|
||||
dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS
|
||||
dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS
|
||||
dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS
|
||||
dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL
|
||||
dnl The advantage is that the check for each of the headers/functions/decls
|
||||
dnl will be put only once into the 'configure' file. It keeps the size of
|
||||
dnl the 'configure' file down, and avoids redundant output when 'configure'
|
||||
dnl is run.
|
||||
dnl The drawback is that the checks cannot be conditionalized. If you write
|
||||
dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
|
||||
dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
|
||||
dnl empty, and the check will be inserted before the body of the AC_DEFUNed
|
||||
dnl function.
|
||||
|
||||
dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE
|
||||
dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to
|
||||
dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested
|
||||
dnl headers at once, thus reducing the size of 'configure'. It is known to work
|
||||
dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%.
|
||||
|
||||
dnl Autoconf version 2.59 plus gnulib is required; this file is not needed
|
||||
dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of
|
||||
dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first
|
||||
dnl argument!
|
||||
AC_PREREQ([2.59])
|
||||
|
||||
# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
|
||||
# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
|
||||
AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
|
||||
:
|
||||
m4_foreach_w([gl_HEADER_NAME], [$1], [
|
||||
AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
|
||||
[./-], [___])), [
|
||||
m4_divert_text([INIT_PREPARE],
|
||||
[gl_header_list="$gl_header_list gl_HEADER_NAME"])
|
||||
gl_HEADERS_EXPANSION
|
||||
AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])),
|
||||
[Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.])
|
||||
])
|
||||
AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
|
||||
[./-], [___])))
|
||||
])
|
||||
])
|
||||
m4_define([gl_HEADERS_EXPANSION], [
|
||||
m4_divert_text([DEFAULTS], [gl_header_list=])
|
||||
AC_CHECK_HEADERS([$gl_header_list])
|
||||
m4_define([gl_HEADERS_EXPANSION], [])
|
||||
])
|
||||
|
||||
# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
|
||||
# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
|
||||
AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
|
||||
:
|
||||
m4_foreach_w([gl_FUNC_NAME], [$1], [
|
||||
AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
|
||||
m4_divert_text([INIT_PREPARE],
|
||||
[gl_func_list="$gl_func_list gl_FUNC_NAME"])
|
||||
gl_FUNCS_EXPANSION
|
||||
AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])),
|
||||
[Define to 1 if you have the `]m4_defn([gl_FUNC_NAME])[' function.])
|
||||
])
|
||||
AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
|
||||
])
|
||||
])
|
||||
m4_define([gl_FUNCS_EXPANSION], [
|
||||
m4_divert_text([DEFAULTS], [gl_func_list=])
|
||||
AC_CHECK_FUNCS([$gl_func_list])
|
||||
m4_define([gl_FUNCS_EXPANSION], [])
|
||||
])
|
||||
|
||||
# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
|
||||
# AC_CHECK_DECLS(DECL1, DECL2, ...).
|
||||
AC_DEFUN([AC_CHECK_DECLS_ONCE], [
|
||||
:
|
||||
m4_foreach_w([gl_DECL_NAME], [$1], [
|
||||
AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
|
||||
AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
|
||||
])
|
||||
AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
|
||||
])
|
||||
])
|
||||
@ -1,13 +0,0 @@
|
||||
# quote.m4 serial 5
|
||||
dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_QUOTE],
|
||||
[
|
||||
AC_LIBOBJ([quote])
|
||||
|
||||
dnl Prerequisites of lib/quote.c.
|
||||
dnl (none)
|
||||
])
|
||||
@ -1,10 +0,0 @@
|
||||
# quotearg.m4 serial 8
|
||||
dnl Copyright (C) 2002, 2004-2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_QUOTEARG],
|
||||
[
|
||||
AC_LIBOBJ([quotearg])
|
||||
])
|
||||
@ -1,23 +0,0 @@
|
||||
# realloc.m4 serial 9
|
||||
dnl Copyright (C) 2007, 2009 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.
|
||||
|
||||
# gl_FUNC_REALLOC_POSIX
|
||||
# ---------------------
|
||||
# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
|
||||
# fails), and replace realloc if it is not.
|
||||
AC_DEFUN([gl_FUNC_REALLOC_POSIX],
|
||||
[
|
||||
AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
|
||||
if test $gl_cv_func_malloc_posix = yes; then
|
||||
HAVE_REALLOC_POSIX=1
|
||||
AC_DEFINE([HAVE_REALLOC_POSIX], [1],
|
||||
[Define if the 'realloc' function is POSIX compliant.])
|
||||
else
|
||||
AC_LIBOBJ([realloc])
|
||||
HAVE_REALLOC_POSIX=0
|
||||
fi
|
||||
AC_SUBST([HAVE_REALLOC_POSIX])
|
||||
])
|
||||
@ -1,69 +0,0 @@
|
||||
# serial 13
|
||||
|
||||
# Copyright (C) 2001, 2003, 2005, 2006, 2009 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Volker Borchert.
|
||||
dnl Determine whether rename works for source file names with a trailing slash.
|
||||
dnl The rename from SunOS 4.1.1_U1 doesn't.
|
||||
dnl
|
||||
dnl If it doesn't, then define RENAME_TRAILING_SLASH_BUG and arrange
|
||||
dnl to compile the wrapper function.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([gl_FUNC_RENAME],
|
||||
[
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CACHE_CHECK([whether rename is broken with a trailing slash],
|
||||
gl_cv_func_rename_trailing_slash_bug,
|
||||
[
|
||||
rm -rf conftest.d1 conftest.d2
|
||||
mkdir conftest.d1 ||
|
||||
AC_MSG_ERROR([cannot create temporary directory])
|
||||
AC_TRY_RUN([
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
exit (rename ("conftest.d1/", "conftest.d2") ? 1 : 0);
|
||||
}
|
||||
],
|
||||
gl_cv_func_rename_trailing_slash_bug=no,
|
||||
gl_cv_func_rename_trailing_slash_bug=yes,
|
||||
dnl When crosscompiling, assume rename is broken.
|
||||
gl_cv_func_rename_trailing_slash_bug=yes)
|
||||
|
||||
rm -rf conftest.d1 conftest.d2
|
||||
])
|
||||
AC_CACHE_CHECK([whether rename is broken when the destination exists],
|
||||
gl_cv_func_rename_dest_exists_bug,
|
||||
[
|
||||
case "$host_os" in
|
||||
mingw*) gl_cv_func_rename_dest_exists_bug=yes ;;
|
||||
*) gl_cv_func_rename_dest_exists_bug=no ;;
|
||||
esac
|
||||
])
|
||||
if test $gl_cv_func_rename_trailing_slash_bug = yes ||
|
||||
test $gl_cv_func_rename_dest_exists_bug = yes; then
|
||||
AC_LIBOBJ([rename])
|
||||
AC_DEFINE([rename], [rpl_rename],
|
||||
[Define to rpl_rename if the replacement function should be used.])
|
||||
if test $gl_cv_func_rename_trailing_slash_bug = yes; then
|
||||
AC_DEFINE([RENAME_TRAILING_SLASH_BUG], [1],
|
||||
[Define if rename does not work for source file names with a trailing
|
||||
slash, like the one from SunOS 4.1.1_U1.])
|
||||
fi
|
||||
if test $gl_cv_func_rename_dest_exists_bug = yes; then
|
||||
AC_DEFINE([RENAME_DEST_EXISTS_BUG], [1],
|
||||
[Define if rename does not work when the destination file exists,
|
||||
as on Windows.])
|
||||
fi
|
||||
gl_PREREQ_RENAME
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/rename.c.
|
||||
AC_DEFUN([gl_PREREQ_RENAME], [:])
|
||||
@ -1,18 +0,0 @@
|
||||
# safe-read.m4 serial 5
|
||||
dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_SAFE_READ],
|
||||
[
|
||||
AC_LIBOBJ([safe-read])
|
||||
|
||||
gl_PREREQ_SAFE_READ
|
||||
])
|
||||
|
||||
# Prerequisites of lib/safe-read.c.
|
||||
AC_DEFUN([gl_PREREQ_SAFE_READ],
|
||||
[
|
||||
AC_REQUIRE([gt_TYPE_SSIZE_T])
|
||||
])
|
||||
@ -1,18 +0,0 @@
|
||||
# safe-write.m4 serial 3
|
||||
dnl Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_SAFE_WRITE],
|
||||
[
|
||||
AC_LIBOBJ([safe-write])
|
||||
|
||||
gl_PREREQ_SAFE_WRITE
|
||||
])
|
||||
|
||||
# Prerequisites of lib/safe-write.c.
|
||||
AC_DEFUN([gl_PREREQ_SAFE_WRITE],
|
||||
[
|
||||
gl_PREREQ_SAFE_READ
|
||||
])
|
||||
@ -1,21 +0,0 @@
|
||||
# ssize_t.m4 serial 4 (gettext-0.15)
|
||||
dnl Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
dnl Test whether ssize_t is defined.
|
||||
|
||||
AC_DEFUN([gt_TYPE_SSIZE_T],
|
||||
[
|
||||
AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t],
|
||||
[AC_TRY_COMPILE([#include <sys/types.h>],
|
||||
[int x = sizeof (ssize_t *) + sizeof (ssize_t);
|
||||
return !x;],
|
||||
[gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])])
|
||||
if test $gt_cv_ssize_t = no; then
|
||||
AC_DEFINE([ssize_t], [int],
|
||||
[Define as a signed type of the same size as size_t.])
|
||||
fi
|
||||
])
|
||||
115
gl/m4/stdbool.m4
115
gl/m4/stdbool.m4
@ -1,115 +0,0 @@
|
||||
# Check for stdbool.h that conforms to C99.
|
||||
|
||||
dnl Copyright (C) 2002-2006, 2009 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.
|
||||
|
||||
# Prepare for substituting <stdbool.h> if it is not supported.
|
||||
|
||||
AC_DEFUN([AM_STDBOOL_H],
|
||||
[
|
||||
AC_REQUIRE([AC_HEADER_STDBOOL])
|
||||
|
||||
# Define two additional variables used in the Makefile substitution.
|
||||
|
||||
if test "$ac_cv_header_stdbool_h" = yes; then
|
||||
STDBOOL_H=''
|
||||
else
|
||||
STDBOOL_H='stdbool.h'
|
||||
fi
|
||||
AC_SUBST([STDBOOL_H])
|
||||
|
||||
if test "$ac_cv_type__Bool" = yes; then
|
||||
HAVE__BOOL=1
|
||||
else
|
||||
HAVE__BOOL=0
|
||||
fi
|
||||
AC_SUBST([HAVE__BOOL])
|
||||
])
|
||||
|
||||
# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
|
||||
AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
|
||||
|
||||
# This macro is only needed in autoconf <= 2.59. Newer versions of autoconf
|
||||
# have this macro built-in.
|
||||
|
||||
AC_DEFUN([AC_HEADER_STDBOOL],
|
||||
[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
|
||||
[ac_cv_header_stdbool_h],
|
||||
[AC_TRY_COMPILE(
|
||||
[
|
||||
#include <stdbool.h>
|
||||
#ifndef bool
|
||||
"error: bool is not defined"
|
||||
#endif
|
||||
#ifndef false
|
||||
"error: false is not defined"
|
||||
#endif
|
||||
#if false
|
||||
"error: false is not 0"
|
||||
#endif
|
||||
#ifndef true
|
||||
"error: true is not defined"
|
||||
#endif
|
||||
#if true != 1
|
||||
"error: true is not 1"
|
||||
#endif
|
||||
#ifndef __bool_true_false_are_defined
|
||||
"error: __bool_true_false_are_defined is not defined"
|
||||
#endif
|
||||
|
||||
struct s { _Bool s: 1; _Bool t; } s;
|
||||
|
||||
char a[true == 1 ? 1 : -1];
|
||||
char b[false == 0 ? 1 : -1];
|
||||
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
|
||||
char d[(bool) 0.5 == true ? 1 : -1];
|
||||
bool e = &s;
|
||||
char f[(_Bool) 0.0 == false ? 1 : -1];
|
||||
char g[true];
|
||||
char h[sizeof (_Bool)];
|
||||
char i[sizeof s.t];
|
||||
enum { j = false, k = true, l = false * true, m = true * 256 };
|
||||
_Bool n[m];
|
||||
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
|
||||
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
|
||||
#if defined __xlc__ || defined __GNUC__
|
||||
/* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
|
||||
reported by James Lemley on 2005-10-05; see
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
|
||||
This test is not quite right, since xlc is allowed to
|
||||
reject this program, as the initializer for xlcbug is
|
||||
not one of the forms that C requires support for.
|
||||
However, doing the test right would require a run-time
|
||||
test, and that would make cross-compilation harder.
|
||||
Let us hope that IBM fixes the xlc bug, and also adds
|
||||
support for this kind of constant expression. In the
|
||||
meantime, this test will reject xlc, which is OK, since
|
||||
our stdbool.h substitute should suffice. We also test
|
||||
this with GCC, where it should work, to detect more
|
||||
quickly whether someone messes up the test in the
|
||||
future. */
|
||||
char digs[] = "0123456789";
|
||||
int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
|
||||
#endif
|
||||
/* Catch a bug in an HP-UX C compiler. See
|
||||
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
|
||||
*/
|
||||
_Bool q = true;
|
||||
_Bool *pq = &q;
|
||||
],
|
||||
[
|
||||
*pq |= q;
|
||||
*pq |= ! q;
|
||||
/* Refer to every declared value, to avoid compiler optimizations. */
|
||||
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
|
||||
+ !m + !n + !o + !p + !q + !pq);
|
||||
],
|
||||
[ac_cv_header_stdbool_h=yes],
|
||||
[ac_cv_header_stdbool_h=no])])
|
||||
AC_CHECK_TYPES([_Bool])
|
||||
if test $ac_cv_header_stdbool_h = yes; then
|
||||
AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
|
||||
fi])
|
||||
@ -1,39 +0,0 @@
|
||||
# strcase.m4 serial 1
|
||||
dnl Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
dnl This file is free software, distributed under the terms of the GNU
|
||||
dnl General Public License. As a special exception to the GNU General
|
||||
dnl Public License, this file may be distributed as part of a program
|
||||
dnl that contains a configuration script generated by Autoconf, under
|
||||
dnl the same distribution terms as the rest of that program.
|
||||
|
||||
AC_DEFUN([gl_STRCASE],
|
||||
[
|
||||
gl_FUNC_STRCASECMP
|
||||
gl_FUNC_STRNCASECMP
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_FUNC_STRCASECMP],
|
||||
[
|
||||
AC_REPLACE_FUNCS(strcasecmp)
|
||||
if test $ac_cv_func_strcasecmp = no; then
|
||||
gl_PREREQ_STRCASECMP
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_FUNC_STRNCASECMP],
|
||||
[
|
||||
AC_REPLACE_FUNCS(strncasecmp)
|
||||
if test $ac_cv_func_strncasecmp = no; then
|
||||
gl_PREREQ_STRNCASECMP
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/strcasecmp.c.
|
||||
AC_DEFUN([gl_PREREQ_STRCASECMP], [
|
||||
:
|
||||
])
|
||||
|
||||
# Prerequisites of lib/strncasecmp.c.
|
||||
AC_DEFUN([gl_PREREQ_STRNCASECMP], [
|
||||
:
|
||||
])
|
||||
@ -1,53 +0,0 @@
|
||||
# strndup.m4 serial 16
|
||||
dnl Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_STRNDUP],
|
||||
[
|
||||
dnl Persuade glibc <string.h> to declare strndup().
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
|
||||
dnl AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
|
||||
AC_CHECK_DECLS_ONCE([strndup])
|
||||
if test $ac_cv_have_decl_strndup = no; then
|
||||
HAVE_DECL_STRNDUP=0
|
||||
fi
|
||||
|
||||
# AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
|
||||
AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup],
|
||||
[AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([[#include <string.h>
|
||||
#include <stdlib.h>]], [[
|
||||
#ifndef HAVE_DECL_STRNDUP
|
||||
extern char *strndup (const char *, size_t);
|
||||
#endif
|
||||
char *s;
|
||||
s = strndup ("some longer string", 15);
|
||||
free (s);
|
||||
s = strndup ("shorter string", 13);
|
||||
return s[13] != '\0';]])],
|
||||
[gl_cv_func_strndup=yes],
|
||||
[gl_cv_func_strndup=no],
|
||||
[AC_CHECK_FUNC([strndup],
|
||||
[AC_EGREP_CPP([too risky], [
|
||||
#ifdef _AIX
|
||||
too risky
|
||||
#endif
|
||||
],
|
||||
[gl_cv_func_strndup=no],
|
||||
[gl_cv_func_strndup=yes])],
|
||||
[gl_cv_func_strndup=no])])])
|
||||
if test $gl_cv_func_strndup = yes; then
|
||||
AC_DEFINE([HAVE_STRNDUP], [1],
|
||||
[Define if you have the strndup() function and it works.])
|
||||
else
|
||||
HAVE_STRNDUP=0
|
||||
AC_LIBOBJ([strndup])
|
||||
gl_PREREQ_STRNDUP
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/strndup.c.
|
||||
AC_DEFUN([gl_PREREQ_STRNDUP], [:])
|
||||
@ -1,31 +0,0 @@
|
||||
# strnlen.m4 serial 10
|
||||
dnl Copyright (C) 2002-2003, 2005-2007, 2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_STRNLEN],
|
||||
[
|
||||
dnl Persuade glibc <string.h> to declare strnlen().
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
|
||||
dnl AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
|
||||
AC_CHECK_DECLS_ONCE([strnlen])
|
||||
if test $ac_cv_have_decl_strnlen = no; then
|
||||
HAVE_DECL_STRNLEN=0
|
||||
fi
|
||||
|
||||
AC_FUNC_STRNLEN
|
||||
if test $ac_cv_func_strnlen_working = no; then
|
||||
# This is necessary because automake-1.6.1 doesn't understand
|
||||
# that the above use of AC_FUNC_STRNLEN means we may have to use
|
||||
# lib/strnlen.c.
|
||||
AC_LIBOBJ([strnlen])
|
||||
AC_DEFINE([strnlen], [rpl_strnlen],
|
||||
[Define to rpl_strnlen if the replacement function should be used.])
|
||||
gl_PREREQ_STRNLEN
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/strnlen.c.
|
||||
AC_DEFUN([gl_PREREQ_STRNLEN], [:])
|
||||
@ -1,41 +0,0 @@
|
||||
# unlocked-io.m4 serial 15
|
||||
|
||||
# Copyright (C) 1998-2006, 2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl See if the glibc *_unlocked I/O macros or functions are available.
|
||||
dnl Use only those *_unlocked macros or functions that are declared
|
||||
dnl (because some of them were declared in Solaris 2.5.1 but were removed
|
||||
dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run
|
||||
dnl on Solaris 2.6).
|
||||
|
||||
AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO],
|
||||
[
|
||||
AC_DEFINE([USE_UNLOCKED_IO], [1],
|
||||
[Define to 1 if you want getc etc. to use unlocked I/O if available.
|
||||
Unlocked I/O can improve performance in unithreaded apps,
|
||||
but it is not safe for multithreaded apps.])
|
||||
|
||||
dnl Persuade glibc and Solaris <stdio.h> to declare
|
||||
dnl fgets_unlocked(), fputs_unlocked() etc.
|
||||
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
||||
|
||||
AC_CHECK_DECLS_ONCE([clearerr_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([feof_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([ferror_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([fflush_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([fgets_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([fputc_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([fputs_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([fread_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([fwrite_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([getc_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([getchar_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([putc_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([putchar_unlocked])
|
||||
])
|
||||
@ -1,39 +0,0 @@
|
||||
# serial 9
|
||||
|
||||
# Copyright (C) 1998-2001, 2003-2004, 2007, 2009 Free Software
|
||||
# Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Jim Meyering
|
||||
|
||||
dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared --
|
||||
dnl usually in <utime.h>.
|
||||
dnl Some systems have utime.h but don't declare the struct anywhere.
|
||||
|
||||
AC_DEFUN([gl_CHECK_TYPE_STRUCT_UTIMBUF],
|
||||
[
|
||||
AC_CHECK_HEADERS_ONCE([sys/time.h utime.h])
|
||||
AC_CACHE_CHECK([for struct utimbuf], [gl_cv_sys_struct_utimbuf],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#if HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#ifdef HAVE_UTIME_H
|
||||
#include <utime.h>
|
||||
#endif
|
||||
]],
|
||||
[[static struct utimbuf x; x.actime = x.modtime;]])],
|
||||
[gl_cv_sys_struct_utimbuf=yes],
|
||||
[gl_cv_sys_struct_utimbuf=no])])
|
||||
|
||||
if test $gl_cv_sys_struct_utimbuf = yes; then
|
||||
AC_DEFINE([HAVE_STRUCT_UTIMBUF], [1],
|
||||
[Define if struct utimbuf is declared -- usually in <utime.h>.
|
||||
Some systems have utime.h but don't declare the struct anywhere. ])
|
||||
fi
|
||||
])
|
||||
@ -1,24 +0,0 @@
|
||||
# xalloc.m4 serial 16
|
||||
dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_XALLOC],
|
||||
[
|
||||
AC_LIBOBJ([xmalloc])
|
||||
|
||||
gl_PREREQ_XALLOC
|
||||
gl_PREREQ_XMALLOC
|
||||
])
|
||||
|
||||
# Prerequisites of lib/xalloc.h.
|
||||
AC_DEFUN([gl_PREREQ_XALLOC], [
|
||||
AC_REQUIRE([gl_INLINE])
|
||||
:
|
||||
])
|
||||
|
||||
# Prerequisites of lib/xmalloc.c.
|
||||
AC_DEFUN([gl_PREREQ_XMALLOC], [
|
||||
:
|
||||
])
|
||||
@ -1,15 +0,0 @@
|
||||
# xstrndup.m4 serial 2
|
||||
dnl Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_XSTRNDUP],
|
||||
[
|
||||
gl_PREREQ_XSTRNDUP
|
||||
])
|
||||
|
||||
# Prerequisites of lib/xstrndup.c.
|
||||
AC_DEFUN([gl_PREREQ_XSTRNDUP], [
|
||||
:
|
||||
])
|
||||
1
gnulib
Submodule
1
gnulib
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 9829f0a93c40492875f67ee738e000611bdcf0e7
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user