Compare commits
876
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f44fb9b450 | ||
|
|
bf9af9a408 | ||
|
|
394e22ef5d | ||
|
|
5b1614f31a | ||
|
|
8c05c20df4 | ||
|
|
3ecac0e0ab | ||
|
|
e4c108f3d7 | ||
|
|
d2c82fc45a | ||
|
|
7c2e55d3fd | ||
|
|
cb061edef8 | ||
|
|
49aba3d99e | ||
|
|
fca6e38924 | ||
|
|
09446c7544 | ||
|
|
8a4ad6884b | ||
|
|
2021349249 | ||
|
|
e7392a5c22 | ||
|
|
6b0dccd9d5 | ||
|
|
e006418946 | ||
|
|
49ebd1264d | ||
|
|
94d07354ce | ||
|
|
2881b5c3df | ||
|
|
e0209e39ea | ||
|
|
e154c51512 | ||
|
|
e1196c53f2 | ||
|
|
56b431c4c2 | ||
|
|
ac4291f473 | ||
|
|
2482413c83 | ||
|
|
de2192ab20 | ||
|
|
7fcc213b7a | ||
|
|
5aceb08fb4 | ||
|
|
1d465c4012 | ||
|
|
cc945fabb7 | ||
|
|
621251ae2e | ||
|
|
13e35220c2 | ||
|
|
45e6ca04f5 | ||
|
|
5719d6ca30 | ||
|
|
58d332cff9 | ||
|
|
1f2c3cb141 | ||
|
|
398efeba2d | ||
|
|
0591917a06 | ||
|
|
bbdb1f12a0 | ||
|
|
fed4d43bd5 | ||
|
|
f9a4d9f781 | ||
|
|
1a664df87f | ||
|
|
77282aad96 | ||
|
|
c9301353fc | ||
|
|
4b7747b505 | ||
|
|
e7a40e1084 | ||
|
|
ee49fa81d9 | ||
|
|
cc4dae5c0f | ||
|
|
3826a26f8a | ||
|
|
045e0f533d | ||
|
|
ac711bcf45 | ||
|
|
b5f75d3392 | ||
|
|
ffc7a9f0b9 | ||
|
|
a557024511 | ||
|
|
0efc494b97 | ||
|
|
70fb513ba3 | ||
|
|
8985ee2114 | ||
|
|
33d71c61d9 | ||
|
|
85aac3aef7 | ||
|
|
c3c71b5f3c | ||
|
|
d1ec31a73d | ||
|
|
9feb8b7c29 | ||
|
|
b45b819dfe | ||
|
|
c365555a69 | ||
|
|
9707adf634 | ||
|
|
05e0ee4c06 | ||
|
|
50a1375461 | ||
|
|
8f20d609b9 | ||
|
|
ef381abdfd | ||
|
|
3dc49c128c | ||
|
|
38dcdcb300 | ||
|
|
d0ac3d107b | ||
|
|
f08ec44049 | ||
|
|
acbdbb87fb | ||
|
|
a9dab78604 | ||
|
|
084fba1d17 | ||
|
|
c414b83e0a | ||
|
|
3f2c2080cc | ||
|
|
3d5f129cb0 | ||
|
|
6d137e77a5 | ||
|
|
4ee2aeb33d | ||
|
|
fd03d49b6f | ||
|
|
29fbee5784 | ||
|
|
eede8c60a1 | ||
|
|
9dabbdf40b | ||
|
|
2f3fc1cfa2 | ||
|
|
66dc9d1fbf | ||
|
|
e170502d63 | ||
|
|
b1e6b58b6a | ||
|
|
6ec7c04557 | ||
|
|
bfdc5233eb | ||
|
|
1146932b9e | ||
|
|
6cdb3193ec | ||
|
|
bf46b6a1da | ||
|
|
00d5f9266b | ||
|
|
efa79f01e6 | ||
|
|
9f745ab1cd | ||
|
|
f0ab769a7c | ||
|
|
59f808eb7a | ||
|
|
9aa47b2cfa | ||
|
|
761a7867d5 | ||
|
|
46c087f956 | ||
|
|
3b77852126 | ||
|
|
f0f3d8a55b | ||
|
|
d5583552c0 | ||
|
|
71e4ddb74f | ||
|
|
b1f92f4888 | ||
|
|
beac2287a9 | ||
|
|
7b0e9cef60 | ||
|
|
76e2e078e3 | ||
|
|
036cd8c9be | ||
|
|
ac61d77a41 | ||
|
|
d0fab95780 | ||
|
|
338b9ec9d2 | ||
|
|
4719e1f68d | ||
|
|
be629669a5 | ||
|
|
8a6dda8529 | ||
|
|
243ea5f7a3 | ||
|
|
6d3aeef45e | ||
|
|
fbdc68b6a2 | ||
|
|
4603752cef | ||
|
|
d6a9a5d664 | ||
|
|
9f9a9e291d | ||
|
|
1795b4118f | ||
|
|
4ec357c743 | ||
|
|
31b9d1f712 | ||
|
|
25ac7e62ba | ||
|
|
854cf964d2 | ||
|
|
63ef0e3d26 | ||
|
|
df89a7f211 | ||
|
|
d025ae5c08 | ||
|
|
39318d91b7 | ||
|
|
d24a3eb2ba | ||
|
|
bd42171094 | ||
|
|
c5943ec574 | ||
|
|
f11320b6b0 | ||
|
|
1775284940 | ||
|
|
3200ec75ef | ||
|
|
9b45aaa5b0 | ||
|
|
1a3cef4874 | ||
|
|
90e3bdc291 | ||
|
|
cdce5491b3 | ||
|
|
4f17861678 | ||
|
|
0babbf966b | ||
|
|
b47bd89d44 | ||
|
|
33201eb14c | ||
|
|
079f1e33dc | ||
|
|
a35eba4ac2 | ||
|
|
0d73b8a7c0 | ||
|
|
945b10776d | ||
|
|
9a15a1b586 | ||
|
|
4b7caf2e4a | ||
|
|
95db69f27b | ||
|
|
e94df65350 | ||
|
|
b8d2426e1b | ||
|
|
e80eaec4d3 | ||
|
|
b9577c0641 | ||
|
|
833b02bc83 | ||
|
|
6269e32c3b | ||
|
|
3e7ffcaf4b | ||
|
|
5c9968a001 | ||
|
|
cf341f6a19 | ||
|
|
fbef9aa840 | ||
|
|
fdf1df3b29 | ||
|
|
ce13b82329 | ||
|
|
2f2b7f6ac7 | ||
|
|
5f1bd2f2e3 | ||
|
|
2afacbce95 | ||
|
|
0787b1d152 | ||
|
|
cb9f3f9268 | ||
|
|
6d88b01d1e | ||
|
|
c8e7bb7653 | ||
|
|
6dfe3f5de6 | ||
|
|
77a26f5c95 | ||
|
|
9cec6bac27 | ||
|
|
2f19b0f346 | ||
|
|
265c9d416f | ||
|
|
db610f91eb | ||
|
|
afb5bf5583 | ||
|
|
9b7ce068fe | ||
|
|
eeebae7172 | ||
|
|
d4d1014e7d | ||
|
|
820a737a2f | ||
|
|
c2d61d8dbc | ||
|
|
80d62f0547 | ||
|
|
fb0bf9d1b9 | ||
|
|
01dd016ad8 | ||
|
|
d660b325b5 | ||
|
|
26b477b907 | ||
|
|
e588745d77 | ||
|
|
89ff80fbdd | ||
|
|
b3fc99501e | ||
|
|
b3993adcfb | ||
|
|
90afac281e | ||
|
|
aed158b518 | ||
|
|
c475df7cfb | ||
|
|
51ce0579e8 | ||
|
|
57102e40e9 | ||
|
|
9b285dde85 | ||
|
|
afc4e512cb | ||
|
|
e5270637c0 | ||
|
|
f5efc84600 | ||
|
|
245151ad96 | ||
|
|
65f3d0f56b | ||
|
|
18c102aa70 | ||
|
|
e53f3cf9c6 | ||
|
|
6c78bf0adc | ||
|
|
12647cc4fb | ||
|
|
8346cad0dd | ||
|
|
620b4d531d | ||
|
|
ed3e9c60ba | ||
|
|
d87884d51b | ||
|
|
de5637f853 | ||
|
|
40947c7d3e | ||
|
|
cff4a9d980 | ||
|
|
c1ae69114b | ||
|
|
ad757b50dc | ||
|
|
5902889825 | ||
|
|
04c687936c | ||
|
|
304b569170 | ||
|
|
2133e40e58 | ||
|
|
c7cdc550c4 | ||
|
|
7633450128 | ||
|
|
7e727bed70 | ||
|
|
164a7f04c0 | ||
|
|
54fbd7dbcb | ||
|
|
772d2da10b | ||
|
|
0ae1df9bfc | ||
|
|
814c867db4 | ||
|
|
6667ddcb54 | ||
|
|
d00a212e82 | ||
|
|
7fb72851e8 | ||
|
|
4a3f32b84a | ||
|
|
77aceb5c5f | ||
|
|
8a7c004dbc | ||
|
|
a1790a1683 | ||
|
|
885a163b3c | ||
|
|
87e508c590 | ||
|
|
a76637248c | ||
|
|
2a46a48670 | ||
|
|
51aecf205d | ||
|
|
d0f8889c8f | ||
|
|
27110774bd | ||
|
|
5a06fd4bcf | ||
|
|
969f9f571c | ||
|
|
64cbe6e187 | ||
|
|
367ce9ad48 | ||
|
|
6982ae0ca7 | ||
|
|
da7eafc83b | ||
|
|
414bcee273 | ||
|
|
d11660acfe | ||
|
|
5c7ba37901 | ||
|
|
1d1e95e779 | ||
|
|
bffb982059 | ||
|
|
0978bd50ce | ||
|
|
3f8c7d5d40 | ||
|
|
4c24e60418 | ||
|
|
8219fb2632 | ||
|
|
082e8c6d7a | ||
|
|
7a9d97826e | ||
|
|
9683822257 | ||
|
|
9da2aebeae | ||
|
|
bf884c9bc9 | ||
|
|
ed5ed756bc | ||
|
|
fdee46ab16 | ||
|
|
0839047d8b | ||
|
|
94f9cf81ed | ||
|
|
e2a79c2604 | ||
|
|
05209c57d3 | ||
|
|
6cbfdcc4a3 | ||
|
|
94ec3d9431 | ||
|
|
6c1e9f2b0c | ||
|
|
563bd6e4dd | ||
|
|
b418ff1759 | ||
|
|
56ca35e8a9 | ||
|
|
107fb1eb33 | ||
|
|
c911dc937f | ||
|
|
645241afc1 | ||
|
|
03a3c09b1f | ||
|
|
5c87050dd8 | ||
|
|
3c57d80efe | ||
|
|
04004f3abc | ||
|
|
155e8a1ad5 | ||
|
|
625aca976a | ||
|
|
e9c0ec1219 | ||
|
|
8e696a5e5d | ||
|
|
9e511d7874 | ||
|
|
5af99f55b2 | ||
|
|
8047a470ef | ||
|
|
1f91c778bb | ||
|
|
2b739c838a | ||
|
|
dd713ee96e | ||
|
|
983854ad7b | ||
|
|
7bf68c2335 | ||
|
|
41a6159754 | ||
|
|
c9802b0230 | ||
|
|
df97278634 | ||
|
|
06fc5fb636 | ||
|
|
15f804e04e | ||
|
|
e5de25734f | ||
|
|
e393000b1d | ||
|
|
83d92bd747 | ||
|
|
33b8401436 | ||
|
|
d62033b7e2 | ||
|
|
1b3a0a73ae | ||
|
|
9e3e0498e7 | ||
|
|
0d36d5f3d8 | ||
|
|
a54459bed6 | ||
|
|
b5e61d9f54 | ||
|
|
5a05e0d782 | ||
|
|
9c8f784329 | ||
|
|
7fe9e1b90c | ||
|
|
bae4992913 | ||
|
|
1efbaebb6a | ||
|
|
ac47e6953d | ||
|
|
400feb302b | ||
|
|
9c9b3d93f9 | ||
|
|
04d1270786 | ||
|
|
f8b9cb869d | ||
|
|
4755be8f41 | ||
|
|
c2e16d9b1f | ||
|
|
3b14a4b0ed | ||
|
|
a3fdad2b4f | ||
|
|
b89a3efc56 | ||
|
|
240e6b50d2 | ||
|
|
38be8d3de6 | ||
|
|
29bbdb74d3 | ||
|
|
ddd37fb237 | ||
|
|
63be474164 | ||
|
|
754bb107b4 | ||
|
|
fa47c96ac2 | ||
|
|
5e3ca11761 | ||
|
|
6ab540f5ff | ||
|
|
63b0fef31a | ||
|
|
bb503004b6 | ||
|
|
267cdaec03 | ||
|
|
a2ce3dab9b | ||
|
|
6a4d06759e | ||
|
|
6966f0a2b1 | ||
|
|
89a84af271 | ||
|
|
f2ec60553a | ||
|
|
bb5d24622f | ||
|
|
813979693c | ||
|
|
c8da3bbfaf | ||
|
|
35f5b82868 | ||
|
|
b91a2765ae | ||
|
|
5e7a1545a6 | ||
|
|
f4651a5660 | ||
|
|
a0290b85c5 | ||
|
|
8145564d30 | ||
|
|
66ef201ad7 | ||
|
|
6d943ef7b5 | ||
|
|
1c13d543f4 | ||
|
|
263de53394 | ||
|
|
a410c0d8d5 | ||
|
|
ecec1703aa | ||
|
|
fae1c11488 | ||
|
|
1ab67324ca | ||
|
|
202eeb707c | ||
|
|
36a1a69178 | ||
|
|
edb38932e8 | ||
|
|
46aab3eb09 | ||
|
|
ce025f259b | ||
|
|
f6af18a947 | ||
|
|
b729965a3c | ||
|
|
0cab7d260b | ||
|
|
708eadd19e | ||
|
|
7bbadfe0e0 | ||
|
|
4523d8df2c | ||
|
|
791f1c2741 | ||
|
|
d431841a06 | ||
|
|
dffe6bc7f1 | ||
|
|
423f761169 | ||
|
|
ba42e43e97 | ||
|
|
4f1ea4779b | ||
|
|
e6fdfbe93b | ||
|
|
bd706be303 | ||
|
|
4e12ee1bc4 | ||
|
|
7672af7212 | ||
|
|
eae621b175 | ||
|
|
c2fceada6c | ||
|
|
6ba27f887c | ||
|
|
5eef06ea24 | ||
|
|
9333525d11 | ||
|
|
911c1c6237 | ||
|
|
49a9e59311 | ||
|
|
242d4d7095 | ||
|
|
c744824995 | ||
|
|
ae6192f9cb | ||
|
|
9cb3b15616 | ||
|
|
6d0cc0c589 | ||
|
|
d9bc6cbae2 | ||
|
|
388266030b | ||
|
|
ede72e80ac | ||
|
|
7bf3f83abd | ||
|
|
d3fd405e6b | ||
|
|
eed54b6281 | ||
|
|
6dbdfc31d2 | ||
|
|
35d6c2453e | ||
|
|
f7f4cbb151 | ||
|
|
f5e8751307 | ||
|
|
7855612da6 | ||
|
|
7f26fedbcc | ||
|
|
47e9dbdc37 | ||
|
|
8fd1568405 | ||
|
|
78ee8c697e | ||
|
|
08f43a1ff4 | ||
|
|
1f71d7079b | ||
|
|
5cef8b0f8e | ||
|
|
5f0cf291f5 | ||
|
|
5500074eff | ||
|
|
db133f0144 | ||
|
|
66525c95ee | ||
|
|
86c6a11cdb | ||
|
|
13bdb0305c | ||
|
|
2a19591dc7 | ||
|
|
411bfad9f4 | ||
|
|
f58e9ed842 | ||
|
|
e383cd7b26 | ||
|
|
3a3fd2954f | ||
|
|
5238a999d5 | ||
|
|
ab49bdfd12 | ||
|
|
351c77bca3 | ||
|
|
c1555b7cfd | ||
|
|
227db01958 | ||
|
|
41954059c4 | ||
|
|
b169c964e6 | ||
|
|
3771e638b0 | ||
|
|
f44e7c1795 | ||
|
|
04604552b2 | ||
|
|
b5d6b4f138 | ||
|
|
ad02c0b532 | ||
|
|
28e500cbf9 | ||
|
|
637c7dbc7e | ||
|
|
4588d7300e | ||
|
|
d690b84738 | ||
|
|
49879791f4 | ||
|
|
8262e514d0 | ||
|
|
48ed067359 | ||
|
|
5a8d06b076 | ||
|
|
6bc8c27b7f | ||
|
|
6a58a0cab2 | ||
|
|
1357172367 | ||
|
|
466fd1d930 | ||
|
|
008f1c98d0 | ||
|
|
3fe69cba13 | ||
|
|
42a2b87f32 | ||
|
|
a3204f806c | ||
|
|
441e4f6796 | ||
|
|
3117af219f | ||
|
|
a0e1b18138 | ||
|
|
70af5c2b82 | ||
|
|
d38ae8f974 | ||
|
|
0d887fa465 | ||
|
|
e9bb0992b0 | ||
|
|
f35c0dc2ed | ||
|
|
e80e214673 | ||
|
|
731f40c6d9 | ||
|
|
767cf6314a | ||
|
|
b00317d174 | ||
|
|
a8408767a4 | ||
|
|
4f8b177250 | ||
|
|
25aad1ab18 | ||
|
|
3b48db4a90 | ||
|
|
58eff8f224 | ||
|
|
97721e9675 | ||
|
|
d88d33f74d | ||
|
|
0a9706f48f | ||
|
|
45f91441a5 | ||
|
|
38781266d3 | ||
|
|
843d29b448 | ||
|
|
1a73baff09 | ||
|
|
383c53f80e | ||
|
|
ba9cf35aa3 | ||
|
|
db41a49d9c | ||
|
|
cbbab84b71 | ||
|
|
55a65632d0 | ||
|
|
47152d94c1 | ||
|
|
f52d25e68a | ||
|
|
6de6ee8aa9 | ||
|
|
3616fc519b | ||
|
|
5fd49d1907 | ||
|
|
7024801722 | ||
|
|
40dfdbd929 | ||
|
|
0cb6effe14 | ||
|
|
a0c07fcf28 | ||
|
|
221f1bc18e | ||
|
|
c0c1cce296 | ||
|
|
a628ce605f | ||
|
|
3607c177d9 | ||
|
|
e1efe253d2 | ||
|
|
544d338e0e | ||
|
|
5b5bd699ff | ||
|
|
3b3a5ff07f | ||
|
|
69868ee129 | ||
|
|
e16df96d28 | ||
|
|
608373fcb1 | ||
|
|
a866c42f19 | ||
|
|
3502aebe10 | ||
|
|
9947048fbd | ||
|
|
37b48e808c | ||
|
|
3fc7771456 | ||
|
|
7aa147800f | ||
|
|
b533731c50 | ||
|
|
983b089edb | ||
|
|
47c7771af1 | ||
|
|
1dd89810eb | ||
|
|
53795bd199 | ||
|
|
72af38dd32 | ||
|
|
7f1c241ea2 | ||
|
|
45a3c74a04 | ||
|
|
71cf0dba40 | ||
|
|
603e23c2a9 | ||
|
|
3f03f8189e | ||
|
|
c576cbec93 | ||
|
|
5c4f8d88b5 | ||
|
|
9c5c1a721f | ||
|
|
2756d01872 | ||
|
|
bf868c1c56 | ||
|
|
a69614b432 | ||
|
|
9b22762d4c | ||
|
|
0951ca5344 | ||
|
|
bb48fae153 | ||
|
|
ae2707f558 | ||
|
|
99dc87a51d | ||
|
|
7154cc9c47 | ||
|
|
b3ff8cc20c | ||
|
|
2fcfa34fcf | ||
|
|
2d811a0adf | ||
|
|
09f849cabd | ||
|
|
d997aa477d | ||
|
|
8225859a93 | ||
|
|
35adf8c728 | ||
|
|
334149646f | ||
|
|
d8a921174e | ||
|
|
d7b40297d2 | ||
|
|
9ef614086a | ||
|
|
6b40a5dc5a | ||
|
|
3cd8b86e50 | ||
|
|
d2fc7a6ed5 | ||
|
|
12a14f4954 | ||
|
|
1f34b918b9 | ||
|
|
4a8bb308e8 | ||
|
|
3640513caf | ||
|
|
4e97c16367 | ||
|
|
280b6aa62e | ||
|
|
fe346634a7 | ||
|
|
1d444f5610 | ||
|
|
30938251a2 | ||
|
|
157e55c7bc | ||
|
|
d8a0c08bbc | ||
|
|
3730061388 | ||
|
|
b171f5cc41 | ||
|
|
02a019458f | ||
|
|
b59255450b | ||
|
|
c6d82079ea | ||
|
|
52d32b1033 | ||
|
|
f85da9c9fd | ||
|
|
f20b58c6a9 | ||
|
|
9513859f8c | ||
|
|
f81c2ae724 | ||
|
|
7c1f63bb60 | ||
|
|
4515103846 | ||
|
|
87d37d3101 | ||
|
|
da76cd286c | ||
|
|
3c532f6336 | ||
|
|
ded3368d3c | ||
|
|
e84763748b | ||
|
|
8079a467a7 | ||
|
|
be47788793 | ||
|
|
62fbfd89d7 | ||
|
|
932afb0105 | ||
|
|
b2722c42b1 | ||
|
|
c2dfae0758 | ||
|
|
23440fcbd7 | ||
|
|
399ff79e21 | ||
|
|
338e92cb28 | ||
|
|
433dff0c14 | ||
|
|
67e505d2ab | ||
|
|
ef7ea2c390 | ||
|
|
5470f13299 | ||
|
|
c0effc5b46 | ||
|
|
fc947a1ad4 | ||
|
|
54bc992b81 | ||
|
|
e55f59bd83 | ||
|
|
15f27ca8f2 | ||
|
|
c55b8ed591 | ||
|
|
522456ba98 | ||
|
|
b5273bc1fa | ||
|
|
627f0a4d6a | ||
|
|
b645469c95 | ||
|
|
e295641767 | ||
|
|
c3a18ac8f4 | ||
|
|
f9dda45e97 | ||
|
|
a5c310f993 | ||
|
|
80d9aa777b | ||
|
|
c745f44e3a | ||
|
|
21d4596064 | ||
|
|
5f738db586 | ||
|
|
76bb4d1ea4 | ||
|
|
4db368d595 | ||
|
|
9dfe53af4a | ||
|
|
e58a9dabbe | ||
|
|
3e0c5c6c90 | ||
|
|
e9e40f5f02 | ||
|
|
a4dbdda700 | ||
|
|
5bf83d86b6 | ||
|
|
3c85e6e0ef | ||
|
|
58ab27bf86 | ||
|
|
824b71f959 | ||
|
|
c3c935369d | ||
|
|
e14a1e9e3d | ||
|
|
5c93243c18 | ||
|
|
bd1370959e | ||
|
|
a852495cf6 | ||
|
|
9a7f1bd48c | ||
|
|
47cb19c83f | ||
|
|
f4cc5617a6 | ||
|
|
e48602d674 | ||
|
|
e9a8c42972 | ||
|
|
5bcc7fa342 | ||
|
|
b0c45c3ad0 | ||
|
|
e1e49c9dd1 | ||
|
|
18ba46bf37 | ||
|
|
5b719a2281 | ||
|
|
edbf30e23a | ||
|
|
395d0889b0 | ||
|
|
ba0d107038 | ||
|
|
763f9dff55 | ||
|
|
bbcef5b648 | ||
|
|
b3b6f6ff99 | ||
|
|
71b97d16f3 | ||
|
|
25d1f4aa03 | ||
|
|
22f5c55560 | ||
|
|
3cf33e9e9f | ||
|
|
a288c5e54a | ||
|
|
c3e9d3205f | ||
|
|
227fbec0fc | ||
|
|
dc21089720 | ||
|
|
f6bb864fc7 | ||
|
|
bd7d14f293 | ||
|
|
982211da16 | ||
|
|
a1740d9766 | ||
|
|
e9795fb407 | ||
|
|
299924e512 | ||
|
|
a03e74efc1 | ||
|
|
3c03a492f9 | ||
|
|
56c5833c4a | ||
|
|
63b07461da | ||
|
|
1c3288f038 | ||
|
|
8ecd6aeb5b | ||
|
|
4d00715902 | ||
|
|
95aeb2a3d6 | ||
|
|
b0a98f480d | ||
|
|
cb73551e8d | ||
|
|
4d946107e7 | ||
|
|
c795f44ea5 | ||
|
|
ecd9567624 | ||
|
|
d6fdfa4624 | ||
|
|
58ace2b1dc | ||
|
|
8f6089f225 | ||
|
|
19627fed47 | ||
|
|
83145e2bb1 | ||
|
|
621c76324a | ||
|
|
e961e1c08a | ||
|
|
e740674cb8 | ||
|
|
23ced66a6b | ||
|
|
b637222a5d | ||
|
|
9a0f7dd2c8 | ||
|
|
440e5fc7dc | ||
|
|
74ed7238b0 | ||
|
|
38d734ddcf | ||
|
|
cbeed9da92 | ||
|
|
a369d46795 | ||
|
|
1956f4b66b | ||
|
|
90b38da321 | ||
|
|
4594b4f27a | ||
|
|
ff3f0131bd | ||
|
|
5b793fef99 | ||
|
|
13aa1642ac | ||
|
|
d905cc4737 | ||
|
|
d954f3c4ee | ||
|
|
c770024ce1 | ||
|
|
c1f95640c4 | ||
|
|
48ef2b50eb | ||
|
|
071aa09c6e | ||
|
|
10cd3c906d | ||
|
|
0fca37f803 | ||
|
|
9dd94f7396 | ||
|
|
ce65c7b396 | ||
|
|
a80a084de9 | ||
|
|
ddc625f2fe | ||
|
|
842b15b839 | ||
|
|
4506b4536b | ||
|
|
dbe627594e | ||
|
|
130fe11f2b | ||
|
|
3bce1ab6f2 | ||
|
|
fe773c0a46 | ||
|
|
ecc90e3787 | ||
|
|
6e0d4b6761 | ||
|
|
53ad2ab17d | ||
|
|
a2a59dfb75 | ||
|
|
829af34165 | ||
|
|
1579eae899 | ||
|
|
6fcdce9c74 | ||
|
|
ac785323be | ||
|
|
d68207f7ca | ||
|
|
ddc615491d | ||
|
|
b1031c0d07 | ||
|
|
cdba31b9d5 | ||
|
|
83da0d6374 | ||
|
|
bb504b06b4 | ||
|
|
55717aeaea | ||
|
|
e886aae69e | ||
|
|
adceea62b6 | ||
|
|
348f13ad57 | ||
|
|
e448db56ee | ||
|
|
dd60d52814 | ||
|
|
428c3163c5 | ||
|
|
339d4879a0 | ||
|
|
ded95f89d3 | ||
|
|
5949095693 | ||
|
|
410178bb88 | ||
|
|
9cbfbd034e | ||
|
|
3b50f8bcd6 | ||
|
|
85442c797c | ||
|
|
3e723b7f5e | ||
|
|
6b423f0d9e | ||
|
|
bdc43f8241 | ||
|
|
9171dde346 | ||
|
|
6826dbab46 | ||
|
|
b2164040ac | ||
|
|
307bb5f72d | ||
|
|
963de5ae2a | ||
|
|
2b022e6979 | ||
|
|
cfd9edb0fe | ||
|
|
74b45809d1 | ||
|
|
507bab4b21 | ||
|
|
f45b6c1066 | ||
|
|
ebebb29be9 | ||
|
|
2e0b2484a9 | ||
|
|
ff7a13136d | ||
|
|
4b8398a6ed | ||
|
|
a684c1a281 | ||
|
|
b25f4f5272 | ||
|
|
c003b95ed4 | ||
|
|
0cbfed0c55 | ||
|
|
ee30b1c0ab | ||
|
|
b3362b7dfd | ||
|
|
99d72ae892 | ||
|
|
39145d45d1 | ||
|
|
627a5bfa73 | ||
|
|
ab35383fda | ||
|
|
9f12483ed2 | ||
|
|
4e331e27f8 | ||
|
|
71e02d5298 | ||
|
|
0008ed9ea4 | ||
|
|
3bd1370dbc | ||
|
|
a426ba29d5 | ||
|
|
a813938bef | ||
|
|
295272b73c | ||
|
|
703177e26a | ||
|
|
b992e62207 | ||
|
|
4691bea988 | ||
|
|
fce753c3d5 | ||
|
|
670a31f84f | ||
|
|
25358e0ba4 | ||
|
|
b6f9bc7ca8 | ||
|
|
79ccab2fd2 | ||
|
|
8d1d673760 | ||
|
|
6c2512bc35 | ||
|
|
2c1a55d314 | ||
|
|
e88bbb7296 | ||
|
|
06547a29be | ||
|
|
8ca1a78b1a | ||
|
|
6c59decfba | ||
|
|
732a963e04 | ||
|
|
cd9922f497 | ||
|
|
9554b52dba | ||
|
|
8c90b3ae99 | ||
|
|
811d367c49 | ||
|
|
1d9824ec60 | ||
|
|
5c6730bd0f | ||
|
|
78b3c04320 | ||
|
|
0ce217e309 | ||
|
|
d1536b7378 | ||
|
|
eb664a3d72 | ||
|
|
96dd5baf98 | ||
|
|
18eed1d727 | ||
|
|
ce72e40607 | ||
|
|
8615597984 | ||
|
|
a333bbaa12 | ||
|
|
2bc847ac57 | ||
|
|
24197ad684 | ||
|
|
92323ee89f | ||
|
|
0f2d93b3a6 | ||
|
|
f96b9f2783 | ||
|
|
f370c68d92 | ||
|
|
f8e147cb73 | ||
|
|
ceb88b82f1 | ||
|
|
a6c0992f47 | ||
|
|
9283692888 | ||
|
|
9acc153698 | ||
|
|
017b8b10b6 | ||
|
|
4ddfe70ae2 | ||
|
|
53dc25e532 | ||
|
|
542b57cf21 | ||
|
|
afd4d17b3c | ||
|
|
82132b6c4c | ||
|
|
21d8621d11 | ||
|
|
e36fd891e4 | ||
|
|
954b241f34 | ||
|
|
f038b7fc3d | ||
|
|
3f56494834 | ||
|
|
6a811b97b9 | ||
|
|
30dbc0a75b | ||
|
|
1900da6d24 | ||
|
|
8f38d12eee | ||
|
|
3f5f45f002 | ||
|
|
e6528cb48d | ||
|
|
041184928d | ||
|
|
b108063f75 | ||
|
|
9ce336b3d1 | ||
|
|
b5da760544 | ||
|
|
7e520e2089 | ||
|
|
07af7d5337 | ||
|
|
696a9ba3f9 | ||
|
|
9db6776dbe | ||
|
|
1c6a242b2e | ||
|
|
a58db736cf | ||
|
|
449ea43718 | ||
|
|
260c2634b9 | ||
|
|
6d0db57c02 | ||
|
|
11593d64b8 | ||
|
|
e4a0b9dbfd | ||
|
|
bb770e33f8 | ||
|
|
d048128004 | ||
|
|
eecece2afe | ||
|
|
74c7068a25 | ||
|
|
59360240b3 | ||
|
|
57d33c5027 | ||
|
|
e1c5526cb2 | ||
|
|
290c2ef84f | ||
|
|
91ba235b3c | ||
|
|
d13fe1e431 | ||
|
|
f361c1805c | ||
|
|
52b8ad45d1 | ||
|
|
9b6c85d82e | ||
|
|
88b8fc30a2 | ||
|
|
1a0463ea04 | ||
|
|
cab91124b4 | ||
|
|
8d9ea7c132 | ||
|
|
c5558280d7 | ||
|
|
3913f5f7ae | ||
|
|
e8c69aa654 | ||
|
|
b2b37d97cf | ||
|
|
4796adf5cb | ||
|
|
2c02c2ae5d | ||
|
|
ef824b7395 | ||
|
|
2930daf68c | ||
|
|
0481e3ca74 | ||
|
|
073618d375 | ||
|
|
5ddf03d324 | ||
|
|
ac98be85ce | ||
|
|
048fae9de6 | ||
|
|
81735df1fa | ||
|
|
9c32ab0d8b | ||
|
|
861e75f503 | ||
|
|
e891120584 | ||
|
|
2045bb3c21 | ||
|
|
a498488c59 | ||
|
|
dd43ee3dbf | ||
|
|
39ad9eb8f3 | ||
|
|
b30ba5a92b |
@@ -1,19 +0,0 @@
|
||||
compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
|
||||
compat/zlib/contrib/vstudio/readme.txt
|
||||
compat/zlib/contrib/vstudio/*/zlib.rc
|
||||
compat/zlib/win32/*.txt
|
||||
compat/zlib/win64/*.txt
|
||||
libtommath/*.dsp
|
||||
libtommath/*.sln
|
||||
libtommath/*.vcproj
|
||||
tools/tcl.hpj.in
|
||||
tools/tcl.wse.in
|
||||
win/buildall.vc.bat
|
||||
win/coffbase.txt
|
||||
win/makefile.vc
|
||||
win/rules.vc
|
||||
win/rules-ext.vc
|
||||
win/targets.vc
|
||||
win/tcl.dsp
|
||||
win/tcl.dsw
|
||||
win/tcl.hpj.in
|
||||
@@ -0,0 +1,3 @@
|
||||
Important Note
|
||||
==========
|
||||
Please do not file issues with Tcl on Github. They are unlikely to be noticed in a timely fashion. Tcl issues are hosted in the [tcl fossil repository on core.tcl.tk](https://core.tcl.tk/tcl/tktnew); please post them there.
|
||||
@@ -0,0 +1,3 @@
|
||||
Important Note
|
||||
==========
|
||||
Please do not file pull requests with Tcl on Github. They are unlikely to be noticed in a timely fashion. Tcl issues (including patches) are hosted in the [tcl fossil repository on core.tcl.tk](https://core.tcl.tk/tcl/tktnew); please post them there.
|
||||
+1
-1
@@ -1426,7 +1426,7 @@
|
||||
initialization assumptions of the TIP 280 code in CompileWord().
|
||||
|
||||
* generic/tclCompExpr.c: Suppress the attempt to convert to
|
||||
numeric when pre-compiling a constant expresion indicates an error.
|
||||
numeric when pre-compiling a constant expression indicates an error.
|
||||
|
||||
2007-08-22 Miguel Sofer <msofer@users.sf.net>
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
*/
|
||||
|
||||
|
||||
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
|
||||
#ifndef __USE_FILE_OFFSET64
|
||||
#define __USE_FILE_OFFSET64
|
||||
@@ -28,7 +27,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(IOAPI_NO_64)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
@@ -39,8 +38,7 @@
|
||||
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "tinydir.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -172,6 +170,7 @@ void do_banner()
|
||||
void do_help()
|
||||
{
|
||||
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
|
||||
" -r Scan directories recursively\n" \
|
||||
" -o Overwrite existing file.zip\n" \
|
||||
" -a Append to existing file.zip\n" \
|
||||
" -0 Store only\n" \
|
||||
@@ -243,12 +242,153 @@ int isLargeFile(const char* filename)
|
||||
return largeFile;
|
||||
}
|
||||
|
||||
void addFileToZip(zipFile zf, const char *filenameinzip, const char *password, int opt_exclude_path,int opt_compress_level) {
|
||||
FILE * fin;
|
||||
int size_read;
|
||||
const char *savefilenameinzip;
|
||||
zip_fileinfo zi;
|
||||
unsigned long crcFile=0;
|
||||
int zip64 = 0;
|
||||
int err=0;
|
||||
int size_buf=WRITEBUFFERSIZE;
|
||||
unsigned char buf[WRITEBUFFERSIZE];
|
||||
zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
|
||||
zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
|
||||
zi.dosDate = 0;
|
||||
zi.internal_fa = 0;
|
||||
zi.external_fa = 0;
|
||||
filetime(filenameinzip,&zi.tmz_date,&zi.dosDate);
|
||||
|
||||
/*
|
||||
err = zipOpenNewFileInZip(zf,filenameinzip,&zi,
|
||||
NULL,0,NULL,0,NULL / * comment * /,
|
||||
(opt_compress_level != 0) ? Z_DEFLATED : 0,
|
||||
opt_compress_level);
|
||||
*/
|
||||
if ((password != NULL) && (err==ZIP_OK))
|
||||
err = getFileCrc(filenameinzip,buf,size_buf,&crcFile);
|
||||
|
||||
zip64 = isLargeFile(filenameinzip);
|
||||
|
||||
/* The path name saved, should not include a leading slash. */
|
||||
/*if it did, windows/xp and dynazip couldn't read the zip file. */
|
||||
savefilenameinzip = filenameinzip;
|
||||
while( savefilenameinzip[0] == '\\' || savefilenameinzip[0] == '/' )
|
||||
{
|
||||
savefilenameinzip++;
|
||||
}
|
||||
|
||||
/*should the zip file contain any path at all?*/
|
||||
if( opt_exclude_path )
|
||||
{
|
||||
const char *tmpptr;
|
||||
const char *lastslash = 0;
|
||||
for( tmpptr = savefilenameinzip; *tmpptr; tmpptr++)
|
||||
{
|
||||
if( *tmpptr == '\\' || *tmpptr == '/')
|
||||
{
|
||||
lastslash = tmpptr;
|
||||
}
|
||||
}
|
||||
if( lastslash != NULL )
|
||||
{
|
||||
savefilenameinzip = lastslash+1; // base filename follows last slash.
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
err = zipOpenNewFileInZip3_64(zf,savefilenameinzip,&zi,
|
||||
NULL,0,NULL,0,NULL /* comment*/,
|
||||
(opt_compress_level != 0) ? Z_DEFLATED : 0,
|
||||
opt_compress_level,0,
|
||||
/* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
password,crcFile, zip64);
|
||||
|
||||
if (err != ZIP_OK)
|
||||
printf("error in opening %s in zipfile\n",filenameinzip);
|
||||
else
|
||||
{
|
||||
fin = FOPEN_FUNC(filenameinzip,"rb");
|
||||
if (fin==NULL)
|
||||
{
|
||||
err=ZIP_ERRNO;
|
||||
printf("error in opening %s for reading\n",filenameinzip);
|
||||
}
|
||||
}
|
||||
|
||||
if (err == ZIP_OK)
|
||||
do
|
||||
{
|
||||
err = ZIP_OK;
|
||||
size_read = (int)fread(buf,1,size_buf,fin);
|
||||
if (size_read < size_buf)
|
||||
if (feof(fin)==0)
|
||||
{
|
||||
printf("error in reading %s\n",filenameinzip);
|
||||
err = ZIP_ERRNO;
|
||||
}
|
||||
|
||||
if (size_read>0)
|
||||
{
|
||||
err = zipWriteInFileInZip (zf,buf,size_read);
|
||||
if (err<0)
|
||||
{
|
||||
printf("error in writing %s in the zipfile\n",
|
||||
filenameinzip);
|
||||
}
|
||||
|
||||
}
|
||||
} while ((err == ZIP_OK) && (size_read>0));
|
||||
|
||||
if (fin)
|
||||
fclose(fin);
|
||||
|
||||
if (err<0)
|
||||
err=ZIP_ERRNO;
|
||||
else
|
||||
{
|
||||
err = zipCloseFileInZip(zf);
|
||||
if (err!=ZIP_OK)
|
||||
printf("error in closing %s in the zipfile\n",
|
||||
filenameinzip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void addPathToZip(zipFile zf, const char *filenameinzip, const char *password, int opt_exclude_path,int opt_compress_level) {
|
||||
tinydir_dir dir;
|
||||
int i;
|
||||
char newname[512];
|
||||
|
||||
tinydir_open_sorted(&dir, filenameinzip);
|
||||
|
||||
for (i = 0; i < dir.n_files; i++)
|
||||
{
|
||||
tinydir_file file;
|
||||
tinydir_readfile_n(&dir, &file, i);
|
||||
if(strcmp(file.name,".")==0) continue;
|
||||
if(strcmp(file.name,"..")==0) continue;
|
||||
sprintf(newname,"%s/%s",dir.path,file.name);
|
||||
if (file.is_dir)
|
||||
{
|
||||
addPathToZip(zf,newname,password,opt_exclude_path,opt_compress_level);
|
||||
} else {
|
||||
addFileToZip(zf,newname,password,opt_exclude_path,opt_compress_level);
|
||||
}
|
||||
}
|
||||
|
||||
tinydir_close(&dir);
|
||||
}
|
||||
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int i;
|
||||
int opt_overwrite=0;
|
||||
int opt_recursive=0;
|
||||
int opt_overwrite=1;
|
||||
int opt_compress_level=Z_DEFAULT_COMPRESSION;
|
||||
int opt_exclude_path=0;
|
||||
int zipfilenamearg = 0;
|
||||
@@ -285,7 +425,8 @@ int main(argc,argv)
|
||||
opt_compress_level = c-'0';
|
||||
if ((c=='j') || (c=='J'))
|
||||
opt_exclude_path = 1;
|
||||
|
||||
if ((c=='r') || (c=='R'))
|
||||
opt_recursive = 1;
|
||||
if (((c=='p') || (c=='P')) && (i+1<argc))
|
||||
{
|
||||
password=argv[i+1];
|
||||
@@ -392,117 +533,14 @@ int main(argc,argv)
|
||||
((argv[i][1]=='o') || (argv[i][1]=='O') ||
|
||||
(argv[i][1]=='a') || (argv[i][1]=='A') ||
|
||||
(argv[i][1]=='p') || (argv[i][1]=='P') ||
|
||||
(argv[i][1]=='r') || (argv[i][1]=='R') ||
|
||||
((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
|
||||
(strlen(argv[i]) == 2)))
|
||||
{
|
||||
FILE * fin;
|
||||
int size_read;
|
||||
const char* filenameinzip = argv[i];
|
||||
const char *savefilenameinzip;
|
||||
zip_fileinfo zi;
|
||||
unsigned long crcFile=0;
|
||||
int zip64 = 0;
|
||||
|
||||
zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
|
||||
zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
|
||||
zi.dosDate = 0;
|
||||
zi.internal_fa = 0;
|
||||
zi.external_fa = 0;
|
||||
filetime(filenameinzip,&zi.tmz_date,&zi.dosDate);
|
||||
|
||||
/*
|
||||
err = zipOpenNewFileInZip(zf,filenameinzip,&zi,
|
||||
NULL,0,NULL,0,NULL / * comment * /,
|
||||
(opt_compress_level != 0) ? Z_DEFLATED : 0,
|
||||
opt_compress_level);
|
||||
*/
|
||||
if ((password != NULL) && (err==ZIP_OK))
|
||||
err = getFileCrc(filenameinzip,buf,size_buf,&crcFile);
|
||||
|
||||
zip64 = isLargeFile(filenameinzip);
|
||||
|
||||
/* The path name saved, should not include a leading slash. */
|
||||
/*if it did, windows/xp and dynazip couldn't read the zip file. */
|
||||
savefilenameinzip = filenameinzip;
|
||||
while( savefilenameinzip[0] == '\\' || savefilenameinzip[0] == '/' )
|
||||
{
|
||||
savefilenameinzip++;
|
||||
}
|
||||
|
||||
/*should the zip file contain any path at all?*/
|
||||
if( opt_exclude_path )
|
||||
{
|
||||
const char *tmpptr;
|
||||
const char *lastslash = 0;
|
||||
for( tmpptr = savefilenameinzip; *tmpptr; tmpptr++)
|
||||
{
|
||||
if( *tmpptr == '\\' || *tmpptr == '/')
|
||||
{
|
||||
lastslash = tmpptr;
|
||||
}
|
||||
}
|
||||
if( lastslash != NULL )
|
||||
{
|
||||
savefilenameinzip = lastslash+1; // base filename follows last slash.
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
err = zipOpenNewFileInZip3_64(zf,savefilenameinzip,&zi,
|
||||
NULL,0,NULL,0,NULL /* comment*/,
|
||||
(opt_compress_level != 0) ? Z_DEFLATED : 0,
|
||||
opt_compress_level,0,
|
||||
/* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
password,crcFile, zip64);
|
||||
|
||||
if (err != ZIP_OK)
|
||||
printf("error in opening %s in zipfile\n",filenameinzip);
|
||||
else
|
||||
{
|
||||
fin = FOPEN_FUNC(filenameinzip,"rb");
|
||||
if (fin==NULL)
|
||||
{
|
||||
err=ZIP_ERRNO;
|
||||
printf("error in opening %s for reading\n",filenameinzip);
|
||||
}
|
||||
}
|
||||
|
||||
if (err == ZIP_OK)
|
||||
do
|
||||
{
|
||||
err = ZIP_OK;
|
||||
size_read = (int)fread(buf,1,size_buf,fin);
|
||||
if (size_read < size_buf)
|
||||
if (feof(fin)==0)
|
||||
{
|
||||
printf("error in reading %s\n",filenameinzip);
|
||||
err = ZIP_ERRNO;
|
||||
}
|
||||
|
||||
if (size_read>0)
|
||||
{
|
||||
err = zipWriteInFileInZip (zf,buf,size_read);
|
||||
if (err<0)
|
||||
{
|
||||
printf("error in writing %s in the zipfile\n",
|
||||
filenameinzip);
|
||||
}
|
||||
|
||||
}
|
||||
} while ((err == ZIP_OK) && (size_read>0));
|
||||
|
||||
if (fin)
|
||||
fclose(fin);
|
||||
|
||||
if (err<0)
|
||||
err=ZIP_ERRNO;
|
||||
else
|
||||
{
|
||||
err = zipCloseFileInZip(zf);
|
||||
if (err!=ZIP_OK)
|
||||
printf("error in closing %s in the zipfile\n",
|
||||
filenameinzip);
|
||||
if(opt_recursive) {
|
||||
addPathToZip(zf,argv[i],password,opt_exclude_path,opt_compress_level);
|
||||
} else {
|
||||
addFileToZip(zf,argv[i],password,opt_exclude_path,opt_compress_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+816
@@ -0,0 +1,816 @@
|
||||
/*
|
||||
Copyright (c) 2013-2017, tinydir authors:
|
||||
- Cong Xu
|
||||
- Lautis Sun
|
||||
- Baudouin Feildel
|
||||
- Andargor <andargor@yahoo.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef TINYDIR_H
|
||||
#define TINYDIR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if ((defined _UNICODE) && !(defined UNICODE))
|
||||
#define UNICODE
|
||||
#endif
|
||||
|
||||
#if ((defined UNICODE) && !(defined _UNICODE))
|
||||
#define _UNICODE
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# include <tchar.h>
|
||||
# pragma warning(push)
|
||||
# pragma warning (disable : 4996)
|
||||
#else
|
||||
# include <dirent.h>
|
||||
# include <libgen.h>
|
||||
# include <sys/stat.h>
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
#ifdef __MINGW32__
|
||||
# include <tchar.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* types */
|
||||
|
||||
/* Windows UNICODE wide character support */
|
||||
#if defined _MSC_VER || defined __MINGW32__
|
||||
# define _tinydir_char_t TCHAR
|
||||
# define TINYDIR_STRING(s) _TEXT(s)
|
||||
# define _tinydir_strlen _tcslen
|
||||
# define _tinydir_strcpy _tcscpy
|
||||
# define _tinydir_strcat _tcscat
|
||||
# define _tinydir_strcmp _tcscmp
|
||||
# define _tinydir_strrchr _tcsrchr
|
||||
# define _tinydir_strncmp _tcsncmp
|
||||
#else
|
||||
# define _tinydir_char_t char
|
||||
# define TINYDIR_STRING(s) s
|
||||
# define _tinydir_strlen strlen
|
||||
# define _tinydir_strcpy strcpy
|
||||
# define _tinydir_strcat strcat
|
||||
# define _tinydir_strcmp strcmp
|
||||
# define _tinydir_strrchr strrchr
|
||||
# define _tinydir_strncmp strncmp
|
||||
#endif
|
||||
|
||||
#if (defined _MSC_VER || defined __MINGW32__)
|
||||
# include <windows.h>
|
||||
# define _TINYDIR_PATH_MAX MAX_PATH
|
||||
#elif defined __linux__
|
||||
# include <limits.h>
|
||||
# define _TINYDIR_PATH_MAX PATH_MAX
|
||||
#elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
# include <sys/param.h>
|
||||
# if defined(BSD)
|
||||
# include <limits.h>
|
||||
# define _TINYDIR_PATH_MAX PATH_MAX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _TINYDIR_PATH_MAX
|
||||
#define _TINYDIR_PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* extra chars for the "\\*" mask */
|
||||
# define _TINYDIR_PATH_EXTRA 2
|
||||
#else
|
||||
# define _TINYDIR_PATH_EXTRA 0
|
||||
#endif
|
||||
|
||||
#define _TINYDIR_FILENAME_MAX 256
|
||||
|
||||
#if (defined _MSC_VER || defined __MINGW32__)
|
||||
#define _TINYDIR_DRIVE_MAX 3
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define _TINYDIR_FUNC static __inline
|
||||
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
|
||||
# define _TINYDIR_FUNC static __inline__
|
||||
#else
|
||||
# define _TINYDIR_FUNC static inline
|
||||
#endif
|
||||
|
||||
/* readdir_r usage; define TINYDIR_USE_READDIR_R to use it (if supported) */
|
||||
#ifdef TINYDIR_USE_READDIR_R
|
||||
|
||||
/* readdir_r is a POSIX-only function, and may not be available under various
|
||||
* environments/settings, e.g. MinGW. Use readdir fallback */
|
||||
#if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE ||\
|
||||
_POSIX_SOURCE
|
||||
# define _TINYDIR_HAS_READDIR_R
|
||||
#endif
|
||||
#if _POSIX_C_SOURCE >= 200112L
|
||||
# define _TINYDIR_HAS_FPATHCONF
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#if _BSD_SOURCE || _SVID_SOURCE || \
|
||||
(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
|
||||
# define _TINYDIR_HAS_DIRFD
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#if defined _TINYDIR_HAS_FPATHCONF && defined _TINYDIR_HAS_DIRFD &&\
|
||||
defined _PC_NAME_MAX
|
||||
# define _TINYDIR_USE_FPATHCONF
|
||||
#endif
|
||||
#if defined __MINGW32__ || !defined _TINYDIR_HAS_READDIR_R ||\
|
||||
!(defined _TINYDIR_USE_FPATHCONF || defined NAME_MAX)
|
||||
# define _TINYDIR_USE_READDIR
|
||||
#endif
|
||||
|
||||
/* Use readdir by default */
|
||||
#else
|
||||
# define _TINYDIR_USE_READDIR
|
||||
#endif
|
||||
|
||||
/* MINGW32 has two versions of dirent, ASCII and UNICODE*/
|
||||
#ifndef _MSC_VER
|
||||
#if (defined __MINGW32__) && (defined _UNICODE)
|
||||
#define _TINYDIR_DIR _WDIR
|
||||
#define _tinydir_dirent _wdirent
|
||||
#define _tinydir_opendir _wopendir
|
||||
#define _tinydir_readdir _wreaddir
|
||||
#define _tinydir_closedir _wclosedir
|
||||
#else
|
||||
#define _TINYDIR_DIR DIR
|
||||
#define _tinydir_dirent dirent
|
||||
#define _tinydir_opendir opendir
|
||||
#define _tinydir_readdir readdir
|
||||
#define _tinydir_closedir closedir
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Allow user to use a custom allocator by defining _TINYDIR_MALLOC and _TINYDIR_FREE. */
|
||||
#if defined(_TINYDIR_MALLOC) && defined(_TINYDIR_FREE)
|
||||
#elif !defined(_TINYDIR_MALLOC) && !defined(_TINYDIR_FREE)
|
||||
#else
|
||||
#error "Either define both alloc and free or none of them!"
|
||||
#endif
|
||||
|
||||
#if !defined(_TINYDIR_MALLOC)
|
||||
#define _TINYDIR_MALLOC(_size) malloc(_size)
|
||||
#define _TINYDIR_FREE(_ptr) free(_ptr)
|
||||
#endif /* !defined(_TINYDIR_MALLOC) */
|
||||
|
||||
typedef struct tinydir_file
|
||||
{
|
||||
_tinydir_char_t path[_TINYDIR_PATH_MAX];
|
||||
_tinydir_char_t name[_TINYDIR_FILENAME_MAX];
|
||||
_tinydir_char_t *extension;
|
||||
int is_dir;
|
||||
int is_reg;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#ifdef __MINGW32__
|
||||
struct _stat _s;
|
||||
#else
|
||||
struct stat _s;
|
||||
#endif
|
||||
#endif
|
||||
} tinydir_file;
|
||||
|
||||
typedef struct tinydir_dir
|
||||
{
|
||||
_tinydir_char_t path[_TINYDIR_PATH_MAX];
|
||||
int has_next;
|
||||
size_t n_files;
|
||||
|
||||
tinydir_file *_files;
|
||||
#ifdef _MSC_VER
|
||||
HANDLE _h;
|
||||
WIN32_FIND_DATA _f;
|
||||
#else
|
||||
_TINYDIR_DIR *_d;
|
||||
struct _tinydir_dirent *_e;
|
||||
#ifndef _TINYDIR_USE_READDIR
|
||||
struct _tinydir_dirent *_ep;
|
||||
#endif
|
||||
#endif
|
||||
} tinydir_dir;
|
||||
|
||||
|
||||
/* declarations */
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_open(tinydir_dir *dir, const _tinydir_char_t *path);
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_open_sorted(tinydir_dir *dir, const _tinydir_char_t *path);
|
||||
_TINYDIR_FUNC
|
||||
void tinydir_close(tinydir_dir *dir);
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_next(tinydir_dir *dir);
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_readfile(const tinydir_dir *dir, tinydir_file *file);
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_readfile_n(const tinydir_dir *dir, tinydir_file *file, size_t i);
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_open_subdir_n(tinydir_dir *dir, size_t i);
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path);
|
||||
_TINYDIR_FUNC
|
||||
void _tinydir_get_ext(tinydir_file *file);
|
||||
_TINYDIR_FUNC
|
||||
int _tinydir_file_cmp(const void *a, const void *b);
|
||||
#ifndef _MSC_VER
|
||||
#ifndef _TINYDIR_USE_READDIR
|
||||
_TINYDIR_FUNC
|
||||
size_t _tinydir_dirent_buf_size(_TINYDIR_DIR *dirp);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* definitions*/
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_open(tinydir_dir *dir, const _tinydir_char_t *path)
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
#ifndef _TINYDIR_USE_READDIR
|
||||
int error;
|
||||
int size; /* using int size */
|
||||
#endif
|
||||
#else
|
||||
_tinydir_char_t path_buf[_TINYDIR_PATH_MAX];
|
||||
#endif
|
||||
_tinydir_char_t *pathp;
|
||||
|
||||
if (dir == NULL || path == NULL || _tinydir_strlen(path) == 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (_tinydir_strlen(path) + _TINYDIR_PATH_EXTRA >= _TINYDIR_PATH_MAX)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* initialise dir */
|
||||
dir->_files = NULL;
|
||||
#ifdef _MSC_VER
|
||||
dir->_h = INVALID_HANDLE_VALUE;
|
||||
#else
|
||||
dir->_d = NULL;
|
||||
#ifndef _TINYDIR_USE_READDIR
|
||||
dir->_ep = NULL;
|
||||
#endif
|
||||
#endif
|
||||
tinydir_close(dir);
|
||||
|
||||
_tinydir_strcpy(dir->path, path);
|
||||
/* Remove trailing slashes */
|
||||
pathp = &dir->path[_tinydir_strlen(dir->path) - 1];
|
||||
while (pathp != dir->path && (*pathp == TINYDIR_STRING('\\') || *pathp == TINYDIR_STRING('/')))
|
||||
{
|
||||
*pathp = TINYDIR_STRING('\0');
|
||||
pathp++;
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
_tinydir_strcpy(path_buf, dir->path);
|
||||
_tinydir_strcat(path_buf, TINYDIR_STRING("\\*"));
|
||||
#if (defined WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP)
|
||||
dir->_h = FindFirstFileEx(path_buf, FindExInfoStandard, &dir->_f, FindExSearchNameMatch, NULL, 0);
|
||||
#else
|
||||
dir->_h = FindFirstFile(path_buf, &dir->_f);
|
||||
#endif
|
||||
if (dir->_h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
errno = ENOENT;
|
||||
#else
|
||||
dir->_d = _tinydir_opendir(path);
|
||||
if (dir->_d == NULL)
|
||||
{
|
||||
#endif
|
||||
goto bail;
|
||||
}
|
||||
|
||||
/* read first file */
|
||||
dir->has_next = 1;
|
||||
#ifndef _MSC_VER
|
||||
#ifdef _TINYDIR_USE_READDIR
|
||||
dir->_e = _tinydir_readdir(dir->_d);
|
||||
#else
|
||||
/* allocate dirent buffer for readdir_r */
|
||||
size = _tinydir_dirent_buf_size(dir->_d); /* conversion to int */
|
||||
if (size == -1) return -1;
|
||||
dir->_ep = (struct _tinydir_dirent*)_TINYDIR_MALLOC(size);
|
||||
if (dir->_ep == NULL) return -1;
|
||||
|
||||
error = readdir_r(dir->_d, dir->_ep, &dir->_e);
|
||||
if (error != 0) return -1;
|
||||
#endif
|
||||
if (dir->_e == NULL)
|
||||
{
|
||||
dir->has_next = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
bail:
|
||||
tinydir_close(dir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_open_sorted(tinydir_dir *dir, const _tinydir_char_t *path)
|
||||
{
|
||||
/* Count the number of files first, to pre-allocate the files array */
|
||||
size_t n_files = 0;
|
||||
if (tinydir_open(dir, path) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
while (dir->has_next)
|
||||
{
|
||||
n_files++;
|
||||
if (tinydir_next(dir) == -1)
|
||||
{
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
tinydir_close(dir);
|
||||
|
||||
if (tinydir_open(dir, path) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
dir->n_files = 0;
|
||||
dir->_files = (tinydir_file *)_TINYDIR_MALLOC(sizeof *dir->_files * n_files);
|
||||
if (dir->_files == NULL)
|
||||
{
|
||||
goto bail;
|
||||
}
|
||||
while (dir->has_next)
|
||||
{
|
||||
tinydir_file *p_file;
|
||||
dir->n_files++;
|
||||
|
||||
p_file = &dir->_files[dir->n_files - 1];
|
||||
if (tinydir_readfile(dir, p_file) == -1)
|
||||
{
|
||||
goto bail;
|
||||
}
|
||||
|
||||
if (tinydir_next(dir) == -1)
|
||||
{
|
||||
goto bail;
|
||||
}
|
||||
|
||||
/* Just in case the number of files has changed between the first and
|
||||
second reads, terminate without writing into unallocated memory */
|
||||
if (dir->n_files == n_files)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qsort(dir->_files, dir->n_files, sizeof(tinydir_file), _tinydir_file_cmp);
|
||||
|
||||
return 0;
|
||||
|
||||
bail:
|
||||
tinydir_close(dir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
_TINYDIR_FUNC
|
||||
void tinydir_close(tinydir_dir *dir)
|
||||
{
|
||||
if (dir == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
memset(dir->path, 0, sizeof(dir->path));
|
||||
dir->has_next = 0;
|
||||
dir->n_files = 0;
|
||||
_TINYDIR_FREE(dir->_files);
|
||||
dir->_files = NULL;
|
||||
#ifdef _MSC_VER
|
||||
if (dir->_h != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
FindClose(dir->_h);
|
||||
}
|
||||
dir->_h = INVALID_HANDLE_VALUE;
|
||||
#else
|
||||
if (dir->_d)
|
||||
{
|
||||
_tinydir_closedir(dir->_d);
|
||||
}
|
||||
dir->_d = NULL;
|
||||
dir->_e = NULL;
|
||||
#ifndef _TINYDIR_USE_READDIR
|
||||
_TINYDIR_FREE(dir->_ep);
|
||||
dir->_ep = NULL;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_next(tinydir_dir *dir)
|
||||
{
|
||||
if (dir == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!dir->has_next)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
if (FindNextFile(dir->_h, &dir->_f) == 0)
|
||||
#else
|
||||
#ifdef _TINYDIR_USE_READDIR
|
||||
dir->_e = _tinydir_readdir(dir->_d);
|
||||
#else
|
||||
if (dir->_ep == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (readdir_r(dir->_d, dir->_ep, &dir->_e) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
if (dir->_e == NULL)
|
||||
#endif
|
||||
{
|
||||
dir->has_next = 0;
|
||||
#ifdef _MSC_VER
|
||||
if (GetLastError() != ERROR_SUCCESS &&
|
||||
GetLastError() != ERROR_NO_MORE_FILES)
|
||||
{
|
||||
tinydir_close(dir);
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_readfile(const tinydir_dir *dir, tinydir_file *file)
|
||||
{
|
||||
if (dir == NULL || file == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
if (dir->_h == INVALID_HANDLE_VALUE)
|
||||
#else
|
||||
if (dir->_e == NULL)
|
||||
#endif
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
if (_tinydir_strlen(dir->path) +
|
||||
_tinydir_strlen(
|
||||
#ifdef _MSC_VER
|
||||
dir->_f.cFileName
|
||||
#else
|
||||
dir->_e->d_name
|
||||
#endif
|
||||
) + 1 + _TINYDIR_PATH_EXTRA >=
|
||||
_TINYDIR_PATH_MAX)
|
||||
{
|
||||
/* the path for the file will be too long */
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
if (_tinydir_strlen(
|
||||
#ifdef _MSC_VER
|
||||
dir->_f.cFileName
|
||||
#else
|
||||
dir->_e->d_name
|
||||
#endif
|
||||
) >= _TINYDIR_FILENAME_MAX)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
_tinydir_strcpy(file->path, dir->path);
|
||||
_tinydir_strcat(file->path, TINYDIR_STRING("/"));
|
||||
_tinydir_strcpy(file->name,
|
||||
#ifdef _MSC_VER
|
||||
dir->_f.cFileName
|
||||
#else
|
||||
dir->_e->d_name
|
||||
#endif
|
||||
);
|
||||
_tinydir_strcat(file->path, file->name);
|
||||
#ifndef _MSC_VER
|
||||
#ifdef __MINGW32__
|
||||
if (_tstat(
|
||||
#else
|
||||
if (stat(
|
||||
#endif
|
||||
file->path, &file->_s) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
_tinydir_get_ext(file);
|
||||
|
||||
file->is_dir =
|
||||
#ifdef _MSC_VER
|
||||
!!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||
#else
|
||||
S_ISDIR(file->_s.st_mode);
|
||||
#endif
|
||||
file->is_reg =
|
||||
#ifdef _MSC_VER
|
||||
!!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) ||
|
||||
(
|
||||
!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) &&
|
||||
!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
|
||||
!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED) &&
|
||||
#ifdef FILE_ATTRIBUTE_INTEGRITY_STREAM
|
||||
!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_INTEGRITY_STREAM) &&
|
||||
#endif
|
||||
#ifdef FILE_ATTRIBUTE_NO_SCRUB_DATA
|
||||
!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_NO_SCRUB_DATA) &&
|
||||
#endif
|
||||
!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_OFFLINE) &&
|
||||
!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY));
|
||||
#else
|
||||
S_ISREG(file->_s.st_mode);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_readfile_n(const tinydir_dir *dir, tinydir_file *file, size_t i)
|
||||
{
|
||||
if (dir == NULL || file == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (i >= dir->n_files)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(file, &dir->_files[i], sizeof(tinydir_file));
|
||||
_tinydir_get_ext(file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_open_subdir_n(tinydir_dir *dir, size_t i)
|
||||
{
|
||||
_tinydir_char_t path[_TINYDIR_PATH_MAX];
|
||||
if (dir == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (i >= dir->n_files || !dir->_files[i].is_dir)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
_tinydir_strcpy(path, dir->_files[i].path);
|
||||
tinydir_close(dir);
|
||||
if (tinydir_open_sorted(dir, path) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Open a single file given its path */
|
||||
_TINYDIR_FUNC
|
||||
int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path)
|
||||
{
|
||||
tinydir_dir dir;
|
||||
int result = 0;
|
||||
int found = 0;
|
||||
_tinydir_char_t dir_name_buf[_TINYDIR_PATH_MAX];
|
||||
_tinydir_char_t file_name_buf[_TINYDIR_FILENAME_MAX];
|
||||
_tinydir_char_t *dir_name;
|
||||
_tinydir_char_t *base_name;
|
||||
#if (defined _MSC_VER || defined __MINGW32__)
|
||||
_tinydir_char_t drive_buf[_TINYDIR_PATH_MAX];
|
||||
_tinydir_char_t ext_buf[_TINYDIR_FILENAME_MAX];
|
||||
#endif
|
||||
|
||||
if (file == NULL || path == NULL || _tinydir_strlen(path) == 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (_tinydir_strlen(path) + _TINYDIR_PATH_EXTRA >= _TINYDIR_PATH_MAX)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get the parent path */
|
||||
#if (defined _MSC_VER || defined __MINGW32__)
|
||||
#if ((defined _MSC_VER) && (_MSC_VER >= 1400))
|
||||
_tsplitpath_s(
|
||||
path,
|
||||
drive_buf, _TINYDIR_DRIVE_MAX,
|
||||
dir_name_buf, _TINYDIR_FILENAME_MAX,
|
||||
file_name_buf, _TINYDIR_FILENAME_MAX,
|
||||
ext_buf, _TINYDIR_FILENAME_MAX);
|
||||
#else
|
||||
_tsplitpath(
|
||||
path,
|
||||
drive_buf,
|
||||
dir_name_buf,
|
||||
file_name_buf,
|
||||
ext_buf);
|
||||
#endif
|
||||
|
||||
/* _splitpath_s not work fine with only filename and widechar support */
|
||||
#ifdef _UNICODE
|
||||
if (drive_buf[0] == L'\xFEFE')
|
||||
drive_buf[0] = '\0';
|
||||
if (dir_name_buf[0] == L'\xFEFE')
|
||||
dir_name_buf[0] = '\0';
|
||||
#endif
|
||||
|
||||
if (errno)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
/* Emulate the behavior of dirname by returning "." for dir name if it's
|
||||
empty */
|
||||
if (drive_buf[0] == '\0' && dir_name_buf[0] == '\0')
|
||||
{
|
||||
_tinydir_strcpy(dir_name_buf, TINYDIR_STRING("."));
|
||||
}
|
||||
/* Concatenate the drive letter and dir name to form full dir name */
|
||||
_tinydir_strcat(drive_buf, dir_name_buf);
|
||||
dir_name = drive_buf;
|
||||
/* Concatenate the file name and extension to form base name */
|
||||
_tinydir_strcat(file_name_buf, ext_buf);
|
||||
base_name = file_name_buf;
|
||||
#else
|
||||
_tinydir_strcpy(dir_name_buf, path);
|
||||
dir_name = dirname(dir_name_buf);
|
||||
_tinydir_strcpy(file_name_buf, path);
|
||||
base_name =basename(file_name_buf);
|
||||
#endif
|
||||
|
||||
/* Open the parent directory */
|
||||
if (tinydir_open(&dir, dir_name) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read through the parent directory and look for the file */
|
||||
while (dir.has_next)
|
||||
{
|
||||
if (tinydir_readfile(&dir, file) == -1)
|
||||
{
|
||||
result = -1;
|
||||
goto bail;
|
||||
}
|
||||
if (_tinydir_strcmp(file->name, base_name) == 0)
|
||||
{
|
||||
/* File found */
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
tinydir_next(&dir);
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
result = -1;
|
||||
errno = ENOENT;
|
||||
}
|
||||
|
||||
bail:
|
||||
tinydir_close(&dir);
|
||||
return result;
|
||||
}
|
||||
|
||||
_TINYDIR_FUNC
|
||||
void _tinydir_get_ext(tinydir_file *file)
|
||||
{
|
||||
_tinydir_char_t *period = _tinydir_strrchr(file->name, TINYDIR_STRING('.'));
|
||||
if (period == NULL)
|
||||
{
|
||||
file->extension = &(file->name[_tinydir_strlen(file->name)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
file->extension = period + 1;
|
||||
}
|
||||
}
|
||||
|
||||
_TINYDIR_FUNC
|
||||
int _tinydir_file_cmp(const void *a, const void *b)
|
||||
{
|
||||
const tinydir_file *fa = (const tinydir_file *)a;
|
||||
const tinydir_file *fb = (const tinydir_file *)b;
|
||||
if (fa->is_dir != fb->is_dir)
|
||||
{
|
||||
return -(fa->is_dir - fb->is_dir);
|
||||
}
|
||||
return _tinydir_strncmp(fa->name, fb->name, _TINYDIR_FILENAME_MAX);
|
||||
}
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#ifndef _TINYDIR_USE_READDIR
|
||||
/*
|
||||
The following authored by Ben Hutchings <ben@decadent.org.uk>
|
||||
from https://womble.decadent.org.uk/readdir_r-advisory.html
|
||||
*/
|
||||
/* Calculate the required buffer size (in bytes) for directory *
|
||||
* entries read from the given directory handle. Return -1 if this *
|
||||
* this cannot be done. *
|
||||
* *
|
||||
* This code does not trust values of NAME_MAX that are less than *
|
||||
* 255, since some systems (including at least HP-UX) incorrectly *
|
||||
* define it to be a smaller value. */
|
||||
_TINYDIR_FUNC
|
||||
size_t _tinydir_dirent_buf_size(_TINYDIR_DIR *dirp)
|
||||
{
|
||||
long name_max;
|
||||
size_t name_end;
|
||||
/* parameter may be unused */
|
||||
(void)dirp;
|
||||
|
||||
#if defined _TINYDIR_USE_FPATHCONF
|
||||
name_max = fpathconf(dirfd(dirp), _PC_NAME_MAX);
|
||||
if (name_max == -1)
|
||||
#if defined(NAME_MAX)
|
||||
name_max = (NAME_MAX > 255) ? NAME_MAX : 255;
|
||||
#else
|
||||
return (size_t)(-1);
|
||||
#endif
|
||||
#elif defined(NAME_MAX)
|
||||
name_max = (NAME_MAX > 255) ? NAME_MAX : 255;
|
||||
#else
|
||||
#error "buffer size for readdir_r cannot be determined"
|
||||
#endif
|
||||
name_end = (size_t)offsetof(struct _tinydir_dirent, d_name) + name_max + 1;
|
||||
return (name_end > sizeof(struct _tinydir_dirent) ?
|
||||
name_end : sizeof(struct _tinydir_dirent));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
# if defined (_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
# endif
|
||||
|
||||
#endif
|
||||
Executable → Regular
+28
-1
@@ -8,7 +8,7 @@
|
||||
.so man.macros
|
||||
.BS
|
||||
.SH NAME
|
||||
Tcl_CreateObjCommand, Tcl_DeleteCommand, Tcl_DeleteCommandFromToken, Tcl_GetCommandInfo, Tcl_GetCommandInfoFromToken, Tcl_SetCommandInfo, Tcl_SetCommandInfoFromToken, Tcl_GetCommandName, Tcl_GetCommandFullName, Tcl_GetCommandFromObj \- implement new commands in C
|
||||
Tcl_CreateObjCommand, Tcl_DeleteCommand, Tcl_DeleteCommandFromToken, Tcl_GetCommandInfo, Tcl_GetCommandInfoFromToken, Tcl_SetCommandInfo, Tcl_SetCommandInfoFromToken, Tcl_GetCommandName, Tcl_GetCommandFullName, Tcl_GetCommandFromObj Tcl_RegisterCommandTypeName, Tcl_GetCommandTypeName \- implement new commands in C
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fB#include <tcl.h>\fR
|
||||
@@ -42,6 +42,14 @@ void
|
||||
.sp
|
||||
Tcl_Command
|
||||
\fBTcl_GetCommandFromObj\fR(\fIinterp, objPtr\fR)
|
||||
.sp
|
||||
.VS "info cmdtype feature"
|
||||
void
|
||||
\fBTcl_RegisterCommandTypeName\fR(\fIproc, typeName\fR)
|
||||
.sp
|
||||
const char *
|
||||
\fBTcl_GetCommandTypeName\fR(\fItoken\fR)
|
||||
.VE "info cmdtype feature"
|
||||
.SH ARGUMENTS
|
||||
.AS Tcl_CmdDeleteProc *deleteProc in/out
|
||||
.AP Tcl_Interp *interp in
|
||||
@@ -65,6 +73,9 @@ Pointer to structure containing various information about a
|
||||
Tcl command.
|
||||
.AP Tcl_Obj *objPtr in
|
||||
Value containing the name of a Tcl command.
|
||||
.AP "const char" *typeName in
|
||||
Indicates the name of the type of command implementation associated
|
||||
with a particular \fIproc\fR, or NULL to break the association.
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -296,6 +307,22 @@ is appended to the value specified by \fIobjPtr\fR.
|
||||
specified by the name in a \fBTcl_Obj\fR.
|
||||
The command name is resolved relative to the current namespace.
|
||||
Returns NULL if the command is not found.
|
||||
.PP
|
||||
.VS "info cmdtype feature"
|
||||
\fBTcl_RegisterCommandTypeName\fR is used to associate a name (the
|
||||
\fItypeName\fR argument) with a particular implementation function so that it
|
||||
can then be looked up with \fBTcl_GetCommandTypeName\fR, which in turn is
|
||||
called with a command token that information is wanted for and which returns
|
||||
the name of the type that was registered for the implementation function used
|
||||
for that command. (The lookup functionality is surfaced virtually directly in Tcl via
|
||||
\fBinfo cmdtype\fR.) If there is no function registered for a particular
|
||||
function, the result will be the string literal
|
||||
.QW \fBnative\fR .
|
||||
The registration of a name can be undone by registering a mapping to NULL
|
||||
instead. The result from \fBTcl_GetCommandTypeName\fR will be exactly that
|
||||
string which was registered, and not a copy; use of a compile-time constant
|
||||
string is \fIstrongly recommended\fR.
|
||||
.VE "info cmdtype feature"
|
||||
.SH "SEE ALSO"
|
||||
Tcl_CreateCommand(3), Tcl_ResetResult(3), Tcl_SetObjResult(3)
|
||||
.SH KEYWORDS
|
||||
|
||||
+31
-13
@@ -9,18 +9,18 @@
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
Tcl_ClassSetConstructor, Tcl_ClassSetDestructor, Tcl_MethodDeclarerClass, Tcl_MethodDeclarerObject, Tcl_MethodIsPublic, Tcl_MethodIsType, Tcl_MethodName, Tcl_NewInstanceMethod, Tcl_NewMethod, Tcl_ObjectContextInvokeNext, Tcl_ObjectContextIsFiltering, Tcl_ObjectContextMethod, Tcl_ObjectContextObject, Tcl_ObjectContextSkippedArgs \- manipulate methods and method-call contexts
|
||||
Tcl_ClassSetConstructor, Tcl_ClassSetDestructor, Tcl_MethodDeclarerClass, Tcl_MethodDeclarerObject, Tcl_MethodIsPublic, Tcl_MethodIsPrivate, Tcl_MethodIsType, Tcl_MethodName, Tcl_NewInstanceMethod, Tcl_NewMethod, Tcl_ObjectContextInvokeNext, Tcl_ObjectContextIsFiltering, Tcl_ObjectContextMethod, Tcl_ObjectContextObject, Tcl_ObjectContextSkippedArgs \- manipulate methods and method-call contexts
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fB#include <tclOO.h>\fR
|
||||
.sp
|
||||
Tcl_Method
|
||||
\fBTcl_NewMethod\fR(\fIinterp, class, nameObj, isPublic,
|
||||
methodTypePtr, clientData\fR)
|
||||
\fBTcl_NewMethod\fR(\fIinterp, class, nameObj, flags, methodTypePtr,
|
||||
clientData\fR)
|
||||
.sp
|
||||
Tcl_Method
|
||||
\fBTcl_NewInstanceMethod\fR(\fIinterp, object, nameObj, isPublic,
|
||||
methodTypePtr, clientData\fR)
|
||||
\fBTcl_NewInstanceMethod\fR(\fIinterp, object, nameObj, flags, methodTypePtr,
|
||||
clientData\fR)
|
||||
.sp
|
||||
\fBTcl_ClassSetConstructor\fR(\fIinterp, class, method\fR)
|
||||
.sp
|
||||
@@ -35,8 +35,13 @@ Tcl_Object
|
||||
Tcl_Obj *
|
||||
\fBTcl_MethodName\fR(\fImethod\fR)
|
||||
.sp
|
||||
.VS TIP500
|
||||
int
|
||||
\fBTcl_MethodIsPublic\fR(\fImethod\fR)
|
||||
.VE TIP500
|
||||
.sp
|
||||
int
|
||||
\fBTcl_MethodIsPrivate\fR(\fImethod\fR)
|
||||
.sp
|
||||
int
|
||||
\fBTcl_MethodIsType\fR(\fImethod, methodTypePtr, clientDataPtr\fR)
|
||||
@@ -66,10 +71,15 @@ The class to create the method in.
|
||||
.AP Tcl_Obj *nameObj in
|
||||
The name of the method to create. Should not be NULL unless creating
|
||||
constructors or destructors.
|
||||
.AP int isPublic in
|
||||
A flag saying what the visibility of the method is. The only supported public
|
||||
values of this flag are 0 for a non-exported method, and 1 for an exported
|
||||
method.
|
||||
.AP int flags in
|
||||
A flag saying (currently) what the visibility of the method is. The supported
|
||||
public values of this flag are \fBTCL_OO_METHOD_PUBLIC\fR (which is fixed at 1
|
||||
for backward compatibility) for an exported method,
|
||||
\fBTCL_OO_METHOD_UNEXPORTED\fR (which is fixed at 0 for backward
|
||||
compatibility) for a non-exported method,
|
||||
.VS TIP500
|
||||
and \fBTCL_OO_METHOD_PRIVATE\fR for a private method.
|
||||
.VE TIP500
|
||||
.AP Tcl_MethodType *methodTypePtr in
|
||||
A description of the type of the method to create, or the type of method to
|
||||
compare against.
|
||||
@@ -105,8 +115,12 @@ Given a method, the entity that declared it can be found using
|
||||
attached to (or NULL if the method is not attached to any class) and
|
||||
\fBTcl_MethodDeclarerObject\fR which returns the object that the method is
|
||||
attached to (or NULL if the method is not attached to an object). The name of
|
||||
the method can be retrieved with \fBTcl_MethodName\fR and whether the method
|
||||
is exported is retrieved with \fBTcl_MethodIsPublic\fR. The type of the method
|
||||
the method can be retrieved with \fBTcl_MethodName\fR, whether the method
|
||||
is exported is retrieved with \fBTcl_MethodIsPublic\fR,
|
||||
.VS TIP500
|
||||
and whether the method is private is retrieved with \fBTcl_MethodIsPrivate\fR.
|
||||
.VE TIP500
|
||||
The type of the method
|
||||
can also be introspected upon to a limited degree; the function
|
||||
\fBTcl_MethodIsType\fR returns whether a method is of a particular type,
|
||||
assigning the per-method \fIclientData\fR to the variable pointed to by
|
||||
@@ -117,8 +131,12 @@ Methods are created by \fBTcl_NewMethod\fR and \fBTcl_NewInstanceMethod\fR,
|
||||
which
|
||||
create a method attached to a class or an object respectively. In both cases,
|
||||
the \fInameObj\fR argument gives the name of the method to create, the
|
||||
\fIisPublic\fR argument states whether the method should be exported
|
||||
initially, the \fImethodTypePtr\fR argument describes the implementation of
|
||||
\fIflags\fR argument states whether the method should be exported
|
||||
initially
|
||||
.VS TIP500
|
||||
or be marked as a private method,
|
||||
.VE TIP500
|
||||
the \fImethodTypePtr\fR argument describes the implementation of
|
||||
the method (see the \fBMETHOD TYPES\fR section below) and the \fIclientData\fR
|
||||
argument gives some implementation-specific data that is passed on to the
|
||||
implementation of the method when it is called.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2008 by Kevin B. Kenny.
|
||||
.\" Copyright (c) 2018 by Nathan Coulter.
|
||||
.\" Copyright (c) 2018 by Nathan Coulter.
|
||||
.\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
|
||||
+12
-1
@@ -7,7 +7,7 @@
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
Tcl_Panic, Tcl_PanicVA, Tcl_SetPanicProc \- report fatal error and abort
|
||||
Tcl_Panic, Tcl_PanicVA, Tcl_SetPanicProc, Tcl_ConsolePanic \- report fatal error and abort
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fB#include <tcl.h>\fR
|
||||
@@ -21,6 +21,9 @@ void
|
||||
void
|
||||
\fBTcl_SetPanicProc\fR(\fIpanicProc\fR)
|
||||
.sp
|
||||
void
|
||||
\fBTcl_ConsolePanic\fR(\fIformat\fR, \fIarg\fR, \fIarg\fR, \fI...\fR)
|
||||
.sp
|
||||
.SH ARGUMENTS
|
||||
.AS Tcl_PanicProc *panicProc
|
||||
.AP "const char*" format in
|
||||
@@ -54,6 +57,14 @@ message is sent to the debugger in stead. If the windows executable
|
||||
does not have a stderr channel (e.g. \fBwish.exe\fR), then a
|
||||
system dialog box is used to display the panic message.
|
||||
.PP
|
||||
If your application doesn't use \fBTcl_Main\fR or \fBTk_Main\fR
|
||||
and you want to implicitly use the stderr channel of your
|
||||
application's C runtime (in stead of the stderr channel of the
|
||||
C runtime used by Tcl), you can call \fBTcl_SetPanicProc\fR
|
||||
with \fBTcl_ConsolePanic\fR as its argument. On platforms which
|
||||
only have one C runtime (almost all platforms except Windows)
|
||||
\fBTcl_ConsolePanic\fR is equivalent to NULL.
|
||||
.PP
|
||||
\fBTcl_SetPanicProc\fR may be used to modify the behavior of
|
||||
\fBTcl_Panic\fR. The \fIpanicProc\fR argument should match the
|
||||
type \fBTcl_PanicProc\fR:
|
||||
|
||||
+36
-71
@@ -1,6 +1,7 @@
|
||||
'\"
|
||||
'\" Copyright (c) 1997 by Sun Microsystems, Inc.
|
||||
'\" Contributions from Don Porter, NIST, 2004. (not subject to US copyright)
|
||||
'\" Copyright (c) 2018 Nathan Coulter.
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
@@ -9,7 +10,9 @@
|
||||
.so man.macros
|
||||
.BS
|
||||
.SH NAME
|
||||
Tcl_SaveInterpState, Tcl_RestoreInterpState, Tcl_DiscardInterpState, Tcl_SaveResult, Tcl_RestoreResult, Tcl_DiscardResult \- save and restore an interpreter's state
|
||||
Tcl_SaveInterpState, Tcl_RestoreInterpState, Tcl_DiscardInterpState,
|
||||
Tcl_SaveResult, Tcl_RestoreResult, Tcl_DiscardResult \- Save and restore the
|
||||
state of an an interpreter.
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fB#include <tcl.h>\fR
|
||||
@@ -30,91 +33,53 @@ int
|
||||
.SH ARGUMENTS
|
||||
.AS Tcl_InterpState savedPtr
|
||||
.AP Tcl_Interp *interp in
|
||||
Interpreter for which state should be saved.
|
||||
The interpreter for the operation.
|
||||
.AP int status in
|
||||
Return code value to save as part of interpreter state.
|
||||
The return code for the state.
|
||||
.AP Tcl_InterpState state in
|
||||
Saved state token to be restored or discarded.
|
||||
A token for saved state.
|
||||
.AP Tcl_SavedResult *savedPtr in
|
||||
Pointer to location where interpreter result should be saved or restored.
|
||||
A pointer to storage for saved state.
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
These routines allows a C procedure to take a snapshot of the current
|
||||
state of an interpreter so that it can be restored after a call
|
||||
to \fBTcl_Eval\fR or some other routine that modifies the interpreter
|
||||
state. There are two triplets of routines meant to work together.
|
||||
These routines save the state of an interpreter before a call to a routine such
|
||||
as \fBTcl_Eval\fR, and restore the state afterwards.
|
||||
.PP
|
||||
The first triplet stores the snapshot of interpreter state in
|
||||
an opaque token returned by \fBTcl_SaveInterpState\fR. That token
|
||||
value may then be passed back to one of \fBTcl_RestoreInterpState\fR
|
||||
or \fBTcl_DiscardInterpState\fR, depending on whether the interp
|
||||
state is to be restored. So long as one of the latter two routines
|
||||
is called, Tcl will take care of memory management.
|
||||
\fBTcl_SaveInterpState\fR saves the parts of \fIinterp\fR that comprise the
|
||||
result of a script, including the resulting value, the return code passed as
|
||||
\fIstatus\fR, and any options such as \fB\-errorinfo\fR and \fB\-errorcode\fR.
|
||||
It returns a token for the saved state. The interpreter result is not reset
|
||||
and no interpreter state is changed.
|
||||
.PP
|
||||
The second triplet stores the snapshot of only the interpreter
|
||||
result (not its complete state) in memory allocated by the caller.
|
||||
These routines are passed a pointer to \fBTcl_SavedResult\fR
|
||||
that is used to store enough information to restore the interpreter result.
|
||||
\fBTcl_SavedResult\fR can be allocated on the stack of the calling
|
||||
procedure. These routines do not save the state of any error
|
||||
information in the interpreter (e.g. the \fB\-errorcode\fR or
|
||||
\fB\-errorinfo\fR return options, when an error is in progress).
|
||||
\fBTcl_RestoreInterpState\fR restores the state indicated by \fIstate\fR and
|
||||
returns the \fIstatus\fR originally passed in the corresponding call to
|
||||
\fBTcl_SaveInterpState\fR.
|
||||
.PP
|
||||
Because the routines \fBTcl_SaveInterpState\fR,
|
||||
\fBTcl_RestoreInterpState\fR, and \fBTcl_DiscardInterpState\fR perform
|
||||
a superset of the functions provided by the other routines,
|
||||
any new code should only make use of the more powerful routines.
|
||||
The older, weaker routines \fBTcl_SaveResult\fR, \fBTcl_RestoreResult\fR,
|
||||
and \fBTcl_DiscardResult\fR continue to exist only for the sake
|
||||
of existing programs that may already be using them.
|
||||
If a saved state is not restored, \fBTcl_DiscardInterpState\fR must be called
|
||||
to release it. A token used to discard or restore state must not be used
|
||||
again.
|
||||
.PP
|
||||
\fBTcl_SaveInterpState\fR takes a snapshot of those portions of
|
||||
interpreter state that make up the full result of script evaluation.
|
||||
This include the interpreter result, the return code (passed in
|
||||
as the \fIstatus\fR argument, and any return options, including
|
||||
\fB\-errorinfo\fR and \fB\-errorcode\fR when an error is in progress.
|
||||
This snapshot is returned as an opaque token of type \fBTcl_InterpState\fR.
|
||||
The call to \fBTcl_SaveInterpState\fR does not itself change the
|
||||
state of the interpreter. Unlike \fBTcl_SaveResult\fR, it does
|
||||
not reset the interpreter.
|
||||
\fBTcl_SaveResult\fR, \fBTcl_RestoreResult\fR, and \fBTcl_DiscardResult\fR are
|
||||
deprecated. Instead use \fBTcl_SaveInterpState\fR,
|
||||
\fBTcl_RestoreInterpState\fR, and \fBTcl_DiscardInterpState\fR, which are more
|
||||
capable.
|
||||
.PP
|
||||
\fBTcl_RestoreInterpState\fR accepts a \fBTcl_InterpState\fR token
|
||||
previously returned by \fBTcl_SaveInterpState\fR and restores the
|
||||
state of the interp to the state held in that snapshot. The return
|
||||
value of \fBTcl_RestoreInterpState\fR is the status value originally
|
||||
passed to \fBTcl_SaveInterpState\fR when the snapshot token was
|
||||
created.
|
||||
\fBTcl_SaveResult\fR moves the result of \fIinterp\fR to the location
|
||||
\fIstatePtr\fR points to and returns the interpreter result to its initial
|
||||
state. It does not save options such as \fB\-errorcode\fR or
|
||||
\fB\-errorinfo\fR.
|
||||
.PP
|
||||
\fBTcl_DiscardInterpState\fR is called to release a \fBTcl_InterpState\fR
|
||||
token previously returned by \fBTcl_SaveInterpState\fR when that
|
||||
snapshot is not to be restored to an interp.
|
||||
.PP
|
||||
The \fBTcl_InterpState\fR token returned by \fBTcl_SaveInterpState\fR
|
||||
must eventually be passed to either \fBTcl_RestoreInterpState\fR
|
||||
or \fBTcl_DiscardInterpState\fR to avoid a memory leak. Once
|
||||
the \fBTcl_InterpState\fR token is passed to one of them, the
|
||||
token is no longer valid and should not be used anymore.
|
||||
.PP
|
||||
\fBTcl_SaveResult\fR moves the string and value results
|
||||
of \fIinterp\fR into the location specified by \fIstatePtr\fR.
|
||||
\fBTcl_SaveResult\fR clears the result for \fIinterp\fR and
|
||||
leaves the result in its normal empty initialized state.
|
||||
.PP
|
||||
\fBTcl_RestoreResult\fR moves the string and value results from
|
||||
\fIstatePtr\fR back into \fIinterp\fR. Any result or error that was
|
||||
already in the interpreter will be cleared. The \fIstatePtr\fR is left
|
||||
in an uninitialized state and cannot be used until another call to
|
||||
\fBTcl_RestoreResult\fR clears any existing result or error in \fIinterp\fR and
|
||||
moves the result from \fIstatePtr\fR back to \fIinterp\fR. \fIstatePtr\fR is
|
||||
then in an undefined state and must not be used until passed again to
|
||||
\fBTcl_SaveResult\fR.
|
||||
.PP
|
||||
\fBTcl_DiscardResult\fR releases the saved interpreter state
|
||||
stored at \fBstatePtr\fR. The state structure is left in an
|
||||
uninitialized state and cannot be used until another call to
|
||||
\fBTcl_DiscardResult\fR releases the state stored at \fBstatePtr\fR, which is
|
||||
then in an undefined state and must not be used until passed again to
|
||||
\fBTcl_SaveResult\fR.
|
||||
.PP
|
||||
Once \fBTcl_SaveResult\fR is called to save the interpreter
|
||||
result, either \fBTcl_RestoreResult\fR or
|
||||
\fBTcl_DiscardResult\fR must be called to properly clean up the
|
||||
memory associated with the saved state.
|
||||
If a saved result is not restored, \fBTcl_DiscardResult\fR must be called to
|
||||
release it.
|
||||
.SH KEYWORDS
|
||||
result, state, interp
|
||||
|
||||
+9
-3
@@ -45,7 +45,9 @@ int
|
||||
.AP Tcl_Condition *condPtr in
|
||||
A condition variable, which must be associated with a mutex lock.
|
||||
.AP Tcl_Mutex *mutexPtr in
|
||||
A mutex lock.
|
||||
.VS TIP509
|
||||
A recursive mutex lock.
|
||||
.VE TIP509
|
||||
.AP "const Tcl_Time" *timePtr in
|
||||
A time limit on the condition wait. NULL to wait forever.
|
||||
Note that a polling value of 0 seconds does not make much sense.
|
||||
@@ -140,8 +142,12 @@ of code by calling \fBTcl_MutexLock\fR and \fBTcl_MutexUnlock\fR.
|
||||
If one thread holds a mutex, any other thread calling \fBTcl_MutexLock\fR will
|
||||
block until \fBTcl_MutexUnlock\fR is called.
|
||||
A mutex can be destroyed after its use by calling \fBTcl_MutexFinalize\fR.
|
||||
The result of locking a mutex twice from the same thread is undefined.
|
||||
On some platforms it will result in a deadlock.
|
||||
.VS TIP509
|
||||
Mutexes are reentrant: they can be locked several times from the same
|
||||
thread. However there must be exactly one call to
|
||||
\fBTcl_MutexUnlock\fR for each call to \fBTcl_MutexLock\fR in order
|
||||
for a thread to release a mutex completely.
|
||||
.VE TIP509
|
||||
The \fBTcl_MutexLock\fR, \fBTcl_MutexUnlock\fR and \fBTcl_MutexFinalize\fR
|
||||
procedures are defined as empty macros if not compiling with threads enabled.
|
||||
For declaration of mutexes the \fBTCL_DECLARE_MUTEX\fR macro should be used.
|
||||
|
||||
@@ -121,8 +121,8 @@ case-insensitive (1).
|
||||
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
These routines convert between UTF-8 strings and Tcl_UniChars. A
|
||||
Tcl_UniChar is a Unicode character represented as an unsigned, fixed-size
|
||||
These routines convert between UTF-8 strings and Unicode characters. An
|
||||
Unicode character represented as an unsigned, fixed-size
|
||||
quantity. A UTF-8 character is a Unicode character represented as
|
||||
a varying-length sequence of up to \fBTCL_UTF_MAX\fR bytes. A multibyte UTF-8
|
||||
sequence consists of a lead byte followed by some number of trail bytes.
|
||||
@@ -130,9 +130,12 @@ sequence consists of a lead byte followed by some number of trail bytes.
|
||||
\fBTCL_UTF_MAX\fR is the maximum number of bytes that it takes to
|
||||
represent one Unicode character in the UTF-8 representation.
|
||||
.PP
|
||||
\fBTcl_UniCharToUtf\fR stores the Tcl_UniChar \fIch\fR as a UTF-8 string
|
||||
\fBTcl_UniCharToUtf\fR stores the character \fIch\fR as a UTF-8 string
|
||||
in starting at \fIbuf\fR. The return value is the number of bytes stored
|
||||
in \fIbuf\fR.
|
||||
in \fIbuf\fR. If ch is an upper surrogate (range U+D800 - U+DBFF), then
|
||||
the return value will be 0 and nothing will be stored. If you still
|
||||
want to produce UTF-8 output for it (even though knowing it's an illegal
|
||||
code-point on its own), just call \fBTcl_UniCharToUtf\fR again using ch = -1.
|
||||
.PP
|
||||
\fBTcl_UtfToUniChar\fR reads one UTF-8 character starting at \fIsrc\fR
|
||||
and stores it as a Tcl_UniChar in \fI*chPtr\fR. The return value is the
|
||||
@@ -203,7 +206,7 @@ of \fIlength\fR bytes is long enough to be decoded by
|
||||
\fBTcl_UtfToUniChar\fR, or 0 otherwise. This function does not guarantee
|
||||
that the UTF-8 string is properly formed. This routine is used by
|
||||
procedures that are operating on a byte at a time and need to know if a
|
||||
full Tcl_UniChar has been seen.
|
||||
full Unicode character has been seen.
|
||||
.PP
|
||||
\fBTcl_NumUtfChars\fR corresponds to \fBstrlen\fR for UTF-8 strings. It
|
||||
returns the number of Tcl_UniChars that are represented by the UTF-8 string
|
||||
@@ -211,12 +214,12 @@ returns the number of Tcl_UniChars that are represented by the UTF-8 string
|
||||
length is negative, all bytes up to the first null byte are used.
|
||||
.PP
|
||||
\fBTcl_UtfFindFirst\fR corresponds to \fBstrchr\fR for UTF-8 strings. It
|
||||
returns a pointer to the first occurrence of the Tcl_UniChar \fIch\fR
|
||||
returns a pointer to the first occurrence of the Unicode character \fIch\fR
|
||||
in the null-terminated UTF-8 string \fIsrc\fR. The null terminator is
|
||||
considered part of the UTF-8 string.
|
||||
.PP
|
||||
\fBTcl_UtfFindLast\fR corresponds to \fBstrrchr\fR for UTF-8 strings. It
|
||||
returns a pointer to the last occurrence of the Tcl_UniChar \fIch\fR
|
||||
returns a pointer to the last occurrence of the Unicode character \fIch\fR
|
||||
in the null-terminated UTF-8 string \fIsrc\fR. The null terminator is
|
||||
considered part of the UTF-8 string.
|
||||
.PP
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2018 Donal K. Fellows
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH abstract n 0.3 TclOO "TclOO Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
oo::abstract \- a class that does not allow direct instances of itself
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
package require TclOO
|
||||
|
||||
\fBoo::abstract\fI method \fR?\fIarg ...\fR?
|
||||
.fi
|
||||
.SH "CLASS HIERARCHY"
|
||||
.nf
|
||||
\fBoo::object\fR
|
||||
\(-> \fBoo::class\fR
|
||||
\(-> \fBoo::abstract\fR
|
||||
.fi
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
Abstract classes are classes that can contain definitions, but which cannot be
|
||||
directly manufactured; they are intended to only ever be inherited from and
|
||||
instantiated indirectly. The characteristic methods of \fBoo::class\fR
|
||||
(\fBcreate\fR and \fBnew\fR) are not exported by an instance of
|
||||
\fBoo::abstract\fR.
|
||||
.PP
|
||||
Note that \fBoo::abstract\fR is not itself an instance of \fBoo::abstract\fR.
|
||||
.SS CONSTRUCTOR
|
||||
The \fBoo::abstract\fR class does not define an explicit constructor; this
|
||||
means that it is effectively the same as the constructor of the
|
||||
\fBoo::class\fR class.
|
||||
.SS DESTRUCTOR
|
||||
The \fBoo::abstract\fR class does not define an explicit destructor;
|
||||
destroying an instance of it is just like destroying an ordinary class (and
|
||||
will destroy all its subclasses).
|
||||
.SS "EXPORTED METHODS"
|
||||
The \fBoo::abstract\fR class defines no new exported methods.
|
||||
.SS "NON-EXPORTED METHODS"
|
||||
The \fBoo::abstract\fR class explicitly states that \fBcreate\fR,
|
||||
\fBcreateWithNamespace\fR, and \fBnew\fR are unexported.
|
||||
.SH EXAMPLES
|
||||
.PP
|
||||
This example defines a simple class hierarchy and creates a new instance of
|
||||
it. It then invokes a method of the object before destroying the hierarchy and
|
||||
showing that the destruction is transitive.
|
||||
.PP
|
||||
.CS
|
||||
\fBoo::abstract\fR create fruit {
|
||||
method eat {} {
|
||||
puts "yummy!"
|
||||
}
|
||||
}
|
||||
oo::class create banana {
|
||||
superclass fruit
|
||||
method peel {} {
|
||||
puts "skin now off"
|
||||
}
|
||||
}
|
||||
set b [banana \fBnew\fR]
|
||||
$b peel \fI\(-> prints 'skin now off'\fR
|
||||
$b eat \fI\(-> prints 'yummy!'\fR
|
||||
set f [fruit new] \fI\(-> error 'unknown method "new"...'\fR
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
oo::define(n), oo::object(n)
|
||||
.SH KEYWORDS
|
||||
abstract class, class, metaclass, object
|
||||
.\" Local variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
+9
-3
@@ -20,6 +20,11 @@ Append all of the \fIvalue\fR arguments to the current value
|
||||
of variable \fIvarName\fR. If \fIvarName\fR does not exist,
|
||||
it is given a value equal to the concatenation of all the
|
||||
\fIvalue\fR arguments.
|
||||
.VS TIP508
|
||||
If \fIvarName\fR indicate an element that does not exist of an array that has
|
||||
a default value set, the concatenation of the default value and all the
|
||||
\fIvalue\fR arguments will be stored in the array element.
|
||||
.VE TIP508
|
||||
The result of this command is the new value stored in variable
|
||||
\fIvarName\fR.
|
||||
This command provides an efficient way to build up long
|
||||
@@ -44,6 +49,7 @@ puts $var
|
||||
concat(n), lappend(n)
|
||||
.SH KEYWORDS
|
||||
append, variable
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" End:
|
||||
.\" Local variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
|
||||
+52
-1
@@ -5,7 +5,7 @@
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH array n 8.3 Tcl "Tcl Built-In Commands"
|
||||
.TH array n 8.7 Tcl "Tcl Built-In Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
@@ -36,6 +36,53 @@ with an empty name, since the return value from
|
||||
\fBarray nextelement\fR will not indicate whether the search
|
||||
has been completed.
|
||||
.TP
|
||||
\fBarray default \fIsubcommand arrayName args...\fR
|
||||
.VS TIP508
|
||||
Manages the default value of the array. Arrays initially have no default
|
||||
value, but this command allows you to set one; the default value will be
|
||||
returned when reading from an element of the array \farrayName\fR if the read
|
||||
would otherwise result in an error. Note that this may cause the \fBappend\fR,
|
||||
\fBdict\fR, \fBincr\fR and \fBlappend\fR commands to change their behavior in
|
||||
relation to non-existing array elements.
|
||||
.RS
|
||||
.PP
|
||||
The \fIsubcommand\fR argument controls what exact operation will be performed
|
||||
on the default value of \fIarrayName\fR. Supported \fIsubcommand\fRs are:
|
||||
.VE TIP508
|
||||
.TP
|
||||
\fBarray default exists \fIarrayName\fR
|
||||
.VS TIP508
|
||||
This returns a boolean value indicating whether a default value has been set
|
||||
for the array \fIarrayName\fR. Returns a false value if \fIarrayName\fR does
|
||||
not exist. Raises an error if \fIarrayName\fR is an existing variable that is
|
||||
not an array.
|
||||
.VE TIP508
|
||||
.TP
|
||||
\fBarray default get \fIarrayName\fR
|
||||
.VS TIP508
|
||||
This returns the current default value for the array \fIarrayName\fR. Raises
|
||||
an error if \fIarrayName\fR is an existing variable that is not an array, or
|
||||
if \fIarrayName\fR is an array without a default value.
|
||||
.VE TIP508
|
||||
.TP
|
||||
\fBarray default set \fIarrayName value\fR
|
||||
.VS TIP508
|
||||
This sets the default value for the array \fIarrayName\fR to \fIvalue\fR.
|
||||
Returns the empty string. Raises an error if \fIarrayName\fR is an existing
|
||||
variable that is not an array, or if \fIarrayName\fR is an illegal name for an
|
||||
array. If \fIarrayName\fR does not currently exist, it is created as an empty
|
||||
array as well as having its default value set.
|
||||
.VE TIP508
|
||||
.TP
|
||||
\fBarray default unset \fIarrayName\fR
|
||||
.VS TIP508
|
||||
This removes the default value for the array \fIarrayName\fR and returns the
|
||||
empty string. Does nothing if \fIarrayName\fR does not have a default
|
||||
value. Raises an error if \fIarrayName\fR is an existing variable that is not
|
||||
an array.
|
||||
.VE TIP508
|
||||
.RE
|
||||
.TP
|
||||
\fBarray donesearch \fIarrayName searchId\fR
|
||||
This command terminates an array search and destroys all the
|
||||
state associated with that search. \fISearchId\fR indicates
|
||||
@@ -194,3 +241,7 @@ foreach color [lsort [\fBarray names\fR colorcount]] {
|
||||
list(n), string(n), variable(n), trace(n), foreach(n)
|
||||
.SH KEYWORDS
|
||||
array, element names, search
|
||||
.\" Local variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2018 Donal K. Fellows
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH callback n 0.3 TclOO "TclOO Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
callback, mymethod \- generate callbacks to methods
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
package require TclOO
|
||||
|
||||
\fBcallback\fR \fImethodName\fR ?\fIarg ...\fR?
|
||||
\fBmymethod\fR \fImethodName\fR ?\fIarg ...\fR?
|
||||
.fi
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
The \fBcallback\fR command,
|
||||
'\" Based on notes in the tcllib docs, we know the provenance of mymethod
|
||||
also called \fBmymethod\fR for compatibility with the ooutil and snit packages
|
||||
of Tcllib,
|
||||
and which should only be used from within the context of a call to a method
|
||||
(i.e. inside a method, constructor or destructor body) is used to generate a
|
||||
script fragment that will invoke the method, \fImethodName\fR, on the current
|
||||
object (as reported by \fBself\fR) when executed. Any additional arguments
|
||||
provided will be provided as leading arguments to the callback. The resulting
|
||||
script fragment shall be a proper list.
|
||||
.PP
|
||||
Note that it is up to the caller to ensure that the current object is able to
|
||||
handle the call of \fImethodName\fR; this command does not check that.
|
||||
\fImethodName\fR may refer to any exported or unexported method, but may not
|
||||
refer to a private method as those can only be invoked directly from within
|
||||
methods. If there is no such method present at the point when the callback is
|
||||
invoked, the standard \fBunknown\fR method handler will be called.
|
||||
.SH EXAMPLE
|
||||
This is a simple echo server class. The \fBcallback\fR command is used in two
|
||||
places, to arrange for the incoming socket connections to be handled by the
|
||||
\fIAccept\fR method, and to arrange for the incoming bytes on those
|
||||
connections to be handled by the \fIReceive\fR method.
|
||||
.PP
|
||||
.CS
|
||||
oo::class create EchoServer {
|
||||
variable server clients
|
||||
constructor {port} {
|
||||
set server [socket -server [\fBcallback\fR Accept] $port]
|
||||
set clients {}
|
||||
}
|
||||
destructor {
|
||||
chan close $server
|
||||
foreach client [dict keys $clients] {
|
||||
chan close $client
|
||||
}
|
||||
}
|
||||
|
||||
method Accept {channel clientAddress clientPort} {
|
||||
dict set clients $channel [dict create \e
|
||||
address $clientAddress port $clientPort]
|
||||
chan event $channel readable [\fBcallback\fR Receive $channel]
|
||||
}
|
||||
method Receive {channel} {
|
||||
if {[chan gets $channel line] >= 0} {
|
||||
my echo $channel $line
|
||||
} else {
|
||||
chan close $channel
|
||||
dict unset clients $channel
|
||||
}
|
||||
}
|
||||
|
||||
method echo {channel line} {
|
||||
dict with clients $channel {
|
||||
chan puts $channel \e
|
||||
[format {[%s:%d] %s} $address $port $line]
|
||||
}
|
||||
}
|
||||
}
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
chan(n), fileevent(n), my(n), self(n), socket(n), trace(n)
|
||||
.SH KEYWORDS
|
||||
callback, object
|
||||
.\" Local Variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
@@ -41,3 +41,7 @@ current one:
|
||||
filename(n), glob(n), pwd(n)
|
||||
.SH KEYWORDS
|
||||
working directory
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2011-2015 Andreas Kupries
|
||||
'\" Copyright (c) 2018 Donal K. Fellows
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH classvariable n 0.3 TclOO "TclOO Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
classvariable \- create link from local variable to variable in class
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
package require TclOO
|
||||
|
||||
\fBclassvariable\fR \fIvariableName\fR ?\fI...\fR?
|
||||
.fi
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
The \fBclassvariable\fR command is available within methods. It takes a series
|
||||
of one or more variable names and makes them available in the method's scope;
|
||||
those variable names must not be qualified and must not refer to array
|
||||
elements. The originating scope for the variables is the namespace of the
|
||||
class that the method was defined by. In other words, the referenced variables
|
||||
are shared between all instances of that class.
|
||||
.PP
|
||||
Note: This command is equivalent to the command \fBtypevariable\fR provided by
|
||||
the snit package in tcllib for approximately the same purpose. If used in a
|
||||
method defined directly on a class instance (e.g., through the
|
||||
\fBoo::objdefine\fR \fBmethod\fR definition) this is very much like just
|
||||
using:
|
||||
.PP
|
||||
.CS
|
||||
namespace upvar [namespace current] $var $var
|
||||
.CE
|
||||
.PP
|
||||
for each variable listed to \fBclassvariable\fR.
|
||||
.SH EXAMPLE
|
||||
This class counts how many instances of it have been made.
|
||||
.PP
|
||||
.CS
|
||||
oo::class create Counted {
|
||||
initialise {
|
||||
variable count 0
|
||||
}
|
||||
|
||||
variable number
|
||||
constructor {} {
|
||||
\fBclassvariable\fR count
|
||||
set number [incr count]
|
||||
}
|
||||
|
||||
method report {} {
|
||||
\fBclassvariable\fR count
|
||||
puts "This is instance $number of $count"
|
||||
}
|
||||
}
|
||||
|
||||
set a [Counted new]
|
||||
set b [Counted new]
|
||||
$a report
|
||||
\fI\(-> This is instance 1 of 2\fR
|
||||
set c [Counted new]
|
||||
$b report
|
||||
\fI\(-> This is instance 2 of 3\fR
|
||||
$c report
|
||||
\fI\(-> This is instance 3 of 3\fR
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
global(n), namespace(n), oo::class(n), oo::define(n), upvar(n), variable(n)
|
||||
.SH KEYWORDS
|
||||
class, class variable, variable
|
||||
.\" Local Variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
+29
-10
@@ -452,6 +452,19 @@ If this situation occurs, the first occurrence of the time is chosen.
|
||||
(For this reason, it is wise to have the input string contain the
|
||||
time zone when converting local times. This caveat does not apply to
|
||||
UTC times.)
|
||||
.PP
|
||||
If the interpretation of the groups yields an impossible time because
|
||||
a field is out of range, enough of that field's unit will be added to
|
||||
or subtracted from the time to bring it in range. Thus, if attempting to
|
||||
scan or format day 0 of the month, one day will be subtracted from day
|
||||
1 of the month, yielding the last day of the previous month.
|
||||
.PP
|
||||
If the interpretation of the groups yields an impossible time because
|
||||
a Daylight Saving Time change skips over that time, or an ambiguous
|
||||
time because a Daylight Saving Time change skips back so that the clock
|
||||
observes the given time twice, and no time zone specifier (\fB%z\fR
|
||||
or \fB%Z\fR) is present in the format, the time is interpreted as
|
||||
if the clock had not changed.
|
||||
.SH "FORMAT GROUPS"
|
||||
.PP
|
||||
The following format groups are recognized by the \fBclock scan\fR and
|
||||
@@ -873,40 +886,46 @@ The \fIinputString\fR argument consists of zero or more specifications of the
|
||||
following form:
|
||||
.TP
|
||||
\fItime\fR
|
||||
A time of day, which is of the form: \fBhh?:mm?:ss?? ?meridian? ?zone?\fR
|
||||
or \fBhhmm ?meridian? ?zone?\fR
|
||||
If no meridian is specified, \fBhh\fR is interpreted on
|
||||
.
|
||||
A time of day, which is of the form:
|
||||
.QW "\fIhh\fR?\fB:\fImm\fR?\fB:\fIss\fR?? ?\fImeridian\fR? ?\fIzone\fR?"
|
||||
or
|
||||
.QW "\fBhhmm \fR?\fBmeridian\fR? ?\fBzone\fR?" .
|
||||
If no \fImeridian\fR is specified, \fIhh\fR is interpreted on
|
||||
a 24-hour clock.
|
||||
.TP
|
||||
\fIdate\fR
|
||||
.
|
||||
A specific month and day with optional year. The
|
||||
acceptable formats are
|
||||
.QW "\fBmm/dd\fR?\fB/yy\fR?" ,
|
||||
.QW "\fBmonthname dd\fR?\fB, yy\fR?" ,
|
||||
.QW "\fBday, dd monthname \fR?\fByy\fR?" ,
|
||||
.QW "\fBdd monthname yy\fR" ,
|
||||
.QW "?\fBCC\fR?\fByymmdd\fR" ,
|
||||
.QW "\fImm\fB/\fIdd\fR?\fB/\fIyy\fR?" ,
|
||||
.QW "\fImonthname dd\fR?\fB, \fIyy\fR?" ,
|
||||
.QW "\fIday\fB, \fIdd monthname \fR?\fIyy\fR?" ,
|
||||
.QW "\fIdd monthname yy\fR" ,
|
||||
.QW "?\fICC\fR?\fIyymmdd\fR" ,
|
||||
and
|
||||
.QW "\fBdd-monthname-\fR?\fBCC\fR?\fByy\fR" .
|
||||
.QW "\fIdd\fB-\fImonthname\fB-\fR?\fICC\fR?\fIyy\fR" .
|
||||
The default year is the current year. If the year is less
|
||||
than 100, we treat the years 00-68 as 2000-2068 and the years 69-99
|
||||
as 1969-1999. Not all platforms can represent the years 38-70, so
|
||||
an error may result if these years are used.
|
||||
.TP
|
||||
\fIISO 8601 point-in-time\fR
|
||||
.
|
||||
An ISO 8601 point-in-time specification, such as
|
||||
.QW \fICCyymmdd\fBT\fIhhmmss\fR,
|
||||
where \fBT\fR is the literal
|
||||
.QW T ,
|
||||
.QW "\fICCyymmdd hhmmss\fR" ,
|
||||
or
|
||||
.QW \fICCyymmdd\fBT\fIhh:mm:ss\fR .
|
||||
.QW \fICCyymmdd\fBT\fIhh\fB:\fImm\fB:\fIss\fR .
|
||||
Note that only these three formats are accepted.
|
||||
The command does \fInot\fR accept the full range of point-in-time
|
||||
specifications specified in ISO8601. Other formats can be recognized by
|
||||
giving an explicit \fB\-format\fR option to the \fBclock scan\fR command.
|
||||
.TP
|
||||
\fIrelative time\fR
|
||||
.
|
||||
A specification relative to the current time. The format is \fBnumber
|
||||
unit\fR. Acceptable units are \fByear\fR, \fBfortnight\fR,
|
||||
\fBmonth\fR, \fBweek\fR, \fBday\fR,
|
||||
|
||||
+293
-43
@@ -1,5 +1,5 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2007 Donal K. Fellows
|
||||
'\" Copyright (c) 2007-2018 Donal K. Fellows
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
@@ -39,6 +39,27 @@ used as the \fIdefScript\fR argument.
|
||||
The following commands are supported in the \fIdefScript\fR for
|
||||
\fBoo::define\fR, each of which may also be used in the \fIsubcommand\fR form:
|
||||
.TP
|
||||
\fBclassmethod\fI name\fR ?\fIargList bodyScrip\fR?
|
||||
.VS TIP478
|
||||
This creates a class method, or (if \fIargList\fR and \fIbodyScript\fR are
|
||||
omitted) promotes an existing method on the class object to be a class
|
||||
method. The \fIname\fR, \fIargList\fR and \fIbodyScript\fR arguments are as in
|
||||
the \fBmethod\fR definition, below.
|
||||
.RS
|
||||
.PP
|
||||
Class methods can be called on either the class itself or on the instances of
|
||||
that class. When they are called, the current object (see the \fBself\R and
|
||||
\fBmy\fR commands) is the class on which they are called or the class of the
|
||||
instance on which they are called, depending on whether they are called on the
|
||||
class or an instance of the class, respectively. If called on a subclass or
|
||||
instance of the subclass, the current object is the subclass.
|
||||
.PP
|
||||
In a private definition context, the methods as invoked on classes are
|
||||
\fInot\fR private, but the methods as invoked on instances of classes are
|
||||
private.
|
||||
.RE
|
||||
.VE TIP478
|
||||
.TP
|
||||
\fBconstructor\fI argList bodyScript\fR
|
||||
.
|
||||
This creates or updates the constructor for a class. The formal arguments to
|
||||
@@ -82,17 +103,14 @@ by a superclass; subclass exports override superclass visibility, and may in
|
||||
turn be overridden by instances.
|
||||
.TP
|
||||
\fBfilter\fR ?\fI\-slotOperation\fR? ?\fImethodName ...\fR?
|
||||
.VS
|
||||
.
|
||||
This slot (see \fBSLOTTED DEFINITIONS\fR below)
|
||||
.VE
|
||||
sets or updates the list of method names that are used to guard whether
|
||||
method call to instances of the class may be called and what the method's
|
||||
results are. Each \fImethodName\fR names a single filtering method (which may
|
||||
be exposed or not exposed); it is not an error for a non-existent method to be
|
||||
named since they may be defined by subclasses.
|
||||
.VS
|
||||
By default, this slot works by appending.
|
||||
.VE
|
||||
.TP
|
||||
\fBforward\fI name cmdName \fR?\fIarg ...\fR?
|
||||
.
|
||||
@@ -105,6 +123,22 @@ fully-qualified, the command will be searched for in each object's namespace,
|
||||
using the instances' namespace's path, or by looking in the global namespace.
|
||||
The method will be exported if \fIname\fR starts with a lower-case letter, and
|
||||
non-exported otherwise.
|
||||
.RS
|
||||
.PP
|
||||
.VS TIP500
|
||||
If in a private definition context (see the \fBprivate\fR definition command,
|
||||
below), this command creates private forwarded methods.
|
||||
.VE TIP500
|
||||
.RE
|
||||
.TP
|
||||
\fBinitialise\fI script\fR
|
||||
.TP
|
||||
\fBinitialize\fI script\fR
|
||||
.VS TIP478
|
||||
This evaluates \fIscript\fR in a context which supports local variables and
|
||||
where the current namespace is the instance namespace of the class object
|
||||
itself. This is useful for setting up, e.g., class-scoped variables.
|
||||
.VE TIP478
|
||||
.TP
|
||||
\fBmethod\fI name argList bodyScript\fR
|
||||
.
|
||||
@@ -117,17 +151,40 @@ be a namespace that is unique to the current object. The method will be
|
||||
exported if \fIname\fR starts with a lower-case letter, and non-exported
|
||||
otherwise; this behavior can be overridden via \fBexport\fR and
|
||||
\fBunexport\fR.
|
||||
.RS
|
||||
.PP
|
||||
.VS TIP500
|
||||
If in a private definition context (see the \fBprivate\fR definition command,
|
||||
below), this command creates private procedure-like methods.
|
||||
.VE TIP500
|
||||
.RE
|
||||
.TP
|
||||
\fBmixin\fR ?\fI\-slotOperation\fR? ?\fIclassName ...\fR?
|
||||
.VS
|
||||
.
|
||||
This slot (see \fBSLOTTED DEFINITIONS\fR below)
|
||||
.VE
|
||||
sets or updates the list of additional classes that are to be mixed into
|
||||
all the instances of the class being defined. Each \fIclassName\fR argument
|
||||
names a single class that is to be mixed in.
|
||||
.VS
|
||||
By default, this slot works by replacement.
|
||||
.VE
|
||||
.TP
|
||||
\fBprivate \fIcmd arg...\fR
|
||||
.TP
|
||||
\fBprivate \fIscript\fR
|
||||
.
|
||||
.VS TIP500
|
||||
This evaluates the \fIscript\fR (or the list of command and arguments given by
|
||||
\fIcmd\fR and \fIarg\fRs) in a context where the definitions made on the
|
||||
current class will be private definitions.
|
||||
.RS
|
||||
.PP
|
||||
The following class definition commands are affected by \fBprivate\fR:
|
||||
\fBforward\fR, \fBmethod\fR, \fBself\fR, and \fBvariable\fR. Nesting
|
||||
\fBprivate\fR inside \fBprivate\fR has no cumulative effect; the innermost
|
||||
definition context is just a private definition context. All other definition
|
||||
commands have no difference in behavior when used in a private definition
|
||||
context.
|
||||
.RE
|
||||
.VE TIP500
|
||||
.TP
|
||||
\fBrenamemethod\fI fromName toName\fR
|
||||
.
|
||||
@@ -159,21 +216,23 @@ operates identically to
|
||||
If no arguments at all are used, this gives the name of the class currently
|
||||
being configured.
|
||||
.VE TIP470
|
||||
.VS TIP500
|
||||
If in a private definition context (see the \fBprivate\fR definition command,
|
||||
below), the definitions on the class object will also be made in a private
|
||||
definition context.
|
||||
.VE TIP500
|
||||
.RE
|
||||
.TP
|
||||
\fBsuperclass\fR ?\fI\-slotOperation\fR? ?\fIclassName ...\fR?
|
||||
.VS
|
||||
.
|
||||
This slot (see \fBSLOTTED DEFINITIONS\fR below)
|
||||
.VE
|
||||
allows the alteration of the superclasses of the class being defined.
|
||||
Each \fIclassName\fR argument names one class that is to be a superclass of
|
||||
the defined class. Note that objects must not be changed from being classes to
|
||||
being non-classes or vice-versa, that an empty parent class is equivalent to
|
||||
\fBoo::object\fR, and that the parent classes of \fBoo::object\fR and
|
||||
\fBoo::class\fR may not be modified.
|
||||
.VS
|
||||
By default, this slot works by replacement.
|
||||
.VE
|
||||
.TP
|
||||
\fBunexport\fI name \fR?\fIname ...\fR?
|
||||
.
|
||||
@@ -185,18 +244,31 @@ actually defined by a superclass; subclass unexports override superclass
|
||||
visibility, and may be overridden by instance unexports.
|
||||
.TP
|
||||
\fBvariable\fR ?\fI\-slotOperation\fR? ?\fIname ...\fR?
|
||||
.VS
|
||||
.
|
||||
This slot (see \fBSLOTTED DEFINITIONS\fR below) arranges for each of the named
|
||||
variables to be automatically made
|
||||
available in the methods, constructor and destructor declared by the class
|
||||
being defined. Each variable name must not have any namespace
|
||||
separators and must not look like an array access. All variables will be
|
||||
actually present in the instance object on which the method is executed. Note
|
||||
actually present in the namespace of the instance object on which the method
|
||||
is executed. Note
|
||||
that the variable lists declared by a superclass or subclass are completely
|
||||
disjoint, as are variable lists declared by instances; the list of variable
|
||||
names is just for methods (and constructors and destructors) declared by this
|
||||
class. By default, this slot works by appending.
|
||||
.VE
|
||||
.RS
|
||||
.PP
|
||||
.VS TIP500
|
||||
If in a private definition context (see the \fBprivate\fR definition command,
|
||||
below), this slot manipulates the list of private variable bindings for this
|
||||
class. In a private variable binding, the name of the variable within the
|
||||
instance object is different to the name given in the definition; the name
|
||||
used in the definition is the name that you use to access the variable within
|
||||
the methods of this class, and the name of the variable in the instance
|
||||
namespace has a unique prefix that makes accidental use from other classes
|
||||
extremely unlikely.
|
||||
.VE TIP500
|
||||
.RE
|
||||
.SS "CONFIGURING OBJECTS"
|
||||
.PP
|
||||
The following commands are supported in the \fIdefScript\fR for
|
||||
@@ -223,18 +295,15 @@ being defined. Note that the methods themselves may be actually defined by a
|
||||
class or superclass; object exports override class visibility.
|
||||
.TP
|
||||
\fBfilter\fR ?\fI\-slotOperation\fR? ?\fImethodName ...\fR?
|
||||
.VS
|
||||
.
|
||||
This slot (see \fBSLOTTED DEFINITIONS\fR below)
|
||||
.VE
|
||||
sets or updates the list of method names that are used to guard whether a
|
||||
method call to the object may be called and what the method's results are.
|
||||
Each \fImethodName\fR names a single filtering method (which may be exposed or
|
||||
not exposed); it is not an error for a non-existent method to be named. Note
|
||||
that the actual list of filters also depends on the filters set upon any
|
||||
classes that the object is an instance of.
|
||||
.VS
|
||||
By default, this slot works by appending.
|
||||
.VE
|
||||
.TP
|
||||
\fBforward\fI name cmdName \fR?\fIarg ...\fR?
|
||||
.
|
||||
@@ -244,6 +313,13 @@ additional arguments, \fIarg\fR etc., added before those arguments specified
|
||||
by the caller of the method. Forwarded methods should be deleted using the
|
||||
\fBmethod\fR subcommand. The method will be exported if \fIname\fR starts with
|
||||
a lower-case letter, and non-exported otherwise.
|
||||
.RS
|
||||
.PP
|
||||
.VS TIP500
|
||||
If in a private definition context (see the \fBprivate\fR definition command,
|
||||
below), this command creates private forwarded methods.
|
||||
.VE TIP500
|
||||
.RE
|
||||
.TP
|
||||
\fBmethod\fI name argList bodyScript\fR
|
||||
.
|
||||
@@ -254,17 +330,38 @@ method will be \fIbodyScript\fR. When the body of the method is evaluated, the
|
||||
current namespace of the method will be a namespace that is unique to the
|
||||
object. The method will be exported if \fIname\fR starts with a lower-case
|
||||
letter, and non-exported otherwise.
|
||||
.RS
|
||||
.PP
|
||||
.VS TIP500
|
||||
If in a private definition context (see the \fBprivate\fR definition command,
|
||||
below), this command creates private procedure-like methods.
|
||||
.VE TIP500
|
||||
.RE
|
||||
.TP
|
||||
\fBmixin\fR ?\fI\-slotOperation\fR? ?\fIclassName ...\fR?
|
||||
.VS
|
||||
.
|
||||
This slot (see \fBSLOTTED DEFINITIONS\fR below)
|
||||
.VE
|
||||
sets or updates a per-object list of additional classes that are to be
|
||||
mixed into the object. Each argument, \fIclassName\fR, names a single class
|
||||
that is to be mixed in.
|
||||
.VS
|
||||
By default, this slot works by replacement.
|
||||
.VE
|
||||
.TP
|
||||
\fBprivate \fIcmd arg...\fR
|
||||
.TP
|
||||
\fBprivate \fIscript\fR
|
||||
.VS TIP500
|
||||
This evaluates the \fIscript\fR (or the list of command and arguments given by
|
||||
\fIcmd\fR and \fIarg\fRs) in a context where the definitions made on the
|
||||
current object will be private definitions.
|
||||
.RS
|
||||
.PP
|
||||
The following class definition commands are affected by \fBprivate\fR:
|
||||
\fBforward\fR, \fBmethod\fR, and \fBvariable\fR. Nesting \fBprivate\fR inside
|
||||
\fBprivate\fR has no cumulative effect; the innermost definition context is
|
||||
just a private definition context. All other definition commands have no
|
||||
difference in behavior when used in a private definition context.
|
||||
.RE
|
||||
.VE TIP500
|
||||
.TP
|
||||
\fBrenamemethod\fI fromName toName\fR
|
||||
.
|
||||
@@ -275,7 +372,6 @@ that the object is an instance of. Does not change the export status of the
|
||||
method; if it was exported before, it will be afterwards.
|
||||
.TP
|
||||
\fBself \fR
|
||||
.
|
||||
.VS TIP470
|
||||
This gives the name of the object currently being configured.
|
||||
.VE TIP470
|
||||
@@ -289,36 +385,70 @@ object being defined. Note that the methods themselves may be actually defined
|
||||
by a class; instance unexports override class visibility.
|
||||
.TP
|
||||
\fBvariable\fR ?\fI\-slotOperation\fR? ?\fIname ...\fR?
|
||||
.VS
|
||||
.
|
||||
This slot (see \fBSLOTTED DEFINITIONS\fR below) arranges for each of the named
|
||||
variables to be automatically made available in the methods declared by the
|
||||
object being defined. Each variable name must not have any namespace
|
||||
separators and must not look like an array access. All variables will be
|
||||
actually present in the object on which the method is executed. Note that the
|
||||
actually present in the namespace of the object on which the method is
|
||||
executed. Note that the
|
||||
variable lists declared by the classes and mixins of which the object is an
|
||||
instance are completely disjoint; the list of variable names is just for
|
||||
methods declared by this object. By default, this slot works by appending.
|
||||
.RS
|
||||
.PP
|
||||
.VS TIP500
|
||||
If in a private definition context (see the \fBprivate\fR definition command,
|
||||
below), this slot manipulates the list of private variable bindings for this
|
||||
object. In a private variable binding, the name of the variable within the
|
||||
instance object is different to the name given in the definition; the name
|
||||
used in the definition is the name that you use to access the variable within
|
||||
the methods of this instance object, and the name of the variable in the
|
||||
instance namespace has a unique prefix that makes accidental use from
|
||||
superclass methods extremely unlikely.
|
||||
.VE TIP500
|
||||
.RE
|
||||
.SH "PRIVATE METHODS"
|
||||
.VS TIP500
|
||||
When a class or instance has a private method, that private method can only be
|
||||
invoked from within methods of that class or instance. Other callers of the
|
||||
object's methods \fIcannot\fR invoke private methods, it is as if the private
|
||||
methods do not exist. However, a private method of a class \fIcan\fR be
|
||||
invoked from the class's methods when those methods are being used on another
|
||||
instance object; this means that a class can use them to coordinate behaviour
|
||||
between several instances of itself without interfering with how other
|
||||
classes (especially either subclasses or superclasses) interact. Private
|
||||
methods precede all mixed in classes in the method call order (as reported by
|
||||
\fBself call\fR).
|
||||
.VE TIP500
|
||||
.SH "SLOTTED DEFINITIONS"
|
||||
Some of the configurable definitions of a class or object are \fIslotted
|
||||
definitions\fR. This means that the configuration is implemented by a slot
|
||||
object, that is an instance of the class \fBoo::Slot\fR, which manages a list
|
||||
of values (class names, variable names, etc.) that comprises the contents of
|
||||
the slot. The class defines three operations (as methods) that may be done on
|
||||
the slot. The class defines five operations (as methods) that may be done on
|
||||
the slot:
|
||||
.VE
|
||||
.TP
|
||||
\fIslot\fR \fB\-append\fR ?\fImember ...\fR?
|
||||
.VS
|
||||
.
|
||||
This appends the given \fImember\fR elements to the slot definition.
|
||||
.VE
|
||||
.TP
|
||||
\fIslot\fR \fB\-clear\fR
|
||||
.VS
|
||||
.
|
||||
This sets the slot definition to the empty list.
|
||||
.VE
|
||||
.TP
|
||||
\fIslot\fR \fB\-prepend\fR ?\fImember ...\fR?
|
||||
.VS TIP516
|
||||
This prepends the given \fImember\fR elements to the slot definition.
|
||||
.VE TIP516
|
||||
.TP
|
||||
\fIslot\fR \fB\-remove\fR ?\fImember ...\fR?
|
||||
.VS TIP516
|
||||
This removes the given \fImember\fR elements from the slot definition.
|
||||
.VE TIP516
|
||||
.TP
|
||||
\fIslot\fR \fB\-set\fR ?\fImember ...\fR?
|
||||
.VS
|
||||
.
|
||||
This replaces the slot definition with the given \fImember\fR elements.
|
||||
.PP
|
||||
A consequence of this is that any use of a slot's default operation where the
|
||||
@@ -331,20 +461,55 @@ which is forwarded to the default operation of the slot (thus, for the class
|
||||
slot, this is forwarded to
|
||||
.QW "\fBmy \-append\fR" ),
|
||||
and these methods which provide the implementation interface:
|
||||
.VE
|
||||
.TP
|
||||
\fIslot\fR \fBGet\fR
|
||||
.VS
|
||||
Returns a list that is the current contents of the slot. This method must
|
||||
always be called from a stack frame created by a call to \fBoo::define\fR or
|
||||
\fBoo::objdefine\fR.
|
||||
.VE
|
||||
.
|
||||
Returns a list that is the current contents of the slot, but does not modify
|
||||
the slot. This method must always be called from a stack frame created by a
|
||||
call to \fBoo::define\fR or \fBoo::objdefine\fR. This method \fIshould not\fR
|
||||
return an error unless it is called from outside a definition context or with
|
||||
the wrong number of arguments.
|
||||
.RS
|
||||
.PP
|
||||
.VS TIP516
|
||||
The elements of the list should be fully resolved, if that is a meaningful
|
||||
concept to the slot.
|
||||
.VE TIP516
|
||||
.RE
|
||||
.TP
|
||||
\fIslot\fR \fBResolve\fR \fIslotElement\fR
|
||||
.VS TIP516
|
||||
Returns \fIslotElement\fR with a resolution operation applied to it, but does
|
||||
not modify the slot. For slots of simple strings, this is an operation that
|
||||
does nothing, whereas for slots of classes, this maps a class name to its
|
||||
fully-qualified class name. This method must always be called from a stack
|
||||
frame created by a call to \fBoo::define\fR or \fBoo::objdefine\fR. This
|
||||
method \fIshould not\fR return an error unless it is called from outside a
|
||||
definition context or with the wrong number of arguments; unresolvable
|
||||
arguments should be returned as is (as not all slot operations strictly
|
||||
require that values are resolvable to work).
|
||||
.RS
|
||||
.PP
|
||||
Implementations \fIshould not\fR enforce uniqueness and ordering constraints
|
||||
in this method; that is the responsibility of the \fBSet\fR method.
|
||||
.RE
|
||||
.VE TIP516
|
||||
.TP
|
||||
\fIslot\fR \fBSet \fIelementList\fR
|
||||
.VS
|
||||
.
|
||||
Sets the contents of the slot to the list \fIelementList\fR and returns the
|
||||
empty string. This method must always be called from a stack frame created by
|
||||
a call to \fBoo::define\fR or \fBoo::objdefine\fR.
|
||||
a call to \fBoo::define\fR or \fBoo::objdefine\fR. This method may return an
|
||||
error if it rejects the change to the slot contents (e.g., because of invalid
|
||||
values) as well as if it is called from outside a definition context or with
|
||||
the wrong number of arguments.
|
||||
.RS
|
||||
.PP
|
||||
This method \fImay\fR reorder and filter the elements if this is necessary in
|
||||
order to satisfy the underlying constraints of the slot. (For example, slots
|
||||
of classes enforce a uniqueness constraint that places each element in the
|
||||
earliest location in the slot that it can.)
|
||||
.RE
|
||||
.PP
|
||||
The implementation of these methods is slot-dependent (and responsible for
|
||||
accessing the correct part of the class or object definition). Slots also have
|
||||
@@ -352,7 +517,14 @@ an unknown method handler to tie all these pieces together, and they hide
|
||||
their \fBdestroy\fR method so that it is not invoked inadvertently. It is
|
||||
\fIrecommended\fR that any user changes to the slot mechanism be restricted to
|
||||
defining new operations whose names start with a hyphen.
|
||||
.VE
|
||||
.PP
|
||||
.VS TIP516
|
||||
Most slot operations will initially \fBResolve\fR their argument list, combine
|
||||
it with the results of the \fBGet\fR method, and then \fBSet\fR the result.
|
||||
Some operations omit one or both of the first two steps; omitting the third
|
||||
would result in an idempotent read-only operation (but the standard mechanism
|
||||
for reading from slots is via \fBinfo class\fR and \fBinfo object\fR).
|
||||
.VE TIP516
|
||||
.SH EXAMPLES
|
||||
This example demonstrates how to use both forms of the \fBoo::define\fR and
|
||||
\fBoo::objdefine\fR commands (they work in the same way), as well as
|
||||
@@ -409,6 +581,84 @@ oo::class create B {
|
||||
inst m1 \fI\(-> prints "red brick"\fR
|
||||
inst m2 \fI\(-> prints "blue brick"\fR
|
||||
.CE
|
||||
.PP
|
||||
.VS TIP478
|
||||
This example shows how to create and use class variables. It is a class that
|
||||
counts how many instances of itself have been made.
|
||||
.PP
|
||||
.CS
|
||||
oo::class create Counted
|
||||
\fBoo::define\fR Counted {
|
||||
\fBinitialise\fR {
|
||||
variable count 0
|
||||
}
|
||||
|
||||
\fBvariable\fR number
|
||||
\fBconstructor\fR {} {
|
||||
classvariable count
|
||||
set number [incr count]
|
||||
}
|
||||
|
||||
\fBmethod\fR report {} {
|
||||
classvariable count
|
||||
puts "This is instance $number of $count"
|
||||
}
|
||||
}
|
||||
|
||||
set a [Counted new]
|
||||
set b [Counted new]
|
||||
$a report
|
||||
\fI\(-> This is instance 1 of 2\fR
|
||||
set c [Counted new]
|
||||
$b report
|
||||
\fI\(-> This is instance 2 of 3\fR
|
||||
$c report
|
||||
\fI\(-> This is instance 3 of 3\fR
|
||||
.CE
|
||||
.PP
|
||||
This example demonstrates how to use class methods. (Note that the constructor
|
||||
for \fBoo::class\fR calls \fBoo::define\fR on the class.)
|
||||
.PP
|
||||
.CS
|
||||
oo::class create DBTable {
|
||||
\fBclassmethod\fR find {description} {
|
||||
puts "DB: locate row from [self] matching $description"
|
||||
return [my new]
|
||||
}
|
||||
\fBclassmethod\fR insert {description} {
|
||||
puts "DB: create row in [self] matching $description"
|
||||
return [my new]
|
||||
}
|
||||
\fBmethod\fR update {description} {
|
||||
puts "DB: update row [self] with $description"
|
||||
}
|
||||
\fBmethod\fR delete {} {
|
||||
puts "DB: delete row [self]"
|
||||
my destroy; # Just delete the object, not the DB row
|
||||
}
|
||||
}
|
||||
|
||||
oo::class create Users {
|
||||
\fBsuperclass\fR DBTable
|
||||
}
|
||||
oo::class create Groups {
|
||||
\fBsuperclass\fR DBTable
|
||||
}
|
||||
|
||||
set u1 [Users insert "username=abc"]
|
||||
\fI\(-> DB: create row from ::Users matching username=abc\fR
|
||||
set u2 [Users insert "username=def"]
|
||||
\fI\(-> DB: create row from ::Users matching username=def\fR
|
||||
$u2 update "group=NULL"
|
||||
\fI\(-> DB: update row ::oo::Obj124 with group=NULL\fR
|
||||
$u1 delete
|
||||
\fI\(-> DB: delete row ::oo::Obj123\fR
|
||||
set g [Group find "groupname=webadmins"]
|
||||
\fI\(-> DB: locate row ::Group with groupname=webadmins\fR
|
||||
$g update "emailaddress=admins"
|
||||
\fI\(-> DB: update row ::oo::Obj125 with emailaddress=admins\fR
|
||||
.CE
|
||||
.VE TIP478
|
||||
.SH "SEE ALSO"
|
||||
next(n), oo::class(n), oo::object(n)
|
||||
.SH KEYWORDS
|
||||
|
||||
+35
@@ -27,6 +27,11 @@ key maps to in the dictionary value contained in the given variable,
|
||||
writing the resulting dictionary value back to that variable.
|
||||
Non-existent keys are treated as if they map to an empty string. The
|
||||
updated dictionary value is returned.
|
||||
.VS TIP508
|
||||
If \fIdictionaryVarable\fR indicates an element that does not exist of an
|
||||
array that has a default value set, the default value and will be used as the
|
||||
value of the dictionary prior to the appending operation.
|
||||
.VE TIP508
|
||||
.TP
|
||||
\fBdict create \fR?\fIkey value ...\fR?
|
||||
.
|
||||
@@ -124,6 +129,11 @@ resulting dictionary value back to that variable. Non-existent keys
|
||||
are treated as if they map to 0. It is an error to increment a value
|
||||
for an existing key if that value is not an integer. The updated
|
||||
dictionary value is returned.
|
||||
.VS TIP508
|
||||
If \fIdictionaryVarable\fR indicates an element that does not exist of an
|
||||
array that has a default value set, the default value and will be used as the
|
||||
value of the dictionary prior to the incrementing operation.
|
||||
.VE TIP508
|
||||
.TP
|
||||
\fBdict info \fIdictionaryValue\fR
|
||||
.
|
||||
@@ -149,6 +159,11 @@ keys are treated as if they map to an empty list, and it is legal for
|
||||
there to be no items to append to the list. It is an error for the
|
||||
value that the key maps to to not be representable as a list. The
|
||||
updated dictionary value is returned.
|
||||
.VS TIP508
|
||||
If \fIdictionaryVarable\fR indicates an element that does not exist of an
|
||||
array that has a default value set, the default value and will be used as the
|
||||
value of the dictionary prior to the list-appending operation.
|
||||
.VE TIP508
|
||||
.TP
|
||||
\fBdict map \fR{\fIkeyVariable valueVariable\fR} \fIdictionaryValue body\fR
|
||||
.
|
||||
@@ -206,6 +221,11 @@ value and places an updated dictionary value in that variable
|
||||
containing a mapping from the given key to the given value. When
|
||||
multiple keys are present, this operation creates or updates a chain
|
||||
of nested dictionaries. The updated dictionary value is returned.
|
||||
.VS TIP508
|
||||
If \fIdictionaryVarable\fR indicates an element that does not exist of an
|
||||
array that has a default value set, the default value and will be used as the
|
||||
value of the dictionary prior to the value insert/update operation.
|
||||
.VE TIP508
|
||||
.TP
|
||||
\fBdict size \fIdictionaryValue\fR
|
||||
.
|
||||
@@ -221,6 +241,11 @@ through nested dictionaries to the mapping to remove. At least one key
|
||||
must be specified, but the last key on the key-path need not exist.
|
||||
All other components on the path must exist. The updated dictionary
|
||||
value is returned.
|
||||
.VS TIP508
|
||||
If \fIdictionaryVarable\fR indicates an element that does not exist of an
|
||||
array that has a default value set, the default value and will be used as the
|
||||
value of the dictionary prior to the value remove operation.
|
||||
.VE TIP508
|
||||
.TP
|
||||
\fBdict update \fIdictionaryVariable key varName \fR?\fIkey varName ...\fR? \fIbody\fR
|
||||
.
|
||||
@@ -236,6 +261,11 @@ are silently discarded), even if the result of \fIbody\fR is an error
|
||||
or some other kind of exceptional exit. The result of \fBdict
|
||||
update\fR is (unless some kind of error occurs) the result of the
|
||||
evaluation of \fIbody\fR.
|
||||
.VS TIP508
|
||||
If \fIdictionaryVarable\fR indicates an element that does not exist of an
|
||||
array that has a default value set, the default value and will be used as the
|
||||
value of the dictionary prior to the update operation.
|
||||
.VE TIP508
|
||||
.RS
|
||||
.PP
|
||||
Each \fIvarName\fR is mapped in the scope enclosing the \fBdict update\fR;
|
||||
@@ -270,6 +300,11 @@ dictionary be discarded, and this also happens if the contents of
|
||||
dictionaries no longer exists. The result of \fBdict with\fR is
|
||||
(unless some kind of error occurs) the result of the evaluation of
|
||||
\fIbody\fR.
|
||||
.VS TIP508
|
||||
If \fIdictionaryVarable\fR indicates an element that does not exist of an
|
||||
array that has a default value set, the default value and will be used as the
|
||||
value of the dictionary prior to the updating operation.
|
||||
.VE TIP508
|
||||
.RS
|
||||
.PP
|
||||
The variables are mapped in the scope enclosing the \fBdict with\fR;
|
||||
|
||||
@@ -59,3 +59,7 @@ while {1} {
|
||||
file(n), open(n), close(n), fblocked(n), Tcl_StandardChannels(3)
|
||||
.SH KEYWORDS
|
||||
channel, end of file
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+17
@@ -217,6 +217,19 @@ information is instead sent to the console, if one is present, or is
|
||||
discarded.
|
||||
.RS
|
||||
.PP
|
||||
Note that the current escape resp. quoting of arguments for windows works only
|
||||
with executables using CommandLineToArgv, CRT-library or similar, as well as
|
||||
with the windows batch files (excepting the newline, see below).
|
||||
Although it is the common escape algorithm, but, in fact, the way how the
|
||||
executable parses the command-line (resp. splits it into single arguments)
|
||||
is decisive.
|
||||
.PP
|
||||
Unfortunately, there is currently no way to supply newline character within
|
||||
an argument to the batch files (\fB.cmd\fR or \fB.bat\fR) or to the command
|
||||
processor (\fBcmd.exe /c\fR), because this causes truncation of command-line
|
||||
(also the argument chain) on the first newline character.
|
||||
But it works properly with an executable (using CommandLineToArgv, etc).
|
||||
.PP
|
||||
The Tk console text widget does not provide real standard IO capabilities.
|
||||
Under Tk, when redirecting from standard input, all applications will see an
|
||||
immediate end-of-file; information redirected to standard output or standard
|
||||
@@ -409,6 +422,10 @@ that sometimes pop up:
|
||||
With the file \fIcmp.bat\fR looking something like:
|
||||
.PP
|
||||
.CS
|
||||
@gcc %*
|
||||
.CE
|
||||
or like another variant using single parameters:
|
||||
.CS
|
||||
@gcc %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
.CE
|
||||
.SS "WORKING WITH COMMAND BUILT-INS"
|
||||
|
||||
@@ -49,3 +49,7 @@ if {[catch {main} msg options]} {
|
||||
exec(n)
|
||||
.SH KEYWORDS
|
||||
abort, exit, process
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -65,3 +65,7 @@ vwait forever
|
||||
gets(n), open(n), read(n), socket(n), Tcl_StandardChannels(3)
|
||||
.SH KEYWORDS
|
||||
blocking, nonblocking
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -154,3 +154,7 @@ fconfigure(n), gets(n), interp(n), puts(n), read(n), Tcl_StandardChannels(3)
|
||||
.SH KEYWORDS
|
||||
asynchronous I/O, blocking, channel, event handler, nonblocking, readable,
|
||||
script, writable.
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -176,3 +176,7 @@ file(n), glob(n)
|
||||
.SH KEYWORDS
|
||||
current directory, absolute file name, relative file name,
|
||||
volume-relative file name, portability
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -43,3 +43,7 @@ puts "Hello there, $name!"
|
||||
file(n), open(n), socket(n), Tcl_StandardChannels(3)
|
||||
.SH KEYWORDS
|
||||
blocking, buffer, channel, flush, nonblocking, output
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -102,3 +102,7 @@ for(n), while(n), break(n), continue(n)
|
||||
|
||||
.SH KEYWORDS
|
||||
foreach, iteration, list, loop
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -56,3 +56,7 @@ proc accum {string} {
|
||||
namespace(n), upvar(n), variable(n)
|
||||
.SH KEYWORDS
|
||||
global, namespace, procedure, variable
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -100,3 +100,7 @@ the \fBevent\fR operation to retrieve some event,
|
||||
and the \fBadd\fR operation to add it to history and execute it.
|
||||
.SH KEYWORDS
|
||||
event, history, record
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+178
-10
@@ -6,22 +6,24 @@
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH "http" n 2.7 http "Tcl Bundled Packages"
|
||||
.TH "http" n 2.9 http "Tcl Bundled Packages"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
http \- Client-side implementation of the HTTP/1.1 protocol
|
||||
.SH SYNOPSIS
|
||||
\fBpackage require http ?2.7?\fR
|
||||
\fBpackage require http\fI ?\fB2.8\fR?
|
||||
.\" See Also -useragent option documentation in body!
|
||||
.sp
|
||||
\fB::http::config ?\fI\-option value\fR ...?
|
||||
\fB::http::config\fR ?\fI\-option value\fR ...?
|
||||
.sp
|
||||
\fB::http::geturl \fIurl\fR ?\fI\-option value\fR ...?
|
||||
.sp
|
||||
\fB::http::formatQuery\fR \fIkey value\fR ?\fIkey value\fR ...?
|
||||
.sp
|
||||
\fB::http::quoteString\fR \fIvalue\fR
|
||||
.sp
|
||||
\fB::http::reset\fR \fItoken\fR ?\fIwhy\fR?
|
||||
.sp
|
||||
\fB::http::wait \fItoken\fR
|
||||
@@ -44,12 +46,14 @@ http \- Client-side implementation of the HTTP/1.1 protocol
|
||||
.sp
|
||||
\fB::http::register \fIproto port command\fR
|
||||
.sp
|
||||
\fB::http::registerError \fIport\fR ?\fImessage\fR?
|
||||
.sp
|
||||
\fB::http::unregister \fIproto\fR
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
The \fBhttp\fR package provides the client side of the HTTP/1.1
|
||||
protocol, as defined in RFC 2616.
|
||||
protocol, as defined in RFC 7230 to RFC 7235, which supersede RFC 2616.
|
||||
The package implements the GET, POST, and HEAD operations
|
||||
of HTTP/1.1. It allows configuration of a proxy host to get through
|
||||
firewalls. The package is compatible with the \fBSafesock\fR security
|
||||
@@ -95,6 +99,19 @@ comma-separated list of mime type patterns that you are
|
||||
willing to receive. For example,
|
||||
.QW "image/gif, image/jpeg, text/*" .
|
||||
.TP
|
||||
\fB\-pipeline\fR \fIboolean\fR
|
||||
.
|
||||
Specifies whether HTTP/1.1 transactions on a persistent socket will be
|
||||
pipelined. See the \fBPERSISTENT SOCKETS\fR section for details. The default
|
||||
is 1.
|
||||
.TP
|
||||
\fB\-postfresh\fR \fIboolean\fR
|
||||
.
|
||||
Specifies whether requests that use the \fBPOST\fR method will always use a
|
||||
fresh socket, overriding the \fB-keepalive\fR option of
|
||||
command \fBhttp::geturl\fR. See the \fBPERSISTENT SOCKETS\fR section for details.
|
||||
The default is 0.
|
||||
.TP
|
||||
\fB\-proxyhost\fR \fIhostname\fR
|
||||
.
|
||||
The name of the proxy host, if any. If this value is the
|
||||
@@ -116,20 +133,47 @@ an empty list. The default filter returns the values of the
|
||||
\fB\-proxyhost\fR and \fB\-proxyport\fR settings if they are
|
||||
non-empty.
|
||||
.TP
|
||||
\fB\-repost\fR \fIboolean\fR
|
||||
.
|
||||
Specifies what to do if a POST request over a persistent connection fails
|
||||
because the server has half-closed the connection. If boolean \fBtrue\fR, the
|
||||
request
|
||||
will be automatically retried; if boolean \fBfalse\fR it will not, and the
|
||||
application
|
||||
that uses \fBhttp::geturl\fR is expected to seek user confirmation before
|
||||
retrying the POST. The value \fBtrue\fR should be used only under certain
|
||||
conditions. See the \fBPERSISTENT SOCKETS\fR section for details. The
|
||||
default is 0.
|
||||
.TP
|
||||
\fB\-urlencoding\fR \fIencoding\fR
|
||||
.
|
||||
The \fIencoding\fR used for creating the x-url-encoded URLs with
|
||||
\fB::http::formatQuery\fR. The default is \fButf-8\fR, as specified by RFC
|
||||
\fB::http::formatQuery\fR and \fB::http::quoteString\fR.
|
||||
The default is \fButf-8\fR, as specified by RFC
|
||||
2718. Prior to http 2.5 this was unspecified, and that behavior can be
|
||||
returned by specifying the empty string (\fB{}\fR), although
|
||||
\fIiso8859-1\fR is recommended to restore similar behavior but without the
|
||||
\fB::http::formatQuery\fR throwing an error processing non-latin-1
|
||||
characters.
|
||||
\fB::http::formatQuery\fR or \fB::http::quoteString\fR
|
||||
throwing an error processing non-latin-1 characters.
|
||||
.TP
|
||||
\fB\-useragent\fR \fIstring\fR
|
||||
.
|
||||
The value of the User-Agent header in the HTTP request. The default is
|
||||
.QW "\fBTcl http client package 2.7\fR" .
|
||||
The value of the User-Agent header in the HTTP request. In an unsafe
|
||||
interpreter, the default value depends upon the operating system, and
|
||||
the version numbers of \fBhttp\fR and \fBTcl\fR, and is (for example)
|
||||
.QW "\fBMozilla/5.0 (Windows; U; Windows NT 10.0) http/2.8.12 Tcl/8.6.8\fR" .
|
||||
A safe interpreter cannot determine its operating system, and so the default
|
||||
in a safe interpreter is to use a Windows 10 value with the current version
|
||||
numbers of \fBhttp\fR and \fBTcl\fR.
|
||||
.TP
|
||||
\fB\-zip\fR \fIboolean\fR
|
||||
.
|
||||
If the value is boolean \fBtrue\fR, then by default requests will send a header
|
||||
.QW "\fBAccept-Encoding: gzip,deflate,compress\fR" .
|
||||
If the value is boolean \fBfalse\fR, then by default this header will not be sent.
|
||||
In either case the default can be overridden for an individual request by
|
||||
supplying a custom \fBAccept-Encoding\fR header in the \fB-headers\fR option
|
||||
of \fBhttp::geturl\fR. The default is 1.
|
||||
.RE
|
||||
.TP
|
||||
\fB::http::geturl\fR \fIurl\fR ?\fIoptions\fR?
|
||||
@@ -227,7 +271,7 @@ Pragma: no-cache
|
||||
.TP
|
||||
\fB\-keepalive\fR \fIboolean\fR
|
||||
.
|
||||
If true, attempt to keep the connection open for servicing
|
||||
If boolean \fBtrue\fR, attempt to keep the connection open for servicing
|
||||
multiple requests. Default is 0.
|
||||
.TP
|
||||
\fB\-method\fR \fItype\fR
|
||||
@@ -334,6 +378,11 @@ encodes the keys and values, and generates one string that has the
|
||||
proper & and = separators. The result is suitable for the
|
||||
\fB\-query\fR value passed to \fB::http::geturl\fR.
|
||||
.TP
|
||||
\fB::http::quoteString\fR \fIvalue\fR
|
||||
.
|
||||
This procedure does x-url-encoding of string. It takes a single argument and
|
||||
encodes it.
|
||||
.TP
|
||||
\fB::http::reset\fR \fItoken\fR ?\fIwhy\fR?
|
||||
.
|
||||
This command resets the HTTP transaction identified by \fItoken\fR, if any.
|
||||
@@ -415,6 +464,17 @@ set token [::http::geturl https://my.secure.site/]
|
||||
.CE
|
||||
.RE
|
||||
.TP
|
||||
\fB::http::registerError\fR \fIport\fR ?\fImessage\fR?
|
||||
.
|
||||
This procedure allows a registered protocol handler to deliver an error
|
||||
message for use by \fBhttp\fR. Calling this command does not raise an
|
||||
error. The command is useful when a registered protocol detects an problem
|
||||
(for example, an invalid TLS certificate) that will cause an error to
|
||||
propagate to \fBhttp\fR. The command allows \fBhttp\fR to provide a
|
||||
precise error message rather than a general one. The command returns the
|
||||
value provided by the last call with argument \fImessage\fR, or the empty
|
||||
string if no such call has been made.
|
||||
.TP
|
||||
\fB::http::unregister\fR \fIproto\fR
|
||||
.
|
||||
This procedure unregisters a protocol handler that was previously
|
||||
@@ -504,6 +564,14 @@ The following elements of
|
||||
the array are supported:
|
||||
.RS
|
||||
.TP
|
||||
\fBbinary\fR
|
||||
.
|
||||
This is boolean \fBtrue\fR if (after decoding any compression specified
|
||||
by the
|
||||
.QW "Content-Encoding"
|
||||
response header) the HTTP response is binary. It is boolean \fBfalse\fR
|
||||
if the HTTP response is text.
|
||||
.TP
|
||||
\fBbody\fR
|
||||
.
|
||||
The contents of the URL. This will be empty if the \fB\-channel\fR
|
||||
@@ -602,6 +670,106 @@ A copy of the \fBContent-Type\fR meta-data value.
|
||||
.
|
||||
The requested URL.
|
||||
.RE
|
||||
.SH "PERSISTENT CONNECTIONS"
|
||||
.PP
|
||||
.SS "BASICS"
|
||||
.PP
|
||||
See RFC 7230 Sec 6, which supersedes RFC 2616 Sec 8.1.
|
||||
.PP
|
||||
A persistent connection allows multiple HTTP/1.1 transactions to be
|
||||
carried over the same TCP connection. Pipelining allows a
|
||||
client to make multiple requests over a persistent connection without
|
||||
waiting for each response. The server sends responses in the same order
|
||||
that the requests were received.
|
||||
.PP
|
||||
If a POST request fails to complete, typically user confirmation is
|
||||
needed before sending the request again. The user may wish to verify
|
||||
whether the server was modified by the failed POST request, before
|
||||
sending the same request again.
|
||||
.PP
|
||||
A HTTP request will use a persistent socket if the call to
|
||||
\fBhttp::geturl\fR has the option \fB-keepalive true\fR. It will use
|
||||
pipelining where permitted if the \fBhttp::config\fR option
|
||||
\fB-pipeline\fR is boolean \fBtrue\fR (its default value).
|
||||
.PP
|
||||
The http package maintains no more than one persistent connection to each
|
||||
server (i.e. each value of
|
||||
.QW "domain:port" ).
|
||||
If \fBhttp::geturl\fR is called to make a request over a persistent
|
||||
connection while the connection is busy with another request, the new
|
||||
request will be held in a queue until the connection is free.
|
||||
.PP
|
||||
The http package does not support HTTP/1.0 persistent connections
|
||||
controlled by the \fBKeep-Alive\fR header.
|
||||
.SS "SPECIAL CASES"
|
||||
.PP
|
||||
This subsection discusses issues related to closure of the
|
||||
persistent connection by the server, automatic retry of failed requests,
|
||||
the special treatment necessary for POST requests, and the options for
|
||||
dealing with these cases.
|
||||
.PP
|
||||
In accordance with RFC 7230, \fBhttp::geturl\fR does not pipeline
|
||||
requests that use the POST method. If a POST uses a persistent
|
||||
connection and is not the first request on that connection,
|
||||
\fBhttp::geturl\fR waits until it has received the response for the previous
|
||||
request; or (if \fBhttp::config\fR option \fB-postfresh\fR is boolean \fBtrue\fR) it
|
||||
uses a new connection for each POST.
|
||||
.PP
|
||||
If the server is processing a number of pipelined requests, and sends a
|
||||
response header
|
||||
.QW "\fBConnection: close\fR"
|
||||
with one of the responses (other than the last), then subsequent responses
|
||||
are unfulfilled. \fBhttp::geturl\fR will send the unfulfilled requests again
|
||||
over a new connection.
|
||||
.PP
|
||||
A difficulty arises when a HTTP client sends a request over a persistent
|
||||
connection that has been idle for a while. The HTTP server may
|
||||
half-close an apparently idle connection while the client is sending a
|
||||
request, but before the request arrives at the server: in this case (an
|
||||
.QW "asynchronous close event" )
|
||||
the request will fail. The difficulty arises because the client cannot
|
||||
be certain whether the POST modified the state of the server. For HEAD or
|
||||
GET requests, \fBhttp::geturl\fR opens another connection and retransmits
|
||||
the failed request. However, if the request was a POST, RFC 7230 forbids
|
||||
automatic retry by default, suggesting either user confirmation, or
|
||||
confirmation by user-agent software that has semantic understanding of
|
||||
the application. The \fBhttp::config\fR option \fB-repost\fR allows for
|
||||
either possibility.
|
||||
.PP
|
||||
Asynchronous close events can occur only in a short interval of time. The
|
||||
\fBhttp\fR package monitors each persistent connection for closure by the
|
||||
server. Upon detection, the connection is also closed at the client end,
|
||||
and subsequent requests will use a fresh connection.
|
||||
.PP
|
||||
If the \fBhttp::geturl\fR command is called with option \fB-keepalive true\fR,
|
||||
then it will both try to use an existing persistent connection
|
||||
(if one is available), and it will send the server a
|
||||
.QW "\fBConnection: keep-alive\fR"
|
||||
request header asking to keep the connection open for future requests.
|
||||
.PP
|
||||
The \fBhttp::config\fR options \fB-pipeline\fR, \fB-postfresh\fR, and
|
||||
\fB-repost\fR relate to persistent connections.
|
||||
.PP
|
||||
Option \fB-pipeline\fR, if boolean \fBtrue\fR, will pipeline GET and HEAD requests
|
||||
made
|
||||
over a persistent connection. POST requests will not be pipelined - if the
|
||||
POST is not the first transaction on the connection, its request will not
|
||||
be sent until the previous response has finished. GET and HEAD requests
|
||||
made after a POST will not be sent until the POST response has been
|
||||
delivered, and will not be sent if the POST fails.
|
||||
.PP
|
||||
Option \fB-postfresh\fR, if boolean \fBtrue\fR, will override the \fBhttp::geturl\fR option
|
||||
\fB-keepalive\fR, and always open a fresh connection for a POST request.
|
||||
.PP
|
||||
Option \fB-repost\fR, if \fBtrue\fR, permits automatic retry of a POST request
|
||||
that fails because it uses a persistent connection that the server has
|
||||
half-closed (an
|
||||
.QW "asynchronous close event" ).
|
||||
Subsequent GET and HEAD requests in a failed pipeline will also be retried.
|
||||
\fIThe -repost option should be used only if the application understands
|
||||
that the retry is appropriate\fR - specifically, the application must know
|
||||
that if the failed POST successfully modified the state of the server, a repeat POST
|
||||
would have no adverse effect.
|
||||
.SH EXAMPLE
|
||||
.PP
|
||||
This example creates a procedure to copy a URL to a file while printing a
|
||||
|
||||
@@ -27,6 +27,11 @@ and also returned as result.
|
||||
Starting with the Tcl 8.5 release, the variable \fIvarName\fR passed
|
||||
to \fBincr\fR may be unset, and in that case, it will be set to
|
||||
the value \fIincrement\fR or to the default increment value of \fB1\fR.
|
||||
.VS TIP508
|
||||
If \fIvarName\fR indicate an element that does not exist of an array that has
|
||||
a default value set, the sum of the default value and the \fIincrement\fR (or
|
||||
1) will be stored in the array element.
|
||||
.VE TIP508
|
||||
.SH EXAMPLES
|
||||
.PP
|
||||
Add one to the contents of the variable \fIx\fR:
|
||||
@@ -59,3 +64,7 @@ an error if it is not):
|
||||
expr(n), set(n)
|
||||
.SH KEYWORDS
|
||||
add, increment, variable, value
|
||||
.\" Local variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
|
||||
+188
-98
@@ -35,16 +35,51 @@ Returns the body of procedure \fIprocname\fR. \fIProcname\fR must be
|
||||
the name of a Tcl command procedure.
|
||||
.TP
|
||||
\fBinfo class\fI subcommand class\fR ?\fIarg ...\fR
|
||||
.VS 8.6
|
||||
.
|
||||
Returns information about the class, \fIclass\fR. The \fIsubcommand\fRs are
|
||||
described in \fBCLASS INTROSPECTION\fR below.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo cmdcount\fR
|
||||
.
|
||||
Returns a count of the total number of commands that have been invoked
|
||||
in this interpreter.
|
||||
.TP
|
||||
\fBinfo cmdtype \fIcommandName\fR
|
||||
.VS TIP426
|
||||
Returns a description of the kind of command named by \fIcommandName\fR. The
|
||||
supported types are:
|
||||
.RS
|
||||
.IP \fBalias\fR
|
||||
Indicates that \fIcommandName\fR was created by \fBinterp alias\fR. Note that
|
||||
safe interpreters can only see a subset of aliases (specifically those between
|
||||
two commands within themselves).
|
||||
.IP \fBcoroutine\fR
|
||||
Indicates that \fIcommandName\fR was created by \fBcoroutine\fR.
|
||||
.IP \fBensemble\fR
|
||||
Indicates that \fIcommandName\fR was created by \fBnamespace ensemble\fR.
|
||||
.IP \fBimport\fR
|
||||
Indicates that \fIcommandName\fR was created by \fBnamespace import\fR.
|
||||
.IP \fBnative\fR
|
||||
Indicates that \fIcommandName\fR was created by the \fBTcl_CreateObjProc\fR
|
||||
interface directly without further registration of the type of command.
|
||||
.IP \fBobject\fR
|
||||
Indicates that \fIcommandName\fR is the public command that represents an
|
||||
instance of \fBoo::object\fR or one of its subclasses.
|
||||
.IP \fBprivateObject\fR
|
||||
Indicates that \fIcommandName\fR is the private command (\fBmy\fR by default)
|
||||
that represents an instance of \fBoo::object\fR or one of its subclasses.
|
||||
.IP \fBproc\fR
|
||||
Indicates that \fIcommandName\fR was created by \fBproc\fR.
|
||||
.IP \fBslave\fR
|
||||
Indicates that \fIcommandName\fR was created by \fBinterp create\fR.
|
||||
.IP \fBzlibStream\fR
|
||||
Indicates that \fIcommandName\fR was created by \fBzlib stream\fR.
|
||||
.PP
|
||||
There may be other registered types as well; this is a set that is extensible
|
||||
at the implementation level with \fBTcl_RegisterCommandTypeName\fR.
|
||||
.RE
|
||||
.VE TIP426
|
||||
.TP
|
||||
\fBinfo commands \fR?\fIpattern\fR?
|
||||
.
|
||||
If \fIpattern\fR is not specified,
|
||||
@@ -78,11 +113,10 @@ command is not complete, the script can delay evaluating it until additional
|
||||
lines have been typed to complete the command.
|
||||
.TP
|
||||
\fBinfo coroutine\fR
|
||||
.VS 8.6
|
||||
.
|
||||
Returns the name of the currently executing \fBcoroutine\fR, or the empty
|
||||
string if either no coroutine is currently executing, or the current coroutine
|
||||
has been deleted (but has not yet returned or yielded since deletion).
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo default \fIprocname arg varname\fR
|
||||
.
|
||||
@@ -93,7 +127,7 @@ Otherwise it returns \fB1\fR and places the default value of \fIarg\fR
|
||||
into variable \fIvarname\fR.
|
||||
.TP
|
||||
\fBinfo errorstack \fR?\fIinterp\fR?
|
||||
.VS 8.6
|
||||
.
|
||||
Returns, in a form that is programmatically easy to parse, the function names
|
||||
and arguments at each level from the call stack of the last error in the given
|
||||
\fIinterp\fR, or in the current one if not specified.
|
||||
@@ -118,7 +152,6 @@ options dictionary returned by 3-argument \fBcatch\fR; \fBinfo errorstack\fR
|
||||
is a convenient way of retrieving it for uncaught errors at top-level in an
|
||||
interactive \fBtclsh\fR.
|
||||
.RE
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo exists \fIvarName\fR
|
||||
.
|
||||
@@ -329,10 +362,9 @@ was invoked. If Tcl was unable to identify the file, then an empty
|
||||
string is returned.
|
||||
.TP
|
||||
\fBinfo object\fI subcommand object\fR ?\fIarg ...\fR
|
||||
.VS 8.6
|
||||
.
|
||||
Returns information about the object, \fIobject\fR. The \fIsubcommand\fRs are
|
||||
described in \fBOBJECT INTROSPECTION\fR below.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo patchlevel\fR
|
||||
.
|
||||
@@ -399,20 +431,22 @@ Note that a currently-visible variable may not yet
|
||||
if it has not
|
||||
been set (e.g. a variable declared but not set by \fBvariable\fR).
|
||||
.SS "CLASS INTROSPECTION"
|
||||
.VS 8.6
|
||||
.PP
|
||||
The following \fIsubcommand\fR values are supported by \fBinfo class\fR:
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class call\fI class method\fR
|
||||
.VS
|
||||
.
|
||||
Returns a description of the method implementations that are used to provide a
|
||||
stereotypical instance of \fIclass\fR's implementation of \fImethod\fR
|
||||
(stereotypical instances being objects instantiated by a class without having
|
||||
any object-specific definitions added). This consists of a list of lists of
|
||||
four elements, where each sublist consists of a word that describes the
|
||||
general type of method implementation (being one of \fBmethod\fR for an
|
||||
ordinary method, \fBfilter\fR for an applied filter, and \fBunknown\fR for a
|
||||
ordinary method, \fBfilter\fR for an applied filter,
|
||||
.VS TIP500
|
||||
\fBprivate\fR for a private method,
|
||||
.VE TIP500
|
||||
and \fBunknown\fR for a
|
||||
method that is invoked as part of unknown method handling), a word giving the
|
||||
name of the particular method invoked (which is always the same as
|
||||
\fImethod\fR for the \fBmethod\fR type, and
|
||||
@@ -423,122 +457,149 @@ implementation (see \fBinfo class methodtype\fR).
|
||||
.RS
|
||||
.PP
|
||||
Note that there is no inspection of whether the method implementations
|
||||
actually use \fBnext\fR to transfer control along the call chain.
|
||||
actually use \fBnext\fR to transfer control along the call chain,
|
||||
.VS TIP500
|
||||
and the call chains that this command files do not actually contain private
|
||||
methods.
|
||||
.VE TIP500
|
||||
.RE
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class constructor\fI class\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a description of the definition of the constructor of
|
||||
class \fIclass\fR. The definition is described as a two element list; the first
|
||||
element is the list of arguments to the constructor in a form suitable for
|
||||
passing to another call to \fBproc\fR or a method definition, and the second
|
||||
element is the body of the constructor. If no constructor is present, this
|
||||
returns the empty list.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class definition\fI class method\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a description of the definition of the method named
|
||||
\fImethod\fR of class \fIclass\fR. The definition is described as a two element
|
||||
list; the first element is the list of arguments to the method in a form
|
||||
suitable for passing to another call to \fBproc\fR or a method definition, and
|
||||
the second element is the body of the method.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class destructor\fI class\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns the body of the destructor of class \fIclass\fR. If no
|
||||
destructor is present, this returns the empty string.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class filters\fI class\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns the list of filter methods set on the class.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class forward\fI class method\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns the argument list for the method forwarding called
|
||||
\fImethod\fR that is set on the class called \fIclass\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class instances\fI class\fR ?\fIpattern\fR?
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a list of instances of class \fIclass\fR. If the
|
||||
optional \fIpattern\fR argument is present, it constrains the list of returned
|
||||
instances to those that match it according to the rules of \fBstring match\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class methods\fI class\fR ?\fIoptions...\fR?
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a list of all public (i.e. exported) methods of the
|
||||
class called \fIclass\fR. Any of the following \fIoption\fRs may be
|
||||
specified, controlling exactly which method names are returned:
|
||||
.RS
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fB\-all\fR
|
||||
.VS 8.6
|
||||
If the \fB\-all\fR flag is given, the list of methods will include those
|
||||
.
|
||||
If the \fB\-all\fR flag is given,
|
||||
.VS TIP500
|
||||
and the \fB\-scope\fR flag is not given,
|
||||
.VE TIP500
|
||||
the list of methods will include those
|
||||
methods defined not just by the class, but also by the class's superclasses
|
||||
and mixins.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fB\-private\fR
|
||||
.VS 8.6
|
||||
If the \fB\-private\fR flag is given, the list of methods will also include
|
||||
the private (i.e. non-exported) methods of the class (and superclasses and
|
||||
.
|
||||
If the \fB\-private\fR flag is given,
|
||||
.VS TIP500
|
||||
and the \fB\-scope\fR flag is not given,
|
||||
.VE TIP500
|
||||
the list of methods will also include
|
||||
the non-exported methods of the class (and superclasses and
|
||||
mixins, if \fB\-all\fR is also given).
|
||||
.VS TIP500
|
||||
Note that this naming is an unfortunate clash with true private methods; this
|
||||
option name is retained for backward compatibility.
|
||||
.VE TIP500
|
||||
.TP
|
||||
\fB\-scope\fI scope\fR
|
||||
.VS TIP500
|
||||
Returns a list of all methods on \fIclass\fR that have the given visibility
|
||||
\fIscope\fR. When this option is supplied, both the \fB\-all\fR and
|
||||
\fB\-private\fR options are ignored. The valid values for \fIscope\fR are:
|
||||
.RS
|
||||
.IP \fBpublic\fR 3
|
||||
Only methods with \fIpublic\fR scope (i.e., callable from anywhere by any instance
|
||||
of this class) are to be returned.
|
||||
.IP \fBunexported\fR 3
|
||||
Only methods with \fIunexported\fR scope (i.e., only callable via \fBmy\fR) are to
|
||||
be returned.
|
||||
.IP \fBprivate\fR 3
|
||||
Only methods with \fIprivate\fR scope (i.e., only callable from within this class's
|
||||
methods) are to be returned.
|
||||
.RE
|
||||
.VE TIP500
|
||||
.RE
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class methodtype\fI class method\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a description of the type of implementation used for
|
||||
the method named \fImethod\fR of class \fIclass\fR. When the result is
|
||||
\fBmethod\fR, further information can be discovered with \fBinfo class
|
||||
definition\fR, and when the result is \fBforward\fR, further information can
|
||||
be discovered with \fBinfo class forward\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class mixins\fI class\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a list of all classes that have been mixed into the
|
||||
class named \fIclass\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class subclasses\fI class\fR ?\fIpattern\fR?
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a list of direct subclasses of class \fIclass\fR. If
|
||||
the optional \fIpattern\fR argument is present, it constrains the list of
|
||||
returned classes to those that match it according to the rules of
|
||||
\fBstring match\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class superclasses\fI class\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a list of direct superclasses of class \fIclass\fR in
|
||||
inheritance precedence order.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo class variables\fI class\fR
|
||||
.VS 8.6
|
||||
\fBinfo class variables\fI class\fR ?\fB\-private\fR?
|
||||
.
|
||||
This subcommand returns a list of all variables that have been declared for
|
||||
the class named \fIclass\fR (i.e. that are automatically present in the
|
||||
class's methods, constructor and destructor).
|
||||
.VS TIP500
|
||||
If the \fB\-private\fR option is specified, this lists the private variables
|
||||
declared instead.
|
||||
.VE TIP500
|
||||
.SS "OBJECT INTROSPECTION"
|
||||
.PP
|
||||
The following \fIsubcommand\fR values are supported by \fBinfo object\fR:
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object call\fI object method\fR
|
||||
.VS 8.6
|
||||
.
|
||||
Returns a description of the method implementations that are used to provide
|
||||
\fIobject\fR's implementation of \fImethod\fR. This consists of a list of
|
||||
lists of four elements, where each sublist consists of a word that describes
|
||||
the general type of method implementation (being one of \fBmethod\fR for an
|
||||
ordinary method, \fBfilter\fR for an applied filter, and \fBunknown\fR for a
|
||||
ordinary method, \fBfilter\fR for an applied filter,
|
||||
.VS TIP500
|
||||
\fBprivate\fR for a private method,
|
||||
.VE TIP500
|
||||
and \fBunknown\fR for a
|
||||
method that is invoked as part of unknown method handling), a word giving the
|
||||
name of the particular method invoked (which is always the same as
|
||||
\fImethod\fR for the \fBmethod\fR type, and
|
||||
@@ -550,128 +611,160 @@ implementation (see \fBinfo object methodtype\fR).
|
||||
.RS
|
||||
.PP
|
||||
Note that there is no inspection of whether the method implementations
|
||||
actually use \fBnext\fR to transfer control along the call chain.
|
||||
actually use \fBnext\fR to transfer control along the call chain,
|
||||
.VS TIP500
|
||||
and the call chains that this command files do not actually contain private
|
||||
methods.
|
||||
.VE TIP500
|
||||
.RE
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object class\fI object\fR ?\fIclassName\fR?
|
||||
.VS 8.6
|
||||
.
|
||||
If \fIclassName\fR is unspecified, this subcommand returns class of the
|
||||
\fIobject\fR object. If \fIclassName\fR is present, this subcommand returns a
|
||||
boolean value indicating whether the \fIobject\fR is of that class.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object creationid\fI object\fR
|
||||
.VS TIP500
|
||||
Returns the unique creation identifier for the \fIobject\fR object. This
|
||||
creation identifier is unique to the object (within a Tcl interpreter) and
|
||||
cannot be controlled at object creation time or altered afterwards.
|
||||
.RS
|
||||
.PP
|
||||
\fIImplementation note:\fR the creation identifier is used to generate unique
|
||||
identifiers associated with the object, especially for private variables.
|
||||
.RE
|
||||
.VE TIP500
|
||||
.TP
|
||||
\fBinfo object definition\fI object method\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a description of the definition of the method named
|
||||
\fImethod\fR of object \fIobject\fR. The definition is described as a two
|
||||
element list; the first element is the list of arguments to the method in a
|
||||
form suitable for passing to another call to \fBproc\fR or a method definition,
|
||||
and the second element is the body of the method.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object filters\fI object\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns the list of filter methods set on the object.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object forward\fI object method\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns the argument list for the method forwarding called
|
||||
\fImethod\fR that is set on the object called \fIobject\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object isa\fI category object\fR ?\fIarg\fR?
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand tests whether an object belongs to a particular category,
|
||||
returning a boolean value that indicates whether the \fIobject\fR argument
|
||||
meets the criteria for the category. The supported categories are:
|
||||
.VE 8.6
|
||||
.RS
|
||||
.TP
|
||||
\fBinfo object isa class\fI object\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This returns whether \fIobject\fR is a class (i.e. an instance of
|
||||
\fBoo::class\fR or one of its subclasses).
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object isa metaclass\fI object\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This returns whether \fIobject\fR is a class that can manufacture classes
|
||||
(i.e. is \fBoo::class\fR or a subclass of it).
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object isa mixin\fI object class\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This returns whether \fIclass\fR is directly mixed into \fIobject\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object isa object\fI object\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This returns whether \fIobject\fR really is an object.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object isa typeof\fI object class\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This returns whether \fIclass\fR is the type of \fIobject\fR (i.e. whether
|
||||
\fIobject\fR is an instance of \fIclass\fR or one of its subclasses, whether
|
||||
direct or indirect).
|
||||
.RE
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object methods\fI object\fR ?\fIoption...\fR?
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a list of all public (i.e. exported) methods of the
|
||||
object called \fIobject\fR. Any of the following \fIoption\fRs may be
|
||||
specified, controlling exactly which method names are returned:
|
||||
.RS
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fB\-all\fR
|
||||
.VS 8.6
|
||||
If the \fB\-all\fR flag is given, the list of methods will include those
|
||||
.
|
||||
If the \fB\-all\fR flag is given,
|
||||
.VS TIP500
|
||||
and the \fB\-scope\fR flag is not given,
|
||||
.VE TIP500
|
||||
the list of methods will include those
|
||||
methods defined not just by the object, but also by the object's class and
|
||||
mixins, plus the superclasses of those classes.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fB\-private\fR
|
||||
.VS 8.6
|
||||
If the \fB\-private\fR flag is given, the list of methods will also include
|
||||
the private (i.e. non-exported) methods of the object (and classes, if
|
||||
.
|
||||
If the \fB\-private\fR flag is given,
|
||||
.VS TIP500
|
||||
and the \fB\-scope\fR flag is not given,
|
||||
.VE TIP500
|
||||
the list of methods will also include
|
||||
the non-exported methods of the object (and classes, if
|
||||
\fB\-all\fR is also given).
|
||||
.VS TIP500
|
||||
Note that this naming is an unfortunate clash with true private methods; this
|
||||
option name is retained for backward compatibility.
|
||||
.VE TIP500
|
||||
.TP
|
||||
\fB\-scope\fI scope\fR
|
||||
.VS TIP500
|
||||
Returns a list of all methods on \fIobject\fR that have the given visibility
|
||||
\fIscope\fR. When this option is supplied, both the \fB\-all\fR and
|
||||
\fB\-private\fR options are ignored. The valid values for \fIscope\fR are:
|
||||
.RS
|
||||
.IP \fBpublic\fR 3
|
||||
Only methods with \fIpublic\fR scope (i.e., callable from anywhere) are to be
|
||||
returned.
|
||||
.IP \fBunexported\fR 3
|
||||
Only methods with \fIunexported\fR scope (i.e., only callable via \fBmy\fR) are to
|
||||
be returned.
|
||||
.IP \fBprivate\fR 3
|
||||
Only methods with \fIprivate\fR scope (i.e., only callable from within this object's
|
||||
instance methods) are to be returned.
|
||||
.RE
|
||||
.VE TIP500
|
||||
.RE
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object methodtype\fI object method\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a description of the type of implementation used for
|
||||
the method named \fImethod\fR of object \fIobject\fR. When the result is
|
||||
\fBmethod\fR, further information can be discovered with \fBinfo object
|
||||
definition\fR, and when the result is \fBforward\fR, further information can
|
||||
be discovered with \fBinfo object forward\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object mixins\fI object\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a list of all classes that have been mixed into the
|
||||
object named \fIobject\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object namespace\fI object\fR
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns the name of the internal namespace of the object named
|
||||
\fIobject\fR.
|
||||
.VE 8.6
|
||||
.TP
|
||||
\fBinfo object variables\fI object\fR
|
||||
.VS 8.6
|
||||
\fBinfo object variables\fI object\fRR ?\fB\-private\fR?
|
||||
.
|
||||
This subcommand returns a list of all variables that have been declared for
|
||||
the object named \fIobject\fR (i.e. that are automatically present in the
|
||||
object's methods).
|
||||
.VE 8.6
|
||||
.VS TIP500
|
||||
If the \fB\-private\fR option is specified, this lists the private variables
|
||||
declared instead.
|
||||
.VE TIP500
|
||||
.TP
|
||||
\fBinfo object vars\fI object\fR ?\fIpattern\fR?
|
||||
.VS 8.6
|
||||
.
|
||||
This subcommand returns a list of all variables in the private namespace of
|
||||
the object named \fIobject\fR. If the optional \fIpattern\fR argument is
|
||||
given, it is a filter (in the syntax of a \fBstring match\fR glob pattern)
|
||||
@@ -680,7 +773,6 @@ from the list returned by \fBinfo object variables\fR; that can include
|
||||
variables that are currently unset, whereas this can include variables that
|
||||
are not automatically included by any of \fIobject\fR's methods (or those of
|
||||
its class, superclasses or mixins).
|
||||
.VE 8.6
|
||||
.SH EXAMPLES
|
||||
.PP
|
||||
This command prints out a procedure suitable for saving in a Tcl
|
||||
@@ -703,7 +795,6 @@ proc printProc {procName} {
|
||||
}
|
||||
.CE
|
||||
.SS "EXAMPLES WITH OBJECTS"
|
||||
.VS 8.6
|
||||
.PP
|
||||
Every object necessarily knows what its class is; this information is
|
||||
trivially extractable through introspection:
|
||||
@@ -724,8 +815,10 @@ method and get how it is defined. This procedure illustrates how:
|
||||
proc getDef {obj method} {
|
||||
foreach inf [\fBinfo object call\fR $obj $method] {
|
||||
lassign $inf calltype name locus methodtype
|
||||
|
||||
# Assume no forwards or filters, and hence no $calltype
|
||||
# or $methodtype checks...
|
||||
|
||||
if {$locus eq "object"} {
|
||||
return [\fBinfo object definition\fR $obj $name]
|
||||
} else {
|
||||
@@ -748,7 +841,9 @@ proc getDef {obj method} {
|
||||
# Assume no forwards
|
||||
return [\fBinfo object definition\fR $obj $method]
|
||||
}
|
||||
|
||||
set cls [\fBinfo object class\fR $obj]
|
||||
|
||||
while {$method ni [\fBinfo class methods\fR $cls]} {
|
||||
# Assume the simple case
|
||||
set cls [lindex [\fBinfo class superclass\fR $cls] 0]
|
||||
@@ -756,22 +851,17 @@ proc getDef {obj method} {
|
||||
error "no definition for $method"
|
||||
}
|
||||
}
|
||||
|
||||
# Assume no forwards
|
||||
return [\fBinfo class definition\fR $cls $method]
|
||||
}
|
||||
.CE
|
||||
.VE 8.6
|
||||
.SH "SEE ALSO"
|
||||
.VS 8.6
|
||||
global(n), oo::class(n), oo::define(n), oo::object(n), proc(n), self(n),
|
||||
.VE 8.6
|
||||
tcl_library(n), tcl_patchLevel(n), tcl_version(n)
|
||||
.SH KEYWORDS
|
||||
command, information, interpreter, introspection, level, namespace,
|
||||
.VS 8.6
|
||||
object,
|
||||
.VE 8.6
|
||||
procedure, variable
|
||||
object, procedure, variable
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
|
||||
+1
-1
@@ -236,7 +236,7 @@ attempts are silently ignored. This is needed to maintain the
|
||||
consistency of the underlying interpreter's state.
|
||||
.RE
|
||||
.TP
|
||||
\fBinterp\fR \fBdelete \fR?\fIpath ...?\fR
|
||||
\fBinterp\fR \fBdelete \fR?\fIpath ...\fR?
|
||||
.
|
||||
Deletes zero or more interpreters given by the optional \fIpath\fR
|
||||
arguments, and for each interpreter, it also deletes its slaves. The
|
||||
|
||||
@@ -42,3 +42,7 @@ set data {1 {2 3} 4 {5 {6 7} 8}}
|
||||
list(n), lappend(n), split(n)
|
||||
.SH KEYWORDS
|
||||
element, join, list, separator
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -22,6 +22,12 @@ and appends each of the \fIvalue\fR arguments to that list as a separate
|
||||
element, with spaces between elements.
|
||||
If \fIvarName\fR does not exist, it is created as a list with elements
|
||||
given by the \fIvalue\fR arguments.
|
||||
.VS TIP508
|
||||
If \fIvarName\fR indicate an element that does not exist of an array that has
|
||||
a default value set, list that is comprised of the default value with all the
|
||||
\fIvalue\fR arguments appended as elements will be stored in the array
|
||||
element.
|
||||
.VE TIP508
|
||||
\fBLappend\fR is similar to \fBappend\fR except that the \fIvalue\fRs
|
||||
are appended as list elements rather than raw text.
|
||||
This command provides a relatively efficient way to build up
|
||||
@@ -47,3 +53,7 @@ list(n), lindex(n), linsert(n), llength(n), lset(n),
|
||||
lsort(n), lrange(n)
|
||||
.SH KEYWORDS
|
||||
append, element, list, variable
|
||||
.\" Local variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
.SH NAME
|
||||
lindex \- Retrieve an element from a list
|
||||
.SH SYNOPSIS
|
||||
\fBlindex \fIlist ?index ...?\fR
|
||||
\fBlindex \fIlist\fR ?\fIindex ...\fR?
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2011-2015 Andreas Kupries
|
||||
'\" Copyright (c) 2018 Donal K. Fellows
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH link n 0.3 TclOO "TclOO Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
link \- create link from command to method of object
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
package require TclOO
|
||||
|
||||
\fBlink\fR \fImethodName\fR ?\fI...\fR?
|
||||
\fBlink\fR \fB{\fIcommandName methodName\fB}\fR ?\fI...\fR?
|
||||
.fi
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
The \fBlink\fR command is available within methods. It takes a series of one
|
||||
or more method names (\fImethodName ...\fR) and/or pairs of command- and
|
||||
method-name (\fB{\fIcommandName methodName\fB}\fR) and makes the named methods
|
||||
available as commands without requiring the explicit use of the name of the
|
||||
object or the \fBmy\fR command. The method does not need to exist at the time
|
||||
that the link is made; if the link command is invoked when the method does not
|
||||
exist, the standard \fBunknown\fR method handling system is used.
|
||||
.PP
|
||||
The command name under which the method becomes available defaults to the
|
||||
method name, except where explicitly specified through an alias/method pair.
|
||||
Formally, every argument must be a list; if the list has two elements, the
|
||||
first element is the name of the command to create and the second element is
|
||||
the name of the method of the current object to which the command links;
|
||||
otherwise, the name of the command and the name of the method are the same
|
||||
string (the first element of the list).
|
||||
.PP
|
||||
If the name of the command is not a fully-qualified command name, it will be
|
||||
resolved with respect to the current namespace (i.e., the object namespace).
|
||||
.SH EXAMPLES
|
||||
This demonstrates linking a single method in various ways. First it makes a
|
||||
simple link, then a renamed link, then an external link. Note that the method
|
||||
itself is unexported, but that it can still be called directly from outside
|
||||
the class.
|
||||
.PP
|
||||
.CS
|
||||
oo::class create ABC {
|
||||
method Foo {} {
|
||||
puts "This is Foo in [self]"
|
||||
}
|
||||
|
||||
constructor {} {
|
||||
\fBlink\fR Foo
|
||||
# The method foo is now directly accessible as foo here
|
||||
\fBlink\fR {bar Foo}
|
||||
# The method foo is now directly accessible as bar
|
||||
\fBlink\fR {::ExternalCall Foo}
|
||||
# The method foo is now directly accessible in the global
|
||||
# namespace as ExternalCall
|
||||
}
|
||||
|
||||
method grill {} {
|
||||
puts "Step 1:"
|
||||
Foo
|
||||
puts "Step 2:"
|
||||
bar
|
||||
}
|
||||
}
|
||||
|
||||
ABC create abc
|
||||
abc grill
|
||||
\fI\(-> Step 1:\fR
|
||||
\fI\(-> This is foo in ::abc\fR
|
||||
\fI\(-> Step 2:\fR
|
||||
\fI\(-> This is foo in ::abc\fR
|
||||
# Direct access via the linked command
|
||||
puts "Step 3:"; ExternalCall
|
||||
\fI\(-> Step 3:\fR
|
||||
\fI\(-> This is foo in ::abc\fR
|
||||
.CE
|
||||
.PP
|
||||
This example shows that multiple linked commands can be made in a call to
|
||||
\fBlink\fR, and that they can handle arguments.
|
||||
.PP
|
||||
.CS
|
||||
oo::class create Ex {
|
||||
constructor {} {
|
||||
\fBlink\fR a b c
|
||||
# The methods a, b, and c (defined below) are all now
|
||||
# directly acessible within methods under their own names.
|
||||
}
|
||||
|
||||
method a {} {
|
||||
puts "This is a"
|
||||
}
|
||||
method b {x} {
|
||||
puts "This is b($x)"
|
||||
}
|
||||
method c {y z} {
|
||||
puts "This is c($y,$z)"
|
||||
}
|
||||
|
||||
method call {p q r} {
|
||||
a
|
||||
b $p
|
||||
c $q $r
|
||||
}
|
||||
}
|
||||
|
||||
set o [Ex new]
|
||||
$o 3 5 7
|
||||
\fI\(-> This is a\fR
|
||||
\fI\(-> This is b(3)\fR
|
||||
\fI\(-> This is c(5,7)\fR
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
interp(n), my(n), oo::class(n), oo::define(n)
|
||||
.SH KEYWORDS
|
||||
command, method, object
|
||||
.\" Local Variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
@@ -53,3 +53,7 @@ list(n), lappend(n), lindex(n), linsert(n), lsearch(n),
|
||||
lset(n), lsort(n), lrange(n), lreplace(n)
|
||||
.SH KEYWORDS
|
||||
element, list, length
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -76,3 +76,7 @@ lset(n), lreplace(n), lsort(n),
|
||||
string(n)
|
||||
.SH KEYWORDS
|
||||
element, list, range, sublist
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+4
-1
@@ -33,6 +33,9 @@ is identical to \fBlist element ...\fR.
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
list(n), lappend(n), linsert(n), llength(n), lset(n)
|
||||
|
||||
.SH KEYWORDS
|
||||
element, index, list
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+30
-10
@@ -17,7 +17,7 @@ lreplace \- Replace elements in a list with new elements
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
\fBlreplace\fR returns a new list formed by replacing one or more elements of
|
||||
\fBlreplace\fR returns a new list formed by replacing zero or more elements of
|
||||
\fIlist\fR with the \fIelement\fR arguments.
|
||||
\fIfirst\fR and \fIlast\fR are index values specifying the first and
|
||||
last elements of the range to replace.
|
||||
@@ -27,23 +27,26 @@ supporting simple index arithmetic and indices relative to the
|
||||
end of the list.
|
||||
0 refers to the first element of the
|
||||
list, and \fBend\fR refers to the last element of the list.
|
||||
If \fIlist\fR is empty, then \fIfirst\fR and \fIlast\fR are ignored.
|
||||
.PP
|
||||
If \fIfirst\fR is less than zero, it is considered to refer to before the
|
||||
first element of the list. For non-empty lists, the element indicated
|
||||
by \fIfirst\fR must exist or \fIfirst\fR must indicate before the
|
||||
start of the list.
|
||||
If either \fIfirst\fR or \fIlast\fR is less than zero, it is considered
|
||||
to refer to before the first element of the list. This allows \fBlreplace\fR
|
||||
to prepend elements to \fIlist\fR.
|
||||
.VS TIP505
|
||||
If either \fIfirst\fR or \fIlast\fR indicates a position greater than the
|
||||
index of the last element of the list, it is treated as if it is an
|
||||
index one greater than the last element. This allows \fBlreplace\fR to
|
||||
append elements to \fIlist\fR.
|
||||
.VE TIP505
|
||||
.PP
|
||||
If \fIlast\fR is less than \fIfirst\fR, then any specified elements
|
||||
will be inserted into the list before the point specified by \fIfirst\fR
|
||||
will be inserted into the list before the element specified by \fIfirst\fR
|
||||
with no elements being deleted.
|
||||
.PP
|
||||
The \fIelement\fR arguments specify zero or more new arguments to
|
||||
The \fIelement\fR arguments specify zero or more new elements to
|
||||
be added to the list in place of those that were deleted.
|
||||
Each \fIelement\fR argument will become a separate element of
|
||||
the list. If no \fIelement\fR arguments are specified, then the elements
|
||||
between \fIfirst\fR and \fIlast\fR are simply deleted. If \fIlist\fR
|
||||
is empty, any \fIelement\fR arguments are added to the end of the list.
|
||||
between \fIfirst\fR and \fIlast\fR are simply deleted.
|
||||
.SH EXAMPLES
|
||||
.PP
|
||||
Replacing an element of a list with another:
|
||||
@@ -78,9 +81,26 @@ proc lremove {listVariable value} {
|
||||
set var [\fBlreplace\fR $var $idx $idx]
|
||||
}
|
||||
.CE
|
||||
.PP
|
||||
.VS TIP505
|
||||
Appending elements to the list; note that \fBend+2\fR will initially
|
||||
be treated as if it is \fB6\fR here, but both that and \fB12345\fR are greater
|
||||
than the index of the final item so they behave identically:
|
||||
.PP
|
||||
.CS
|
||||
% set var {a b c d e}
|
||||
a b c d e
|
||||
% set var [\fBlreplace\fR $var 12345 end+2 f g h i]
|
||||
a b c d e f g h i
|
||||
.CE
|
||||
.VE TIP505
|
||||
.SH "SEE ALSO"
|
||||
list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n),
|
||||
lset(n), lrange(n), lsort(n),
|
||||
string(n)
|
||||
.SH KEYWORDS
|
||||
element, list, replace
|
||||
.\" Local variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
|
||||
@@ -9,25 +9,45 @@
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
my \- invoke any method of current object
|
||||
my, myclass \- invoke any method of current object or its class
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
package require TclOO
|
||||
|
||||
\fBmy\fI methodName\fR ?\fIarg ...\fR?
|
||||
\fBmyclass\fI methodName\fR ?\fIarg ...\fR?
|
||||
.fi
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
The \fBmy\fR command is used to allow methods of objects to invoke any method
|
||||
of the object (or its class). In particular, the set of valid values for
|
||||
The \fBmy\fR command is used to allow methods of objects to invoke methods
|
||||
of the object (or its class),
|
||||
.VS TIP478
|
||||
and he \fBmyclass\fR command is used to allow methods of objects to invoke
|
||||
methods of the current class of the object \fIas an object\fR.
|
||||
.VE TIP478
|
||||
In particular, the set of valid values for
|
||||
\fImethodName\fR is the set of all methods supported by an object and its
|
||||
superclasses, including those that are not exported. The object upon which the
|
||||
method is invoked is always the one that is the current context of the method
|
||||
(i.e. the object that is returned by \fBself object\fR) from which the
|
||||
\fBmy\fR command is invoked.
|
||||
superclasses, including those that are not exported
|
||||
.VS TIP500
|
||||
and private methods of the object or class when used within another method
|
||||
defined by that object or class.
|
||||
.VE TIP500
|
||||
.PP
|
||||
Each object has its own \fBmy\fR command, contained in its instance namespace.
|
||||
The object upon which the method is invoked via \fBmy\fR is the one that owns
|
||||
the namespace that the \fBmy\fR command is contained in initially (\fBNB:\fR the link
|
||||
remains if the command is renamed), which is the currently invoked object by
|
||||
default.
|
||||
.VS TIP478
|
||||
Similarly, the object on which the method is invoked via \fBmyclass\fR is the
|
||||
object that is the current class of the object that owns the namespace that
|
||||
the \fBmyclass\fR command is contained in initially. As with \fBmy\fR, the
|
||||
link remains even if the command is renamed into another namespace, and
|
||||
defaults to being the manufacturing class of the current object.
|
||||
.VE TIP478
|
||||
.PP
|
||||
Each object has its own \fBmy\fR and \fBmyclass\fR commands, contained in its
|
||||
instance namespace.
|
||||
.SH EXAMPLES
|
||||
.PP
|
||||
This example shows basic use of \fBmy\fR to use the \fBvariables\fR method of
|
||||
@@ -40,16 +60,71 @@ oo::class create c {
|
||||
puts [incr counter]
|
||||
}
|
||||
}
|
||||
|
||||
c create o
|
||||
o count \fI\(-> prints "1"\fR
|
||||
o count \fI\(-> prints "2"\fR
|
||||
o count \fI\(-> prints "3"\fR
|
||||
.CE
|
||||
.PP
|
||||
This example shows how you can use \fBmy\fR to make callbacks to private
|
||||
methods from outside the object (from a \fBtrace\fR), using
|
||||
\fBnamespace code\fR to enter the correct context. (See the \fBcallback\fR
|
||||
command for the recommended way of doing this.)
|
||||
.PP
|
||||
.CS
|
||||
oo::class create HasCallback {
|
||||
method makeCallback {} {
|
||||
return [namespace code {
|
||||
\fBmy\fR Callback
|
||||
}]
|
||||
}
|
||||
|
||||
method Callback {args} {
|
||||
puts "callback: $args"
|
||||
}
|
||||
}
|
||||
|
||||
set o [HasCallback new]
|
||||
trace add variable xyz write [$o makeCallback]
|
||||
set xyz "called" \fI\(-> prints "callback: xyz {} write"\fR
|
||||
.CE
|
||||
.PP
|
||||
.VS TIP478
|
||||
This example shows how to access a private method of a class from an instance
|
||||
of that class. (See the \fBclassmethod\fR declaration in \fBoo::define\fR for
|
||||
a higher level interface for doing this.)
|
||||
.PP
|
||||
.CS
|
||||
oo::class create CountedSteps {
|
||||
self {
|
||||
variable count
|
||||
method Count {} {
|
||||
return [incr count]
|
||||
}
|
||||
}
|
||||
method advanceTwice {} {
|
||||
puts "in [self] step A: [\fBmyclass\fR Count]"
|
||||
puts "in [self] step B: [\fBmyclass\fR Count]"
|
||||
}
|
||||
}
|
||||
|
||||
CountedSteps create x
|
||||
CountedSteps create y
|
||||
x advanceTwice \fI\(-> prints "in ::x step A: 1"\fR
|
||||
\fI\(-> prints "in ::x step B: 2"\fR
|
||||
y advanceTwice \fI\(-> prints "in ::y step A: 3"\fR
|
||||
\fI\(-> prints "in ::y step B: 4"\fR
|
||||
x advanceTwice \fI\(-> prints "in ::x step A: 5"\fR
|
||||
\fI\(-> prints "in ::x step B: 6"\fR
|
||||
y advanceTwice \fI\(-> prints "in ::y step A: 7"\fR
|
||||
\fI\(-> prints "in ::y step B: 8"\fR
|
||||
.CE
|
||||
.VE TIP478
|
||||
.SH "SEE ALSO"
|
||||
next(n), oo::object(n), self(n)
|
||||
.SH KEYWORDS
|
||||
method, method visibility, object, private method, public method
|
||||
|
||||
.\" Local variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
|
||||
@@ -112,6 +112,7 @@ oo::class create theSuperclass {
|
||||
puts "in the superclass, args = $args"
|
||||
}
|
||||
}
|
||||
|
||||
oo::class create theSubclass {
|
||||
superclass theSuperclass
|
||||
method example {args} {
|
||||
@@ -121,6 +122,7 @@ oo::class create theSubclass {
|
||||
puts "after chaining from subclass"
|
||||
}
|
||||
}
|
||||
|
||||
theSubclass create obj
|
||||
oo::objdefine obj method example args {
|
||||
puts "per-object method, args = $args"
|
||||
@@ -167,6 +169,7 @@ oo::class create cache {
|
||||
\fI# Compute value, insert into cache, and return it\fR
|
||||
return [set ValueCache($key) [\fBnext\fR {*}$args]]
|
||||
}
|
||||
|
||||
method flushCache {} {
|
||||
my variable ValueCache
|
||||
unset ValueCache
|
||||
@@ -178,10 +181,12 @@ oo::class create cache {
|
||||
oo::object create demo
|
||||
oo::objdefine demo {
|
||||
mixin cache
|
||||
|
||||
method compute {a b c} {
|
||||
after 3000 \fI;# Simulate deep thought\fR
|
||||
return [expr {$a + $b * $c}]
|
||||
}
|
||||
|
||||
method compute2 {a b c} {
|
||||
after 3000 \fI;# Simulate deep thought\fR
|
||||
return [expr {$a * $b + $c}]
|
||||
|
||||
@@ -48,3 +48,7 @@ At least one \fB\-load\fR or \fB\-source\fR parameter must be given.
|
||||
package(n)
|
||||
.SH KEYWORDS
|
||||
auto-load, index, package, version
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -43,6 +43,9 @@ close $pipeline
|
||||
|
||||
.SH "SEE ALSO"
|
||||
exec(n), open(n)
|
||||
|
||||
.SH KEYWORDS
|
||||
file, pipeline, process identifier
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
platform \- System identification support code and utilities
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fBpackage require platform ?1.0.10?\fR
|
||||
\fBpackage require platform\fR ?\fB1.0.10\fR?
|
||||
.sp
|
||||
\fBplatform::generic\fR
|
||||
\fBplatform::identify\fR
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
platform::shell \- System identification support code and utilities
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fBpackage require platform::shell ?1.1.4?\fR
|
||||
\fBpackage require platform::shell\fR ?\fB1.1.4\fR?
|
||||
.sp
|
||||
\fBplatform::shell::generic \fIshell\fR
|
||||
\fBplatform::shell::identify \fIshell\fR
|
||||
@@ -55,3 +55,7 @@ This command returns the contents of \fBtcl_platform(platform)\fR for
|
||||
the specified Tcl shell.
|
||||
.SH KEYWORDS
|
||||
operating system, cpu architecture, platform, architecture
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+6
-6
@@ -12,9 +12,9 @@
|
||||
tcl::prefix \- facilities for prefix matching
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fB::tcl::prefix all\fR \fItable\fR \fIstring\fR
|
||||
\fB::tcl::prefix longest\fR \fItable\fR \fIstring\fR
|
||||
\fB::tcl::prefix match\fR \fI?option ...?\fR \fItable\fR \fIstring\fR
|
||||
\fB::tcl::prefix all\fR \fItable string\fR
|
||||
\fB::tcl::prefix longest\fR \fItable string\fR
|
||||
\fB::tcl::prefix match\fR ?\fIoption ...\fR? \fItable string\fR
|
||||
.fi
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
@@ -22,17 +22,17 @@ tcl::prefix \- facilities for prefix matching
|
||||
This document describes commands looking up a prefix in a list of strings.
|
||||
The following commands are supported:
|
||||
.TP
|
||||
\fB::tcl::prefix all\fR \fItable\fR \fIstring\fR
|
||||
\fB::tcl::prefix all\fR \fItable string\fR
|
||||
.
|
||||
Returns a list of all elements in \fItable\fR that begin with the prefix
|
||||
\fIstring\fR.
|
||||
.TP
|
||||
\fB::tcl::prefix longest\fR \fItable\fR \fIstring\fR
|
||||
\fB::tcl::prefix longest\fR \fItable string\fR
|
||||
.
|
||||
Returns the longest common prefix of all elements in \fItable\fR that
|
||||
begin with the prefix \fIstring\fR.
|
||||
.TP
|
||||
\fB::tcl::prefix match\fR ?\fIoptions\fR? \fItable\fR \fIstring\fR
|
||||
\fB::tcl::prefix match\fR ?\fIoptions\fR? \fItable string\fR
|
||||
.
|
||||
If \fIstring\fR equals one element in \fItable\fR or is a prefix to exactly
|
||||
one element, the matched element is returned. If not, the result depends
|
||||
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2017 Frederic Bonnet.
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH process n 8.7 Tcl "Tcl Built-In Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
tcl::process \- Subprocess management
|
||||
.SH SYNOPSIS
|
||||
\fB::tcl::process \fIoption \fR?\fIarg arg ...\fR?
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
This command provides a way to manage subprocesses created by the \fBopen\fR
|
||||
and \fBexec\fR commands, as identified by the process identifiers (PIDs) of
|
||||
those subprocesses. The legal \fIoptions\fR (which may be abbreviated) are:
|
||||
.TP
|
||||
\fB::tcl::process autopurge\fR ?\fIflag\fR?
|
||||
.
|
||||
Automatic purge facility. If \fIflag\fR is specified as a boolean value then
|
||||
it activates or deactivate autopurge. In all cases it returns the current
|
||||
status as a boolean value. When autopurge is active,
|
||||
\fBTcl_ReapDetachedProcs\fR is called each time the \fBexec\fR command is
|
||||
executed or a pipe channel created by \fBopen\fR is closed. When autopurge is
|
||||
inactive, \fB::tcl::process\fR purge must be called explicitly. By default
|
||||
autopurge is active.
|
||||
.TP
|
||||
\fB::tcl::process list\fR
|
||||
.
|
||||
Returns the list of subprocess PIDs. This includes all currently executing
|
||||
subprocesses and all terminated subprocesses that have not yet had their
|
||||
corresponding process table entries purged.
|
||||
.TP
|
||||
\fB::tcl::process purge\fR ?\fIpids\fR?
|
||||
.
|
||||
Cleans up all data associated with terminated subprocesses. If \fIpids\fR is
|
||||
specified as a list of PIDs then the command only cleanup data for the matching
|
||||
subprocesses if they exist, and raises an error otherwise. If a process listed is
|
||||
still active, this command does nothing to that process.
|
||||
.TP
|
||||
\fB::tcl::process status\fR ?\fIswitches\fR? ?\fIpids\fR?
|
||||
.
|
||||
Returns a dictionary mapping subprocess PIDs to their respective status. If
|
||||
\fIpids\fR is specified as a list of PIDs then the command only returns the
|
||||
status of the matching subprocesses if they exist, and raises an error
|
||||
otherwise. For active processes, the status is an empty value. For terminated
|
||||
processes, the status is a list with the following format:
|
||||
.QW "\fB{\fIcode\fR ?\fImsg errorCode\fR?\fB}\fR" ,
|
||||
where:
|
||||
.RS
|
||||
.TP
|
||||
\fIcode\fR\0
|
||||
.
|
||||
is a standard Tcl return code, i.e., \fB0\fR for TCL_OK and \fB1\fR
|
||||
for TCL_ERROR,
|
||||
.TP
|
||||
\fImsg\fR\0
|
||||
.
|
||||
is the human-readable error message,
|
||||
.TP
|
||||
\fIerrorCode\fR\0
|
||||
.
|
||||
uses the same format as the \fBerrorCode\fR global variable
|
||||
.PP
|
||||
Note that \fBmsg\fR and \fBerrorCode\fR are only present for abnormally
|
||||
terminated processes (i.e. those where the \fIcode\fR is nonzero). Under the
|
||||
hood this command calls \fBTcl_WaitPid\fR with the \fBWNOHANG\fR flag set for
|
||||
non-blocking behavior, unless the \fB\-wait\fR switch is set (see below).
|
||||
.PP
|
||||
Additionally, \fB::tcl::process status\fR accepts the following switches:
|
||||
.TP
|
||||
\fB\-wait\fR\0
|
||||
.
|
||||
By default the command returns immediately (the underlying \fBTcl_WaitPid\fR is
|
||||
called with the \fBWNOHANG\fR flag set) unless this switch is set. If \fIpids\fR
|
||||
is specified as a list of PIDs then the command waits until the status of the
|
||||
matching subprocesses are available. If \fIpids\fR was not specified, this
|
||||
command will wait for all known subprocesses.
|
||||
.TP
|
||||
\fB\-\|\-\fR
|
||||
.
|
||||
Marks the end of switches. The argument following this one will
|
||||
be treated as the first \fIarg\fR even if it starts with a \fB\-\fR.
|
||||
.RE
|
||||
.SH "EXAMPLES"
|
||||
.PP
|
||||
These show the use of \fB::tcl::process\fR. Some of the results from
|
||||
\fB::tcl::process status\fR are split over multiple lines for readability.
|
||||
.PP
|
||||
.CS
|
||||
\fB::tcl::process autopurge\fR
|
||||
\fI\(-> true\fR
|
||||
\fB::tcl::process autopurge\fR false
|
||||
\fI\(-> false\fR
|
||||
|
||||
set pid1 [exec command1 a b c | command2 d e f &]
|
||||
\fI\(-> 123 456\fR
|
||||
set chan [open "|command1 a b c | command2 d e f"]
|
||||
\fI\(-> file123\fR
|
||||
set pid2 [pid $chan]
|
||||
\fI\(-> 789 1011\fR
|
||||
|
||||
\fB::tcl::process list\fR
|
||||
\fI\(-> 123 456 789 1011\fR
|
||||
|
||||
\fB::tcl::process status\fR
|
||||
\fI\(-> 123 0
|
||||
456 {1 "child killed: write on pipe with no readers" {
|
||||
CHILDKILLED 456 SIGPIPE "write on pipe with no readers"}}
|
||||
789 {1 "child suspended: background tty read" {
|
||||
CHILDSUSP 789 SIGTTIN "background tty read"}}
|
||||
1011 {}\fR
|
||||
|
||||
\fB::tcl::process status\fR 123
|
||||
\fI\(-> 123 0\fR
|
||||
|
||||
\fB::tcl::process status\fR 1011
|
||||
\fI\(-> 1011 {}\fR
|
||||
|
||||
\fB::tcl::process status\fR -wait
|
||||
\fI\(-> 123 0
|
||||
456 {1 "child killed: write on pipe with no readers" {
|
||||
CHILDKILLED 456 SIGPIPE "write on pipe with no readers"}}
|
||||
789 {1 "child suspended: background tty read" {
|
||||
CHILDSUSP 789 SIGTTIN "background tty read"}}
|
||||
1011 {1 "child process exited abnormally" {
|
||||
CHILDSTATUS 1011 -1}}\fR
|
||||
|
||||
\fB::tcl::process status\fR 1011
|
||||
\fI\(-> 1011 {1 "child process exited abnormally" {
|
||||
CHILDSTATUS 1011 -1}}\fR
|
||||
|
||||
\fB::tcl::process purge\fR
|
||||
exec command1 1 2 3 &
|
||||
\fI\(-> 1213\fR
|
||||
\fB::tcl::process list\fR
|
||||
\fI\(-> 1213\fR
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
exec(n), open(n), pid(n),
|
||||
Tcl_DetachPids(3), Tcl_WaitPid(3), Tcl_ReapDetachedProcs(3)
|
||||
.SH "KEYWORDS"
|
||||
background, child, detach, process, wait
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" End:
|
||||
@@ -96,3 +96,7 @@ close $chan
|
||||
file(n), fileevent(n), Tcl_StandardChannels(3)
|
||||
.SH KEYWORDS
|
||||
channel, newline, output, write
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -37,3 +37,7 @@ cd $savedDir
|
||||
file(n), cd(n), glob(n), filename(n)
|
||||
.SH KEYWORDS
|
||||
working directory
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -43,3 +43,7 @@ proc ::source args {
|
||||
namespace(n), proc(n)
|
||||
.SH KEYWORDS
|
||||
command, delete, namespace, rename
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+6
-1
@@ -32,7 +32,12 @@ implement the current call chain. The first element is the same as would be
|
||||
reported by \fBinfo object\fR \fBcall\fR for the current method (except that this
|
||||
also reports useful values from within constructors and destructors, whose
|
||||
names are reported as \fB<constructor>\fR and \fB<destructor>\fR
|
||||
respectively), and the second element is an index into the first element's
|
||||
respectively,
|
||||
.VS TIP500
|
||||
and for private methods, which are described as being \fBprivate\fR instead of
|
||||
being a \fBmethod\fR),
|
||||
.VE TIP500
|
||||
and the second element is an index into the first element's
|
||||
list that indicates which actual implementation is currently executing (the
|
||||
first implementation to execute is always at index 0).
|
||||
.TP
|
||||
|
||||
@@ -73,3 +73,7 @@ practice instead of doing double-dereferencing):
|
||||
expr(n), global(n), namespace(n), proc(n), trace(n), unset(n), upvar(n), variable(n)
|
||||
.SH KEYWORDS
|
||||
read, write, variable
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2018 Donal K. Fellows
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH singleton n 0.3 TclOO "TclOO Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
oo::singleton \- a class that does only allows one instance of itself
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
package require TclOO
|
||||
|
||||
\fBoo::singleton\fI method \fR?\fIarg ...\fR?
|
||||
.fi
|
||||
.SH "CLASS HIERARCHY"
|
||||
.nf
|
||||
\fBoo::object\fR
|
||||
\(-> \fBoo::class\fR
|
||||
\(-> \fBoo::singleton\fR
|
||||
.fi
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
Singleton classes are classes that only permit at most one instance of
|
||||
themselves to exist. They unexport the \fBcreate\fR and
|
||||
\fBcreateWithNamespace\fR methods entirely, and override the \fBnew\fR method
|
||||
so that it only makes a new instance if there is no existing instance. It is
|
||||
not recommended to inherit from a singleton class; singleton-ness is \fInot\fR
|
||||
inherited. It is not recommended that a singleton class's constructor take any
|
||||
arguments.
|
||||
.PP
|
||||
Instances have their\fB destroy\fR method overridden with a method that always
|
||||
returns an error in order to discourage destruction of the object, but
|
||||
destruction remains possible if strictly necessary (e.g., by destroying the
|
||||
class or using \fBrename\fR to delete it). They also have a (non-exported)
|
||||
\fB<cloned>\fR method defined on them that similarly always returns errors to
|
||||
make attempts to use the singleton instance with \fBoo::copy\fR fail.
|
||||
.SS CONSTRUCTOR
|
||||
The \fBoo::singleton\fR class does not define an explicit constructor; this
|
||||
means that it is effectively the same as the constructor of the
|
||||
\fBoo::class\fR class.
|
||||
.SS DESTRUCTOR
|
||||
The \fBoo::singleton\fR class does not define an explicit destructor;
|
||||
destroying an instance of it is just like destroying an ordinary class (and
|
||||
will destroy the singleton object).
|
||||
.SS "EXPORTED METHODS"
|
||||
.TP
|
||||
\fIcls \fBnew \fR?\fIarg ...\fR?
|
||||
.
|
||||
This returns the current instance of the singleton class, if one exists, and
|
||||
creates a new instance only if there is no existing instance. The additional
|
||||
arguments, \fIarg ...\fR, are only used if a new instance is actually
|
||||
manufactured; that construction is via the \fBoo::class\fR class's \fBnew\fR
|
||||
method.
|
||||
.RS
|
||||
.PP
|
||||
This is an override of the behaviour of a superclass's method with an
|
||||
identical call signature to the superclass's implementation.
|
||||
.RE
|
||||
.SS "NON-EXPORTED METHODS"
|
||||
The \fBoo::singleton\fR class explicitly states that \fBcreate\fR and
|
||||
\fBcreateWithNamespace\fR are unexported; callers should not assume that they
|
||||
have control over either the name or the namespace name of the singleton instance.
|
||||
.SH EXAMPLE
|
||||
.PP
|
||||
This example demonstrates that there is only one instance even though the
|
||||
\fBnew\fR method is called three times.
|
||||
.PP
|
||||
.CS
|
||||
\fBoo::singleton\fR create Highlander {
|
||||
method say {} {
|
||||
puts "there can be only one"
|
||||
}
|
||||
}
|
||||
|
||||
set h1 [Highlander new]
|
||||
set h2 [Highlander new]
|
||||
if {$h1 eq $h2} {
|
||||
puts "equal objects" \fI\(-> prints "equal objects"\fR
|
||||
}
|
||||
set h3 [Highlander new]
|
||||
if {$h1 eq $h3} {
|
||||
puts "equal objects" \fI\(-> prints "equal objects"\fR
|
||||
}
|
||||
.CE
|
||||
.PP
|
||||
Note that the name of the instance of the singleton is not guaranteed to be
|
||||
anything in particular.
|
||||
.SH "SEE ALSO"
|
||||
oo::class(n)
|
||||
.SH KEYWORDS
|
||||
class, metaclass, object, single instance
|
||||
.\" Local variables:
|
||||
.\" mode: nroff
|
||||
.\" fill-column: 78
|
||||
.\" End:
|
||||
@@ -69,3 +69,7 @@ foreach scriptFile {foo.tcl bar.tcl} {
|
||||
file(n), cd(n), encoding(n), info(n)
|
||||
.SH KEYWORDS
|
||||
file, script
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
.SH NAME
|
||||
string \- Manipulate strings
|
||||
.SH SYNOPSIS
|
||||
\fBstring \fIoption arg \fR?\fIarg ...?\fR
|
||||
\fBstring \fIoption arg \fR?\fIarg ...\fR?
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
|
||||
@@ -143,6 +143,15 @@ incomplete commands.
|
||||
.SH "STANDARD CHANNELS"
|
||||
.PP
|
||||
See \fBTcl_StandardChannels\fR for more explanations.
|
||||
.SH ZIPVFS
|
||||
.PP
|
||||
When a zipfile is concatenated to the end of a \fBtclsh\fR, on
|
||||
startup the contents of the zip archive will be mounted as the
|
||||
virtual file system /zvfs. If a top level directory tcl8.6 is
|
||||
present in the zip archive, it will become the directory loaded
|
||||
as env(TCL_LIBRARY). If a file named \fBmain.tcl\fR is present
|
||||
in the top level directory of the zip archive, it will be sourced
|
||||
instead of the shell's normal command line handing.
|
||||
.SH "SEE ALSO"
|
||||
auto_path(n), encoding(n), env(n), fconfigure(n)
|
||||
.SH KEYWORDS
|
||||
|
||||
+12
-2
@@ -8,7 +8,7 @@
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH "tcltest" n 2.3 tcltest "Tcl Bundled Packages"
|
||||
.TH "tcltest" n 2.5 tcltest "Tcl Bundled Packages"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
@@ -16,7 +16,7 @@
|
||||
tcltest \- Test harness support code and utilities
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fBpackage require tcltest\fR ?\fB2.3\fR?
|
||||
\fBpackage require tcltest\fR ?\fB2.5\fR?
|
||||
|
||||
\fBtcltest::test \fIname description\fR ?\fI\-option value ...\fR?
|
||||
\fBtcltest::test \fIname description\fR ?\fIconstraints\fR? \fIbody result\fR
|
||||
@@ -454,6 +454,7 @@ The valid options for \fBtest\fR are summarized:
|
||||
?\fB\-output \fIexpectedOutput\fR?
|
||||
?\fB\-errorOutput \fIexpectedError\fR?
|
||||
?\fB\-returnCodes \fIcodeList\fR?
|
||||
?\fB\-errorCode \fIexpectedErrorCode\fR?
|
||||
?\fB\-match \fImode\fR?
|
||||
.CE
|
||||
.PP
|
||||
@@ -577,6 +578,15 @@ return codes known to \fBreturn\fR, in both numeric and symbolic
|
||||
form, including extended return codes, are acceptable elements in
|
||||
the \fIexpectedCodeList\fR. Default value is
|
||||
.QW "\fBok return\fR" .
|
||||
.TP
|
||||
\fB\-errorCode \fIexpectedErrorCode\fR
|
||||
.
|
||||
The optional \fB\-errorCode\fR attribute supplies \fIexpectedErrorCode\fR,
|
||||
a glob pattern that should match the error code reported from evaluation of the
|
||||
\fB\-body\fR script. If evaluation of the \fB\-body\fR script returns
|
||||
a code not matching \fIexpectedErrorCode\fR, the test fails. Default value is
|
||||
.QW "\fB*\fR" .
|
||||
If \fB\-returnCodes\fR does not include \fBerror\fR it is set to \fBerror\fR.
|
||||
.PP
|
||||
To pass, a test must successfully evaluate its \fB\-setup\fR, \fB\-body\fR,
|
||||
and \fB\-cleanup\fR scripts. The return code of the \fB\-body\fR script and
|
||||
|
||||
@@ -46,3 +46,7 @@ if {[read $chan 6] eq "foobar"} {
|
||||
file(n), open(n), close(n), gets(n), seek(n), Tcl_StandardChannels(3)
|
||||
.SH KEYWORDS
|
||||
access position, channel, seeking
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ trace \- Monitor variable accesses, command usages and command executions
|
||||
This command causes Tcl commands to be executed whenever certain operations are
|
||||
invoked. The legal \fIoption\fRs (which may be abbreviated) are:
|
||||
.TP
|
||||
\fBtrace add \fItype name ops ?args?\fR
|
||||
\fBtrace add \fItype name ops\fR ?\fIargs\fR?
|
||||
.
|
||||
Where \fItype\fR is \fBcommand\fR, \fBexecution\fR, or \fBvariable\fR.
|
||||
.RS
|
||||
.TP
|
||||
|
||||
@@ -89,3 +89,7 @@ proc \fBunknown\fR args {
|
||||
info(n), proc(n), interp(n), library(n), namespace(n)
|
||||
.SH KEYWORDS
|
||||
error, non-existent command, unknown
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
@@ -63,3 +63,7 @@ while {!$done} {
|
||||
after(n), interp(n)
|
||||
.SH KEYWORDS
|
||||
asynchronous I/O, event, flush, handler, idle, update
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+2
-2
@@ -24,9 +24,9 @@ the result of that evaluation.
|
||||
If \fIlevel\fR is an integer then
|
||||
it gives a distance (up the procedure calling stack) to move before
|
||||
executing the command. If \fIlevel\fR consists of \fB#\fR followed by
|
||||
a number then the number gives an absolute level number. If \fIlevel\fR
|
||||
a integer then the level gives an absolute level. If \fIlevel\fR
|
||||
is omitted then it defaults to \fB1\fR. \fILevel\fR cannot be
|
||||
defaulted if the first \fIcommand\fR argument starts with a digit or \fB#\fR.
|
||||
defaulted if the first \fIcommand\fR argument is an integer or starts with \fB#\fR.
|
||||
.PP
|
||||
For example, suppose that procedure \fBa\fR was invoked
|
||||
from top-level, and that it called \fBb\fR, and that \fBb\fR called \fBc\fR.
|
||||
|
||||
@@ -63,3 +63,7 @@ set lineCount 0
|
||||
break(n), continue(n), for(n), foreach(n)
|
||||
.SH KEYWORDS
|
||||
boolean, loop, test, while
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" fill-column: 78
|
||||
'\" End:
|
||||
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2015 Jan Nijtmans <jan.nijtmans@gmail.com>
|
||||
'\" Copyright (c) 2015 Christian Werner <chw@ch-werner.de>
|
||||
'\" Copyright (c) 2017 Sean Woods <yoda@etoyoc.com>
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH Tclzipfs 3 8.7 Tcl "Tcl Library Procedures"
|
||||
.so man.macros
|
||||
.BS
|
||||
.SH NAME
|
||||
TclZipfs_AppHook, Tclzipfs_Mount, TclZipfs_MountBuffer, Tclzipfs_Unmount \- handle ZIP files as Tcl virtual filesystems
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
int
|
||||
\fBTclZipfs_AppHook(\fIargcPtr, argvPtr\fR)
|
||||
.sp
|
||||
int
|
||||
\fBTclzipfs_Mount\fR(\fIinterp, mountpoint, zipname, password\fR)
|
||||
.sp
|
||||
int
|
||||
\fBTclZipfs_MountBuffer\fR(\fIinterp, mountpoint, data, dataLen, copy\fR)
|
||||
.sp
|
||||
int
|
||||
\fBTclzipfs_Unmount\fR(\fIinterp, mountpoint\fR)
|
||||
.fi
|
||||
.SH ARGUMENTS
|
||||
.AS Tcl_Interp *mountpoint in
|
||||
.AP "int" *argcPtr in
|
||||
Pointer to a variable holding the number of command line arguments from
|
||||
\fBmain\fR().
|
||||
.AP "char" ***argvPtr in
|
||||
Pointer to an array of strings containing the command line arguments to
|
||||
\fBmain\fR().
|
||||
.AP Tcl_Interp *interp in
|
||||
Interpreter in which the ZIP file system is mounted. The interpreter's result is
|
||||
modified to hold the result or error message from the script.
|
||||
.AP "const char" *zipname in
|
||||
Name of a ZIP file. Must not be NULL when either mounting or unmounting a ZIP.
|
||||
.AP "const char" *mountpoint in
|
||||
Name of a mount point, which must be a legal Tcl file or directory name. May
|
||||
be NULL to query current mount points.
|
||||
.AP "const char" *password in
|
||||
An (optional) password. Use NULL if no password is wanted to read the file.
|
||||
.AP "unsigned char" *data in
|
||||
A data buffer to mount. The data buffer must hold the contents of a ZIP
|
||||
archive, and must not be NULL.
|
||||
.AP size_t dataLen in
|
||||
The number of bytes in the supplied data buffer argument, \fIdata\fR.
|
||||
.AP int copy in
|
||||
If non-zero, the ZIP archive in the data buffer will be internally copied
|
||||
before mounting, allowing the data buffer to be disposed once
|
||||
\fBTclZipfs_MountBuffer\fR returns. If zero, the caller guarantees that the
|
||||
buffer will be valid to read from for the duration of the mount.
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
\fBTclZipfs_AppHook\fR is a utility function to perform standard application
|
||||
initialization procedures, taking into account available ZIP archives as
|
||||
follows:
|
||||
.IP [1]
|
||||
If the current application has a mountable ZIP archive, that archive is
|
||||
mounted under \fIZIPFS_VOLUME\fB/app\fR as a read-only Tcl virtual file
|
||||
system. \fIZIPFS_VOLUME\fR is usually \fB//zipfs:\fR on all platforms, but
|
||||
\fBzipfs:\fR may also be used on Windows (due to differences in the
|
||||
platform's filename parsing).
|
||||
.IP [2]
|
||||
If a file named \fBmain.tcl\fR is located in the root directory of that file
|
||||
system (i.e., at \fIZIPROOT\fB/app/main.tcl\fR after the ZIP archive is
|
||||
mounted as described above) it is treated as the startup script for the
|
||||
process.
|
||||
.IP [3]
|
||||
If the file \fIZIPROOT\fB/app/tcl_library/init.tcl\fR is present, the
|
||||
\fBtcl_library\fR global variable in the initial Tcl interpreter is set to
|
||||
\fIZIPROOT\fB/app/tcl_library\fR.
|
||||
.IP [4]
|
||||
If the directory \fBtcl_library\fR was not found in the main application
|
||||
mount, the system will then search for it as either a VFS attached to the
|
||||
application dynamic library, or as a zip archive named
|
||||
\fBlibtcl_\fImajor\fB_\fIminor\fB_\fIpatchlevel\fB.zip\fR either in the
|
||||
present working directory or in the standard Tcl install location. (For
|
||||
example, the Tcl 8.7.2 release would be searched for in a file
|
||||
\fBlibtcl_8_7_2.zip\fR.) That archive, if located, is also mounted read-only.
|
||||
.PP
|
||||
On Windows, \fBTclZipfs_AppHook\fR has a slightly different signature, since
|
||||
it uses WCHAR in stead of char. As a result, it requires your application to
|
||||
be compiled with the UNICODE preprocessor symbol defined (e.g., via the
|
||||
\fB-DUNICODE\fR compiler flag).
|
||||
.PP
|
||||
The result of \fBTclZipfs_AppHook\fR is a Tcl result code (e.g., \fBTCL_OK\fR
|
||||
when the function is successful). The function \fImay\fR modify the variables
|
||||
pointed to by \fIargcPtr\fR and \fIargvPtr\fR to remove arguments; the
|
||||
current implementation does not do so, but callers \fIshould not\fR assume
|
||||
that this will be true in the future.
|
||||
.PP
|
||||
\fBTclzipfs_Mount\fR mounts the ZIP archive \fIzipname\fR on the mount point
|
||||
given in \fImountpoint\fR using the optional ZIP password \fIpassword\fR.
|
||||
Errors during that process are reported in the interpreter \fIinterp\fR. If
|
||||
\fImountpoint\fR is a NULL pointer, information on all currently mounted ZIP
|
||||
file systems is written into \fIinterp\fR's result as a sequence of mount
|
||||
points and ZIP file names. The result of this call is a standard Tcl result
|
||||
code.
|
||||
.PP
|
||||
\fBTclzipfs_MountBuffer\fR mounts the ZIP archive in the buffer pointed to by
|
||||
\fIdata\fR on the mount point given in \fImountpoint\fR. The ZIP archive is
|
||||
assumed to be not password protected. Errors during that process are reported
|
||||
in the interpreter \fIinterp\fR. The \fIcopy\fR argument determines whether
|
||||
the buffer is internally copied before mounting or not. The result of this
|
||||
call is a standard Tcl result code.
|
||||
.PP
|
||||
\fBTclzipfs_Unmount\fR undoes the effect of \fBTclzipfs_Mount\fR, i.e., it
|
||||
unmounts the mounted ZIP file system that was mounted from \fIzipname\fR (at
|
||||
\fImountpoint\fR). Errors are reported in the interpreter \fIinterp\fR. The
|
||||
result of this call is a standard Tcl result code.
|
||||
.SH "SEE ALSO"
|
||||
zipfs(n)
|
||||
.SH KEYWORDS
|
||||
compress, filesystem, zip
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2015 Jan Nijtmans <jan.nijtmans@gmail.com>
|
||||
'\" Copyright (c) 2015 Christian Werner <chw@ch-werner.de>
|
||||
'\" Copyright (c) 2015 Sean Woods <yoda@etoyoc.com>
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH zipfs n 1.0 Zipfs "zipfs Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
zipfs \- Mount and work with ZIP files within Tcl
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fBpackage require zipfs \fR?\fB1.0\fR?
|
||||
.sp
|
||||
\fBzipfs canonical\fR ?\fImntpnt\fR? \fIfilename\fR ?\fIZIPFS\fR?
|
||||
\fBzipfs exists\fR \fIfilename\fR
|
||||
\fBzipfs find\fR \fIdirectoryName\fR
|
||||
\fBzipfs info\fR \fIfilename\fR
|
||||
\fBzipfs list\fR ?(\fB\-glob\fR|\fB\-regexp\fR)? ?\fIpattern\fR?
|
||||
\fBzipfs lmkimg\fR \fIoutfile inlist\fR ?\fIpassword infile\fR?
|
||||
\fBzipfs lmkzip\fR \fIoutfile inlist\fR ?\fIpassword\fR?
|
||||
\fBzipfs mkimg\fR \fIoutfile indir\fR ?\fIstrip\fR? ?\fIpassword\fR? ?\fIinfile\fR?
|
||||
\fBzipfs mkkey\fR \fIpassword\fR
|
||||
\fBzipfs mkzip\fR \fIoutfile indir\fR ?\fIstrip\fR? ?\fIpassword\fR?
|
||||
\fBzipfs mount\fR ?\fImountpoint\fR? ?\fIzipfile\fR? ?\fIpassword\fR?
|
||||
\fBzipfs root\fR
|
||||
\fBzipfs unmount\fR \fImountpoint\fR
|
||||
.fi
|
||||
'\" The following subcommand is *UNDOCUMENTED*
|
||||
'\" \fBzipfs mount_data\fR ?\fImountpoint\fR? ?\fIdata\fR?
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
The \fBzipfs\fR command (the sole public command provided by the built-in
|
||||
package with the same name) provides Tcl with the ability to mount the
|
||||
contents of a ZIP archive file as a virtual file system. ZIP archives support
|
||||
simple encryption, sufficient to prevent casual inspection of their contents
|
||||
but not able to prevent access by even a moderately determined attacker.
|
||||
.TP
|
||||
\fBzipfs canonical\fR ?\fImountpoint\fR? \fIfilename\fR ?\fIinZipfs\fR?
|
||||
.
|
||||
This takes the name of a file, \fIfilename\fR, and produces where it would be
|
||||
mapped into a zipfs mount as its result. If specified, \fImountpoint\fR says
|
||||
within which mount the mapping will be done; if omitted, the main root of the
|
||||
zipfs system is used. The \fIinZipfs\fR argument is a an optional boolean
|
||||
which controls whether to fully canonicalise the name; it defaults to true.
|
||||
.TP
|
||||
\fBzipfs exists\fR \fIfilename\fR
|
||||
.
|
||||
Return 1 if the given filename exists in the mounted zipfs and 0 if it does not.
|
||||
.TP
|
||||
\fBzipfs find\fR \fIdirectoryName\fR
|
||||
.
|
||||
Recursively lists files including and below the directory \fIdirectoryName\fR.
|
||||
The result list consists of relative path names starting from the given
|
||||
directory. This command is also used by the \fBzipfs mkzip\fR and \fBzipfs
|
||||
mkimg\fR commands.
|
||||
.TP
|
||||
\fBzipfs info\fR \fIfile\fR
|
||||
.
|
||||
Return information about the given \fIfile\fR in the mounted zipfs. The
|
||||
information consists of:
|
||||
.RS
|
||||
.IP (1)
|
||||
the name of the ZIP archive file that contains the file,
|
||||
.IP (2)
|
||||
the size of the file after decompressions,
|
||||
.IP (3)
|
||||
the compressed size of the file, and
|
||||
.IP (4)
|
||||
the offset of the compressed data in the ZIP archive file.
|
||||
.PP
|
||||
Note: querying the mount point gives the start of the zip data as the offset
|
||||
in (4), which can be used to truncate the zip information from an executable.
|
||||
.RE
|
||||
.TP
|
||||
\fBzipfs list\fR ?(\fB\-glob\fR|\fB\-regexp\fR)? ?\fIpattern\fR?
|
||||
.
|
||||
Return a list of all files in the mounted zipfs, or just those matching
|
||||
\fIpattern\fR (optionally controlled by the option parameters). The order of
|
||||
the names in the list is arbitrary.
|
||||
.TP
|
||||
\fBzipfs mount ?\fImountpoint\fR? ?\fIzipfile\fR? ?\fIpassword\fR?
|
||||
.
|
||||
The \fBzipfs mount\fR command mounts a ZIP archive file as a Tcl virtual
|
||||
filesystem at \fImountpoint\fR. After this command executes, files contained
|
||||
in \fIzipfile\fR will appear to Tcl to be regular files at the mount point.
|
||||
.RS
|
||||
.PP
|
||||
With no \fIzipfile\fR, returns the zipfile mounted at \fImountpoint\fR. With
|
||||
no \fImountpoint\fR, return all zipfile/mount pairs. If \fImountpoint\fR is
|
||||
specified as an empty string, mount on file path.
|
||||
.PP
|
||||
\fBNB:\fR because the current working directory is a concept maintained by the
|
||||
operating system, using \fBcd\fR into a mounted archive will only work in the
|
||||
current process, and then not entirely consistently (e.g., if a shared library
|
||||
uses direct access to the OS rather than through Tcl's filesystem API, it will
|
||||
not see the current directory as being inside the mount and will not be able
|
||||
to access the files inside the mount).
|
||||
.RE
|
||||
.TP
|
||||
\fBzipfs root\fR
|
||||
.
|
||||
Returns a constant string which indicates the mount point for zipfs volumes
|
||||
for the current platform. On Windows, this value is
|
||||
.QW \fBzipfs:/\fR .
|
||||
On Unix, this value is
|
||||
.QW \fB//zipfs:/\fR .
|
||||
.RE
|
||||
.TP
|
||||
\fBzipfs unmount \fImountpoint\fR
|
||||
.
|
||||
Unmounts a previously mounted ZIP archive mounted to \fImountpoint\fR.
|
||||
.SS "ZIP CREATION COMMANDS"
|
||||
This package also provides several commands to aid the creation of ZIP
|
||||
archives as Tcl applications.
|
||||
.TP
|
||||
\fBzipfs mkzip\fR \fIoutfile indir\fR ?\fIstrip\fR? ?\fIpassword\fR?
|
||||
.
|
||||
Creates a ZIP archive file named \fIoutfile\fR from the contents of the input
|
||||
directory \fIindir\fR (contained regular files only) with optional ZIP
|
||||
password \fIpassword\fR. While processing the files below \fIindir\fR the
|
||||
optional file name prefix given in \fIstrip\fR is stripped off the beginning
|
||||
of the respective file name. When stripping, it is common to remove either
|
||||
the whole source directory name or the name of its parent directory.
|
||||
.RS
|
||||
.PP
|
||||
\fBCaution:\fR the choice of the \fIindir\fR parameter (less the optional
|
||||
stripped prefix) determines the later root name of the archive's content.
|
||||
.RE
|
||||
.TP
|
||||
\fBzipfs mkimg\fR \fIoutfile indir\fR ?\fIstrip\fR? ?\fIpassword\fR? ?\fIinfile\fR?
|
||||
.
|
||||
Creates an image (potentially a new executable file) similar to \fBzipfs
|
||||
mkzip\fR; see that command for a description of most parameters to this
|
||||
command, as they behave identically here.
|
||||
.RS
|
||||
.PP
|
||||
If the \fIinfile\fR parameter is specified, this file is prepended in front of
|
||||
the ZIP archive, otherwise the file returned by \fBinfo nameofexecutable\fR
|
||||
(i.e., the executable file of the running process) is used. If the
|
||||
\fIpassword\fR parameter is not empty, an obfuscated version of that password
|
||||
(see \fBzipfs mkkey\fR) is placed between the image and ZIP chunks of the
|
||||
output file and the contents of the ZIP chunk are protected with that
|
||||
password.
|
||||
.PP
|
||||
If there is a file, \fBmain.tcl\fR, in the root directory of the resulting
|
||||
archive and the image file that the archive is attached to is a \fBtclsh\fR
|
||||
(or \fBwish\fR) instance (true by default, but depends on your configuration),
|
||||
then the resulting image is an executable that will \fBsource\fR the script in
|
||||
that \fBmain.tcl\fR after mounting the ZIP archive, and will \fBexit\fR once
|
||||
that script has been executed.
|
||||
.PP
|
||||
\fBCaution:\fR highly experimental, not usable on Android, only partially
|
||||
tested on Linux and Windows.
|
||||
.RE
|
||||
.TP
|
||||
\fBzipfs mkkey\fR \fIpassword\fR
|
||||
.
|
||||
Given the clear text \fIpassword\fR argument, an obfuscated string version is
|
||||
returned with the same format used in the \fBzipfs mkimg\fR command.
|
||||
.TP
|
||||
\fBzipfs lmkimg\fR \fIoutfile inlist\fR ?\fIpassword infile\fR?
|
||||
.
|
||||
This command is like \fBzipfs mkimg\fR, but instead of an input directory,
|
||||
\fIinlist\fR must be a Tcl list where the odd elements are the names of files
|
||||
to be copied into the archive in the image, and the even elements are their
|
||||
respective names within that archive.
|
||||
.TP
|
||||
\fBzipfs lmkzip\fR \fIoutfile inlist\fR ?\fIpassword\fR?
|
||||
.
|
||||
This command is like \fBzipfs mkzip\fR, but instead of an input directory,
|
||||
\fIinlist\fR must be a Tcl list where the odd elements are the names of files
|
||||
to be copied into the archive, and the even elements are their respective
|
||||
names within that archive.
|
||||
.SH "EXAMPLES"
|
||||
.PP
|
||||
Mounting an ZIP archive as an application directory and running code out of it
|
||||
before unmounting it again:
|
||||
.PP
|
||||
.CS
|
||||
set zip myApp.zip
|
||||
set base [file join [\fbzipfs root\fR] myApp]
|
||||
|
||||
\fBzipfs mount\fR $base $zip
|
||||
# $base now has the contents of myApp.zip
|
||||
|
||||
source [file join $base app.tcl]
|
||||
# use the contents, load libraries from it, etc...
|
||||
|
||||
\fBzipfs unmount\fR $zip
|
||||
.CE
|
||||
.PP
|
||||
Creating a ZIP archive, given that a directory exists containing the content
|
||||
to put in the archive. Note that the source directory is given twice, in order
|
||||
to strip the exterior directory name from each filename in the archive.
|
||||
.PP
|
||||
.CS
|
||||
set sourceDirectory [file normalize myApp]
|
||||
set targetZip myApp.zip
|
||||
|
||||
\fBzipfs mkzip\fR $targetZip $sourceDirectory $sourceDirectory
|
||||
.CE
|
||||
.PP
|
||||
Encryption can be applied to ZIP archives by providing a password when
|
||||
building the ZIP and when mounting it.
|
||||
.PP
|
||||
.CS
|
||||
set zip myApp.zip
|
||||
set sourceDir [file normalize myApp]
|
||||
set password "hunter2"
|
||||
set base [file join [\fbzipfs root\fR] myApp]
|
||||
|
||||
# Create with password
|
||||
\fBzipfs mkzip\fR $targetZip $sourceDir $sourceDir $password
|
||||
|
||||
# Mount with password
|
||||
\fBzipfs mount\fR $base $zip $password
|
||||
.CE
|
||||
.PP
|
||||
When creating an executable image with a password, the password is placed
|
||||
within the executable in a shrouded form so that the application can read
|
||||
files inside the embedded ZIP archive yet casual inspection cannot read it.
|
||||
.PP
|
||||
.CS
|
||||
set appDir [file normalize myApp]
|
||||
set img "myApp.bin"
|
||||
set password "hunter2"
|
||||
|
||||
# Create some simple content to define a basic application
|
||||
file mkdir $appDir
|
||||
set f [open $appDir/main.tcl]
|
||||
puts $f {
|
||||
puts "Hi. This is [info script]"
|
||||
}
|
||||
close $f
|
||||
|
||||
# Create the executable
|
||||
\fBzipfs mkimg\fR $img $appDir $appDir $password
|
||||
|
||||
# Launch the executable, printing its output to stdout
|
||||
exec $img >@stdout
|
||||
# prints: \fIHi. This is //zipfs:/app/main.tcl\fR
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
tclsh(1), file(n), zipfs(3), zlib(n)
|
||||
.SH "KEYWORDS"
|
||||
compress, filesystem, zip
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" End:
|
||||
+44
-26
@@ -104,7 +104,7 @@ declare 20 {
|
||||
declare 21 {
|
||||
int Tcl_DbIsShared(Tcl_Obj *objPtr, const char *file, int line)
|
||||
}
|
||||
declare 22 {
|
||||
declare 22 {deprecated {No longer in use, changed to macro}} {
|
||||
Tcl_Obj *Tcl_DbNewBooleanObj(int boolValue, const char *file, int line)
|
||||
}
|
||||
declare 23 {
|
||||
@@ -119,7 +119,7 @@ declare 25 {
|
||||
Tcl_Obj *Tcl_DbNewListObj(int objc, Tcl_Obj *const *objv,
|
||||
const char *file, int line)
|
||||
}
|
||||
declare 26 {
|
||||
declare 26 {deprecated {No longer in use, changed to macro}} {
|
||||
Tcl_Obj *Tcl_DbNewLongObj(long longValue, const char *file, int line)
|
||||
}
|
||||
declare 27 {
|
||||
@@ -152,7 +152,7 @@ declare 35 {
|
||||
int Tcl_GetDoubleFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
|
||||
double *doublePtr)
|
||||
}
|
||||
declare 36 {
|
||||
declare 36 {deprecated {No longer in use, changed to macro}} {
|
||||
int Tcl_GetIndexFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
|
||||
const char *const *tablePtr, const char *msg, int flags, int *indexPtr)
|
||||
}
|
||||
@@ -198,7 +198,7 @@ declare 48 {
|
||||
int Tcl_ListObjReplace(Tcl_Interp *interp, Tcl_Obj *listPtr, int first,
|
||||
int count, int objc, Tcl_Obj *const objv[])
|
||||
}
|
||||
declare 49 {
|
||||
declare 49 {deprecated {No longer in use, changed to macro}} {
|
||||
Tcl_Obj *Tcl_NewBooleanObj(int boolValue)
|
||||
}
|
||||
declare 50 {
|
||||
@@ -207,13 +207,13 @@ declare 50 {
|
||||
declare 51 {
|
||||
Tcl_Obj *Tcl_NewDoubleObj(double doubleValue)
|
||||
}
|
||||
declare 52 {
|
||||
declare 52 {deprecated {No longer in use, changed to macro}} {
|
||||
Tcl_Obj *Tcl_NewIntObj(int intValue)
|
||||
}
|
||||
declare 53 {
|
||||
Tcl_Obj *Tcl_NewListObj(int objc, Tcl_Obj *const objv[])
|
||||
}
|
||||
declare 54 {
|
||||
declare 54 {deprecated {No longer in use, changed to macro}} {
|
||||
Tcl_Obj *Tcl_NewLongObj(long longValue)
|
||||
}
|
||||
declare 55 {
|
||||
@@ -222,7 +222,7 @@ declare 55 {
|
||||
declare 56 {
|
||||
Tcl_Obj *Tcl_NewStringObj(const char *bytes, int length)
|
||||
}
|
||||
declare 57 {
|
||||
declare 57 {deprecated {No longer in use, changed to macro}} {
|
||||
void Tcl_SetBooleanObj(Tcl_Obj *objPtr, int boolValue)
|
||||
}
|
||||
declare 58 {
|
||||
@@ -235,13 +235,13 @@ declare 59 {
|
||||
declare 60 {
|
||||
void Tcl_SetDoubleObj(Tcl_Obj *objPtr, double doubleValue)
|
||||
}
|
||||
declare 61 {
|
||||
declare 61 {deprecated {No longer in use, changed to macro}} {
|
||||
void Tcl_SetIntObj(Tcl_Obj *objPtr, int intValue)
|
||||
}
|
||||
declare 62 {
|
||||
void Tcl_SetListObj(Tcl_Obj *objPtr, int objc, Tcl_Obj *const objv[])
|
||||
}
|
||||
declare 63 {
|
||||
declare 63 {deprecated {No longer in use, changed to macro}} {
|
||||
void Tcl_SetLongObj(Tcl_Obj *objPtr, long longValue)
|
||||
}
|
||||
declare 64 {
|
||||
@@ -250,10 +250,10 @@ declare 64 {
|
||||
declare 65 {
|
||||
void Tcl_SetStringObj(Tcl_Obj *objPtr, const char *bytes, int length)
|
||||
}
|
||||
declare 66 {
|
||||
declare 66 {deprecated {No longer in use, changed to macro}} {
|
||||
void Tcl_AddErrorInfo(Tcl_Interp *interp, const char *message)
|
||||
}
|
||||
declare 67 {
|
||||
declare 67 {deprecated {No longer in use, changed to macro}} {
|
||||
void Tcl_AddObjErrorInfo(Tcl_Interp *interp, const char *message,
|
||||
int length)
|
||||
}
|
||||
@@ -472,7 +472,7 @@ declare 129 {
|
||||
declare 130 {
|
||||
int Tcl_EvalFile(Tcl_Interp *interp, const char *fileName)
|
||||
}
|
||||
declare 131 {
|
||||
declare 131 {deprecated {No longer in use, changed to macro}} {
|
||||
int Tcl_EvalObj(Tcl_Interp *interp, Tcl_Obj *objPtr)
|
||||
}
|
||||
declare 132 {
|
||||
@@ -624,7 +624,7 @@ declare 173 {
|
||||
declare 174 {
|
||||
const char *Tcl_GetStringResult(Tcl_Interp *interp)
|
||||
}
|
||||
declare 175 {
|
||||
declare 175 {deprecated {No longer in use, changed to macro}} {
|
||||
const char *Tcl_GetVar(Tcl_Interp *interp, const char *varName,
|
||||
int flags)
|
||||
}
|
||||
@@ -635,7 +635,7 @@ declare 176 {
|
||||
declare 177 {
|
||||
int Tcl_GlobalEval(Tcl_Interp *interp, const char *command)
|
||||
}
|
||||
declare 178 {
|
||||
declare 178 {deprecated {No longer in use, changed to macro}} {
|
||||
int Tcl_GlobalEvalObj(Tcl_Interp *interp, Tcl_Obj *objPtr)
|
||||
}
|
||||
declare 179 {
|
||||
@@ -834,7 +834,7 @@ declare 235 {
|
||||
declare 236 {
|
||||
void Tcl_SetStdChannel(Tcl_Channel channel, int type)
|
||||
}
|
||||
declare 237 {
|
||||
declare 237 {deprecated {No longer in use, changed to macro}} {
|
||||
const char *Tcl_SetVar(Tcl_Interp *interp, const char *varName,
|
||||
const char *newValue, int flags)
|
||||
}
|
||||
@@ -869,7 +869,7 @@ declare 245 {
|
||||
declare 246 {deprecated {}} {
|
||||
int Tcl_TellOld(Tcl_Channel chan)
|
||||
}
|
||||
declare 247 {
|
||||
declare 247 {deprecated {No longer in use, changed to macro}} {
|
||||
int Tcl_TraceVar(Tcl_Interp *interp, const char *varName, int flags,
|
||||
Tcl_VarTraceProc *proc, ClientData clientData)
|
||||
}
|
||||
@@ -890,14 +890,14 @@ declare 251 {
|
||||
declare 252 {
|
||||
int Tcl_UnregisterChannel(Tcl_Interp *interp, Tcl_Channel chan)
|
||||
}
|
||||
declare 253 {
|
||||
declare 253 {deprecated {No longer in use, changed to macro}} {
|
||||
int Tcl_UnsetVar(Tcl_Interp *interp, const char *varName, int flags)
|
||||
}
|
||||
declare 254 {
|
||||
int Tcl_UnsetVar2(Tcl_Interp *interp, const char *part1, const char *part2,
|
||||
int flags)
|
||||
}
|
||||
declare 255 {
|
||||
declare 255 {deprecated {No longer in use, changed to macro}} {
|
||||
void Tcl_UntraceVar(Tcl_Interp *interp, const char *varName, int flags,
|
||||
Tcl_VarTraceProc *proc, ClientData clientData)
|
||||
}
|
||||
@@ -909,7 +909,7 @@ declare 256 {
|
||||
declare 257 {
|
||||
void Tcl_UpdateLinkedVar(Tcl_Interp *interp, const char *varName)
|
||||
}
|
||||
declare 258 {
|
||||
declare 258 {deprecated {No longer in use, changed to macro}} {
|
||||
int Tcl_UpVar(Tcl_Interp *interp, const char *frameName,
|
||||
const char *varName, const char *localName, int flags)
|
||||
}
|
||||
@@ -920,7 +920,7 @@ declare 259 {
|
||||
declare 260 {
|
||||
int Tcl_VarEval(Tcl_Interp *interp, ...)
|
||||
}
|
||||
declare 261 {
|
||||
declare 261 {deprecated {No longer in use, changed to macro}} {
|
||||
ClientData Tcl_VarTraceInfo(Tcl_Interp *interp, const char *varName,
|
||||
int flags, Tcl_VarTraceProc *procPtr, ClientData prevClientData)
|
||||
}
|
||||
@@ -955,7 +955,7 @@ declare 270 {
|
||||
const char *Tcl_ParseVar(Tcl_Interp *interp, const char *start,
|
||||
const char **termPtr)
|
||||
}
|
||||
declare 271 {
|
||||
declare 271 {deprecated {No longer in use, changed to macro}} {
|
||||
const char *Tcl_PkgPresent(Tcl_Interp *interp, const char *name,
|
||||
const char *version, int exact)
|
||||
}
|
||||
@@ -964,12 +964,12 @@ declare 272 {
|
||||
const char *name, const char *version, int exact,
|
||||
void *clientDataPtr)
|
||||
}
|
||||
declare 273 {
|
||||
declare 273 {deprecated {No longer in use, changed to macro}} {
|
||||
int Tcl_PkgProvide(Tcl_Interp *interp, const char *name,
|
||||
const char *version)
|
||||
}
|
||||
# TIP #268: The internally used new Require function is in slot 573.
|
||||
declare 274 {
|
||||
declare 274 {deprecated {No longer in use, changed to macro}} {
|
||||
const char *Tcl_PkgRequire(Tcl_Interp *interp, const char *name,
|
||||
const char *version, int exact)
|
||||
}
|
||||
@@ -1350,7 +1350,7 @@ declare 380 {
|
||||
declare 381 {
|
||||
int Tcl_GetUniChar(Tcl_Obj *objPtr, int index)
|
||||
}
|
||||
declare 382 {
|
||||
declare 382 {deprecated {No longer in use, changed to macro}} {
|
||||
Tcl_UniChar *Tcl_GetUnicode(Tcl_Obj *objPtr)
|
||||
}
|
||||
declare 383 {
|
||||
@@ -2330,10 +2330,24 @@ declare 631 {
|
||||
ClientData callbackData)
|
||||
}
|
||||
|
||||
# TIP #430
|
||||
declare 632 {
|
||||
int TclZipfs_Mount(Tcl_Interp *interp, const char *mountPoint,
|
||||
const char *zipname, const char *passwd)
|
||||
}
|
||||
declare 633 {
|
||||
int TclZipfs_Unmount(Tcl_Interp *interp, const char *mountPoint)
|
||||
}
|
||||
declare 634 {
|
||||
Tcl_Obj *TclZipfs_TclLibrary(void)
|
||||
}
|
||||
declare 635 {
|
||||
int TclZipfs_MountBuffer(Tcl_Interp *interp, const char *mountPoint,
|
||||
unsigned char *data, size_t datalen, int copy)
|
||||
}
|
||||
|
||||
# ----- BASELINE -- FOR -- 8.7.0 ----- #
|
||||
|
||||
|
||||
|
||||
##############################################################################
|
||||
|
||||
# Define the platform specific public Tcl interface. These functions are only
|
||||
@@ -2378,6 +2392,10 @@ declare 1 macosx {
|
||||
export {
|
||||
void Tcl_Main(int argc, char **argv, Tcl_AppInitProc *appInitProc)
|
||||
}
|
||||
export {
|
||||
void Tcl_MainEx(int argc, char **argv, Tcl_AppInitProc *appInitProc,
|
||||
Tcl_Interp *interp)
|
||||
}
|
||||
export {
|
||||
const char *Tcl_InitStubs(Tcl_Interp *interp, const char *version,
|
||||
int exact)
|
||||
|
||||
+25
-32
@@ -89,6 +89,10 @@ extern "C" {
|
||||
# define JOIN(a,b) JOIN1(a,b)
|
||||
# define JOIN1(a,b) a##b
|
||||
#endif
|
||||
|
||||
#ifndef TCL_THREADS
|
||||
# define TCL_THREADS 1
|
||||
#endif
|
||||
#endif /* !TCL_NO_DEPRECATED */
|
||||
|
||||
/*
|
||||
@@ -103,15 +107,10 @@ extern "C" {
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
/*
|
||||
* Special macro to define mutexes, that doesn't do anything if we are not
|
||||
* using threads.
|
||||
* Special macro to define mutexes.
|
||||
*/
|
||||
|
||||
#ifdef TCL_THREADS
|
||||
#define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name;
|
||||
#else
|
||||
#define TCL_DECLARE_MUTEX(name)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Tcl's public routine Tcl_FSSeek() uses the values SEEK_SET, SEEK_CUR, and
|
||||
@@ -225,7 +224,7 @@ extern "C" {
|
||||
* to be included in a shared library, then it should have the DLLEXPORT
|
||||
* storage class. If is being declared for use by a module that is going to
|
||||
* link against the shared library, then it should have the DLLIMPORT storage
|
||||
* class. If the symbol is beind declared for a static build or for use from a
|
||||
* class. If the symbol is being declared for a static build or for use from a
|
||||
* stub library, then the storage class should be empty.
|
||||
*
|
||||
* The convention is that a macro called BUILD_xxxx, where xxxx is the name of
|
||||
@@ -2146,9 +2145,9 @@ typedef struct Tcl_EncodingType {
|
||||
|
||||
/*
|
||||
* The maximum number of bytes that are necessary to represent a single
|
||||
* Unicode character in UTF-8. The valid values should be 3, 4 or 6
|
||||
* (or perhaps 1 if we want to support a non-unicode enabled core). If 3 or
|
||||
* 4, then Tcl_UniChar must be 2-bytes in size (UCS-2) (the default). If 6,
|
||||
* Unicode character in UTF-8. The valid values are 4 and 6
|
||||
* (or perhaps 1 if we want to support a non-unicode enabled core). If 4,
|
||||
* then Tcl_UniChar must be 2-bytes in size (UCS-2) (the default). If 6,
|
||||
* then Tcl_UniChar must be 4-bytes in size (UCS-4). At this time UCS-2 mode
|
||||
* is the default and recommended mode. UCS-4 is experimental and not
|
||||
* recommended. It works for the core, but most extensions expect UCS-2.
|
||||
@@ -2334,6 +2333,13 @@ typedef int (Tcl_ArgvGenFuncProc)(ClientData clientData, Tcl_Interp *interp,
|
||||
#define TCL_TCPSERVER_REUSEADDR (1<<0)
|
||||
#define TCL_TCPSERVER_REUSEPORT (1<<1)
|
||||
|
||||
/*
|
||||
* Constants for special int-typed values, see TIP #494
|
||||
*/
|
||||
|
||||
#define TCL_IO_FAILURE (-1)
|
||||
#define TCL_AUTO_LENGTH (-1)
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------------
|
||||
* Single public declaration for NRE.
|
||||
@@ -2361,6 +2367,11 @@ const char * Tcl_InitStubs(Tcl_Interp *interp, const char *version,
|
||||
int exact, int magic);
|
||||
const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
|
||||
const char *version, int epoch, int revision);
|
||||
#if defined(_WIN32)
|
||||
TCL_NORETURN void Tcl_ConsolePanic(const char *format, ...);
|
||||
#else
|
||||
# define Tcl_ConsolePanic ((Tcl_PanicProc *)0)
|
||||
#endif
|
||||
|
||||
#ifdef USE_TCL_STUBS
|
||||
#if TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE
|
||||
@@ -2392,12 +2403,15 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
|
||||
*/
|
||||
|
||||
#define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \
|
||||
((Tcl_CreateInterp)()))
|
||||
(((Tcl_SetPanicProc)(Tcl_ConsolePanic), Tcl_CreateInterp)()))
|
||||
EXTERN void Tcl_MainEx(int argc, char **argv,
|
||||
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
|
||||
EXTERN const char * Tcl_PkgInitStubsCheck(Tcl_Interp *interp,
|
||||
const char *version, int exact);
|
||||
EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr);
|
||||
#ifndef _WIN32
|
||||
EXTERN int TclZipfs_AppHook(int *argc, char ***argv);
|
||||
#endif
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------------
|
||||
@@ -2550,27 +2564,6 @@ EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr);
|
||||
#define Tcl_CreateHashEntry(tablePtr, key, newPtr) \
|
||||
(*((tablePtr)->createProc))(tablePtr, (const char *)(key), newPtr)
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------------
|
||||
* Macros that eliminate the overhead of the thread synchronization functions
|
||||
* when compiling without thread support.
|
||||
*/
|
||||
|
||||
#ifndef TCL_THREADS
|
||||
#undef Tcl_MutexLock
|
||||
#define Tcl_MutexLock(mutexPtr)
|
||||
#undef Tcl_MutexUnlock
|
||||
#define Tcl_MutexUnlock(mutexPtr)
|
||||
#undef Tcl_MutexFinalize
|
||||
#define Tcl_MutexFinalize(mutexPtr)
|
||||
#undef Tcl_ConditionNotify
|
||||
#define Tcl_ConditionNotify(condPtr)
|
||||
#undef Tcl_ConditionWait
|
||||
#define Tcl_ConditionWait(condPtr, mutexPtr, timePtr)
|
||||
#undef Tcl_ConditionFinalize
|
||||
#define Tcl_ConditionFinalize(condPtr)
|
||||
#endif /* TCL_THREADS */
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------------
|
||||
* Deprecated Tcl functions:
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "tclInt.h"
|
||||
#if !defined(TCL_THREADS) || !defined(USE_THREAD_ALLOC)
|
||||
#if !TCL_THREADS || !defined(USE_THREAD_ALLOC)
|
||||
|
||||
#if USE_TCLALLOC
|
||||
|
||||
@@ -121,7 +121,7 @@ static struct block bigBlocks={ /* Big blocks aren't suballocated. */
|
||||
* variable.
|
||||
*/
|
||||
|
||||
#ifdef TCL_THREADS
|
||||
#if TCL_THREADS
|
||||
static Tcl_Mutex *allocMutexPtr;
|
||||
#endif
|
||||
static int allocInit = 0;
|
||||
@@ -171,7 +171,7 @@ TclInitAlloc(void)
|
||||
{
|
||||
if (!allocInit) {
|
||||
allocInit = 1;
|
||||
#ifdef TCL_THREADS
|
||||
#if TCL_THREADS
|
||||
allocMutexPtr = Tcl_GetAllocMutex();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2253,7 +2253,7 @@ GetListIndexOperand(
|
||||
if (GetNextOperand(assemEnvPtr, tokenPtrPtr, &value) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* Convert to an integer, advance to the next token and return. */
|
||||
/*
|
||||
* NOTE: Indexing a list with an index before it yields the
|
||||
|
||||
+309
-115
@@ -71,7 +71,18 @@ typedef struct {
|
||||
} CancelInfo;
|
||||
static Tcl_HashTable cancelTable;
|
||||
static int cancelTableInitialized = 0; /* 0 means not yet initialized. */
|
||||
TCL_DECLARE_MUTEX(cancelLock)
|
||||
TCL_DECLARE_MUTEX(cancelLock);
|
||||
|
||||
/*
|
||||
* Table used to map command implementation functions to a human-readable type
|
||||
* name, for [info type]. The keys in the table are function addresses, and
|
||||
* the values in the table are static char* containing strings in Tcl's
|
||||
* internal encoding (almost UTF-8).
|
||||
*/
|
||||
|
||||
static Tcl_HashTable commandTypeTable;
|
||||
static int commandTypeInit = 0;
|
||||
TCL_DECLARE_MUTEX(commandTypeLock);
|
||||
|
||||
/*
|
||||
* Declarations for managing contexts for non-recursive coroutines. Contexts
|
||||
@@ -94,6 +105,7 @@ TCL_DECLARE_MUTEX(cancelLock)
|
||||
* Static functions in this file:
|
||||
*/
|
||||
|
||||
static Tcl_ObjCmdProc BadEnsembleSubcommand;
|
||||
static char * CallCommandTraces(Interp *iPtr, Command *cmdPtr,
|
||||
const char *oldName, const char *newName,
|
||||
int flags);
|
||||
@@ -114,7 +126,6 @@ static Tcl_ObjCmdProc ExprBinaryFunc;
|
||||
static Tcl_ObjCmdProc ExprBoolFunc;
|
||||
static Tcl_ObjCmdProc ExprCeilFunc;
|
||||
static Tcl_ObjCmdProc ExprDoubleFunc;
|
||||
static Tcl_ObjCmdProc ExprEntierFunc;
|
||||
static Tcl_ObjCmdProc ExprFloorFunc;
|
||||
static Tcl_ObjCmdProc ExprIntFunc;
|
||||
static Tcl_ObjCmdProc ExprIsqrtFunc;
|
||||
@@ -195,6 +206,24 @@ typedef struct {
|
||||
* expansion for itself rather than needing the generic layer to take care of
|
||||
* it for it. Defined in tclInt.h. */
|
||||
|
||||
/*
|
||||
* The following struct states that the command it talks about (a subcommand
|
||||
* of one of Tcl's built-in ensembles) is unsafe and must be hidden when an
|
||||
* interpreter is made safe. (TclHideUnsafeCommands accesses an array of these
|
||||
* structs.) Alas, we can't sensibly just store the information directly in
|
||||
* the commands.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
const char *ensembleNsName; /* The ensemble's name within ::tcl. NULL for
|
||||
* the end of the list of commands to hide. */
|
||||
const char *commandName; /* The name of the command within the
|
||||
* ensemble. If this is NULL, we want to also
|
||||
* make the overall command be hidden, an ugly
|
||||
* hack because it is expected by security
|
||||
* policies in the wild. */
|
||||
} UnsafeEnsembleInfo;
|
||||
|
||||
/*
|
||||
* The built-in commands, and the functions that implement them:
|
||||
*/
|
||||
@@ -295,6 +324,68 @@ static const CmdInfo builtInCmds[] = {
|
||||
{NULL, NULL, NULL, NULL, 0}
|
||||
};
|
||||
|
||||
/*
|
||||
* Information about which pieces of ensembles to hide when making an
|
||||
* interpreter safe:
|
||||
*/
|
||||
|
||||
static const UnsafeEnsembleInfo unsafeEnsembleCommands[] = {
|
||||
/* [encoding] has two unsafe commands. Assumed by older security policies
|
||||
* to be overall unsafe; it isn't but... */
|
||||
{"encoding", NULL},
|
||||
{"encoding", "dirs"},
|
||||
{"encoding", "system"},
|
||||
/* [file] has MANY unsafe commands! Assumed by older security policies to
|
||||
* be overall unsafe; it isn't but... */
|
||||
{"file", NULL},
|
||||
{"file", "atime"},
|
||||
{"file", "attributes"},
|
||||
{"file", "copy"},
|
||||
{"file", "delete"},
|
||||
{"file", "dirname"},
|
||||
{"file", "executable"},
|
||||
{"file", "exists"},
|
||||
{"file", "extension"},
|
||||
{"file", "isdirectory"},
|
||||
{"file", "isfile"},
|
||||
{"file", "link"},
|
||||
{"file", "lstat"},
|
||||
{"file", "mtime"},
|
||||
{"file", "mkdir"},
|
||||
{"file", "nativename"},
|
||||
{"file", "normalize"},
|
||||
{"file", "owned"},
|
||||
{"file", "readable"},
|
||||
{"file", "readlink"},
|
||||
{"file", "rename"},
|
||||
{"file", "rootname"},
|
||||
{"file", "size"},
|
||||
{"file", "stat"},
|
||||
{"file", "tail"},
|
||||
{"file", "tempfile"},
|
||||
{"file", "type"},
|
||||
{"file", "volumes"},
|
||||
{"file", "writable"},
|
||||
/* [info] has two unsafe commands */
|
||||
{"info", "cmdtype"},
|
||||
{"info", "nameofexecutable"},
|
||||
/* [tcl::process] has ONLY unsafe commands! */
|
||||
{"process", "list"},
|
||||
{"process", "status"},
|
||||
{"process", "purge"},
|
||||
{"process", "autopurge"},
|
||||
/* [zipfs] has MANY unsafe commands! */
|
||||
{"zipfs", "lmkimg"},
|
||||
{"zipfs", "lmkzip"},
|
||||
{"zipfs", "mkimg"},
|
||||
{"zipfs", "mkkey"},
|
||||
{"zipfs", "mkzip"},
|
||||
{"zipfs", "mount"},
|
||||
{"zipfs", "mount_data"},
|
||||
{"zipfs", "unmount"},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
* Math functions. All are safe.
|
||||
*/
|
||||
@@ -316,7 +407,7 @@ static const BuiltinFuncDef BuiltinFuncTable[] = {
|
||||
{ "cos", ExprUnaryFunc, (ClientData) cos },
|
||||
{ "cosh", ExprUnaryFunc, (ClientData) cosh },
|
||||
{ "double", ExprDoubleFunc, NULL },
|
||||
{ "entier", ExprEntierFunc, NULL },
|
||||
{ "entier", ExprIntFunc, NULL },
|
||||
{ "exp", ExprUnaryFunc, (ClientData) exp },
|
||||
{ "floor", ExprFloorFunc, NULL },
|
||||
{ "fmod", ExprBinaryFunc, (ClientData) fmod },
|
||||
@@ -431,6 +522,13 @@ TclFinalizeEvaluation(void)
|
||||
cancelTableInitialized = 0;
|
||||
}
|
||||
Tcl_MutexUnlock(&cancelLock);
|
||||
|
||||
Tcl_MutexLock(&commandTypeLock);
|
||||
if (commandTypeInit) {
|
||||
Tcl_DeleteHashTable(&commandTypeTable);
|
||||
commandTypeInit = 0;
|
||||
}
|
||||
Tcl_MutexUnlock(&commandTypeLock);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -504,9 +602,23 @@ Tcl_CreateInterp(void)
|
||||
Tcl_InitHashTable(&cancelTable, TCL_ONE_WORD_KEYS);
|
||||
cancelTableInitialized = 1;
|
||||
}
|
||||
|
||||
Tcl_MutexUnlock(&cancelLock);
|
||||
}
|
||||
|
||||
if (commandTypeInit == 0) {
|
||||
TclRegisterCommandTypeName(TclObjInterpProc, "proc");
|
||||
TclRegisterCommandTypeName(TclEnsembleImplementationCmd, "ensemble");
|
||||
TclRegisterCommandTypeName(TclAliasObjCmd, "alias");
|
||||
TclRegisterCommandTypeName(TclLocalAliasObjCmd, "alias");
|
||||
TclRegisterCommandTypeName(TclSlaveObjCmd, "slave");
|
||||
TclRegisterCommandTypeName(TclInvokeImportedCmd, "import");
|
||||
TclRegisterCommandTypeName(TclOOPublicObjectCmd, "object");
|
||||
TclRegisterCommandTypeName(TclOOPrivateObjectCmd, "privateObject");
|
||||
TclRegisterCommandTypeName(TclOOMyClassObjCmd, "privateClass");
|
||||
TclRegisterCommandTypeName(TclNRInterpCoroutine, "coroutine");
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize support for namespaces and create the global namespace
|
||||
* (whose name is ""; an alias is "::"). This also initializes the Tcl
|
||||
@@ -749,7 +861,7 @@ Tcl_CreateInterp(void)
|
||||
* cache was already initialised by the call to alloc the interp struct.
|
||||
*/
|
||||
|
||||
#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
|
||||
#if TCL_THREADS && defined(USE_THREAD_ALLOC)
|
||||
iPtr->allocCache = TclpGetAllocCache();
|
||||
#else
|
||||
iPtr->allocCache = NULL;
|
||||
@@ -964,7 +1076,7 @@ Tcl_CreateInterp(void)
|
||||
#endif /* !TCL_NO_DEPRECATED */
|
||||
TclpSetVariables(interp);
|
||||
|
||||
#ifdef TCL_THREADS
|
||||
#if TCL_THREADS
|
||||
/*
|
||||
* The existence of the "threaded" element of the tcl_platform array
|
||||
* indicates that this particular Tcl shell has been compiled with threads
|
||||
@@ -999,6 +1111,9 @@ Tcl_CreateInterp(void)
|
||||
if (TclZlibInit(interp) != TCL_OK) {
|
||||
Tcl_Panic("%s", TclGetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
if (TclZipfs_Init(interp) != TCL_OK) {
|
||||
Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
#endif
|
||||
|
||||
TOP_CB(iPtr) = NULL;
|
||||
@@ -1014,6 +1129,71 @@ DeleteOpCmdClientData(
|
||||
ckfree(occdPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* TclRegisterCommandTypeName, TclGetCommandTypeName --
|
||||
*
|
||||
* Command type registration and lookup mechanism. Everything is keyed by
|
||||
* the Tcl_ObjCmdProc for the command, and that is used as the *key* into
|
||||
* the hash table that maps to constant strings that are names. (It is
|
||||
* recommended that those names be ASCII.)
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
TclRegisterCommandTypeName(
|
||||
Tcl_ObjCmdProc *implementationProc,
|
||||
const char *nameStr)
|
||||
{
|
||||
Tcl_HashEntry *hPtr;
|
||||
|
||||
Tcl_MutexLock(&commandTypeLock);
|
||||
if (commandTypeInit == 0) {
|
||||
Tcl_InitHashTable(&commandTypeTable, TCL_ONE_WORD_KEYS);
|
||||
commandTypeInit = 1;
|
||||
}
|
||||
if (nameStr != NULL) {
|
||||
int isNew;
|
||||
|
||||
hPtr = Tcl_CreateHashEntry(&commandTypeTable,
|
||||
(void *) implementationProc, &isNew);
|
||||
Tcl_SetHashValue(hPtr, (void *) nameStr);
|
||||
} else {
|
||||
hPtr = Tcl_FindHashEntry(&commandTypeTable,
|
||||
(void *) implementationProc);
|
||||
if (hPtr != NULL) {
|
||||
Tcl_DeleteHashEntry(hPtr);
|
||||
}
|
||||
}
|
||||
Tcl_MutexUnlock(&commandTypeLock);
|
||||
}
|
||||
|
||||
const char *
|
||||
TclGetCommandTypeName(
|
||||
Tcl_Command command)
|
||||
{
|
||||
Command *cmdPtr = (Command *) command;
|
||||
void *procPtr = cmdPtr->objProc;
|
||||
const char *name = "native";
|
||||
|
||||
if (procPtr == NULL) {
|
||||
procPtr = cmdPtr->nreProc;
|
||||
}
|
||||
Tcl_MutexLock(&commandTypeLock);
|
||||
if (commandTypeInit) {
|
||||
Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&commandTypeTable, procPtr);
|
||||
|
||||
if (hPtr && Tcl_GetHashValue(hPtr)) {
|
||||
name = (const char *) Tcl_GetHashValue(hPtr);
|
||||
}
|
||||
}
|
||||
Tcl_MutexUnlock(&commandTypeLock);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
@@ -1035,6 +1215,7 @@ TclHideUnsafeCommands(
|
||||
Tcl_Interp *interp) /* Hide commands in this interpreter. */
|
||||
{
|
||||
register const CmdInfo *cmdInfoPtr;
|
||||
register const UnsafeEnsembleInfo *unsafePtr;
|
||||
|
||||
if (interp == NULL) {
|
||||
return TCL_ERROR;
|
||||
@@ -1044,11 +1225,82 @@ TclHideUnsafeCommands(
|
||||
Tcl_HideCommand(interp, cmdInfoPtr->name, cmdInfoPtr->name);
|
||||
}
|
||||
}
|
||||
TclMakeEncodingCommandSafe(interp); /* Ugh! */
|
||||
TclMakeFileCommandSafe(interp); /* Ugh! */
|
||||
|
||||
for (unsafePtr = unsafeEnsembleCommands;
|
||||
unsafePtr->ensembleNsName; unsafePtr++) {
|
||||
if (unsafePtr->commandName) {
|
||||
/*
|
||||
* Hide an ensemble subcommand.
|
||||
*/
|
||||
|
||||
Tcl_Obj *cmdName = Tcl_ObjPrintf("::tcl::%s::%s",
|
||||
unsafePtr->ensembleNsName, unsafePtr->commandName);
|
||||
Tcl_Obj *hideName = Tcl_ObjPrintf("tcl:%s:%s",
|
||||
unsafePtr->ensembleNsName, unsafePtr->commandName);
|
||||
|
||||
if (TclRenameCommand(interp, TclGetString(cmdName),
|
||||
"___tmp") != TCL_OK
|
||||
|| Tcl_HideCommand(interp, "___tmp",
|
||||
TclGetString(hideName)) != TCL_OK) {
|
||||
Tcl_Panic("problem making '%s %s' safe: %s",
|
||||
unsafePtr->ensembleNsName, unsafePtr->commandName,
|
||||
Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
Tcl_CreateObjCommand(interp, TclGetString(cmdName),
|
||||
BadEnsembleSubcommand, (ClientData) unsafePtr, NULL);
|
||||
TclDecrRefCount(cmdName);
|
||||
TclDecrRefCount(hideName);
|
||||
} else {
|
||||
/*
|
||||
* Hide an ensemble main command (for compatibility).
|
||||
*/
|
||||
|
||||
if (Tcl_HideCommand(interp, unsafePtr->ensembleNsName,
|
||||
unsafePtr->ensembleNsName) != TCL_OK) {
|
||||
Tcl_Panic("problem making '%s' safe: %s",
|
||||
unsafePtr->ensembleNsName,
|
||||
Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* BadEnsembleSubcommand --
|
||||
*
|
||||
* Command used to act as a backstop implementation when subcommands of
|
||||
* ensembles are unsafe (the real implementations of the subcommands are
|
||||
* hidden). The clientData is description of what was hidden.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result (always a TCL_ERROR).
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
BadEnsembleSubcommand(
|
||||
ClientData clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *const objv[])
|
||||
{
|
||||
const UnsafeEnsembleInfo *infoPtr = clientData;
|
||||
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"not allowed to invoke subcommand %s of %s",
|
||||
infoPtr->commandName, infoPtr->ensembleNsName));
|
||||
Tcl_SetErrorCode(interp, "TCL", "SAFE", "SUBCOMMAND", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
*
|
||||
@@ -2295,30 +2547,33 @@ Tcl_CreateObjCommand(
|
||||
}
|
||||
|
||||
Tcl_Command
|
||||
TclCreateObjCommandInNs (
|
||||
TclCreateObjCommandInNs(
|
||||
Tcl_Interp *interp,
|
||||
const char *cmdName, /* Name of command, without any namespace components */
|
||||
const char *cmdName, /* Name of command, without any namespace
|
||||
* components. */
|
||||
Tcl_Namespace *namespace, /* The namespace to create the command in */
|
||||
Tcl_ObjCmdProc *proc, /* Object-based function to associate with
|
||||
* name. */
|
||||
ClientData clientData, /* Arbitrary value to pass to object
|
||||
* function. */
|
||||
Tcl_CmdDeleteProc *deleteProc
|
||||
Tcl_CmdDeleteProc *deleteProc)
|
||||
/* If not NULL, gives a function to call when
|
||||
* this command is deleted. */
|
||||
) {
|
||||
{
|
||||
int deleted = 0, isNew = 0;
|
||||
Command *cmdPtr;
|
||||
ImportRef *oldRefPtr = NULL;
|
||||
ImportedCmdData *dataPtr;
|
||||
Tcl_HashEntry *hPtr;
|
||||
Namespace *nsPtr = (Namespace *) namespace;
|
||||
|
||||
/*
|
||||
* If the command name we seek to create already exists, we need to
|
||||
* delete that first. That can be tricky in the presence of traces.
|
||||
* Loop until we no longer find an existing command in the way, or
|
||||
* until we've deleted one command and that didn't finish the job.
|
||||
* If the command name we seek to create already exists, we need to delete
|
||||
* that first. That can be tricky in the presence of traces. Loop until we
|
||||
* no longer find an existing command in the way, or until we've deleted
|
||||
* one command and that didn't finish the job.
|
||||
*/
|
||||
|
||||
while (1) {
|
||||
hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, cmdName, &isNew);
|
||||
|
||||
@@ -2330,16 +2585,18 @@ TclCreateObjCommandInNs (
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* An existing command conflicts. Try to delete it.
|
||||
*/
|
||||
|
||||
/* An existing command conflicts. Try to delete it.. */
|
||||
cmdPtr = Tcl_GetHashValue(hPtr);
|
||||
|
||||
/*
|
||||
* [***] This is wrong. See Tcl Bug a16752c252.
|
||||
* However, this buggy behavior is kept under particular
|
||||
* circumstances to accommodate deployed binaries of the
|
||||
* "tclcompiler" program. http://sourceforge.net/projects/tclpro/
|
||||
* that crash if the bug is fixed.
|
||||
* [***] This is wrong. See Tcl Bug a16752c252. However, this buggy
|
||||
* behavior is kept under particular circumstances to accommodate
|
||||
* deployed binaries of the "tclcompiler" program
|
||||
* http://sourceforge.net/projects/tclpro/
|
||||
* that crash if the bug is fixed.
|
||||
*/
|
||||
|
||||
if (cmdPtr->objProc == TclInvokeStringCommand
|
||||
@@ -2363,12 +2620,15 @@ TclCreateObjCommandInNs (
|
||||
cmdPtr->flags |= CMD_REDEF_IN_PROGRESS;
|
||||
}
|
||||
|
||||
/* Make sure namespace doesn't get deallocated. */
|
||||
/*
|
||||
* Make sure namespace doesn't get deallocated.
|
||||
*/
|
||||
|
||||
cmdPtr->nsPtr->refCount++;
|
||||
|
||||
Tcl_DeleteCommandFromToken(interp, (Tcl_Command) cmdPtr);
|
||||
nsPtr = (Namespace *) TclEnsureNamespace(interp,
|
||||
(Tcl_Namespace *)cmdPtr->nsPtr);
|
||||
(Tcl_Namespace *) cmdPtr->nsPtr);
|
||||
TclNsDecrRefCount(cmdPtr->nsPtr);
|
||||
|
||||
if (cmdPtr->flags & CMD_REDEF_IN_PROGRESS) {
|
||||
@@ -2380,9 +2640,9 @@ TclCreateObjCommandInNs (
|
||||
}
|
||||
if (!isNew) {
|
||||
/*
|
||||
* If the deletion callback recreated the command, just throw away
|
||||
* the new command (if we try to delete it again, we could get
|
||||
* stuck in an infinite loop).
|
||||
* If the deletion callback recreated the command, just throw away the
|
||||
* new command (if we try to delete it again, we could get stuck in an
|
||||
* infinite loop).
|
||||
*/
|
||||
|
||||
ckfree(Tcl_GetHashValue(hPtr));
|
||||
@@ -2437,6 +2697,7 @@ TclCreateObjCommandInNs (
|
||||
cmdPtr->importRefPtr = oldRefPtr;
|
||||
while (oldRefPtr != NULL) {
|
||||
Command *refCmdPtr = oldRefPtr->importedCmdPtr;
|
||||
|
||||
dataPtr = refCmdPtr->objClientData;
|
||||
dataPtr->realCmdPtr = cmdPtr;
|
||||
oldRefPtr = oldRefPtr->nextPtr;
|
||||
@@ -6511,7 +6772,7 @@ Tcl_ExprLongObj(
|
||||
resultPtr = Tcl_NewBignumObj(&big);
|
||||
/* FALLTHROUGH */
|
||||
}
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
case TCL_NUMBER_BIG:
|
||||
result = TclGetLongFromObj(interp, resultPtr, ptr);
|
||||
break;
|
||||
@@ -7487,7 +7748,7 @@ ExprAbsFunc(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (type == TCL_NUMBER_WIDE) {
|
||||
if (type == TCL_NUMBER_INT) {
|
||||
Tcl_WideInt l = *((const Tcl_WideInt *) ptr);
|
||||
|
||||
if (l > (Tcl_WideInt)0) {
|
||||
@@ -7504,7 +7765,7 @@ ExprAbsFunc(
|
||||
}
|
||||
}
|
||||
goto unChanged;
|
||||
} else if (l == LLONG_MIN) {
|
||||
} else if (l == WIDE_MIN) {
|
||||
TclInitBignumFromWideInt(&big, l);
|
||||
goto tooLarge;
|
||||
}
|
||||
@@ -7608,7 +7869,7 @@ ExprDoubleFunc(
|
||||
}
|
||||
|
||||
static int
|
||||
ExprEntierFunc(
|
||||
ExprIntFunc(
|
||||
ClientData clientData, /* Ignored. */
|
||||
Tcl_Interp *interp, /* The interpreter in which to execute the
|
||||
* function. */
|
||||
@@ -7629,7 +7890,7 @@ ExprEntierFunc(
|
||||
|
||||
if (type == TCL_NUMBER_DOUBLE) {
|
||||
d = *((const double *) ptr);
|
||||
if ((d >= (double)LONG_MAX) || (d <= (double)LONG_MIN)) {
|
||||
if ((d >= (double)WIDE_MAX) || (d <= (double)WIDE_MIN)) {
|
||||
mp_int big;
|
||||
|
||||
if (Tcl_InitBignumFromDouble(interp, d, &big) != TCL_OK) {
|
||||
@@ -7639,9 +7900,9 @@ ExprEntierFunc(
|
||||
Tcl_SetObjResult(interp, Tcl_NewBignumObj(&big));
|
||||
return TCL_OK;
|
||||
} else {
|
||||
long result = (long) d;
|
||||
Tcl_WideInt result = (Tcl_WideInt) d;
|
||||
|
||||
Tcl_SetObjResult(interp, Tcl_NewLongObj(result));
|
||||
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result));
|
||||
return TCL_OK;
|
||||
}
|
||||
}
|
||||
@@ -7663,38 +7924,6 @@ ExprEntierFunc(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
static int
|
||||
ExprIntFunc(
|
||||
ClientData clientData, /* Ignored. */
|
||||
Tcl_Interp *interp, /* The interpreter in which to execute the
|
||||
* function. */
|
||||
int objc, /* Actual parameter count. */
|
||||
Tcl_Obj *const *objv) /* Actual parameter vector. */
|
||||
{
|
||||
long iResult;
|
||||
Tcl_Obj *objPtr;
|
||||
if (ExprEntierFunc(NULL, interp, objc, objv) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
objPtr = Tcl_GetObjResult(interp);
|
||||
if (TclGetLongFromObj(NULL, objPtr, &iResult) != TCL_OK) {
|
||||
/*
|
||||
* Truncate the bignum; keep only bits in long range.
|
||||
*/
|
||||
|
||||
mp_int big;
|
||||
|
||||
Tcl_GetBignumFromObj(NULL, objPtr, &big);
|
||||
mp_mod_2d(&big, (int) CHAR_BIT * sizeof(long), &big);
|
||||
objPtr = Tcl_NewBignumObj(&big);
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
TclGetLongFromObj(NULL, objPtr, &iResult);
|
||||
Tcl_DecrRefCount(objPtr);
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_NewLongObj(iResult));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
ExprWideFunc(
|
||||
ClientData clientData, /* Ignored. */
|
||||
@@ -7704,26 +7933,11 @@ ExprWideFunc(
|
||||
Tcl_Obj *const *objv) /* Actual parameter vector. */
|
||||
{
|
||||
Tcl_WideInt wResult;
|
||||
Tcl_Obj *objPtr;
|
||||
|
||||
if (ExprEntierFunc(NULL, interp, objc, objv) != TCL_OK) {
|
||||
if (ExprIntFunc(NULL, interp, objc, objv) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
objPtr = Tcl_GetObjResult(interp);
|
||||
if (TclGetWideIntFromObj(NULL, objPtr, &wResult) != TCL_OK) {
|
||||
/*
|
||||
* Truncate the bignum; keep only bits in wide int range.
|
||||
*/
|
||||
|
||||
mp_int big;
|
||||
|
||||
Tcl_GetBignumFromObj(NULL, objPtr, &big);
|
||||
mp_mod_2d(&big, (int) CHAR_BIT * sizeof(Tcl_WideInt), &big);
|
||||
objPtr = Tcl_NewBignumObj(&big);
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
TclGetWideIntFromObj(NULL, objPtr, &wResult);
|
||||
Tcl_DecrRefCount(objPtr);
|
||||
}
|
||||
TclGetWideBitsFromObj(NULL, Tcl_GetObjResult(interp), &wResult);
|
||||
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(wResult));
|
||||
return TCL_OK;
|
||||
}
|
||||
@@ -7826,7 +8040,7 @@ ExprRandFunc(
|
||||
* Make sure 1 <= randSeed <= (2^31) - 2. See below.
|
||||
*/
|
||||
|
||||
iPtr->randSeed &= (unsigned long) 0x7fffffff;
|
||||
iPtr->randSeed &= 0x7fffffff;
|
||||
if ((iPtr->randSeed == 0) || (iPtr->randSeed == 0x7fffffff)) {
|
||||
iPtr->randSeed ^= 123459876;
|
||||
}
|
||||
@@ -7970,7 +8184,7 @@ ExprSrandFunc(
|
||||
Tcl_Obj *const *objv) /* Parameter vector. */
|
||||
{
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
long i = 0; /* Initialized to avoid compiler warning. */
|
||||
Tcl_WideInt w = 0; /* Initialized to avoid compiler warning. */
|
||||
|
||||
/*
|
||||
* Convert argument and use it to reset the seed.
|
||||
@@ -7981,20 +8195,8 @@ ExprSrandFunc(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (TclGetLongFromObj(NULL, objv[1], &i) != TCL_OK) {
|
||||
Tcl_Obj *objPtr;
|
||||
mp_int big;
|
||||
|
||||
if (Tcl_GetBignumFromObj(interp, objv[1], &big) != TCL_OK) {
|
||||
/* TODO: more ::errorInfo here? or in caller? */
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
mp_mod_2d(&big, (int) CHAR_BIT * sizeof(long), &big);
|
||||
objPtr = Tcl_NewBignumObj(&big);
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
TclGetLongFromObj(NULL, objPtr, &i);
|
||||
Tcl_DecrRefCount(objPtr);
|
||||
if (TclGetWideBitsFromObj(NULL, objv[1], &w) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -8003,8 +8205,7 @@ ExprSrandFunc(
|
||||
*/
|
||||
|
||||
iPtr->flags |= RAND_SEED_INITIALIZED;
|
||||
iPtr->randSeed = i;
|
||||
iPtr->randSeed &= (unsigned long) 0x7fffffff;
|
||||
iPtr->randSeed = (long) w & 0x7fffffff;
|
||||
if ((iPtr->randSeed == 0) || (iPtr->randSeed == 0x7fffffff)) {
|
||||
iPtr->randSeed ^= 123459876;
|
||||
}
|
||||
@@ -8276,23 +8477,26 @@ Tcl_NRCreateCommand(
|
||||
* this command is deleted. */
|
||||
{
|
||||
Command *cmdPtr = (Command *)
|
||||
Tcl_CreateObjCommand(interp,cmdName,proc,clientData,deleteProc);
|
||||
Tcl_CreateObjCommand(interp, cmdName, proc, clientData,
|
||||
deleteProc);
|
||||
|
||||
cmdPtr->nreProc = nreProc;
|
||||
return (Tcl_Command) cmdPtr;
|
||||
}
|
||||
|
||||
Tcl_Command
|
||||
TclNRCreateCommandInNs (
|
||||
TclNRCreateCommandInNs(
|
||||
Tcl_Interp *interp,
|
||||
const char *cmdName,
|
||||
Tcl_Namespace *nsPtr,
|
||||
Tcl_ObjCmdProc *proc,
|
||||
Tcl_ObjCmdProc *nreProc,
|
||||
ClientData clientData,
|
||||
Tcl_CmdDeleteProc *deleteProc) {
|
||||
Tcl_CmdDeleteProc *deleteProc)
|
||||
{
|
||||
Command *cmdPtr = (Command *)
|
||||
TclCreateObjCommandInNs(interp,cmdName,nsPtr,proc,clientData,deleteProc);
|
||||
TclCreateObjCommandInNs(interp, cmdName, nsPtr, proc, clientData,
|
||||
deleteProc);
|
||||
|
||||
cmdPtr->nreProc = nreProc;
|
||||
return (Tcl_Command) cmdPtr;
|
||||
@@ -8396,7 +8600,6 @@ TclPushTailcallPoint(
|
||||
TclNRAddCallback(interp, NRCommand, NULL, NULL, NULL, NULL);
|
||||
((Interp *) interp)->numLevels++;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -8432,7 +8635,6 @@ TclSetTailcall(
|
||||
}
|
||||
runPtr->data[1] = listPtr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -8490,25 +8692,18 @@ TclNRTailcallObjCmd(
|
||||
if (objc > 1) {
|
||||
Tcl_Obj *listPtr, *nsObjPtr;
|
||||
Tcl_Namespace *nsPtr = (Tcl_Namespace *) iPtr->varFramePtr->nsPtr;
|
||||
Tcl_Namespace *ns1Ptr;
|
||||
|
||||
/* The tailcall data is in a Tcl list: the first element is the
|
||||
* namespace, the rest the command to be tailcalled. */
|
||||
|
||||
listPtr = Tcl_NewListObj(objc, objv);
|
||||
|
||||
nsObjPtr = Tcl_NewStringObj(nsPtr->fullName, -1);
|
||||
if ((TCL_OK != TclGetNamespaceFromObj(interp, nsObjPtr, &ns1Ptr))
|
||||
|| (nsPtr != ns1Ptr)) {
|
||||
Tcl_Panic("Tailcall failed to find the proper namespace");
|
||||
}
|
||||
listPtr = Tcl_NewListObj(objc, objv);
|
||||
TclListObjSetElement(interp, listPtr, 0, nsObjPtr);
|
||||
|
||||
iPtr->varFramePtr->tailcallPtr = listPtr;
|
||||
}
|
||||
return TCL_RETURN;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -8576,7 +8771,6 @@ TclNRReleaseValues(
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Tcl_NRAddCallback(
|
||||
|
||||
+25
-26
@@ -1963,7 +1963,6 @@ FormatNumber(
|
||||
Tcl_Obj *src, /* Number to format. */
|
||||
unsigned char **cursorPtr) /* Pointer to index into destination buffer. */
|
||||
{
|
||||
long value;
|
||||
double dvalue;
|
||||
Tcl_WideInt wvalue;
|
||||
float fvalue;
|
||||
@@ -2025,7 +2024,7 @@ FormatNumber(
|
||||
case 'w':
|
||||
case 'W':
|
||||
case 'm':
|
||||
if (Tcl_GetWideIntFromObj(interp, src, &wvalue) != TCL_OK) {
|
||||
if (TclGetWideBitsFromObj(interp, src, &wvalue) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (NeedReversing(type)) {
|
||||
@@ -2055,19 +2054,19 @@ FormatNumber(
|
||||
case 'i':
|
||||
case 'I':
|
||||
case 'n':
|
||||
if (TclGetLongFromObj(interp, src, &value) != TCL_OK) {
|
||||
if (TclGetWideBitsFromObj(interp, src, &wvalue) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (NeedReversing(type)) {
|
||||
*(*cursorPtr)++ = UCHAR(value);
|
||||
*(*cursorPtr)++ = UCHAR(value >> 8);
|
||||
*(*cursorPtr)++ = UCHAR(value >> 16);
|
||||
*(*cursorPtr)++ = UCHAR(value >> 24);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue >> 8);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue >> 16);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue >> 24);
|
||||
} else {
|
||||
*(*cursorPtr)++ = UCHAR(value >> 24);
|
||||
*(*cursorPtr)++ = UCHAR(value >> 16);
|
||||
*(*cursorPtr)++ = UCHAR(value >> 8);
|
||||
*(*cursorPtr)++ = UCHAR(value);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue >> 24);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue >> 16);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue >> 8);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue);
|
||||
}
|
||||
return TCL_OK;
|
||||
|
||||
@@ -2077,15 +2076,15 @@ FormatNumber(
|
||||
case 's':
|
||||
case 'S':
|
||||
case 't':
|
||||
if (TclGetLongFromObj(interp, src, &value) != TCL_OK) {
|
||||
if (TclGetWideBitsFromObj(interp, src, &wvalue) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (NeedReversing(type)) {
|
||||
*(*cursorPtr)++ = UCHAR(value);
|
||||
*(*cursorPtr)++ = UCHAR(value >> 8);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue >> 8);
|
||||
} else {
|
||||
*(*cursorPtr)++ = UCHAR(value >> 8);
|
||||
*(*cursorPtr)++ = UCHAR(value);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue >> 8);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue);
|
||||
}
|
||||
return TCL_OK;
|
||||
|
||||
@@ -2093,10 +2092,10 @@ FormatNumber(
|
||||
* 8-bit integer values.
|
||||
*/
|
||||
case 'c':
|
||||
if (TclGetLongFromObj(interp, src, &value) != TCL_OK) {
|
||||
if (TclGetWideBitsFromObj(interp, src, &wvalue) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
*(*cursorPtr)++ = UCHAR(value);
|
||||
*(*cursorPtr)++ = UCHAR(wvalue);
|
||||
return TCL_OK;
|
||||
|
||||
default:
|
||||
@@ -2484,8 +2483,8 @@ BinaryDecodeHex(
|
||||
}
|
||||
|
||||
c = *data++;
|
||||
if (!isxdigit((int) c)) {
|
||||
if (strict || !isspace(c)) {
|
||||
if (!isxdigit(UCHAR(c))) {
|
||||
if (strict || !TclIsSpaceProc(c)) {
|
||||
goto badChar;
|
||||
}
|
||||
i--;
|
||||
@@ -2832,7 +2831,7 @@ BinaryDecodeUu(
|
||||
if (lineLen < 0) {
|
||||
c = *data++;
|
||||
if (c < 32 || c > 96) {
|
||||
if (strict || !isspace(c)) {
|
||||
if (strict || !TclIsSpaceProc(c)) {
|
||||
goto badUu;
|
||||
}
|
||||
i--;
|
||||
@@ -2850,7 +2849,7 @@ BinaryDecodeUu(
|
||||
d[i] = c = *data++;
|
||||
if (c < 32 || c > 96) {
|
||||
if (strict) {
|
||||
if (!isspace(c)) {
|
||||
if (!TclIsSpaceProc(c)) {
|
||||
goto badUu;
|
||||
} else if (c == '\n') {
|
||||
goto shortUu;
|
||||
@@ -2894,7 +2893,7 @@ BinaryDecodeUu(
|
||||
} else if (c >= 32 && c <= 96) {
|
||||
data--;
|
||||
break;
|
||||
} else if (strict || !isspace(c)) {
|
||||
} else if (strict || !TclIsSpaceProc(c)) {
|
||||
goto badUu;
|
||||
}
|
||||
} while (data < dataend);
|
||||
@@ -3019,7 +3018,7 @@ BinaryDecode64(
|
||||
if (c == '=' && i > 1) {
|
||||
value <<= 6;
|
||||
cut++;
|
||||
} else if (!strict && isspace(c)) {
|
||||
} else if (!strict && TclIsSpaceProc(c)) {
|
||||
i--;
|
||||
} else {
|
||||
goto bad64;
|
||||
@@ -3037,7 +3036,7 @@ BinaryDecode64(
|
||||
} else if (c == '=') {
|
||||
value <<= 6;
|
||||
cut++;
|
||||
} else if (strict || !isspace(c)) {
|
||||
} else if (strict || !TclIsSpaceProc(c)) {
|
||||
goto bad64;
|
||||
} else {
|
||||
i--;
|
||||
@@ -3058,7 +3057,7 @@ BinaryDecode64(
|
||||
goto bad64;
|
||||
}
|
||||
for (; data < dataend; data++) {
|
||||
if (!isspace(*data)) {
|
||||
if (!TclIsSpaceProc(*data)) {
|
||||
goto bad64;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ TclInitDbCkalloc(void)
|
||||
if (!ckallocInit) {
|
||||
ckallocInit = 1;
|
||||
ckallocMutexPtr = Tcl_GetAllocMutex();
|
||||
#ifndef TCL_THREADS
|
||||
#if !TCL_THREADS
|
||||
/* Silence compiler warning */
|
||||
(void)ckallocMutexPtr;
|
||||
#endif
|
||||
|
||||
+34
-337
@@ -46,9 +46,6 @@ struct ForeachState {
|
||||
|
||||
static int CheckAccess(Tcl_Interp *interp, Tcl_Obj *pathPtr,
|
||||
int mode);
|
||||
static int BadEncodingSubcommand(ClientData dummy,
|
||||
Tcl_Interp *interp, int objc,
|
||||
Tcl_Obj *const objv[]);
|
||||
static int EncodingConvertfromObjCmd(ClientData dummy,
|
||||
Tcl_Interp *interp, int objc,
|
||||
Tcl_Obj *const objv[]);
|
||||
@@ -84,7 +81,6 @@ static Tcl_NRPostProc ForPostNextCallback;
|
||||
static Tcl_NRPostProc ForeachLoopStep;
|
||||
static Tcl_NRPostProc EvalCmdErrMsg;
|
||||
|
||||
static Tcl_ObjCmdProc BadFileSubcommand;
|
||||
static Tcl_ObjCmdProc FileAttrAccessTimeCmd;
|
||||
static Tcl_ObjCmdProc FileAttrIsDirectoryCmd;
|
||||
static Tcl_ObjCmdProc FileAttrIsExecutableCmd;
|
||||
@@ -513,63 +509,6 @@ Tcl_ContinueObjCmd(
|
||||
return TCL_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* Tcl_EncodingObjCmd --
|
||||
*
|
||||
* This command manipulates encodings.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result.
|
||||
*
|
||||
* Side effects:
|
||||
* See the user documentation.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Tcl_EncodingObjCmd(
|
||||
ClientData dummy, /* Not used. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
int index;
|
||||
|
||||
static const char *const optionStrings[] = {
|
||||
"convertfrom", "convertto", "dirs", "names", "system",
|
||||
NULL
|
||||
};
|
||||
enum options {
|
||||
ENC_CONVERTFROM, ENC_CONVERTTO, ENC_DIRS, ENC_NAMES, ENC_SYSTEM
|
||||
};
|
||||
|
||||
if (objc < 2) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
|
||||
&index) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
switch ((enum options) index) {
|
||||
case ENC_CONVERTTO:
|
||||
return EncodingConverttoObjCmd(dummy, interp, objc, objv);
|
||||
case ENC_CONVERTFROM:
|
||||
return EncodingConvertfromObjCmd(dummy, interp, objc, objv);
|
||||
case ENC_DIRS:
|
||||
return EncodingDirsObjCmd(dummy, interp, objc, objv);
|
||||
case ENC_NAMES:
|
||||
return EncodingNamesObjCmd(dummy, interp, objc, objv);
|
||||
case ENC_SYSTEM:
|
||||
return EncodingSystemObjCmd(dummy, interp, objc, objv);
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*-----------------------------------------------------------------------------
|
||||
*
|
||||
@@ -593,122 +532,15 @@ TclInitEncodingCmd(
|
||||
static const EnsembleImplMap encodingImplMap[] = {
|
||||
{"convertfrom", EncodingConvertfromObjCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 0},
|
||||
{"convertto", EncodingConverttoObjCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 0},
|
||||
{"dirs", EncodingDirsObjCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
|
||||
{"dirs", EncodingDirsObjCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 1},
|
||||
{"names", EncodingNamesObjCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0},
|
||||
{"system", EncodingSystemObjCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
|
||||
{"system", EncodingSystemObjCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 1},
|
||||
{NULL, NULL, NULL, NULL, NULL, 0}
|
||||
};
|
||||
|
||||
return TclMakeEnsemble(interp, "encoding", encodingImplMap);
|
||||
}
|
||||
|
||||
/*
|
||||
*-----------------------------------------------------------------------------
|
||||
*
|
||||
* TclMakeEncodingCommandSafe --
|
||||
*
|
||||
* This function hides the unsafe 'dirs' and 'system' subcommands of
|
||||
* the "encoding" Tcl command ensemble. It must be called only from
|
||||
* TclHideUnsafeCommands.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result
|
||||
*
|
||||
* Side effects:
|
||||
* Adds commands to the table of hidden commands.
|
||||
*
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
TclMakeEncodingCommandSafe(
|
||||
Tcl_Interp* interp) /* Tcl interpreter */
|
||||
{
|
||||
static const struct {
|
||||
const char *cmdName;
|
||||
int unsafe;
|
||||
} unsafeInfo[] = {
|
||||
{"convertfrom", 0},
|
||||
{"convertto", 0},
|
||||
{"dirs", 1},
|
||||
{"names", 0},
|
||||
{"system", 0},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
int i;
|
||||
Tcl_DString oldBuf, newBuf;
|
||||
|
||||
Tcl_DStringInit(&oldBuf);
|
||||
TclDStringAppendLiteral(&oldBuf, "::tcl::encoding::");
|
||||
Tcl_DStringInit(&newBuf);
|
||||
TclDStringAppendLiteral(&newBuf, "tcl:encoding:");
|
||||
for (i=0 ; unsafeInfo[i].cmdName != NULL ; i++) {
|
||||
if (unsafeInfo[i].unsafe) {
|
||||
const char *oldName, *newName;
|
||||
|
||||
Tcl_DStringSetLength(&oldBuf, 17);
|
||||
oldName = Tcl_DStringAppend(&oldBuf, unsafeInfo[i].cmdName, -1);
|
||||
Tcl_DStringSetLength(&newBuf, 13);
|
||||
newName = Tcl_DStringAppend(&newBuf, unsafeInfo[i].cmdName, -1);
|
||||
if (TclRenameCommand(interp, oldName, "___tmp") != TCL_OK
|
||||
|| Tcl_HideCommand(interp, "___tmp", newName) != TCL_OK) {
|
||||
Tcl_Panic("problem making 'encoding %s' safe: %s",
|
||||
unsafeInfo[i].cmdName,
|
||||
Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
Tcl_CreateObjCommand(interp, oldName, BadEncodingSubcommand,
|
||||
(ClientData) unsafeInfo[i].cmdName, NULL);
|
||||
}
|
||||
}
|
||||
Tcl_DStringFree(&oldBuf);
|
||||
Tcl_DStringFree(&newBuf);
|
||||
|
||||
/*
|
||||
* Ugh. The [encoding] command is now actually safe, but it is assumed by
|
||||
* scripts that it is not, which messes up security policies.
|
||||
*/
|
||||
|
||||
if (Tcl_HideCommand(interp, "encoding", "encoding") != TCL_OK) {
|
||||
Tcl_Panic("problem making 'encoding' safe: %s",
|
||||
Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* BadEncodingSubcommand --
|
||||
*
|
||||
* Command used to act as a backstop implementation when subcommands of
|
||||
* "encoding" are unsafe (the real implementations of the subcommands are
|
||||
* hidden). The clientData is always the full official subcommand name.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result (always a TCL_ERROR).
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
BadEncodingSubcommand(
|
||||
ClientData clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *const objv[])
|
||||
{
|
||||
const char *subcommandName = (const char *) clientData;
|
||||
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"not allowed to invoke subcommand %s of encoding", subcommandName));
|
||||
Tcl_SetErrorCode(interp, "TCL", "SAFE", "SUBCOMMAND", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
@@ -1231,180 +1063,45 @@ TclInitFileCmd(
|
||||
*/
|
||||
|
||||
static const EnsembleImplMap initMap[] = {
|
||||
{"atime", FileAttrAccessTimeCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 0},
|
||||
{"attributes", TclFileAttrsCmd, NULL, NULL, NULL, 0},
|
||||
{"atime", FileAttrAccessTimeCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 1},
|
||||
{"attributes", TclFileAttrsCmd, NULL, NULL, NULL, 1},
|
||||
{"channels", TclChannelNamesCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
|
||||
{"copy", TclFileCopyCmd, NULL, NULL, NULL, 0},
|
||||
{"delete", TclFileDeleteCmd, TclCompileBasicMin0ArgCmd, NULL, NULL, 0},
|
||||
{"dirname", PathDirNameCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"executable", FileAttrIsExecutableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"exists", FileAttrIsExistingCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"extension", PathExtensionCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"isdirectory", FileAttrIsDirectoryCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"isfile", FileAttrIsFileCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"copy", TclFileCopyCmd, NULL, NULL, NULL, 1},
|
||||
{"delete", TclFileDeleteCmd, TclCompileBasicMin0ArgCmd, NULL, NULL, 1},
|
||||
{"dirname", PathDirNameCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"executable", FileAttrIsExecutableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"exists", FileAttrIsExistingCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"extension", PathExtensionCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"isdirectory", FileAttrIsDirectoryCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"isfile", FileAttrIsFileCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"join", PathJoinCmd, TclCompileBasicMin1ArgCmd, NULL, NULL, 0},
|
||||
{"link", TclFileLinkCmd, TclCompileBasic1To3ArgCmd, NULL, NULL, 0},
|
||||
{"lstat", FileAttrLinkStatCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0},
|
||||
{"mtime", FileAttrModifyTimeCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 0},
|
||||
{"mkdir", TclFileMakeDirsCmd, TclCompileBasicMin0ArgCmd, NULL, NULL, 0},
|
||||
{"nativename", PathNativeNameCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"normalize", PathNormalizeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"owned", FileAttrIsOwnedCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"link", TclFileLinkCmd, TclCompileBasic1To3ArgCmd, NULL, NULL, 1},
|
||||
{"lstat", FileAttrLinkStatCmd, TclCompileBasic2ArgCmd, NULL, NULL, 1},
|
||||
{"mtime", FileAttrModifyTimeCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 1},
|
||||
{"mkdir", TclFileMakeDirsCmd, TclCompileBasicMin0ArgCmd, NULL, NULL, 1},
|
||||
{"nativename", PathNativeNameCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"normalize", PathNormalizeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"owned", FileAttrIsOwnedCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"pathtype", PathTypeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"readable", FileAttrIsReadableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"readlink", TclFileReadLinkCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"rename", TclFileRenameCmd, NULL, NULL, NULL, 0},
|
||||
{"rootname", PathRootNameCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"readable", FileAttrIsReadableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"readlink", TclFileReadLinkCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"rename", TclFileRenameCmd, NULL, NULL, NULL, 1},
|
||||
{"rootname", PathRootNameCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"separator", FilesystemSeparatorCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
|
||||
{"size", FileAttrSizeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"size", FileAttrSizeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"split", PathSplitCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"stat", FileAttrStatCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0},
|
||||
{"stat", FileAttrStatCmd, TclCompileBasic2ArgCmd, NULL, NULL, 1},
|
||||
{"system", PathFilesystemCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
|
||||
{"tail", PathTailCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"tempfile", TclFileTemporaryCmd, TclCompileBasic0To2ArgCmd, NULL, NULL, 0},
|
||||
{"type", FileAttrTypeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"volumes", FilesystemVolumesCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0},
|
||||
{"writable", FileAttrIsWritableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"tail", PathTailCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"tempfile", TclFileTemporaryCmd, TclCompileBasic0To2ArgCmd, NULL, NULL, 1},
|
||||
{"type", FileAttrTypeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"volumes", FilesystemVolumesCmd, TclCompileBasic0ArgCmd, NULL, NULL, 1},
|
||||
{"writable", FileAttrIsWritableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{NULL, NULL, NULL, NULL, NULL, 0}
|
||||
};
|
||||
return TclMakeEnsemble(interp, "file", initMap);
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclMakeFileCommandSafe --
|
||||
*
|
||||
* This function hides the unsafe subcommands of the "file" Tcl command
|
||||
* ensemble. It must only be called from TclHideUnsafeCommands.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result.
|
||||
*
|
||||
* Side effects:
|
||||
* Adds commands to the table of hidden commands.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
TclMakeFileCommandSafe(
|
||||
Tcl_Interp *interp)
|
||||
{
|
||||
static const struct {
|
||||
const char *cmdName;
|
||||
int unsafe;
|
||||
} unsafeInfo[] = {
|
||||
{"atime", 1},
|
||||
{"attributes", 1},
|
||||
{"channels", 0},
|
||||
{"copy", 1},
|
||||
{"delete", 1},
|
||||
{"dirname", 1},
|
||||
{"executable", 1},
|
||||
{"exists", 1},
|
||||
{"extension", 1},
|
||||
{"isdirectory", 1},
|
||||
{"isfile", 1},
|
||||
{"join", 0},
|
||||
{"link", 1},
|
||||
{"lstat", 1},
|
||||
{"mtime", 1},
|
||||
{"mkdir", 1},
|
||||
{"nativename", 1},
|
||||
{"normalize", 1},
|
||||
{"owned", 1},
|
||||
{"pathtype", 0},
|
||||
{"readable", 1},
|
||||
{"readlink", 1},
|
||||
{"rename", 1},
|
||||
{"rootname", 1},
|
||||
{"separator", 0},
|
||||
{"size", 1},
|
||||
{"split", 0},
|
||||
{"stat", 1},
|
||||
{"system", 0},
|
||||
{"tail", 1},
|
||||
{"tempfile", 1},
|
||||
{"type", 1},
|
||||
{"volumes", 1},
|
||||
{"writable", 1},
|
||||
{NULL, 0}
|
||||
};
|
||||
int i;
|
||||
Tcl_DString oldBuf, newBuf;
|
||||
|
||||
Tcl_DStringInit(&oldBuf);
|
||||
TclDStringAppendLiteral(&oldBuf, "::tcl::file::");
|
||||
Tcl_DStringInit(&newBuf);
|
||||
TclDStringAppendLiteral(&newBuf, "tcl:file:");
|
||||
for (i=0 ; unsafeInfo[i].cmdName != NULL ; i++) {
|
||||
if (unsafeInfo[i].unsafe) {
|
||||
const char *oldName, *newName;
|
||||
|
||||
Tcl_DStringSetLength(&oldBuf, 13);
|
||||
oldName = Tcl_DStringAppend(&oldBuf, unsafeInfo[i].cmdName, -1);
|
||||
Tcl_DStringSetLength(&newBuf, 9);
|
||||
newName = Tcl_DStringAppend(&newBuf, unsafeInfo[i].cmdName, -1);
|
||||
if (TclRenameCommand(interp, oldName, "___tmp") != TCL_OK
|
||||
|| Tcl_HideCommand(interp, "___tmp", newName) != TCL_OK) {
|
||||
Tcl_Panic("problem making 'file %s' safe: %s",
|
||||
unsafeInfo[i].cmdName,
|
||||
Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
Tcl_CreateObjCommand(interp, oldName, BadFileSubcommand,
|
||||
(ClientData) unsafeInfo[i].cmdName, NULL);
|
||||
}
|
||||
}
|
||||
Tcl_DStringFree(&oldBuf);
|
||||
Tcl_DStringFree(&newBuf);
|
||||
|
||||
/*
|
||||
* Ugh. The [file] command is now actually safe, but it is assumed by
|
||||
* scripts that it is not, which messes up security policies. [Bug
|
||||
* 3211758]
|
||||
*/
|
||||
|
||||
if (Tcl_HideCommand(interp, "file", "file") != TCL_OK) {
|
||||
Tcl_Panic("problem making 'file' safe: %s",
|
||||
Tcl_GetString(Tcl_GetObjResult(interp)));
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* BadFileSubcommand --
|
||||
*
|
||||
* Command used to act as a backstop implementation when subcommands of
|
||||
* "file" are unsafe (the real implementations of the subcommands are
|
||||
* hidden). The clientData is always the full official subcommand name.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result (always a TCL_ERROR).
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
BadFileSubcommand(
|
||||
ClientData clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *const objv[])
|
||||
{
|
||||
const char *subcommandName = (const char *) clientData;
|
||||
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"not allowed to invoke subcommand %s of file", subcommandName));
|
||||
Tcl_SetErrorCode(interp, "TCL", "SAFE", "SUBCOMMAND", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
@@ -1455,9 +1152,9 @@ FileAttrAccessTimeCmd(
|
||||
* platforms. [Bug 698146]
|
||||
*/
|
||||
|
||||
long newTime;
|
||||
Tcl_WideInt newTime;
|
||||
|
||||
if (TclGetLongFromObj(interp, objv[2], &newTime) != TCL_OK) {
|
||||
if (TclGetWideIntFromObj(interp, objv[2], &newTime) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
@@ -1536,9 +1233,9 @@ FileAttrModifyTimeCmd(
|
||||
* platforms. [Bug 698146]
|
||||
*/
|
||||
|
||||
long newTime;
|
||||
Tcl_WideInt newTime;
|
||||
|
||||
if (TclGetLongFromObj(interp, objv[2], &newTime) != TCL_OK) {
|
||||
if (TclGetWideIntFromObj(interp, objv[2], &newTime) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
+63
-17
@@ -138,6 +138,8 @@ static int InfoScriptCmd(ClientData dummy, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *const objv[]);
|
||||
static int InfoSharedlibCmd(ClientData dummy, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *const objv[]);
|
||||
static int InfoCmdTypeCmd(ClientData dummy, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *const objv[]);
|
||||
static int InfoTclVersionCmd(ClientData dummy, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *const objv[]);
|
||||
static SortElement * MergeLists(SortElement *leftPtr, SortElement *rightPtr,
|
||||
@@ -156,6 +158,7 @@ static const EnsembleImplMap defaultInfoMap[] = {
|
||||
{"args", InfoArgsCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"body", InfoBodyCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"cmdcount", InfoCmdCountCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0},
|
||||
{"cmdtype", InfoCmdTypeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1},
|
||||
{"commands", InfoCommandsCmd, TclCompileInfoCommandsCmd, NULL, NULL, 0},
|
||||
{"complete", InfoCompleteCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0},
|
||||
{"coroutine", TclInfoCoroutineCmd, TclCompileInfoCoroutineCmd, NULL, NULL, 0},
|
||||
@@ -170,7 +173,7 @@ static const EnsembleImplMap defaultInfoMap[] = {
|
||||
{"library", InfoLibraryCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0},
|
||||
{"loaded", InfoLoadedCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
|
||||
{"locals", TclInfoLocalsCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
|
||||
{"nameofexecutable", InfoNameOfExecutableCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0},
|
||||
{"nameofexecutable", InfoNameOfExecutableCmd, TclCompileBasic0ArgCmd, NULL, NULL, 1},
|
||||
{"patchlevel", InfoPatchLevelCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0},
|
||||
{"procs", InfoProcsCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
|
||||
{"script", InfoScriptCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0},
|
||||
@@ -2129,6 +2132,60 @@ InfoTclVersionCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* InfoCmdTypeCmd --
|
||||
*
|
||||
* Called to implement the "info cmdtype" command that returns the type
|
||||
* of a given command. Handles the following syntax:
|
||||
*
|
||||
* info cmdtype cmdName
|
||||
*
|
||||
* Results:
|
||||
* Returns TCL_OK if successful and TCL_ERROR if there is an error.
|
||||
*
|
||||
* Side effects:
|
||||
* Returns a type name. If there is an error, the result is an error
|
||||
* message.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
InfoCmdTypeCmd(
|
||||
ClientData dummy, /* Not used. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
Tcl_Command command;
|
||||
|
||||
if (objc != 2) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "commandName");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
command = Tcl_FindCommand(interp, Tcl_GetString(objv[1]), NULL,
|
||||
TCL_LEAVE_ERR_MSG);
|
||||
if (command == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* There's one special case: safe slave interpreters can't see aliases as
|
||||
* aliases as they're part of the security mechanisms.
|
||||
*/
|
||||
|
||||
if (Tcl_IsSafe(interp)
|
||||
&& (((Command *) command)->objProc == TclAliasObjCmd)) {
|
||||
Tcl_AppendResult(interp, "native", NULL);
|
||||
} else {
|
||||
Tcl_SetObjResult(interp,
|
||||
Tcl_NewStringObj(TclGetCommandTypeName(command), -1));
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
@@ -2730,21 +2787,10 @@ Tcl_LreplaceObjCmd(
|
||||
if (first < 0) {
|
||||
first = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Complain if the user asked for a start element that is greater than the
|
||||
* list length. This won't ever trigger for the "end-*" case as that will
|
||||
* be properly constrained by TclGetIntForIndex because we use listLen-1
|
||||
* (to allow for replacing the last elem).
|
||||
*/
|
||||
|
||||
if ((first >= listLen) && (listLen > 0)) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"list doesn't contain element %s", TclGetString(objv[2])));
|
||||
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LREPLACE", "BADIDX",
|
||||
NULL);
|
||||
return TCL_ERROR;
|
||||
if (first > listLen) {
|
||||
first = listLen;
|
||||
}
|
||||
|
||||
if (last >= listLen) {
|
||||
last = listLen - 1;
|
||||
}
|
||||
@@ -3333,7 +3379,7 @@ Tcl_LsearchObjCmd(
|
||||
* sense in doing this when the match sense is inverted.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* With -stride, lower, upper and i are kept as multiples of groupSize.
|
||||
*/
|
||||
|
||||
@@ -4015,7 +4061,7 @@ Tcl_LsortObjCmd(
|
||||
/*
|
||||
* Do not shrink the actual memory block used; that doesn't
|
||||
* work with TclStackAlloc-allocated memory. [Bug 2918962]
|
||||
*
|
||||
*
|
||||
* TODO: Consider a pointer increment to replace this
|
||||
* array shift.
|
||||
*/
|
||||
|
||||
+52
-186
@@ -258,7 +258,7 @@ Tcl_RegexpObjCmd(
|
||||
stringLength = Tcl_GetCharLength(objPtr);
|
||||
|
||||
if (startIndex) {
|
||||
TclGetIntForIndexM(NULL, startIndex, stringLength, &offset);
|
||||
TclGetIntForIndexM(interp, startIndex, stringLength, &offset);
|
||||
Tcl_DecrRefCount(startIndex);
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
@@ -582,7 +582,7 @@ Tcl_RegsubObjCmd(
|
||||
if (startIndex) {
|
||||
int stringLength = Tcl_GetCharLength(objv[1]);
|
||||
|
||||
TclGetIntForIndexM(NULL, startIndex, stringLength, &offset);
|
||||
TclGetIntForIndexM(interp, startIndex, stringLength, &offset);
|
||||
Tcl_DecrRefCount(startIndex);
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
@@ -597,9 +597,9 @@ Tcl_RegsubObjCmd(
|
||||
* slightly modified version of the one pair STR_MAP code.
|
||||
*/
|
||||
|
||||
int slen, nocase;
|
||||
int slen, nocase, wsrclc;
|
||||
int (*strCmpFn)(const Tcl_UniChar*,const Tcl_UniChar*,unsigned long);
|
||||
Tcl_UniChar *p, wsrclc;
|
||||
Tcl_UniChar *p;
|
||||
|
||||
numMatches = 0;
|
||||
nocase = (cflags & TCL_REG_NOCASE);
|
||||
@@ -1447,6 +1447,9 @@ StringIndexCmd(
|
||||
char buf[4];
|
||||
|
||||
length = Tcl_UniCharToUtf(ch, buf);
|
||||
if (!length) {
|
||||
length = Tcl_UniCharToUtf(-1, buf);
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, length));
|
||||
}
|
||||
}
|
||||
@@ -1620,10 +1623,6 @@ StringIsCmd(
|
||||
chcomp = Tcl_UniCharIsGraph;
|
||||
break;
|
||||
case STR_IS_INT:
|
||||
if (TCL_OK == TclGetIntFromObj(NULL, objPtr, &i)) {
|
||||
break;
|
||||
}
|
||||
goto failedIntParse;
|
||||
case STR_IS_ENTIER:
|
||||
if ((objPtr->typePtr == &tclIntType) ||
|
||||
(objPtr->typePtr == &tclBignumType)) {
|
||||
@@ -1671,7 +1670,6 @@ StringIsCmd(
|
||||
break;
|
||||
}
|
||||
|
||||
failedIntParse:
|
||||
string1 = TclGetStringFromObj(objPtr, &length1);
|
||||
if (length1 == 0) {
|
||||
if (strict) {
|
||||
@@ -1846,7 +1844,7 @@ static int
|
||||
UniCharIsHexDigit(
|
||||
int character)
|
||||
{
|
||||
return (character >= 0) && (character < 0x80) && isxdigit(character);
|
||||
return (character >= 0) && (character < 0x80) && isxdigit(UCHAR(character));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2001,8 +1999,8 @@ StringMapCmd(
|
||||
* larger strings.
|
||||
*/
|
||||
|
||||
int mapLen;
|
||||
Tcl_UniChar *mapString, u2lc;
|
||||
int mapLen, u2lc;
|
||||
Tcl_UniChar *mapString;
|
||||
|
||||
ustring2 = Tcl_GetUnicodeFromObj(mapElemv[0], &length2);
|
||||
p = ustring1;
|
||||
@@ -2033,8 +2031,8 @@ StringMapCmd(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Tcl_UniChar **mapStrings, *u2lc = NULL;
|
||||
int *mapLens;
|
||||
Tcl_UniChar **mapStrings;
|
||||
int *mapLens, *u2lc = NULL;
|
||||
|
||||
/*
|
||||
* Precompute pointers to the unicode string and length. This saves us
|
||||
@@ -2046,7 +2044,7 @@ StringMapCmd(
|
||||
mapStrings = TclStackAlloc(interp, mapElemc*2*sizeof(Tcl_UniChar *));
|
||||
mapLens = TclStackAlloc(interp, mapElemc * 2 * sizeof(int));
|
||||
if (nocase) {
|
||||
u2lc = TclStackAlloc(interp, mapElemc * sizeof(Tcl_UniChar));
|
||||
u2lc = TclStackAlloc(interp, mapElemc * sizeof(int));
|
||||
}
|
||||
for (index = 0; index < mapElemc; index++) {
|
||||
mapStrings[index] = Tcl_GetUnicodeFromObj(mapElemv[index],
|
||||
@@ -2546,10 +2544,8 @@ StringEqualCmd(
|
||||
* the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...).
|
||||
*/
|
||||
|
||||
const char *string1, *string2;
|
||||
int length1, length2, i, match, length, nocase = 0, reqlength = -1;
|
||||
typedef int (*strCmpFn_t)(const char *, const char *, unsigned int);
|
||||
strCmpFn_t strCmpFn;
|
||||
const char *string2;
|
||||
int length, i, match, nocase = 0, reqlength = -1;
|
||||
|
||||
if (objc < 3 || objc > 6) {
|
||||
str_cmp_args:
|
||||
@@ -2559,11 +2555,11 @@ StringEqualCmd(
|
||||
}
|
||||
|
||||
for (i = 1; i < objc-2; i++) {
|
||||
string2 = TclGetStringFromObj(objv[i], &length2);
|
||||
if ((length2 > 1) && !strncmp(string2, "-nocase", (size_t)length2)) {
|
||||
string2 = TclGetStringFromObj(objv[i], &length);
|
||||
if ((length > 1) && !strncmp(string2, "-nocase", (size_t)length)) {
|
||||
nocase = 1;
|
||||
} else if ((length2 > 1)
|
||||
&& !strncmp(string2, "-length", (size_t)length2)) {
|
||||
} else if ((length > 1)
|
||||
&& !strncmp(string2, "-length", (size_t)length)) {
|
||||
if (i+1 >= objc-2) {
|
||||
goto str_cmp_args;
|
||||
}
|
||||
@@ -2588,78 +2584,7 @@ StringEqualCmd(
|
||||
|
||||
objv += objc-2;
|
||||
|
||||
if ((reqlength == 0) || (objv[0] == objv[1])) {
|
||||
/*
|
||||
* Always match at 0 chars of if it is the same obj.
|
||||
*/
|
||||
|
||||
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(1));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
if (!nocase && TclIsPureByteArray(objv[0]) &&
|
||||
TclIsPureByteArray(objv[1])) {
|
||||
/*
|
||||
* Use binary versions of comparisons since that won't cause undue
|
||||
* type conversions and it is much faster. Only do this if we're
|
||||
* case-sensitive (which is all that really makes sense with byte
|
||||
* arrays anyway, and we have no memcasecmp() for some reason... :^)
|
||||
*/
|
||||
|
||||
string1 = (char *) Tcl_GetByteArrayFromObj(objv[0], &length1);
|
||||
string2 = (char *) Tcl_GetByteArrayFromObj(objv[1], &length2);
|
||||
strCmpFn = (strCmpFn_t) memcmp;
|
||||
} else if ((objv[0]->typePtr == &tclStringType)
|
||||
&& (objv[1]->typePtr == &tclStringType)) {
|
||||
/*
|
||||
* Do a unicode-specific comparison if both of the args are of String
|
||||
* type. In benchmark testing this proved the most efficient check
|
||||
* between the unicode and string comparison operations.
|
||||
*/
|
||||
|
||||
string1 = (char *) Tcl_GetUnicodeFromObj(objv[0], &length1);
|
||||
string2 = (char *) Tcl_GetUnicodeFromObj(objv[1], &length2);
|
||||
strCmpFn = (strCmpFn_t)
|
||||
(nocase ? Tcl_UniCharNcasecmp : Tcl_UniCharNcmp);
|
||||
} else {
|
||||
/*
|
||||
* As a catch-all we will work with UTF-8. We cannot use memcmp() as
|
||||
* that is unsafe with any string containing NUL (\xC0\x80 in Tcl's
|
||||
* utf rep). We can use the more efficient TclpUtfNcmp2 if we are
|
||||
* case-sensitive and no specific length was requested.
|
||||
*/
|
||||
|
||||
string1 = (char *) TclGetStringFromObj(objv[0], &length1);
|
||||
string2 = (char *) TclGetStringFromObj(objv[1], &length2);
|
||||
if ((reqlength < 0) && !nocase) {
|
||||
strCmpFn = (strCmpFn_t) TclpUtfNcmp2;
|
||||
} else {
|
||||
length1 = Tcl_NumUtfChars(string1, length1);
|
||||
length2 = Tcl_NumUtfChars(string2, length2);
|
||||
strCmpFn = (strCmpFn_t) (nocase ? Tcl_UtfNcasecmp : Tcl_UtfNcmp);
|
||||
}
|
||||
}
|
||||
|
||||
if ((reqlength < 0) && (length1 != length2)) {
|
||||
match = 1; /* This will be reversed below. */
|
||||
} else {
|
||||
length = (length1 < length2) ? length1 : length2;
|
||||
if (reqlength > 0 && reqlength < length) {
|
||||
length = reqlength;
|
||||
} else if (reqlength < 0) {
|
||||
/*
|
||||
* The requested length is negative, so we ignore it by setting it
|
||||
* to length + 1 so we correct the match var.
|
||||
*/
|
||||
|
||||
reqlength = length + 1;
|
||||
}
|
||||
|
||||
match = strCmpFn(string1, string2, (unsigned) length);
|
||||
if ((match == 0) && (reqlength > length)) {
|
||||
match = length1 - length2;
|
||||
}
|
||||
}
|
||||
match = TclStringCmp(objv[0], objv[1], 0, nocase, reqlength);
|
||||
|
||||
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(match ? 0 : 1));
|
||||
return TCL_OK;
|
||||
@@ -2696,11 +2621,31 @@ StringCmpCmd(
|
||||
* the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...).
|
||||
*/
|
||||
|
||||
const char *string1, *string2;
|
||||
int length1, length2, i, match, length, nocase = 0, reqlength = -1;
|
||||
typedef int (*strCmpFn_t)(const char *, const char *, unsigned int);
|
||||
strCmpFn_t strCmpFn;
|
||||
int match, nocase, reqlength, status;
|
||||
|
||||
status = TclStringCmpOpts(interp, objc, objv, &nocase, &reqlength);
|
||||
if (status != TCL_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
objv += objc-2;
|
||||
match = TclStringCmp(objv[0], objv[1], 0, nocase, reqlength);
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(match));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
int TclStringCmpOpts(
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[], /* Argument objects. */
|
||||
int *nocase,
|
||||
int *reqlength)
|
||||
{
|
||||
int i, length;
|
||||
const char *string;
|
||||
|
||||
*reqlength = -1;
|
||||
*nocase = 0;
|
||||
if (objc < 3 || objc > 6) {
|
||||
str_cmp_args:
|
||||
Tcl_WrongNumArgs(interp, 1, objv,
|
||||
@@ -2709,106 +2654,27 @@ StringCmpCmd(
|
||||
}
|
||||
|
||||
for (i = 1; i < objc-2; i++) {
|
||||
string2 = TclGetStringFromObj(objv[i], &length2);
|
||||
if ((length2 > 1) && !strncmp(string2, "-nocase", (size_t)length2)) {
|
||||
nocase = 1;
|
||||
} else if ((length2 > 1)
|
||||
&& !strncmp(string2, "-length", (size_t)length2)) {
|
||||
string = TclGetStringFromObj(objv[i], &length);
|
||||
if ((length > 1) && !strncmp(string, "-nocase", (size_t)length)) {
|
||||
*nocase = 1;
|
||||
} else if ((length > 1)
|
||||
&& !strncmp(string, "-length", (size_t)length)) {
|
||||
if (i+1 >= objc-2) {
|
||||
goto str_cmp_args;
|
||||
}
|
||||
i++;
|
||||
if (TclGetIntFromObj(interp, objv[i], &reqlength) != TCL_OK) {
|
||||
if (TclGetIntFromObj(interp, objv[i], reqlength) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
} else {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"bad option \"%s\": must be -nocase or -length",
|
||||
string2));
|
||||
string));
|
||||
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option",
|
||||
string2, NULL);
|
||||
string, NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* From now on, we only access the two objects at the end of the argument
|
||||
* array.
|
||||
*/
|
||||
|
||||
objv += objc-2;
|
||||
|
||||
if ((reqlength == 0) || (objv[0] == objv[1])) {
|
||||
/*
|
||||
* Always match at 0 chars of if it is the same obj.
|
||||
*/
|
||||
|
||||
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(0));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
if (!nocase && TclIsPureByteArray(objv[0]) &&
|
||||
TclIsPureByteArray(objv[1])) {
|
||||
/*
|
||||
* Use binary versions of comparisons since that won't cause undue
|
||||
* type conversions and it is much faster. Only do this if we're
|
||||
* case-sensitive (which is all that really makes sense with byte
|
||||
* arrays anyway, and we have no memcasecmp() for some reason... :^)
|
||||
*/
|
||||
|
||||
string1 = (char *) Tcl_GetByteArrayFromObj(objv[0], &length1);
|
||||
string2 = (char *) Tcl_GetByteArrayFromObj(objv[1], &length2);
|
||||
strCmpFn = (strCmpFn_t) memcmp;
|
||||
} else if ((objv[0]->typePtr == &tclStringType)
|
||||
&& (objv[1]->typePtr == &tclStringType)) {
|
||||
/*
|
||||
* Do a unicode-specific comparison if both of the args are of String
|
||||
* type. In benchmark testing this proved the most efficient check
|
||||
* between the unicode and string comparison operations.
|
||||
*/
|
||||
|
||||
string1 = (char *) Tcl_GetUnicodeFromObj(objv[0], &length1);
|
||||
string2 = (char *) Tcl_GetUnicodeFromObj(objv[1], &length2);
|
||||
strCmpFn = (strCmpFn_t)
|
||||
(nocase ? Tcl_UniCharNcasecmp : Tcl_UniCharNcmp);
|
||||
} else {
|
||||
/*
|
||||
* As a catch-all we will work with UTF-8. We cannot use memcmp() as
|
||||
* that is unsafe with any string containing NUL (\xC0\x80 in Tcl's
|
||||
* utf rep). We can use the more efficient TclpUtfNcmp2 if we are
|
||||
* case-sensitive and no specific length was requested.
|
||||
*/
|
||||
|
||||
string1 = (char *) TclGetStringFromObj(objv[0], &length1);
|
||||
string2 = (char *) TclGetStringFromObj(objv[1], &length2);
|
||||
if ((reqlength < 0) && !nocase) {
|
||||
strCmpFn = (strCmpFn_t) TclpUtfNcmp2;
|
||||
} else {
|
||||
length1 = Tcl_NumUtfChars(string1, length1);
|
||||
length2 = Tcl_NumUtfChars(string2, length2);
|
||||
strCmpFn = (strCmpFn_t) (nocase ? Tcl_UtfNcasecmp : Tcl_UtfNcmp);
|
||||
}
|
||||
}
|
||||
|
||||
length = (length1 < length2) ? length1 : length2;
|
||||
if (reqlength > 0 && reqlength < length) {
|
||||
length = reqlength;
|
||||
} else if (reqlength < 0) {
|
||||
/*
|
||||
* The requested length is negative, so we ignore it by setting it to
|
||||
* length + 1 so we correct the match var.
|
||||
*/
|
||||
|
||||
reqlength = length + 1;
|
||||
}
|
||||
|
||||
match = strCmpFn(string1, string2, (unsigned) length);
|
||||
if ((match == 0) && (reqlength > length)) {
|
||||
match = length1 - length2;
|
||||
}
|
||||
|
||||
Tcl_SetObjResult(interp,
|
||||
Tcl_NewIntObj((match > 0) ? 1 : (match < 0) ? -1 : 0));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
+28
-77
@@ -27,7 +27,6 @@ static void CompileReturnInternal(CompileEnv *envPtr,
|
||||
Tcl_Obj *returnOpts);
|
||||
static int IndexTailVarIfKnown(Tcl_Interp *interp,
|
||||
Tcl_Token *varTokenPtr, CompileEnv *envPtr);
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -35,7 +34,7 @@ static int IndexTailVarIfKnown(Tcl_Interp *interp,
|
||||
* TclGetIndexFromToken --
|
||||
*
|
||||
* Parse a token to determine if an index value is known at
|
||||
* compile time.
|
||||
* compile time.
|
||||
*
|
||||
* Returns:
|
||||
* TCL_OK if parsing succeeded, and TCL_ERROR if it failed.
|
||||
@@ -127,9 +126,12 @@ TclCompileGlobalCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/* TODO: Consider what value can pass through the
|
||||
* IndexTailVarIfKnown() screen. Full CompileWord()
|
||||
* likely does not apply here. Push known value instead. */
|
||||
/*
|
||||
* TODO: Consider what value can pass through the
|
||||
* IndexTailVarIfKnown() screen. Full CompileWord() likely does not
|
||||
* apply here. Push known value instead.
|
||||
*/
|
||||
|
||||
CompileWord(envPtr, varTokenPtr, interp, i);
|
||||
TclEmitInstInt4( INST_NSUPVAR, localIndex, envPtr);
|
||||
}
|
||||
@@ -270,7 +272,7 @@ TclCompileIfCmd(
|
||||
jumpIndex = jumpFalseFixupArray.next;
|
||||
jumpFalseFixupArray.next++;
|
||||
TclEmitForwardJump(envPtr, TCL_FALSE_JUMP,
|
||||
jumpFalseFixupArray.fixup+jumpIndex);
|
||||
jumpFalseFixupArray.fixup + jumpIndex);
|
||||
}
|
||||
code = TCL_OK;
|
||||
}
|
||||
@@ -317,7 +319,7 @@ TclCompileIfCmd(
|
||||
}
|
||||
jumpEndFixupArray.next++;
|
||||
TclEmitForwardJump(envPtr, TCL_UNCONDITIONAL_JUMP,
|
||||
jumpEndFixupArray.fixup+jumpIndex);
|
||||
jumpEndFixupArray.fixup + jumpIndex);
|
||||
|
||||
/*
|
||||
* Fix the target of the jumpFalse after the test. Generate a 4
|
||||
@@ -329,7 +331,7 @@ TclCompileIfCmd(
|
||||
|
||||
TclAdjustStackDepth(-1, envPtr);
|
||||
if (TclFixupForwardJumpToHere(envPtr,
|
||||
jumpFalseFixupArray.fixup+jumpIndex, 120)) {
|
||||
jumpFalseFixupArray.fixup + jumpIndex, 120)) {
|
||||
/*
|
||||
* Adjust the code offset for the proceeding jump to the end
|
||||
* of the "if" command.
|
||||
@@ -412,7 +414,7 @@ TclCompileIfCmd(
|
||||
for (j = jumpEndFixupArray.next; j > 0; j--) {
|
||||
jumpIndex = (j - 1); /* i.e. process the closest jump first. */
|
||||
if (TclFixupForwardJumpToHere(envPtr,
|
||||
jumpEndFixupArray.fixup+jumpIndex, 127)) {
|
||||
jumpEndFixupArray.fixup + jumpIndex, 127)) {
|
||||
/*
|
||||
* Adjust the immediately preceeding "ifFalse" jump. We moved it's
|
||||
* target (just after this jump) down three bytes.
|
||||
@@ -920,7 +922,7 @@ TclCompileLappendCmd(
|
||||
CompileWord(envPtr, valueTokenPtr, interp, i);
|
||||
valueTokenPtr = TokenAfter(valueTokenPtr);
|
||||
}
|
||||
TclEmitInstInt4( INST_LIST, numWords-2, envPtr);
|
||||
TclEmitInstInt4( INST_LIST, numWords - 2, envPtr);
|
||||
if (isScalar) {
|
||||
if (localIndex < 0) {
|
||||
TclEmitOpcode( INST_LAPPEND_LIST_STK, envPtr);
|
||||
@@ -997,7 +999,7 @@ TclCompileLassignCmd(
|
||||
*/
|
||||
|
||||
PushVarNameWord(interp, tokenPtr, envPtr, 0, &localIndex,
|
||||
&isScalar, idx+2);
|
||||
&isScalar, idx + 2);
|
||||
|
||||
/*
|
||||
* Emit instructions to get the idx'th item out of the list value on
|
||||
@@ -1414,7 +1416,7 @@ TclCompileLinsertCmd(
|
||||
tokenPtr = TokenAfter(tokenPtr);
|
||||
CompileWord(envPtr, tokenPtr, interp, i);
|
||||
}
|
||||
TclEmitInstInt4( INST_LIST, i-3, envPtr);
|
||||
TclEmitInstInt4( INST_LIST, i - 3, envPtr);
|
||||
|
||||
if (idx == TCL_INDEX_START) {
|
||||
TclEmitInstInt4( INST_REVERSE, 2, envPtr);
|
||||
@@ -1439,7 +1441,7 @@ TclCompileLinsertCmd(
|
||||
}
|
||||
TclEmitInstInt4( INST_OVER, 1, envPtr);
|
||||
TclEmitInstInt4( INST_LIST_RANGE_IMM, 0, envPtr);
|
||||
TclEmitInt4( idx-1, envPtr);
|
||||
TclEmitInt4( idx - 1, envPtr);
|
||||
TclEmitInstInt4( INST_REVERSE, 3, envPtr);
|
||||
TclEmitInstInt4( INST_LIST_RANGE_IMM, idx, envPtr);
|
||||
TclEmitInt4( TCL_INDEX_END, envPtr);
|
||||
@@ -1472,7 +1474,7 @@ TclCompileLreplaceCmd(
|
||||
{
|
||||
Tcl_Token *tokenPtr, *listTokenPtr;
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
int idx1, idx2, i, offset, offset2;
|
||||
int idx1, idx2, i;
|
||||
int emptyPrefix=1, suffixStart = 0;
|
||||
|
||||
if (parsePtr->numWords < 4) {
|
||||
@@ -1492,23 +1494,6 @@ TclCompileLreplaceCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* idx1, idx2 are the conventional encoded forms of the tokens parsed
|
||||
* as all forms of index values. Values of idx1 that come before the
|
||||
* list are treated the same as if they were the start of the list.
|
||||
* Values of idx2 that come after the list are treated the same as if
|
||||
* they were the end of the list.
|
||||
*/
|
||||
|
||||
if (idx1 == TCL_INDEX_AFTER) {
|
||||
/*
|
||||
* [lreplace] treats idx1 value end+1 differently from end+2, etc.
|
||||
* The operand encoding cannot distinguish them, so we must bail
|
||||
* out to direct evaluation.
|
||||
*/
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* General structure of the [lreplace] result is
|
||||
* prefix replacement suffix
|
||||
@@ -1520,7 +1505,9 @@ TclCompileLreplaceCmd(
|
||||
* we must defer to direct evaluation.
|
||||
*/
|
||||
|
||||
if (idx2 == TCL_INDEX_BEFORE) {
|
||||
if (idx1 == TCL_INDEX_AFTER) {
|
||||
suffixStart = idx1;
|
||||
} else if (idx2 == TCL_INDEX_BEFORE) {
|
||||
suffixStart = idx1;
|
||||
} else if (idx2 == TCL_INDEX_END) {
|
||||
suffixStart = TCL_INDEX_AFTER;
|
||||
@@ -1551,42 +1538,6 @@ TclCompileLreplaceCmd(
|
||||
|
||||
emptyPrefix = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* [lreplace] raises an error when idx1 points after the list, but
|
||||
* only when the list is not empty. This is maximum stupidity.
|
||||
*
|
||||
* TODO: TIP this nonsense away!
|
||||
*/
|
||||
if (idx1 >= TCL_INDEX_START) {
|
||||
if (emptyPrefix) {
|
||||
TclEmitOpcode( INST_DUP, envPtr);
|
||||
} else {
|
||||
TclEmitInstInt4( INST_OVER, 1, envPtr);
|
||||
}
|
||||
TclEmitOpcode( INST_LIST_LENGTH, envPtr);
|
||||
TclEmitOpcode( INST_DUP, envPtr);
|
||||
offset = CurrentOffset(envPtr);
|
||||
TclEmitInstInt1( INST_JUMP_FALSE1, 0, envPtr);
|
||||
|
||||
/* List is not empty */
|
||||
TclEmitPush(TclAddLiteralObj(envPtr, Tcl_NewIntObj(idx1),
|
||||
NULL), envPtr);
|
||||
TclEmitOpcode( INST_GT, envPtr);
|
||||
offset2 = CurrentOffset(envPtr);
|
||||
TclEmitInstInt1( INST_JUMP_TRUE1, 0, envPtr);
|
||||
|
||||
/* Idx1 >= list length ===> raise an error */
|
||||
TclEmitPush(TclAddLiteralObj(envPtr, Tcl_ObjPrintf(
|
||||
"list doesn't contain element %d", idx1), NULL), envPtr);
|
||||
CompileReturnInternal(envPtr, INST_RETURN_IMM, TCL_ERROR, 0,
|
||||
Tcl_ObjPrintf("-errorcode {TCL OPERATION LREPLACE BADIDX}"));
|
||||
TclStoreInt1AtPtr(CurrentOffset(envPtr) - offset,
|
||||
envPtr->codeStart + offset + 1);
|
||||
TclEmitOpcode( INST_POP, envPtr);
|
||||
TclStoreInt1AtPtr(CurrentOffset(envPtr) - offset2,
|
||||
envPtr->codeStart + offset2 + 1);
|
||||
}
|
||||
|
||||
if ((idx1 == suffixStart) && (parsePtr->numWords == 4)) {
|
||||
/*
|
||||
@@ -2234,7 +2185,7 @@ TclCompileRegexpCmd(
|
||||
}
|
||||
|
||||
if (!simple) {
|
||||
CompileWord(envPtr, varTokenPtr, interp, parsePtr->numWords-2);
|
||||
CompileWord(envPtr, varTokenPtr, interp, parsePtr->numWords - 2);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2242,7 +2193,7 @@ TclCompileRegexpCmd(
|
||||
*/
|
||||
|
||||
varTokenPtr = TokenAfter(varTokenPtr);
|
||||
CompileWord(envPtr, varTokenPtr, interp, parsePtr->numWords-1);
|
||||
CompileWord(envPtr, varTokenPtr, interp, parsePtr->numWords - 1);
|
||||
|
||||
if (simple) {
|
||||
if (exact && !nocase) {
|
||||
@@ -2426,7 +2377,7 @@ TclCompileRegsubCmd(
|
||||
PushLiteral(envPtr, bytes, len);
|
||||
bytes = TclGetStringFromObj(replacementObj, &len);
|
||||
PushLiteral(envPtr, bytes, len);
|
||||
CompileWord(envPtr, stringTokenPtr, interp, parsePtr->numWords-2);
|
||||
CompileWord(envPtr, stringTokenPtr, interp, parsePtr->numWords - 2);
|
||||
TclEmitOpcode( INST_STR_MAP, envPtr);
|
||||
|
||||
done:
|
||||
@@ -2555,7 +2506,7 @@ TclCompileReturnCmd(
|
||||
*/
|
||||
|
||||
if (explicitResult) {
|
||||
CompileWord(envPtr, wordTokenPtr, interp, numWords-1);
|
||||
CompileWord(envPtr, wordTokenPtr, interp, numWords - 1);
|
||||
} else {
|
||||
/*
|
||||
* No explict result argument, so default result is empty string.
|
||||
@@ -2633,7 +2584,7 @@ TclCompileReturnCmd(
|
||||
*/
|
||||
|
||||
if (explicitResult) {
|
||||
CompileWord(envPtr, wordTokenPtr, interp, numWords-1);
|
||||
CompileWord(envPtr, wordTokenPtr, interp, numWords - 1);
|
||||
} else {
|
||||
PushStringLiteral(envPtr, "");
|
||||
}
|
||||
@@ -2864,12 +2815,12 @@ TclCompileVariableCmd(
|
||||
CompileWord(envPtr, varTokenPtr, interp, i);
|
||||
TclEmitInstInt4( INST_VARIABLE, localIndex, envPtr);
|
||||
|
||||
if (i+1 < numWords) {
|
||||
if (i + 1 < numWords) {
|
||||
/*
|
||||
* A value has been given: set the variable, pop the value
|
||||
*/
|
||||
|
||||
CompileWord(envPtr, valueTokenPtr, interp, i+1);
|
||||
CompileWord(envPtr, valueTokenPtr, interp, i + 1);
|
||||
Emit14Inst( INST_STORE_SCALAR, localIndex, envPtr);
|
||||
TclEmitOpcode( INST_POP, envPtr);
|
||||
}
|
||||
@@ -2945,7 +2896,7 @@ IndexTailVarIfKnown(
|
||||
tailName = TclGetStringFromObj(tailPtr, &len);
|
||||
|
||||
if (len) {
|
||||
if (*(tailName+len-1) == ')') {
|
||||
if (*(tailName + len - 1) == ')') {
|
||||
/*
|
||||
* Possible array: bail out
|
||||
*/
|
||||
@@ -2959,7 +2910,7 @@ IndexTailVarIfKnown(
|
||||
*/
|
||||
|
||||
for (p = tailName + len -1; p > tailName; p--) {
|
||||
if ((*p == ':') && (*(p-1) == ':')) {
|
||||
if ((*p == ':') && (*(p - 1) == ':')) {
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
|
||||
+9
-12
@@ -691,14 +691,11 @@ TclCompileStringIsCmd(
|
||||
}
|
||||
|
||||
switch (t) {
|
||||
case STR_IS_INT:
|
||||
PUSH( "1");
|
||||
OP( EQ);
|
||||
break;
|
||||
case STR_IS_WIDE:
|
||||
PUSH( "2");
|
||||
OP( LE);
|
||||
break;
|
||||
case STR_IS_INT:
|
||||
case STR_IS_ENTIER:
|
||||
PUSH( "3");
|
||||
OP( LE);
|
||||
@@ -1002,13 +999,13 @@ TclCompileStringReplaceCmd(
|
||||
if (parsePtr->numWords < 4 || parsePtr->numWords > 5) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* Bytecode to compute/push string argument being replaced */
|
||||
valueTokenPtr = TokenAfter(parsePtr->tokenPtr);
|
||||
CompileWord(envPtr, valueTokenPtr, interp, 1);
|
||||
|
||||
/*
|
||||
* Check for first index known and useful at compile time.
|
||||
* Check for first index known and useful at compile time.
|
||||
*/
|
||||
tokenPtr = TokenAfter(valueTokenPtr);
|
||||
if (TclGetIndexFromToken(tokenPtr, TCL_INDEX_BEFORE, TCL_INDEX_AFTER,
|
||||
@@ -1017,7 +1014,7 @@ TclCompileStringReplaceCmd(
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for last index known and useful at compile time.
|
||||
* Check for last index known and useful at compile time.
|
||||
*/
|
||||
tokenPtr = TokenAfter(tokenPtr);
|
||||
if (TclGetIndexFromToken(tokenPtr, TCL_INDEX_BEFORE, TCL_INDEX_AFTER,
|
||||
@@ -1025,7 +1022,7 @@ TclCompileStringReplaceCmd(
|
||||
goto genericReplace;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* [string replace] is an odd bird. For many arguments it is
|
||||
* a conventional substring replacer. However it also goes out
|
||||
* of its way to become a no-op for many cases where it would be
|
||||
@@ -1108,12 +1105,12 @@ TclCompileStringReplaceCmd(
|
||||
* Finally we need, third:
|
||||
*
|
||||
* (first <= last)
|
||||
*
|
||||
*
|
||||
* Considered in combination with the constraints we already have,
|
||||
* we see that we can proceed when (first == TCL_INDEX_BEFORE)
|
||||
* or (last == TCL_INDEX_AFTER). These also permit simplification
|
||||
* of the prefix|replace|suffix construction. The other constraints,
|
||||
* though, interfere with getting a guarantee that first <= last.
|
||||
* though, interfere with getting a guarantee that first <= last.
|
||||
*/
|
||||
|
||||
if ((first == TCL_INDEX_BEFORE) && (last >= TCL_INDEX_START)) {
|
||||
@@ -1141,7 +1138,7 @@ TclCompileStringReplaceCmd(
|
||||
/* FLOW THROUGH TO genericReplace */
|
||||
|
||||
} else {
|
||||
/*
|
||||
/*
|
||||
* When we have no replacement string to worry about, we may
|
||||
* have more luck, because the forbidden empty string replacements
|
||||
* are harmless when they are replaced by another empty string.
|
||||
@@ -1353,7 +1350,7 @@ static int
|
||||
UniCharIsHexDigit(
|
||||
int character)
|
||||
{
|
||||
return (character >= 0) && (character < 0x80) && isxdigit(character);
|
||||
return (character >= 0) && (character < 0x80) && isxdigit(UCHAR(character));
|
||||
}
|
||||
|
||||
StringClassDesc const tclStringClassTable[] = {
|
||||
|
||||
@@ -1759,7 +1759,7 @@ ConvertTreeToTokens(
|
||||
|
||||
/*
|
||||
* All the Tcl_Tokens allocated and filled belong to
|
||||
* this subexpresion. The first token is the leading
|
||||
* this subexpression. The first token is the leading
|
||||
* TCL_TOKEN_SUB_EXPR token, and all the rest (one fewer)
|
||||
* are its components.
|
||||
*/
|
||||
|
||||
@@ -1473,7 +1473,7 @@ MODULE_SCOPE int TclPushProcCallFrame(ClientData clientData,
|
||||
#endif
|
||||
|
||||
#define TclGetInt4AtPtr(p) \
|
||||
(((int) TclGetInt1AtPtr(p) << 24) | \
|
||||
(((int) (TclGetUInt1AtPtr(p) << 24)) | \
|
||||
(*((p)+1) << 16) | \
|
||||
(*((p)+2) << 8) | \
|
||||
(*((p)+3)))
|
||||
|
||||
+953
-953
File diff suppressed because it is too large
Load Diff
+102
-53
@@ -119,7 +119,8 @@ EXTERN void Tcl_DbIncrRefCount(Tcl_Obj *objPtr, const char *file,
|
||||
EXTERN int Tcl_DbIsShared(Tcl_Obj *objPtr, const char *file,
|
||||
int line);
|
||||
/* 22 */
|
||||
EXTERN Tcl_Obj * Tcl_DbNewBooleanObj(int boolValue, const char *file,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
Tcl_Obj * Tcl_DbNewBooleanObj(int boolValue, const char *file,
|
||||
int line);
|
||||
/* 23 */
|
||||
EXTERN Tcl_Obj * Tcl_DbNewByteArrayObj(const unsigned char *bytes,
|
||||
@@ -131,7 +132,8 @@ EXTERN Tcl_Obj * Tcl_DbNewDoubleObj(double doubleValue,
|
||||
EXTERN Tcl_Obj * Tcl_DbNewListObj(int objc, Tcl_Obj *const *objv,
|
||||
const char *file, int line);
|
||||
/* 26 */
|
||||
EXTERN Tcl_Obj * Tcl_DbNewLongObj(long longValue, const char *file,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
Tcl_Obj * Tcl_DbNewLongObj(long longValue, const char *file,
|
||||
int line);
|
||||
/* 27 */
|
||||
EXTERN Tcl_Obj * Tcl_DbNewObj(const char *file, int line);
|
||||
@@ -158,7 +160,8 @@ EXTERN int Tcl_GetDouble(Tcl_Interp *interp, const char *src,
|
||||
EXTERN int Tcl_GetDoubleFromObj(Tcl_Interp *interp,
|
||||
Tcl_Obj *objPtr, double *doublePtr);
|
||||
/* 36 */
|
||||
EXTERN int Tcl_GetIndexFromObj(Tcl_Interp *interp,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
int Tcl_GetIndexFromObj(Tcl_Interp *interp,
|
||||
Tcl_Obj *objPtr, const char *const *tablePtr,
|
||||
const char *msg, int flags, int *indexPtr);
|
||||
/* 37 */
|
||||
@@ -198,24 +201,28 @@ EXTERN int Tcl_ListObjReplace(Tcl_Interp *interp,
|
||||
Tcl_Obj *listPtr, int first, int count,
|
||||
int objc, Tcl_Obj *const objv[]);
|
||||
/* 49 */
|
||||
EXTERN Tcl_Obj * Tcl_NewBooleanObj(int boolValue);
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
Tcl_Obj * Tcl_NewBooleanObj(int boolValue);
|
||||
/* 50 */
|
||||
EXTERN Tcl_Obj * Tcl_NewByteArrayObj(const unsigned char *bytes,
|
||||
int length);
|
||||
/* 51 */
|
||||
EXTERN Tcl_Obj * Tcl_NewDoubleObj(double doubleValue);
|
||||
/* 52 */
|
||||
EXTERN Tcl_Obj * Tcl_NewIntObj(int intValue);
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
Tcl_Obj * Tcl_NewIntObj(int intValue);
|
||||
/* 53 */
|
||||
EXTERN Tcl_Obj * Tcl_NewListObj(int objc, Tcl_Obj *const objv[]);
|
||||
/* 54 */
|
||||
EXTERN Tcl_Obj * Tcl_NewLongObj(long longValue);
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
Tcl_Obj * Tcl_NewLongObj(long longValue);
|
||||
/* 55 */
|
||||
EXTERN Tcl_Obj * Tcl_NewObj(void);
|
||||
/* 56 */
|
||||
EXTERN Tcl_Obj * Tcl_NewStringObj(const char *bytes, int length);
|
||||
/* 57 */
|
||||
EXTERN void Tcl_SetBooleanObj(Tcl_Obj *objPtr, int boolValue);
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
void Tcl_SetBooleanObj(Tcl_Obj *objPtr, int boolValue);
|
||||
/* 58 */
|
||||
EXTERN unsigned char * Tcl_SetByteArrayLength(Tcl_Obj *objPtr, int length);
|
||||
/* 59 */
|
||||
@@ -224,22 +231,26 @@ EXTERN void Tcl_SetByteArrayObj(Tcl_Obj *objPtr,
|
||||
/* 60 */
|
||||
EXTERN void Tcl_SetDoubleObj(Tcl_Obj *objPtr, double doubleValue);
|
||||
/* 61 */
|
||||
EXTERN void Tcl_SetIntObj(Tcl_Obj *objPtr, int intValue);
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
void Tcl_SetIntObj(Tcl_Obj *objPtr, int intValue);
|
||||
/* 62 */
|
||||
EXTERN void Tcl_SetListObj(Tcl_Obj *objPtr, int objc,
|
||||
Tcl_Obj *const objv[]);
|
||||
/* 63 */
|
||||
EXTERN void Tcl_SetLongObj(Tcl_Obj *objPtr, long longValue);
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
void Tcl_SetLongObj(Tcl_Obj *objPtr, long longValue);
|
||||
/* 64 */
|
||||
EXTERN void Tcl_SetObjLength(Tcl_Obj *objPtr, int length);
|
||||
/* 65 */
|
||||
EXTERN void Tcl_SetStringObj(Tcl_Obj *objPtr, const char *bytes,
|
||||
int length);
|
||||
/* 66 */
|
||||
EXTERN void Tcl_AddErrorInfo(Tcl_Interp *interp,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
void Tcl_AddErrorInfo(Tcl_Interp *interp,
|
||||
const char *message);
|
||||
/* 67 */
|
||||
EXTERN void Tcl_AddObjErrorInfo(Tcl_Interp *interp,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
void Tcl_AddObjErrorInfo(Tcl_Interp *interp,
|
||||
const char *message, int length);
|
||||
/* 68 */
|
||||
EXTERN void Tcl_AllowExceptions(Tcl_Interp *interp);
|
||||
@@ -422,7 +433,8 @@ EXTERN int Tcl_Eval(Tcl_Interp *interp, const char *script);
|
||||
EXTERN int Tcl_EvalFile(Tcl_Interp *interp,
|
||||
const char *fileName);
|
||||
/* 131 */
|
||||
EXTERN int Tcl_EvalObj(Tcl_Interp *interp, Tcl_Obj *objPtr);
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
int Tcl_EvalObj(Tcl_Interp *interp, Tcl_Obj *objPtr);
|
||||
/* 132 */
|
||||
EXTERN void Tcl_EventuallyFree(ClientData clientData,
|
||||
Tcl_FreeProc *freeProc);
|
||||
@@ -549,7 +561,8 @@ EXTERN Tcl_Channel Tcl_GetStdChannel(int type);
|
||||
/* 174 */
|
||||
EXTERN const char * Tcl_GetStringResult(Tcl_Interp *interp);
|
||||
/* 175 */
|
||||
EXTERN const char * Tcl_GetVar(Tcl_Interp *interp, const char *varName,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
const char * Tcl_GetVar(Tcl_Interp *interp, const char *varName,
|
||||
int flags);
|
||||
/* 176 */
|
||||
EXTERN const char * Tcl_GetVar2(Tcl_Interp *interp, const char *part1,
|
||||
@@ -558,7 +571,8 @@ EXTERN const char * Tcl_GetVar2(Tcl_Interp *interp, const char *part1,
|
||||
EXTERN int Tcl_GlobalEval(Tcl_Interp *interp,
|
||||
const char *command);
|
||||
/* 178 */
|
||||
EXTERN int Tcl_GlobalEvalObj(Tcl_Interp *interp,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
int Tcl_GlobalEvalObj(Tcl_Interp *interp,
|
||||
Tcl_Obj *objPtr);
|
||||
/* 179 */
|
||||
EXTERN int Tcl_HideCommand(Tcl_Interp *interp,
|
||||
@@ -713,7 +727,8 @@ EXTERN void Tcl_SetObjResult(Tcl_Interp *interp,
|
||||
/* 236 */
|
||||
EXTERN void Tcl_SetStdChannel(Tcl_Channel channel, int type);
|
||||
/* 237 */
|
||||
EXTERN const char * Tcl_SetVar(Tcl_Interp *interp, const char *varName,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
const char * Tcl_SetVar(Tcl_Interp *interp, const char *varName,
|
||||
const char *newValue, int flags);
|
||||
/* 238 */
|
||||
EXTERN const char * Tcl_SetVar2(Tcl_Interp *interp, const char *part1,
|
||||
@@ -743,7 +758,8 @@ EXTERN int Tcl_StringMatch(const char *str, const char *pattern);
|
||||
TCL_DEPRECATED("")
|
||||
int Tcl_TellOld(Tcl_Channel chan);
|
||||
/* 247 */
|
||||
EXTERN int Tcl_TraceVar(Tcl_Interp *interp, const char *varName,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
int Tcl_TraceVar(Tcl_Interp *interp, const char *varName,
|
||||
int flags, Tcl_VarTraceProc *proc,
|
||||
ClientData clientData);
|
||||
/* 248 */
|
||||
@@ -764,13 +780,15 @@ EXTERN void Tcl_UnlinkVar(Tcl_Interp *interp,
|
||||
EXTERN int Tcl_UnregisterChannel(Tcl_Interp *interp,
|
||||
Tcl_Channel chan);
|
||||
/* 253 */
|
||||
EXTERN int Tcl_UnsetVar(Tcl_Interp *interp, const char *varName,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
int Tcl_UnsetVar(Tcl_Interp *interp, const char *varName,
|
||||
int flags);
|
||||
/* 254 */
|
||||
EXTERN int Tcl_UnsetVar2(Tcl_Interp *interp, const char *part1,
|
||||
const char *part2, int flags);
|
||||
/* 255 */
|
||||
EXTERN void Tcl_UntraceVar(Tcl_Interp *interp,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
void Tcl_UntraceVar(Tcl_Interp *interp,
|
||||
const char *varName, int flags,
|
||||
Tcl_VarTraceProc *proc,
|
||||
ClientData clientData);
|
||||
@@ -783,7 +801,8 @@ EXTERN void Tcl_UntraceVar2(Tcl_Interp *interp,
|
||||
EXTERN void Tcl_UpdateLinkedVar(Tcl_Interp *interp,
|
||||
const char *varName);
|
||||
/* 258 */
|
||||
EXTERN int Tcl_UpVar(Tcl_Interp *interp, const char *frameName,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
int Tcl_UpVar(Tcl_Interp *interp, const char *frameName,
|
||||
const char *varName, const char *localName,
|
||||
int flags);
|
||||
/* 259 */
|
||||
@@ -793,7 +812,8 @@ EXTERN int Tcl_UpVar2(Tcl_Interp *interp, const char *frameName,
|
||||
/* 260 */
|
||||
EXTERN int Tcl_VarEval(Tcl_Interp *interp, ...);
|
||||
/* 261 */
|
||||
EXTERN ClientData Tcl_VarTraceInfo(Tcl_Interp *interp,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
ClientData Tcl_VarTraceInfo(Tcl_Interp *interp,
|
||||
const char *varName, int flags,
|
||||
Tcl_VarTraceProc *procPtr,
|
||||
ClientData prevClientData);
|
||||
@@ -825,17 +845,20 @@ EXTERN char * Tcl_HashStats(Tcl_HashTable *tablePtr);
|
||||
EXTERN const char * Tcl_ParseVar(Tcl_Interp *interp, const char *start,
|
||||
const char **termPtr);
|
||||
/* 271 */
|
||||
EXTERN const char * Tcl_PkgPresent(Tcl_Interp *interp, const char *name,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
const char * Tcl_PkgPresent(Tcl_Interp *interp, const char *name,
|
||||
const char *version, int exact);
|
||||
/* 272 */
|
||||
EXTERN const char * Tcl_PkgPresentEx(Tcl_Interp *interp,
|
||||
const char *name, const char *version,
|
||||
int exact, void *clientDataPtr);
|
||||
/* 273 */
|
||||
EXTERN int Tcl_PkgProvide(Tcl_Interp *interp, const char *name,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
int Tcl_PkgProvide(Tcl_Interp *interp, const char *name,
|
||||
const char *version);
|
||||
/* 274 */
|
||||
EXTERN const char * Tcl_PkgRequire(Tcl_Interp *interp, const char *name,
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
const char * Tcl_PkgRequire(Tcl_Interp *interp, const char *name,
|
||||
const char *version, int exact);
|
||||
/* 275 */
|
||||
TCL_DEPRECATED("see TIP #422")
|
||||
@@ -1125,7 +1148,8 @@ EXTERN int Tcl_GetCharLength(Tcl_Obj *objPtr);
|
||||
/* 381 */
|
||||
EXTERN int Tcl_GetUniChar(Tcl_Obj *objPtr, int index);
|
||||
/* 382 */
|
||||
EXTERN Tcl_UniChar * Tcl_GetUnicode(Tcl_Obj *objPtr);
|
||||
TCL_DEPRECATED("No longer in use, changed to macro")
|
||||
Tcl_UniChar * Tcl_GetUnicode(Tcl_Obj *objPtr);
|
||||
/* 383 */
|
||||
EXTERN Tcl_Obj * Tcl_GetRange(Tcl_Obj *objPtr, int first, int last);
|
||||
/* 384 */
|
||||
@@ -1838,6 +1862,19 @@ EXTERN Tcl_Channel Tcl_OpenTcpServerEx(Tcl_Interp *interp,
|
||||
unsigned int flags,
|
||||
Tcl_TcpAcceptProc *acceptProc,
|
||||
ClientData callbackData);
|
||||
/* 632 */
|
||||
EXTERN int TclZipfs_Mount(Tcl_Interp *interp,
|
||||
const char *mountPoint, const char *zipname,
|
||||
const char *passwd);
|
||||
/* 633 */
|
||||
EXTERN int TclZipfs_Unmount(Tcl_Interp *interp,
|
||||
const char *mountPoint);
|
||||
/* 634 */
|
||||
EXTERN Tcl_Obj * TclZipfs_TclLibrary(void);
|
||||
/* 635 */
|
||||
EXTERN int TclZipfs_MountBuffer(Tcl_Interp *interp,
|
||||
const char *mountPoint, unsigned char *data,
|
||||
size_t datalen, int copy);
|
||||
|
||||
typedef struct {
|
||||
const struct TclPlatStubs *tclPlatStubs;
|
||||
@@ -1887,11 +1924,11 @@ typedef struct TclStubs {
|
||||
void (*tcl_DbDecrRefCount) (Tcl_Obj *objPtr, const char *file, int line); /* 19 */
|
||||
void (*tcl_DbIncrRefCount) (Tcl_Obj *objPtr, const char *file, int line); /* 20 */
|
||||
int (*tcl_DbIsShared) (Tcl_Obj *objPtr, const char *file, int line); /* 21 */
|
||||
Tcl_Obj * (*tcl_DbNewBooleanObj) (int boolValue, const char *file, int line); /* 22 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") Tcl_Obj * (*tcl_DbNewBooleanObj) (int boolValue, const char *file, int line); /* 22 */
|
||||
Tcl_Obj * (*tcl_DbNewByteArrayObj) (const unsigned char *bytes, int length, const char *file, int line); /* 23 */
|
||||
Tcl_Obj * (*tcl_DbNewDoubleObj) (double doubleValue, const char *file, int line); /* 24 */
|
||||
Tcl_Obj * (*tcl_DbNewListObj) (int objc, Tcl_Obj *const *objv, const char *file, int line); /* 25 */
|
||||
Tcl_Obj * (*tcl_DbNewLongObj) (long longValue, const char *file, int line); /* 26 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") Tcl_Obj * (*tcl_DbNewLongObj) (long longValue, const char *file, int line); /* 26 */
|
||||
Tcl_Obj * (*tcl_DbNewObj) (const char *file, int line); /* 27 */
|
||||
Tcl_Obj * (*tcl_DbNewStringObj) (const char *bytes, int length, const char *file, int line); /* 28 */
|
||||
Tcl_Obj * (*tcl_DuplicateObj) (Tcl_Obj *objPtr); /* 29 */
|
||||
@@ -1901,7 +1938,7 @@ typedef struct TclStubs {
|
||||
unsigned char * (*tcl_GetByteArrayFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 33 */
|
||||
int (*tcl_GetDouble) (Tcl_Interp *interp, const char *src, double *doublePtr); /* 34 */
|
||||
int (*tcl_GetDoubleFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, double *doublePtr); /* 35 */
|
||||
int (*tcl_GetIndexFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, const char *const *tablePtr, const char *msg, int flags, int *indexPtr); /* 36 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") int (*tcl_GetIndexFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, const char *const *tablePtr, const char *msg, int flags, int *indexPtr); /* 36 */
|
||||
int (*tcl_GetInt) (Tcl_Interp *interp, const char *src, int *intPtr); /* 37 */
|
||||
int (*tcl_GetIntFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *intPtr); /* 38 */
|
||||
int (*tcl_GetLongFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, long *longPtr); /* 39 */
|
||||
@@ -1914,25 +1951,25 @@ typedef struct TclStubs {
|
||||
int (*tcl_ListObjIndex) (Tcl_Interp *interp, Tcl_Obj *listPtr, int index, Tcl_Obj **objPtrPtr); /* 46 */
|
||||
int (*tcl_ListObjLength) (Tcl_Interp *interp, Tcl_Obj *listPtr, int *lengthPtr); /* 47 */
|
||||
int (*tcl_ListObjReplace) (Tcl_Interp *interp, Tcl_Obj *listPtr, int first, int count, int objc, Tcl_Obj *const objv[]); /* 48 */
|
||||
Tcl_Obj * (*tcl_NewBooleanObj) (int boolValue); /* 49 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") Tcl_Obj * (*tcl_NewBooleanObj) (int boolValue); /* 49 */
|
||||
Tcl_Obj * (*tcl_NewByteArrayObj) (const unsigned char *bytes, int length); /* 50 */
|
||||
Tcl_Obj * (*tcl_NewDoubleObj) (double doubleValue); /* 51 */
|
||||
Tcl_Obj * (*tcl_NewIntObj) (int intValue); /* 52 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") Tcl_Obj * (*tcl_NewIntObj) (int intValue); /* 52 */
|
||||
Tcl_Obj * (*tcl_NewListObj) (int objc, Tcl_Obj *const objv[]); /* 53 */
|
||||
Tcl_Obj * (*tcl_NewLongObj) (long longValue); /* 54 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") Tcl_Obj * (*tcl_NewLongObj) (long longValue); /* 54 */
|
||||
Tcl_Obj * (*tcl_NewObj) (void); /* 55 */
|
||||
Tcl_Obj * (*tcl_NewStringObj) (const char *bytes, int length); /* 56 */
|
||||
void (*tcl_SetBooleanObj) (Tcl_Obj *objPtr, int boolValue); /* 57 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") void (*tcl_SetBooleanObj) (Tcl_Obj *objPtr, int boolValue); /* 57 */
|
||||
unsigned char * (*tcl_SetByteArrayLength) (Tcl_Obj *objPtr, int length); /* 58 */
|
||||
void (*tcl_SetByteArrayObj) (Tcl_Obj *objPtr, const unsigned char *bytes, int length); /* 59 */
|
||||
void (*tcl_SetDoubleObj) (Tcl_Obj *objPtr, double doubleValue); /* 60 */
|
||||
void (*tcl_SetIntObj) (Tcl_Obj *objPtr, int intValue); /* 61 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") void (*tcl_SetIntObj) (Tcl_Obj *objPtr, int intValue); /* 61 */
|
||||
void (*tcl_SetListObj) (Tcl_Obj *objPtr, int objc, Tcl_Obj *const objv[]); /* 62 */
|
||||
void (*tcl_SetLongObj) (Tcl_Obj *objPtr, long longValue); /* 63 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") void (*tcl_SetLongObj) (Tcl_Obj *objPtr, long longValue); /* 63 */
|
||||
void (*tcl_SetObjLength) (Tcl_Obj *objPtr, int length); /* 64 */
|
||||
void (*tcl_SetStringObj) (Tcl_Obj *objPtr, const char *bytes, int length); /* 65 */
|
||||
void (*tcl_AddErrorInfo) (Tcl_Interp *interp, const char *message); /* 66 */
|
||||
void (*tcl_AddObjErrorInfo) (Tcl_Interp *interp, const char *message, int length); /* 67 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") void (*tcl_AddErrorInfo) (Tcl_Interp *interp, const char *message); /* 66 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") void (*tcl_AddObjErrorInfo) (Tcl_Interp *interp, const char *message, int length); /* 67 */
|
||||
void (*tcl_AllowExceptions) (Tcl_Interp *interp); /* 68 */
|
||||
void (*tcl_AppendElement) (Tcl_Interp *interp, const char *element); /* 69 */
|
||||
void (*tcl_AppendResult) (Tcl_Interp *interp, ...); /* 70 */
|
||||
@@ -1996,7 +2033,7 @@ typedef struct TclStubs {
|
||||
const char * (*tcl_ErrnoMsg) (int err); /* 128 */
|
||||
int (*tcl_Eval) (Tcl_Interp *interp, const char *script); /* 129 */
|
||||
int (*tcl_EvalFile) (Tcl_Interp *interp, const char *fileName); /* 130 */
|
||||
int (*tcl_EvalObj) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 131 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") int (*tcl_EvalObj) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 131 */
|
||||
void (*tcl_EventuallyFree) (ClientData clientData, Tcl_FreeProc *freeProc); /* 132 */
|
||||
TCL_NORETURN1 void (*tcl_Exit) (int status); /* 133 */
|
||||
int (*tcl_ExposeCommand) (Tcl_Interp *interp, const char *hiddenCmdToken, const char *cmdName); /* 134 */
|
||||
@@ -2048,10 +2085,10 @@ typedef struct TclStubs {
|
||||
Tcl_Interp * (*tcl_GetSlave) (Tcl_Interp *interp, const char *slaveName); /* 172 */
|
||||
Tcl_Channel (*tcl_GetStdChannel) (int type); /* 173 */
|
||||
const char * (*tcl_GetStringResult) (Tcl_Interp *interp); /* 174 */
|
||||
const char * (*tcl_GetVar) (Tcl_Interp *interp, const char *varName, int flags); /* 175 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") const char * (*tcl_GetVar) (Tcl_Interp *interp, const char *varName, int flags); /* 175 */
|
||||
const char * (*tcl_GetVar2) (Tcl_Interp *interp, const char *part1, const char *part2, int flags); /* 176 */
|
||||
int (*tcl_GlobalEval) (Tcl_Interp *interp, const char *command); /* 177 */
|
||||
int (*tcl_GlobalEvalObj) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 178 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") int (*tcl_GlobalEvalObj) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 178 */
|
||||
int (*tcl_HideCommand) (Tcl_Interp *interp, const char *cmdName, const char *hiddenCmdToken); /* 179 */
|
||||
int (*tcl_Init) (Tcl_Interp *interp); /* 180 */
|
||||
void (*tcl_InitHashTable) (Tcl_HashTable *tablePtr, int keyType); /* 181 */
|
||||
@@ -2110,7 +2147,7 @@ typedef struct TclStubs {
|
||||
void (*tcl_SetObjErrorCode) (Tcl_Interp *interp, Tcl_Obj *errorObjPtr); /* 234 */
|
||||
void (*tcl_SetObjResult) (Tcl_Interp *interp, Tcl_Obj *resultObjPtr); /* 235 */
|
||||
void (*tcl_SetStdChannel) (Tcl_Channel channel, int type); /* 236 */
|
||||
const char * (*tcl_SetVar) (Tcl_Interp *interp, const char *varName, const char *newValue, int flags); /* 237 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") const char * (*tcl_SetVar) (Tcl_Interp *interp, const char *varName, const char *newValue, int flags); /* 237 */
|
||||
const char * (*tcl_SetVar2) (Tcl_Interp *interp, const char *part1, const char *part2, const char *newValue, int flags); /* 238 */
|
||||
const char * (*tcl_SignalId) (int sig); /* 239 */
|
||||
const char * (*tcl_SignalMsg) (int sig); /* 240 */
|
||||
@@ -2120,21 +2157,21 @@ typedef struct TclStubs {
|
||||
void (*tcl_StaticPackage) (Tcl_Interp *interp, const char *pkgName, Tcl_PackageInitProc *initProc, Tcl_PackageInitProc *safeInitProc); /* 244 */
|
||||
int (*tcl_StringMatch) (const char *str, const char *pattern); /* 245 */
|
||||
TCL_DEPRECATED_API("") int (*tcl_TellOld) (Tcl_Channel chan); /* 246 */
|
||||
int (*tcl_TraceVar) (Tcl_Interp *interp, const char *varName, int flags, Tcl_VarTraceProc *proc, ClientData clientData); /* 247 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") int (*tcl_TraceVar) (Tcl_Interp *interp, const char *varName, int flags, Tcl_VarTraceProc *proc, ClientData clientData); /* 247 */
|
||||
int (*tcl_TraceVar2) (Tcl_Interp *interp, const char *part1, const char *part2, int flags, Tcl_VarTraceProc *proc, ClientData clientData); /* 248 */
|
||||
char * (*tcl_TranslateFileName) (Tcl_Interp *interp, const char *name, Tcl_DString *bufferPtr); /* 249 */
|
||||
int (*tcl_Ungets) (Tcl_Channel chan, const char *str, int len, int atHead); /* 250 */
|
||||
void (*tcl_UnlinkVar) (Tcl_Interp *interp, const char *varName); /* 251 */
|
||||
int (*tcl_UnregisterChannel) (Tcl_Interp *interp, Tcl_Channel chan); /* 252 */
|
||||
int (*tcl_UnsetVar) (Tcl_Interp *interp, const char *varName, int flags); /* 253 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") int (*tcl_UnsetVar) (Tcl_Interp *interp, const char *varName, int flags); /* 253 */
|
||||
int (*tcl_UnsetVar2) (Tcl_Interp *interp, const char *part1, const char *part2, int flags); /* 254 */
|
||||
void (*tcl_UntraceVar) (Tcl_Interp *interp, const char *varName, int flags, Tcl_VarTraceProc *proc, ClientData clientData); /* 255 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") void (*tcl_UntraceVar) (Tcl_Interp *interp, const char *varName, int flags, Tcl_VarTraceProc *proc, ClientData clientData); /* 255 */
|
||||
void (*tcl_UntraceVar2) (Tcl_Interp *interp, const char *part1, const char *part2, int flags, Tcl_VarTraceProc *proc, ClientData clientData); /* 256 */
|
||||
void (*tcl_UpdateLinkedVar) (Tcl_Interp *interp, const char *varName); /* 257 */
|
||||
int (*tcl_UpVar) (Tcl_Interp *interp, const char *frameName, const char *varName, const char *localName, int flags); /* 258 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") int (*tcl_UpVar) (Tcl_Interp *interp, const char *frameName, const char *varName, const char *localName, int flags); /* 258 */
|
||||
int (*tcl_UpVar2) (Tcl_Interp *interp, const char *frameName, const char *part1, const char *part2, const char *localName, int flags); /* 259 */
|
||||
int (*tcl_VarEval) (Tcl_Interp *interp, ...); /* 260 */
|
||||
ClientData (*tcl_VarTraceInfo) (Tcl_Interp *interp, const char *varName, int flags, Tcl_VarTraceProc *procPtr, ClientData prevClientData); /* 261 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") ClientData (*tcl_VarTraceInfo) (Tcl_Interp *interp, const char *varName, int flags, Tcl_VarTraceProc *procPtr, ClientData prevClientData); /* 261 */
|
||||
ClientData (*tcl_VarTraceInfo2) (Tcl_Interp *interp, const char *part1, const char *part2, int flags, Tcl_VarTraceProc *procPtr, ClientData prevClientData); /* 262 */
|
||||
int (*tcl_Write) (Tcl_Channel chan, const char *s, int slen); /* 263 */
|
||||
void (*tcl_WrongNumArgs) (Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], const char *message); /* 264 */
|
||||
@@ -2144,10 +2181,10 @@ typedef struct TclStubs {
|
||||
TCL_DEPRECATED_API("see TIP #422") void (*tcl_AppendStringsToObjVA) (Tcl_Obj *objPtr, va_list argList); /* 268 */
|
||||
char * (*tcl_HashStats) (Tcl_HashTable *tablePtr); /* 269 */
|
||||
const char * (*tcl_ParseVar) (Tcl_Interp *interp, const char *start, const char **termPtr); /* 270 */
|
||||
const char * (*tcl_PkgPresent) (Tcl_Interp *interp, const char *name, const char *version, int exact); /* 271 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") const char * (*tcl_PkgPresent) (Tcl_Interp *interp, const char *name, const char *version, int exact); /* 271 */
|
||||
const char * (*tcl_PkgPresentEx) (Tcl_Interp *interp, const char *name, const char *version, int exact, void *clientDataPtr); /* 272 */
|
||||
int (*tcl_PkgProvide) (Tcl_Interp *interp, const char *name, const char *version); /* 273 */
|
||||
const char * (*tcl_PkgRequire) (Tcl_Interp *interp, const char *name, const char *version, int exact); /* 274 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") int (*tcl_PkgProvide) (Tcl_Interp *interp, const char *name, const char *version); /* 273 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") const char * (*tcl_PkgRequire) (Tcl_Interp *interp, const char *name, const char *version, int exact); /* 274 */
|
||||
TCL_DEPRECATED_API("see TIP #422") void (*tcl_SetErrorCodeVA) (Tcl_Interp *interp, va_list argList); /* 275 */
|
||||
TCL_DEPRECATED_API("see TIP #422") int (*tcl_VarEvalVA) (Tcl_Interp *interp, va_list argList); /* 276 */
|
||||
Tcl_Pid (*tcl_WaitPid) (Tcl_Pid pid, int *statPtr, int options); /* 277 */
|
||||
@@ -2255,7 +2292,7 @@ typedef struct TclStubs {
|
||||
void (*tcl_SetUnicodeObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int numChars); /* 379 */
|
||||
int (*tcl_GetCharLength) (Tcl_Obj *objPtr); /* 380 */
|
||||
int (*tcl_GetUniChar) (Tcl_Obj *objPtr, int index); /* 381 */
|
||||
Tcl_UniChar * (*tcl_GetUnicode) (Tcl_Obj *objPtr); /* 382 */
|
||||
TCL_DEPRECATED_API("No longer in use, changed to macro") Tcl_UniChar * (*tcl_GetUnicode) (Tcl_Obj *objPtr); /* 382 */
|
||||
Tcl_Obj * (*tcl_GetRange) (Tcl_Obj *objPtr, int first, int last); /* 383 */
|
||||
void (*tcl_AppendUnicodeToObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int length); /* 384 */
|
||||
int (*tcl_RegExpMatchObj) (Tcl_Interp *interp, Tcl_Obj *textObj, Tcl_Obj *patternObj); /* 385 */
|
||||
@@ -2505,6 +2542,10 @@ typedef struct TclStubs {
|
||||
int (*tcl_FSUnloadFile) (Tcl_Interp *interp, Tcl_LoadHandle handlePtr); /* 629 */
|
||||
void (*tcl_ZlibStreamSetCompressionDictionary) (Tcl_ZlibStream zhandle, Tcl_Obj *compressionDictionaryObj); /* 630 */
|
||||
Tcl_Channel (*tcl_OpenTcpServerEx) (Tcl_Interp *interp, const char *service, const char *host, unsigned int flags, Tcl_TcpAcceptProc *acceptProc, ClientData callbackData); /* 631 */
|
||||
int (*tclZipfs_Mount) (Tcl_Interp *interp, const char *mountPoint, const char *zipname, const char *passwd); /* 632 */
|
||||
int (*tclZipfs_Unmount) (Tcl_Interp *interp, const char *mountPoint); /* 633 */
|
||||
Tcl_Obj * (*tclZipfs_TclLibrary) (void); /* 634 */
|
||||
int (*tclZipfs_MountBuffer) (Tcl_Interp *interp, const char *mountPoint, unsigned char *data, size_t datalen, int copy); /* 635 */
|
||||
} TclStubs;
|
||||
|
||||
extern const TclStubs *tclStubsPtr;
|
||||
@@ -3799,6 +3840,14 @@ extern const TclStubs *tclStubsPtr;
|
||||
(tclStubsPtr->tcl_ZlibStreamSetCompressionDictionary) /* 630 */
|
||||
#define Tcl_OpenTcpServerEx \
|
||||
(tclStubsPtr->tcl_OpenTcpServerEx) /* 631 */
|
||||
#define TclZipfs_Mount \
|
||||
(tclStubsPtr->tclZipfs_Mount) /* 632 */
|
||||
#define TclZipfs_Unmount \
|
||||
(tclStubsPtr->tclZipfs_Unmount) /* 633 */
|
||||
#define TclZipfs_TclLibrary \
|
||||
(tclStubsPtr->tclZipfs_TclLibrary) /* 634 */
|
||||
#define TclZipfs_MountBuffer \
|
||||
(tclStubsPtr->tclZipfs_MountBuffer) /* 635 */
|
||||
|
||||
#endif /* defined(USE_TCL_STUBS) */
|
||||
|
||||
@@ -3810,15 +3859,12 @@ extern const TclStubs *tclStubsPtr;
|
||||
# undef Tcl_GetStringResult
|
||||
# undef Tcl_Init
|
||||
# undef Tcl_SetPanicProc
|
||||
# undef Tcl_SetVar
|
||||
# undef Tcl_ObjSetVar2
|
||||
# undef Tcl_StaticPackage
|
||||
# define Tcl_CreateInterp() (tclStubsPtr->tcl_CreateInterp())
|
||||
# define Tcl_GetStringResult(interp) (tclStubsPtr->tcl_GetStringResult(interp))
|
||||
# define Tcl_Init(interp) (tclStubsPtr->tcl_Init(interp))
|
||||
# define Tcl_SetPanicProc(proc) (tclStubsPtr->tcl_SetPanicProc(proc))
|
||||
# define Tcl_SetVar(interp, varName, newValue, flags) \
|
||||
(tclStubsPtr->tcl_SetVar(interp, varName, newValue, flags))
|
||||
# define Tcl_ObjSetVar2(interp, part1, part2, newValue, flags) \
|
||||
(tclStubsPtr->tcl_ObjSetVar2(interp, part1, part2, newValue, flags))
|
||||
#endif
|
||||
@@ -3828,6 +3874,7 @@ extern const TclStubs *tclStubsPtr;
|
||||
# define Tcl_MainEx Tcl_MainExW
|
||||
EXTERN void Tcl_MainExW(int argc, wchar_t **argv,
|
||||
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
|
||||
EXTERN int TclZipfs_AppHook(int *argc, wchar_t ***argv);
|
||||
#endif
|
||||
|
||||
#undef TCL_STORAGE_CLASS
|
||||
@@ -3974,9 +4021,11 @@ extern const TclStubs *tclStubsPtr;
|
||||
#undef Tcl_DbNewLongObj
|
||||
#define Tcl_DbNewLongObj(value, file, line) Tcl_DbNewWideIntObj((long)(value), file, line)
|
||||
#undef Tcl_SetIntObj
|
||||
#define Tcl_SetIntObj(objPtr, value) Tcl_SetWideIntObj(objPtr, (int)(value))
|
||||
#define Tcl_SetIntObj(objPtr, value) Tcl_SetWideIntObj((objPtr), (int)(value))
|
||||
#undef Tcl_SetLongObj
|
||||
#define Tcl_SetLongObj(objPtr, value) Tcl_SetWideIntObj(objPtr, (long)(value))
|
||||
#define Tcl_SetLongObj(objPtr, value) Tcl_SetWideIntObj((objPtr), (long)(value))
|
||||
#undef Tcl_GetUnicode
|
||||
#define Tcl_GetUnicode(objPtr) Tcl_GetUnicodeFromObj((objPtr), NULL)
|
||||
|
||||
/*
|
||||
* Deprecated Tcl procedures:
|
||||
|
||||
@@ -153,7 +153,7 @@ typedef struct Dict {
|
||||
* must be assignable as well as readable.
|
||||
*/
|
||||
|
||||
#define DICT(dictObj) (*((Dict **)&(dictObj)->internalRep.twoPtrValue.ptr1))
|
||||
#define DICT(dictObj) ((dictObj)->internalRep.twoPtrValue.ptr1)
|
||||
|
||||
/*
|
||||
* The structure below defines the dictionary object type by means of
|
||||
|
||||
@@ -894,7 +894,7 @@ PrintSourceToObj(
|
||||
Tcl_AppendPrintfToObj(appendObj, "\\U%08x", ch);
|
||||
i += 10;
|
||||
} else
|
||||
#elif TCL_UTF_MAX > 3
|
||||
#else
|
||||
/* If len == 0, this means we have a char > 0xffff, resulting in
|
||||
* TclUtfToUniChar producing a surrogate pair. We want to output
|
||||
* this pair as a single Unicode character.
|
||||
@@ -1610,7 +1610,7 @@ Tcl_DisassembleObjCmd(
|
||||
"BYTECODE", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (PTR2INT(clientData)) {
|
||||
if (clientData) {
|
||||
Tcl_SetObjResult(interp,
|
||||
DisassembleByteCodeAsDicts(interp, codeObjPtr));
|
||||
} else {
|
||||
|
||||
@@ -2058,7 +2058,7 @@ LoadEscapeEncoding(
|
||||
dataPtr->numSubTables =
|
||||
Tcl_DStringLength(&escapeData) / sizeof(EscapeSubTable);
|
||||
memcpy(dataPtr->subTables, Tcl_DStringValue(&escapeData),
|
||||
(size_t) Tcl_DStringLength(&escapeData));
|
||||
Tcl_DStringLength(&escapeData));
|
||||
Tcl_DStringFree(&escapeData);
|
||||
|
||||
memset(dataPtr->prefixBytes, 0, sizeof(dataPtr->prefixBytes));
|
||||
|
||||
+76
-71
@@ -21,8 +21,6 @@ static inline Tcl_Obj * NewNsObj(Tcl_Namespace *namespacePtr);
|
||||
static inline int EnsembleUnknownCallback(Tcl_Interp *interp,
|
||||
EnsembleConfig *ensemblePtr, int objc,
|
||||
Tcl_Obj *const objv[], Tcl_Obj **prefixObjPtr);
|
||||
static int NsEnsembleImplementationCmd(ClientData clientData,
|
||||
Tcl_Interp *interp,int objc,Tcl_Obj *const objv[]);
|
||||
static int NsEnsembleImplementationCmdNR(ClientData clientData,
|
||||
Tcl_Interp *interp,int objc,Tcl_Obj *const objv[]);
|
||||
static void BuildEnsembleConfig(EnsembleConfig *ensemblePtr);
|
||||
@@ -87,8 +85,8 @@ static const Tcl_ObjType ensembleCmdType = {
|
||||
};
|
||||
|
||||
/*
|
||||
* The internal rep for caching ensemble subcommand lookups and
|
||||
* spell corrections.
|
||||
* The internal rep for caching ensemble subcommand lookups and spelling
|
||||
* corrections.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
@@ -98,10 +96,9 @@ typedef struct {
|
||||
Command *token; /* Reference to the command for which this
|
||||
* structure is a cache of the resolution. */
|
||||
Tcl_Obj *fix; /* Corrected spelling, if needed. */
|
||||
Tcl_HashEntry *hPtr; /* Direct link to entry in the subcommand
|
||||
* hash table. */
|
||||
Tcl_HashEntry *hPtr; /* Direct link to entry in the subcommand hash
|
||||
* table. */
|
||||
} EnsembleCmdRep;
|
||||
|
||||
|
||||
static inline Tcl_Obj *
|
||||
NewNsObj(
|
||||
@@ -111,9 +108,8 @@ NewNsObj(
|
||||
|
||||
if (namespacePtr == TclGetGlobalNamespace(nsPtr->interp)) {
|
||||
return Tcl_NewStringObj("::", 2);
|
||||
} else {
|
||||
return Tcl_NewStringObj(nsPtr->fullName, -1);
|
||||
}
|
||||
return Tcl_NewStringObj(nsPtr->fullName, -1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -147,7 +143,7 @@ TclNamespaceEnsembleCmd(
|
||||
{
|
||||
Tcl_Namespace *namespacePtr;
|
||||
Namespace *nsPtr = (Namespace *) TclGetCurrentNamespace(interp), *cxtPtr,
|
||||
*foundNsPtr, *altFoundNsPtr, *actualCxtPtr;
|
||||
*foundNsPtr, *altFoundNsPtr, *actualCxtPtr;
|
||||
Tcl_Command token;
|
||||
Tcl_DictSearch search;
|
||||
Tcl_Obj *listObj;
|
||||
@@ -302,7 +298,8 @@ TclNamespaceEnsembleCmd(
|
||||
Tcl_DictObjPut(NULL, patchedDict, subcmdWordsObj,
|
||||
newList);
|
||||
}
|
||||
Tcl_DictObjNext(&search, &subcmdWordsObj,&listObj, &done);
|
||||
Tcl_DictObjNext(&search, &subcmdWordsObj, &listObj,
|
||||
&done);
|
||||
} while (!done);
|
||||
|
||||
if (allocatedMapFlag) {
|
||||
@@ -336,8 +333,8 @@ TclNamespaceEnsembleCmd(
|
||||
}
|
||||
|
||||
TclGetNamespaceForQualName(interp, name, cxtPtr,
|
||||
TCL_CREATE_NS_IF_UNKNOWN, &foundNsPtr, &altFoundNsPtr, &actualCxtPtr,
|
||||
&simpleName);
|
||||
TCL_CREATE_NS_IF_UNKNOWN, &foundNsPtr, &altFoundNsPtr,
|
||||
&actualCxtPtr, &simpleName);
|
||||
|
||||
/*
|
||||
* Create the ensemble. Note that this might delete another ensemble
|
||||
@@ -347,8 +344,8 @@ TclNamespaceEnsembleCmd(
|
||||
*/
|
||||
|
||||
token = TclCreateEnsembleInNs(interp, simpleName,
|
||||
(Tcl_Namespace *) foundNsPtr, (Tcl_Namespace *) nsPtr,
|
||||
(permitPrefix ? TCL_ENSEMBLE_PREFIX : 0));
|
||||
(Tcl_Namespace *) foundNsPtr, (Tcl_Namespace *) nsPtr,
|
||||
(permitPrefix ? TCL_ENSEMBLE_PREFIX : 0));
|
||||
Tcl_SetEnsembleSubcommandList(interp, token, subcmdObj);
|
||||
Tcl_SetEnsembleMappingDict(interp, token, mapObj);
|
||||
Tcl_SetEnsembleUnknownHandler(interp, token, unknownObj);
|
||||
@@ -576,7 +573,8 @@ TclNamespaceEnsembleCmd(
|
||||
Tcl_AppendStringsToObj(newCmd, "::", NULL);
|
||||
}
|
||||
Tcl_AppendObjToObj(newCmd, listv[0]);
|
||||
Tcl_ListObjReplace(NULL, newList, 0,1, 1,&newCmd);
|
||||
Tcl_ListObjReplace(NULL, newList, 0, 1, 1,
|
||||
&newCmd);
|
||||
if (patchedDict == NULL) {
|
||||
patchedDict = Tcl_DuplicateObj(objv[1]);
|
||||
}
|
||||
@@ -650,15 +648,13 @@ TclNamespaceEnsembleCmd(
|
||||
Tcl_Command
|
||||
TclCreateEnsembleInNs(
|
||||
Tcl_Interp *interp,
|
||||
|
||||
const char *name, /* Simple name of command to create (no */
|
||||
/* namespace components). */
|
||||
Tcl_Namespace /* Name of namespace to create the command in. */
|
||||
*nameNsPtr,
|
||||
Tcl_Namespace
|
||||
*ensembleNsPtr, /* Name of the namespace for the ensemble. */
|
||||
int flags
|
||||
)
|
||||
const char *name, /* Simple name of command to create (no
|
||||
* namespace components). */
|
||||
Tcl_Namespace *nameNsPtr, /* Name of namespace to create the command
|
||||
* in. */
|
||||
Tcl_Namespace *ensembleNsPtr,
|
||||
/* Name of the namespace for the ensemble. */
|
||||
int flags)
|
||||
{
|
||||
Namespace *nsPtr = (Namespace *) ensembleNsPtr;
|
||||
EnsembleConfig *ensemblePtr;
|
||||
@@ -666,8 +662,8 @@ TclCreateEnsembleInNs(
|
||||
|
||||
ensemblePtr = ckalloc(sizeof(EnsembleConfig));
|
||||
token = TclNRCreateCommandInNs(interp, name,
|
||||
(Tcl_Namespace *) nameNsPtr, NsEnsembleImplementationCmd,
|
||||
NsEnsembleImplementationCmdNR, ensemblePtr, DeleteEnsembleConfig);
|
||||
(Tcl_Namespace *) nameNsPtr, TclEnsembleImplementationCmd,
|
||||
NsEnsembleImplementationCmdNR, ensemblePtr, DeleteEnsembleConfig);
|
||||
if (token == NULL) {
|
||||
ckfree(ensemblePtr);
|
||||
return NULL;
|
||||
@@ -701,18 +697,15 @@ TclCreateEnsembleInNs(
|
||||
}
|
||||
|
||||
return ensemblePtr->token;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* Tcl_CreateEnsemble
|
||||
*
|
||||
* Create a simple ensemble attached to the given namespace.
|
||||
*
|
||||
* Deprecated by TclCreateEnsembleInNs.
|
||||
* Create a simple ensemble attached to the given namespace. Deprecated
|
||||
* (internally) by TclCreateEnsembleInNs.
|
||||
*
|
||||
* Value
|
||||
*
|
||||
@@ -732,8 +725,8 @@ Tcl_CreateEnsemble(
|
||||
Tcl_Namespace *namespacePtr,
|
||||
int flags)
|
||||
{
|
||||
Namespace *nsPtr = (Namespace *)namespacePtr, *foundNsPtr, *altNsPtr,
|
||||
*actualNsPtr;
|
||||
Namespace *nsPtr = (Namespace *) namespacePtr, *foundNsPtr, *altNsPtr,
|
||||
*actualNsPtr;
|
||||
const char * simpleName;
|
||||
|
||||
if (nsPtr == NULL) {
|
||||
@@ -741,11 +734,10 @@ Tcl_CreateEnsemble(
|
||||
}
|
||||
|
||||
TclGetNamespaceForQualName(interp, name, nsPtr, TCL_CREATE_NS_IF_UNKNOWN,
|
||||
&foundNsPtr, &altNsPtr, &actualNsPtr, &simpleName);
|
||||
&foundNsPtr, &altNsPtr, &actualNsPtr, &simpleName);
|
||||
return TclCreateEnsembleInNs(interp, simpleName,
|
||||
(Tcl_Namespace *) foundNsPtr, (Tcl_Namespace *) nsPtr, flags);
|
||||
(Tcl_Namespace *) foundNsPtr, (Tcl_Namespace *) nsPtr, flags);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -774,7 +766,7 @@ Tcl_SetEnsembleSubcommandList(
|
||||
EnsembleConfig *ensemblePtr;
|
||||
Tcl_Obj *oldList;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
|
||||
@@ -850,7 +842,7 @@ Tcl_SetEnsembleParameterList(
|
||||
Tcl_Obj *oldList;
|
||||
int length;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
|
||||
@@ -926,7 +918,7 @@ Tcl_SetEnsembleMappingDict(
|
||||
EnsembleConfig *ensemblePtr;
|
||||
Tcl_Obj *oldDict;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
|
||||
@@ -1025,7 +1017,7 @@ Tcl_SetEnsembleUnknownHandler(
|
||||
EnsembleConfig *ensemblePtr;
|
||||
Tcl_Obj *oldList;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
|
||||
@@ -1091,7 +1083,7 @@ Tcl_SetEnsembleFlags(
|
||||
EnsembleConfig *ensemblePtr;
|
||||
int wasCompiled;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "ENSEMBLE", "NOT_ENSEMBLE", NULL);
|
||||
@@ -1167,7 +1159,7 @@ Tcl_GetEnsembleSubcommandList(
|
||||
Command *cmdPtr = (Command *) token;
|
||||
EnsembleConfig *ensemblePtr;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
if (interp != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
@@ -1209,7 +1201,7 @@ Tcl_GetEnsembleParameterList(
|
||||
Command *cmdPtr = (Command *) token;
|
||||
EnsembleConfig *ensemblePtr;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
if (interp != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
@@ -1251,7 +1243,7 @@ Tcl_GetEnsembleMappingDict(
|
||||
Command *cmdPtr = (Command *) token;
|
||||
EnsembleConfig *ensemblePtr;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
if (interp != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
@@ -1292,7 +1284,7 @@ Tcl_GetEnsembleUnknownHandler(
|
||||
Command *cmdPtr = (Command *) token;
|
||||
EnsembleConfig *ensemblePtr;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
if (interp != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
@@ -1333,7 +1325,7 @@ Tcl_GetEnsembleFlags(
|
||||
Command *cmdPtr = (Command *) token;
|
||||
EnsembleConfig *ensemblePtr;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
if (interp != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
@@ -1374,7 +1366,7 @@ Tcl_GetEnsembleNamespace(
|
||||
Command *cmdPtr = (Command *) token;
|
||||
EnsembleConfig *ensemblePtr;
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
if (interp != NULL) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"command is not an ensemble", -1));
|
||||
@@ -1424,7 +1416,7 @@ Tcl_FindEnsemble(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
/*
|
||||
* Reuse existing infrastructure for following import link chains
|
||||
* rather than duplicating it.
|
||||
@@ -1432,7 +1424,8 @@ Tcl_FindEnsemble(
|
||||
|
||||
cmdPtr = (Command *) TclGetOriginalCommand((Tcl_Command) cmdPtr);
|
||||
|
||||
if (cmdPtr == NULL || cmdPtr->objProc != NsEnsembleImplementationCmd){
|
||||
if (cmdPtr == NULL
|
||||
|| cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
if (flags & TCL_LEAVE_ERR_MSG) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"\"%s\" is not an ensemble command",
|
||||
@@ -1470,11 +1463,11 @@ Tcl_IsEnsemble(
|
||||
{
|
||||
Command *cmdPtr = (Command *) token;
|
||||
|
||||
if (cmdPtr->objProc == NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr->objProc == TclEnsembleImplementationCmd) {
|
||||
return 1;
|
||||
}
|
||||
cmdPtr = (Command *) TclGetOriginalCommand((Tcl_Command) cmdPtr);
|
||||
if (cmdPtr == NULL || cmdPtr->objProc != NsEnsembleImplementationCmd) {
|
||||
if (cmdPtr == NULL || cmdPtr->objProc != TclEnsembleImplementationCmd) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -1645,7 +1638,7 @@ TclMakeEnsemble(
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* NsEnsembleImplementationCmd --
|
||||
* TclEnsembleImplementationCmd --
|
||||
*
|
||||
* Implements an ensemble of commands (being those exported by a
|
||||
* namespace other than the global namespace) as a command with the same
|
||||
@@ -1664,8 +1657,8 @@ TclMakeEnsemble(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
NsEnsembleImplementationCmd(
|
||||
int
|
||||
TclEnsembleImplementationCmd(
|
||||
ClientData clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
@@ -2117,22 +2110,27 @@ TclSpellFix(
|
||||
iPtr->ensembleRewrite.numInsertedObjs = 0;
|
||||
}
|
||||
|
||||
/* Compute the valid length of the ensemble root */
|
||||
/*
|
||||
* Compute the valid length of the ensemble root.
|
||||
*/
|
||||
|
||||
size = iPtr->ensembleRewrite.numRemovedObjs + objc
|
||||
- iPtr->ensembleRewrite.numInsertedObjs;
|
||||
- iPtr->ensembleRewrite.numInsertedObjs;
|
||||
|
||||
search = iPtr->ensembleRewrite.sourceObjs;
|
||||
if (search[0] == NULL) {
|
||||
/* Awful casting abuse here */
|
||||
/*
|
||||
* Awful casting abuse here...
|
||||
*/
|
||||
search = (Tcl_Obj *const *) search[1];
|
||||
}
|
||||
|
||||
if (badIdx < iPtr->ensembleRewrite.numInsertedObjs) {
|
||||
/*
|
||||
* Misspelled value was inserted. We cannot directly jump
|
||||
* to the bad value, but have to search.
|
||||
* Misspelled value was inserted. We cannot directly jump to the bad
|
||||
* value, but have to search.
|
||||
*/
|
||||
|
||||
idx = 1;
|
||||
while (idx < size) {
|
||||
if (search[idx] == bad) {
|
||||
@@ -2156,13 +2154,14 @@ TclSpellFix(
|
||||
|
||||
search = iPtr->ensembleRewrite.sourceObjs;
|
||||
if (search[0] == NULL) {
|
||||
store = (Tcl_Obj **)search[2];
|
||||
} else {
|
||||
store = (Tcl_Obj **) search[2];
|
||||
} else {
|
||||
Tcl_Obj **tmp = ckalloc(3 * sizeof(Tcl_Obj *));
|
||||
|
||||
tmp[0] = NULL;
|
||||
tmp[1] = (Tcl_Obj *)iPtr->ensembleRewrite.sourceObjs;
|
||||
tmp[2] = (Tcl_Obj *)ckalloc(size * sizeof(Tcl_Obj *));
|
||||
memcpy(tmp[2], tmp[1], size*sizeof(Tcl_Obj *));
|
||||
tmp[1] = (Tcl_Obj *) iPtr->ensembleRewrite.sourceObjs;
|
||||
tmp[2] = (Tcl_Obj *) ckalloc(size * sizeof(Tcl_Obj *));
|
||||
memcpy(tmp[2], tmp[1], size * sizeof(Tcl_Obj *));
|
||||
|
||||
iPtr->ensembleRewrite.sourceObjs = (Tcl_Obj *const *) tmp;
|
||||
TclNRAddCallback(interp, FreeER, tmp, NULL, NULL, NULL);
|
||||
@@ -2589,7 +2588,9 @@ BuildEnsembleConfig(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Usual case where we can freely act on the list and dict. */
|
||||
/*
|
||||
* Usual case where we can freely act on the list and dict.
|
||||
*/
|
||||
|
||||
for (i = 0; i < subc; i++) {
|
||||
name = TclGetString(subv[i]);
|
||||
@@ -2598,7 +2599,10 @@ BuildEnsembleConfig(
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Lookup target in the dictionary */
|
||||
/*
|
||||
* Lookup target in the dictionary.
|
||||
*/
|
||||
|
||||
if (mapDict) {
|
||||
Tcl_DictObjGet(NULL, mapDict, subv[i], &target);
|
||||
if (target) {
|
||||
@@ -2610,10 +2614,11 @@ BuildEnsembleConfig(
|
||||
|
||||
/*
|
||||
* target was not in the dictionary so map onto the namespace.
|
||||
* Note in this case that we do not guarantee that the
|
||||
* command is actually there; that is the programmer's
|
||||
* responsibility (or [::unknown] of course).
|
||||
* Note in this case that we do not guarantee that the command
|
||||
* is actually there; that is the programmer's responsibility
|
||||
* (or [::unknown] of course).
|
||||
*/
|
||||
|
||||
cmdObj = Tcl_NewStringObj(name, -1);
|
||||
cmdPrefixObj = Tcl_NewListObj(1, &cmdObj);
|
||||
Tcl_SetHashValue(hPtr, cmdPrefixObj);
|
||||
|
||||
+12
-1
@@ -723,14 +723,25 @@ TclFinalizeEnvironment(void)
|
||||
* strings. This may leak more memory that strictly necessary, since some
|
||||
* of the strings may no longer be in the environment. However,
|
||||
* determining which ones are ok to delete is n-squared, and is pretty
|
||||
* unlikely, so we don't bother.
|
||||
* unlikely, so we don't bother. However, in the case of DPURIFY, just
|
||||
* free all strings in the cache.
|
||||
*/
|
||||
|
||||
if (env.cache) {
|
||||
#ifdef PURIFY
|
||||
int i;
|
||||
for (i = 0; i < env.cacheSize; i++) {
|
||||
ckfree(env.cache[i]);
|
||||
}
|
||||
#endif
|
||||
ckfree(env.cache);
|
||||
env.cache = NULL;
|
||||
env.cacheSize = 0;
|
||||
#ifndef USE_PUTENV
|
||||
if ((env.ourEnviron != NULL)) {
|
||||
ckfree(env.ourEnviron);
|
||||
env.ourEnviron = NULL;
|
||||
}
|
||||
env.ourEnvironSize = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
+5
-5
@@ -100,7 +100,7 @@ typedef struct ThreadSpecificData {
|
||||
} ThreadSpecificData;
|
||||
static Tcl_ThreadDataKey dataKey;
|
||||
|
||||
#ifdef TCL_THREADS
|
||||
#if TCL_THREADS
|
||||
typedef struct {
|
||||
Tcl_ThreadCreateProc *proc; /* Main() function of the thread */
|
||||
ClientData clientData; /* The one argument to Main() */
|
||||
@@ -1043,7 +1043,7 @@ TclInitSubsystems(void)
|
||||
#if USE_TCLALLOC
|
||||
TclInitAlloc(); /* Process wide mutex init */
|
||||
#endif
|
||||
#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
|
||||
#if TCL_THREADS && defined(USE_THREAD_ALLOC)
|
||||
TclInitThreadAlloc(); /* Setup thread allocator caches */
|
||||
#endif
|
||||
#ifdef TCL_MEM_DEBUG
|
||||
@@ -1220,7 +1220,7 @@ Tcl_Finalize(void)
|
||||
* Close down the thread-specific object allocator.
|
||||
*/
|
||||
|
||||
#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
|
||||
#if TCL_THREADS && defined(USE_THREAD_ALLOC)
|
||||
TclFinalizeThreadAlloc();
|
||||
#endif
|
||||
|
||||
@@ -1538,7 +1538,7 @@ Tcl_UpdateObjCmd(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
#ifdef TCL_THREADS
|
||||
#if TCL_THREADS
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
@@ -1601,7 +1601,7 @@ Tcl_CreateThread(
|
||||
int flags) /* Flags controlling behaviour of the new
|
||||
* thread. */
|
||||
{
|
||||
#ifdef TCL_THREADS
|
||||
#if TCL_THREADS
|
||||
ThreadClientData *cdPtr = ckalloc(sizeof(ThreadClientData));
|
||||
int result;
|
||||
|
||||
|
||||
+71
-147
@@ -500,7 +500,7 @@ VarHashCreateVar(
|
||||
|
||||
#define GetNumberFromObj(interp, objPtr, ptrPtr, tPtr) \
|
||||
(((objPtr)->typePtr == &tclIntType) \
|
||||
? (*(tPtr) = TCL_NUMBER_WIDE, \
|
||||
? (*(tPtr) = TCL_NUMBER_INT, \
|
||||
*(ptrPtr) = (ClientData) \
|
||||
(&((objPtr)->internalRep.wideValue)), TCL_OK) : \
|
||||
((objPtr)->typePtr == &tclDoubleType) \
|
||||
@@ -3620,7 +3620,7 @@ TEBCresume(
|
||||
|
||||
objPtr = varPtr->value.objPtr;
|
||||
if (GetNumberFromObj(NULL, objPtr, &ptr, &type) == TCL_OK) {
|
||||
if (type == TCL_NUMBER_WIDE) {
|
||||
if (type == TCL_NUMBER_INT) {
|
||||
Tcl_WideInt augend = *((const Tcl_WideInt *)ptr);
|
||||
Tcl_WideInt sum = augend + increment;
|
||||
|
||||
@@ -3662,7 +3662,7 @@ TEBCresume(
|
||||
TclSetIntObj(objPtr, w+increment);
|
||||
}
|
||||
goto doneIncr;
|
||||
} /* end if (type == TCL_NUMBER_WIDE) */
|
||||
} /* end if (type == TCL_NUMBER_INT) */
|
||||
}
|
||||
if (Tcl_IsShared(objPtr)) {
|
||||
objPtr->refCount--; /* We know it's shared */
|
||||
@@ -4070,10 +4070,7 @@ TEBCresume(
|
||||
TRACE_ERROR(interp);
|
||||
goto gotError;
|
||||
}
|
||||
TclSetVarArray(varPtr);
|
||||
varPtr->value.tablePtr = ckalloc(sizeof(TclVarHashTable));
|
||||
TclInitVarHashTable(varPtr->value.tablePtr,
|
||||
TclGetVarNsPtr(varPtr));
|
||||
TclInitArrayVar(varPtr);
|
||||
#ifdef TCL_COMPILE_DEBUG
|
||||
TRACE_APPEND(("done\n"));
|
||||
} else {
|
||||
@@ -4764,7 +4761,7 @@ TEBCresume(
|
||||
|
||||
if ((TclListObjGetElements(interp, valuePtr, &objc, &objv) == TCL_OK)
|
||||
&& (value2Ptr->typePtr != &tclListType)
|
||||
&& (TclGetIntForIndexM(NULL , value2Ptr, objc-1,
|
||||
&& (TclGetIntForIndexM(NULL, value2Ptr, objc-1,
|
||||
&index) == TCL_OK)) {
|
||||
TclDecrRefCount(value2Ptr);
|
||||
tosPtr--;
|
||||
@@ -4964,7 +4961,7 @@ TEBCresume(
|
||||
|
||||
/* Decode index value operands. */
|
||||
|
||||
/*
|
||||
/*
|
||||
assert ( toIdx != TCL_INDEX_AFTER);
|
||||
*
|
||||
* Extra safety for legacy bytecodes:
|
||||
@@ -5088,88 +5085,10 @@ TEBCresume(
|
||||
value2Ptr = OBJ_AT_TOS;
|
||||
valuePtr = OBJ_UNDER_TOS;
|
||||
|
||||
if (valuePtr == value2Ptr) {
|
||||
match = 0;
|
||||
} else {
|
||||
/*
|
||||
* We only need to check (in)equality when we have equal length
|
||||
* strings. We can use memcmp in all (n)eq cases because we
|
||||
* don't need to worry about lexical LE/BE variance.
|
||||
*/
|
||||
|
||||
typedef int (*memCmpFn_t)(const void*, const void*, size_t);
|
||||
memCmpFn_t memCmpFn;
|
||||
{
|
||||
int checkEq = ((*pc == INST_EQ) || (*pc == INST_NEQ)
|
||||
|| (*pc == INST_STR_EQ) || (*pc == INST_STR_NEQ));
|
||||
|
||||
if (TclIsPureByteArray(valuePtr)
|
||||
&& TclIsPureByteArray(value2Ptr)) {
|
||||
s1 = (char *) Tcl_GetByteArrayFromObj(valuePtr, &s1len);
|
||||
s2 = (char *) Tcl_GetByteArrayFromObj(value2Ptr, &s2len);
|
||||
memCmpFn = memcmp;
|
||||
} else if ((valuePtr->typePtr == &tclStringType)
|
||||
&& (value2Ptr->typePtr == &tclStringType)) {
|
||||
/*
|
||||
* Do a unicode-specific comparison if both of the args are of
|
||||
* String type. If the char length == byte length, we can do a
|
||||
* memcmp. In benchmark testing this proved the most efficient
|
||||
* check between the unicode and string comparison operations.
|
||||
*/
|
||||
|
||||
s1len = Tcl_GetCharLength(valuePtr);
|
||||
s2len = Tcl_GetCharLength(value2Ptr);
|
||||
if ((s1len == valuePtr->length)
|
||||
&& (valuePtr->bytes != NULL)
|
||||
&& (s2len == value2Ptr->length)
|
||||
&& (value2Ptr->bytes != NULL)) {
|
||||
s1 = valuePtr->bytes;
|
||||
s2 = value2Ptr->bytes;
|
||||
memCmpFn = memcmp;
|
||||
} else {
|
||||
s1 = (char *) Tcl_GetUnicode(valuePtr);
|
||||
s2 = (char *) Tcl_GetUnicode(value2Ptr);
|
||||
if (
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
1
|
||||
#else
|
||||
checkEq
|
||||
#endif
|
||||
) {
|
||||
memCmpFn = memcmp;
|
||||
s1len *= sizeof(Tcl_UniChar);
|
||||
s2len *= sizeof(Tcl_UniChar);
|
||||
} else {
|
||||
memCmpFn = (memCmpFn_t) Tcl_UniCharNcmp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* strcmp can't do a simple memcmp in order to handle the
|
||||
* special Tcl \xC0\x80 null encoding for utf-8.
|
||||
*/
|
||||
|
||||
s1 = TclGetStringFromObj(valuePtr, &s1len);
|
||||
s2 = TclGetStringFromObj(value2Ptr, &s2len);
|
||||
if (checkEq) {
|
||||
memCmpFn = memcmp;
|
||||
} else {
|
||||
memCmpFn = (memCmpFn_t) TclpUtfNcmp2;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkEq && (s1len != s2len)) {
|
||||
match = 1;
|
||||
} else {
|
||||
/*
|
||||
* The comparison function should compare up to the minimum
|
||||
* byte length only.
|
||||
*/
|
||||
match = memCmpFn(s1, s2,
|
||||
(size_t) ((s1len < s2len) ? s1len : s2len));
|
||||
if (match == 0) {
|
||||
match = s1len - s2len;
|
||||
}
|
||||
}
|
||||
match = TclStringCmp(valuePtr, value2Ptr, checkEq, 0, -1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5301,9 +5220,15 @@ TEBCresume(
|
||||
* but creating the object as a string seems to be faster in
|
||||
* practical use.
|
||||
*/
|
||||
|
||||
length = (ch != -1) ? Tcl_UniCharToUtf(ch, buf) : 0;
|
||||
objResultPtr = Tcl_NewStringObj(buf, length);
|
||||
if (ch == -1) {
|
||||
objResultPtr = Tcl_NewObj();
|
||||
} else {
|
||||
length = Tcl_UniCharToUtf(ch, buf);
|
||||
if (!length) {
|
||||
length = Tcl_UniCharToUtf(-1, buf);
|
||||
}
|
||||
objResultPtr = Tcl_NewStringObj(buf, length);
|
||||
}
|
||||
}
|
||||
|
||||
TRACE_APPEND(("\"%s\"\n", O2S(objResultPtr)));
|
||||
@@ -5706,22 +5631,13 @@ TEBCresume(
|
||||
case INST_NUM_TYPE:
|
||||
if (GetNumberFromObj(NULL, OBJ_AT_TOS, &ptr1, &type1) != TCL_OK) {
|
||||
type1 = 0;
|
||||
} else if (type1 == TCL_NUMBER_WIDE) {
|
||||
/* value is between LLONG_MIN and LLONG_MAX */
|
||||
/* [string is integer] is -UINT_MAX to UINT_MAX range */
|
||||
/* [string is wideinteger] is -ULLONG_MAX to ULLONG_MAX range */
|
||||
int i;
|
||||
|
||||
if (Tcl_GetIntFromObj(NULL, OBJ_AT_TOS, &i) == TCL_OK) {
|
||||
type1 = TCL_NUMBER_LONG;
|
||||
}
|
||||
} else if (type1 == TCL_NUMBER_BIG) {
|
||||
/* value is an integer outside the LLONG_MIN to LLONG_MAX range */
|
||||
/* [string is wideinteger] is -ULLONG_MAX to ULLONG_MAX range */
|
||||
/* value is an integer outside the WIDE_MIN to WIDE_MAX range */
|
||||
/* [string is wideinteger] is WIDE_MIN to WIDE_MAX range */
|
||||
Tcl_WideInt w;
|
||||
|
||||
if (Tcl_GetWideIntFromObj(NULL, OBJ_AT_TOS, &w) == TCL_OK) {
|
||||
type1 = TCL_NUMBER_WIDE;
|
||||
type1 = TCL_NUMBER_INT;
|
||||
}
|
||||
}
|
||||
TclNewIntObj(objResultPtr, type1);
|
||||
@@ -5739,6 +5655,14 @@ TEBCresume(
|
||||
value2Ptr = OBJ_AT_TOS;
|
||||
valuePtr = OBJ_UNDER_TOS;
|
||||
|
||||
/*
|
||||
Try to determine, without triggering generation of a string
|
||||
representation, whether one value is not a number.
|
||||
*/
|
||||
if (TclCheckEmptyString(valuePtr) > 0 || TclCheckEmptyString(value2Ptr) > 0) {
|
||||
goto stringCompare;
|
||||
}
|
||||
|
||||
if (GetNumberFromObj(NULL, valuePtr, &ptr1, &type1) != TCL_OK
|
||||
|| GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2) != TCL_OK) {
|
||||
/*
|
||||
@@ -5759,7 +5683,7 @@ TEBCresume(
|
||||
compare = MP_EQ;
|
||||
goto convertComparison;
|
||||
}
|
||||
if ((type1 == TCL_NUMBER_WIDE) && (type2 == TCL_NUMBER_WIDE)) {
|
||||
if ((type1 == TCL_NUMBER_INT) && (type2 == TCL_NUMBER_INT)) {
|
||||
w1 = *((const Tcl_WideInt *)ptr1);
|
||||
w2 = *((const Tcl_WideInt *)ptr2);
|
||||
compare = (w1 < w2) ? MP_LT : ((w1 > w2) ? MP_GT : MP_EQ);
|
||||
@@ -5838,7 +5762,7 @@ TEBCresume(
|
||||
* Check for common, simple case.
|
||||
*/
|
||||
|
||||
if ((type1 == TCL_NUMBER_WIDE) && (type2 == TCL_NUMBER_WIDE)) {
|
||||
if ((type1 == TCL_NUMBER_INT) && (type2 == TCL_NUMBER_INT)) {
|
||||
w1 = *((const Tcl_WideInt *)ptr1);
|
||||
w2 = *((const Tcl_WideInt *)ptr2);
|
||||
|
||||
@@ -6078,7 +6002,7 @@ TEBCresume(
|
||||
* an external function.
|
||||
*/
|
||||
|
||||
if ((type1 == TCL_NUMBER_WIDE) && (type2 == TCL_NUMBER_WIDE)) {
|
||||
if ((type1 == TCL_NUMBER_INT) && (type2 == TCL_NUMBER_INT)) {
|
||||
w1 = *((const Tcl_WideInt *)ptr1);
|
||||
w2 = *((const Tcl_WideInt *)ptr2);
|
||||
|
||||
@@ -6125,9 +6049,9 @@ TEBCresume(
|
||||
TRACE(("%s %s => DIVIDE BY ZERO\n",
|
||||
O2S(valuePtr), O2S(value2Ptr)));
|
||||
goto divideByZero;
|
||||
} else if ((w1 == LLONG_MIN) && (w2 == -1)) {
|
||||
} else if ((w1 == WIDE_MIN) && (w2 == -1)) {
|
||||
/*
|
||||
* Can't represent (-LLONG_MIN) as a Tcl_WideInt.
|
||||
* Can't represent (-WIDE_MIN) as a Tcl_WideInt.
|
||||
*/
|
||||
|
||||
goto overflow;
|
||||
@@ -6221,7 +6145,7 @@ TEBCresume(
|
||||
CACHE_STACK_INFO();
|
||||
goto gotError;
|
||||
}
|
||||
if (type1 == TCL_NUMBER_WIDE) {
|
||||
if (type1 == TCL_NUMBER_INT) {
|
||||
w1 = *((const Tcl_WideInt *) ptr1);
|
||||
if (Tcl_IsShared(valuePtr)) {
|
||||
TclNewIntObj(objResultPtr, ~w1);
|
||||
@@ -6258,9 +6182,9 @@ TEBCresume(
|
||||
/* -NaN => NaN */
|
||||
TRACE_APPEND(("%s\n", O2S(valuePtr)));
|
||||
NEXT_INST_F(1, 0, 0);
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
w1 = *((const Tcl_WideInt *) ptr1);
|
||||
if (w1 != LLONG_MIN) {
|
||||
if (w1 != WIDE_MIN) {
|
||||
if (Tcl_IsShared(valuePtr)) {
|
||||
TclNewIntObj(objResultPtr, -w1);
|
||||
TRACE_APPEND(("%s\n", O2S(objResultPtr)));
|
||||
@@ -7937,7 +7861,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
/* TODO: Attempts to re-use unshared operands on stack */
|
||||
|
||||
w2 = 0; /* silence gcc warning */
|
||||
if (type2 == TCL_NUMBER_WIDE) {
|
||||
if (type2 == TCL_NUMBER_INT) {
|
||||
w2 = *((const Tcl_WideInt *)ptr2);
|
||||
if (w2 == 0) {
|
||||
return DIVIDED_BY_ZERO;
|
||||
@@ -7950,7 +7874,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
return constants[0];
|
||||
}
|
||||
}
|
||||
if (type1 == TCL_NUMBER_WIDE) {
|
||||
if (type1 == TCL_NUMBER_INT) {
|
||||
w1 = *((const Tcl_WideInt *)ptr1);
|
||||
|
||||
if (w1 == 0) {
|
||||
@@ -8028,7 +7952,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
*/
|
||||
|
||||
switch (type2) {
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
invalid = (*((const Tcl_WideInt *)ptr2) < (Tcl_WideInt)0);
|
||||
break;
|
||||
case TCL_NUMBER_BIG:
|
||||
@@ -8050,7 +7974,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
* Zero shifted any number of bits is still zero.
|
||||
*/
|
||||
|
||||
if ((type1==TCL_NUMBER_WIDE) && (*((const Tcl_WideInt *)ptr1) == (Tcl_WideInt)0)) {
|
||||
if ((type1==TCL_NUMBER_INT) && (*((const Tcl_WideInt *)ptr1) == (Tcl_WideInt)0)) {
|
||||
return constants[0];
|
||||
}
|
||||
|
||||
@@ -8063,7 +7987,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
* counterparts, leading to incorrect results.
|
||||
*/
|
||||
|
||||
if ((type2 != TCL_NUMBER_WIDE)
|
||||
if ((type2 != TCL_NUMBER_INT)
|
||||
|| (*((const Tcl_WideInt *)ptr2) > INT_MAX)) {
|
||||
/*
|
||||
* Technically, we could hold the value (1 << (INT_MAX+1)) in
|
||||
@@ -8096,7 +8020,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
* Quickly force large right shifts to 0 or -1.
|
||||
*/
|
||||
|
||||
if ((type2 != TCL_NUMBER_WIDE)
|
||||
if ((type2 != TCL_NUMBER_INT)
|
||||
|| (*(const Tcl_WideInt *)ptr2 > INT_MAX)) {
|
||||
/*
|
||||
* Again, technically, the value to be shifted could be an
|
||||
@@ -8107,7 +8031,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
*/
|
||||
|
||||
switch (type1) {
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
zero = (*(const Tcl_WideInt *)ptr1 > (Tcl_WideInt)0);
|
||||
break;
|
||||
case TCL_NUMBER_BIG:
|
||||
@@ -8130,7 +8054,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
* Handle shifts within the native wide range.
|
||||
*/
|
||||
|
||||
if (type1 == TCL_NUMBER_WIDE) {
|
||||
if (type1 == TCL_NUMBER_INT) {
|
||||
w1 = *(const Tcl_WideInt *)ptr1;
|
||||
if ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideInt)) {
|
||||
if (w1 >= (Tcl_WideInt)0) {
|
||||
@@ -8307,7 +8231,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
BIG_RESULT(&bigResult);
|
||||
}
|
||||
|
||||
if ((type1 == TCL_NUMBER_WIDE) || (type2 == TCL_NUMBER_WIDE)) {
|
||||
if ((type1 == TCL_NUMBER_INT) || (type2 == TCL_NUMBER_INT)) {
|
||||
TclGetWideIntFromObj(NULL, valuePtr, &w1);
|
||||
TclGetWideIntFromObj(NULL, value2Ptr, &w2);
|
||||
|
||||
@@ -8361,7 +8285,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
goto doubleResult;
|
||||
}
|
||||
w2 = 0;
|
||||
if (type2 == TCL_NUMBER_WIDE) {
|
||||
if (type2 == TCL_NUMBER_INT) {
|
||||
w2 = *((const Tcl_WideInt *) ptr2);
|
||||
if (w2 == 0) {
|
||||
/*
|
||||
@@ -8379,7 +8303,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
}
|
||||
|
||||
switch (type2) {
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
w2 = *((const Tcl_WideInt *)ptr2);
|
||||
negativeExponent = (w2 < 0);
|
||||
oddExponent = (int) (w2 & (Tcl_WideInt)1);
|
||||
@@ -8393,11 +8317,11 @@ ExecuteExtendedBinaryMathOp(
|
||||
break;
|
||||
}
|
||||
|
||||
if (type1 == TCL_NUMBER_WIDE) {
|
||||
if (type1 == TCL_NUMBER_INT) {
|
||||
w1 = *((const Tcl_WideInt *)ptr1);
|
||||
}
|
||||
if (negativeExponent) {
|
||||
if (type1 == TCL_NUMBER_WIDE) {
|
||||
if (type1 == TCL_NUMBER_INT) {
|
||||
switch (w1) {
|
||||
case 0:
|
||||
/*
|
||||
@@ -8427,7 +8351,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
return constants[0];
|
||||
}
|
||||
|
||||
if (type1 == TCL_NUMBER_WIDE) {
|
||||
if (type1 == TCL_NUMBER_INT) {
|
||||
switch (w1) {
|
||||
case 0:
|
||||
/*
|
||||
@@ -8454,17 +8378,17 @@ ExecuteExtendedBinaryMathOp(
|
||||
* which means the max exponent value is 2**28-1 = 0x0fffffff =
|
||||
* 268435455, which fits into a signed 32 bit int which is within the
|
||||
* range of the long int type. This means any numeric Tcl_Obj value
|
||||
* not using TCL_NUMBER_WIDE type must hold a value larger than we
|
||||
* not using TCL_NUMBER_INT type must hold a value larger than we
|
||||
* accept.
|
||||
*/
|
||||
|
||||
if (type2 != TCL_NUMBER_WIDE) {
|
||||
if (type2 != TCL_NUMBER_INT) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"exponent too large", -1));
|
||||
return GENERAL_ARITHMETIC_ERROR;
|
||||
}
|
||||
|
||||
if (type1 == TCL_NUMBER_WIDE) {
|
||||
if (type1 == TCL_NUMBER_INT) {
|
||||
if (w1 == 2) {
|
||||
/*
|
||||
* Reduce small powers of 2 to shifts.
|
||||
@@ -8488,7 +8412,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
goto overflowExpon;
|
||||
}
|
||||
}
|
||||
if (type1 == TCL_NUMBER_WIDE) {
|
||||
if (type1 == TCL_NUMBER_INT) {
|
||||
w1 = *((const Tcl_WideInt *) ptr1);
|
||||
} else {
|
||||
goto overflowExpon;
|
||||
@@ -8688,7 +8612,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
switch (opcode) {
|
||||
case INST_ADD:
|
||||
wResult = w1 + w2;
|
||||
if ((type1 == TCL_NUMBER_WIDE) || (type2 == TCL_NUMBER_WIDE))
|
||||
if ((type1 == TCL_NUMBER_INT) || (type2 == TCL_NUMBER_INT))
|
||||
{
|
||||
/*
|
||||
* Check for overflow.
|
||||
@@ -8702,7 +8626,7 @@ ExecuteExtendedBinaryMathOp(
|
||||
|
||||
case INST_SUB:
|
||||
wResult = w1 - w2;
|
||||
if ((type1 == TCL_NUMBER_WIDE) || (type2 == TCL_NUMBER_WIDE))
|
||||
if ((type1 == TCL_NUMBER_INT) || (type2 == TCL_NUMBER_INT))
|
||||
{
|
||||
/*
|
||||
* Must check for overflow. The macro tests for overflows
|
||||
@@ -8734,10 +8658,10 @@ ExecuteExtendedBinaryMathOp(
|
||||
}
|
||||
|
||||
/*
|
||||
* Need a bignum to represent (LLONG_MIN / -1)
|
||||
* Need a bignum to represent (WIDE_MIN / -1)
|
||||
*/
|
||||
|
||||
if ((w1 == LLONG_MIN) && (w2 == -1)) {
|
||||
if ((w1 == WIDE_MIN) && (w2 == -1)) {
|
||||
goto overflowBasic;
|
||||
}
|
||||
wResult = w1 / w2;
|
||||
@@ -8825,7 +8749,7 @@ ExecuteExtendedUnaryMathOp(
|
||||
|
||||
switch (opcode) {
|
||||
case INST_BITNOT:
|
||||
if (type == TCL_NUMBER_WIDE) {
|
||||
if (type == TCL_NUMBER_INT) {
|
||||
w = *((const Tcl_WideInt *) ptr);
|
||||
WIDE_RESULT(~w);
|
||||
}
|
||||
@@ -8838,9 +8762,9 @@ ExecuteExtendedUnaryMathOp(
|
||||
switch (type) {
|
||||
case TCL_NUMBER_DOUBLE:
|
||||
DOUBLE_RESULT(-(*((const double *) ptr)));
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
w = *((const Tcl_WideInt *) ptr);
|
||||
if (w != LLONG_MIN) {
|
||||
if (w != WIDE_MIN) {
|
||||
WIDE_RESULT(-w);
|
||||
}
|
||||
TclInitBignumFromWideInt(&big, w);
|
||||
@@ -8892,10 +8816,10 @@ TclCompareTwoNumbers(
|
||||
(void) GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2);
|
||||
|
||||
switch (type1) {
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
w1 = *((const Tcl_WideInt *)ptr1);
|
||||
switch (type2) {
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
w2 = *((const Tcl_WideInt *)ptr2);
|
||||
wideCompare:
|
||||
return (w1 < w2) ? MP_LT : ((w1 > w2) ? MP_GT : MP_EQ);
|
||||
@@ -8926,10 +8850,10 @@ TclCompareTwoNumbers(
|
||||
* integer comparison can tell the difference.
|
||||
*/
|
||||
|
||||
if (d2 < (double)LLONG_MIN) {
|
||||
if (d2 < (double)WIDE_MIN) {
|
||||
return MP_GT;
|
||||
}
|
||||
if (d2 > (double)LLONG_MAX) {
|
||||
if (d2 > (double)WIDE_MAX) {
|
||||
return MP_LT;
|
||||
}
|
||||
w2 = (Tcl_WideInt) d2;
|
||||
@@ -8952,17 +8876,17 @@ TclCompareTwoNumbers(
|
||||
d2 = *((const double *)ptr2);
|
||||
doubleCompare:
|
||||
return (d1 < d2) ? MP_LT : ((d1 > d2) ? MP_GT : MP_EQ);
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
w2 = *((const Tcl_WideInt *)ptr2);
|
||||
d2 = (double) w2;
|
||||
if (DBL_MANT_DIG > CHAR_BIT*sizeof(Tcl_WideInt)
|
||||
|| w2 == (Tcl_WideInt) d2 || modf(d1, &tmp) != 0.0) {
|
||||
goto doubleCompare;
|
||||
}
|
||||
if (d1 < (double)LLONG_MIN) {
|
||||
if (d1 < (double)WIDE_MIN) {
|
||||
return MP_LT;
|
||||
}
|
||||
if (d1 > (double)LLONG_MAX) {
|
||||
if (d1 > (double)WIDE_MAX) {
|
||||
return MP_GT;
|
||||
}
|
||||
w1 = (Tcl_WideInt) d1;
|
||||
@@ -8972,7 +8896,7 @@ TclCompareTwoNumbers(
|
||||
return (d1 > 0.0) ? MP_GT : MP_LT;
|
||||
}
|
||||
Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
|
||||
if ((d1 < (double)LLONG_MAX) && (d1 > (double)LLONG_MIN)) {
|
||||
if ((d1 < (double)WIDE_MAX) && (d1 > (double)WIDE_MIN)) {
|
||||
if (mp_isneg(&big2)) {
|
||||
compare = MP_GT;
|
||||
} else {
|
||||
@@ -8994,7 +8918,7 @@ TclCompareTwoNumbers(
|
||||
case TCL_NUMBER_BIG:
|
||||
Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
|
||||
switch (type2) {
|
||||
case TCL_NUMBER_WIDE:
|
||||
case TCL_NUMBER_INT:
|
||||
compare = mp_cmp_d(&big1, 0);
|
||||
mp_clear(&big1);
|
||||
return compare;
|
||||
@@ -9005,7 +8929,7 @@ TclCompareTwoNumbers(
|
||||
mp_clear(&big1);
|
||||
return compare;
|
||||
}
|
||||
if ((d2 < (double)LLONG_MAX) && (d2 > (double)LLONG_MIN)) {
|
||||
if ((d2 < (double)WIDE_MAX) && (d2 > (double)WIDE_MIN)) {
|
||||
compare = mp_cmp_d(&big1, 0);
|
||||
mp_clear(&big1);
|
||||
return compare;
|
||||
|
||||
+20
-14
@@ -240,9 +240,13 @@ TclFileMakeDirsCmd(
|
||||
break;
|
||||
}
|
||||
for (j = 0; j < pobjc; j++) {
|
||||
int errCount = 2;
|
||||
|
||||
target = Tcl_FSJoinPath(split, j + 1);
|
||||
Tcl_IncrRefCount(target);
|
||||
|
||||
createDir:
|
||||
|
||||
/*
|
||||
* Call Tcl_FSStat() so that if target is a symlink that points to
|
||||
* a directory we will create subdirectories in that directory.
|
||||
@@ -269,23 +273,25 @@ TclFileMakeDirsCmd(
|
||||
* subdirectory.
|
||||
*/
|
||||
|
||||
if (errno != EEXIST) {
|
||||
errfile = target;
|
||||
goto done;
|
||||
} else if ((Tcl_FSStat(target, &statBuf) == 0)
|
||||
&& S_ISDIR(statBuf.st_mode)) {
|
||||
/*
|
||||
* It is a directory that wasn't there before, so keep
|
||||
* going without error.
|
||||
*/
|
||||
|
||||
Tcl_ResetResult(interp);
|
||||
} else {
|
||||
errfile = target;
|
||||
goto done;
|
||||
if (errno == EEXIST) {
|
||||
/* Be aware other workers could delete it immediately after
|
||||
* creation, so give this worker still one chance (repeat once),
|
||||
* see [270f78ca95] for description of the race-condition.
|
||||
* Don't repeat the create always (to avoid endless loop). */
|
||||
if (--errCount > 0) {
|
||||
goto createDir;
|
||||
}
|
||||
/* Already tried, with delete in-between directly after
|
||||
* creation, so just continue (assume created successful). */
|
||||
goto nextPart;
|
||||
}
|
||||
|
||||
/* return with error */
|
||||
errfile = target;
|
||||
goto done;
|
||||
}
|
||||
|
||||
nextPart:
|
||||
/*
|
||||
* Forget about this sub-path.
|
||||
*/
|
||||
|
||||
@@ -1881,7 +1881,7 @@ TclGlob(
|
||||
separators = "/\\";
|
||||
|
||||
} else if (tclPlatform == TCL_PLATFORM_UNIX) {
|
||||
if (pathPrefix == NULL && tail[0] == '/') {
|
||||
if (pathPrefix == NULL && tail[0] == '/' && tail[1] != '/') {
|
||||
pathPrefix = Tcl_NewStringObj(tail, 1);
|
||||
tail++;
|
||||
Tcl_IncrRefCount(pathPrefix);
|
||||
|
||||
@@ -897,7 +897,7 @@ TclDatelex(
|
||||
|
||||
location->first_column = yyInput - info->dateStart;
|
||||
for ( ; ; ) {
|
||||
while (isspace(UCHAR(*yyInput))) {
|
||||
while (TclIsSpaceProc(UCHAR(*yyInput))) {
|
||||
yyInput++;
|
||||
}
|
||||
|
||||
|
||||
+17
-17
@@ -482,13 +482,13 @@ ChanSeek(
|
||||
offset, mode, errnoPtr);
|
||||
}
|
||||
|
||||
if (offset<Tcl_LongAsWide(LONG_MIN) || offset>Tcl_LongAsWide(LONG_MAX)) {
|
||||
if (offset<LONG_MIN || offset>LONG_MAX) {
|
||||
*errnoPtr = EOVERFLOW;
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return Tcl_LongAsWide(chanPtr->typePtr->seekProc(chanPtr->instanceData,
|
||||
Tcl_WideAsLong(offset), mode, errnoPtr));
|
||||
return chanPtr->typePtr->seekProc(chanPtr->instanceData,
|
||||
offset, mode, errnoPtr);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -6953,7 +6953,7 @@ Tcl_Seek(
|
||||
* non-blocking mode after the seek. */
|
||||
|
||||
if (CheckChannelErrors(statePtr, TCL_WRITABLE | TCL_READABLE) != 0) {
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6964,7 +6964,7 @@ Tcl_Seek(
|
||||
*/
|
||||
|
||||
if (CheckForDeadChannel(NULL, statePtr)) {
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6980,7 +6980,7 @@ Tcl_Seek(
|
||||
|
||||
if (chanPtr->typePtr->seekProc == NULL) {
|
||||
Tcl_SetErrno(EINVAL);
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6993,7 +6993,7 @@ Tcl_Seek(
|
||||
|
||||
if ((inputBuffered != 0) && (outputBuffered != 0)) {
|
||||
Tcl_SetErrno(EFAULT);
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -7036,7 +7036,7 @@ Tcl_Seek(
|
||||
wasAsync = 1;
|
||||
result = StackSetBlockMode(chanPtr, TCL_MODE_BLOCKING);
|
||||
if (result != 0) {
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
ResetFlag(statePtr, CHANNEL_NONBLOCKING);
|
||||
if (GotFlag(statePtr, BG_FLUSH_SCHEDULED)) {
|
||||
@@ -7061,7 +7061,7 @@ Tcl_Seek(
|
||||
*/
|
||||
|
||||
curPos = ChanSeek(chanPtr, offset, mode, &result);
|
||||
if (curPos == Tcl_LongAsWide(-1)) {
|
||||
if (curPos == -1) {
|
||||
Tcl_SetErrno(result);
|
||||
}
|
||||
}
|
||||
@@ -7077,7 +7077,7 @@ Tcl_Seek(
|
||||
SetFlag(statePtr, CHANNEL_NONBLOCKING);
|
||||
result = StackSetBlockMode(chanPtr, TCL_MODE_NONBLOCKING);
|
||||
if (result != 0) {
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7117,7 +7117,7 @@ Tcl_Tell(
|
||||
Tcl_WideInt curPos; /* Position on device. */
|
||||
|
||||
if (CheckChannelErrors(statePtr, TCL_WRITABLE | TCL_READABLE) != 0) {
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -7128,7 +7128,7 @@ Tcl_Tell(
|
||||
*/
|
||||
|
||||
if (CheckForDeadChannel(NULL, statePtr)) {
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -7144,7 +7144,7 @@ Tcl_Tell(
|
||||
|
||||
if (chanPtr->typePtr->seekProc == NULL) {
|
||||
Tcl_SetErrno(EINVAL);
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -7161,10 +7161,10 @@ Tcl_Tell(
|
||||
* wideSeekProc if that is available and non-NULL...
|
||||
*/
|
||||
|
||||
curPos = ChanSeek(chanPtr, Tcl_LongAsWide(0), SEEK_CUR, &result);
|
||||
if (curPos == Tcl_LongAsWide(-1)) {
|
||||
curPos = ChanSeek(chanPtr, 0, SEEK_CUR, &result);
|
||||
if (curPos == -1) {
|
||||
Tcl_SetErrno(result);
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (inputBuffered != 0) {
|
||||
|
||||
+3
-3
@@ -559,7 +559,7 @@ Tcl_SeekObjCmd(
|
||||
|
||||
TclChannelPreserve(chan);
|
||||
result = Tcl_Seek(chan, offset, mode);
|
||||
if (result == Tcl_LongAsWide(-1)) {
|
||||
if (result == -1) {
|
||||
/*
|
||||
* TIP #219.
|
||||
* Capture error messages put by the driver into the bypass area and
|
||||
@@ -991,7 +991,7 @@ Tcl_ExecObjCmd(
|
||||
|
||||
resultPtr = Tcl_NewObj();
|
||||
if (Tcl_GetChannelHandle(chan, TCL_READABLE, NULL) == TCL_OK) {
|
||||
if (Tcl_ReadChars(chan, resultPtr, -1, 0) < 0) {
|
||||
if (Tcl_ReadChars(chan, resultPtr, -1, 0) == TCL_IO_FAILURE) {
|
||||
/*
|
||||
* TIP #219.
|
||||
* Capture error messages put by the driver into the bypass area
|
||||
@@ -1913,7 +1913,7 @@ ChanTruncateObjCmd(
|
||||
*/
|
||||
|
||||
length = Tcl_Tell(chan);
|
||||
if (length == Tcl_WideAsLong(-1)) {
|
||||
if (length == -1) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"could not determine current location in \"%s\": %s",
|
||||
TclGetString(objv[1]), Tcl_PosixError(interp)));
|
||||
|
||||
+6
-7
@@ -910,7 +910,7 @@ TransformWideSeekProc(
|
||||
Tcl_ChannelWideSeekProc(parentType);
|
||||
ClientData parentData = Tcl_GetChannelInstanceData(parent);
|
||||
|
||||
if ((offset == Tcl_LongAsWide(0)) && (mode == SEEK_CUR)) {
|
||||
if ((offset == 0) && (mode == SEEK_CUR)) {
|
||||
/*
|
||||
* This is no seek but a request to tell the caller the current
|
||||
* location. Simply pass the request down.
|
||||
@@ -920,8 +920,7 @@ TransformWideSeekProc(
|
||||
return parentWideSeekProc(parentData, offset, mode, errorCodePtr);
|
||||
}
|
||||
|
||||
return Tcl_LongAsWide(parentSeekProc(parentData, 0, mode,
|
||||
errorCodePtr));
|
||||
return parentSeekProc(parentData, 0, mode, errorCodePtr);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -961,13 +960,13 @@ TransformWideSeekProc(
|
||||
* to go out of the representable range.
|
||||
*/
|
||||
|
||||
if (offset<Tcl_LongAsWide(LONG_MIN) || offset>Tcl_LongAsWide(LONG_MAX)) {
|
||||
if (offset<LONG_MIN || offset>LONG_MAX) {
|
||||
*errorCodePtr = EOVERFLOW;
|
||||
return Tcl_LongAsWide(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return Tcl_LongAsWide(parentSeekProc(parentData, Tcl_WideAsLong(offset),
|
||||
mode, errorCodePtr));
|
||||
return parentSeekProc(parentData, offset,
|
||||
mode, errorCodePtr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user