Compare commits
1142
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69e27dde73 | ||
|
|
6cce62dfa9 | ||
|
|
25a0608a64 | ||
|
|
4c15a17bf6 | ||
|
|
d295348dcb | ||
|
|
b47d0162c0 | ||
|
|
fc505694a7 | ||
|
|
493ca3e252 | ||
|
|
f88c4e5888 | ||
|
|
03db5509cb | ||
|
|
d5dd41e2dc | ||
|
|
d829524680 | ||
|
|
6d694a4a58 | ||
|
|
5dacc6b3a1 | ||
|
|
82d5602230 | ||
|
|
7c1efd67ff | ||
|
|
98835eec24 | ||
|
|
e468eaa396 | ||
|
|
44c89ad3da | ||
|
|
73966c80ec | ||
|
|
fac5553b22 | ||
|
|
6864aa8630 | ||
|
|
dd5ce98caf | ||
|
|
9a590427db | ||
|
|
f7102e9bed | ||
|
|
38b42e537f | ||
|
|
076d0a2826 | ||
|
|
11d909170e | ||
|
|
c2026f5d9e | ||
|
|
0567d26923 | ||
|
|
d2f1ddbd5a | ||
|
|
52d5988afb | ||
|
|
9cb69ad5a5 | ||
|
|
2e5c3f490c | ||
|
|
433b79dddf | ||
|
|
5cebe86a7b | ||
|
|
bd86ca3002 | ||
|
|
840dc55263 | ||
|
|
1d69ca636a | ||
|
|
e5414e6828 | ||
|
|
fd9da6647c | ||
|
|
e066172aa1 | ||
|
|
a87dca3c87 | ||
|
|
6c5c8f2115 | ||
|
|
b8816caf0a | ||
|
|
df8ee8dd79 | ||
|
|
b7f9587bb9 | ||
|
|
90bfa96249 | ||
|
|
d178ebdc94 | ||
|
|
b7511b9b1f | ||
|
|
c815794e4b | ||
|
|
4e9a1a8037 | ||
|
|
a5ba98a55c | ||
|
|
d57a96e3f7 | ||
|
|
360cd8dbe2 | ||
|
|
cd4dc1e6d1 | ||
|
|
527ea012f3 | ||
|
|
019a9ffbee | ||
|
|
908f5d54a7 | ||
|
|
91d10c556b | ||
|
|
13d1930154 | ||
|
|
4975b01a21 | ||
|
|
89caf46a5f | ||
|
|
eb610c0323 | ||
|
|
cff5336ec7 | ||
|
|
f2ad9517c7 | ||
|
|
c4d39c4d22 | ||
|
|
174db0f935 | ||
|
|
29cf77977e | ||
|
|
55e6e2c218 | ||
|
|
88116ba76d | ||
|
|
3678822e7f | ||
|
|
0171a9eb60 | ||
|
|
edacc8f70d | ||
|
|
2a3e4cf7b2 | ||
|
|
94e87c9377 | ||
|
|
f9afa950e2 | ||
|
|
6c24c71ddb | ||
|
|
a9f97e9e61 | ||
|
|
0c3455d329 | ||
|
|
1a1804afcb | ||
|
|
582717a7b4 | ||
|
|
07dc653ae1 | ||
|
|
d79fe7fd58 | ||
|
|
a9ce7244b4 | ||
|
|
34182cca7b | ||
|
|
d18b2d078c | ||
|
|
cc4efc49e1 | ||
|
|
e615bdc407 | ||
|
|
9600a5c781 | ||
|
|
d57d9737d7 | ||
|
|
2de3bc3732 | ||
|
|
77417c1335 | ||
|
|
e660003abf | ||
|
|
80052e5275 | ||
|
|
a17dd3248a | ||
|
|
6306ac8966 | ||
|
|
9163e09605 | ||
|
|
15fa1dec99 | ||
|
|
ccc79e592c | ||
|
|
50a7022ea6 | ||
|
|
8c61ebad0a | ||
|
|
d24c3d2263 | ||
|
|
63b5c7b553 | ||
|
|
5b9e63e4af | ||
|
|
503fae5dc9 | ||
|
|
087100183c | ||
|
|
baecf2ce9e | ||
|
|
e7d37983c4 | ||
|
|
07b18a33fe | ||
|
|
cf615152e1 | ||
|
|
fa3733cc4c | ||
|
|
82987df98d | ||
|
|
839316e66b | ||
|
|
d235e97f5e | ||
|
|
4c2e63a658 | ||
|
|
24564b2d34 | ||
|
|
707022b0e5 | ||
|
|
2065d6c3aa | ||
|
|
e74eab828e | ||
|
|
bda75c3142 | ||
|
|
9b51a0852a | ||
|
|
74c44bc9a3 | ||
|
|
4860ed4396 | ||
|
|
cf4b48c7ba | ||
|
|
b6be13d5de | ||
|
|
37b2d2129e | ||
|
|
78774647e1 | ||
|
|
a97638713a | ||
|
|
8d9817d2f7 | ||
|
|
e944fe8436 | ||
|
|
ad9fc9f559 | ||
|
|
263e1061ea | ||
|
|
4f58a59f4d | ||
|
|
584370127a | ||
|
|
528a4f5945 | ||
|
|
c4062e09b9 | ||
|
|
70e04d6a8e | ||
|
|
bcd594ed69 | ||
|
|
3c4fcb1594 | ||
|
|
b52fc1043b | ||
|
|
b34af08f67 | ||
|
|
e01398c9db | ||
|
|
dffba62e13 | ||
|
|
2b4d51f697 | ||
|
|
0dab2b18d7 | ||
|
|
3e0a118886 | ||
|
|
c72ed135e4 | ||
|
|
3ea0199e03 | ||
|
|
abed751e96 | ||
|
|
141bb78e96 | ||
|
|
30afc86af1 | ||
|
|
6df393c902 | ||
|
|
f951d0241c | ||
|
|
cc724f105d | ||
|
|
a4756fde3f | ||
|
|
15be4e7915 | ||
|
|
53a3f47076 | ||
|
|
175dbc4e25 | ||
|
|
c1f11855e3 | ||
|
|
76e72a301d | ||
|
|
a1626adb7e | ||
|
|
d1a07cbdc1 | ||
|
|
8c1e7175ec | ||
|
|
fc6df0fdc1 | ||
|
|
78271b179a | ||
|
|
d3abe3a468 | ||
|
|
41b859325b | ||
|
|
6a0bdf6063 | ||
|
|
36c250a03d | ||
|
|
260879a5c3 | ||
|
|
8537b93a43 | ||
|
|
9a0d5be790 | ||
|
|
130152a2ac | ||
|
|
730c730940 | ||
|
|
85caac4473 | ||
|
|
048acee39b | ||
|
|
8a02b2c9c1 | ||
|
|
4f6045a94e | ||
|
|
1ef90acb38 | ||
|
|
e843a4fdf9 | ||
|
|
b2b0bd37a1 | ||
|
|
450ade4818 | ||
|
|
c814c4e001 | ||
|
|
4f4494c770 | ||
|
|
ff014824bc | ||
|
|
8edf58a95f | ||
|
|
88e1f59ec1 | ||
|
|
80b064f97b | ||
|
|
0fc8200ab4 | ||
|
|
87594f81d6 | ||
|
|
def42a31ca | ||
|
|
605bfb3577 | ||
|
|
9fa2e51099 | ||
|
|
3f59bee3e0 | ||
|
|
88613f5469 | ||
|
|
2660b04a73 | ||
|
|
18ac789d6d | ||
|
|
956d40d9dd | ||
|
|
2fd725209e | ||
|
|
21be3857b5 | ||
|
|
d29bf5b4fc | ||
|
|
3c5b1419a2 | ||
|
|
012af2186b | ||
|
|
12a628abdc | ||
|
|
63ba2b1637 | ||
|
|
61cd6dbb3b | ||
|
|
4b4fefa254 | ||
|
|
0bc77083ba | ||
|
|
b10878fea7 | ||
|
|
6893284ee5 | ||
|
|
b436156f5b | ||
|
|
fb1c635af6 | ||
|
|
6d3d2750ec | ||
|
|
712330940b | ||
|
|
9c029f7077 | ||
|
|
2760fd365b | ||
|
|
8ea4a5584e | ||
|
|
9caa1ba146 | ||
|
|
bb87e6e30f | ||
|
|
a1f1231a73 | ||
|
|
0ab71031a6 | ||
|
|
2f2d05b087 | ||
|
|
2e01ff1fb6 | ||
|
|
3daecb246a | ||
|
|
cd4f61aee6 | ||
|
|
39a3e2c46f | ||
|
|
0c845aa291 | ||
|
|
341a5fcab3 | ||
|
|
dd4cec664c | ||
|
|
46d1ce2667 | ||
|
|
0673dee1b3 | ||
|
|
3dc5f4e948 | ||
|
|
90bc29c1b5 | ||
|
|
7fd9e86ea6 | ||
|
|
e113c67d51 | ||
|
|
bf88c73c20 | ||
|
|
ae11f111a5 | ||
|
|
2ce1e323df | ||
|
|
68d0048148 | ||
|
|
bafb43e589 | ||
|
|
c163e88af3 | ||
|
|
bd34b8dd2e | ||
|
|
61edf3fa93 | ||
|
|
8eff744eec | ||
|
|
b4742c1257 | ||
|
|
9a4576e756 | ||
|
|
b5560d8420 | ||
|
|
79ece35981 | ||
|
|
f06deb828a | ||
|
|
0c9eacedaa | ||
|
|
476b36770d | ||
|
|
239278fd3a | ||
|
|
98b36e74b8 | ||
|
|
c3cbbdd8a2 | ||
|
|
18879fb993 | ||
|
|
bdaddcf107 | ||
|
|
7b81a836c3 | ||
|
|
c538237f4e | ||
|
|
4a6241be06 | ||
|
|
1900c7bcac | ||
|
|
578d536233 | ||
|
|
b0d6d28310 | ||
|
|
10d66051ef | ||
|
|
cb3d5aff84 | ||
|
|
ca12bd9b5d | ||
|
|
6d89e297fe | ||
|
|
32d8f2000a | ||
|
|
0bd7614bd5 | ||
|
|
4b4cf789e0 | ||
|
|
76b1fc18f1 | ||
|
|
405071337d | ||
|
|
151b494382 | ||
|
|
12f74b226e | ||
|
|
18753cb7a7 | ||
|
|
71d4ff6ed8 | ||
|
|
7935d307f0 | ||
|
|
38bfec1594 | ||
|
|
2421dfb843 | ||
|
|
94035be3fa | ||
|
|
c8a2a0acc2 | ||
|
|
3a8c8f4747 | ||
|
|
b142d484d5 | ||
|
|
674e9fb7c2 | ||
|
|
6878123202 | ||
|
|
f7bf9a8e96 | ||
|
|
89809a2d0f | ||
|
|
9df19f53e4 | ||
|
|
65cbaac344 | ||
|
|
2fcb257168 | ||
|
|
63791b795a | ||
|
|
ea90b947b0 | ||
|
|
9a0d796298 | ||
|
|
0337027d54 | ||
|
|
8ea21a54ad | ||
|
|
6bac4ed059 | ||
|
|
a03ae02f44 | ||
|
|
45f126514c | ||
|
|
b279713e47 | ||
|
|
3504bd9a2a | ||
|
|
1a8a0ae0f5 | ||
|
|
441b066dd8 | ||
|
|
ef87010059 | ||
|
|
66fb962a66 | ||
|
|
e8abc0a2f6 | ||
|
|
7b1bd99de6 | ||
|
|
8619c6e060 | ||
|
|
2e1f2db8b5 | ||
|
|
ba32b33796 | ||
|
|
6e77b017c5 | ||
|
|
5d058fa416 | ||
|
|
12c60b2f32 | ||
|
|
9801de6979 | ||
|
|
c695f2cd9c | ||
|
|
27c29aeb7b | ||
|
|
06f20603f6 | ||
|
|
607a9e3912 | ||
|
|
d3b4ad04f5 | ||
|
|
e7caf68edd | ||
|
|
c6374b6a1f | ||
|
|
8cde328007 | ||
|
|
02bad4b298 | ||
|
|
9b2179089b | ||
|
|
1c806b74ea | ||
|
|
8001955fb7 | ||
|
|
e6fa039f3f | ||
|
|
e0b784ac6d | ||
|
|
dc679081fa | ||
|
|
597c1f6667 | ||
|
|
125071cf00 | ||
|
|
2fb099e4cf | ||
|
|
6f9646a44f | ||
|
|
bd7b48c1b9 | ||
|
|
aac8132f47 | ||
|
|
7bdf3a39ad | ||
|
|
396543191c | ||
|
|
e24af3c78e | ||
|
|
e82147bbb8 | ||
|
|
d2c3cf49e1 | ||
|
|
e84d17196c | ||
|
|
fd4ae8304e | ||
|
|
83e2cf607f | ||
|
|
61b75639a7 | ||
|
|
19d266b528 | ||
|
|
9c4238c2f6 | ||
|
|
114ac72169 | ||
|
|
a10d7fbb02 | ||
|
|
f33af0b16a | ||
|
|
eeba7b3167 | ||
|
|
e5c30e6fae | ||
|
|
0b8218515e | ||
|
|
1a8a5ee000 | ||
|
|
1740fd036d | ||
|
|
6c635998f8 | ||
|
|
7835a724d6 | ||
|
|
239c357af0 | ||
|
|
d228490162 | ||
|
|
b92a12cf6c | ||
|
|
c514368f98 | ||
|
|
062f86a625 | ||
|
|
c3d13260a7 | ||
|
|
e6e07cd2c6 | ||
|
|
ec4dfd32cc | ||
|
|
c0e01452f2 | ||
|
|
45260890f2 | ||
|
|
4337fc5fe0 | ||
|
|
093d20c3b9 | ||
|
|
ec07936888 | ||
|
|
8e4724e16c | ||
|
|
3afdbb7b7d | ||
|
|
f217fa26ae | ||
|
|
8f6f28c8d3 | ||
|
|
856a4b2f3f | ||
|
|
6d76cd0a99 | ||
|
|
6151f20477 | ||
|
|
ad8d1a8cc8 | ||
|
|
ec583deefa | ||
|
|
5fe053671a | ||
|
|
0d177d240d | ||
|
|
18b4b18b41 | ||
|
|
befd192958 | ||
|
|
79f9ecd150 | ||
|
|
8f115e9eed | ||
|
|
e17ccf2297 | ||
|
|
8eb1367ca4 | ||
|
|
2f79004f85 | ||
|
|
b7a219a91d | ||
|
|
aa279ae7ac | ||
|
|
4060535f9f | ||
|
|
1847333342 | ||
|
|
87c278c8a5 | ||
|
|
143e8dc5e4 | ||
|
|
b80d58e167 | ||
|
|
6c31850e86 | ||
|
|
c8dc164566 | ||
|
|
32e5e6af4b | ||
|
|
4a886f831c | ||
|
|
e3c36777ab | ||
|
|
c2395f0278 | ||
|
|
0791261f07 | ||
|
|
73b8413d10 | ||
|
|
664b8e26f0 | ||
|
|
64ade137bc | ||
|
|
da15e10bd0 | ||
|
|
1f7c24fea7 | ||
|
|
49b8382c5f | ||
|
|
583ab589dc | ||
|
|
c80c07ab68 | ||
|
|
c5875504da | ||
|
|
05d1c09cc1 | ||
|
|
9d6e91ea7b | ||
|
|
4887cfd951 | ||
|
|
9a51696bc0 | ||
|
|
bf271b8062 | ||
|
|
2864fb467e | ||
|
|
4490d9d1f6 | ||
|
|
c4524da3e0 | ||
|
|
58f082d74f | ||
|
|
154d0ee4a8 | ||
|
|
83ab4e273b | ||
|
|
dccda74062 | ||
|
|
b52bebfbe8 | ||
|
|
1758c1ba74 | ||
|
|
83e8ec587f | ||
|
|
63dd033da7 | ||
|
|
91f0dcff5c | ||
|
|
688bb1993f | ||
|
|
94bda489ce | ||
|
|
c9003e521c | ||
|
|
8105255be2 | ||
|
|
f57743eb37 | ||
|
|
0c93eb3379 | ||
|
|
891f28ef5e | ||
|
|
371e74a25f | ||
|
|
9ec27fe362 | ||
|
|
75662a4b05 | ||
|
|
4a993dff29 | ||
|
|
516e79151f | ||
|
|
6c3934de15 | ||
|
|
370833d555 | ||
|
|
302ae77712 | ||
|
|
5d23c240b6 | ||
|
|
7032228879 | ||
|
|
8932cf719f | ||
|
|
7668a4f255 | ||
|
|
2c6c521799 | ||
|
|
19577fcefa | ||
|
|
b8f71d3659 | ||
|
|
2d05b5475c | ||
|
|
44a5c4b0b1 | ||
|
|
a12b9102c7 | ||
|
|
b5f8cb2126 | ||
|
|
31be4a0495 | ||
|
|
e785a17a5f | ||
|
|
b6e3657eda | ||
|
|
ec7c3cf9a7 | ||
|
|
eb2fc1d27e | ||
|
|
73b9e8dc99 | ||
|
|
490a843947 | ||
|
|
6fa1300d39 | ||
|
|
ef0fb50c1c | ||
|
|
3608341c53 | ||
|
|
461f04bd4d | ||
|
|
161a6fa635 | ||
|
|
6d2f917a3a | ||
|
|
8f55d6d4ab | ||
|
|
2306795864 | ||
|
|
e0eb03b96d | ||
|
|
b1083ab367 | ||
|
|
e3e7cea177 | ||
|
|
d36a85a369 | ||
|
|
bd46a5dd52 | ||
|
|
7f87785002 | ||
|
|
0f419563ea | ||
|
|
aff6f49990 | ||
|
|
58a053d7de | ||
|
|
7b5c6a9224 | ||
|
|
5479d7f2dc | ||
|
|
a5b2c55a70 | ||
|
|
b119853aef | ||
|
|
5d08d54636 | ||
|
|
10df52efed | ||
|
|
68f84659f3 | ||
|
|
3ef92863f2 | ||
|
|
dea7868f01 | ||
|
|
16d0e528aa | ||
|
|
c426d494f0 | ||
|
|
9a3f802d20 | ||
|
|
89897b4bcd | ||
|
|
f1d1fea467 | ||
|
|
e404a1a96d | ||
|
|
b23d07875e | ||
|
|
9a68905228 | ||
|
|
486c275885 | ||
|
|
a864e848b5 | ||
|
|
a4dc312eff | ||
|
|
765f9ac74c | ||
|
|
3fae608b65 | ||
|
|
a47b32999b | ||
|
|
d66fbd218b | ||
|
|
b5edbf7ffa | ||
|
|
6b55baa00f | ||
|
|
7f251344b7 | ||
|
|
21309bc6d7 | ||
|
|
8295baf284 | ||
|
|
ec84f28630 | ||
|
|
701a47c82e | ||
|
|
616f365e5a | ||
|
|
ceb2684f2f | ||
|
|
b9c340a211 | ||
|
|
3a964e2025 | ||
|
|
3d49fc59dd | ||
|
|
16e8d0b1ab | ||
|
|
5856a2d2c0 | ||
|
|
227f62e013 | ||
|
|
89244cc3ea | ||
|
|
3a43e2ff07 | ||
|
|
81f328f1aa | ||
|
|
f5a7bba986 | ||
|
|
66ef8e2c24 | ||
|
|
1628bbf95f | ||
|
|
812703139c | ||
|
|
54add5ac9a | ||
|
|
f183b57ed5 | ||
|
|
dc4dfdff17 | ||
|
|
f55034d314 | ||
|
|
930899e12d | ||
|
|
579518c78d | ||
|
|
fa45a5121c | ||
|
|
862566a48f | ||
|
|
f9f4d2d1e5 | ||
|
|
b74379532d | ||
|
|
1e5e0c9fe2 | ||
|
|
05899f8b3e | ||
|
|
a2a6f2d896 | ||
|
|
1c350c67d7 | ||
|
|
2348b7245e | ||
|
|
6e27de4f74 | ||
|
|
e5dafaea44 | ||
|
|
fd4f4f2087 | ||
|
|
6c89186437 | ||
|
|
32c4759e6b | ||
|
|
6366cfd7a4 | ||
|
|
9985c01975 | ||
|
|
e6371712ff | ||
|
|
d7e35101c5 | ||
|
|
1defaa7b00 | ||
|
|
815b4c9772 | ||
|
|
aaf305868c | ||
|
|
8cc31f0f49 | ||
|
|
a011ac6392 | ||
|
|
505e23124f | ||
|
|
e7f6d1e6d0 | ||
|
|
a220482de6 | ||
|
|
e16bd17571 | ||
|
|
25d47ca08e | ||
|
|
5108a451ca | ||
|
|
ec7647c4ab | ||
|
|
8aecf82bfe | ||
|
|
10cbb9b580 | ||
|
|
4a316fbb5a | ||
|
|
7811ef1e17 | ||
|
|
b04cd6aada | ||
|
|
1146b8b84a | ||
|
|
292f2d3208 | ||
|
|
3cbefde376 | ||
|
|
0b42457929 | ||
|
|
51a81c96f1 | ||
|
|
6083581fea | ||
|
|
164b877bfa | ||
|
|
b9c2a326ba | ||
|
|
bdc1feb50e | ||
|
|
4ef04e5b5c | ||
|
|
0f5345e515 | ||
|
|
c95b4a8ab4 | ||
|
|
520b429ca0 | ||
|
|
d3343d5113 | ||
|
|
2e96fb2c9b | ||
|
|
24a5e5b1b1 | ||
|
|
74ecb88935 | ||
|
|
33874eb513 | ||
|
|
1de56bc5df | ||
|
|
8a79f1d0a3 | ||
|
|
f4f5d8882d | ||
|
|
4451c08007 | ||
|
|
89c57f7936 | ||
|
|
6af7857ccd | ||
|
|
dff96aebcf | ||
|
|
8af52aaf52 | ||
|
|
d66e434fb4 | ||
|
|
3700b457aa | ||
|
|
11f084f9a7 | ||
|
|
454a9dc042 | ||
|
|
ff458803ce | ||
|
|
110e009996 | ||
|
|
7b6a018dff | ||
|
|
a50e548cc5 | ||
|
|
4b258f7d31 | ||
|
|
d1cb8ee0ad | ||
|
|
c7f063188f | ||
|
|
a6460f4fe2 | ||
|
|
2e257563a6 | ||
|
|
ad0090964b | ||
|
|
cbdaeb4062 | ||
|
|
cf1306f469 | ||
|
|
7675f7434a | ||
|
|
821d6404b6 | ||
|
|
e3cb1f76cd | ||
|
|
ef12efbf8c | ||
|
|
adb9b9b8a7 | ||
|
|
07f94f82a2 | ||
|
|
215b4c0fe1 | ||
|
|
89963e1370 | ||
|
|
5d40f3a7c0 | ||
|
|
5e0e7a7ebd | ||
|
|
dad6e42934 | ||
|
|
7d938487dd | ||
|
|
fcfacb932d | ||
|
|
6906d291c5 | ||
|
|
943090846f | ||
|
|
2dc8621d05 | ||
|
|
b6cc00fa71 | ||
|
|
9e2d9b6419 | ||
|
|
3210b29bba | ||
|
|
ddad9618dc | ||
|
|
24005287f4 | ||
|
|
1dcfc2f547 | ||
|
|
7d6d4066dd | ||
|
|
4c22bda09b | ||
|
|
9d62c6fd0c | ||
|
|
5e0db6dd65 | ||
|
|
551d875be1 | ||
|
|
4f8567476d | ||
|
|
ffa2832e33 | ||
|
|
0f7759f831 | ||
|
|
ccfba00178 | ||
|
|
3e8183fcd5 | ||
|
|
0df387f6b5 | ||
|
|
4104c4fa1c | ||
|
|
33a85679b9 | ||
|
|
a4b9552c82 | ||
|
|
b82c231900 | ||
|
|
3d2ab93b11 | ||
|
|
c86ef36769 | ||
|
|
3b8d08177f | ||
|
|
0164ff0bbc | ||
|
|
a4baac2256 | ||
|
|
1e5e9f3ef8 | ||
|
|
d58d85af9e | ||
|
|
10e8d34fd3 | ||
|
|
ebc090ad15 | ||
|
|
8cef5a37ab | ||
|
|
8afdeee785 | ||
|
|
a83a9e0bc2 | ||
|
|
0d414471bb | ||
|
|
91fb3df495 | ||
|
|
373ef71feb | ||
|
|
ca78a746e6 | ||
|
|
1e13e1e06e | ||
|
|
42ff8a6959 | ||
|
|
2e92c3e568 | ||
|
|
5389fdb651 | ||
|
|
7a295b30e0 | ||
|
|
cca3e92854 | ||
|
|
4d05dc55a3 | ||
|
|
aeb52e29d6 | ||
|
|
97602456e3 | ||
|
|
8b5ff40402 | ||
|
|
d630597e87 | ||
|
|
60d1ecb58a | ||
|
|
d927a2c185 | ||
|
|
6e7cf81d74 | ||
|
|
736f1751ee | ||
|
|
28aab9ca79 | ||
|
|
972c048149 | ||
|
|
902aa39fce | ||
|
|
22f55aa585 | ||
|
|
157c95b988 | ||
|
|
426913f127 | ||
|
|
c4cc62a053 | ||
|
|
862696a778 | ||
|
|
86bc662bd2 | ||
|
|
ae7f8d6ab9 | ||
|
|
7dc34b92af | ||
|
|
cbfc0d6130 | ||
|
|
c308b2881f | ||
|
|
c959d1fca1 | ||
|
|
63511a874f | ||
|
|
90c705f138 | ||
|
|
b67bad82cb | ||
|
|
6981b46338 | ||
|
|
752e00bc66 | ||
|
|
00f018a054 | ||
|
|
56344670f4 | ||
|
|
5df20f4954 | ||
|
|
a9c613e87d | ||
|
|
7538ef34be | ||
|
|
5c62a4b805 | ||
|
|
559863ca68 | ||
|
|
845ad5e969 | ||
|
|
243b1f8e5e | ||
|
|
5bfb9781f7 | ||
|
|
906d2537b9 | ||
|
|
bbb287f54b | ||
|
|
e51e916e31 | ||
|
|
46e3125e26 | ||
|
|
c02fcc8fef | ||
|
|
25d4cbd1b3 | ||
|
|
3234a7681e | ||
|
|
36077da66a | ||
|
|
9e1fd8cf4d | ||
|
|
a55085b662 | ||
|
|
e0f9b6a5cd | ||
|
|
0053aa868c | ||
|
|
fab2048648 | ||
|
|
56ae88d9d5 | ||
|
|
1cdcff1c01 | ||
|
|
8ca07a08c3 | ||
|
|
2775b90b20 | ||
|
|
ae312bd7fe | ||
|
|
9017b83d4e | ||
|
|
02cf1831e9 | ||
|
|
d237de7b30 | ||
|
|
84d3203dd1 | ||
|
|
a3234034b5 | ||
|
|
b748eae035 | ||
|
|
a6656edc7c | ||
|
|
b4a9ea56ae | ||
|
|
fdbc91e3c4 | ||
|
|
bd67bb8273 | ||
|
|
54a0470c42 | ||
|
|
3dd790c408 | ||
|
|
be11b2768f | ||
|
|
2075bec60f | ||
|
|
44c2382402 | ||
|
|
fd041c2064 | ||
|
|
c6495f6632 | ||
|
|
7243989c52 | ||
|
|
46613af64c | ||
|
|
79000644c6 | ||
|
|
b349e7d9a8 | ||
|
|
6c8882caf3 | ||
|
|
30e00820a7 | ||
|
|
0f81e1bcd0 | ||
|
|
cb376b27f8 | ||
|
|
dc5e77ef8e | ||
|
|
72735167f9 | ||
|
|
89791a000b | ||
|
|
3411167c03 | ||
|
|
85f0e30c81 | ||
|
|
1796a716ea | ||
|
|
07d8d5c5ef | ||
|
|
0b29b44cab | ||
|
|
a0a350f468 | ||
|
|
4a57b84db0 | ||
|
|
f7a2af7052 | ||
|
|
456bafa82f | ||
|
|
7a8e3c759e | ||
|
|
b70bea8d34 | ||
|
|
d177944b75 | ||
|
|
9bd55487ea | ||
|
|
23e2e2eab3 | ||
|
|
8d2d5e37e5 | ||
|
|
287e2c96ed | ||
|
|
f8d9478517 | ||
|
|
1ba8c2cfa6 | ||
|
|
d654724fef | ||
|
|
3375089013 | ||
|
|
9f13afa20f | ||
|
|
908c10928b | ||
|
|
c321c3b86b | ||
|
|
f87521183f | ||
|
|
8a561120c4 | ||
|
|
20ca21cb0d | ||
|
|
2d1a75f550 | ||
|
|
8cddb7c681 | ||
|
|
4249bbf0d5 | ||
|
|
8a57c27e92 | ||
|
|
8706b6b16a | ||
|
|
32c08d48f3 | ||
|
|
fc52e78ed4 | ||
|
|
eb12f0358e | ||
|
|
a696c6b551 | ||
|
|
0d437e25de | ||
|
|
6744664ff4 | ||
|
|
ef5bd5a6de | ||
|
|
2159f9f5e0 | ||
|
|
2518b3a34f | ||
|
|
c3d6d5fd37 | ||
|
|
a25950a58c | ||
|
|
f8fed0f0bc | ||
|
|
89545ea9d0 | ||
|
|
a2f99d43c3 | ||
|
|
a7878a8d1a | ||
|
|
c73ad74be0 | ||
|
|
53993a9942 | ||
|
|
e1b20b48f0 | ||
|
|
14bc1f6526 | ||
|
|
2e2538ccb8 | ||
|
|
ae27178352 | ||
|
|
0f89270d08 | ||
|
|
10f5a3448d | ||
|
|
50b85c2911 | ||
|
|
38b939688a | ||
|
|
01fc8168e9 | ||
|
|
3362fb3406 | ||
|
|
8c3d503d54 | ||
|
|
2bb9fc5dda | ||
|
|
ea3e947b50 | ||
|
|
538e012e85 | ||
|
|
918ada06dc | ||
|
|
cb2737a433 | ||
|
|
c38e5b1b2c | ||
|
|
089041b090 | ||
|
|
cadf8c3cb0 | ||
|
|
6b6e3f4262 | ||
|
|
6e88d419ba | ||
|
|
ab4bf05300 | ||
|
|
ecac7bd3a1 | ||
|
|
1d620c0de3 | ||
|
|
f68815d5ad | ||
|
|
666aeda82c | ||
|
|
5be80b81eb | ||
|
|
10477fc2d4 | ||
|
|
d8672e1b2a | ||
|
|
a68958e5dc | ||
|
|
824f7df404 | ||
|
|
4bcff40828 | ||
|
|
80a9937e48 | ||
|
|
b963ebaf1d | ||
|
|
eb45372414 | ||
|
|
539dccae90 | ||
|
|
6458910ba3 | ||
|
|
ef9b591215 | ||
|
|
f845808813 | ||
|
|
25719b5596 | ||
|
|
8780bc0b8e | ||
|
|
821cd31e67 | ||
|
|
5a863bf010 | ||
|
|
d0ca11d665 | ||
|
|
7d3a44a1e2 | ||
|
|
7fce34292e | ||
|
|
9113282c27 | ||
|
|
78a8419428 | ||
|
|
ff9a61ead2 | ||
|
|
3a647d3e47 | ||
|
|
1f17ef3623 | ||
|
|
a6030ab374 | ||
|
|
9f4d7e2fb8 | ||
|
|
ba1acbe961 | ||
|
|
9deee38dc8 | ||
|
|
436941d48b | ||
|
|
e1c5a2f575 | ||
|
|
a5e9086676 | ||
|
|
1204e328df | ||
|
|
3e1baf5916 | ||
|
|
beb0d081bb | ||
|
|
4b7c701fdd | ||
|
|
233e32208c | ||
|
|
63e31c2a35 | ||
|
|
f9349becab | ||
|
|
ff5cf0abc7 | ||
|
|
8ff935c01a | ||
|
|
5d9d1b1020 | ||
|
|
8725d9fa3e | ||
|
|
9ae2d66d21 | ||
|
|
0c762925b2 | ||
|
|
ad52026550 | ||
|
|
cf7895876b | ||
|
|
f902d5fae6 | ||
|
|
98e3ebc378 | ||
|
|
dde43f796e | ||
|
|
7ee3b724d1 | ||
|
|
e151a300d0 | ||
|
|
f58f771660 | ||
|
|
ea63d5d3c2 | ||
|
|
ea0ffe24f8 | ||
|
|
061a604a2a | ||
|
|
f741074267 | ||
|
|
de5952d67e | ||
|
|
a03f4802ef | ||
|
|
778ba9f7ab | ||
|
|
676e0ce38e | ||
|
|
088a42fc53 | ||
|
|
63dbac28ad | ||
|
|
e9a1de47b4 | ||
|
|
d14fca0cc6 | ||
|
|
bb83813f51 | ||
|
|
8225d4e0c5 | ||
|
|
d45195ab5c | ||
|
|
73bd347fcf | ||
|
|
c9dbe090c5 | ||
|
|
61cc0d4fb1 | ||
|
|
15c4a7f95f | ||
|
|
20e629284f | ||
|
|
e73951f3d1 | ||
|
|
fdf843c08b | ||
|
|
cf145ec65e | ||
|
|
4889844d0c | ||
|
|
dc7857c585 | ||
|
|
d65dbf89c9 | ||
|
|
ed2b3e26fb | ||
|
|
46436bd870 | ||
|
|
1dbe9317bc | ||
|
|
ef4f3a54fe | ||
|
|
9af03c2562 | ||
|
|
c10e5f4e73 | ||
|
|
01f676041d | ||
|
|
6856ab8a69 | ||
|
|
8212750fe9 | ||
|
|
35b6b949e3 | ||
|
|
d1ea3ab89d | ||
|
|
ae625d0de7 | ||
|
|
5fb82d1018 | ||
|
|
f9d1b94496 | ||
|
|
854ff5643a | ||
|
|
072ebb911b | ||
|
|
d46f5d29fa | ||
|
|
69aa0003af | ||
|
|
41a093c1f2 | ||
|
|
022a418894 | ||
|
|
d056668f4f | ||
|
|
917334d18a | ||
|
|
7a83f1c416 | ||
|
|
6f0a9521e1 | ||
|
|
aee5c3ecb0 | ||
|
|
da0d575649 | ||
|
|
74d2216da2 | ||
|
|
769314a8a2 | ||
|
|
831be04027 | ||
|
|
1a1adf73e8 | ||
|
|
68f41097b9 | ||
|
|
4402c6d806 | ||
|
|
2aa8a43c5b | ||
|
|
219bb9ecb7 | ||
|
|
88fd2ee4f2 | ||
|
|
6c3683dfe9 | ||
|
|
36e495da1e | ||
|
|
15faf9dc3b | ||
|
|
59302fd208 | ||
|
|
24202d1ecf | ||
|
|
336f4e27e6 | ||
|
|
fe29d3d3fa | ||
|
|
3d33412e9a | ||
|
|
fb9196021e | ||
|
|
b23fae9ee3 | ||
|
|
8b41415b07 | ||
|
|
1fa55a3fae | ||
|
|
a45c937f80 | ||
|
|
6ed3adb091 | ||
|
|
106fdf5114 | ||
|
|
99f170adc3 | ||
|
|
f60d83c15f | ||
|
|
36a47bae56 | ||
|
|
dc8528af0f | ||
|
|
e12d0ffd1e | ||
|
|
a71138a43a | ||
|
|
cb976b9a50 | ||
|
|
060eb39bf9 | ||
|
|
ab363e9e50 | ||
|
|
41a8ae7557 | ||
|
|
1956abbedf | ||
|
|
2003a0440f | ||
|
|
a0274cc46e | ||
|
|
3b384740b9 | ||
|
|
4d40a47eab | ||
|
|
18e828f17c | ||
|
|
0966230ba8 | ||
|
|
669f4ab4c3 | ||
|
|
3455714410 | ||
|
|
32ea50d336 | ||
|
|
5ac6a460fa | ||
|
|
f147b7fae5 | ||
|
|
474386a1d9 | ||
|
|
7fd2c2d08b | ||
|
|
5412f3f1c1 | ||
|
|
014b45b4a9 | ||
|
|
30ea390b77 | ||
|
|
00f244385b | ||
|
|
7b671b95d2 | ||
|
|
1535f23455 | ||
|
|
4ba0c8baef | ||
|
|
a7dd3ab793 | ||
|
|
f6f7d4d973 | ||
|
|
f4ae5c883b | ||
|
|
74a14f5de7 | ||
|
|
fee21c959a | ||
|
|
4b48054f41 | ||
|
|
17a319d120 | ||
|
|
3a1dab5396 | ||
|
|
dac081e183 | ||
|
|
489fcdc089 | ||
|
|
3ba7c97b2a | ||
|
|
54635000c5 | ||
|
|
426edff09c | ||
|
|
b37ce20c2a | ||
|
|
cac14a531d | ||
|
|
ae7a042876 | ||
|
|
eb165459aa | ||
|
|
04bc2ef7cf | ||
|
|
09104ce531 | ||
|
|
9fa2173825 | ||
|
|
346da34432 | ||
|
|
fa316ac430 | ||
|
|
77936a594d | ||
|
|
4e07eac356 | ||
|
|
d018e43ddc | ||
|
|
8cee66e609 | ||
|
|
3c4248192d | ||
|
|
255f8ef5be | ||
|
|
20b32db5af | ||
|
|
b634722c8a | ||
|
|
c9e8581f45 | ||
|
|
da129f6664 | ||
|
|
884e6c7d8b | ||
|
|
5aadaa79eb | ||
|
|
cf562961b7 | ||
|
|
63bed9bdf1 | ||
|
|
5989dbdfcf | ||
|
|
db19a11399 | ||
|
|
6c734cb609 | ||
|
|
ef41d1cb57 | ||
|
|
08b4a34a8e | ||
|
|
1fc5656762 | ||
|
|
91cfc34ae4 | ||
|
|
a0b942a7f5 | ||
|
|
6a401c8262 | ||
|
|
d235f32bc9 | ||
|
|
bdbfa7e32c | ||
|
|
78976b3504 | ||
|
|
8d4748c8df | ||
|
|
da723d3e11 | ||
|
|
0feeb7d0d4 | ||
|
|
9e53f36a74 | ||
|
|
7e7c08da47 | ||
|
|
2f6b89ef70 | ||
|
|
4e3024cb61 | ||
|
|
c427bf6a94 | ||
|
|
dae2422fd1 | ||
|
|
f98e3e6c26 | ||
|
|
fe99532f8b | ||
|
|
41a4968c90 | ||
|
|
1cdaabf2dd | ||
|
|
82d8253c19 | ||
|
|
c1717d6e12 | ||
|
|
f0d1c39b5b | ||
|
|
111aea3f0a | ||
|
|
37cfc912c1 | ||
|
|
8c2e228c74 | ||
|
|
8630fb02bb | ||
|
|
5052ab4e2b | ||
|
|
a44f739356 | ||
|
|
f44ecf3872 | ||
|
|
1c9e03f800 | ||
|
|
5d9ec83805 | ||
|
|
3a295c659b | ||
|
|
d253414783 | ||
|
|
8b1b503609 | ||
|
|
ff48bd6ec5 | ||
|
|
54b9c9bdb2 | ||
|
|
3dcdc582ea | ||
|
|
7c4171d414 | ||
|
|
1d839ff9df | ||
|
|
3403d07912 | ||
|
|
e8643787cf | ||
|
|
298b2a6033 | ||
|
|
c791428905 | ||
|
|
dc2fe63e42 | ||
|
|
7af88962ee | ||
|
|
3216d7683a | ||
|
|
e4094c8664 | ||
|
|
b49d65a276 | ||
|
|
824ce76cec | ||
|
|
2a18f97d12 | ||
|
|
8c4d29ee38 | ||
|
|
2c13f4fe72 | ||
|
|
94931040a8 | ||
|
|
b78a4cdc93 | ||
|
|
da09544bb0 | ||
|
|
ce17b6bd53 | ||
|
|
fe03bea191 | ||
|
|
0ed6347d47 | ||
|
|
3f86e97f70 | ||
|
|
69fa279e3c | ||
|
|
bbf4e05fde | ||
|
|
05d90517b0 | ||
|
|
5f5c1dc5a6 | ||
|
|
e0524644f8 | ||
|
|
81e2336ace | ||
|
|
25bf1a0169 | ||
|
|
c8ab67be27 | ||
|
|
6c34288ebf | ||
|
|
2ffbb9d6b7 | ||
|
|
dad608d5c0 | ||
|
|
04b939625b | ||
|
|
5dac485458 | ||
|
|
2c4ccd122e | ||
|
|
b90ae078b8 | ||
|
|
cc8761dbde | ||
|
|
08cc591884 | ||
|
|
1bc4d04f43 | ||
|
|
d4018192a9 | ||
|
|
19ddbfeca9 | ||
|
|
4fed6763fc | ||
|
|
73446a9cce | ||
|
|
dcf1ac0d1f | ||
|
|
364c58d13f | ||
|
|
8cfe11e4e2 | ||
|
|
40378a18f7 | ||
|
|
7fb5d8c973 | ||
|
|
6e373942e5 | ||
|
|
f0b982795c | ||
|
|
cbd422d56e | ||
|
|
03598bb5d6 | ||
|
|
983a53a643 | ||
|
|
0535e724a2 | ||
|
|
fd1ac5dd79 | ||
|
|
9b91eafac4 | ||
|
|
bc42812715 | ||
|
|
8fbee891b3 | ||
|
|
919292764a | ||
|
|
a1e4dfa324 | ||
|
|
f8644c31a3 | ||
|
|
1e2851cdb3 | ||
|
|
e83e51eb56 | ||
|
|
c496a924ce | ||
|
|
81be37b236 | ||
|
|
4d540b7102 | ||
|
|
33901b74b1 | ||
|
|
a47cfa4757 | ||
|
|
a625d2821e | ||
|
|
d8706fd460 | ||
|
|
e13f24ab45 | ||
|
|
34a63246ab | ||
|
|
8c708f3c7a | ||
|
|
b0e65d149f | ||
|
|
e29db8d272 | ||
|
|
7ca5127fcc | ||
|
|
7813f363a2 | ||
|
|
fb3c124af1 | ||
|
|
46814da91a | ||
|
|
d0cd26cd8e |
No files matched your search
@@ -1,2 +1,3 @@
|
||||
.gitattributes export-ignore
|
||||
.gitignore export-ignore
|
||||
* text=auto eol=lf
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
READ THIS FIRST!
|
||||
|
||||
If you have a usage question, please ask us on either Stack Overflow (https://stackoverflow.com/questions/tagged/jq) or in the #jq channel (https://web.libera.chat/#jq) on Libera.Chat (https://libera.chat/).
|
||||
|
||||
-->
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Provide a minimal test case to reproduce the behavior.
|
||||
If the input is large, either attach it as a file, or [create a gist](https://gist.github.com) and link to it here.
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Environment (please complete the following information):**
|
||||
- OS and Version: [e.g. macOS, Windows, Linux (please specify distro)]
|
||||
- jq version [e.g. 1.5]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,209 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- "v*"
|
||||
pull_request:
|
||||
jobs:
|
||||
linux:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler: [gcc, clang]
|
||||
image: [ubuntu-20.04, ubuntu-22.04]
|
||||
runs-on: ${{ matrix.image }}
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
SUFFIX: linux-${{ matrix.image}}-${{ matrix.compiler }}
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install packages
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y \
|
||||
automake \
|
||||
autoconf \
|
||||
bison \
|
||||
flex \
|
||||
gdb \
|
||||
python3
|
||||
- name: Build
|
||||
run: |
|
||||
autoreconf -fi
|
||||
./configure --disable-dependency-tracking \
|
||||
--disable-silent-rules \
|
||||
--disable-maintainer-mode \
|
||||
--disable-valgrind \
|
||||
--with-oniguruma=builtin \
|
||||
YACC="$(which bison) -y"
|
||||
make
|
||||
- name: Test
|
||||
run: |
|
||||
make check
|
||||
- name: Upload Test Logs
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-logs-${{ env.SUFFIX }}
|
||||
retention-days: 7
|
||||
path: |
|
||||
test-suite.log
|
||||
tests/*.log
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: jq-${{ env.SUFFIX }}
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
path: |
|
||||
jq
|
||||
macos:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler: [gcc, clang]
|
||||
image: [macos-11, macos-12, macos-13]
|
||||
runs-on: ${{ matrix.image }}
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
SUFFIX: macos-${{ matrix.image}}-${{ matrix.compiler }}
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install packages
|
||||
run: |
|
||||
# brew update sometimes fails with "Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!"
|
||||
brew update || brew update-reset
|
||||
brew install \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
flex \
|
||||
bison
|
||||
sed -i.bak '/^AM_INIT_AUTOMAKE(\[-Wno-portability 1\.14\])$/s/14/11/' modules/oniguruma/configure.ac
|
||||
- name: Build
|
||||
run: |
|
||||
autoreconf -fi
|
||||
./configure --disable-dependency-tracking \
|
||||
--disable-silent-rules \
|
||||
--disable-maintainer-mode \
|
||||
--disable-valgrind \
|
||||
--with-oniguruma=builtin \
|
||||
YACC="$(brew --prefix)/opt/bison/bin/bison -y"
|
||||
make
|
||||
- name: Test
|
||||
run: |
|
||||
make check
|
||||
- name: Upload Test Logs
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-logs-${{ env.SUFFIX }}
|
||||
retention-days: 7
|
||||
path: |
|
||||
test-suite.log
|
||||
tests/*.log
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: jq-${{ env.SUFFIX }}
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
path: |
|
||||
jq
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler: [gcc]
|
||||
image: [windows-2019, windows-2022]
|
||||
runs-on: ${{ matrix.image }}
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
SUFFIX: windows-${{ matrix.image}}-${{ matrix.compiler }}
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
update: true
|
||||
install: >-
|
||||
base-devel
|
||||
git
|
||||
clang
|
||||
autoconf
|
||||
automake
|
||||
libtool
|
||||
bison
|
||||
flex
|
||||
- name: Build
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
autoreconf -fi
|
||||
./configure --disable-dependency-tracking \
|
||||
--disable-silent-rules \
|
||||
--disable-maintainer-mode \
|
||||
--disable-valgrind \
|
||||
--with-oniguruma=builtin \
|
||||
--disable-shared \
|
||||
--enable-static \
|
||||
--enable-all-static \
|
||||
YACC="$(which bison) -y"
|
||||
make
|
||||
- name: Test
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
make check
|
||||
- name: Upload Test Logs
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-logs-${{ env.SUFFIX }}
|
||||
retention-days: 7
|
||||
path: |
|
||||
test-suite.log
|
||||
tests/*.log
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: jq-${{ env.SUFFIX }}
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
path: |
|
||||
jq.exe
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
needs: [linux, macos, windows]
|
||||
if: startsWith(github.event.ref, 'refs/tags/v')
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Merge built artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: artifacts
|
||||
- name: Upload release
|
||||
env:
|
||||
TAG_NAME: ${{ github.ref_name }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
mkdir release
|
||||
cp artifacts/jq-linux-ubuntu-22.04-gcc/jq release/jq-linux-amd64
|
||||
cp artifacts/jq-macos-macos-13-gcc/jq release/jq-macos-amd64
|
||||
cp artifacts/jq-windows-windows-2022-gcc/jq.exe release/jq-windows-amd64.exe
|
||||
|
||||
gh release create $TAG_NAME --draft --title "jq ${TAG_NAME#v}" --generate-notes
|
||||
gh release upload $TAG_NAME --clobber release/jq-*
|
||||
@@ -0,0 +1,77 @@
|
||||
name: Linux Clang scan-build Static Analyzer Build
|
||||
|
||||
on:
|
||||
# Don't do this for PRs. It eats up minutes.
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'scan-build'
|
||||
paths:
|
||||
- '.github/workflows/scanbuild.yml'
|
||||
|
||||
jobs:
|
||||
unix:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
name: [linux-clang]
|
||||
include:
|
||||
- name: linux-clang
|
||||
os: ubuntu-latest
|
||||
compiler: clang
|
||||
cflags: ''
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v1
|
||||
- name: Open Submodule(s)
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
- name: Install packages
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y automake autoconf bison flex gdb python3 valgrind clang-tools
|
||||
- name: Prep
|
||||
run: |
|
||||
#pyenv global 3.6.7
|
||||
#pip3 install pipenv
|
||||
#(cd docs && pipenv sync)
|
||||
#if [ -n "$COVERAGE" ]; then pip install --user cpp-coveralls; fi
|
||||
echo SHELL=$SHELL
|
||||
echo PATH=$PATH
|
||||
which bison
|
||||
bison --version
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
MAKEVARS: ${{ matrix.makevars }}
|
||||
run: |
|
||||
autoreconf -fi
|
||||
rm src/lexer.c src/lexer.h
|
||||
rm src/parser.c src/parser.h
|
||||
./configure --with-oniguruma=builtin YACC="$(which bison) -y" $COVERAGE
|
||||
scan-build --keep-going make -j4
|
||||
- name: Test
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
MAKEVARS: ${{ matrix.makevars }}
|
||||
run: |
|
||||
ulimit -c unlimited
|
||||
scan-build --keep-going make -j4 check
|
||||
- name: Core dump stacks
|
||||
run: |
|
||||
echo "thread apply all bt" > /tmp/x
|
||||
find . -name core -print | while read core; do gdb -batch -x x `file "$core"|sed -e "s/^[^']*'//" -e "s/[ '].*$//"` "$core"; done
|
||||
if [ "$(find . -name core -print | wc -l)" -gt 0 ]; then false; fi
|
||||
- name: Test logs
|
||||
if: ${{ failure() }}
|
||||
run: |
|
||||
cat test-suite.log
|
||||
cat tests/*.log
|
||||
- name: Upload Logs
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Scan-Build Reports
|
||||
path: '/tmp/scan-build*/'
|
||||
@@ -0,0 +1,40 @@
|
||||
name: Update website
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'docs/**'
|
||||
concurrency: website
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
website:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
cache: pipenv
|
||||
- name: Install pipenv
|
||||
run: pip install pipenv
|
||||
- name: Install dependencies
|
||||
run: pipenv sync
|
||||
working-directory: docs
|
||||
- name: Update website
|
||||
run: scripts/update-website
|
||||
- name: Commit changes
|
||||
run: |
|
||||
if ! git diff --quiet; then
|
||||
git add --all
|
||||
git config user.name 'github-actions[bot]'
|
||||
git config user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
git commit -m 'Update website'
|
||||
git push origin gh-pages
|
||||
fi
|
||||
+37
-9
@@ -1,28 +1,56 @@
|
||||
*.o
|
||||
*.a
|
||||
*.lo
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.so.*
|
||||
*.gcda
|
||||
*.gcno
|
||||
*.gcov
|
||||
*~
|
||||
.*.sw[a-p]
|
||||
tags
|
||||
|
||||
jq
|
||||
!tests/modules/lib/jq/
|
||||
jq.1
|
||||
|
||||
# Something delightfully recursive happens otherwise
|
||||
docs/content/2.download/source/*
|
||||
|
||||
# Autogenerated
|
||||
lexer.c
|
||||
lexer.h
|
||||
parser.c
|
||||
parser.h
|
||||
# Generated source
|
||||
src/builtin.inc
|
||||
*.pc
|
||||
|
||||
# Autotools junk
|
||||
.libs
|
||||
.deps
|
||||
.dirstamp
|
||||
libtool
|
||||
*.log
|
||||
stamp-h1
|
||||
config.log
|
||||
config.status
|
||||
autom4te.cache
|
||||
config.h
|
||||
INSTALL
|
||||
Makefile
|
||||
jq-*.tar.gz
|
||||
configure
|
||||
aclocal.m4
|
||||
Makefile.in
|
||||
version.h
|
||||
.remake-version-h
|
||||
config.cache
|
||||
*.rpm
|
||||
m4/libtool.m4
|
||||
m4/ltoptions.m4
|
||||
m4/ltsugar.m4
|
||||
m4/ltversion.m4
|
||||
m4/lt~obsolete.m4
|
||||
tests/*.trs
|
||||
|
||||
# Docs output
|
||||
docs/output
|
||||
|
||||
cscope.in.out
|
||||
cscope.out
|
||||
cscope.po.out
|
||||
jq.dSYM
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "modules/oniguruma"]
|
||||
path = modules/oniguruma
|
||||
url = https://github.com/kkos/oniguruma.git
|
||||
@@ -1,6 +1,74 @@
|
||||
Created By:
|
||||
Stephen Dolan <mu@netsoc.tcd.ie>
|
||||
|
||||
Contributions by
|
||||
Anthony Shortland <anthony.shortland@me.com> - rpmbuild target
|
||||
Lee Thompson <stagr.lee@gmail.com> - autoconf stuff
|
||||
Maintained by:
|
||||
Nicolas Williams <nico@cryptonector.com>
|
||||
William Langford <wlangfor@gmail.com>
|
||||
|
||||
Contributions by:
|
||||
Aaron Peschel <apeschel@zendesk.com>
|
||||
Adam Lindberg <hello@alind.io>
|
||||
Alex Chamberlain <alex@alexchamberlain.co.uk>
|
||||
Andrew O'Brien <obrien.andrew@gmail.com> - docs build
|
||||
Andrew Rodland <andrew@cleverdomain.org> - bug fixes
|
||||
Ankur <ankz.kothari@gmail.com> - bug fixes
|
||||
Anthony Shortland <anthony.shortland@me.com> - rpmbuild target
|
||||
Assaf Gordon <assafgordon@gmail.com> - error handling
|
||||
Brendan Macmillan <melbourne.research@gmail.com> - bug fixes, load library from ~/.jq
|
||||
cdnbacon <mike@busbud.com>
|
||||
Charles Merriam <charles.merriam@gmail.com>
|
||||
Colin von Heuring <colin@janrain.com>
|
||||
Damian Gryski <damian@gryski.com>
|
||||
David Fetter <david@fetter.org> - added --rawfile
|
||||
David Haguenauer <ml@kurokatta.org>
|
||||
David R. MacIver <david@drmaciver.com> - bug fixes
|
||||
David Tolnay <dtolnay@gmail.com> - destructuring, build improvements
|
||||
Doug Luce <doug@github.con.com> - build
|
||||
Eiichi Sato <sato.eiichi@gmail.com>
|
||||
Eric Bréchemier <eric@egull.co> - bug fix
|
||||
Filippo Giunchedi <fgiunchedi@gmail.com> - bug fixes
|
||||
Filippo Valsorda <filippo.valsorda@gmail.com> - recursive object merge (`*`)
|
||||
Hanfei Shen <qqshfox@gmail.com>
|
||||
i <isomorphisms@sdf.org>
|
||||
Ian Miell <ian.miell@gmail.com>
|
||||
Jack Pearkes <jackpearkes@gmail.com> - update tutorial
|
||||
James Andariese <james.andariese@locationlabs.com> - Dockerfile
|
||||
jkleint <jkleint@gmail.com>
|
||||
Joe Littlejohn <joe.littlejohn@nokia.com> - bug fixes
|
||||
Joel Purra <code+github@joelpurra.com>
|
||||
Juan Guerrero <juan.guerrero.lozano@gmail.com> - bug fixes
|
||||
Kenny Shen <kenny.shen@zalora.com> - doc fixes
|
||||
Kim De Mey <kim.demey@gmail.com> - build
|
||||
Kim Toms <kim.toms@bplglobal.net>
|
||||
LCD 47 <lcd047@gmail.com>
|
||||
Lee Thompson <stagr.lee@gmail.com> - autoconf stuff, rpm
|
||||
Marc Abramowitz <marc@marc-abramowitz.com>
|
||||
Marc Bruggmann <marcbr@spotify.com>
|
||||
Markus Lanthaler <mark_lanthaler@gmx.net> - doc fixes
|
||||
Maxime Biais <maxime.biais@gmail.com> - build
|
||||
Michael Daines <michael@mdaines.com> - add sqrt; doc fixes
|
||||
Mike Fletcher <john.m.fletcher@bankofamerica.com>
|
||||
Mike McCabe <mccabe@archive.org> - math (libm) functions
|
||||
Nicolas Pouillard <nicolas.pouillard@gmail.com> - add tests
|
||||
Nicolas Williams <nico@cryptonector.com> - library-fication, autoconf stuff, exception handling, various
|
||||
Owen Ou <o@owenou.com> - jqplay.org and link to it
|
||||
Peter van Dijk <peter@7bits.nl> - doc fixes
|
||||
Philipp Hagemeister <phihag@phihag.de> - doc fixes
|
||||
pkoppstein <pkoppstein@gmail.com> - various builtins, improvements
|
||||
polyester <paul@cleanclothes.org> - automake version update
|
||||
Ryoichi KATO <ryo1kato@gmail.com> - doc fixes
|
||||
Rémy Léone <remy.leone@gmail.com> - add .travis.yml
|
||||
Santiago Lapresta <santiago.lapresta@gmail.com> - join, arrays, all, any, other filters
|
||||
Sebastian Freundt <freundt@ga-group.nl> - build
|
||||
Shaun Guth <shaun.guth@gmail.com> - base64d
|
||||
Shay Elkin <shay@everything.me>
|
||||
Simon Elsbrock <simon@iodev.org> - Debian
|
||||
Stefan Seemayer <stefan@seemayer.de>
|
||||
Stephen Roantree <stroantree@gmail.com>
|
||||
Stephen Shaw <stesh@netsoc.tcd.ie>
|
||||
Steven Maude <StevenMaude@users.noreply.github.com>
|
||||
Steven Penny <svnpenn@gmail.com> - Windows bug fixes
|
||||
tal@whatexit.org <tal@whatexit.org>
|
||||
Travis Gockel <travis@gockelhut.com>
|
||||
Zhiming Wang <zmwangx@gmail.com>
|
||||
13ren <melbourne.research@gmail.com>
|
||||
@@ -25,14 +25,14 @@ jq's documentation (everything found under the docs/ subdirectory in
|
||||
the source tree) is licensed under the Creative Commons CC BY 3.0
|
||||
license, which can be found at:
|
||||
|
||||
http://creativecommons.org/licenses/by/3.0/
|
||||
https://creativecommons.org/licenses/by/3.0/
|
||||
|
||||
The documentation website includes a copy of Twitter's Boostrap and
|
||||
The documentation website includes a copy of Twitter's Bootstrap and
|
||||
relies on Bonsai, Liquid templates and various other projects, look
|
||||
them up for detailed licensing conditions.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
jq incorporates David M. Gay's dtoa.c and g_fmt.c, which bear the
|
||||
following notices:
|
||||
|
||||
@@ -68,3 +68,69 @@ WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
|
||||
REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
||||
OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
|
||||
jq uses parts of the open source C library "decNumber", which is distributed
|
||||
under the following license:
|
||||
|
||||
|
||||
ICU License - ICU 1.8.1 and later
|
||||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright (c) 1995-2005 International Business Machines Corporation and others
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, and/or sell copies of the Software, and to permit persons
|
||||
to whom the Software is furnished to do so, provided that the above
|
||||
copyright notice(s) and this permission notice appear in all copies of
|
||||
the Software and that both the above copyright notice(s) and this
|
||||
permission notice appear in supporting documentation.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
|
||||
INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of a copyright holder
|
||||
shall not be used in advertising or otherwise to promote the sale, use
|
||||
or other dealings in this Software without prior written authorization
|
||||
of the copyright holder.
|
||||
|
||||
Portions Copyright (c) 2016 Kungliga Tekniska Högskolan
|
||||
(Royal Institute of Technology, Stockholm, Sweden).
|
||||
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 HOLDER 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.
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
FROM debian:9
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
DEBCONF_NONINTERACTIVE_SEEN=true \
|
||||
LC_ALL=C.UTF-8 \
|
||||
LANG=C.UTF-8
|
||||
|
||||
COPY . /app
|
||||
|
||||
# get dependencies, build, and remove anything we don't need for running jq.
|
||||
# valgrind seems to have trouble with pthreads TLS so it's off.
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
build-essential \
|
||||
autoconf \
|
||||
libtool \
|
||||
git \
|
||||
bison \
|
||||
flex \
|
||||
python3 \
|
||||
python3-pip \
|
||||
wget && \
|
||||
pip3 install pipenv && \
|
||||
(cd /app/docs && pipenv sync) && \
|
||||
(cd /app && \
|
||||
git submodule init && \
|
||||
git submodule update && \
|
||||
autoreconf -i && \
|
||||
./configure --disable-valgrind --enable-all-static --prefix=/usr/local && \
|
||||
make -j8 && \
|
||||
make check && \
|
||||
make install ) && \
|
||||
(cd /app/modules/oniguruma && \
|
||||
make uninstall ) && \
|
||||
(cd /app && \
|
||||
make distclean ) && \
|
||||
apt-get purge -y \
|
||||
build-essential \
|
||||
autoconf \
|
||||
libtool \
|
||||
bison \
|
||||
git \
|
||||
flex \
|
||||
python3 \
|
||||
python3-pip && \
|
||||
apt-get autoremove -y && \
|
||||
rm -rf /app/modules/oniguruma/* && \
|
||||
rm -rf /app/modules/oniguruma/.git && \
|
||||
rm -rf /app/modules/oniguruma/.gitignore && \
|
||||
rm -rf /var/lib/apt/lists/* /var/lib/gems
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/jq"]
|
||||
CMD []
|
||||
@@ -0,0 +1,8 @@
|
||||
pub 4096R/71523402 2015-10-11
|
||||
Key fingerprint = 4FD7 01D6 FA9B 3D2D F5AC 935D AF19 040C 7152 3402
|
||||
uid jq Release Signing Key <jq@stedolan.github.io>
|
||||
|
||||
pub 2048R/D15684DB 2015-10-12 [expires: 2017-10-11]
|
||||
Key fingerprint = 7F6C 7BD3 0412 AFD5 8C1A 5007 EB26 A4F8 D156 84DB
|
||||
uid Nicolas Williams <nico@cryptonector.com>
|
||||
sub 2048R/9C9CCD6A 2015-10-12 [expires: 2017-10-11]
|
||||
+196
-64
@@ -1,116 +1,237 @@
|
||||
|
||||
### C source files to be built and distributed.
|
||||
|
||||
JQ_INCS = jq_parser.h builtin.h bytecode.h compile.h execute.h \
|
||||
forkable_stack.h frame_layout.h jv.h jv_alloc.h jv_aux.h jv_dtoa.h \
|
||||
jv_parse.h jv_unicode.h locfile.h opcode.h opcode_list.h parser.y \
|
||||
jv_utf8_tables.h lexer.l
|
||||
|
||||
JQ_SRC = opcode.c bytecode.c compile.c execute.c builtin.c jv.c \
|
||||
jv_parse.c jv_print.c jv_dtoa.c jv_unicode.c jv_aux.c jv_alloc.c \
|
||||
jq_test.c ${JQ_INCS}
|
||||
LIBJQ_INCS = src/builtin.h src/bytecode.h src/compile.h \
|
||||
src/exec_stack.h src/jq_parser.h src/jv_alloc.h src/jv_dtoa.h \
|
||||
src/jv_unicode.h src/jv_utf8_tables.h src/lexer.l src/libm.h \
|
||||
src/linker.h src/locfile.h src/opcode_list.h src/parser.y \
|
||||
src/util.h src/decNumber/decContext.h src/decNumber/decNumber.h \
|
||||
src/decNumber/decNumberLocal.h src/jv_dtoa_tsd.h src/jv_thread.h \
|
||||
src/jv_type_private.h
|
||||
|
||||
LIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c \
|
||||
src/jq_test.c src/jv.c src/jv_alloc.c src/jv_aux.c \
|
||||
src/jv_dtoa.c src/jv_file.c src/jv_parse.c src/jv_print.c \
|
||||
src/jv_unicode.c src/linker.c src/locfile.c src/util.c \
|
||||
src/decNumber/decContext.c src/decNumber/decNumber.c \
|
||||
src/jv_dtoa_tsd.c \
|
||||
${LIBJQ_INCS}
|
||||
|
||||
### C build options
|
||||
|
||||
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
|
||||
-Wno-unused-parameter -Wno-unused-function
|
||||
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
|
||||
-Wno-unused-parameter -Wno-unused-function
|
||||
|
||||
if WIN32
|
||||
AM_CFLAGS += -municode
|
||||
endif
|
||||
|
||||
ACLOCAL_AMFLAGS = -I config/m4
|
||||
|
||||
### Generating the lexer and parser
|
||||
|
||||
# While there is some autoconf macro support for lex/flex, it doesn't support
|
||||
# header file creation so we'll use good old make
|
||||
BUILT_SOURCES = lexer.h lexer.c parser.h parser.c
|
||||
lexer.c: lexer.l
|
||||
flex -o lexer.c --header-file=lexer.h $<
|
||||
lexer.h: lexer.c
|
||||
if MAINTAINER_MODE
|
||||
BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \
|
||||
src/builtin.inc src/version.h
|
||||
src/lexer.c: src/lexer.l
|
||||
$(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $<
|
||||
src/lexer.h: src/lexer.c
|
||||
else
|
||||
BUILT_SOURCES = src/builtin.inc src/version.h
|
||||
.y.c:
|
||||
$(AM_V_YACC) echo "NOT building parser.c!"
|
||||
.l.c:
|
||||
$(AM_V_LEX) echo "NOT building lexer.c!"
|
||||
endif
|
||||
|
||||
# Tell YACC (bison) autoconf macros that you want a header file created.
|
||||
# If the --warnings=all fails, you probably have an old version of bison
|
||||
# OSX ships an old bison, so update with homebrew or macports
|
||||
AM_YFLAGS = --warnings=all -d
|
||||
# Tell YACC (Bison) autoconf macros that you want a header file created.
|
||||
# If the --warnings=all fails, you probably have an old version of Bison
|
||||
# macOS ships an old Bison, so update with Homebrew or MacPorts.
|
||||
AM_YFLAGS = --warnings=all -Wno-yacc -d
|
||||
|
||||
### libjq
|
||||
|
||||
lib_LTLIBRARIES = libjq.la
|
||||
libjq_la_SOURCES = ${LIBJQ_SRC}
|
||||
libjq_la_LIBADD = -lm
|
||||
libjq_la_LDFLAGS = $(onig_LDFLAGS) -export-symbols-regex '^j[qv]_' -version-info 1:4:0
|
||||
|
||||
if WIN32
|
||||
libjq_la_LIBADD += -lshlwapi
|
||||
libjq_la_LDFLAGS += -no-undefined
|
||||
endif
|
||||
|
||||
include_HEADERS = src/jv.h src/jq.h
|
||||
|
||||
if ENABLE_UBSAN
|
||||
AM_CFLAGS += -fsanitize=undefined
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir)/src
|
||||
|
||||
### Running tests under Valgrind
|
||||
|
||||
if ENABLE_ASAN
|
||||
AM_CFLAGS += -fsanitize=address
|
||||
NO_VALGRIND = 1
|
||||
else
|
||||
if ENABLE_VALGRIND
|
||||
NO_VALGRIND =
|
||||
else
|
||||
NO_VALGRIND = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
### Code coverage with gcov
|
||||
|
||||
if ENABLE_GCOV
|
||||
AM_CFLAGS += --coverage --no-inline
|
||||
endif
|
||||
|
||||
### Error injection for testing
|
||||
|
||||
if ENABLE_ERROR_INJECTION
|
||||
lib_LTLIBRARIES += libinject_errors.la
|
||||
libinject_errors_la_SOURCES = src/inject_errors.c
|
||||
libinject_errors_la_LIBADD = -ldl
|
||||
libinject_errors_la_LDFLAGS = -module
|
||||
endif
|
||||
|
||||
### Building the jq binary
|
||||
|
||||
main.c: config.h
|
||||
# Remake the version.h header file if, and only if, the git ID has changed
|
||||
.PHONY: .FORCE
|
||||
.FORCE:
|
||||
generate_ver = ver="`{ $(srcdir)/scripts/version || echo '$(VERSION)' ; } | sed 's/.*/\#define JQ_VERSION \"&\"/'`"
|
||||
.remake-version-h: .FORCE
|
||||
@ $(generate_ver); test "x`cat src/version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h
|
||||
src/version.h: .remake-version-h
|
||||
mkdir -p src
|
||||
$(AM_V_GEN) $(generate_ver); echo "$$ver" > $@
|
||||
src/main.c: src/version.h
|
||||
|
||||
src/builtin.inc: $(srcdir)/src/builtin.jq
|
||||
mkdir -p src
|
||||
$(AM_V_GEN) sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $(srcdir)/src/builtin.jq > $@
|
||||
src/builtin.o: src/builtin.inc
|
||||
|
||||
bin_PROGRAMS = jq
|
||||
jq_SOURCES = ${JQ_SRC} main.c
|
||||
jq_SOURCES = src/main.c src/version.h
|
||||
jq_LDFLAGS = -static-libtool-libs
|
||||
jq_LDADD = libjq.la -lm
|
||||
|
||||
if WIN32
|
||||
jq_LDADD += -lshlwapi
|
||||
endif
|
||||
|
||||
if ENABLE_ALL_STATIC
|
||||
jq_LDFLAGS += -all-static
|
||||
endif
|
||||
|
||||
### Tests (make check)
|
||||
|
||||
TESTS = tests/all.test
|
||||
TEST_LOG_COMPILER = ${srcdir}/tests/run
|
||||
TESTS = tests/optionaltest tests/mantest tests/jqtest tests/onigtest tests/shtest tests/utf8test tests/base64test
|
||||
TESTS_ENVIRONMENT = NO_VALGRIND=$(NO_VALGRIND)
|
||||
|
||||
# This is a magic make variable that causes it to treat tests/man.test as a
|
||||
# DATA-type dependency for the check target. As a result, it will attempt to
|
||||
# run any defined targets for tests/man.test as a dependency for check. This
|
||||
# allows us to ensure that the tests are up-to-date if the manual has been updated
|
||||
check_DATA = tests/man.test
|
||||
|
||||
### Building the man tests
|
||||
|
||||
# We use the examples in the manual as additional tests, to ensure they always work.
|
||||
# As a result, we need to rebuild the tests if the manual has been updated.
|
||||
# Making changes to the manpage without having the python deps means your
|
||||
# tests won't run. If you aren't making changes to the examples, you probably
|
||||
# don't care. But if you are, then you need to run the tests anyway.
|
||||
tests/man.test: $(srcdir)/docs/content/manual/manual.yml
|
||||
if ENABLE_DOCS
|
||||
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; $(PIPENV) run python build_mantests.py ) > $@
|
||||
else
|
||||
@echo Changes to the manual.yml require docs to be enabled to update the manual test.
|
||||
@echo As a result, the manual test is out of date.
|
||||
endif
|
||||
|
||||
### Building the manpage
|
||||
|
||||
# If ENABLE_DOCS is not set, just copy jq.1.default to jq.1
|
||||
# The real_docs target succeeds (possibly after building jq.1) only if ENABLE_DOCS is set
|
||||
# Thus, making "dist" depend on "real_docs" ensures that we never build a tarball with
|
||||
# a stub manpage.
|
||||
|
||||
# We build the docs from the manpage yml. If no changes have been made to the
|
||||
# manpage, then we'll end up using the cached version. Otherwise, we need to
|
||||
# rebuild it.
|
||||
man_MANS = jq.1
|
||||
.PHONY: real_docs
|
||||
jq.1.prebuilt: $(srcdir)/docs/content/manual/manual.yml
|
||||
if ENABLE_DOCS
|
||||
jq.1: $(srcdir)/docs/content/3.manual/manual.yml
|
||||
( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage ) > $@ || { rm -f $@; false; }
|
||||
jq.1.default: $(srcdir)/docs/default_manpage.md
|
||||
( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage_default ) > $@ || { rm -f $@; false; }
|
||||
real_docs: jq.1
|
||||
if cmp jq.1 $(srcdir)/jq.1.default > /dev/null; then\
|
||||
rm -f jq.1; $(MAKE) $(AM_MAKEFLAGS) jq.1;\
|
||||
fi
|
||||
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; $(PIPENV) run python build_manpage.py ) > $@ || { rm -f $@; false; }
|
||||
else
|
||||
jq.1: $(srcdir)/jq.1.default
|
||||
cp $^ $@
|
||||
real_docs:
|
||||
@echo "Ruby dependencies not found, cannot build manpage." > /dev/stderr
|
||||
@echo "Follow the instructions in docs/README.md to install them" > /dev/stderr
|
||||
@echo "and then rerun ./configure" > /dev/stderr
|
||||
false
|
||||
@echo Changes to the manual.yml require docs to be enabled to update the manpage.
|
||||
@echo As a result, the manpage is out of date.
|
||||
endif
|
||||
|
||||
jq.1: jq.1.prebuilt
|
||||
$(AM_V_GEN) cp $(srcdir)/jq.1.prebuilt $@
|
||||
|
||||
### Build oniguruma
|
||||
|
||||
if BUILD_ONIGURUMA
|
||||
libjq_la_LIBADD += modules/oniguruma/src/.libs/libonig.la
|
||||
SUBDIRS = modules/oniguruma
|
||||
endif
|
||||
|
||||
AM_CFLAGS += $(onig_CFLAGS)
|
||||
|
||||
### Packaging
|
||||
|
||||
docs/site.yml: configure.ac
|
||||
sed 's/^jq_version: .*/jq_version: $(VERSION)/' $@ > $@.new
|
||||
sed 's/^jq_version: .*/jq_version: "$(VERSION)"/' $@ > $@.new
|
||||
mv $@.new $@
|
||||
|
||||
install-binaries: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-exec
|
||||
|
||||
# Ensure "make dist" fails when we can't build the real manpage
|
||||
dist-hook: real_docs
|
||||
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
|
||||
docs/Pipfile docs/Pipfile.lock docs/build_manpage.py \
|
||||
docs/build_manpage.py docs/README.md jq.1.prebuilt
|
||||
|
||||
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
|
||||
docs/Gemfile docs/Gemfile.lock docs/Rakefile docs/README.md \
|
||||
docs/default_manpage.md jq.1.default
|
||||
EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \
|
||||
jq.1.prebuilt jq.spec src/lexer.c src/lexer.h src/parser.c \
|
||||
src/parser.h src/version.h src/builtin.jq scripts/version \
|
||||
libjq.pc \
|
||||
tests/base64.test tests/jq-f-test.sh tests/jq.test \
|
||||
tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \
|
||||
tests/modules/c/d.jq tests/modules/data.json \
|
||||
tests/modules/home1/.jq tests/modules/home2/.jq/g.jq \
|
||||
tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \
|
||||
tests/modules/shadow1.jq tests/modules/shadow2.jq \
|
||||
tests/modules/syntaxerror/syntaxerror.jq \
|
||||
tests/modules/test_bind_order.jq \
|
||||
tests/modules/test_bind_order0.jq \
|
||||
tests/modules/test_bind_order1.jq \
|
||||
tests/modules/test_bind_order2.jq \
|
||||
tests/onig.supp tests/local.supp \
|
||||
tests/onig.test tests/setup tests/torture/input0.json \
|
||||
tests/optional.test tests/optionaltest \
|
||||
tests/utf8-truncate.jq tests/utf8test \
|
||||
tests/base64.test tests/base64test \
|
||||
tests/jq-f-test.sh tests/shtest
|
||||
|
||||
# setup is only used by distribution developers, not package developers.
|
||||
# Still, as a matter of allowing patching, its not a bad idea to distribute
|
||||
# the developer setup script in the tarball.
|
||||
EXTRA_DIST = config.h.in $(BUILT_SOURCES) $(man_MANS) $(TESTS) \
|
||||
$(TEST_LOG_COMPILER) gen_utf8_tables.py jq.spec \
|
||||
$(DOC_FILES)
|
||||
DISTCHECK_CONFIGURE_FLAGS=--disable-maintainer-mode --with-oniguruma=builtin
|
||||
|
||||
# README.md is expected in Github projects, good stuff in it, so we'll
|
||||
# README.md is expected in GitHub projects, good stuff in it, so we'll
|
||||
# distribute it and install it with the package in the doc directory.
|
||||
docdir = ${datadir}/doc/${PACKAGE}
|
||||
dist_doc_DATA = README.md COPYING AUTHORS README
|
||||
dist_doc_DATA = README.md COPYING AUTHORS
|
||||
|
||||
releasetag:
|
||||
git tag -s "jq-$$(cat VERSION)" -m "jq release $$(cat VERSION)"
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libjq.pc
|
||||
|
||||
RELEASE ?= 1
|
||||
rpm: jq
|
||||
rpm: dist jq.spec
|
||||
@echo "Packaging jq as an RPM ..."
|
||||
mkdir -p rpm/SOURCES rpm/BUILD rpm/BUILDROOT rpm/RPMS rpm/SPECS
|
||||
cp jq-$$(cat VERSION).tar.gz rpm/SOURCES/
|
||||
rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "myver $$(cat VERSION)" --define "myrel ${RELEASE}" rpm/SOURCES/jq-$$(cat VERSION).tar.gz
|
||||
cp jq-$(VERSION).tar.gz rpm/SOURCES/
|
||||
rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "myver $(VERSION)" --define "myrel ${RELEASE}" rpm/SOURCES/jq-$(VERSION).tar.gz
|
||||
find rpm/RPMS/ -name "*.rpm" -exec mv {} ./ \;
|
||||
rm -rf rpm
|
||||
|
||||
@@ -119,5 +240,16 @@ dist-clean-local:
|
||||
|
||||
# Not sure why this doesn't get cleaned up automatically, guess
|
||||
# automake used to man pages which are hand coded?
|
||||
clean-local:
|
||||
# 'make clean' doesn't delete the manpage if it can't be rebuilt
|
||||
clean-local-docs:
|
||||
if ENABLE_DOCS
|
||||
rm -f jq.1
|
||||
endif
|
||||
|
||||
clean-local-gcov:
|
||||
rm -f src/*.gcno src/*.gcda src/*.gcov
|
||||
|
||||
clean-local: clean-local-docs clean-local-gcov
|
||||
rm -f src/version.h .remake-version-h
|
||||
|
||||
.PHONY: clean-local-docs clean-local-gcov
|
||||
@@ -0,0 +1,113 @@
|
||||
|
||||
Release history
|
||||
|
||||
* jq version 1.6 was released on Fri Nov 2 2018
|
||||
* jq version 1.5 was released on Sat Aug 15 2015
|
||||
* jq version 1.4 was released on Mon Jun 9 2014
|
||||
* jq version 1.3 was released on Sun May 19 2013
|
||||
* jq version 1.2 was released on Thu Dec 20 2012
|
||||
* jq version 1.1 was released on Sun Oct 21 2012
|
||||
* jq version 1.0 was released on Sun Oct 21 2012
|
||||
|
||||
New features in 1.6 since 1.5:
|
||||
|
||||
- Destructuring Alternation
|
||||
|
||||
- New Builtins:
|
||||
- builtins/0
|
||||
- stderr/0
|
||||
- halt/0, halt_error/1
|
||||
- isempty/1
|
||||
- walk/1
|
||||
- utf8bytelength/1
|
||||
- localtime/0, strflocaltime/1
|
||||
- SQL-style builtins
|
||||
- and more!
|
||||
|
||||
- Add support for ASAN and UBSAN
|
||||
|
||||
- Make it easier to use jq with shebangs (8f6f28c)
|
||||
|
||||
- Add $ENV builtin variable to access environment
|
||||
|
||||
- Add JQ_COLORS env var for configuring the output colors
|
||||
|
||||
New features in 1.5 since 1.4:
|
||||
|
||||
- regular expressions (with Oniguruma)
|
||||
|
||||
- a library/module system
|
||||
|
||||
- many new builtins
|
||||
|
||||
- datetime builtins
|
||||
- math builtins
|
||||
- regexp-related builtins
|
||||
- stream-related builtins (e.g., all/1, any/1)
|
||||
- minimal I/O builtins (`inputs`, `debug`)
|
||||
|
||||
- new syntactic features, including:
|
||||
|
||||
- destructuring (`. as [$first, $second] | ...`)
|
||||
- try/catch, generalized `?` operator, and label/break
|
||||
- `foreach`
|
||||
- multiple definitions of a function with different numbers of
|
||||
arguments
|
||||
|
||||
- command-line arguments
|
||||
|
||||
- --join-lines / -j for raw output
|
||||
- --argjson and --slurpfile
|
||||
- --tab and --indent
|
||||
- --stream (streaming JSON parser)
|
||||
- --seq (RFC7464 JSON text sequence)
|
||||
- --run-tests improvements
|
||||
|
||||
- optimizations:
|
||||
|
||||
- tail-call optimization
|
||||
- reduce and foreach no longer leak a reference to .
|
||||
|
||||
New features in 1.4 since 1.3:
|
||||
|
||||
- command-line arguments
|
||||
|
||||
- jq --arg-file variable file
|
||||
- jq --unbuffered
|
||||
- jq -e / --exit-status (set exit status based on outputs)
|
||||
- jq -S / --sort-keys (now jq no longer sorts object keys by
|
||||
default
|
||||
|
||||
- syntax
|
||||
|
||||
- .. -> like // in XPath (recursive traversal)
|
||||
- question mark (e.g., .a?) to suppress errors
|
||||
- ."foo" syntax (equivalent to .["foo"])
|
||||
- better error handling for .foo
|
||||
- added % operator (modulo)
|
||||
- allow negation without requiring extra parenthesis
|
||||
- more function arguments (up to six)
|
||||
|
||||
- filters:
|
||||
|
||||
- any, all
|
||||
- iterables, arrays, objects, scalars, nulls, booleans, numbers,
|
||||
strings, values
|
||||
|
||||
- string built-ins:
|
||||
|
||||
- split
|
||||
- join (join an array of strings with a given separator string)
|
||||
- ltrimstr, rtrimstr
|
||||
- startswith, endswith
|
||||
- explode, implode
|
||||
- fromjson, tojson
|
||||
- index, rindex, indices
|
||||
|
||||
- math functions
|
||||
|
||||
- floor, sqrt, cbrt, etcetera (depends on what's available from libm)
|
||||
|
||||
- libjq -- a C API interface to jq's JSON representation and for
|
||||
running jq programs from C applications
|
||||
|
||||
@@ -1,23 +1,78 @@
|
||||
jq
|
||||
==
|
||||
|
||||
jq is a command-line JSON processor.
|
||||
jq is a lightweight and flexible command-line JSON processor.
|
||||
|
||||
[](https://github.com/jqlang/jq/actions/workflows/linux.yml?query=branch%3Amaster)
|
||||
[](https://github.com/jqlang/jq/actions/workflows/macos.yml?query=branch%3Amaster)
|
||||
[](https://github.com/jqlang/jq/actions/workflows/windows.yml?query=branch%3Amaster)
|
||||
|
||||
If you want to learn to use jq, read the documentation at
|
||||
[http://stedolan.github.com/jq](http://stedolan.github.com/jq). This
|
||||
[https://jqlang.github.io/jq](https://jqlang.github.io/jq). This
|
||||
documentation is generated from the docs/ folder of this repository.
|
||||
You can also try it online at [jqplay.org](https://jqplay.org).
|
||||
|
||||
If you want to hack on jq, feel free, but be warned that its internals
|
||||
are not well-documented at the moment. Bring a hard hat and a
|
||||
shovel. Also, read the wiki: http://github.com/stedolan/jq/wiki
|
||||
shovel. Also, read the wiki: https://github.com/jqlang/jq/wiki, where
|
||||
you will find cookbooks, discussion of advanced topics, internals,
|
||||
release engineering, and more.
|
||||
|
||||
To build jq, run
|
||||
Source tarball and built executable releases can be found on the
|
||||
homepage and on the github release page, https://github.com/jqlang/jq/releases
|
||||
|
||||
If you're building directly from the latest git, you'll need flex,
|
||||
bison (3.0 or newer), libtool, make, automake, and autoconf installed.
|
||||
To get regexp support you'll also need to install Oniguruma or clone it as a
|
||||
git submodule as per the instructions below.
|
||||
(note that jq's tests require regexp support to pass). To build, run:
|
||||
|
||||
git submodule update --init # if building from git to get oniguruma
|
||||
autoreconf -fi # if building from git
|
||||
./configure --with-oniguruma=builtin
|
||||
make -j8
|
||||
make check
|
||||
|
||||
To build without bison or flex, add `--disable-maintainer-mode` to the
|
||||
./configure invocation:
|
||||
|
||||
./configure --with-oniguruma=builtin --disable-maintainer-mode
|
||||
|
||||
(Developers must not use `--disable-maintainer-mode`, not when making
|
||||
changes to the jq parser and/or lexer.)
|
||||
|
||||
To build a statically linked version of jq, run:
|
||||
|
||||
make LDFLAGS=-all-static
|
||||
|
||||
After make finishes, you'll be able to use `./jq`. You can also
|
||||
install it using:
|
||||
|
||||
sudo make install
|
||||
|
||||
If you're not using the latest git version but instead building a
|
||||
released tarball (available on the website), then you won't need to
|
||||
run `autoreconf` (and shouldn't), and you won't need flex or bison.
|
||||
|
||||
To cross-compile for OS X and Windows, see docs/Rakefile's build task
|
||||
and scripts/crosscompile. You'll need a cross-compilation environment,
|
||||
such as Mingw for cross-compiling for Windows.
|
||||
|
||||
Cross-compilation requires a clean workspace, then:
|
||||
|
||||
# git clean ...
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
sudo make install (optionally)
|
||||
make distclean
|
||||
scripts/crosscompile <name-of-build> <configure-options>
|
||||
|
||||
If you've just checked out the latest version from git (rather than
|
||||
using a released source tarball) then you'll need to run this first:
|
||||
Use the `--host=` and `--target=` ./configure options to select a
|
||||
cross-compilation environment. See also
|
||||
["Cross compilation"](https://github.com/jqlang/jq/wiki/Cross-compilation) on
|
||||
the wiki.
|
||||
|
||||
autoreconf
|
||||
|
||||
# Community
|
||||
|
||||
* Send questions to https://stackoverflow.com/questions/tagged/jq.
|
||||
* Join our [Discord server](https://discord.gg/yg6yjNmgAC).
|
||||
@@ -0,0 +1,7 @@
|
||||
# How to report security vulnerabilities in `jq`
|
||||
|
||||
GitHub has a [mechanism for private disclosure of vulnerabilities](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability) to repository owners and authorized persons such as maintainers. The `jqlang/jq` repository now has this feature enabled.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
See [Privately Reporting a Security Vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability). Click on [`jqlang/jq`](https://github.com/jqlang/jq)'s [Security page](https://github.com/jqlang/jq/security) and click on [Report a vulnerability](https://github.com/jqlang/jq/security/advisories/new). This will notify the owners and maintainers. After submitting you'll get an option to start a private clone of `jqlang/jq` for collaboration with the maintainers.
|
||||
@@ -0,0 +1,68 @@
|
||||
environment:
|
||||
matrix:
|
||||
- MSYSTEM: MINGW64
|
||||
PATH: C:\Python36;C:\Python36\Scripts;C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\Windows\System32;C:\Windows;%PATH%
|
||||
- MSYSTEM: MINGW32
|
||||
PATH: C:\Python36;C:\Python36\Scripts;C:\msys64\usr\bin;C:\msys64\mingw32\bin;C:\Windows\System32;C:\Windows;%PATH%
|
||||
|
||||
clone_script:
|
||||
- bash -lc "git clone -q --branch=${APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH:-$APPVEYOR_REPO_BRANCH} https://github.com/${APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME:-$APPVEYOR_REPO_NAME}.git $APPVEYOR_BUILD_FOLDER"
|
||||
- bash -lc "cd $APPVEYOR_BUILD_FOLDER && git checkout -qf ${APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH:APPVEYOR_REPO_BRANCH}"
|
||||
- bash -lc "cd $APPVEYOR_BUILD_FOLDER && git submodule update --init --recursive"
|
||||
|
||||
install:
|
||||
# update msys2
|
||||
- C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz"
|
||||
- C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig"
|
||||
- C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/bison-3.5.4-1-x86_64.pkg.tar.xz"
|
||||
- C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/bison-3.5.4-1-x86_64.pkg.tar.xz.sig"
|
||||
- C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/flex-2.6.4-1-x86_64.pkg.tar.xz"
|
||||
- C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/flex-2.6.4-1-x86_64.pkg.tar.xz.sig"
|
||||
#- C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/git-2.33.1-1-x86_64.pkg.tar.zst"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman-key --verify msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman-key --verify bison-3.5.4-1-x86_64.pkg.tar.xz.sig"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm bison-3.5.4-1-x86_64.pkg.tar.xz"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman-key --verify flex-2.6.4-1-x86_64.pkg.tar.xz.sig"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm flex-2.6.4-1-x86_64.pkg.tar.xz"
|
||||
- ps: Get-Process | Where-Object {$_.path -like 'C:\msys64*'} | Stop-Process
|
||||
#- C:\msys64\usr\bin\bash -lc "pacman --needed --noconfirm -Sy pacman-mirrors"
|
||||
#- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Su"
|
||||
#- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S autoconf automake bison flex git"
|
||||
- C:\msys64\usr\bin\bash -lc "pip3 install --upgrade pipenv"
|
||||
- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER/docs && pipenv sync"
|
||||
|
||||
build_script:
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && autoreconf -i"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && ./configure --with-oniguruma=builtin --disable-shared --enable-static --enable-all-static"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && cat jq.1 | groff -mandoc -Thtml > jq.html"
|
||||
- 7z a jq-package.zip jq.1 jq.html jq.exe
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && pwd && ls -la"
|
||||
- file jq.exe
|
||||
|
||||
test_script:
|
||||
# tests/optionaltest and tests/shtest fail on Windows; run them
|
||||
# anyways but ignore their failures. Also, trace shtest.
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make -j3 SUBDIRS= 'TESTS=tests/mantest tests/jqtest tests/onigtest tests/base64test' check"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make SUBDIRS= TESTS=tests/optionaltest check || true"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make SUBDIRS= TRACE_TESTS=1 TESTS=tests/shtest check || true"
|
||||
|
||||
artifacts:
|
||||
- path: jq-package.zip
|
||||
name: jq-package
|
||||
|
||||
- path: jq.exe
|
||||
name: jq-exe
|
||||
|
||||
- path: test-suite.log
|
||||
name: logs
|
||||
|
||||
|
||||
on_failure:
|
||||
- cat config.log
|
||||
- cat test-suite.log
|
||||
- appveyor PushArtifact test-suite.log
|
||||
# also push the jq.exe so that someone can download it anyways...
|
||||
- appveyor PushArtifact jq-package.zip
|
||||
|
||||
@@ -1,565 +0,0 @@
|
||||
#include <string.h>
|
||||
#include "builtin.h"
|
||||
#include "compile.h"
|
||||
#include "jq_parser.h"
|
||||
#include "locfile.h"
|
||||
#include "jv_aux.h"
|
||||
#include "jv_unicode.h"
|
||||
|
||||
|
||||
|
||||
typedef jv (*func_1)(jv);
|
||||
typedef jv (*func_2)(jv,jv);
|
||||
typedef jv (*func_3)(jv,jv,jv);
|
||||
typedef jv (*func_4)(jv,jv,jv,jv);
|
||||
typedef jv (*func_5)(jv,jv,jv,jv,jv);
|
||||
jv cfunction_invoke(struct cfunction* function, jv input[]) {
|
||||
switch (function->nargs) {
|
||||
case 1: return ((func_1)function->fptr)(input[0]);
|
||||
case 2: return ((func_2)function->fptr)(input[0], input[1]);
|
||||
case 3: return ((func_3)function->fptr)(input[0], input[1], input[2]);
|
||||
case 4: return ((func_4)function->fptr)(input[0], input[1], input[2], input[3]);
|
||||
case 5: return ((func_5)function->fptr)(input[0], input[1], input[2], input[3], input[4]);
|
||||
default: return jv_invalid_with_msg(jv_string("Function takes too many arguments"));
|
||||
}
|
||||
}
|
||||
|
||||
static jv type_error(jv bad, const char* msg) {
|
||||
jv err = jv_invalid_with_msg(jv_string_fmt("%s %s",
|
||||
jv_kind_name(jv_get_kind(bad)),
|
||||
msg));
|
||||
jv_free(bad);
|
||||
return err;
|
||||
}
|
||||
|
||||
static jv type_error2(jv bad1, jv bad2, const char* msg) {
|
||||
jv err = jv_invalid_with_msg(jv_string_fmt("%s and %s %s",
|
||||
jv_kind_name(jv_get_kind(bad1)),
|
||||
jv_kind_name(jv_get_kind(bad2)),
|
||||
msg));
|
||||
jv_free(bad1);
|
||||
jv_free(bad2);
|
||||
return err;
|
||||
}
|
||||
|
||||
static jv f_plus(jv input, jv a, jv b) {
|
||||
jv_free(input);
|
||||
if (jv_get_kind(a) == JV_KIND_NULL) {
|
||||
jv_free(a);
|
||||
return b;
|
||||
} else if (jv_get_kind(b) == JV_KIND_NULL) {
|
||||
jv_free(b);
|
||||
return a;
|
||||
} else if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
|
||||
return jv_number(jv_number_value(a) +
|
||||
jv_number_value(b));
|
||||
} else if (jv_get_kind(a) == JV_KIND_STRING && jv_get_kind(b) == JV_KIND_STRING) {
|
||||
return jv_string_concat(a, b);
|
||||
} else if (jv_get_kind(a) == JV_KIND_ARRAY && jv_get_kind(b) == JV_KIND_ARRAY) {
|
||||
return jv_array_concat(a, b);
|
||||
} else if (jv_get_kind(a) == JV_KIND_OBJECT && jv_get_kind(b) == JV_KIND_OBJECT) {
|
||||
return jv_object_merge(a, b);
|
||||
} else {
|
||||
return type_error2(a, b, "cannot be added");
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_negate(jv input) {
|
||||
if (jv_get_kind(input) != JV_KIND_NUMBER) {
|
||||
return type_error(input, "cannot be negated");
|
||||
}
|
||||
jv ret = jv_number(-jv_number_value(input));
|
||||
jv_free(input);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static jv f_minus(jv input, jv a, jv b) {
|
||||
jv_free(input);
|
||||
if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
|
||||
return jv_number(jv_number_value(a) - jv_number_value(b));
|
||||
} else if (jv_get_kind(a) == JV_KIND_ARRAY && jv_get_kind(b) == JV_KIND_ARRAY) {
|
||||
jv out = jv_array();
|
||||
jv_array_foreach(a, i, x) {
|
||||
int include = 1;
|
||||
jv_array_foreach(b, j, y) {
|
||||
if (jv_equal(jv_copy(x), y)) {
|
||||
include = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (include)
|
||||
out = jv_array_append(out, jv_copy(x));
|
||||
jv_free(x);
|
||||
}
|
||||
jv_free(a);
|
||||
jv_free(b);
|
||||
return out;
|
||||
} else {
|
||||
return type_error2(a, b, "cannot be subtracted");
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_multiply(jv input, jv a, jv b) {
|
||||
jv_free(input);
|
||||
if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
|
||||
return jv_number(jv_number_value(a) * jv_number_value(b));
|
||||
} else {
|
||||
return type_error2(a, b, "cannot be multiplied");
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_divide(jv input, jv a, jv b) {
|
||||
jv_free(input);
|
||||
if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
|
||||
return jv_number(jv_number_value(a) / jv_number_value(b));
|
||||
} else {
|
||||
return type_error2(a, b, "cannot be divided");
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_equal(jv input, jv a, jv b) {
|
||||
jv_free(input);
|
||||
return jv_bool(jv_equal(a, b));
|
||||
}
|
||||
|
||||
static jv f_notequal(jv input, jv a, jv b) {
|
||||
jv_free(input);
|
||||
return jv_bool(!jv_equal(a, b));
|
||||
}
|
||||
|
||||
enum cmp_op {
|
||||
CMP_OP_LESS,
|
||||
CMP_OP_GREATER,
|
||||
CMP_OP_LESSEQ,
|
||||
CMP_OP_GREATEREQ
|
||||
};
|
||||
|
||||
static jv order_cmp(jv input, jv a, jv b, enum cmp_op op) {
|
||||
jv_free(input);
|
||||
int r = jv_cmp(a, b);
|
||||
return jv_bool((op == CMP_OP_LESS && r < 0) ||
|
||||
(op == CMP_OP_LESSEQ && r <= 0) ||
|
||||
(op == CMP_OP_GREATEREQ && r >= 0) ||
|
||||
(op == CMP_OP_GREATER && r > 0));
|
||||
}
|
||||
|
||||
static jv f_less(jv input, jv a, jv b) {
|
||||
return order_cmp(input, a, b, CMP_OP_LESS);
|
||||
}
|
||||
|
||||
static jv f_greater(jv input, jv a, jv b) {
|
||||
return order_cmp(input, a, b, CMP_OP_GREATER);
|
||||
}
|
||||
|
||||
static jv f_lesseq(jv input, jv a, jv b) {
|
||||
return order_cmp(input, a, b, CMP_OP_LESSEQ);
|
||||
}
|
||||
|
||||
static jv f_greatereq(jv input, jv a, jv b) {
|
||||
return order_cmp(input, a, b, CMP_OP_GREATEREQ);
|
||||
}
|
||||
|
||||
static jv f_contains(jv a, jv b) {
|
||||
if (jv_get_kind(a) == jv_get_kind(b)) {
|
||||
return jv_bool(jv_contains(a, b));
|
||||
} else {
|
||||
return type_error2(a, b, "cannot have their containment checked");
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_tonumber(jv input) {
|
||||
if (jv_get_kind(input) == JV_KIND_NUMBER) {
|
||||
return input;
|
||||
}
|
||||
if (jv_get_kind(input) == JV_KIND_STRING) {
|
||||
jv parsed = jv_parse(jv_string_value(input));
|
||||
if (!jv_is_valid(parsed) || jv_get_kind(parsed) == JV_KIND_NUMBER) {
|
||||
jv_free(input);
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
return type_error(input, "cannot be parsed as a number");
|
||||
}
|
||||
|
||||
static jv f_length(jv input) {
|
||||
if (jv_get_kind(input) == JV_KIND_ARRAY) {
|
||||
return jv_number(jv_array_length(input));
|
||||
} else if (jv_get_kind(input) == JV_KIND_OBJECT) {
|
||||
return jv_number(jv_object_length(input));
|
||||
} else if (jv_get_kind(input) == JV_KIND_STRING) {
|
||||
return jv_number(jv_string_length(input));
|
||||
} else if (jv_get_kind(input) == JV_KIND_NULL) {
|
||||
jv_free(input);
|
||||
return jv_number(0);
|
||||
} else {
|
||||
return type_error(input, "has no length");
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_tostring(jv input) {
|
||||
if (jv_get_kind(input) == JV_KIND_STRING) {
|
||||
return input;
|
||||
} else {
|
||||
return jv_dump_string(input, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#define CHARS_ALPHANUM "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
|
||||
static jv escape_string(jv input, const char* escapings) {
|
||||
|
||||
assert(jv_get_kind(input) == JV_KIND_STRING);
|
||||
const char* lookup[128] = {0};
|
||||
const char* p = escapings;
|
||||
while (*p) {
|
||||
lookup[(int)*p] = p+1;
|
||||
p++;
|
||||
p += strlen(p);
|
||||
p++;
|
||||
}
|
||||
|
||||
jv ret = jv_string("");
|
||||
const char* i = jv_string_value(input);
|
||||
const char* end = i + jv_string_length(jv_copy(input));
|
||||
const char* cstart;
|
||||
int c = 0;
|
||||
while ((i = jvp_utf8_next((cstart = i), end, &c))) {
|
||||
assert(c != -1);
|
||||
if (c < 128 && lookup[c]) {
|
||||
ret = jv_string_append_str(ret, lookup[c]);
|
||||
} else {
|
||||
ret = jv_string_append_buf(ret, cstart, i - cstart);
|
||||
}
|
||||
}
|
||||
jv_free(input);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
static jv f_format(jv input, jv fmt) {
|
||||
if (jv_get_kind(fmt) != JV_KIND_STRING) {
|
||||
jv_free(input);
|
||||
return type_error(fmt, "is not a valid format");
|
||||
}
|
||||
const char* fmt_s = jv_string_value(fmt);
|
||||
if (!strcmp(fmt_s, "json")) {
|
||||
jv_free(fmt);
|
||||
return jv_dump_string(input, 0);
|
||||
} else if (!strcmp(fmt_s, "text")) {
|
||||
jv_free(fmt);
|
||||
return f_tostring(input);
|
||||
} else if (!strcmp(fmt_s, "csv")) {
|
||||
jv_free(fmt);
|
||||
if (jv_get_kind(input) != JV_KIND_ARRAY)
|
||||
return type_error(input, "cannot be csv-formatted, only array");
|
||||
jv line = jv_string("");
|
||||
jv_array_foreach(input, i, x) {
|
||||
if (i) line = jv_string_append_str(line, ",");
|
||||
switch (jv_get_kind(x)) {
|
||||
case JV_KIND_NULL:
|
||||
/* null rendered as empty string */
|
||||
jv_free(x);
|
||||
break;
|
||||
case JV_KIND_TRUE:
|
||||
case JV_KIND_FALSE:
|
||||
line = jv_string_concat(line, jv_dump_string(x, 0));
|
||||
break;
|
||||
case JV_KIND_NUMBER:
|
||||
if (jv_number_value(x) != jv_number_value(x)) {
|
||||
/* NaN, render as empty string */
|
||||
jv_free(x);
|
||||
} else {
|
||||
line = jv_string_concat(line, jv_dump_string(x, 0));
|
||||
}
|
||||
break;
|
||||
case JV_KIND_STRING: {
|
||||
line = jv_string_append_str(line, "\"");
|
||||
line = jv_string_concat(line, escape_string(x, "\"\"\"\0"));
|
||||
line = jv_string_append_str(line, "\"");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
jv_free(input);
|
||||
jv_free(line);
|
||||
return type_error(x, "is not valid in a csv row");
|
||||
}
|
||||
}
|
||||
jv_free(input);
|
||||
return line;
|
||||
} else if (!strcmp(fmt_s, "html")) {
|
||||
jv_free(fmt);
|
||||
return escape_string(f_tostring(input), "&&\0<<\0>>\0''\0\""\0");
|
||||
} else if (!strcmp(fmt_s, "uri")) {
|
||||
jv_free(fmt);
|
||||
input = f_tostring(input);
|
||||
|
||||
int unreserved[128] = {0};
|
||||
const char* p = CHARS_ALPHANUM "-_.!~*'()";
|
||||
while (*p) unreserved[(int)*p++] = 1;
|
||||
|
||||
jv line = jv_string("");
|
||||
const char* s = jv_string_value(input);
|
||||
for (int i=0; i<jv_string_length(jv_copy(input)); i++) {
|
||||
unsigned ch = (unsigned)(unsigned char)*s;
|
||||
if (ch < 128 && unreserved[ch]) {
|
||||
line = jv_string_append_buf(line, s, 1);
|
||||
} else {
|
||||
line = jv_string_concat(line, jv_string_fmt("%%%02x", ch));
|
||||
}
|
||||
s++;
|
||||
}
|
||||
jv_free(input);
|
||||
return line;
|
||||
} else if (!strcmp(fmt_s, "sh")) {
|
||||
jv_free(fmt);
|
||||
if (jv_get_kind(input) != JV_KIND_ARRAY)
|
||||
input = jv_array_set(jv_array(), 0, input);
|
||||
jv line = jv_string("");
|
||||
jv_array_foreach(input, i, x) {
|
||||
if (i) line = jv_string_append_str(line, " ");
|
||||
switch (jv_get_kind(x)) {
|
||||
case JV_KIND_NULL:
|
||||
case JV_KIND_TRUE:
|
||||
case JV_KIND_FALSE:
|
||||
case JV_KIND_NUMBER:
|
||||
line = jv_string_concat(line, jv_dump_string(x, 0));
|
||||
break;
|
||||
|
||||
case JV_KIND_STRING: {
|
||||
line = jv_string_append_str(line, "'");
|
||||
line = jv_string_concat(line, escape_string(x, "''\\''\0"));
|
||||
line = jv_string_append_str(line, "'");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
jv_free(input);
|
||||
jv_free(line);
|
||||
return type_error(x, "can not be escaped for shell");
|
||||
}
|
||||
}
|
||||
jv_free(input);
|
||||
return line;
|
||||
} else if (!strcmp(fmt_s, "base64")) {
|
||||
jv_free(fmt);
|
||||
input = f_tostring(input);
|
||||
jv line = jv_string("");
|
||||
const char b64[64 + 1] = CHARS_ALPHANUM "+/";
|
||||
const char* data = jv_string_value(input);
|
||||
int len = jv_string_length(jv_copy(input));
|
||||
for (int i=0; i<len; i+=3) {
|
||||
uint32_t code = 0;
|
||||
int n = len - i >= 3 ? 3 : len-i;
|
||||
for (int j=0; j<3; j++) {
|
||||
code <<= 8;
|
||||
code |= j < n ? (unsigned)data[i+j] : 0;
|
||||
}
|
||||
char buf[4];
|
||||
for (int j=0; j<4; j++) {
|
||||
buf[j] = b64[(code >> (18 - j*6)) & 0x3f];
|
||||
}
|
||||
if (n < 3) buf[3] = '=';
|
||||
if (n < 2) buf[2] = '=';
|
||||
line = jv_string_append_buf(line, buf, sizeof(buf));
|
||||
}
|
||||
jv_free(input);
|
||||
return line;
|
||||
} else {
|
||||
jv_free(input);
|
||||
return jv_invalid_with_msg(jv_string_concat(fmt, jv_string(" is not a valid format")));
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_keys(jv input) {
|
||||
if (jv_get_kind(input) == JV_KIND_OBJECT || jv_get_kind(input) == JV_KIND_ARRAY) {
|
||||
return jv_keys(input);
|
||||
} else {
|
||||
return type_error(input, "has no keys");
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_sort(jv input){
|
||||
if (jv_get_kind(input) == JV_KIND_ARRAY) {
|
||||
return jv_sort(input, jv_copy(input));
|
||||
} else {
|
||||
return type_error(input, "cannot be sorted, as it is not an array");
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_sort_by_impl(jv input, jv keys) {
|
||||
if (jv_get_kind(input) == JV_KIND_ARRAY &&
|
||||
jv_get_kind(keys) == JV_KIND_ARRAY &&
|
||||
jv_array_length(jv_copy(input)) == jv_array_length(jv_copy(keys))) {
|
||||
return jv_sort(input, keys);
|
||||
} else {
|
||||
return type_error2(input, keys, "cannot be sorted, as they are not both arrays");
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_group_by_impl(jv input, jv keys) {
|
||||
if (jv_get_kind(input) == JV_KIND_ARRAY &&
|
||||
jv_get_kind(keys) == JV_KIND_ARRAY &&
|
||||
jv_array_length(jv_copy(input)) == jv_array_length(jv_copy(keys))) {
|
||||
return jv_group(input, keys);
|
||||
} else {
|
||||
return type_error2(input, keys, "cannot be sorted, as they are not both arrays");
|
||||
}
|
||||
}
|
||||
|
||||
static jv minmax_by(jv values, jv keys, int is_min) {
|
||||
if (jv_get_kind(values) != JV_KIND_ARRAY)
|
||||
return type_error2(values, keys, "cannot be iterated over");
|
||||
if (jv_get_kind(keys) != JV_KIND_ARRAY)
|
||||
return type_error2(values, keys, "cannot be iterated over");
|
||||
if (jv_array_length(jv_copy(values)) != jv_array_length(jv_copy(keys)))
|
||||
return type_error2(values, keys, "have wrong length");
|
||||
|
||||
if (jv_array_length(jv_copy(values)) == 0) {
|
||||
jv_free(values);
|
||||
jv_free(keys);
|
||||
return jv_null();
|
||||
}
|
||||
jv ret = jv_array_get(jv_copy(values), 0);
|
||||
jv retkey = jv_array_get(jv_copy(keys), 0);
|
||||
for (int i=1; i<jv_array_length(jv_copy(values)); i++) {
|
||||
jv item = jv_array_get(jv_copy(keys), i);
|
||||
int cmp = jv_cmp(jv_copy(item), jv_copy(retkey));
|
||||
if ((cmp < 0) == (is_min == 1)) {
|
||||
jv_free(retkey);
|
||||
retkey = item;
|
||||
jv_free(ret);
|
||||
ret = jv_array_get(jv_copy(values), i);
|
||||
} else {
|
||||
jv_free(item);
|
||||
}
|
||||
}
|
||||
jv_free(values);
|
||||
jv_free(keys);
|
||||
jv_free(retkey);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static jv f_min(jv x) {
|
||||
return minmax_by(x, jv_copy(x), 1);
|
||||
}
|
||||
|
||||
static jv f_max(jv x) {
|
||||
return minmax_by(x, jv_copy(x), 0);
|
||||
}
|
||||
|
||||
static jv f_min_by_impl(jv x, jv y) {
|
||||
return minmax_by(x, y, 1);
|
||||
}
|
||||
|
||||
static jv f_max_by_impl(jv x, jv y) {
|
||||
return minmax_by(x, y, 0);
|
||||
}
|
||||
|
||||
|
||||
static jv f_type(jv input) {
|
||||
jv out = jv_string(jv_kind_name(jv_get_kind(input)));
|
||||
jv_free(input);
|
||||
return out;
|
||||
}
|
||||
|
||||
static jv f_error(jv input, jv msg) {
|
||||
jv_free(input);
|
||||
msg = f_tostring(msg);
|
||||
return jv_invalid_with_msg(msg);
|
||||
}
|
||||
|
||||
static const struct cfunction function_list[] = {
|
||||
{(cfunction_ptr)f_plus, "_plus", 3},
|
||||
{(cfunction_ptr)f_negate, "_negate", 1},
|
||||
{(cfunction_ptr)f_minus, "_minus", 3},
|
||||
{(cfunction_ptr)f_multiply, "_multiply", 3},
|
||||
{(cfunction_ptr)f_divide, "_divide", 3},
|
||||
{(cfunction_ptr)f_tonumber, "tonumber", 1},
|
||||
{(cfunction_ptr)f_tostring, "tostring", 1},
|
||||
{(cfunction_ptr)f_keys, "keys", 1},
|
||||
{(cfunction_ptr)jv_setpath, "setpath", 3}, // FIXME typechecking
|
||||
{(cfunction_ptr)jv_getpath, "getpath", 2},
|
||||
{(cfunction_ptr)jv_delpaths, "delpaths", 2},
|
||||
{(cfunction_ptr)jv_has, "has", 2},
|
||||
{(cfunction_ptr)f_equal, "_equal", 3},
|
||||
{(cfunction_ptr)f_notequal, "_notequal", 3},
|
||||
{(cfunction_ptr)f_less, "_less", 3},
|
||||
{(cfunction_ptr)f_greater, "_greater", 3},
|
||||
{(cfunction_ptr)f_lesseq, "_lesseq", 3},
|
||||
{(cfunction_ptr)f_greatereq, "_greatereq", 3},
|
||||
{(cfunction_ptr)f_contains, "contains", 2},
|
||||
{(cfunction_ptr)f_length, "length", 1},
|
||||
{(cfunction_ptr)f_type, "type", 1},
|
||||
{(cfunction_ptr)f_sort, "sort", 1},
|
||||
{(cfunction_ptr)f_sort_by_impl, "_sort_by_impl", 2},
|
||||
{(cfunction_ptr)f_group_by_impl, "_group_by_impl", 2},
|
||||
{(cfunction_ptr)f_min, "min", 1},
|
||||
{(cfunction_ptr)f_max, "max", 1},
|
||||
{(cfunction_ptr)f_min_by_impl, "_min_by_impl", 2},
|
||||
{(cfunction_ptr)f_max_by_impl, "_max_by_impl", 2},
|
||||
{(cfunction_ptr)f_error, "error", 2},
|
||||
{(cfunction_ptr)f_format, "format", 2},
|
||||
};
|
||||
|
||||
struct bytecoded_builtin { const char* name; block code; };
|
||||
static block bind_bytecoded_builtins(block b) {
|
||||
block builtins = gen_noop();
|
||||
{
|
||||
struct bytecoded_builtin builtin_defs[] = {
|
||||
{"empty", gen_op_simple(BACKTRACK)},
|
||||
{"false", gen_const(jv_false())},
|
||||
{"true", gen_const(jv_true())},
|
||||
{"null", gen_const(jv_null())},
|
||||
{"not", gen_condbranch(gen_const(jv_false()),
|
||||
gen_const(jv_true()))}
|
||||
};
|
||||
for (unsigned i=0; i<sizeof(builtin_defs)/sizeof(builtin_defs[0]); i++) {
|
||||
builtins = BLOCK(builtins, gen_function(builtin_defs[i].name, gen_noop(),
|
||||
builtin_defs[i].code));
|
||||
}
|
||||
}
|
||||
{
|
||||
struct bytecoded_builtin builtin_def_1arg[] = {
|
||||
{"path", BLOCK(gen_op_simple(DUP),
|
||||
gen_call("arg", gen_noop()),
|
||||
gen_op_simple(GETPATH))},
|
||||
};
|
||||
for (unsigned i=0; i<sizeof(builtin_def_1arg)/sizeof(builtin_def_1arg[0]); i++) {
|
||||
builtins = BLOCK(builtins, gen_function(builtin_def_1arg[i].name,
|
||||
gen_op_block_unbound(CLOSURE_PARAM, "arg"),
|
||||
builtin_def_1arg[i].code));
|
||||
}
|
||||
}
|
||||
|
||||
return block_bind(builtins, b, OP_IS_CALL_PSEUDO);
|
||||
}
|
||||
|
||||
static const char* const jq_builtins[] = {
|
||||
"def map(f): [.[] | f];",
|
||||
"def select(f): if f then . else empty end;",
|
||||
"def sort_by(f): _sort_by_impl(map([f]));",
|
||||
"def group_by(f): _group_by_impl(map([f]));",
|
||||
"def unique: group_by(.) | map(.[0]);",
|
||||
"def max_by(f): _max_by_impl(map([f]));",
|
||||
"def min_by(f): _min_by_impl(map([f]));",
|
||||
"def add: fold null as $sum (.[] | $sum + .);",
|
||||
"def del(f): delpaths([path(f)]);",
|
||||
"def _assign(paths; value): value as $v | fold . as $obj (path(paths) as $p | $obj | setpath($p; $v));",
|
||||
"def _modify(paths; update): fold . as $obj (path(paths) as $p | $obj | setpath($p; getpath($p) | update));",
|
||||
"def recurse(f): ., (f | select(. != null) | recurse(f));",
|
||||
};
|
||||
|
||||
|
||||
block builtins_bind(block b) {
|
||||
for (int i=(int)(sizeof(jq_builtins)/sizeof(jq_builtins[0]))-1; i>=0; i--) {
|
||||
struct locfile src;
|
||||
locfile_init(&src, jq_builtins[i], strlen(jq_builtins[i]));
|
||||
block funcs;
|
||||
int nerrors = jq_parse_library(&src, &funcs);
|
||||
assert(!nerrors);
|
||||
b = block_bind(funcs, b, OP_IS_CALL_PSEUDO);
|
||||
locfile_free(&src);
|
||||
}
|
||||
b = bind_bytecoded_builtins(b);
|
||||
return gen_cbinding(function_list, sizeof(function_list)/sizeof(function_list[0]), b);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef BUILTIN_H
|
||||
#define BUILTIN_H
|
||||
|
||||
#include "compile.h"
|
||||
|
||||
block builtins_bind(block);
|
||||
|
||||
|
||||
typedef void (*cfunction_ptr)(void);
|
||||
|
||||
struct cfunction {
|
||||
cfunction_ptr fptr;
|
||||
const char* name;
|
||||
int nargs;
|
||||
};
|
||||
|
||||
|
||||
jv cfunction_invoke(struct cfunction* function, jv input[]);
|
||||
|
||||
|
||||
#endif
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "bytecode.h"
|
||||
#include "opcode.h"
|
||||
#include "jv_alloc.h"
|
||||
|
||||
static int bytecode_operation_length(uint16_t* codeptr) {
|
||||
int length = opcode_describe(*codeptr)->length;
|
||||
if (*codeptr == CALL_JQ) {
|
||||
length += codeptr[1] * 2;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
void dump_disassembly(int indent, struct bytecode* bc) {
|
||||
if (bc->nclosures > 0) {
|
||||
printf("%*s[params: %d]\n", indent, "", bc->nclosures);
|
||||
}
|
||||
dump_code(indent, bc);
|
||||
for (int i=0; i<bc->nsubfunctions; i++) {
|
||||
printf("%*ssubfn[%d]:\n", indent, "", i);
|
||||
dump_disassembly(indent+2, bc->subfunctions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void dump_code(int indent, struct bytecode* bc) {
|
||||
int pc = 0;
|
||||
while (pc < bc->codelen) {
|
||||
printf("%*s", indent, "");
|
||||
dump_operation(bc, bc->code + pc);
|
||||
printf("\n");
|
||||
pc += bytecode_operation_length(bc->code + pc);
|
||||
}
|
||||
}
|
||||
|
||||
void dump_operation(struct bytecode* bc, uint16_t* codeptr) {
|
||||
int pc = codeptr - bc->code;
|
||||
printf("%04d ", pc);
|
||||
const struct opcode_description* op = opcode_describe(bc->code[pc++]);
|
||||
printf("%s", op->name);
|
||||
if (op->length > 1) {
|
||||
uint16_t imm = bc->code[pc++];
|
||||
if (op->op == CALL_JQ) {
|
||||
for (int i=0; i<imm+1; i++) {
|
||||
uint16_t level = bc->code[pc++];
|
||||
uint16_t idx = bc->code[pc++];
|
||||
if (idx & ARG_NEWCLOSURE) {
|
||||
printf(" subfn[%d]", idx & ~ARG_NEWCLOSURE);
|
||||
} else {
|
||||
printf(" param[%d]", idx);
|
||||
}
|
||||
if (level) {
|
||||
printf("^%d", level);
|
||||
}
|
||||
}
|
||||
} else if (op->flags & OP_HAS_BRANCH) {
|
||||
printf(" %04d", pc + imm);
|
||||
} else if (op->flags & OP_HAS_CONSTANT) {
|
||||
printf(" ");
|
||||
jv_dump(jv_array_get(jv_copy(bc->constants), imm), 0);
|
||||
} else if (op->flags & OP_HAS_VARIABLE) {
|
||||
uint16_t v = bc->code[pc++];
|
||||
printf(" v%d", v);
|
||||
if (imm) {
|
||||
printf("^%d", imm);
|
||||
}
|
||||
} else {
|
||||
printf(" %d", imm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void symbol_table_free(struct symbol_table* syms) {
|
||||
jv_mem_free(syms->cfunctions);
|
||||
jv_mem_free(syms);
|
||||
}
|
||||
|
||||
void bytecode_free(struct bytecode* bc) {
|
||||
jv_mem_free(bc->code);
|
||||
jv_free(bc->constants);
|
||||
for (int i=0; i<bc->nsubfunctions; i++)
|
||||
bytecode_free(bc->subfunctions[i]);
|
||||
if (!bc->parent)
|
||||
symbol_table_free(bc->globals);
|
||||
jv_mem_free(bc->subfunctions);
|
||||
jv_mem_free(bc);
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
#ifndef BYTECODE_H
|
||||
#define BYTECODE_H
|
||||
#include <stdint.h>
|
||||
|
||||
#include "jv.h"
|
||||
#include "opcode.h"
|
||||
#include "builtin.h"
|
||||
|
||||
#define MAX_CFUNCTION_ARGS 10
|
||||
struct symbol_table {
|
||||
struct cfunction* cfunctions;
|
||||
int ncfunctions;
|
||||
};
|
||||
|
||||
// The bytecode format matters in:
|
||||
// execute.c - interpreter
|
||||
// compile.c - compiler
|
||||
// bytecode.c - disassembler
|
||||
|
||||
#define ARG_NEWCLOSURE 0x1000
|
||||
|
||||
struct bytecode {
|
||||
uint16_t* code;
|
||||
int codelen;
|
||||
|
||||
int nlocals;
|
||||
int nclosures;
|
||||
|
||||
jv constants; // JSON array of constants
|
||||
struct symbol_table* globals;
|
||||
|
||||
struct bytecode** subfunctions;
|
||||
int nsubfunctions;
|
||||
|
||||
struct bytecode* parent;
|
||||
};
|
||||
|
||||
void dump_disassembly(int, struct bytecode* code);
|
||||
void dump_code(int, struct bytecode* code);
|
||||
void dump_operation(struct bytecode* bc, uint16_t* op);
|
||||
|
||||
void symbol_table_free(struct symbol_table* syms);
|
||||
void bytecode_free(struct bytecode* bc);
|
||||
|
||||
#endif
|
||||
Executable
+106
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env bash
|
||||
# Mac C. compile-ios.sh for JQ.
|
||||
|
||||
# Defaults
|
||||
set -e
|
||||
oniguruma='6.9.3'
|
||||
|
||||
unset CFLAGS
|
||||
unset CXXFLAGS
|
||||
unset LDFLAGS
|
||||
|
||||
# Parse args.
|
||||
usage(){
|
||||
cat << EOF
|
||||
${0##*/}: usage
|
||||
|
||||
Description:
|
||||
This simple script builds oniguruma and jq for all *-apple-darwin devices.
|
||||
|
||||
Arguments:
|
||||
--extra-cflags <arg>: Pass defines or includes to clang.
|
||||
--extra-ldflags <arg>: Pass libs or includes to ld64.
|
||||
|
||||
--with-oniguruma <arg>: Change default version of onigurma from ${oniguruma}.
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
while (( $# )); do
|
||||
case "$1" in
|
||||
--with-oniguruma) shift; oniguruma="${1}" ;;
|
||||
|
||||
--extra-cflags) shift; export CFLAGS_="${1}" ;;
|
||||
--extra-ldflags) shift; export LDFLAGS_="${1}" ;;
|
||||
|
||||
--help) usage ;;
|
||||
*) echo -e "Unknown option: ${1}\n"; usage ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Start building.
|
||||
echo "Building..."
|
||||
MAKEJOBS="$(sysctl -n hw.ncpu || echo 1)"
|
||||
CC_="$(xcrun -f clang || echo clang)"
|
||||
|
||||
onig_url="https://github.com/kkos/oniguruma/releases/download/v${oniguruma}/onig-${oniguruma}.tar.gz"
|
||||
builddir="${TMPDIR:-/tmp}/${RANDOM:-'xxxxx'}-compile-ios-build"
|
||||
cwd="$(realpath ${PWD} 2>/dev/null || echo ${PWD})"
|
||||
|
||||
t_exit() {
|
||||
cat << EOF
|
||||
|
||||
A error as occurred.
|
||||
oniguruma location: ${builddir}/onig/onig-${oniguruma}
|
||||
jq location: ${cwd}
|
||||
|
||||
Provide config.log and console logs when posting a issue.
|
||||
|
||||
EOF
|
||||
}
|
||||
trap t_exit ERR
|
||||
|
||||
# Onig.
|
||||
mkdir -p "${builddir}/onig"
|
||||
cd "${builddir}/"
|
||||
curl -L ${onig_url} | tar xz
|
||||
for arch in i386 x86_64 armv7 armv7s arm64; do
|
||||
if [[ "$arch" = "i386" || "$arch" = "x86_64" ]]; then
|
||||
SYSROOT=$(xcrun -f --sdk iphonesimulator --show-sdk-path)
|
||||
else
|
||||
SYSROOT=$(xcrun -f --sdk iphoneos --show-sdk-path)
|
||||
fi
|
||||
HOST="${arch}-apple-darwin"
|
||||
[[ "${arch}" = "arm64" ]] && HOST="aarch64-apple-darwin"
|
||||
|
||||
CFLAGS="-arch ${arch} -miphoneos-version-min=9.0 -isysroot ${SYSROOT} ${CFLAGS_} -D_REENTRANT"
|
||||
LDFLAGS="-arch ${arch} -miphoneos-version-min=9.0 -isysroot ${SYSROOT} ${LDFLAGS_}"
|
||||
CC="${CC_} ${CFLAGS}"
|
||||
|
||||
# ./configure; make install
|
||||
cd "${builddir}/onig-${oniguruma}"
|
||||
CC=${CC} LDFLAGS=${LDFLAGS} \
|
||||
./configure --host=${HOST} --build=$(./config.guess) --enable-shared=no --enable-static=yes --prefix=/
|
||||
make -j${MAKEJOBS} install DESTDIR="${cwd}/ios/onig/${arch}"
|
||||
make clean
|
||||
|
||||
# Jump back to JQ.
|
||||
cd ${cwd}
|
||||
[[ ! -f ./configure ]] && autoreconf -ivf
|
||||
CC=${CC} LDFLAGS=${LDFLAGS} \
|
||||
./configure --host=${HOST} --build=$(./config/config.guess) --enable-docs=no --enable-shared=no --enable-static=yes --prefix=/ --with-oniguruma=${cwd}/ios/onig/${arch} $(test -z ${BISON+x} && echo '--disable-maintainer-mode')
|
||||
make -j${MAKEJOBS} install DESTDIR="${cwd}/ios/jq/${arch}"
|
||||
make clean
|
||||
done
|
||||
|
||||
mkdir -p "${cwd}/ios/dest/lib"
|
||||
# lipo, make a static lib.
|
||||
lipo -create -output ${cwd}/ios/dest/lib/libonig.a ${cwd}/ios/onig/{i386,x86_64,armv7,armv7s,arm64}/lib/libonig.a
|
||||
lipo -create -output ${cwd}/ios/dest/lib/libjq.a ${cwd}/ios/jq/{i386,x86_64,armv7,armv7s,arm64}/lib/libjq.a
|
||||
|
||||
# Take the arm64 headers- the most common target.
|
||||
cp -r ${cwd}/ios/jq/arm64/include ${cwd}/ios/dest/
|
||||
rm -rf ${cwd}/build/ios/{i386,x86_64,armv7,armv7s,arm64}
|
||||
|
||||
echo "Output to ${cwd}/ios/dest"
|
||||
@@ -1,646 +0,0 @@
|
||||
#define _GNU_SOURCE // for strdup
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "opcode.h"
|
||||
#include "compile.h"
|
||||
#include "bytecode.h"
|
||||
#include "locfile.h"
|
||||
#include "jv_alloc.h"
|
||||
|
||||
/*
|
||||
The intermediate representation for jq filters is as a sequence of
|
||||
struct inst, which form a doubly-linked list via the next and prev
|
||||
pointers.
|
||||
|
||||
A "block" represents a sequence of "struct inst", which may be
|
||||
empty.
|
||||
|
||||
Blocks are generated by the parser bottom-up, so may have free
|
||||
variables (refer to things not defined). See inst.bound_by and
|
||||
inst.symbol.
|
||||
*/
|
||||
struct inst {
|
||||
struct inst* next;
|
||||
struct inst* prev;
|
||||
|
||||
opcode op;
|
||||
|
||||
struct {
|
||||
uint16_t intval;
|
||||
struct inst* target;
|
||||
jv constant;
|
||||
const struct cfunction* cfunc;
|
||||
} imm;
|
||||
|
||||
location source;
|
||||
|
||||
// Binding
|
||||
// An instruction requiring binding (for parameters/variables/functions)
|
||||
// is in one of three states:
|
||||
// inst->bound_by = NULL - Unbound free variable
|
||||
// inst->bound_by = inst - This instruction binds a variable
|
||||
// inst->bound_by = other - Uses variable bound by other instruction
|
||||
// Unbound instructions (references to other things that may or may not
|
||||
// exist) are created by "gen_foo_unbound", and bindings are created by
|
||||
// block_bind(definition, body), which binds all instructions in
|
||||
// body which are unboudn and refer to "definition" by name.
|
||||
struct inst* bound_by;
|
||||
char* symbol;
|
||||
|
||||
block subfn; // used by CLOSURE_CREATE (body of function)
|
||||
block arglist; // used by CLOSURE_CREATE (formals) and CALL_JQ (arguments)
|
||||
|
||||
// This instruction is compiled as part of which function?
|
||||
// (only used during block_compile)
|
||||
struct bytecode* compiled;
|
||||
|
||||
int bytecode_pos; // position just after this insn
|
||||
};
|
||||
|
||||
static inst* inst_new(opcode op) {
|
||||
inst* i = jv_mem_alloc(sizeof(inst));
|
||||
i->next = i->prev = 0;
|
||||
i->op = op;
|
||||
i->bytecode_pos = -1;
|
||||
i->bound_by = 0;
|
||||
i->symbol = 0;
|
||||
i->subfn = gen_noop();
|
||||
i->arglist = gen_noop();
|
||||
i->source = UNKNOWN_LOCATION;
|
||||
return i;
|
||||
}
|
||||
|
||||
static void inst_free(struct inst* i) {
|
||||
jv_mem_free(i->symbol);
|
||||
block_free(i->subfn);
|
||||
block_free(i->arglist);
|
||||
if (opcode_describe(i->op)->flags & OP_HAS_CONSTANT) {
|
||||
jv_free(i->imm.constant);
|
||||
}
|
||||
jv_mem_free(i);
|
||||
}
|
||||
|
||||
static block inst_block(inst* i) {
|
||||
block b = {i,i};
|
||||
return b;
|
||||
}
|
||||
|
||||
static int block_is_single(block b) {
|
||||
return b.first && b.first == b.last;
|
||||
}
|
||||
|
||||
static inst* block_take(block* b) {
|
||||
if (b->first == 0) return 0;
|
||||
inst* i = b->first;
|
||||
if (i->next) {
|
||||
i->next->prev = 0;
|
||||
b->first = i->next;
|
||||
i->next = 0;
|
||||
} else {
|
||||
b->first = 0;
|
||||
b->last = 0;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
block gen_location(location loc, block b) {
|
||||
for (inst* i = b.first; i; i = i->next) {
|
||||
if (i->source.start == UNKNOWN_LOCATION.start &&
|
||||
i->source.end == UNKNOWN_LOCATION.end) {
|
||||
i->source = loc;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
block gen_noop() {
|
||||
block b = {0,0};
|
||||
return b;
|
||||
}
|
||||
|
||||
block gen_op_simple(opcode op) {
|
||||
assert(opcode_describe(op)->length == 1);
|
||||
return inst_block(inst_new(op));
|
||||
}
|
||||
|
||||
|
||||
block gen_const(jv constant) {
|
||||
assert(opcode_describe(LOADK)->flags & OP_HAS_CONSTANT);
|
||||
inst* i = inst_new(LOADK);
|
||||
i->imm.constant = constant;
|
||||
return inst_block(i);
|
||||
}
|
||||
|
||||
block gen_op_target(opcode op, block target) {
|
||||
assert(opcode_describe(op)->flags & OP_HAS_BRANCH);
|
||||
assert(target.last);
|
||||
inst* i = inst_new(op);
|
||||
i->imm.target = target.last;
|
||||
return inst_block(i);
|
||||
}
|
||||
|
||||
block gen_op_targetlater(opcode op) {
|
||||
assert(opcode_describe(op)->flags & OP_HAS_BRANCH);
|
||||
inst* i = inst_new(op);
|
||||
i->imm.target = 0;
|
||||
return inst_block(i);
|
||||
}
|
||||
void inst_set_target(block b, block target) {
|
||||
assert(block_is_single(b));
|
||||
assert(opcode_describe(b.first->op)->flags & OP_HAS_BRANCH);
|
||||
assert(target.last);
|
||||
b.first->imm.target = target.last;
|
||||
}
|
||||
|
||||
block gen_op_var_unbound(opcode op, const char* name) {
|
||||
assert(opcode_describe(op)->flags & OP_HAS_VARIABLE);
|
||||
inst* i = inst_new(op);
|
||||
i->symbol = strdup(name);
|
||||
return inst_block(i);
|
||||
}
|
||||
|
||||
block gen_op_var_bound(opcode op, block binder) {
|
||||
assert(block_is_single(binder));
|
||||
block b = gen_op_var_unbound(op, binder.first->symbol);
|
||||
b.first->bound_by = binder.first;
|
||||
return b;
|
||||
}
|
||||
|
||||
block gen_op_block_unbound(opcode op, const char* name) {
|
||||
assert(opcode_describe(op)->flags & OP_IS_CALL_PSEUDO);
|
||||
inst* i = inst_new(op);
|
||||
i->symbol = strdup(name);
|
||||
return inst_block(i);
|
||||
}
|
||||
|
||||
block gen_op_block_bound(opcode op, block binder) {
|
||||
assert(block_is_single(binder));
|
||||
block b = gen_op_block_unbound(op, binder.first->symbol);
|
||||
b.first->bound_by = binder.first;
|
||||
return b;
|
||||
}
|
||||
|
||||
static void inst_join(inst* a, inst* b) {
|
||||
assert(a && b);
|
||||
assert(!a->next);
|
||||
assert(!b->prev);
|
||||
a->next = b;
|
||||
b->prev = a;
|
||||
}
|
||||
|
||||
void block_append(block* b, block b2) {
|
||||
if (b2.first) {
|
||||
if (b->last) {
|
||||
inst_join(b->last, b2.first);
|
||||
} else {
|
||||
b->first = b2.first;
|
||||
}
|
||||
b->last = b2.last;
|
||||
}
|
||||
}
|
||||
|
||||
block block_join(block a, block b) {
|
||||
block c = a;
|
||||
block_append(&c, b);
|
||||
return c;
|
||||
}
|
||||
|
||||
int block_has_only_binders(block binders, int bindflags) {
|
||||
bindflags |= OP_HAS_BINDING;
|
||||
for (inst* curr = binders.first; curr; curr = curr->next) {
|
||||
if ((opcode_describe(curr->op)->flags & bindflags) != bindflags) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void block_bind_subblock(block binder, block body, int bindflags) {
|
||||
assert(block_is_single(binder));
|
||||
assert((opcode_describe(binder.first->op)->flags & bindflags) == bindflags);
|
||||
assert(binder.first->symbol);
|
||||
assert(binder.first->bound_by == 0 || binder.first->bound_by == binder.first);
|
||||
|
||||
binder.first->bound_by = binder.first;
|
||||
for (inst* i = body.first; i; i = i->next) {
|
||||
int flags = opcode_describe(i->op)->flags;
|
||||
if ((flags & bindflags) == bindflags &&
|
||||
i->bound_by == 0 &&
|
||||
!strcmp(i->symbol, binder.first->symbol)) {
|
||||
// bind this instruction
|
||||
i->bound_by = binder.first;
|
||||
}
|
||||
// binding recurses into closures
|
||||
block_bind_subblock(binder, i->subfn, bindflags);
|
||||
// binding recurses into argument list
|
||||
block_bind_subblock(binder, i->arglist, bindflags);
|
||||
}
|
||||
}
|
||||
|
||||
static void block_bind_each(block binder, block body, int bindflags) {
|
||||
assert(block_has_only_binders(binder, bindflags));
|
||||
bindflags |= OP_HAS_BINDING;
|
||||
for (inst* curr = binder.first; curr; curr = curr->next) {
|
||||
block_bind_subblock(inst_block(curr), body, bindflags);
|
||||
}
|
||||
}
|
||||
|
||||
block block_bind(block binder, block body, int bindflags) {
|
||||
block_bind_each(binder, body, bindflags);
|
||||
return block_join(binder, body);
|
||||
}
|
||||
|
||||
block gen_function(const char* name, block formals, block body) {
|
||||
block_bind_each(formals, body, OP_IS_CALL_PSEUDO);
|
||||
inst* i = inst_new(CLOSURE_CREATE);
|
||||
i->subfn = body;
|
||||
i->symbol = strdup(name);
|
||||
i->arglist = formals;
|
||||
block b = inst_block(i);
|
||||
block_bind_subblock(b, b, OP_IS_CALL_PSEUDO | OP_HAS_BINDING);
|
||||
return b;
|
||||
}
|
||||
|
||||
block gen_lambda(block body) {
|
||||
return gen_function("@lambda", gen_noop(), body);
|
||||
}
|
||||
|
||||
block gen_call(const char* name, block args) {
|
||||
block b = gen_op_block_unbound(CALL_JQ, name);
|
||||
b.first->arglist = args;
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
block gen_subexp(block a) {
|
||||
return BLOCK(gen_op_simple(DUP), a, gen_op_simple(SWAP));
|
||||
}
|
||||
|
||||
block gen_both(block a, block b) {
|
||||
block jump = gen_op_targetlater(JUMP);
|
||||
block fork = gen_op_target(FORK, jump);
|
||||
block c = BLOCK(fork, a, jump, b);
|
||||
inst_set_target(jump, c);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
block gen_collect(block expr) {
|
||||
block array_var = block_bind(gen_op_var_unbound(STOREV, "collect"),
|
||||
gen_noop(), OP_HAS_VARIABLE);
|
||||
block c = BLOCK(gen_op_simple(DUP), gen_const(jv_array()), array_var);
|
||||
|
||||
block tail = BLOCK(gen_op_var_bound(APPEND, array_var),
|
||||
gen_op_simple(BACKTRACK));
|
||||
|
||||
return BLOCK(c,
|
||||
gen_op_target(FORK, tail),
|
||||
expr,
|
||||
tail,
|
||||
gen_op_var_bound(LOADV, array_var));
|
||||
}
|
||||
|
||||
block gen_fold(const char* varname, block init, block fold) {
|
||||
block loop = BLOCK(fold, gen_op_var_unbound(STOREV, varname), gen_op_simple(BACKTRACK));
|
||||
return BLOCK(gen_op_simple(DUP),
|
||||
init,
|
||||
block_bind(gen_op_var_unbound(STOREV, varname),
|
||||
BLOCK(gen_op_target(FORK, loop),
|
||||
loop,
|
||||
gen_op_var_unbound(LOADV, varname)),
|
||||
OP_HAS_VARIABLE));
|
||||
}
|
||||
|
||||
block gen_definedor(block a, block b) {
|
||||
// var found := false
|
||||
block found_var = block_bind(gen_op_var_unbound(STOREV, "found"),
|
||||
gen_noop(), OP_HAS_VARIABLE);
|
||||
block init = BLOCK(gen_op_simple(DUP), gen_const(jv_false()), found_var);
|
||||
|
||||
// if found, backtrack. Otherwise execute b
|
||||
block backtrack = gen_op_simple(BACKTRACK);
|
||||
block tail = BLOCK(gen_op_simple(DUP),
|
||||
gen_op_var_bound(LOADV, found_var),
|
||||
gen_op_target(JUMP_F, backtrack),
|
||||
backtrack,
|
||||
gen_op_simple(POP),
|
||||
b);
|
||||
|
||||
// try again
|
||||
block if_notfound = gen_op_simple(BACKTRACK);
|
||||
|
||||
// found := true, produce result
|
||||
block if_found = BLOCK(gen_op_simple(DUP),
|
||||
gen_const(jv_true()),
|
||||
gen_op_var_bound(STOREV, found_var),
|
||||
gen_op_target(JUMP, tail));
|
||||
|
||||
return BLOCK(init,
|
||||
gen_op_target(FORK, if_notfound),
|
||||
a,
|
||||
gen_op_target(JUMP_F, if_found),
|
||||
if_found,
|
||||
if_notfound,
|
||||
tail);
|
||||
}
|
||||
|
||||
block gen_condbranch(block iftrue, block iffalse) {
|
||||
iftrue = BLOCK(iftrue, gen_op_target(JUMP, iffalse));
|
||||
return BLOCK(gen_op_target(JUMP_F, iftrue), iftrue, iffalse);
|
||||
}
|
||||
|
||||
block gen_and(block a, block b) {
|
||||
// a and b = if a then (if b then true else false) else false
|
||||
return BLOCK(gen_op_simple(DUP), a,
|
||||
gen_condbranch(BLOCK(gen_op_simple(POP),
|
||||
b,
|
||||
gen_condbranch(gen_const(jv_true()),
|
||||
gen_const(jv_false()))),
|
||||
BLOCK(gen_op_simple(POP), gen_const(jv_false()))));
|
||||
}
|
||||
|
||||
block gen_or(block a, block b) {
|
||||
// a or b = if a then true else (if b then true else false)
|
||||
return BLOCK(gen_op_simple(DUP), a,
|
||||
gen_condbranch(BLOCK(gen_op_simple(POP), gen_const(jv_true())),
|
||||
BLOCK(gen_op_simple(POP),
|
||||
b,
|
||||
gen_condbranch(gen_const(jv_true()),
|
||||
gen_const(jv_false())))));
|
||||
}
|
||||
|
||||
block gen_var_binding(block var, const char* name, block body) {
|
||||
return BLOCK(gen_op_simple(DUP), var,
|
||||
block_bind(gen_op_var_unbound(STOREV, name),
|
||||
body, OP_HAS_VARIABLE));
|
||||
}
|
||||
|
||||
block gen_cond(block cond, block iftrue, block iffalse) {
|
||||
return BLOCK(gen_op_simple(DUP), cond,
|
||||
gen_condbranch(BLOCK(gen_op_simple(POP), iftrue),
|
||||
BLOCK(gen_op_simple(POP), iffalse)));
|
||||
}
|
||||
|
||||
block gen_cbinding(const struct cfunction* cfunctions, int ncfunctions, block code) {
|
||||
for (int cfunc=0; cfunc<ncfunctions; cfunc++) {
|
||||
inst* i = inst_new(CLOSURE_CREATE_C);
|
||||
i->imm.cfunc = &cfunctions[cfunc];
|
||||
i->symbol = strdup(i->imm.cfunc->name);
|
||||
code = block_bind(inst_block(i), code, OP_IS_CALL_PSEUDO);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static uint16_t nesting_level(struct bytecode* bc, inst* target) {
|
||||
uint16_t level = 0;
|
||||
assert(bc && target->compiled);
|
||||
while (bc && target->compiled != bc) {
|
||||
level++;
|
||||
bc = bc->parent;
|
||||
}
|
||||
assert(bc && bc == target->compiled);
|
||||
return level;
|
||||
}
|
||||
|
||||
static int count_cfunctions(block b) {
|
||||
int n = 0;
|
||||
for (inst* i = b.first; i; i = i->next) {
|
||||
if (i->op == CLOSURE_CREATE_C) n++;
|
||||
n += count_cfunctions(i->subfn);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
// Expands call instructions into a calling sequence
|
||||
static int expand_call_arglist(struct locfile* locations, block* b) {
|
||||
int errors = 0;
|
||||
block ret = gen_noop();
|
||||
for (inst* curr; (curr = block_take(b));) {
|
||||
if (opcode_describe(curr->op)->flags & OP_HAS_BINDING) {
|
||||
if (!curr->bound_by) {
|
||||
locfile_locate(locations, curr->source, "error: %s is not defined", curr->symbol);
|
||||
errors++;
|
||||
// don't process this instruction if it's not well-defined
|
||||
ret = BLOCK(ret, inst_block(curr));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
block prelude = gen_noop();
|
||||
if (curr->op == CALL_JQ) {
|
||||
int actual_args = 0, desired_args = 0;
|
||||
// We expand the argument list as a series of instructions
|
||||
switch (curr->bound_by->op) {
|
||||
default: assert(0 && "Unknown function type"); break;
|
||||
case CLOSURE_CREATE:
|
||||
case CLOSURE_PARAM: {
|
||||
block callargs = gen_noop();
|
||||
for (inst* i; (i = block_take(&curr->arglist));) {
|
||||
assert(opcode_describe(i->op)->flags & OP_IS_CALL_PSEUDO);
|
||||
block b = inst_block(i);
|
||||
switch (i->op) {
|
||||
default: assert(0 && "Unknown type of parameter"); break;
|
||||
case CLOSURE_REF:
|
||||
block_append(&callargs, b);
|
||||
break;
|
||||
case CLOSURE_CREATE:
|
||||
block_append(&prelude, b);
|
||||
block_append(&callargs, gen_op_block_bound(CLOSURE_REF, b));
|
||||
break;
|
||||
}
|
||||
actual_args++;
|
||||
}
|
||||
curr->imm.intval = actual_args;
|
||||
curr->arglist = callargs;
|
||||
|
||||
if (curr->bound_by->op == CLOSURE_CREATE) {
|
||||
for (inst* i = curr->bound_by->arglist.first; i; i = i->next) {
|
||||
assert(i->op == CLOSURE_PARAM);
|
||||
desired_args++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CLOSURE_CREATE_C: {
|
||||
for (inst* i; (i = block_take(&curr->arglist)); ) {
|
||||
assert(i->op == CLOSURE_CREATE); // FIXME
|
||||
block body = i->subfn;
|
||||
i->subfn = gen_noop();
|
||||
inst_free(i);
|
||||
// arguments should be pushed in reverse order, prepend them to prelude
|
||||
errors += expand_call_arglist(locations, &body);
|
||||
prelude = BLOCK(gen_subexp(body), prelude);
|
||||
actual_args++;
|
||||
}
|
||||
assert(curr->op == CALL_JQ);
|
||||
curr->op = CALL_BUILTIN;
|
||||
curr->imm.intval = actual_args + 1 /* include the implicit input in arg count */;
|
||||
assert(curr->bound_by->op == CLOSURE_CREATE_C);
|
||||
desired_args = curr->bound_by->imm.cfunc->nargs - 1;
|
||||
assert(!curr->arglist.first);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (actual_args != desired_args) {
|
||||
locfile_locate(locations, curr->source,
|
||||
"error: %s arguments to %s (expected %d but got %d)",
|
||||
actual_args > desired_args ? "too many" : "too few",
|
||||
curr->symbol, desired_args, actual_args);
|
||||
errors++;
|
||||
}
|
||||
|
||||
}
|
||||
ret = BLOCK(ret, prelude, inst_block(curr));
|
||||
}
|
||||
*b = ret;
|
||||
return errors;
|
||||
}
|
||||
|
||||
static int compile(struct locfile* locations, struct bytecode* bc, block b) {
|
||||
int errors = 0;
|
||||
int pos = 0;
|
||||
int var_frame_idx = 0;
|
||||
bc->nsubfunctions = 0;
|
||||
errors += expand_call_arglist(locations, &b);
|
||||
if (bc->parent) {
|
||||
// functions should end in a return
|
||||
b = BLOCK(b, gen_op_simple(RET));
|
||||
} else {
|
||||
// the toplevel should YIELD;BACKTRACK; when it finds an answer
|
||||
b = BLOCK(b, gen_op_simple(YIELD), gen_op_simple(BACKTRACK));
|
||||
}
|
||||
for (inst* curr = b.first; curr; curr = curr->next) {
|
||||
if (!curr->next) assert(curr == b.last);
|
||||
int length = opcode_describe(curr->op)->length;
|
||||
if (curr->op == CALL_JQ) {
|
||||
for (inst* arg = curr->arglist.first; arg; arg = arg->next) {
|
||||
length += 2;
|
||||
}
|
||||
}
|
||||
pos += length;
|
||||
curr->bytecode_pos = pos;
|
||||
curr->compiled = bc;
|
||||
|
||||
assert(curr->op != CLOSURE_REF && curr->op != CLOSURE_PARAM);
|
||||
|
||||
if ((opcode_describe(curr->op)->flags & OP_HAS_VARIABLE) &&
|
||||
curr->bound_by == curr) {
|
||||
curr->imm.intval = var_frame_idx++;
|
||||
}
|
||||
|
||||
if (curr->op == CLOSURE_CREATE) {
|
||||
assert(curr->bound_by == curr);
|
||||
curr->imm.intval = bc->nsubfunctions++;
|
||||
}
|
||||
if (curr->op == CLOSURE_CREATE_C) {
|
||||
assert(curr->bound_by == curr);
|
||||
int idx = bc->globals->ncfunctions++;
|
||||
bc->globals->cfunctions[idx] = *curr->imm.cfunc;
|
||||
curr->imm.intval = idx;
|
||||
}
|
||||
}
|
||||
if (bc->nsubfunctions) {
|
||||
bc->subfunctions = jv_mem_alloc(sizeof(struct bytecode*) * bc->nsubfunctions);
|
||||
for (inst* curr = b.first; curr; curr = curr->next) {
|
||||
if (curr->op == CLOSURE_CREATE) {
|
||||
struct bytecode* subfn = jv_mem_alloc(sizeof(struct bytecode));
|
||||
bc->subfunctions[curr->imm.intval] = subfn;
|
||||
subfn->globals = bc->globals;
|
||||
subfn->parent = bc;
|
||||
subfn->nclosures = 0;
|
||||
for (inst* param = curr->arglist.first; param; param = param->next) {
|
||||
assert(param->op == CLOSURE_PARAM);
|
||||
assert(param->bound_by == param);
|
||||
param->imm.intval = subfn->nclosures++;
|
||||
param->compiled = subfn;
|
||||
}
|
||||
errors += compile(locations, subfn, curr->subfn);
|
||||
curr->subfn = gen_noop();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bc->subfunctions = 0;
|
||||
}
|
||||
bc->codelen = pos;
|
||||
uint16_t* code = jv_mem_alloc(sizeof(uint16_t) * bc->codelen);
|
||||
bc->code = code;
|
||||
pos = 0;
|
||||
jv constant_pool = jv_array();
|
||||
int maxvar = -1;
|
||||
if (!errors) for (inst* curr = b.first; curr; curr = curr->next) {
|
||||
const struct opcode_description* op = opcode_describe(curr->op);
|
||||
if (op->length == 0)
|
||||
continue;
|
||||
code[pos++] = curr->op;
|
||||
assert(curr->op != CLOSURE_REF && curr->op != CLOSURE_PARAM);
|
||||
if (curr->op == CALL_BUILTIN) {
|
||||
assert(curr->bound_by->op == CLOSURE_CREATE_C);
|
||||
assert(!curr->arglist.first);
|
||||
code[pos++] = (uint16_t)curr->imm.intval;
|
||||
code[pos++] = curr->bound_by->imm.intval;
|
||||
} else if (curr->op == CALL_JQ) {
|
||||
assert(curr->bound_by->op == CLOSURE_CREATE ||
|
||||
curr->bound_by->op == CLOSURE_PARAM);
|
||||
code[pos++] = (uint16_t)curr->imm.intval;
|
||||
code[pos++] = nesting_level(bc, curr->bound_by);
|
||||
code[pos++] = curr->bound_by->imm.intval |
|
||||
(curr->bound_by->op == CLOSURE_CREATE ? ARG_NEWCLOSURE : 0);
|
||||
for (inst* arg = curr->arglist.first; arg; arg = arg->next) {
|
||||
assert(arg->op == CLOSURE_REF && arg->bound_by->op == CLOSURE_CREATE);
|
||||
code[pos++] = nesting_level(bc, arg->bound_by);
|
||||
code[pos++] = arg->bound_by->imm.intval | ARG_NEWCLOSURE;
|
||||
}
|
||||
} else if (op->flags & OP_HAS_CONSTANT) {
|
||||
code[pos++] = jv_array_length(jv_copy(constant_pool));
|
||||
constant_pool = jv_array_append(constant_pool, jv_copy(curr->imm.constant));
|
||||
} else if (op->flags & OP_HAS_VARIABLE) {
|
||||
code[pos++] = nesting_level(bc, curr->bound_by);
|
||||
uint16_t var = (uint16_t)curr->bound_by->imm.intval;
|
||||
code[pos++] = var;
|
||||
if (var > maxvar) maxvar = var;
|
||||
} else if (op->flags & OP_HAS_BRANCH) {
|
||||
assert(curr->imm.target->bytecode_pos != -1);
|
||||
assert(curr->imm.target->bytecode_pos > pos); // only forward branches
|
||||
code[pos] = curr->imm.target->bytecode_pos - (pos + 1);
|
||||
pos++;
|
||||
} else if (op->length > 1) {
|
||||
assert(0 && "codegen not implemented for this operation");
|
||||
}
|
||||
}
|
||||
bc->constants = constant_pool;
|
||||
bc->nlocals = maxvar + 2; // FIXME: frames of size zero?
|
||||
block_free(b);
|
||||
return errors;
|
||||
}
|
||||
|
||||
int block_compile(block b, struct locfile* locations, struct bytecode** out) {
|
||||
struct bytecode* bc = jv_mem_alloc(sizeof(struct bytecode));
|
||||
bc->parent = 0;
|
||||
bc->nclosures = 0;
|
||||
bc->globals = jv_mem_alloc(sizeof(struct symbol_table));
|
||||
int ncfunc = count_cfunctions(b);
|
||||
bc->globals->ncfunctions = 0;
|
||||
bc->globals->cfunctions = jv_mem_alloc(sizeof(struct cfunction) * ncfunc);
|
||||
int nerrors = compile(locations, bc, b);
|
||||
assert(bc->globals->ncfunctions == ncfunc);
|
||||
if (nerrors > 0) {
|
||||
bytecode_free(bc);
|
||||
*out = 0;
|
||||
} else {
|
||||
*out = bc;
|
||||
}
|
||||
return nerrors;
|
||||
}
|
||||
|
||||
void block_free(block b) {
|
||||
struct inst* next;
|
||||
for (struct inst* curr = b.first; curr; curr = next) {
|
||||
next = curr->next;
|
||||
inst_free(curr);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
#ifndef COMPILE_H
|
||||
#define COMPILE_H
|
||||
#include <stdint.h>
|
||||
#include "jv.h"
|
||||
#include "opcode.h"
|
||||
#include "locfile.h"
|
||||
|
||||
struct bytecode;
|
||||
struct symbol_table;
|
||||
struct cfunction;
|
||||
|
||||
struct inst;
|
||||
typedef struct inst inst;
|
||||
|
||||
|
||||
typedef struct block {
|
||||
inst* first;
|
||||
inst* last;
|
||||
} block;
|
||||
|
||||
block gen_location(location, block);
|
||||
|
||||
block gen_noop();
|
||||
block gen_op_simple(opcode op);
|
||||
block gen_const(jv constant);
|
||||
block gen_op_target(opcode op, block target);
|
||||
block gen_op_var_unbound(opcode op, const char* name);
|
||||
block gen_op_var_bound(opcode op, block binder);
|
||||
block gen_op_block_unbound(opcode op, const char* name);
|
||||
|
||||
block gen_function(const char* name, block formals, block body);
|
||||
block gen_lambda(block body);
|
||||
block gen_call(const char* name, block body);
|
||||
block gen_subexp(block a);
|
||||
block gen_both(block a, block b);
|
||||
block gen_collect(block expr);
|
||||
block gen_fold(const char* varname, block init, block body);
|
||||
block gen_definedor(block a, block b);
|
||||
block gen_condbranch(block iftrue, block iffalse);
|
||||
block gen_and(block a, block b);
|
||||
block gen_or(block a, block b);
|
||||
|
||||
block gen_var_binding(block var, const char* name, block body);
|
||||
|
||||
block gen_cond(block cond, block iftrue, block iffalse);
|
||||
|
||||
block gen_cbinding(const struct cfunction* functions, int nfunctions, block b);
|
||||
|
||||
void block_append(block* b, block b2);
|
||||
block block_join(block a, block b);
|
||||
int block_has_only_binders(block, int bindflags);
|
||||
block block_bind(block binder, block body, int bindflags);
|
||||
|
||||
int block_compile(block, struct locfile*, struct bytecode**);
|
||||
|
||||
void block_free(block);
|
||||
|
||||
|
||||
|
||||
// Here's some horrible preprocessor gunk so that code
|
||||
// sequences can be contructed as BLOCK(block1, block2, block3)
|
||||
|
||||
#define BLOCK_1(b1) (b1)
|
||||
#define BLOCK_2(b1,b2) (block_join((b1),(b2)))
|
||||
#define BLOCK_3(b1,b2,b3) (block_join(BLOCK_2(b1,b2),(b3)))
|
||||
#define BLOCK_4(b1,b2,b3,b4) (block_join(BLOCK_3(b1,b2,b3),(b4)))
|
||||
#define BLOCK_5(b1,b2,b3,b4,b5) (block_join(BLOCK_4(b1,b2,b3,b4),(b5)))
|
||||
#define BLOCK_6(b1,b2,b3,b4,b5,b6) (block_join(BLOCK_5(b1,b2,b3,b4,b5),(b6)))
|
||||
#define BLOCK_7(b1,b2,b3,b4,b5,b6,b7) (block_join(BLOCK_6(b1,b2,b3,b4,b5,b6),(b7)))
|
||||
|
||||
#define BLOCK_IDX(_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME
|
||||
#define BLOCK(...) \
|
||||
BLOCK_IDX(__VA_ARGS__, BLOCK_7, BLOCK_6, BLOCK_5, BLOCK_4, BLOCK_3, BLOCK_2, BLOCK_1)(__VA_ARGS__)
|
||||
|
||||
|
||||
#endif
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
#undef NO_MINUS_C_MINUS_O
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||
`char[]'. */
|
||||
#undef YYTEXT_POINTER
|
||||
@@ -0,0 +1,10 @@
|
||||
config.guess
|
||||
config.sub
|
||||
compile
|
||||
depcomp
|
||||
install-sh
|
||||
ltmain.sh
|
||||
missing
|
||||
ylwrap
|
||||
test-driver
|
||||
ar-lib
|
||||
-343
@@ -1,343 +0,0 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-03-05.13; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free
|
||||
# Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
-708
@@ -1,708 +0,0 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2012-03-27.16; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
|
||||
# 2011, 2012 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by 'PROGRAMS ARGS'.
|
||||
object Object file output by 'PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
# A tabulation character.
|
||||
tab=' '
|
||||
# A newline character.
|
||||
nl='
|
||||
'
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
if test "$depmode" = msvc7msys; then
|
||||
# This is just like msvc7 but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvc7
|
||||
fi
|
||||
|
||||
if test "$depmode" = xlc; then
|
||||
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
|
||||
gccflag=-qmakedep=gcc,-MF
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the "deleted header file" problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' "$nl" < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the ':'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well. hp depmode also adds that space, but also prefixes the VPATH
|
||||
## to the object. Take care to not repeat it in the output.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like '#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr "$nl" ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
xlc)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts '$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form 'foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# '$object: dependent.h' and one to simply 'dependent.h:'.
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
|
||||
# However on
|
||||
# $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using '\':
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
# tcc 0.9.26 (FIXME still under development at the moment of writing)
|
||||
# will emit a similar output, but also prepend the continuation lines
|
||||
# with horizontal tabulation characters.
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form 'foo.o: dependent.h',
|
||||
# or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# '$object: dependent.h' and one to simply 'dependent.h:'.
|
||||
sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
|
||||
< "$tmpdepfile" > "$depfile"
|
||||
sed '
|
||||
s/[ '"$tab"'][ '"$tab"']*/ /g
|
||||
s/^ *//
|
||||
s/ *\\*$//
|
||||
s/^[^:]*: *//
|
||||
/^$/d
|
||||
/:$/d
|
||||
s/$/ :/
|
||||
' < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add 'dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in 'foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7)
|
||||
if test "$libtool" = yes; then
|
||||
showIncludes=-Wc,-showIncludes
|
||||
else
|
||||
showIncludes=-showIncludes
|
||||
fi
|
||||
"$@" $showIncludes > "$tmpdepfile"
|
||||
stat=$?
|
||||
grep -v '^Note: including file: ' "$tmpdepfile"
|
||||
if test "$stat" = 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The first sed program below extracts the file names and escapes
|
||||
# backslashes for cygpath. The second sed program outputs the file
|
||||
# name when reading, but also accumulates all include files in the
|
||||
# hold buffer in order to output them again at the end. This only
|
||||
# works with sed implementations that can handle large buffers.
|
||||
sed < "$tmpdepfile" -n '
|
||||
/^Note: including file: *\(.*\)/ {
|
||||
s//\1/
|
||||
s/\\/\\\\/g
|
||||
p
|
||||
}' | $cygpath_u | sort -u | sed -n '
|
||||
s/ /\\ /g
|
||||
s/\(.*\)/'"$tab"'\1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/'"$tab"'/
|
||||
G
|
||||
p
|
||||
}' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7msys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for ':'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' "$nl" < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
# makedepend may prepend the VPATH from the source file name to the object.
|
||||
# No need to regex-escape $object, excess matching of '.' is harmless.
|
||||
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
|
||||
echo "$tab" >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
@@ -1,527 +0,0 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2011-01-19.21; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
# Protect names problematic for `test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for `test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names problematic for `test' and other utilities.
|
||||
case $src in
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
@@ -0,0 +1,2 @@
|
||||
libtool.m4
|
||||
lt*.m4
|
||||
@@ -0,0 +1,9 @@
|
||||
dnl AC_CHECK_MATH_FUNC(func)
|
||||
AC_DEFUN([AC_CHECK_MATH_FUNC], [
|
||||
AC_LANG(C)
|
||||
AC_CHECK_LIB([m],[$1],[
|
||||
eval "ac_tr_func=HAVE_[]upcase($1)"
|
||||
AC_DEFINE_UNQUOTED($ac_tr_func)
|
||||
],[
|
||||
])
|
||||
])
|
||||
@@ -0,0 +1,8 @@
|
||||
dnl Shamelessly stolen from Heimdal
|
||||
dnl
|
||||
dnl Look for function in any of the specified libraries
|
||||
dnl
|
||||
|
||||
dnl AC_FIND_FUNC_NO_LIBS(func, libraries, includes, arguments, extra libs, extra args)
|
||||
AC_DEFUN([AC_FIND_FUNC_NO_LIBS], [
|
||||
AC_FIND_FUNC_NO_LIBS2([$1], ["" $2], [$3], [$4], [$5], [$6])])
|
||||
@@ -0,0 +1,62 @@
|
||||
dnl Shamelessly stolen from Heimdal
|
||||
dnl
|
||||
dnl Look for function in any of the specified libraries
|
||||
dnl
|
||||
|
||||
dnl AC_FIND_FUNC_NO_LIBS2(func, libraries, includes, arguments, extra libs, extra args)
|
||||
AC_DEFUN([AC_FIND_FUNC_NO_LIBS2], [
|
||||
|
||||
AC_MSG_CHECKING([for $1])
|
||||
AC_CACHE_VAL(ac_cv_funclib_$1,
|
||||
[
|
||||
if eval "test \"\$ac_cv_func_$1\" != yes" ; then
|
||||
ac_save_LIBS="$LIBS"
|
||||
for ac_lib in $2; do
|
||||
case "$ac_lib" in
|
||||
"") ;;
|
||||
yes) ac_lib="" ;;
|
||||
no) continue ;;
|
||||
-l*) ;;
|
||||
*) ac_lib="-l$ac_lib" ;;
|
||||
esac
|
||||
LIBS="$6 $ac_lib $5 $ac_save_LIBS"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[$3]],[[$1($4)]])],[eval "if test -n \"$ac_lib\";then ac_cv_funclib_$1=$ac_lib; else ac_cv_funclib_$1=yes; fi";break])
|
||||
done
|
||||
eval "ac_cv_funclib_$1=\${ac_cv_funclib_$1-no}"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
])
|
||||
|
||||
eval "ac_res=\$ac_cv_funclib_$1"
|
||||
|
||||
if false; then
|
||||
AC_CHECK_FUNCS($1)
|
||||
dnl AC_CHECK_LIBS($2, foo)
|
||||
fi
|
||||
# $1
|
||||
eval "ac_tr_func=HAVE_[]upcase($1)"
|
||||
eval "ac_tr_lib=HAVE_LIB[]upcase($ac_res | sed -e 's/-l//')"
|
||||
eval "LIB_$1=$ac_res"
|
||||
|
||||
case "$ac_res" in
|
||||
yes)
|
||||
eval "ac_cv_func_$1=yes"
|
||||
eval "LIB_$1="
|
||||
AC_DEFINE_UNQUOTED($ac_tr_func)
|
||||
AC_MSG_RESULT([yes])
|
||||
;;
|
||||
no)
|
||||
eval "ac_cv_func_$1=no"
|
||||
eval "LIB_$1="
|
||||
AC_MSG_RESULT([no])
|
||||
;;
|
||||
*)
|
||||
eval "ac_cv_func_$1=yes"
|
||||
eval "ac_cv_lib_`echo "$ac_res" | sed 's/-l//'`=yes"
|
||||
AC_DEFINE_UNQUOTED($ac_tr_func)
|
||||
AC_DEFINE_UNQUOTED($ac_tr_lib)
|
||||
AC_MSG_RESULT([yes, in $ac_res])
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(LIB_$1)
|
||||
])
|
||||
@@ -0,0 +1,9 @@
|
||||
dnl Shamelessly stolen from Heimdal
|
||||
dnl
|
||||
dnl AC_FIND_FUNC(func, libraries, includes, arguments)
|
||||
AC_DEFUN([AC_FIND_FUNC], [
|
||||
AC_FIND_FUNC_NO_LIBS([$1], [$2], [$3], [$4])
|
||||
if test -n "$LIB_$1"; then
|
||||
LIBS="$LIB_$1 $LIBS"
|
||||
fi
|
||||
])
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
dnl Shamelessly stolen from Heimdal
|
||||
AC_DEFUN([upcase],[`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`])dnl
|
||||
-331
@@ -1,331 +0,0 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2012-01-06.13; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
|
||||
# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run=:
|
||||
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
|
||||
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
|
||||
|
||||
# In the cases where this matters, `missing' is being run in the
|
||||
# srcdir already.
|
||||
if test -f configure.ac; then
|
||||
configure_ac=configure.ac
|
||||
else
|
||||
configure_ac=configure.in
|
||||
fi
|
||||
|
||||
msg="missing on your system"
|
||||
|
||||
case $1 in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
# Exit code 63 means version mismatch. This often happens
|
||||
# when the user try to use an ancient version of a tool on
|
||||
# a file that requires a minimum version. In this case we
|
||||
# we should proceed has if the program had been absent, or
|
||||
# if --run hadn't been passed.
|
||||
if test $? = 63; then
|
||||
run=:
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--run try to run the given command, and emulate it if it fails
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
autom4te touch the output file, or create a stub one
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
help2man touch the output file
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
|
||||
\`g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# normalize program name to check for.
|
||||
program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program). This is about non-GNU programs, so use $1 not
|
||||
# $program.
|
||||
case $1 in
|
||||
lex*|yacc*)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
# Could not run --version or --help. This is probably someone
|
||||
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case $program in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case $f in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them.
|
||||
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo "#! /bin/sh"
|
||||
echo "# Created by GNU Automake missing as a replacement of"
|
||||
echo "# $ $@"
|
||||
echo "exit 0"
|
||||
chmod +x $file
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
bison*|yacc*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' $msg. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG=\${$#}
|
||||
case $LASTARG in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f y.tab.h; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if test ! -f y.tab.c; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex*|flex*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG=\${$#}
|
||||
case $LASTARG in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f lex.yy.c; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
\`Help2man' package in order for those modifications to take
|
||||
effect. You can get \`Help2man' from any GNU archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit $?
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
# The file to touch is that specified with -o ...
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -z "$file"; then
|
||||
# ... or it is the one specified with @setfilename ...
|
||||
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '
|
||||
/^@setfilename/{
|
||||
s/.* \([^ ]*\) *$/\1/
|
||||
p
|
||||
q
|
||||
}' $infile`
|
||||
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||
fi
|
||||
# If the file does not exist, the user really needs makeinfo;
|
||||
# let's fail without touching anything.
|
||||
test -f $file || exit 1
|
||||
touch $file
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequisites for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
-226
@@ -1,226 +0,0 @@
|
||||
#! /bin/sh
|
||||
# ylwrap - wrapper for lex/yacc invocations.
|
||||
|
||||
scriptversion=2011-08-25.18; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
|
||||
# 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
case "$1" in
|
||||
'')
|
||||
echo "$0: No files given. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1
|
||||
;;
|
||||
--basedir)
|
||||
basedir=$2
|
||||
shift 2
|
||||
;;
|
||||
-h|--h*)
|
||||
cat <<\EOF
|
||||
Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
|
||||
|
||||
Wrapper for lex/yacc invocations, renaming files as desired.
|
||||
|
||||
INPUT is the input file
|
||||
OUTPUT is one file PROG generates
|
||||
DESIRED is the file we actually want instead of OUTPUT
|
||||
PROGRAM is program to run
|
||||
ARGS are passed to PROG
|
||||
|
||||
Any number of OUTPUT,DESIRED pairs may be used.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v|--v*)
|
||||
echo "ylwrap $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# The input.
|
||||
input="$1"
|
||||
shift
|
||||
case "$input" in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
# Absolute path; do nothing.
|
||||
;;
|
||||
*)
|
||||
# Relative path. Make it absolute.
|
||||
input="`pwd`/$input"
|
||||
;;
|
||||
esac
|
||||
|
||||
pairlist=
|
||||
while test "$#" -ne 0; do
|
||||
if test "$1" = "--"; then
|
||||
shift
|
||||
break
|
||||
fi
|
||||
pairlist="$pairlist $1"
|
||||
shift
|
||||
done
|
||||
|
||||
# The program to run.
|
||||
prog="$1"
|
||||
shift
|
||||
# Make any relative path in $prog absolute.
|
||||
case "$prog" in
|
||||
[\\/]* | ?:[\\/]*) ;;
|
||||
*[\\/]*) prog="`pwd`/$prog" ;;
|
||||
esac
|
||||
|
||||
# FIXME: add hostname here for parallel makes that run commands on
|
||||
# other machines. But that might take us over the 14-char limit.
|
||||
dirname=ylwrap$$
|
||||
do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
mkdir $dirname || exit 1
|
||||
|
||||
cd $dirname
|
||||
|
||||
case $# in
|
||||
0) "$prog" "$input" ;;
|
||||
*) "$prog" "$@" "$input" ;;
|
||||
esac
|
||||
ret=$?
|
||||
|
||||
if test $ret -eq 0; then
|
||||
set X $pairlist
|
||||
shift
|
||||
first=yes
|
||||
# Since DOS filename conventions don't allow two dots,
|
||||
# the DOS version of Bison writes out y_tab.c instead of y.tab.c
|
||||
# and y_tab.h instead of y.tab.h. Test to see if this is the case.
|
||||
y_tab_nodot="no"
|
||||
if test -f y_tab.c || test -f y_tab.h; then
|
||||
y_tab_nodot="yes"
|
||||
fi
|
||||
|
||||
# The directory holding the input.
|
||||
input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
|
||||
# Quote $INPUT_DIR so we can use it in a regexp.
|
||||
# FIXME: really we should care about more than `.' and `\'.
|
||||
input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
|
||||
|
||||
while test "$#" -ne 0; do
|
||||
from="$1"
|
||||
# Handle y_tab.c and y_tab.h output by DOS
|
||||
if test $y_tab_nodot = "yes"; then
|
||||
if test $from = "y.tab.c"; then
|
||||
from="y_tab.c"
|
||||
else
|
||||
if test $from = "y.tab.h"; then
|
||||
from="y_tab.h"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test -f "$from"; then
|
||||
# If $2 is an absolute path name, then just use that,
|
||||
# otherwise prepend `../'.
|
||||
case "$2" in
|
||||
[\\/]* | ?:[\\/]*) target="$2";;
|
||||
*) target="../$2";;
|
||||
esac
|
||||
|
||||
# We do not want to overwrite a header file if it hasn't
|
||||
# changed. This avoid useless recompilations. However the
|
||||
# parser itself (the first file) should always be updated,
|
||||
# because it is the destination of the .y.c rule in the
|
||||
# Makefile. Divert the output of all other files to a temporary
|
||||
# file so we can compare them to existing versions.
|
||||
if test $first = no; then
|
||||
realtarget="$target"
|
||||
target="tmp-`echo $target | sed s/.*[\\/]//g`"
|
||||
fi
|
||||
# Edit out `#line' or `#' directives.
|
||||
#
|
||||
# We don't want the resulting debug information to point at
|
||||
# an absolute srcdir; it is better for it to just mention the
|
||||
# .y file with no path.
|
||||
#
|
||||
# We want to use the real output file name, not yy.lex.c for
|
||||
# instance.
|
||||
#
|
||||
# We want the include guards to be adjusted too.
|
||||
FROM=`echo "$from" | sed \
|
||||
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
|
||||
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
|
||||
TARGET=`echo "$2" | sed \
|
||||
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
|
||||
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
|
||||
|
||||
sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
|
||||
-e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
|
||||
|
||||
# Check whether header files must be updated.
|
||||
if test $first = no; then
|
||||
if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
|
||||
echo "$2" is unchanged
|
||||
rm -f "$target"
|
||||
else
|
||||
echo updating "$2"
|
||||
mv -f "$target" "$realtarget"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# A missing file is only an error for the first file. This
|
||||
# is a blatant hack to let us support using "yacc -d". If -d
|
||||
# is not specified, we don't want an error when the header
|
||||
# file is "missing".
|
||||
if test $first = yes; then
|
||||
ret=1
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
shift
|
||||
first=no
|
||||
done
|
||||
else
|
||||
ret=$?
|
||||
fi
|
||||
|
||||
# Remove the directory.
|
||||
cd ..
|
||||
rm -rf $dirname
|
||||
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
+260
-29
@@ -1,66 +1,297 @@
|
||||
AC_INIT([jq], [1.2], [mu@netsoc.tcd.ie],
|
||||
[jq], [http://stedolan.github.com/jq/])
|
||||
m4_define([jq_version], m4_esyscmd_s([scripts/version])))
|
||||
|
||||
AC_INIT([jq], [jq_version], [https://github.com/jqlang/jq/issues],
|
||||
[jq], [https://jqlang.github.io/jq])
|
||||
|
||||
dnl Created autoconf implementation thompson@dtosolutions, 26NOV12
|
||||
AC_PREREQ([2.61])
|
||||
AC_PREREQ([2.64])
|
||||
AC_CONFIG_AUX_DIR([config])
|
||||
AM_INIT_AUTOMAKE([parallel-tests foreign])
|
||||
AM_INIT_AUTOMAKE([1.11.2 subdir-objects parallel-tests foreign -Wall])
|
||||
AM_SILENT_RULES([yes])
|
||||
AM_PROG_AR
|
||||
AM_MAINTAINER_MODE([enable])
|
||||
AC_PROG_CC
|
||||
AC_PROG_CC_STDC
|
||||
AC_PROG_CPP_WERROR
|
||||
AC_PROG_YACC
|
||||
|
||||
AC_OBJEXT
|
||||
AC_EXEEXT
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
LT_INIT([shared static win32-dll])
|
||||
AM_PROG_CC_C_O
|
||||
|
||||
AC_SYS_LARGEFILE # issue 2167
|
||||
|
||||
dnl couldn't use AM_PROG_LEX as it doesn't support header files like the
|
||||
dnl AC_PROG_YACC macros...
|
||||
|
||||
dnl
|
||||
dnl these program checks should probably be deleted
|
||||
dnl
|
||||
dnl check bison version
|
||||
|
||||
AC_PROG_LEX
|
||||
if test "x$LEX" != xflex; then
|
||||
LEX="$SHELL $missing_dir/missing flex"
|
||||
if test "$USE_MAINTAINER_MODE" = yes; then
|
||||
if test "$YACC" != "bison -y"; then
|
||||
AC_MSG_CHECKING([bison version])
|
||||
AC_MSG_RESULT([not bison])
|
||||
else
|
||||
AX_PROG_BISON_VERSION([3],
|
||||
[],
|
||||
[AC_MSG_ERROR([You need bison version 3.0 or greater, or use --disable-maintainer-mode.])])
|
||||
fi
|
||||
|
||||
AC_CHECK_PROGS(LEX, flex lex)
|
||||
fi
|
||||
|
||||
|
||||
dnl Check for valgrind
|
||||
AC_CHECK_PROGS(valgrind_cmd, valgrind)
|
||||
if test "x$valgrind_cmd" = "x" ; then
|
||||
AC_MSG_WARN([valgrind is required to test jq.])
|
||||
fi
|
||||
AC_CHECK_FUNCS(memmem)
|
||||
AC_CHECK_FUNCS(mkstemp)
|
||||
|
||||
AC_CHECK_HEADER("sys/cygwin.h", [have_cygwin=1;])
|
||||
AC_CHECK_HEADER("shlwapi.h",[have_shlwapi=1;])
|
||||
AM_CONDITIONAL([WIN32], [test \( "x$have_shlwapi" = x1 \) -a ! \( "x$have_cygwin" = x1 \)])
|
||||
|
||||
dnl Don't attempt to build docs if there's no Ruby lying around
|
||||
dnl Running tests with Valgrind is slow. It is faster to iterate on
|
||||
dnl code without Valgrind until tests pass, then enable Valgrind and
|
||||
dnl fix leaks.
|
||||
AC_ARG_ENABLE([valgrind],
|
||||
AC_HELP_STRING([--disable-valgrind], [do not run tests under Valgrind]))
|
||||
|
||||
dnl Running tests with Valgrind is slow; address sanitizer (ASAN) is
|
||||
dnl faster.
|
||||
AC_ARG_ENABLE([asan],
|
||||
AC_HELP_STRING([--enable-asan], [enable address sanitizer]))
|
||||
|
||||
dnl Undefined Behavior Sanitizer
|
||||
AC_ARG_ENABLE([ubsan],
|
||||
AC_HELP_STRING([--enable-ubsan], [enable undefined behavior sanitizer]))
|
||||
|
||||
dnl Code coverage
|
||||
AC_ARG_ENABLE([gcov],
|
||||
AC_HELP_STRING([--enable-gcov], [enable gcov code coverage tool]))
|
||||
|
||||
dnl Don't attempt to build docs if python deps aren't installed
|
||||
AC_ARG_ENABLE([docs],
|
||||
AC_HELP_STRING([--disable-docs], [don't build docs]))
|
||||
AC_HELP_STRING([--disable-docs], [don't build docs]), [], [enable_docs=yes])
|
||||
|
||||
dnl Don't attempt to build the error injection object (if there is no LD_PRELOAD support)
|
||||
AC_ARG_ENABLE([error-injection],
|
||||
AC_HELP_STRING([--enable-error-injection], [build and test with error injection]))
|
||||
|
||||
dnl Enable building all static
|
||||
AC_ARG_ENABLE([all-static],
|
||||
AC_HELP_STRING([--enable-all-static], [link jq with static libraries only]))
|
||||
|
||||
dnl find pipenv
|
||||
AC_ARG_VAR([PIPENV], [pipenv command])
|
||||
AC_CHECK_PROGS([PIPENV], pipenv)
|
||||
|
||||
AS_IF([test "x$enable_docs" != "xno"],[
|
||||
AC_CHECK_PROGS(bundle_cmd, bundle)
|
||||
AS_IF([test "x$bundle_cmd" = "x" || \
|
||||
! ( cd ${srcdir}/docs; "$bundle_cmd" check 2>/dev/null )],[
|
||||
AC_MSG_WARN([no bundler])
|
||||
cat <<EOF
|
||||
AC_CACHE_CHECK([for Python dependencies], [jq_cv_python_deps],[
|
||||
jq_cv_python_deps=yes
|
||||
AS_IF([test "x$PIPENV" = "x" || \
|
||||
! bmsg="`cd ${srcdir}/docs; LC_ALL=$LANG "$PIPENV" --venv`"],[
|
||||
jq_cv_python_deps=no
|
||||
])
|
||||
])
|
||||
|
||||
AS_IF([test "x$jq_cv_python_deps" != "xyes"], [
|
||||
AC_MSG_WARN([Error checking python dependencies: $bmsg
|
||||
*****************************************************************
|
||||
* Ruby dependencies for building jq documentation not found. *
|
||||
* Python dependencies for building jq documentation not found. *
|
||||
* You can still build, install and hack on jq, but the manpage *
|
||||
* will not be rebuilt and some of the tests won't run. *
|
||||
* will not be rebuilt and new manpage tests will not be run. *
|
||||
* See docs/README.md for how to install the docs dependencies. *
|
||||
*****************************************************************
|
||||
EOF
|
||||
enable_docs=no
|
||||
*****************************************************************])
|
||||
enable_docs=no
|
||||
])
|
||||
])
|
||||
|
||||
dnl Disable decNumber support
|
||||
AC_ARG_ENABLE([decnum],
|
||||
AC_HELP_STRING([--disable-decnum], [disable decnum support]))
|
||||
|
||||
AS_IF([test "x$enable_decnum" != "xno"],[
|
||||
AC_DEFINE([USE_DECNUM],1)
|
||||
])
|
||||
|
||||
AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" != xno])
|
||||
AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno])
|
||||
AM_CONDITIONAL([ENABLE_ERROR_INJECTION], [test "x$enable_error_injection" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_ALL_STATIC], [test "x$enable_all_static" = xyes])
|
||||
|
||||
dnl Find pthread, if we have it. We do this first because we may set -pthread on CFLAGS
|
||||
dnl which can cause various macros to be defined (__REENTRANT on Darwin, for example)
|
||||
AX_PTHREAD([
|
||||
AC_DEFINE([HAVE_PTHREAD], [1])
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
CC="$PTHREAD_CC"
|
||||
])
|
||||
|
||||
AC_FUNC_ALLOCA
|
||||
|
||||
AC_FIND_FUNC([isatty], [c], [#include <unistd.h>], [0])
|
||||
AC_FIND_FUNC([_isatty], [c], [#include <io.h>], [0])
|
||||
AC_FIND_FUNC([strptime], [c], [#include <time.h>], [0, 0, 0])
|
||||
AC_FIND_FUNC([strftime], [c], [#include <time.h>], [0, 0, 0, 0])
|
||||
AC_FIND_FUNC([setenv], [c], [#include <stdlib.h>], [0, 0, 0])
|
||||
AC_FIND_FUNC([timegm], [c], [#include <time.h>], [0])
|
||||
AC_FIND_FUNC([gmtime_r], [c], [#include <time.h>], [0, 0])
|
||||
AC_FIND_FUNC([gmtime], [c], [#include <time.h>], [0])
|
||||
AC_FIND_FUNC([localtime_r], [c], [#include <time.h>], [0, 0])
|
||||
AC_FIND_FUNC([localtime], [c], [#include <time.h>], [0])
|
||||
AC_FIND_FUNC([gettimeofday], [c], [#include <sys/time.h>], [0, 0])
|
||||
AC_CHECK_MEMBER([struct tm.tm_gmtoff], [AC_DEFINE([HAVE_TM_TM_GMT_OFF],1,[Define to 1 if the system has the tm_gmt_off field in struct tm])],
|
||||
[], [[#include <time.h>]])
|
||||
AC_CHECK_MEMBER([struct tm.__tm_gmtoff], [AC_DEFINE([HAVE_TM___TM_GMT_OFF],1,[Define to 1 if the system has the __tm_gmt_off field in struct tm])],
|
||||
[], [[#include <time.h>]])
|
||||
|
||||
dnl Figure out if we have the pthread functions we actually need
|
||||
AC_FIND_FUNC_NO_LIBS([pthread_key_create], [], [#include <pthread.h>], [NULL, NULL])
|
||||
AC_FIND_FUNC_NO_LIBS([pthread_once], [], [#include <pthread.h>], [NULL, NULL])
|
||||
AC_FIND_FUNC_NO_LIBS([atexit], [], [#include <stdlib.h>], [NULL])
|
||||
|
||||
dnl libm math.h functions
|
||||
AC_CHECK_MATH_FUNC(acos)
|
||||
AC_CHECK_MATH_FUNC(acosh)
|
||||
AC_CHECK_MATH_FUNC(asin)
|
||||
AC_CHECK_MATH_FUNC(asinh)
|
||||
AC_CHECK_MATH_FUNC(atan2)
|
||||
AC_CHECK_MATH_FUNC(atan)
|
||||
AC_CHECK_MATH_FUNC(atanh)
|
||||
AC_CHECK_MATH_FUNC(cbrt)
|
||||
AC_CHECK_MATH_FUNC(ceil)
|
||||
AC_CHECK_MATH_FUNC(copysign)
|
||||
AC_CHECK_MATH_FUNC(cos)
|
||||
AC_CHECK_MATH_FUNC(cosh)
|
||||
AC_CHECK_MATH_FUNC(drem)
|
||||
AC_CHECK_MATH_FUNC(erf)
|
||||
AC_CHECK_MATH_FUNC(erfc)
|
||||
AC_CHECK_MATH_FUNC(exp10)
|
||||
AC_CHECK_MATH_FUNC(__exp10) dnl macOS has an __exp10
|
||||
AC_CHECK_MATH_FUNC(exp2)
|
||||
AC_CHECK_MATH_FUNC(exp)
|
||||
AC_CHECK_MATH_FUNC(expm1)
|
||||
AC_CHECK_MATH_FUNC(fabs)
|
||||
AC_CHECK_MATH_FUNC(fdim)
|
||||
AC_CHECK_MATH_FUNC(floor)
|
||||
AC_CHECK_MATH_FUNC(fma)
|
||||
AC_CHECK_MATH_FUNC(fmax)
|
||||
AC_CHECK_MATH_FUNC(fmin)
|
||||
AC_CHECK_MATH_FUNC(fmod)
|
||||
AC_CHECK_MATH_FUNC(frexp)
|
||||
AC_CHECK_MATH_FUNC(gamma)
|
||||
AC_CHECK_MATH_FUNC(hypot)
|
||||
AC_CHECK_MATH_FUNC(j0)
|
||||
AC_CHECK_MATH_FUNC(j1)
|
||||
AC_CHECK_MATH_FUNC(jn)
|
||||
AC_CHECK_MATH_FUNC(ldexp)
|
||||
AC_CHECK_MATH_FUNC(lgamma)
|
||||
AC_CHECK_MATH_FUNC(log10)
|
||||
AC_CHECK_MATH_FUNC(log1p)
|
||||
AC_CHECK_MATH_FUNC(log2)
|
||||
AC_CHECK_MATH_FUNC(log)
|
||||
AC_CHECK_MATH_FUNC(logb)
|
||||
AC_CHECK_MATH_FUNC(modf)
|
||||
AC_CHECK_MATH_FUNC(lgamma_r)
|
||||
AC_CHECK_MATH_FUNC(nearbyint)
|
||||
AC_CHECK_MATH_FUNC(nextafter)
|
||||
AC_CHECK_MATH_FUNC(nexttoward)
|
||||
AC_CHECK_MATH_FUNC(pow10) # Not available with glibc version >= 2.27
|
||||
AC_CHECK_MATH_FUNC(pow)
|
||||
AC_CHECK_MATH_FUNC(remainder)
|
||||
AC_CHECK_MATH_FUNC(rint)
|
||||
AC_CHECK_MATH_FUNC(round)
|
||||
AC_CHECK_MATH_FUNC(scalb)
|
||||
AC_CHECK_MATH_FUNC(scalbln)
|
||||
AC_CHECK_MATH_FUNC(significand)
|
||||
dnl scalbn and ilogb are used on macos to replace significand if we don't have frexp
|
||||
AC_CHECK_MATH_FUNC(scalbn)
|
||||
AC_CHECK_MATH_FUNC(ilogb)
|
||||
|
||||
AC_CHECK_MATH_FUNC(sin)
|
||||
AC_CHECK_MATH_FUNC(sinh)
|
||||
AC_CHECK_MATH_FUNC(sqrt)
|
||||
AC_CHECK_MATH_FUNC(tan)
|
||||
AC_CHECK_MATH_FUNC(tanh)
|
||||
AC_CHECK_MATH_FUNC(tgamma)
|
||||
AC_CHECK_MATH_FUNC(trunc)
|
||||
AC_CHECK_MATH_FUNC(y0)
|
||||
AC_CHECK_MATH_FUNC(y1)
|
||||
AC_CHECK_MATH_FUNC(yn)
|
||||
|
||||
dnl Thread local storage
|
||||
have___thread=no
|
||||
AC_MSG_CHECKING(for thread-local storage)
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([
|
||||
static __thread int x ;
|
||||
int main () { x = 123; return x; }
|
||||
])], have___thread=yes)
|
||||
if test $have___thread = yes; then
|
||||
AC_DEFINE([HAVE___THREAD],1,[Define to 1 if the system supports __thread])
|
||||
fi
|
||||
AC_MSG_RESULT($have___thread)
|
||||
|
||||
AC_C_BIGENDIAN(
|
||||
AC_DEFINE([IEEE_MC68k], 1, [machine is bigendian]),
|
||||
AC_DEFINE([IEEE_8087], 1, [machine is littleendian]),
|
||||
AC_MSG_ERROR(unknown endianness),
|
||||
AC_MSG_ERROR(universal endianness not supported)
|
||||
)
|
||||
|
||||
dnl Oniguruma
|
||||
AC_ARG_WITH([oniguruma],
|
||||
[AS_HELP_STRING([--with-oniguruma=prefix],
|
||||
[try this for a non-standard install prefix of the oniguruma library])], ,
|
||||
[with_oniguruma=yes])
|
||||
|
||||
onig_CFLAGS=
|
||||
onig_LDFLAGS=
|
||||
build_oniguruma=no
|
||||
AS_IF([test "x$with_oniguruma" != xno], [
|
||||
save_CFLAGS="$CFLAGS"
|
||||
save_LDFLAGS="$LDFLAGS"
|
||||
AS_IF([test "x$with_oniguruma" != xyes], [
|
||||
AS_IF([test "x$with_oniguruma" = xbuiltin], [
|
||||
build_oniguruma=yes
|
||||
], [
|
||||
onig_CFLAGS="-I${with_oniguruma}/include"
|
||||
onig_LDFLAGS="-L${with_oniguruma}/lib"
|
||||
])
|
||||
])
|
||||
AS_IF([test "x$build_oniguruma" = xno], [
|
||||
# check for ONIGURUMA library, either in /usr or where requested
|
||||
CFLAGS="$CFLAGS $onig_CFLAGS"
|
||||
LDFLAGS="$LDFLAGS $onig_LDFLAGS"
|
||||
AC_CHECK_HEADER("oniguruma.h",
|
||||
AC_CHECK_LIB([onig],[onig_version]))
|
||||
# handle check results
|
||||
AS_IF([test "x$ac_cv_lib_onig_onig_version" != "xyes"], [
|
||||
build_oniguruma=yes
|
||||
AC_MSG_NOTICE([Oniguruma was not found. Will use the packaged oniguruma.])
|
||||
])
|
||||
])
|
||||
AS_IF([test "x$build_oniguruma" = xyes -a -f "${srcdir}/modules/oniguruma/configure.ac" ], [
|
||||
onig_CFLAGS="-I${srcdir}/modules/oniguruma/src"
|
||||
onig_LDFLAGS="-L${srcdir}/modules/oniguruma/src -Wl,-rpath,${libdir}"
|
||||
AC_CONFIG_SUBDIRS([modules/oniguruma])
|
||||
AC_DEFINE([HAVE_LIBONIG],1,[Define to 1 if the system includes libonig])
|
||||
])
|
||||
CFLAGS="$save_CFLAGS"
|
||||
LDFLAGS="$save_LDFLAGS"
|
||||
])
|
||||
AC_SUBST(onig_CFLAGS)
|
||||
AC_SUBST(onig_LDFLAGS)
|
||||
|
||||
AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes])
|
||||
AC_SUBST([BUNDLER], ["$bundle_cmd"])
|
||||
|
||||
dnl AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
AM_INIT_AUTOMAKE([-Wall])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_MACRO_DIRS([config/m4 m4])
|
||||
AC_CONFIG_FILES([Makefile libjq.pc])
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
.DS_Store
|
||||
.sass-cache
|
||||
output/*
|
||||
|
||||
# Autogenerated from public/css/base.scss
|
||||
public/css/base.css
|
||||
@@ -1,6 +0,0 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "rake"
|
||||
gem "bonsai"
|
||||
gem "maruku"
|
||||
gem "ronn"
|
||||
@@ -1,63 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
POpen4 (0.1.4)
|
||||
Platform (>= 0.4.0)
|
||||
open4
|
||||
Platform (0.4.0)
|
||||
activesupport (3.2.12)
|
||||
i18n (~> 0.6)
|
||||
multi_json (~> 1.0)
|
||||
addressable (2.3.4)
|
||||
bonsai (1.4.8)
|
||||
activesupport (>= 3.0.3)
|
||||
builder (>= 3.0.0)
|
||||
i18n (>= 0.5.0)
|
||||
launchy (>= 0.3.7)
|
||||
liquid (>= 2.2.2)
|
||||
maruku (>= 0.6.0)
|
||||
rack
|
||||
sass
|
||||
sinatra (>= 1.0)
|
||||
tilt (>= 1.3)
|
||||
watch (>= 0.1.0)
|
||||
yui-compressor
|
||||
builder (3.2.0)
|
||||
hpricot (0.8.6)
|
||||
i18n (0.6.4)
|
||||
launchy (2.3.0)
|
||||
addressable (~> 2.3)
|
||||
liquid (2.5.0)
|
||||
maruku (0.6.1)
|
||||
syntax (>= 1.0.0)
|
||||
multi_json (1.7.3)
|
||||
mustache (0.99.4)
|
||||
open4 (1.3.0)
|
||||
rack (1.5.2)
|
||||
rack-protection (1.5.0)
|
||||
rack
|
||||
rake (10.0.3)
|
||||
rdiscount (2.0.7.2)
|
||||
ronn (0.7.3)
|
||||
hpricot (>= 0.8.2)
|
||||
mustache (>= 0.7.0)
|
||||
rdiscount (>= 1.5.8)
|
||||
sass (3.2.8)
|
||||
sinatra (1.4.2)
|
||||
rack (~> 1.5, >= 1.5.2)
|
||||
rack-protection (~> 1.4)
|
||||
tilt (~> 1.3, >= 1.3.4)
|
||||
syntax (1.0.0)
|
||||
tilt (1.4.0)
|
||||
watch (0.1.0)
|
||||
yui-compressor (0.9.6)
|
||||
POpen4 (>= 0.1.4)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
bonsai
|
||||
maruku
|
||||
rake
|
||||
ronn
|
||||
@@ -0,0 +1,12 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
jinja2 = "*"
|
||||
pyyaml = "*"
|
||||
markdown = "*"
|
||||
lxml = "*"
|
||||
Generated
+226
@@ -0,0 +1,226 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "16a9ef323592a417142c30be17e58c3cf36dc2bfdbf4757106a796b22262a1ce"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"importlib-metadata": {
|
||||
"hashes": [
|
||||
"sha256:b618b6d2d5ffa2f16add5697cf57a46c76a56229b0ed1c438322e4e95645bd15",
|
||||
"sha256:f284b3e11256ad1e5d03ab86bb2ccd6f5339688ff17a4d797a0fe7df326f23b1"
|
||||
],
|
||||
"markers": "python_version < '3.8'",
|
||||
"version": "==4.8.1"
|
||||
},
|
||||
"jinja2": {
|
||||
"hashes": [
|
||||
"sha256:827a0e32839ab1600d4eb1c4c33ec5a8edfbc5cb42dafa13b81f182f97784b45",
|
||||
"sha256:8569982d3f0889eed11dd620c706d39b60c36d6d25843961f33f77fb6bc6b20c"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==3.0.2"
|
||||
},
|
||||
"lxml": {
|
||||
"hashes": [
|
||||
"sha256:079f3ae844f38982d156efce585bc540c16a926d4436712cf4baee0cce487a3d",
|
||||
"sha256:0fbcf5565ac01dff87cbfc0ff323515c823081c5777a9fc7703ff58388c258c3",
|
||||
"sha256:122fba10466c7bd4178b07dba427aa516286b846b2cbd6f6169141917283aae2",
|
||||
"sha256:1b38116b6e628118dea5b2186ee6820ab138dbb1e24a13e478490c7db2f326ae",
|
||||
"sha256:1b7584d421d254ab86d4f0b13ec662a9014397678a7c4265a02a6d7c2b18a75f",
|
||||
"sha256:26e761ab5b07adf5f555ee82fb4bfc35bf93750499c6c7614bd64d12aaa67927",
|
||||
"sha256:289e9ca1a9287f08daaf796d96e06cb2bc2958891d7911ac7cae1c5f9e1e0ee3",
|
||||
"sha256:2a9d50e69aac3ebee695424f7dbd7b8c6d6eb7de2a2eb6b0f6c7db6aa41e02b7",
|
||||
"sha256:3082c518be8e97324390614dacd041bb1358c882d77108ca1957ba47738d9d59",
|
||||
"sha256:33bb934a044cf32157c12bfcfbb6649807da20aa92c062ef51903415c704704f",
|
||||
"sha256:3439c71103ef0e904ea0a1901611863e51f50b5cd5e8654a151740fde5e1cade",
|
||||
"sha256:36108c73739985979bf302006527cf8a20515ce444ba916281d1c43938b8bb96",
|
||||
"sha256:39b78571b3b30645ac77b95f7c69d1bffc4cf8c3b157c435a34da72e78c82468",
|
||||
"sha256:4289728b5e2000a4ad4ab8da6e1db2e093c63c08bdc0414799ee776a3f78da4b",
|
||||
"sha256:4bff24dfeea62f2e56f5bab929b4428ae6caba2d1eea0c2d6eb618e30a71e6d4",
|
||||
"sha256:4c61b3a0db43a1607d6264166b230438f85bfed02e8cff20c22e564d0faff354",
|
||||
"sha256:542d454665a3e277f76954418124d67516c5f88e51a900365ed54a9806122b83",
|
||||
"sha256:5a0a14e264069c03e46f926be0d8919f4105c1623d620e7ec0e612a2e9bf1c04",
|
||||
"sha256:5c8c163396cc0df3fd151b927e74f6e4acd67160d6c33304e805b84293351d16",
|
||||
"sha256:64812391546a18896adaa86c77c59a4998f33c24788cadc35789e55b727a37f4",
|
||||
"sha256:66e575c62792c3f9ca47cb8b6fab9e35bab91360c783d1606f758761810c9791",
|
||||
"sha256:6f12e1427285008fd32a6025e38e977d44d6382cf28e7201ed10d6c1698d2a9a",
|
||||
"sha256:74f7d8d439b18fa4c385f3f5dfd11144bb87c1da034a466c5b5577d23a1d9b51",
|
||||
"sha256:7610b8c31688f0b1be0ef882889817939490a36d0ee880ea562a4e1399c447a1",
|
||||
"sha256:76fa7b1362d19f8fbd3e75fe2fb7c79359b0af8747e6f7141c338f0bee2f871a",
|
||||
"sha256:7728e05c35412ba36d3e9795ae8995e3c86958179c9770e65558ec3fdfd3724f",
|
||||
"sha256:8157dadbb09a34a6bd95a50690595e1fa0af1a99445e2744110e3dca7831c4ee",
|
||||
"sha256:820628b7b3135403540202e60551e741f9b6d3304371712521be939470b454ec",
|
||||
"sha256:884ab9b29feaca361f7f88d811b1eea9bfca36cf3da27768d28ad45c3ee6f969",
|
||||
"sha256:89b8b22a5ff72d89d48d0e62abb14340d9e99fd637d046c27b8b257a01ffbe28",
|
||||
"sha256:92e821e43ad382332eade6812e298dc9701c75fe289f2a2d39c7960b43d1e92a",
|
||||
"sha256:b007cbb845b28db4fb8b6a5cdcbf65bacb16a8bd328b53cbc0698688a68e1caa",
|
||||
"sha256:bc4313cbeb0e7a416a488d72f9680fffffc645f8a838bd2193809881c67dd106",
|
||||
"sha256:bccbfc27563652de7dc9bdc595cb25e90b59c5f8e23e806ed0fd623755b6565d",
|
||||
"sha256:c1a40c06fd5ba37ad39caa0b3144eb3772e813b5fb5b084198a985431c2f1e8d",
|
||||
"sha256:c47ff7e0a36d4efac9fd692cfa33fbd0636674c102e9e8d9b26e1b93a94e7617",
|
||||
"sha256:c4f05c5a7c49d2fb70223d0d5bcfbe474cf928310ac9fa6a7c6dddc831d0b1d4",
|
||||
"sha256:cdaf11d2bd275bf391b5308f86731e5194a21af45fbaaaf1d9e8147b9160ea92",
|
||||
"sha256:ce256aaa50f6cc9a649c51be3cd4ff142d67295bfc4f490c9134d0f9f6d58ef0",
|
||||
"sha256:d2e35d7bf1c1ac8c538f88d26b396e73dd81440d59c1ef8522e1ea77b345ede4",
|
||||
"sha256:d916d31fd85b2f78c76400d625076d9124de3e4bda8b016d25a050cc7d603f24",
|
||||
"sha256:df7c53783a46febb0e70f6b05df2ba104610f2fb0d27023409734a3ecbb78fb2",
|
||||
"sha256:e1cbd3f19a61e27e011e02f9600837b921ac661f0c40560eefb366e4e4fb275e",
|
||||
"sha256:efac139c3f0bf4f0939f9375af4b02c5ad83a622de52d6dfa8e438e8e01d0eb0",
|
||||
"sha256:efd7a09678fd8b53117f6bae4fa3825e0a22b03ef0a932e070c0bdbb3a35e654",
|
||||
"sha256:f2380a6376dfa090227b663f9678150ef27543483055cc327555fb592c5967e2",
|
||||
"sha256:f8380c03e45cf09f8557bdaa41e1fa7c81f3ae22828e1db470ab2a6c96d8bc23",
|
||||
"sha256:f90ba11136bfdd25cae3951af8da2e95121c9b9b93727b1b896e3fa105b2f586"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==4.6.3"
|
||||
},
|
||||
"markdown": {
|
||||
"hashes": [
|
||||
"sha256:31b5b491868dcc87d6c24b7e3d19a0d730d59d3e46f4eea6430a321bed387a49",
|
||||
"sha256:96c3ba1261de2f7547b46a00ea8463832c921d3f9d6aba3f255a6f71386db20c"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==3.3.4"
|
||||
},
|
||||
"markupsafe": {
|
||||
"hashes": [
|
||||
"sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298",
|
||||
"sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64",
|
||||
"sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b",
|
||||
"sha256:04635854b943835a6ea959e948d19dcd311762c5c0c6e1f0e16ee57022669194",
|
||||
"sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567",
|
||||
"sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff",
|
||||
"sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724",
|
||||
"sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74",
|
||||
"sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646",
|
||||
"sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35",
|
||||
"sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6",
|
||||
"sha256:20dca64a3ef2d6e4d5d615a3fd418ad3bde77a47ec8a23d984a12b5b4c74491a",
|
||||
"sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6",
|
||||
"sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad",
|
||||
"sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26",
|
||||
"sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38",
|
||||
"sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac",
|
||||
"sha256:3c112550557578c26af18a1ccc9e090bfe03832ae994343cfdacd287db6a6ae7",
|
||||
"sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6",
|
||||
"sha256:4296f2b1ce8c86a6aea78613c34bb1a672ea0e3de9c6ba08a960efe0b0a09047",
|
||||
"sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75",
|
||||
"sha256:49e3ceeabbfb9d66c3aef5af3a60cc43b85c33df25ce03d0031a608b0a8b2e3f",
|
||||
"sha256:4dc8f9fb58f7364b63fd9f85013b780ef83c11857ae79f2feda41e270468dd9b",
|
||||
"sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135",
|
||||
"sha256:53edb4da6925ad13c07b6d26c2a852bd81e364f95301c66e930ab2aef5b5ddd8",
|
||||
"sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a",
|
||||
"sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a",
|
||||
"sha256:5b6d930f030f8ed98e3e6c98ffa0652bdb82601e7a016ec2ab5d7ff23baa78d1",
|
||||
"sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9",
|
||||
"sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864",
|
||||
"sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914",
|
||||
"sha256:6300b8454aa6930a24b9618fbb54b5a68135092bc666f7b06901f897fa5c2fee",
|
||||
"sha256:63f3268ba69ace99cab4e3e3b5840b03340efed0948ab8f78d2fd87ee5442a4f",
|
||||
"sha256:6557b31b5e2c9ddf0de32a691f2312a32f77cd7681d8af66c2692efdbef84c18",
|
||||
"sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8",
|
||||
"sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2",
|
||||
"sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d",
|
||||
"sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b",
|
||||
"sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b",
|
||||
"sha256:89c687013cb1cd489a0f0ac24febe8c7a666e6e221b783e53ac50ebf68e45d86",
|
||||
"sha256:8d206346619592c6200148b01a2142798c989edcb9c896f9ac9722a99d4e77e6",
|
||||
"sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f",
|
||||
"sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb",
|
||||
"sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833",
|
||||
"sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28",
|
||||
"sha256:9f02365d4e99430a12647f09b6cc8bab61a6564363f313126f775eb4f6ef798e",
|
||||
"sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415",
|
||||
"sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902",
|
||||
"sha256:aca6377c0cb8a8253e493c6b451565ac77e98c2951c45f913e0b52facdcff83f",
|
||||
"sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d",
|
||||
"sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9",
|
||||
"sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d",
|
||||
"sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145",
|
||||
"sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066",
|
||||
"sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c",
|
||||
"sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1",
|
||||
"sha256:cdfba22ea2f0029c9261a4bd07e830a8da012291fbe44dc794e488b6c9bb353a",
|
||||
"sha256:d6c7ebd4e944c85e2c3421e612a7057a2f48d478d79e61800d81468a8d842207",
|
||||
"sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f",
|
||||
"sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53",
|
||||
"sha256:deb993cacb280823246a026e3b2d81c493c53de6acfd5e6bfe31ab3402bb37dd",
|
||||
"sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134",
|
||||
"sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85",
|
||||
"sha256:f0567c4dc99f264f49fe27da5f735f414c4e7e7dd850cfd8e69f0862d7c74ea9",
|
||||
"sha256:f5653a225f31e113b152e56f154ccbe59eeb1c7487b39b9d9f9cdb58e6c79dc5",
|
||||
"sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94",
|
||||
"sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509",
|
||||
"sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51",
|
||||
"sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872"
|
||||
],
|
||||
"version": "==2.0.1"
|
||||
},
|
||||
"pyyaml": {
|
||||
"hashes": [
|
||||
"sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293",
|
||||
"sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b",
|
||||
"sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57",
|
||||
"sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b",
|
||||
"sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4",
|
||||
"sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07",
|
||||
"sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba",
|
||||
"sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9",
|
||||
"sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287",
|
||||
"sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513",
|
||||
"sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0",
|
||||
"sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0",
|
||||
"sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92",
|
||||
"sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f",
|
||||
"sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2",
|
||||
"sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc",
|
||||
"sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c",
|
||||
"sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86",
|
||||
"sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4",
|
||||
"sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c",
|
||||
"sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34",
|
||||
"sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b",
|
||||
"sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c",
|
||||
"sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb",
|
||||
"sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737",
|
||||
"sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3",
|
||||
"sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d",
|
||||
"sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53",
|
||||
"sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78",
|
||||
"sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803",
|
||||
"sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a",
|
||||
"sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174",
|
||||
"sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==6.0"
|
||||
},
|
||||
"typing-extensions": {
|
||||
"hashes": [
|
||||
"sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e",
|
||||
"sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7",
|
||||
"sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34"
|
||||
],
|
||||
"markers": "python_version < '3.8'",
|
||||
"version": "==3.10.0.2"
|
||||
},
|
||||
"zipp": {
|
||||
"hashes": [
|
||||
"sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832",
|
||||
"sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"
|
||||
],
|
||||
"version": "==3.6.0"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
+10
-15
@@ -2,24 +2,19 @@ Documentation
|
||||
=============
|
||||
|
||||
The jq website, manpages and some of the tests are generated from this
|
||||
directory. The directory holds a [Bonsai](http://tinytree.info)
|
||||
website, and the manual is a YAML file in `content/3.manual`.
|
||||
directory. The manual is a YAML file in `content/manual`.
|
||||
|
||||
To build the documentation (including building the jq manpage), you'll
|
||||
need a working Ruby setup. The easiest way to get one is to install
|
||||
RVM and Ruby 1.9.3 like so:
|
||||
need python3 and pipenv. You can install pipenv like so:
|
||||
|
||||
\curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3
|
||||
pip install pipenv
|
||||
|
||||
After that finishes installing, you'll need to make sure RVM is on
|
||||
your path by doing `source $HOME/.rvm/scripts/rvm`, or just opening a
|
||||
new shell. See <http://rvm.io> for more info on RVM.
|
||||
Though, you may need to say pip3 instead, depending on your system. Once
|
||||
you have pipenv installed, you can install the dependencies by running
|
||||
`pipenv install` from the `docs` directory.
|
||||
|
||||
Once RVM is installed, you can install all the dependencies for jq's
|
||||
documentation build by running this from the `docs` directory:
|
||||
Once this is done, rerun `./configure` in the jq root directory and then
|
||||
the Makefile will be able to generate the jq manpage.
|
||||
|
||||
bundle install
|
||||
|
||||
When bundle manages to install the dependencies, rerun `./configure`
|
||||
in the jq root directory and then the Makefile will be able to
|
||||
generate the jq manpage.
|
||||
To build the website, run `pipenv run ./build_website.py` from inside
|
||||
the `docs` directory.
|
||||
-146
@@ -1,146 +0,0 @@
|
||||
require 'yaml'
|
||||
require 'bonsai'
|
||||
require 'liquid'
|
||||
require 'maruku'
|
||||
require 'json'
|
||||
require 'ronn'
|
||||
require 'tempfile'
|
||||
require 'yaml'
|
||||
|
||||
module ExtraFilters
|
||||
def markdownify(input)
|
||||
Maruku.new(input).to_html
|
||||
end
|
||||
|
||||
def sanitize(input)
|
||||
input.gsub(/[^a-zA-Z0-9_]/,"")
|
||||
end
|
||||
|
||||
def json(input)
|
||||
input.to_json
|
||||
end
|
||||
|
||||
def unique(input)
|
||||
@n = (@n || 0) + 1
|
||||
input + @n.to_s
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter(ExtraFilters)
|
||||
|
||||
|
||||
task :serve do
|
||||
begin
|
||||
Bonsai.log "Press Control+C to quit"
|
||||
|
||||
require 'rack'
|
||||
require 'sinatra'
|
||||
require 'watch'
|
||||
require 'launchy'
|
||||
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
|
||||
server = fork {
|
||||
app = Rack::Builder.app {
|
||||
map "/jq" do
|
||||
use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
|
||||
end
|
||||
run Bonsai::DevelopmentServer
|
||||
}
|
||||
Rack::Handler.default.run(app, :Port => 5000) do
|
||||
Launchy.open("http://localhost:5000/jq/")
|
||||
end
|
||||
}
|
||||
Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
|
||||
rescue Interrupt
|
||||
Process.kill("QUIT", server)
|
||||
Process.wait(server)
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
task :build do
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
Bonsai::Exporter.publish!
|
||||
end
|
||||
|
||||
$BINARIES = {
|
||||
:osx32 => "--host=i686-apple-darwin10 CFLAGS='-m32 -g -O'",
|
||||
:osx64 => "--host=i686-apple-darwin10 CFLAGS='-m64 -g -O'",
|
||||
:win32 => "--host=i686-w64-mingw32 CFLAGS='-g -O'",
|
||||
:win64 => "--host=x86_64-w64-mingw32 CFLAGS='-g -O'",
|
||||
:linux32 => "--host=x86_64-linux-gnu CFLAGS='-m32 -g -O'",
|
||||
:linux64 => "--host=x86_64-linux-gnu CFLAGS='-m64 -g -O'"
|
||||
}
|
||||
|
||||
$BINARIES.each do |name, args|
|
||||
file "../build/#{name}" do |t|
|
||||
sh "MAKEFLAGS=-j4 ../scripts/crosscompile #{name} #{args}"
|
||||
end
|
||||
task :binaries => ["../build/#{name}"]
|
||||
end
|
||||
|
||||
task :binaries => ["output/download"] do
|
||||
$BINARIES.each do |name, args|
|
||||
FileUtils.cp_r "../build/#{name}", "output/download/"
|
||||
end
|
||||
end
|
||||
|
||||
def load_manual
|
||||
YAML::ENGINE.yamler = 'syck'
|
||||
YAML::load(File.open("content/3.manual/manual.yml"))
|
||||
end
|
||||
|
||||
task :manpage do
|
||||
Tempfile.open "manpage" do |f|
|
||||
manual = load_manual
|
||||
f.puts manual['manpage_intro']
|
||||
f.puts manual['body']
|
||||
manual['sections'].each do |section|
|
||||
|
||||
f.puts "## #{section['title'].upcase}\n"
|
||||
f.puts section['body']
|
||||
f.puts ""
|
||||
(section['entries'] || []).each do |entry|
|
||||
f.puts "### #{entry['title']}\n"
|
||||
f.puts entry['body']
|
||||
f.puts ""
|
||||
(entry['examples'] || []).each do |example|
|
||||
f.puts " jq '#{example['program']}'"
|
||||
f.puts " #{example['input']}"
|
||||
f.puts " => #{example['output'].join(", ")}"
|
||||
f.puts
|
||||
end
|
||||
end
|
||||
f.puts ""
|
||||
end
|
||||
f.puts manual['manpage_epilogue']
|
||||
f.close
|
||||
puts Ronn::Document.new(f.path).convert('roff').gsub(/<\/?code>/,"")
|
||||
end
|
||||
end
|
||||
|
||||
task :manpage_default => ["default_manpage.md"] do
|
||||
puts Ronn::Document.new("default_manpage.md").convert('roff').gsub(/<\/?code>/,"")
|
||||
end
|
||||
|
||||
task :mantests do
|
||||
load_manual['sections'].each do |section|
|
||||
(section['entries'] || []).each do |entry|
|
||||
(entry['examples'] || []).each do |example|
|
||||
puts example['program'].gsub("\n", " ")
|
||||
puts example['input']
|
||||
example['output'].each do |s| puts s end
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
directory "output/download/source"
|
||||
task :tarball => ["output/download/source"] do
|
||||
sh "cd ..; ./configure && make dist && make distclean"
|
||||
sh "cp ../jq-*.tar.gz output/download/source"
|
||||
end
|
||||
|
||||
task :dist => [:build, :binaries, :tarball]
|
||||
Executable
+248
@@ -0,0 +1,248 @@
|
||||
#!/usr/bin/env python3
|
||||
from datetime import date
|
||||
from io import StringIO
|
||||
from lxml import etree
|
||||
import markdown
|
||||
from markdown.extensions import Extension
|
||||
import re
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
|
||||
# Prevent our markdown parser from trying to help by interpreting things in angle brackets as HTML tags.
|
||||
class EscapeHtml(Extension):
|
||||
|
||||
def extendMarkdown(self, md, md_globals):
|
||||
del md.preprocessors['html_block']
|
||||
del md.inlinePatterns['html']
|
||||
|
||||
|
||||
class RoffWalker(object):
|
||||
|
||||
def __init__(self, tree, output=sys.stdout):
|
||||
self.tree = tree
|
||||
self.target = output
|
||||
self.f = StringIO()
|
||||
|
||||
def walk(self):
|
||||
self._walk(self.tree, parent_tag=None)
|
||||
# We don't want to start lines with \. because that can confuse man
|
||||
# For lines that start with \., we need to prefix them with \& so it
|
||||
# knows not to treat that line as a directive
|
||||
data = re.sub(r'^\\\.', r'\&.', self.f.getvalue(), flags=re.MULTILINE)
|
||||
self.target.write(data)
|
||||
|
||||
def _ul_is_special(self, root):
|
||||
if len(root) != 1:
|
||||
return False
|
||||
child = root[0]
|
||||
if child.tag != 'li':
|
||||
return False
|
||||
msg = ''.join(child.itertext()).strip()
|
||||
return msg.endswith(':')
|
||||
|
||||
def _walk_child(self, root):
|
||||
if len(root) > 0:
|
||||
self._walk(root[0], parent_tag=root.tag)
|
||||
|
||||
def _write_element(self, root, ensure_newline=True):
|
||||
if root.text is not None:
|
||||
text = self._sanitize(root.text)
|
||||
self.__write_raw(text)
|
||||
self._walk_child(root)
|
||||
self._write_tail(root, ensure_newline=ensure_newline)
|
||||
|
||||
def _write_tail(self, root, ensure_newline=False, inline=False):
|
||||
if root.tail is not None:
|
||||
if inline or root.tail != '\n':
|
||||
text = self._sanitize(root.tail)
|
||||
if text.endswith('\n'):
|
||||
ensure_newline = False
|
||||
self.__write_raw(text)
|
||||
if ensure_newline:
|
||||
self.__write_raw('\n')
|
||||
|
||||
def _walk(self, root, parent_tag=None):
|
||||
last_tag = None
|
||||
while root is not None:
|
||||
if root.tag == 'h1':
|
||||
self.__write_cmd('.TH "JQ" "1" "{}" "" ""'.format(
|
||||
date.today().strftime('%B %Y')))
|
||||
self.__write_cmd('.SH "NAME"')
|
||||
# TODO: properly parse this
|
||||
self.__write_raw(r'\fBjq\fR \- Command\-line JSON processor' +
|
||||
"\n")
|
||||
|
||||
elif root.tag == 'h2':
|
||||
self.__write_cmd('.SH "{}"'.format(''.join(
|
||||
root.itertext()).strip()))
|
||||
|
||||
elif root.tag == 'h3':
|
||||
text = ''.join(root.itertext()).strip()
|
||||
self.__write_cmd('.SS "{}"'.format(self._h3_sanitize(text)))
|
||||
|
||||
elif root.tag == 'p':
|
||||
if last_tag not in ['h2', 'h3'] and parent_tag not in ['li']:
|
||||
self.__write_cmd('.P')
|
||||
self._write_element(root, ensure_newline=(parent_tag != 'li'))
|
||||
|
||||
elif root.tag == 'ul':
|
||||
if self._ul_is_special(root):
|
||||
li = root[0]
|
||||
self.__write_cmd('.TP')
|
||||
self._write_element(li)
|
||||
next = root.getnext()
|
||||
while next is not None and next.tag == 'p':
|
||||
if next.getnext() is not None and next.getnext(
|
||||
).tag == 'pre':
|
||||
# we don't want to .IP these, because it'll look funny with the code indent
|
||||
break
|
||||
self.__write_cmd('.IP')
|
||||
self._write_element(next)
|
||||
root = next
|
||||
next = root.getnext()
|
||||
else:
|
||||
self._walk_child(root)
|
||||
self._write_tail(root)
|
||||
# A pre tag after the end of a list doesn't want two of the indentation commands
|
||||
if root.getnext() is None or root.getnext().tag != 'pre':
|
||||
self.__write_cmd('.IP "" 0')
|
||||
|
||||
elif root.tag == 'li':
|
||||
self.__write_cmd(r'.IP "\(bu" 4')
|
||||
if root.text is not None and root.text.strip() != '':
|
||||
text = self._sanitize(root.text)
|
||||
self.__write_raw(text)
|
||||
self._walk_child(root)
|
||||
self._write_tail(root, ensure_newline=True)
|
||||
|
||||
elif root.tag == 'strong':
|
||||
if root.text is not None:
|
||||
text = self._sanitize(root.text)
|
||||
self.__write_raw('\\fB{}\\fR'.format(text))
|
||||
|
||||
self._write_tail(root, inline=True)
|
||||
|
||||
elif root.tag == 'em':
|
||||
if root.text is not None:
|
||||
text = self._sanitize(root.text)
|
||||
self.__write_raw('\\fI{}\\fR'.format(text))
|
||||
self._write_tail(root, inline=True)
|
||||
|
||||
elif root.tag == 'code':
|
||||
if root.text is not None:
|
||||
text = self._code_sanitize(root.text)
|
||||
self.__write_raw('\\fB{}\\fR'.format(text))
|
||||
self._write_tail(root, inline=True)
|
||||
|
||||
elif root.tag == 'pre':
|
||||
self.__write_cmd('.IP "" 4')
|
||||
self.__write_cmd('.nf\n') # extra newline for spacing reasons
|
||||
next = root
|
||||
first = True
|
||||
while next is not None and next.tag == 'pre':
|
||||
if not first:
|
||||
self.__write_raw('\n')
|
||||
text = ''.join(next.itertext(with_tail=False))
|
||||
self.__write_raw(self._pre_sanitize(text))
|
||||
first = False
|
||||
root = next
|
||||
next = next.getnext()
|
||||
self.__write_cmd('.fi')
|
||||
self.__write_cmd('.IP "" 0')
|
||||
|
||||
else:
|
||||
self._walk_child(root)
|
||||
|
||||
last_tag = root.tag
|
||||
root = root.getnext()
|
||||
|
||||
def _base_sanitize(self, text):
|
||||
text = re.sub(r'\\', r'\\e', text)
|
||||
text = re.sub(r'\.', r'\\.', text)
|
||||
text = re.sub("'", r"\'", text)
|
||||
text = re.sub('-', r'\-', text)
|
||||
return text
|
||||
|
||||
def _pre_sanitize(self, text):
|
||||
return self._base_sanitize(text)
|
||||
|
||||
def _code_sanitize(self, text):
|
||||
text = self._base_sanitize(text)
|
||||
text = re.sub(r'\s', ' ', text)
|
||||
return text
|
||||
|
||||
def _h3_sanitize(self, text):
|
||||
text = self._base_sanitize(text)
|
||||
text = re.sub(' \n|\n ', ' ', text)
|
||||
text = re.sub('\n', ' ', text)
|
||||
return text
|
||||
|
||||
def _sanitize(self, text):
|
||||
text = self._base_sanitize(text)
|
||||
text = re.sub(r'<([^>]+)>', r'\\fI\1\\fR', text)
|
||||
text = re.sub(r' +', ' ', text)
|
||||
text = re.sub('\n', ' ', text)
|
||||
return text
|
||||
|
||||
def __write_cmd(self, dat):
|
||||
print('.', dat, sep='\n', file=self.f)
|
||||
pass
|
||||
|
||||
def __write_raw(self, dat):
|
||||
print(dat, sep='', end='', file=self.f)
|
||||
pass
|
||||
|
||||
|
||||
def load_yml_file(fn):
|
||||
with open(fn) as f:
|
||||
return yaml.safe_load(f)
|
||||
|
||||
|
||||
def dedent_body(body):
|
||||
lines = [re.sub(r'^ (\S)', r'\1', l) for l in body.split('\n')]
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
||||
def convert_manual_to_markdown():
|
||||
f = StringIO()
|
||||
manual = load_yml_file("content/manual/manual.yml")
|
||||
f.write(manual.get('manpage_intro', '\n'))
|
||||
f.write(dedent_body(manual.get('body', '\n')))
|
||||
for section in manual.get('sections', []):
|
||||
f.write('## {}\n'.format(section.get('title', '').upper()))
|
||||
f.write(dedent_body(section.get('body', '\n')))
|
||||
f.write('\n')
|
||||
for entry in section.get('entries', []):
|
||||
f.write('### {}\n'.format(entry.get('title', '')))
|
||||
f.write(dedent_body(entry.get('body', '\n')))
|
||||
f.write('\n')
|
||||
if entry.get('examples') is not None:
|
||||
f.write("~~~~\n")
|
||||
first = True
|
||||
for example in entry.get('examples'):
|
||||
if not first:
|
||||
f.write('\n')
|
||||
f.write("jq '{}'\n".format(example.get('program', '')))
|
||||
f.write(" {}\n".format(example.get('input', '')))
|
||||
output = [str(x) for x in example.get('output', [])]
|
||||
f.write("=> {}\n".format(', '.join(output)))
|
||||
first = False
|
||||
f.write("~~~~\n")
|
||||
f.write('\n')
|
||||
f.write(manual.get('manpage_epilogue', ''))
|
||||
return f.getvalue()
|
||||
|
||||
|
||||
# Convert manual.yml to our special markdown format
|
||||
markdown_data = convert_manual_to_markdown()
|
||||
|
||||
# Convert markdown to html
|
||||
html_data = markdown.markdown(markdown_data,
|
||||
extensions=[EscapeHtml(), 'fenced_code'])
|
||||
|
||||
# Parse the html into a tree so we can walk it
|
||||
tr = etree.HTML(html_data, etree.HTMLParser())
|
||||
|
||||
# Convert the markdown to ROFF
|
||||
RoffWalker(tr).walk()
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
import yaml
|
||||
|
||||
with open("content/manual/manual.yml") as f:
|
||||
manual = yaml.safe_load(f)
|
||||
for section in manual.get('sections', []):
|
||||
for entry in section.get('entries', []):
|
||||
for example in entry.get('examples', []):
|
||||
print(example.get('program', '').replace('\n', ' '))
|
||||
print(example.get('input', ''))
|
||||
for s in example.get('output', []):
|
||||
print(s)
|
||||
print('')
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
import glob
|
||||
import itertools
|
||||
from jinja2 import Environment, FileSystemLoader, Markup, select_autoescape, contextfunction
|
||||
from markdown import markdown
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import shutil
|
||||
import yaml
|
||||
|
||||
env = Environment(
|
||||
loader=FileSystemLoader('templates'),
|
||||
autoescape=select_autoescape(['html.j2']),
|
||||
)
|
||||
|
||||
|
||||
def load_yml_file(fn):
|
||||
with open(fn) as f:
|
||||
return yaml.safe_load(f)
|
||||
|
||||
|
||||
env.filters['search_id'] = lambda input: input.replace(r'`', '')
|
||||
env.filters['section_id'] = lambda input: re.sub(r"[^a-zA-Z0-9_]", '', input)
|
||||
env.filters['entry_id'] = lambda input: re.sub(r"[ `]", '', input)
|
||||
env.filters['markdownify'] = lambda input: Markup(markdown(input))
|
||||
env.filters['no_paragraph'] = lambda input: Markup(re.sub(r"</?p>", '', input))
|
||||
|
||||
env.globals['unique_id'] = contextfunction(
|
||||
lambda ctx: str(next(ctx['unique_ctr'])))
|
||||
|
||||
env.globals.update(load_yml_file('site.yml'))
|
||||
|
||||
env.globals['navigation'] = ['tutorial', 'download', 'manual']
|
||||
|
||||
|
||||
def generate_file(env, fname='content/1.tutorial/default.yml'):
|
||||
path, base = os.path.split(fname)
|
||||
path = os.path.relpath(path, 'content')
|
||||
if path == '.':
|
||||
path = ''
|
||||
slug = 'index'
|
||||
permalink = ''
|
||||
else:
|
||||
slug = os.path.basename(path)
|
||||
permalink = path + '/'
|
||||
|
||||
output_dir = os.path.join('output', path)
|
||||
output_path = os.path.join(output_dir, 'index.html')
|
||||
|
||||
template_name = re.sub(r".yml$", '.html.j2', base)
|
||||
|
||||
ctx = load_yml_file(fname)
|
||||
ctx.update(unique_ctr=itertools.count(1),
|
||||
permalink=permalink,
|
||||
slug=slug,
|
||||
navitem=path)
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
env.get_template(template_name).stream(ctx).dump(output_path,
|
||||
encoding='utf-8')
|
||||
|
||||
|
||||
def copy_public_files(root=''):
|
||||
for f in os.scandir(os.path.join('public', root)):
|
||||
src = os.path.join(root, f.name)
|
||||
dst = os.path.join('output', src)
|
||||
if f.is_dir():
|
||||
os.makedirs(dst, exist_ok=True)
|
||||
copy_public_files(src)
|
||||
else:
|
||||
shutil.copyfile(f.path, dst)
|
||||
|
||||
|
||||
copy_public_files()
|
||||
|
||||
for fn in glob.glob('content/**/*.yml', recursive=True):
|
||||
generate_file(env, fn)
|
||||
@@ -1,241 +0,0 @@
|
||||
headline: Tutorial
|
||||
body:
|
||||
- text: |
|
||||
|
||||
Twitter has a JSON API, so let's play with that. This URL gets
|
||||
us the last 5 tweets about JSON:
|
||||
|
||||
- command: "curl 'http://search.twitter.com/search.json?q=json&rpp=5&include_entities=true'"
|
||||
result: |
|
||||
{"completed_in":0.108,"max_id":247677287108067328,"max_id_str":"247677287108067328","next_page":"?page=2&max_id=247677287108067328&q=json&rpp=5&include_entities=1","page":1,"query":"json","refresh_url":"?since_id=247677287108067328&q=json&include_entities=1","results":[{"created_at":"Mon, 17 Sep 2012 12:44:01 +0000","entities":{"hashtags":[],"urls":[{"url":"http:\/\/t.co\/XRvh1ZVw","expanded_url":"http:\/\/jase.im\/Ri7I0M","display_url":"jase.im\/Ri7I0M","indices":[112,132]}],"user_mentions":[{"screen_name":"imagemechanics","name":"Jason Cotterell","id":57271393,"id_str":"57271393","indices":[3,18]}]},"from_user":"_AaronNg","from_user_id":79771704,"from_user_id_str":"79771704","from_user_name":"NgChenChong","geo":null,"id":247677287108067328,"id_str":"247677287108067328","iso_language_code":"en","metadata":{"result_type":"recent"},"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/2523558403\/ek8mo4j4beq84iw28gjl_normal.jpeg","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/2523558403\/ek8mo4j4beq84iw28gjl_normal.jpeg","source":"<a href="http:\/\/twitter.com\/">web<\/a>","text":"RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas>.\nhttp:\/\/t.co\/XRvh1ZVw","to_user":null,"to_user_id":0,"to_user_id_str":"0","to_user_name":null}, ...
|
||||
|
||||
- text: |
|
||||
|
||||
There's lots of info and no whitespace, so to make it a bit more
|
||||
legible we pipe it through jq, telling jq to just spit the input
|
||||
back at us using the expression `.`:
|
||||
|
||||
|
||||
- command: "curl 'http://search.twitter.com/search.json?q=json&rpp=5&include_entities=true' | jq '.'"
|
||||
result: |
|
||||
|
||||
{
|
||||
"since_id_str": "0",
|
||||
"since_id": 0,
|
||||
"results_per_page": 5,
|
||||
"completed_in": 0.108,
|
||||
"max_id": 247677287108067330,
|
||||
"max_id_str": "247677287108067328",
|
||||
"next_page": "?page=2&max_id=247677287108067328&q=json&rpp=5&include_entities=1",
|
||||
"page": 1,
|
||||
"query": "json",
|
||||
"refresh_url": "?since_id=247677287108067328&q=json&include_entities=1",
|
||||
"results": [
|
||||
{
|
||||
"from_user_name": "NgChenChong",
|
||||
"from_user_id_str": "79771704",
|
||||
"from_user_id": 79771704,
|
||||
"from_user": "_AaronNg",
|
||||
"iso_language_code": "en",
|
||||
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas>.\nhttp://t.co/XRvh1ZVw",
|
||||
"to_user": null
|
||||
/* lots more fields... */
|
||||
},
|
||||
/* lots more results... */
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
- text: |
|
||||
|
||||
Let's pull out the first tweet:
|
||||
|
||||
|
||||
- command: "curl 'http://search.twitter.com/search.json?q=json&rpp=5&include_entities=true' | jq '.results[0]'"
|
||||
result: |
|
||||
{
|
||||
"from_user_name": "NgChenChong",
|
||||
"from_user_id_str": "79771704",
|
||||
"from_user_id": 79771704,
|
||||
"from_user": "_AaronNg",
|
||||
"iso_language_code": "en",
|
||||
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas>.\nhttp://t.co/XRvh1ZVw",
|
||||
"to_user": null
|
||||
/* lots more fields... */
|
||||
},
|
||||
|
||||
- text: |
|
||||
|
||||
For the rest of the examples, I'll leave out the `curl` command - it's not going to change.
|
||||
|
||||
|
||||
There's still a lot of info we don't care about there, so we'll
|
||||
restrict it down to the most interesting fields.
|
||||
|
||||
|
||||
- command: "jq '.results[0] | {from_user, text}'"
|
||||
result: |
|
||||
{
|
||||
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas>.\nhttp://t.co/XRvh1ZVw",
|
||||
"from_user": "_AaronNg"
|
||||
}
|
||||
|
||||
- text: |
|
||||
|
||||
The `|` operator in jq feeds the output of one filter
|
||||
(`.results[0]` which gets the first element of the results
|
||||
array) into the input of another (`{from_user, text}` which
|
||||
builds an object of those two fields).
|
||||
|
||||
Now let's get the rest of the tweets:
|
||||
|
||||
|
||||
|
||||
- command: "jq '.results[] | {from_user, text}'"
|
||||
result: |
|
||||
{
|
||||
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas>.\nhttp://t.co/XRvh1ZVw",
|
||||
"from_user": "_AaronNg"
|
||||
}
|
||||
{
|
||||
"text": "RT @_kud: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas> -- http://t.co/Lhp92IqD",
|
||||
"from_user": "blouerat"
|
||||
}
|
||||
{
|
||||
"text": "Dynamic Forms Mobile App by pmadiset: Few Forms details are hosted on our server in the form of JSON. This JSON ... http://t.co/7KALdWaX",
|
||||
"from_user": "cebu_iphone"
|
||||
}
|
||||
{
|
||||
"text": "iPhone 5 website insanity - Video compressing using JPEG, JSON, and <canvas> http://t.co/28Jesbio (Oh #Apple, U So #Awesome...)",
|
||||
"from_user": "dieswaytoofast"
|
||||
}
|
||||
{
|
||||
"text": "RT @umutm: A very nice web-based JSON editor - http://t.co/M70snaIf",
|
||||
"from_user": "Leolik"
|
||||
}
|
||||
|
||||
|
||||
- text: |
|
||||
|
||||
`.results[]` returns each element of the results array, one at a
|
||||
time, which are all fed into `{from_user, text}`.
|
||||
|
||||
|
||||
Data in jq is represented as streams of JSON values - every jq
|
||||
expression runs for each value in its input stream, and can
|
||||
produce any number of values to its output stream.
|
||||
|
||||
Streams are serialised by just separating JSON values with
|
||||
whitespace. This is a `cat`-friendly format - you can just join
|
||||
two JSON streams together and get a valid JSON stream.
|
||||
|
||||
If you want to get the output as a single array, you can tell jq to
|
||||
"collect" all of the answers by wrapping the filter in square
|
||||
brackets:
|
||||
|
||||
- command: "jq '[.results[] | {from_user, text}]'"
|
||||
result: |
|
||||
[
|
||||
{
|
||||
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas>.\nhttp://t.co/XRvh1ZVw",
|
||||
"from_user": "_AaronNg"
|
||||
},
|
||||
{
|
||||
"text": "RT @_kud: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas> -- http://t.co/Lhp92IqD",
|
||||
"from_user": "blouerat"
|
||||
},
|
||||
{
|
||||
"text": "Dynamic Forms Mobile App by pmadiset: Few Forms details are hosted on our server in the form of JSON. This JSON ... http://t.co/7KALdWaX",
|
||||
"from_user": "cebu_iphone"
|
||||
},
|
||||
{
|
||||
"text": "iPhone 5 website insanity - Video compressing using JPEG, JSON, and <canvas> http://t.co/28Jesbio (Oh #Apple, U So #Awesome...)",
|
||||
"from_user": "dieswaytoofast"
|
||||
},
|
||||
{
|
||||
"text": "RT @umutm: A very nice web-based JSON editor - http://t.co/M70snaIf",
|
||||
"from_user": "Leolik"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
- text: |
|
||||
|
||||
- - -
|
||||
|
||||
Next, let's try getting the URLs out of those API results as
|
||||
well. In each tweet, the Twitter API includes a field called
|
||||
"entities" which looks like this:
|
||||
|
||||
{
|
||||
"user_mentions": [],
|
||||
"urls": [{
|
||||
"indices": [83, 103],
|
||||
"display_url": "bit.ly/StniqT",
|
||||
"expanded_url": "http://bit.ly/StniqT",
|
||||
"url": "http://t.co/28Jesbio"
|
||||
}],
|
||||
"hashtags": [
|
||||
{"indices": [108, 114], "text": "Apple" },
|
||||
{"indices": [121, 129], "text": "Awesome"}
|
||||
]
|
||||
}
|
||||
|
||||
We want to pull out all of the "url" fields inside that array of url
|
||||
objects, and make a simple list of strings to go along with the
|
||||
"from_user" and "text" fields we already have.
|
||||
|
||||
|
||||
|
||||
- command: "jq '.results[] | {from_user, text, urls: [.entities.urls[].url]}'"
|
||||
result: |
|
||||
{
|
||||
"urls": [
|
||||
"http://t.co/XRvh1ZVw"
|
||||
],
|
||||
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas>.\nhttp://t.co/XRvh1ZVw",
|
||||
"from_user": "_AaronNg"
|
||||
}
|
||||
{
|
||||
"urls": [
|
||||
"http://t.co/Lhp92IqD"
|
||||
],
|
||||
"text": "RT @_kud: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and <canvas> -- http://t.co/Lhp92IqD",
|
||||
"from_user": "blouerat"
|
||||
}
|
||||
{
|
||||
"urls": [
|
||||
"http://t.co/7KALdWaX"
|
||||
],
|
||||
"text": "Dynamic Forms Mobile App by pmadiset: Few Forms details are hosted on our server in the form of JSON. This JSON ... http://t.co/7KALdWaX",
|
||||
"from_user": "cebu_iphone"
|
||||
}
|
||||
{
|
||||
"urls": [
|
||||
"http://t.co/28Jesbio"
|
||||
],
|
||||
"text": "iPhone 5 website insanity - Video compressing using JPEG, JSON, and <canvas> http://t.co/28Jesbio (Oh #Apple, U So #Awesome...)",
|
||||
"from_user": "dieswaytoofast"
|
||||
}
|
||||
{
|
||||
"urls": [
|
||||
"http://t.co/M70snaIf"
|
||||
],
|
||||
"text": "RT @umutm: A very nice web-based JSON editor - http://t.co/M70snaIf",
|
||||
"from_user": "Leolik"
|
||||
}
|
||||
|
||||
|
||||
- text: |
|
||||
|
||||
Here we're making an object as before, but this time the urls
|
||||
field is being set to `[.entities.urls[].url]`, which collects
|
||||
all of the URLs defined in the entities object.
|
||||
|
||||
- text: |
|
||||
|
||||
- - -
|
||||
|
||||
Here endeth the tutorial! There's lots more to play with, go
|
||||
read [the manual](../manual/) if you're interested, and [download
|
||||
jq](../download/) if you haven't already.
|
||||
@@ -1,78 +0,0 @@
|
||||
headline: Download jq
|
||||
body:
|
||||
|
||||
- text: |
|
||||
|
||||
jq is written in C and has no runtime dependencies, so it should be
|
||||
possible to build it for nearly any platform. Prebuilt binaries are
|
||||
available for Linux, OS X and Windows.
|
||||
|
||||
The binaries should just run, but on OS X and Linux you may need
|
||||
to make them executable first using `chmod +x jq`.
|
||||
|
||||
jq is licensed under the MIT license. For all of the gory
|
||||
details, read the file `COPYING` in the source distribution.
|
||||
|
||||
|
||||
### Linux
|
||||
|
||||
* Binaries for [64-bit](linux64/jq) or [32-bit](linux32/jq) systems.
|
||||
|
||||
* For Arch users, a PKGBUILD for jq-1.1 is in the
|
||||
[AUR](https://aur.archlinux.org/packages.php?ID=63849), as
|
||||
well as a PKGBUILD for the HEAD of master
|
||||
([jq-git](https://aur.archlinux.org/packages.php?ID=63850)).
|
||||
You can install them using
|
||||
[Yaourt](https://wiki.archlinux.org/index.php/Yaourt) or
|
||||
manually by following instructions on [Arch Linux's
|
||||
Wiki](https://wiki.archlinux.org/index.php/Arch_UseRepository).
|
||||
|
||||
* Debian/Ubuntu packages are coming Real Soon Now.
|
||||
|
||||
### OS X
|
||||
|
||||
* `brew install jq` using [homebrew](http://mxcl.github.com/homebrew/)
|
||||
|
||||
* Or, grab prebuilt [64-bit binaries](osx64/jq) or [32-bit
|
||||
binaries](osx32/jq)
|
||||
|
||||
### Windows
|
||||
|
||||
* Executables for [64-bit](win64/jq.exe) or [32-bit](win32/jq.exe)
|
||||
|
||||
### From source on Linux or OS X
|
||||
|
||||
git clone https://github.com/stedolan/jq.git
|
||||
cd jq
|
||||
make && sudo make install
|
||||
|
||||
To build it from a git clone, you'll need to install a few
|
||||
packages first:
|
||||
|
||||
* [Flex](http://www.gnu.org/software/flex/)
|
||||
* [Bison](http://www.gnu.org/software/bison/)
|
||||
* [Python](http://www.python.org)
|
||||
* [GCC](http://gcc.gnu.org)
|
||||
* [Make](http://www.gnu.org/software/make)
|
||||
|
||||
For Linux systems, these will all be in your system's package
|
||||
manager, and if you do development on the machine they're most
|
||||
likely already installed.
|
||||
|
||||
On OS X, these are all included in Apple's command line tools, which
|
||||
can be installed from [Xcode](http://developer.apple.com/technologies/tools/).
|
||||
However, you may find that you need a newer version of Bison than the one provided
|
||||
by Apple. This can be found in [Homebrew](http://mxcl.github.com/homebrew/)
|
||||
or [MacPorts](http://macports.org/).
|
||||
|
||||
`flex` and `bison` are used to generate the lexer and parser for
|
||||
jq, and some python scripts generate the UTF8 encoding tables
|
||||
needed for JSON parsing.
|
||||
|
||||
#### Building the documentation
|
||||
|
||||
jq's documentation is compiled into static HTML using
|
||||
[Bonsai](http://www.tinytree.info). To view the documentation
|
||||
locally, run `rake serve` from the docs/ subdirectory.
|
||||
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
headline: Download jq
|
||||
body:
|
||||
- text: |
|
||||
|
||||
jq is written in C and has no runtime dependencies, so it should be
|
||||
possible to build it for nearly any platform. Prebuilt binaries are
|
||||
available for Linux, macOS and Windows.
|
||||
|
||||
The binaries should just run, but on macOS and Linux you may need
|
||||
to make them executable first using `chmod +x jq`.
|
||||
|
||||
jq is licensed under the MIT license. For all of the gory
|
||||
details, read the file `COPYING` in the source distribution.
|
||||
|
||||
jq uses a C library for decimal number support. This is an ICU 1.8.1
|
||||
licensed code obtained from the ICU downloads archive
|
||||
http://download.icu-project.org/files/decNumber/decNumber-icu-368.zip.
|
||||
|
||||
|
||||
### Linux
|
||||
|
||||
* jq is in the official [Debian](https://packages.debian.org/jq) and
|
||||
[Ubuntu](http://packages.ubuntu.com/jq) repositories. Install using
|
||||
`sudo apt-get install jq`.
|
||||
|
||||
* jq is in the official [Fedora](https://src.fedoraproject.org/rpms/jq) repository.
|
||||
Install using `sudo dnf install jq`.
|
||||
|
||||
* jq is in the official [openSUSE](https://software.opensuse.org/package/jq) repository.
|
||||
Install using `sudo zypper install jq`.
|
||||
|
||||
* jq is in the official [Arch](https://archlinux.org/packages/?q=jq) repository.
|
||||
Install using `sudo pacman -S jq`.
|
||||
|
||||
* jq 1.6 binaries for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux32).
|
||||
|
||||
* jq 1.5 binaries for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-linux64)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-linux32).
|
||||
|
||||
* jq 1.4 binaries for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-linux-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-linux-x86).
|
||||
|
||||
* jq 1.3 binaries for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-linux-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-linux-x86).
|
||||
|
||||
### macOS
|
||||
|
||||
* Use [Homebrew](http://brew.sh/) to install jq with `brew install jq`.
|
||||
|
||||
* Use [MacPorts](https://www.macports.org) to install jq with `port install jq`.
|
||||
|
||||
* Use [Fink](https://finkproject.org) to install jq with `fink install jq`.
|
||||
|
||||
* jq 1.6 binary for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-osx-amd64).
|
||||
|
||||
* jq 1.5 binary for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-osx-amd64).
|
||||
|
||||
* jq 1.4 binaries for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-osx-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-osx-x86).
|
||||
|
||||
* jq 1.3 binaries for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-osx-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-osx-x86).
|
||||
|
||||
### FreeBSD
|
||||
|
||||
* `pkg install jq` as root installs a pre-built
|
||||
[binary package](https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pkgng-intro.html).
|
||||
|
||||
* `make -C /usr/ports/textproc/jq install clean` as root installs the
|
||||
[jq](https://www.freshports.org/textproc/jq/)
|
||||
[port](https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html)
|
||||
from source.
|
||||
|
||||
### Solaris
|
||||
|
||||
* `pkgutil -i jq` in [OpenCSW](https://www.opencsw.org/p/jq) for Solaris
|
||||
10+, Sparc and x86.
|
||||
|
||||
* jq 1.4 binaries for Solaris 11
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-solaris11-64)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-solaris11-32).
|
||||
|
||||
### Windows
|
||||
* Use [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/)
|
||||
to install jq with `winget install jqlang.jq`.
|
||||
|
||||
* Use [scoop](https://scoop.sh/) to install jq with `scoop install jq`.
|
||||
|
||||
* Use [Chocolatey NuGet](https://chocolatey.org/) to install jq with
|
||||
`chocolatey install jq`.
|
||||
|
||||
* jq 1.6 executables for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win32.exe).
|
||||
|
||||
* jq 1.5 executables for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-win32.exe).
|
||||
|
||||
* jq 1.4 executables for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-win32.exe).
|
||||
|
||||
* jq 1.3 executables for
|
||||
[64-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-win32.exe).
|
||||
|
||||
### Checksums and signatures
|
||||
|
||||
SHA-256 checksums are provided for all release and pre-release binaries.
|
||||
They can be found under
|
||||
[sig/v1.x/sha256sum.txt](https://github.com/jqlang/jq/tree/master/sig).
|
||||
The checksums for jq 1.6 are in
|
||||
[sig/v1.6/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.6/sha256sum.txt).
|
||||
The checksums for jq 1.5 are in
|
||||
[sig/v1.5/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.5/sha256sum.txt).
|
||||
|
||||
Additionally, all binaries are signed by the
|
||||
[jq Package Signing Key](https://raw.githubusercontent.com/jqlang/jq/master/sig/jq-release.key).
|
||||
The signatures can be found under
|
||||
[sig/v1.x/\*.asc](https://github.com/jqlang/jq/tree/master/sig).
|
||||
The signatures for jq 1.6 are in
|
||||
[sig/v1.5/\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.6).
|
||||
The signatures for jq 1.5 are in
|
||||
[sig/v1.5/\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.5).
|
||||
You can use [GnuPG](https://gnupg.org/) to verify a signature by downloading
|
||||
the signature and running `gpg --verify signature.asc`.
|
||||
|
||||
### From source on Linux, macOS, Cygwin, and other POSIX-like operating systems
|
||||
|
||||
* [Source tarball for jq 1.6](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-1.6.tar.gz)
|
||||
* [Source tarball for jq 1.5](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-1.5.tar.gz)
|
||||
|
||||
You can build it using the usual `./configure && make && sudo
|
||||
make install` rigmarole.
|
||||
|
||||
If you're interested in using the lastest development version, try:
|
||||
|
||||
git clone --recursive https://github.com/jqlang/jq.git
|
||||
cd jq
|
||||
autoreconf -i
|
||||
./configure --disable-maintainer-mode
|
||||
make
|
||||
sudo make install
|
||||
|
||||
To build it from a git clone, you'll need to install a few
|
||||
packages first:
|
||||
|
||||
* [GCC](https://gcc.gnu.org)
|
||||
* [Make](https://www.gnu.org/software/make/)
|
||||
* [Autotools](https://www.gnu.org/software/automake/)
|
||||
|
||||
For Linux systems, these will all be in your system's package
|
||||
manager, and if you do development on the machine they're most
|
||||
likely already installed.
|
||||
|
||||
On macOS, these are all included in Apple's command line tools, which can
|
||||
be installed from [Xcode](https://developer.apple.com/xcode/). However,
|
||||
you may find that you need a newer version of Bison than the one provided
|
||||
by Apple. This can be found in [Homebrew](http://brew.sh) or
|
||||
[MacPorts](https://macports.org/).
|
||||
|
||||
The `--disable-maintainer-mode` flag says to use the pre-generated lexer
|
||||
and parser that come with the code. To compile the lexer and parser also
|
||||
from source, leave out this flag. You will need to install
|
||||
[Flex](https://github.com/westes/flex) and
|
||||
[Bison](https://www.gnu.org/software/bison/).
|
||||
|
||||
#### Building the documentation
|
||||
|
||||
jq's documentation is compiled into static HTML using Python.
|
||||
To build the docs, run `pipenv run python3 build_website.py` from
|
||||
the docs/ subdirectory. To serve them locally, you can run
|
||||
`python3 -m SimpleHTTPServer`. You'll need a few Python dependencies,
|
||||
which can be installed by following the instructions in `docs/README.md`.
|
||||
|
||||
The man page is built by `make jq.1`, or just `make`, also from
|
||||
the YAML docs, and you'll still need the Python dependencies to
|
||||
build the manpage.
|
||||
@@ -0,0 +1,72 @@
|
||||
headline: jq
|
||||
|
||||
blurb: |
|
||||
|
||||
jq is a lightweight and flexible command-line JSON processor.
|
||||
|
||||
body1: |
|
||||
|
||||
jq is like `sed` for JSON data - you can use it to slice and filter
|
||||
and map and transform structured data with the same ease that `sed`,
|
||||
`awk`, `grep` and friends let you play with text.
|
||||
|
||||
body2: |
|
||||
|
||||
jq is written in portable C, and it has zero runtime
|
||||
dependencies. You can download a single binary, `scp` it to a far away
|
||||
machine of the same type, and expect it to work.
|
||||
|
||||
body3: |
|
||||
|
||||
jq can mangle the data format that you have into the one that you
|
||||
want with very little effort, and the program to do so is often
|
||||
shorter and simpler than you'd expect.
|
||||
|
||||
tail: |
|
||||
|
||||
Go read the [tutorial](/jq/tutorial/) for more, or the [manual](/jq/manual/)
|
||||
for *way* more.
|
||||
|
||||
Ask questions on [stackoverflow](https://stackoverflow.com/) using the [jq
|
||||
tag](https://stackoverflow.com/questions/tagged/jq), or on the
|
||||
[#jq](https://web.libera.chat/#jq) channel on [Libera.Chat](https://libera.chat/).
|
||||
|
||||
news:
|
||||
- date: 1 November 2018
|
||||
body: |
|
||||
jq 1.6 released. See installation options on the [download](/jq/download/)
|
||||
page, and the [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.6)
|
||||
for details.
|
||||
|
||||
- date: 15 August 2015
|
||||
body: |
|
||||
|
||||
jq 1.5 released, including new datetime, math, and regexp functions,
|
||||
try/catch syntax, array and object destructuring, a streaming parser,
|
||||
and a module system. See installation options on the
|
||||
[download](/jq/download/) page, and the
|
||||
[release notes](https://github.com/jqlang/jq/releases/tag/jq-1.5)
|
||||
for details.
|
||||
|
||||
- date: 26 July 2015
|
||||
body: |
|
||||
|
||||
jq 1.5rc2 is available. Get it on the
|
||||
[releases](https://github.com/jqlang/jq/releases) page.
|
||||
|
||||
- date: 01 January 2015
|
||||
body: |
|
||||
|
||||
jq 1.5rc1 is available. Get it on the
|
||||
[releases](https://github.com/jqlang/jq/releases) page.
|
||||
|
||||
- date: 09 June 2014
|
||||
body: |
|
||||
|
||||
jq 1.4 (finally) released! Get it on the [download](/jq/download/) page.
|
||||
|
||||
- date: 19 May 2013
|
||||
body: |
|
||||
|
||||
jq 1.3 released.
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
headline: jq
|
||||
|
||||
blurb: |
|
||||
|
||||
jq is a lightweight and flexible command-line JSON processor.
|
||||
|
||||
body1: |
|
||||
|
||||
jq is like `sed` for JSON data - you can use it to slice and filter
|
||||
and map and transform structured data with the same ease that `sed`,
|
||||
`awk`, `grep` and friends let you play with text.
|
||||
|
||||
body2: |
|
||||
|
||||
jq is written in portable C, and it has zero runtime
|
||||
dependencies. You can download a single binary, `scp` it to a far away
|
||||
machine, and expect it to work.
|
||||
|
||||
body3: |
|
||||
|
||||
jq can mangle the data format that you have into the one that you
|
||||
want with very little effort, and the program to do so is often
|
||||
shorter and simpler than you'd expect.
|
||||
|
||||
tail: |
|
||||
Go read the [tutorial](tutorial/) for more, or the [manual](manual/)
|
||||
for *way* more.
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,337 @@
|
||||
headline: Tutorial
|
||||
body:
|
||||
- text: |
|
||||
|
||||
GitHub has a JSON API, so let's play with that. This URL gets us the last
|
||||
5 commits from the jq repo.
|
||||
|
||||
- command: "curl 'https://api.github.com/repos/jqlang/jq/commits?per_page=5'"
|
||||
result: |
|
||||
[
|
||||
{
|
||||
"sha": "cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"node_id": "C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "Mattias Wadman",
|
||||
"email": "mattias.wadman@gmail.com",
|
||||
"date": "2021-06-09T14:02:22Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "Nico Williams",
|
||||
"email": "nico@cryptonector.com",
|
||||
"date": "2022-05-26T21:04:32Z"
|
||||
},
|
||||
"message": "docs: Document repeat(exp)",
|
||||
"tree": {
|
||||
"sha": "d67d5542df1f16d1a48e1fb75749f60482cd874b",
|
||||
"url": "https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b"
|
||||
},
|
||||
"url": "https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": false,
|
||||
"reason": "unsigned",
|
||||
"signature": null,
|
||||
"payload": null
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"html_url": "https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"comments_url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments",
|
||||
"author": {
|
||||
...
|
||||
|
||||
- text: |
|
||||
|
||||
GitHub returns nicely formatted JSON. For servers that don't, it can be
|
||||
helpful to pipe the response through jq to pretty-print it. The simplest
|
||||
jq program is the expression `.`, which takes the input and produces it
|
||||
unchanged as output.
|
||||
|
||||
- command: "curl 'https://api.github.com/repos/jqlang/jq/commits?per_page=5' | jq '.'"
|
||||
result: |
|
||||
[
|
||||
{
|
||||
"sha": "cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"node_id": "C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "Mattias Wadman",
|
||||
"email": "mattias.wadman@gmail.com",
|
||||
"date": "2021-06-09T14:02:22Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "Nico Williams",
|
||||
"email": "nico@cryptonector.com",
|
||||
"date": "2022-05-26T21:04:32Z"
|
||||
},
|
||||
"message": "docs: Document repeat(exp)",
|
||||
"tree": {
|
||||
"sha": "d67d5542df1f16d1a48e1fb75749f60482cd874b",
|
||||
"url": "https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b"
|
||||
},
|
||||
"url": "https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": false,
|
||||
"reason": "unsigned",
|
||||
"signature": null,
|
||||
"payload": null
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"html_url": "https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"comments_url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments",
|
||||
"author": {
|
||||
...
|
||||
|
||||
- text: |
|
||||
|
||||
We can use jq to extract just the first commit.
|
||||
|
||||
- command: "curl 'https://api.github.com/repos/jqlang/jq/commits?per_page=5' | jq '.[0]'"
|
||||
result: |
|
||||
{
|
||||
"sha": "cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"node_id": "C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "Mattias Wadman",
|
||||
"email": "mattias.wadman@gmail.com",
|
||||
"date": "2021-06-09T14:02:22Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "Nico Williams",
|
||||
"email": "nico@cryptonector.com",
|
||||
"date": "2022-05-26T21:04:32Z"
|
||||
},
|
||||
"message": "docs: Document repeat(exp)",
|
||||
"tree": {
|
||||
"sha": "d67d5542df1f16d1a48e1fb75749f60482cd874b",
|
||||
"url": "https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b"
|
||||
},
|
||||
"url": "https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": false,
|
||||
"reason": "unsigned",
|
||||
"signature": null,
|
||||
"payload": null
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"html_url": "https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8",
|
||||
"comments_url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments",
|
||||
"author": {
|
||||
"login": "wader",
|
||||
"id": 185566,
|
||||
"node_id": "MDQ6VXNlcjE4NTU2Ng==",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/185566?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/wader",
|
||||
"html_url": "https://github.com/wader",
|
||||
"followers_url": "https://api.github.com/users/wader/followers",
|
||||
"following_url": "https://api.github.com/users/wader/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/wader/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/wader/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/wader/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/wader/orgs",
|
||||
"repos_url": "https://api.github.com/users/wader/repos",
|
||||
"events_url": "https://api.github.com/users/wader/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/wader/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"committer": {
|
||||
"login": "nicowilliams",
|
||||
"id": 604851,
|
||||
"node_id": "MDQ6VXNlcjYwNDg1MQ==",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/604851?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/nicowilliams",
|
||||
"html_url": "https://github.com/nicowilliams",
|
||||
"followers_url": "https://api.github.com/users/nicowilliams/followers",
|
||||
"following_url": "https://api.github.com/users/nicowilliams/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/nicowilliams/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/nicowilliams/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/nicowilliams/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/nicowilliams/orgs",
|
||||
"repos_url": "https://api.github.com/users/nicowilliams/repos",
|
||||
"events_url": "https://api.github.com/users/nicowilliams/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/nicowilliams/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"parents": [
|
||||
{
|
||||
"sha": "f2ad9517c72f6267ae317639ab56bbfd4a8653d4",
|
||||
"url": "https://api.github.com/repos/jqlang/jq/commits/f2ad9517c72f6267ae317639ab56bbfd4a8653d4",
|
||||
"html_url": "https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
- text: |
|
||||
|
||||
For the rest of the examples, I'll leave out the `curl` command - it's not
|
||||
going to change.
|
||||
|
||||
There's a lot of info we don't care about there, so we'll restrict it down
|
||||
to the most interesting fields.
|
||||
|
||||
- command: "jq '.[0] | {message: .commit.message, name: .commit.committer.name}'"
|
||||
result: |
|
||||
{
|
||||
"message": "docs: Document repeat(exp)",
|
||||
"name": "Nico Williams"
|
||||
}
|
||||
|
||||
- text: |
|
||||
|
||||
The `|` operator in jq feeds the output of one filter (`.[0]` which gets
|
||||
the first element of the array in the response) into the input of another
|
||||
(`{...}` which builds an object out of those fields). You can access
|
||||
nested attributes, such as `.commit.message`.
|
||||
|
||||
Now let's get the rest of the commits.
|
||||
|
||||
- command: "jq '.[] | {message: .commit.message, name: .commit.committer.name}'"
|
||||
result: |
|
||||
{
|
||||
"message": "docs: Document repeat(exp)",
|
||||
"name": "Nico Williams"
|
||||
}
|
||||
{
|
||||
"message": "Mention -n in IO-section and for input/inputs",
|
||||
"name": "Nico Williams"
|
||||
}
|
||||
{
|
||||
"message": "Fix iterration problem for non decimal string\n\nWhen the string transformation to number failed, all following\ntransformation failed too.\n\nThis happend because status in decNumberFromString function is\nupdated just in error case. Reusing the DEC_CONTEXT that failed\nbefore results into error even if the string is valid number.",
|
||||
"name": "Nico Williams"
|
||||
}
|
||||
{
|
||||
"message": "docs: point to Libera.Chat instead of Freenode",
|
||||
"name": "Nico Williams"
|
||||
}
|
||||
{
|
||||
"message": "Missing \"va_end\" call. This was found by running the cppcheck static analysis where it shows as error.",
|
||||
"name": "Nico Williams"
|
||||
}
|
||||
|
||||
- text: |
|
||||
|
||||
`.[]` returns each element of the array returned in the response, one at a
|
||||
time, which are all fed into
|
||||
`{message: .commit.message, name: .commit.committer.name}`.
|
||||
|
||||
Data in jq is represented as streams of JSON values - every jq
|
||||
expression runs for each value in its input stream, and can
|
||||
produce any number of values to its output stream.
|
||||
|
||||
Streams are serialised by just separating JSON values with
|
||||
whitespace. This is a `cat`-friendly format - you can just join
|
||||
two JSON streams together and get a valid JSON stream.
|
||||
|
||||
If you want to get the output as a single array, you can tell jq to
|
||||
"collect" all of the answers by wrapping the filter in square
|
||||
brackets:
|
||||
|
||||
- command: "jq '[.[] | {message: .commit.message, name: .commit.committer.name}]'"
|
||||
result: |
|
||||
[
|
||||
{
|
||||
"message": "docs: Document repeat(exp)",
|
||||
"name": "Nico Williams"
|
||||
},
|
||||
{
|
||||
"message": "Mention -n in IO-section and for input/inputs",
|
||||
"name": "Nico Williams"
|
||||
},
|
||||
{
|
||||
"message": "Fix iterration problem for non decimal string\n\nWhen the string transformation to number failed, all following\ntransformation failed too.\n\nThis happend because status in decNumberFromString function is\nupdated just in error case. Reusing the DEC_CONTEXT that failed\nbefore results into error even if the string is valid number.",
|
||||
"name": "Nico Williams"
|
||||
},
|
||||
{
|
||||
"message": "docs: point to Libera.Chat instead of Freenode",
|
||||
"name": "Nico Williams"
|
||||
},
|
||||
{
|
||||
"message": "Missing \"va_end\" call. This was found by running the cppcheck static analysis where it shows as error.",
|
||||
"name": "Nico Williams"
|
||||
}
|
||||
]
|
||||
|
||||
- text: |
|
||||
|
||||
- - -
|
||||
|
||||
Next, let's try getting the URLs of the parent commits out of the
|
||||
API results as well. In each commit, the GitHub API includes information
|
||||
about "parent" commits. There can be one or many.
|
||||
|
||||
"parents": [
|
||||
{
|
||||
"sha": "f2ad9517c72f6267ae317639ab56bbfd4a8653d4",
|
||||
"url": "https://api.github.com/repos/jqlang/jq/commits/f2ad9517c72f6267ae317639ab56bbfd4a8653d4",
|
||||
"html_url": "https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4"
|
||||
}
|
||||
]
|
||||
|
||||
We want to pull out all of the "html_url" fields inside that array of parent
|
||||
commits and make a simple list of strings to go along with the
|
||||
"message" and "author" fields we already have.
|
||||
|
||||
- command: "jq '[.[] | {message: .commit.message, name: .commit.committer.name, parents: [.parents[].html_url]}]'"
|
||||
result: |
|
||||
[
|
||||
{
|
||||
"message": "docs: Document repeat(exp)",
|
||||
"name": "Nico Williams",
|
||||
"parents": [
|
||||
"https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4"
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": "Mention -n in IO-section and for input/inputs",
|
||||
"name": "Nico Williams",
|
||||
"parents": [
|
||||
"https://github.com/jqlang/jq/commit/c4d39c4d22f2b12225ca1b311708f7e084ad9ff8"
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": "Fix iterration problem for non decimal string\n\nWhen the string transformation to number failed, all following\ntransformation failed too.\n\nThis happend because status in decNumberFromString function is\nupdated just in error case. Reusing the DEC_CONTEXT that failed\nbefore results into error even if the string is valid number.",
|
||||
"name": "Nico Williams",
|
||||
"parents": [
|
||||
"https://github.com/jqlang/jq/commit/174db0f93552bdb551ae1f3c5c64744df0ad8e2f"
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": "docs: point to Libera.Chat instead of Freenode",
|
||||
"name": "Nico Williams",
|
||||
"parents": [
|
||||
"https://github.com/jqlang/jq/commit/29cf77977ef52eec708982b19bf9d2ec17443337"
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": "Missing \"va_end\" call. This was found by running the cppcheck static analysis where it shows as error.",
|
||||
"name": "Nico Williams",
|
||||
"parents": [
|
||||
"https://github.com/jqlang/jq/commit/55e6e2c21829bd866bd4b18ee254b05c9020320a"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
- text: |
|
||||
|
||||
Here we're making an object as before, but this time the `parents`
|
||||
field is being set to `[.parents[].html_url]`, which collects
|
||||
all of the parent commit URLs defined in the parents object.
|
||||
|
||||
- text: |
|
||||
|
||||
- - -
|
||||
|
||||
Here endeth the tutorial! There's lots more to play with. Go
|
||||
read [the manual](../manual/) if you're interested, and [download
|
||||
jq](../download/) if you haven't already.
|
||||
@@ -1,22 +0,0 @@
|
||||
jq(1) -- Command-line JSON processor
|
||||
====================================
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
`jq` can transform JSON in various ways, by selecting, iterating,
|
||||
reducing and otherwise mangling JSON documents.
|
||||
|
||||
This version of `jq` was built without a manual, so this manpage is a
|
||||
stub. For full documentation of the `jq` language, see:
|
||||
|
||||
http://stedolan.github.com/jq
|
||||
|
||||
## BUGS
|
||||
|
||||
Presumably. Report them or discuss them at:
|
||||
|
||||
https://github.com/stedolan/jq/issues
|
||||
|
||||
## AUTHOR
|
||||
|
||||
Stephen Dolan `<mu@netsoc.tcd.ie>`
|
||||
@@ -12,7 +12,7 @@ FileETag All
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
|
||||
# Cache, aggressively
|
||||
# Cache, aggressively
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive On
|
||||
ExpiresDefault "access plus 10 days"
|
||||
@@ -25,4 +25,4 @@ FileETag All
|
||||
# Mime-types
|
||||
AddType application/vnd.ms-fontobject .eot
|
||||
AddType font/ttf .ttf
|
||||
AddType font/otf .otf
|
||||
AddType font/otf .otf
|
||||
-1058
File diff suppressed because it is too large.
Load diff
@@ -1,9 +0,0 @@
|
||||
/*!
|
||||
* Bootstrap Responsive v2.1.1
|
||||
*
|
||||
* Copyright 2012 Twitter, Inc
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
*/.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}.visible-desktop{display:inherit!important}@media(min-width:768px) and (max-width:979px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}}@media(max-width:767px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-phone{display:inherit!important}.hidden-phone{display:none!important}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:30px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.564102564102564%;*margin-left:2.5109110747408616%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145299145%;*width:91.39979996362975%}.row-fluid .span10{width:82.90598290598291%;*width:82.8527914166212%}.row-fluid .span9{width:74.35897435897436%;*width:74.30578286961266%}.row-fluid .span8{width:65.81196581196582%;*width:65.75877432260411%}.row-fluid .span7{width:57.26495726495726%;*width:57.21176577559556%}.row-fluid .span6{width:48.717948717948715%;*width:48.664757228587014%}.row-fluid .span5{width:40.17094017094017%;*width:40.11774868157847%}.row-fluid .span4{width:31.623931623931625%;*width:31.570740134569924%}.row-fluid .span3{width:23.076923076923077%;*width:23.023731587561375%}.row-fluid .span2{width:14.52991452991453%;*width:14.476723040552828%}.row-fluid .span1{width:5.982905982905983%;*width:5.929714493544281%}.row-fluid .offset12{margin-left:105.12820512820512%;*margin-left:105.02182214948171%}.row-fluid .offset12:first-child{margin-left:102.56410256410257%;*margin-left:102.45771958537915%}.row-fluid .offset11{margin-left:96.58119658119658%;*margin-left:96.47481360247316%}.row-fluid .offset11:first-child{margin-left:94.01709401709402%;*margin-left:93.91071103837061%}.row-fluid .offset10{margin-left:88.03418803418803%;*margin-left:87.92780505546462%}.row-fluid .offset10:first-child{margin-left:85.47008547008548%;*margin-left:85.36370249136206%}.row-fluid .offset9{margin-left:79.48717948717949%;*margin-left:79.38079650845607%}.row-fluid .offset9:first-child{margin-left:76.92307692307693%;*margin-left:76.81669394435352%}.row-fluid .offset8{margin-left:70.94017094017094%;*margin-left:70.83378796144753%}.row-fluid .offset8:first-child{margin-left:68.37606837606839%;*margin-left:68.26968539734497%}.row-fluid .offset7{margin-left:62.393162393162385%;*margin-left:62.28677941443899%}.row-fluid .offset7:first-child{margin-left:59.82905982905982%;*margin-left:59.72267685033642%}.row-fluid .offset6{margin-left:53.84615384615384%;*margin-left:53.739770867430444%}.row-fluid .offset6:first-child{margin-left:51.28205128205128%;*margin-left:51.175668303327875%}.row-fluid .offset5{margin-left:45.299145299145295%;*margin-left:45.1927623204219%}.row-fluid .offset5:first-child{margin-left:42.73504273504273%;*margin-left:42.62865975631933%}.row-fluid .offset4{margin-left:36.75213675213675%;*margin-left:36.645753773413354%}.row-fluid .offset4:first-child{margin-left:34.18803418803419%;*margin-left:34.081651209310785%}.row-fluid .offset3{margin-left:28.205128205128204%;*margin-left:28.0987452264048%}.row-fluid .offset3:first-child{margin-left:25.641025641025642%;*margin-left:25.53464266230224%}.row-fluid .offset2{margin-left:19.65811965811966%;*margin-left:19.551736679396257%}.row-fluid .offset2:first-child{margin-left:17.094017094017094%;*maLine truncated
|
||||
-5224
File diff suppressed because it is too large.
Load diff
-9
@@ -1,9 +0,0 @@
|
||||
/*!
|
||||
* Bootstrap v2.1.1
|
||||
*
|
||||
* Copyright 2012 Twitter, Inc
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
*/article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{width:auto\9;height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.914893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.840425531914894%}.row-fluid .span1{width:6.382978723404255%;*width:6.329787234042553%}.row-fluid .offset12{margin-left:104.25531914893617%;*margin-left:104.14893617021275%}.row-fluid .offset12:first-child{margin-left:102.12765957446808%;*margin-left:102.02127659574467%}.row-fluid .offset11{margin-left:95.74468085106382%;*margin-left:95.6382978723404%}.row-fluid .offset11:first-child{margin-left:93.61702127659574%;*margin-left:93.51063829787232%}.row-fluid .offset10{margin-left:87.23404255319149%;*margin-left:87.12765957446807%}.row-fluid .offset10:first-child{margin-left:85.1063829787234%;*margin-left:84.99999999999999%}.row-fluid .offset9{margin-left:78.72340425531914%;*margin-left:78.61702127659572%}.row-fluid .offset9:first-child{margin-left:76.59574468085106%;*margin-left:76.48936170212764%}.row-fluiLine truncated
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
-2027
File diff suppressed because it is too large.
Load diff
-6
@@ -1,6 +0,0 @@
|
||||
/*!
|
||||
* Bootstrap.js by @fat & @mdo
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*/
|
||||
!function(e){e(function(){"use strict";e.support.transition=function(){var e=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},n;for(n in t)if(e.style[n]!==undefined)return t[n]}();return e&&{end:e}}()})}(window.jQuery),!function(e){"use strict";var t='[data-dismiss="alert"]',n=function(n){e(n).on("click",t,this.close)};n.prototype.close=function(t){function s(){i.trigger("closed").remove()}var n=e(this),r=n.attr("data-target"),i;r||(r=n.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,"")),i=e(r),t&&t.preventDefault(),i.length||(i=n.hasClass("alert")?n:n.parent()),i.trigger(t=e.Event("close"));if(t.isDefaultPrevented())return;i.removeClass("in"),e.support.transition&&i.hasClass("fade")?i.on(e.support.transition.end,s):s()},e.fn.alert=function(t){return this.each(function(){var r=e(this),i=r.data("alert");i||r.data("alert",i=new n(this)),typeof t=="string"&&i[t].call(r)})},e.fn.alert.Constructor=n,e(function(){e("body").on("click.alert.data-api",t,n.prototype.close)})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.button.defaults,n)};t.prototype.setState=function(e){var t="disabled",n=this.$element,r=n.data(),i=n.is("input")?"val":"html";e+="Text",r.resetText||n.data("resetText",n[i]()),n[i](r[e]||this.options[e]),setTimeout(function(){e=="loadingText"?n.addClass(t).attr(t,t):n.removeClass(t).removeAttr(t)},0)},t.prototype.toggle=function(){var e=this.$element.closest('[data-toggle="buttons-radio"]');e&&e.find(".active").removeClass("active"),this.$element.toggleClass("active")},e.fn.button=function(n){return this.each(function(){var r=e(this),i=r.data("button"),s=typeof n=="object"&&n;i||r.data("button",i=new t(this,s)),n=="toggle"?i.toggle():n&&i.setState(n)})},e.fn.button.defaults={loadingText:"loading..."},e.fn.button.Constructor=t,e(function(){e("body").on("click.button.data-api","[data-toggle^=button]",function(t){var n=e(t.target);n.hasClass("btn")||(n=n.closest(".btn")),n.button("toggle")})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=n,this.options.slide&&this.slide(this.options.slide),this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.prototype={cycle:function(t){return t||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},to:function(t){var n=this.$element.find(".item.active"),r=n.parent().children(),i=r.index(n),s=this;if(t>r.length-1||t<0)return;return this.sliding?this.$element.one("slid",function(){s.to(t)}):i==t?this.pause().cycle():this.slide(t>i?"next":"prev",e(r[t]))},pause:function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition.end&&(this.$element.trigger(e.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f=e.Event("slide",{relatedTarget:i[0]});this.sliding=!0,s&&this.pause(),i=i.length?i:this.$element.find(".item")[u]();if(i.hasClass("active"))return;if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t),i[0].offsetWidth,r.addClass(o),i.addClass(o),this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active"),r.removeClass(["active",o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("active"),i.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}},e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.cycle()})},e.fn.carousel.defaults={interval:5e3,pause:"hover"},e.fn.carousel.Constructor=t,e(function(){e("body").on("click.carousel.data-api","[data-slide]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=!i.data("modal")&&e.extend({},i.data(),n.data());i.carousel(s),t.preventDefault()})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.collapse.defaults,n),this.options.parent&&(this.$parent=e(this.options.parent)),this.options.toggle&&this.toggle()};t.prototype={constructor:t,dimension:function(){var e=this.$element.hLine truncated
|
||||
@@ -0,0 +1,173 @@
|
||||
body {
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 970px;
|
||||
}
|
||||
|
||||
/* index.liquid *******************************************/
|
||||
#blurb {
|
||||
padding-top: 40px;
|
||||
}
|
||||
#blurb p {
|
||||
font-size: 1.9em;
|
||||
}
|
||||
#blurb .btn-group {
|
||||
margin: 4px;
|
||||
}
|
||||
|
||||
#multiblurb {
|
||||
line-height: 1.7;
|
||||
text-align: center;
|
||||
font-size: 12pt;
|
||||
}
|
||||
#multiblurb code {
|
||||
border: 0;
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
#news {
|
||||
font-size: 12pt;
|
||||
}
|
||||
#news .date {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* default.liquid *****************************************/
|
||||
.tutorial-example {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.tutorial-example pre {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.tutorial-example a {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
padding: 15px 8px;
|
||||
color: #777777;
|
||||
font-weight: bold;
|
||||
line-height: 10px;
|
||||
font-size: 12px;
|
||||
border-left: 1px solid #DDDDDD;
|
||||
display: block;
|
||||
}
|
||||
.tutorial-example .accordion-body pre {
|
||||
margin: 0 4px;
|
||||
border-top: 0;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.tutorial-example a {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
/* manual.liquid ******************************************/
|
||||
section {
|
||||
padding-top: 24px;
|
||||
}
|
||||
|
||||
h3 code {
|
||||
border: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
@media (max-width: 991px) {
|
||||
#navcolumn {
|
||||
/* Put nav column above manual content */
|
||||
position: relative !important;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
#manualcontent {
|
||||
/* Put nav column left of manual content */
|
||||
padding-left: 280px;
|
||||
}
|
||||
}
|
||||
.nav-pills {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.nav-pills li a {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.manual-example table {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
.manual-example table td {
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
|
||||
}
|
||||
.manual-example table td.jqprogram {
|
||||
font-weight: bold;
|
||||
}
|
||||
.manual-example table th {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
@media print {
|
||||
#navcolumn {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.manual-example {
|
||||
display: block !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.jqplay-btn {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
/* shared/_footer.liquid **********************************/
|
||||
footer {
|
||||
background-color: #F5F5F5;
|
||||
padding: 20px 0;
|
||||
margin-top: 40px;
|
||||
color: #999999;
|
||||
text-align: center;
|
||||
}
|
||||
footer p {
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
/* typeahead **********************************************/
|
||||
.twitter-typeahead {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tt-menu {
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
padding: 8px 0;
|
||||
border: 1px solid #ccc;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
-webkit-border-radius: 8px;
|
||||
-moz-border-radius: 8px;
|
||||
border-radius: 8px;
|
||||
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.tt-suggestion {
|
||||
padding: 3px 20px;
|
||||
}
|
||||
.tt-suggestion:hover {
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
background-color: #446e9b;
|
||||
}
|
||||
.tt-suggestion.tt-cursor {
|
||||
color: #fff;
|
||||
background-color: #446e9b;
|
||||
}
|
||||
.tt-suggestion p {
|
||||
margin: 0;
|
||||
}
|
||||
+154
-65
@@ -1,85 +1,79 @@
|
||||
@charset "utf-8";
|
||||
body {
|
||||
padding-top: 60px;
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
footer {
|
||||
background-color: #F5F5F5;
|
||||
padding: 40px 0;
|
||||
height: 100px;
|
||||
margin-top: 40px;
|
||||
color: #999999;
|
||||
.container {
|
||||
max-width: 970px;
|
||||
}
|
||||
|
||||
section {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.manual-example {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
|
||||
.manual-example td {
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
|
||||
}
|
||||
|
||||
.manual-example td.jqprogram {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.manual-example th {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.tutorial-example {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.tutorial-example pre {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.tutorial-example a {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
padding: 15px 8px;
|
||||
color: #777777;
|
||||
font-weight: bold;
|
||||
line-height: 10px;
|
||||
font-size: 12px;
|
||||
border-left: 1px solid #DDDDDD;
|
||||
bottom: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
/* index.liquid *******************************************/
|
||||
|
||||
#blurb {
|
||||
padding-top: 40px;
|
||||
padding-right: 50px;
|
||||
}
|
||||
|
||||
#blurb p {
|
||||
font-size: 20pt;
|
||||
}
|
||||
|
||||
#blurb .btn-group {
|
||||
margin-top: 20px;
|
||||
p {
|
||||
font-size: 1.9em;
|
||||
}
|
||||
.btn-group {
|
||||
margin: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
#multiblurb {
|
||||
line-height: 1.7;
|
||||
text-align: center;
|
||||
font-size: 12pt;
|
||||
code {
|
||||
border: 0;
|
||||
font-size: 12pt;
|
||||
}
|
||||
}
|
||||
|
||||
#multiblurb code {
|
||||
border: 0;
|
||||
#news {
|
||||
font-size: 12pt;
|
||||
.date {
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
||||
/* default.liquid *****************************************/
|
||||
|
||||
.tutorial-example {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
pre {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
a {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
padding: 15px 8px;
|
||||
color: #777777;
|
||||
font-weight: bold;
|
||||
line-height: 10px;
|
||||
font-size: 12px;
|
||||
border-left: 1px solid #DDDDDD;
|
||||
display: block;
|
||||
}
|
||||
.accordion-body pre {
|
||||
margin: 0 4px;
|
||||
border-top: 0;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
.tutorial-example a {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* manual.liquid ******************************************/
|
||||
|
||||
section {
|
||||
padding-top: 24px;
|
||||
}
|
||||
|
||||
h3 code {
|
||||
@@ -87,6 +81,101 @@ h3 code {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
@media(max-width: 991px){
|
||||
#navcolumn {
|
||||
/* Put nav column above manual content */
|
||||
position: relative !important;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
}
|
||||
|
||||
@media(min-width: 992px) {
|
||||
#manualcontent {
|
||||
/* Put nav column left of manual content */
|
||||
padding-left: 280px;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-pills {
|
||||
li a {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.manual-example table {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
td {
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
|
||||
}
|
||||
td.jqprogram {
|
||||
font-weight: bold;
|
||||
}
|
||||
th {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
#navcolumn {
|
||||
display: none !important;
|
||||
}
|
||||
.manual-example {
|
||||
display: block !important;
|
||||
height: auto !important;
|
||||
}
|
||||
.jqplay-btn {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* shared/_footer.liquid **********************************/
|
||||
|
||||
footer {
|
||||
background-color: #F5F5F5;
|
||||
padding: 20px 0;
|
||||
margin-top: 40px;
|
||||
color: #999999;
|
||||
text-align: center;
|
||||
}
|
||||
p {
|
||||
margin: 8px 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* typeahead **********************************************/
|
||||
|
||||
.twitter-typeahead {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tt-menu {
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
padding: 8px 0;
|
||||
border: 1px solid #ccc;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
-webkit-border-radius: 8px;
|
||||
-moz-border-radius: 8px;
|
||||
border-radius: 8px;
|
||||
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
.tt-suggestion {
|
||||
padding: 3px 20px;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
background-color: #446e9b;
|
||||
}
|
||||
&.tt-cursor {
|
||||
color: #fff;
|
||||
background-color: #446e9b;
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
var section_names = function(q) {
|
||||
if (!q) {
|
||||
return [];
|
||||
}
|
||||
var matches = [];
|
||||
q = q.toLowerCase();
|
||||
$.each(section_map, function(k, v) {
|
||||
if (k.toLowerCase().indexOf(q) != -1) {
|
||||
matches.push(k);
|
||||
}
|
||||
});
|
||||
matches.sort(function(a, b) {
|
||||
// shortest to longest
|
||||
return a.length - b.length;
|
||||
});
|
||||
return matches;
|
||||
}
|
||||
var section_names_cb = function(q, cb) {
|
||||
cb(section_names(q));
|
||||
}
|
||||
var go_to_section = function() {
|
||||
query = $('#searchbox').val();
|
||||
results = section_names(query);
|
||||
if (results.length == 0) {
|
||||
return;
|
||||
}
|
||||
result = results[0];
|
||||
location.hash = '#' + section_map[result];
|
||||
if (result != query) {
|
||||
$('#searchbox').val(result);
|
||||
}
|
||||
}
|
||||
$(function(){
|
||||
$('#searchbox').typeahead(
|
||||
{hint: false, highlight: true, minLength: 1},
|
||||
{name: "contents", source: section_names_cb, limit: 6}
|
||||
).on('typeahead:selected', function(e, data) {
|
||||
go_to_section();
|
||||
});
|
||||
$('#searchbox').change(go_to_section);
|
||||
});
|
||||
// add "Run" button to execute examples on jqplay.org
|
||||
$(function() {
|
||||
$.each($('.manual-example table'), function(index, value) {
|
||||
$value = $(value)
|
||||
var j = $value.find('tr:nth-child(2) td:first').text();
|
||||
var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/(\r\n|\n|\r)/gm," ").replace(/^'(.+)'$/, '$1');
|
||||
var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)
|
||||
var $last_tr = $value.find('tr:last');
|
||||
$last_tr.after('<tr class="jqplay-btn"><th><a href="' + url + '" class="btn btn-primary btn-sm">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');
|
||||
});
|
||||
});
|
||||
+2
-11
@@ -1,18 +1,9 @@
|
||||
# The key value pairs found below are available within the templates.
|
||||
|
||||
:url: http://stedolan.github.io/jq
|
||||
url: https://jqlang.github.io/jq
|
||||
|
||||
# This line is modified by the Makefile. To change the version number,
|
||||
# edit the Autoconf version number at the top of configure.ac
|
||||
jq_version: 1.2
|
||||
jq_version: "1.6-159-gcff5336-dirty"
|
||||
|
||||
root: '/jq'
|
||||
footer: |
|
||||
|
||||
This website is made with [Bonsai](http://www.tinytree.info) and
|
||||
[Twitter Bootstrap](http://twitter.github.com/bootstrap/), themed
|
||||
with [Bootswatch](http://bootswatch.com).
|
||||
|
||||
jq is licensed under the MIT license (code) and the
|
||||
[CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/) license
|
||||
(docs).
|
||||
+13
-13
@@ -1,34 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/head" %}
|
||||
{% include "shared/_head.html.j2" %}
|
||||
|
||||
<body id="{{slug}}">
|
||||
{% include "shared/header" %}
|
||||
|
||||
{% include "shared/_navbar.html.j2" %}
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="row">
|
||||
<h1>{{headline}}</h1>
|
||||
{% for item in body %}
|
||||
{% if item.text %}
|
||||
{{ item.text | markdownify }}
|
||||
{{ item.text | replace('$JQ_VERSION', jq_version) | markdownify }}
|
||||
{% endif %}
|
||||
|
||||
{% if item.command %}
|
||||
|
||||
|
||||
{% capture resultID %}{{ "result" | unique}}{% endcapture %}
|
||||
{% if item.command %}
|
||||
{% set resultID = unique_id() %}
|
||||
<div class="tutorial-example">
|
||||
<div class="accordion-heading">
|
||||
<pre>{{item.command}}</pre>
|
||||
<a data-toggle="collapse" href="#{{resultID}}">Show result</a>
|
||||
<a data-toggle="collapse" href="#result{{resultID}}">Show result</a>
|
||||
</div>
|
||||
<div id="result{{resultID}}" class="accordion-body collapse">
|
||||
<pre>{{item.result}}</pre>
|
||||
</div>
|
||||
<div id="{{resultID}}" class="accordion-body collapse"><pre>{{item.result}}</pre></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "shared/footer" %}
|
||||
|
||||
|
||||
{% include "shared/_footer.html.j2" %}
|
||||
</body>
|
||||
</html>
|
||||
Vendored
+73
@@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/_head.html.j2" %}
|
||||
|
||||
<body id="{{ slug }}">
|
||||
{% include "shared/_navbar.html.j2" %}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="jumbotron">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<img src="{{root}}/jq.png" class="img-responsive" alt="jq logo"
|
||||
width="400" height="220">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div id="blurb">
|
||||
{{blurb | markdownify}}
|
||||
|
||||
<div class="btn-toolbar" role="toolbar">
|
||||
<div class="btn-group" role="group">
|
||||
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Download jq 1.6
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64">Linux (64-bit)</a></li>
|
||||
<li><a href="https://github.com/jqlang/jq/releases/download/jq-1.6/jq-osx-amd64">macOS (64-bit)</a></li>
|
||||
<li><a href="https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win64.exe">Windows (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/">Other platforms, older versions, and source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-primary" href="https://jqplay.org">
|
||||
Try online at jqplay.org!
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="multiblurb">
|
||||
<div class="col-sm-4">{{body1 | markdownify}}</div>
|
||||
<div class="col-sm-4">{{body2 | markdownify}}</div>
|
||||
<div class="col-sm-4">{{body3 | markdownify}}</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="text-align:center; margin-top: 30px">
|
||||
{{tail | markdownify}}
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<h2>News</h2>
|
||||
<div id="news">
|
||||
<ul>
|
||||
{% for item in news %}
|
||||
<li>
|
||||
<span class="date">{{item.date}}</span>
|
||||
{{item.body | markdownify}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "shared/_footer.html.j2" %}
|
||||
</body>
|
||||
</html>
|
||||
Vendored
-41
@@ -1,41 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/head" %}
|
||||
<body id="{{slug}}">
|
||||
{% include "shared/header" %}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="hero-unit">
|
||||
<img src="{{root}}/jq.png" style="width: 400px; height: 220px; float: left; margin-right: 60px">
|
||||
<div id="blurb">
|
||||
{{blurb | markdownify}}
|
||||
<div class="btn-group" style="float:right">
|
||||
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Download jq-{{jq_version}}
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{root}}/download/linux64/jq">Linux (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/osx64/jq">OS X (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/">Other platforms and source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="multiblurb">
|
||||
<div class="span4">{{body1 | markdownify}}</div>
|
||||
<div class="span4">{{body2 | markdownify}}</div>
|
||||
<div class="span4">{{body3 | markdownify}}</div>
|
||||
</div>
|
||||
<div class="row" style="text-align:center; margin-top: 30px">
|
||||
{{tail | markdownify}}
|
||||
</div>
|
||||
</div>
|
||||
{% include "shared/footer" %}
|
||||
</body>
|
||||
</html>
|
||||
Vendored
+99
@@ -0,0 +1,99 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/_head.html.j2" %}
|
||||
|
||||
<body id="{{slug}}" data-spy="scroll" data-target="#navcolumn" data-offset="100">
|
||||
{% include "shared/_navbar.html.j2" %}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="affix" id="navcolumn">
|
||||
<h4>Contents</h4>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
{% for section in sections %}
|
||||
<li>
|
||||
<a href="#{{section.title | section_id}}">{{section.title}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<form class="form-group" onsubmit="go_to_section(); return false;">
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
placeholder="Search"
|
||||
autocomplete="off"
|
||||
id="searchbox">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="manualcontent">
|
||||
<h1>{{headline}}</h1>
|
||||
{{ history | markdownify }}
|
||||
{{ body | markdownify }}
|
||||
{% for section in sections %}
|
||||
<section id="{{section.title | section_id}}">
|
||||
<h2>{{section.title}}</h2>
|
||||
{{ (section.body | markdownify) if section.body }}
|
||||
{% for entry in section.entries %}
|
||||
<section id="{{entry.title | entry_id}}">
|
||||
<h3>
|
||||
{{entry.title | markdownify | no_paragraph }}
|
||||
{% if entry.subtitle %}<small>{{entry.subtitle}}</small>{% endif %}
|
||||
</h3>
|
||||
{{entry.body | markdownify}}
|
||||
|
||||
{% if entry.examples %}
|
||||
<div>
|
||||
{% set exampleID = unique_id() %}
|
||||
<a data-toggle="collapse" href="#example{{exampleID}}">
|
||||
<i class="glyphicon glyphicon-chevron-right"></i>
|
||||
{% if entry.examples | length > 1 %}Examples{%else%}Example{%endif%}
|
||||
</a>
|
||||
<div id="example{{exampleID}}" class="manual-example collapse">
|
||||
{% for example in entry.examples %}
|
||||
<table>
|
||||
<tr><th></th><td class="jqprogram">jq '{{ example.program }}'</td></tr>
|
||||
<tr><th>Input</th><td>{{ example.input }}</td></tr>
|
||||
{% if not example.output[0] %}
|
||||
<tr>
|
||||
<th>Output</th>
|
||||
<td><i>none</i></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% for output in example.output %}
|
||||
<tr>
|
||||
{% if loop.first %}
|
||||
<th>Output</th>
|
||||
{% else %}
|
||||
<th></th>
|
||||
{% endif %}
|
||||
<td>{{ output }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "shared/_footer.html.j2" %}
|
||||
<script>
|
||||
var section_map = {
|
||||
{% for section in sections %}
|
||||
{% for entry in section.entries %}
|
||||
{{entry.title | search_id | tojson }} : {{entry.title | entry_id | tojson }},
|
||||
{% endfor %}
|
||||
{{section.title | search_id | tojson }} : {{section.title | section_id | tojson }}
|
||||
{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
};
|
||||
</script>
|
||||
<script src="{{root}}/js/manual-search.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Vendored
-110
@@ -1,110 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/head" %}
|
||||
<body id="{{slug}}" data-spy="scroll" data-target="#navcolumn" data-offset="100">
|
||||
{% include "shared/header" %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="span3" id="navcolumn">
|
||||
<div class="affix">
|
||||
<h4>Contents</h4>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
{% for section in sections %}
|
||||
<li {% if forloop.first %} class="active" {% endif %}>
|
||||
<a href="#{{section.title | sanitize}}">{{section.title}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<form class="form-search">
|
||||
<script type="text/javascript">
|
||||
var section_map = {
|
||||
{% for section in sections %}
|
||||
{% for entry in section.entries %}
|
||||
{{entry.title | json}} : {{entry.title | sanitize | json}},
|
||||
{% endfor %}
|
||||
{{section.title | json}} : {{section.title | sanitize | json}}
|
||||
{% unless forloop.last %},{% endunless %}
|
||||
{% endfor %}
|
||||
};
|
||||
var section_names = $.map(section_map, function(v,k){return k});
|
||||
$(function(){
|
||||
$('#searchbox').typeahead({source: section_names})
|
||||
$('#searchbox').change(function() {
|
||||
if ($(this).val() in section_map) {
|
||||
location.hash = '#' + section_map[$(this).val()];
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<input type="text"
|
||||
class="input-medium search-query"
|
||||
placeholder="Search"
|
||||
autocomplete="off"
|
||||
id="searchbox">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<h1>{{headline}}</h1>
|
||||
{{ body | markdownify }}
|
||||
{% for section in sections %}
|
||||
<section id="{{section.title | sanitize}}">
|
||||
<h2>{{section.title}}</h2>
|
||||
{{section.body | markdownify}}
|
||||
{% for entry in section.entries %}
|
||||
<section id="{{entry.title | sanitize}}">
|
||||
<h3>
|
||||
{{entry.title | markdownify}}
|
||||
{% if entry.subtitle %}<small>{{entry.subtitle}}</small>{% endif %}
|
||||
</h3>
|
||||
{{entry.body | markdownify}}
|
||||
|
||||
{% if entry.examples %}
|
||||
<div>
|
||||
{% capture exampleID %}{{ "" | unique }}{% endcapture %}
|
||||
<a data-toggle="collapse" href="#example{{exampleID}}">
|
||||
<i class="icon-chevron-right"></i>
|
||||
{% if entry.examples[1] %}Examples{%else%}Example{%endif%}
|
||||
</a>
|
||||
<div id="example{{exampleID}}" class="collapse">
|
||||
|
||||
{% for example in entry.examples %}
|
||||
<table class="manual-example">
|
||||
<tr><th></th><td class="jqprogram">jq '{{example.program}}'</td></tr>
|
||||
<tr><th>Input</th><td>{{example.input}}</td></tr>
|
||||
{% unless example.output[0] %}
|
||||
<tr>
|
||||
<th>Output</th>
|
||||
<td><i>none</i></td>
|
||||
</tr>
|
||||
{% endunless %}
|
||||
{% for output in example.output %}
|
||||
<tr>
|
||||
{% if forloop.index == 1 %}
|
||||
<th>Output</th>
|
||||
{% else %}
|
||||
<th></th>
|
||||
{% endif %}
|
||||
<td>{{output}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{% include "shared/footer" %}
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<footer>
|
||||
<div class="container">
|
||||
<p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
|
||||
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
|
||||
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
<footer>
|
||||
<div class="container">
|
||||
{{ footer | markdownify }}
|
||||
</div>
|
||||
</footer>
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
<head>
|
||||
<script>
|
||||
if ((window.location.host == "jqlang.github.io") && (window.location.protocol != "https:"))
|
||||
window.location.protocol = "https";
|
||||
</script>
|
||||
<meta charset="utf-8">
|
||||
<title>{{headline}}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<link rel="canonical" href="{{ url }}/{{ permalink }}" />
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/spacelab/bootstrap.min.css" rel="stylesheet" integrity="sha256-j7Dtnd7ZjexEiPNbscbopFn9+Cs0b3TLipKsWAPHZIM= sha512-RFhfi6P8zWMAJrEGU+CPjuxPh3r/UUBGqQ+/o6WKPIVZmQqeOipGotH2ihRULuQ8wsMBoK15TSZqc/7VYWyuIw==" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{{ root }}/css/base.css" type="text/css">
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
<head>
|
||||
<meta charset=UTF-8>
|
||||
<title>{{headline}}</title>
|
||||
<link rel="stylesheet" href="{{root}}/bootstrap/css/bootstrap.css" type="text/css">
|
||||
<link rel="stylesheet" href="{{root}}/css/base.css" type="text/css">
|
||||
<!--[if IE]>
|
||||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
|
||||
<script src="{{root}}/bootstrap/js/bootstrap.js"></script>
|
||||
|
||||
</head>
|
||||
Vendored
-24
@@ -1,24 +0,0 @@
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="brand" href="{{root}}/">jq</a>
|
||||
<div class="nav-collapse collapse">
|
||||
<ul class="nav">
|
||||
{% for item in navigation %}
|
||||
<li {% if item.permalink == permalink %} class="active" {% endif %}>
|
||||
<a href="{{root}}{{item.permalink}}">{{item.name}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li><a href="https://github.com/stedolan/jq/issues">Issues</a></li>
|
||||
<li><a href="https://github.com/stedolan/jq">Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#nav-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{{root}}/">jq</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse" id="nav-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
{% for item in navigation %}
|
||||
<li {% if item == navitem %} class="active" {% endif %}>
|
||||
<a href="{{root}}/{{item}}/">{{item | capitalize}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li><a href="https://github.com/jqlang/jq/issues">Issues</a></li>
|
||||
<li><a href="https://github.com/jqlang/jq">Source</a></li>
|
||||
<li><a href="https://jqplay.org">Try online!</a></li>
|
||||
<li><a href="https://raw.githubusercontent.com/jqlang/jq/master/NEWS">News</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,538 +0,0 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "execute.h"
|
||||
|
||||
#include "opcode.h"
|
||||
#include "bytecode.h"
|
||||
|
||||
#include "forkable_stack.h"
|
||||
#include "frame_layout.h"
|
||||
|
||||
#include "jv_alloc.h"
|
||||
#include "jq_parser.h"
|
||||
#include "locfile.h"
|
||||
#include "jv.h"
|
||||
#include "jv_aux.h"
|
||||
#include "parser.h"
|
||||
#include "builtin.h"
|
||||
|
||||
typedef struct {
|
||||
jv value;
|
||||
int pathidx;
|
||||
} stackval;
|
||||
|
||||
struct jq_state {
|
||||
struct forkable_stack data_stk;
|
||||
struct forkable_stack frame_stk;
|
||||
struct forkable_stack fork_stk;
|
||||
jv* pathbuf;
|
||||
int pathsize; // number of allocated elements
|
||||
int debug_trace_enabled;
|
||||
};
|
||||
|
||||
int path_push(jq_state *jq, stackval sv, jv val) {
|
||||
int pos = sv.pathidx;
|
||||
assert(pos <= jq->pathsize);
|
||||
assert(pos >= 0);
|
||||
if (pos == jq->pathsize) {
|
||||
int oldpathsize = jq->pathsize;
|
||||
jq->pathsize = oldpathsize ? oldpathsize * 2 : 100;
|
||||
jq->pathbuf = jv_mem_realloc(jq->pathbuf, sizeof(jq->pathbuf[0]) * jq->pathsize);
|
||||
for (int i=oldpathsize; i<jq->pathsize; i++) {
|
||||
jq->pathbuf[i] = jv_invalid();
|
||||
}
|
||||
}
|
||||
jv_free(jq->pathbuf[pos]);
|
||||
jq->pathbuf[pos] = val;
|
||||
return pos + 1;
|
||||
}
|
||||
|
||||
stackval stackval_replace(stackval value, jv newjs) {
|
||||
jv_free(value.value);
|
||||
stackval s = {newjs, value.pathidx};
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
// Probably all uses of this function are bugs
|
||||
stackval stackval_root(jv v) {
|
||||
stackval s = {v, 0};
|
||||
return s;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
FORKABLE_STACK_HEADER;
|
||||
stackval sv;
|
||||
} data_stk_elem;
|
||||
|
||||
void stack_push(jq_state *jq, stackval val) {
|
||||
assert(jv_is_valid(val.value));
|
||||
data_stk_elem* s = forkable_stack_push(&jq->data_stk, sizeof(data_stk_elem));
|
||||
s->sv = val;
|
||||
}
|
||||
|
||||
stackval stack_pop(jq_state *jq) {
|
||||
data_stk_elem* s = forkable_stack_peek(&jq->data_stk);
|
||||
stackval sv = s->sv;
|
||||
if (!forkable_stack_pop_will_free(&jq->data_stk)) {
|
||||
sv.value = jv_copy(sv.value);
|
||||
}
|
||||
forkable_stack_pop(&jq->data_stk);
|
||||
assert(jv_is_valid(sv.value));
|
||||
return sv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct forkpoint {
|
||||
FORKABLE_STACK_HEADER;
|
||||
struct forkable_stack_state saved_data_stack;
|
||||
struct forkable_stack_state saved_call_stack;
|
||||
};
|
||||
|
||||
|
||||
void stack_save(jq_state *jq){
|
||||
struct forkpoint* fork = forkable_stack_push(&jq->fork_stk, sizeof(struct forkpoint));
|
||||
forkable_stack_save(&jq->data_stk, &fork->saved_data_stack);
|
||||
forkable_stack_save(&jq->frame_stk, &fork->saved_call_stack);
|
||||
}
|
||||
|
||||
void stack_switch(jq_state *jq) {
|
||||
struct forkpoint* fork = forkable_stack_peek(&jq->fork_stk);
|
||||
forkable_stack_switch(&jq->data_stk, &fork->saved_data_stack);
|
||||
forkable_stack_switch(&jq->frame_stk, &fork->saved_call_stack);
|
||||
}
|
||||
|
||||
int stack_restore(jq_state *jq){
|
||||
while (!forkable_stack_empty(&jq->data_stk) &&
|
||||
forkable_stack_pop_will_free(&jq->data_stk)) {
|
||||
jv_free(stack_pop(jq).value);
|
||||
}
|
||||
while (!forkable_stack_empty(&jq->frame_stk) &&
|
||||
forkable_stack_pop_will_free(&jq->frame_stk)) {
|
||||
frame_pop(&jq->frame_stk);
|
||||
}
|
||||
if (forkable_stack_empty(&jq->fork_stk)) {
|
||||
return 0;
|
||||
} else {
|
||||
struct forkpoint* fork = forkable_stack_peek(&jq->fork_stk);
|
||||
forkable_stack_restore(&jq->data_stk, &fork->saved_data_stack);
|
||||
forkable_stack_restore(&jq->frame_stk, &fork->saved_call_stack);
|
||||
forkable_stack_pop(&jq->fork_stk);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static struct closure make_closure(struct forkable_stack* stk, frame_ptr fr, uint16_t* pc) {
|
||||
uint16_t level = *pc++;
|
||||
uint16_t idx = *pc++;
|
||||
fr = frame_get_level(stk, fr, level);
|
||||
if (idx & ARG_NEWCLOSURE) {
|
||||
int subfn_idx = idx & ~ARG_NEWCLOSURE;
|
||||
assert(subfn_idx < frame_self(fr)->bc->nsubfunctions);
|
||||
struct closure cl = {frame_self(fr)->bc->subfunctions[subfn_idx],
|
||||
forkable_stack_to_idx(stk, fr)};
|
||||
return cl;
|
||||
} else {
|
||||
return *frame_closure_arg(fr, idx);
|
||||
}
|
||||
}
|
||||
|
||||
void print_error(jv value) {
|
||||
assert(!jv_is_valid(value));
|
||||
jv msg = jv_invalid_get_msg(value);
|
||||
if (jv_get_kind(msg) == JV_KIND_STRING) {
|
||||
fprintf(stderr, "jq: error: %s\n", jv_string_value(msg));
|
||||
}
|
||||
jv_free(msg);
|
||||
}
|
||||
#define ON_BACKTRACK(op) ((op)+NUM_OPCODES)
|
||||
|
||||
jv jq_next(jq_state *jq) {
|
||||
jv cfunc_input[MAX_CFUNCTION_ARGS];
|
||||
|
||||
assert(!forkable_stack_empty(&jq->frame_stk));
|
||||
uint16_t* pc = *frame_current_retaddr(&jq->frame_stk);
|
||||
frame_pop(&jq->frame_stk);
|
||||
|
||||
assert(!forkable_stack_empty(&jq->frame_stk));
|
||||
|
||||
int backtracking = 0;
|
||||
while (1) {
|
||||
uint16_t opcode = *pc;
|
||||
|
||||
if (jq->debug_trace_enabled) {
|
||||
dump_operation(frame_current_bytecode(&jq->frame_stk), pc);
|
||||
printf("\t");
|
||||
const struct opcode_description* opdesc = opcode_describe(opcode);
|
||||
data_stk_elem* param = 0;
|
||||
int stack_in = opdesc->stack_in;
|
||||
if (stack_in == -1) stack_in = pc[1];
|
||||
for (int i=0; i<stack_in; i++) {
|
||||
if (i == 0) {
|
||||
param = forkable_stack_peek(&jq->data_stk);
|
||||
} else {
|
||||
printf(" | ");
|
||||
param = forkable_stack_peek_next(&jq->data_stk, param);
|
||||
}
|
||||
if (!param) break;
|
||||
jv_dump(jv_copy(param->sv.value), 0);
|
||||
printf("<%d>", jv_get_refcnt(param->sv.value));
|
||||
}
|
||||
|
||||
if (backtracking) printf("\t<backtracking>");
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
if (backtracking) {
|
||||
opcode = ON_BACKTRACK(opcode);
|
||||
backtracking = 0;
|
||||
}
|
||||
pc++;
|
||||
|
||||
switch (opcode) {
|
||||
default: assert(0 && "invalid instruction");
|
||||
|
||||
case LOADK: {
|
||||
jv v = jv_array_get(jv_copy(frame_current_bytecode(&jq->frame_stk)->constants), *pc++);
|
||||
assert(jv_is_valid(v));
|
||||
stack_push(jq, stackval_replace(stack_pop(jq), v));
|
||||
break;
|
||||
}
|
||||
|
||||
case DUP: {
|
||||
stackval v = stack_pop(jq);
|
||||
stackval v2 = v;
|
||||
v2.value = jv_copy(v.value);
|
||||
stack_push(jq, v);
|
||||
stack_push(jq, v2);
|
||||
break;
|
||||
}
|
||||
|
||||
case DUP2: {
|
||||
stackval keep = stack_pop(jq);
|
||||
stackval v = stack_pop(jq);
|
||||
stackval v2 = v;
|
||||
v2.value = jv_copy(v.value);
|
||||
stack_push(jq, v);
|
||||
stack_push(jq, keep);
|
||||
stack_push(jq, v2);
|
||||
break;
|
||||
}
|
||||
|
||||
case SWAP: {
|
||||
stackval a = stack_pop(jq);
|
||||
stackval b = stack_pop(jq);
|
||||
stack_push(jq, a);
|
||||
stack_push(jq, b);
|
||||
break;
|
||||
}
|
||||
|
||||
case POP: {
|
||||
jv_free(stack_pop(jq).value);
|
||||
break;
|
||||
}
|
||||
|
||||
case APPEND: {
|
||||
// FIXME paths
|
||||
jv v = stack_pop(jq).value;
|
||||
uint16_t level = *pc++;
|
||||
uint16_t vidx = *pc++;
|
||||
frame_ptr fp = frame_get_level(&jq->frame_stk, frame_current(&jq->frame_stk), level);
|
||||
jv* var = frame_local_var(fp, vidx);
|
||||
assert(jv_get_kind(*var) == JV_KIND_ARRAY);
|
||||
*var = jv_array_append(*var, v);
|
||||
break;
|
||||
}
|
||||
|
||||
case INSERT: {
|
||||
stackval stktop = stack_pop(jq);
|
||||
jv v = stack_pop(jq).value;
|
||||
jv k = stack_pop(jq).value;
|
||||
stackval objv = stack_pop(jq);
|
||||
assert(jv_get_kind(k) == JV_KIND_STRING);
|
||||
assert(jv_get_kind(objv.value) == JV_KIND_OBJECT);
|
||||
objv.value = jv_object_set(objv.value, k, v);
|
||||
stack_push(jq, objv);
|
||||
stack_push(jq, stktop);
|
||||
break;
|
||||
}
|
||||
|
||||
// FIXME: loadv/storev may do too much copying/freeing
|
||||
case LOADV: {
|
||||
uint16_t level = *pc++;
|
||||
uint16_t v = *pc++;
|
||||
frame_ptr fp = frame_get_level(&jq->frame_stk, frame_current(&jq->frame_stk), level);
|
||||
jv* var = frame_local_var(fp, v);
|
||||
if (jq->debug_trace_enabled) {
|
||||
printf("V%d = ", v);
|
||||
jv_dump(jv_copy(*var), 0);
|
||||
printf("\n");
|
||||
}
|
||||
stack_push(jq, stackval_replace(stack_pop(jq), jv_copy(*var)));
|
||||
break;
|
||||
}
|
||||
|
||||
case STOREV: {
|
||||
uint16_t level = *pc++;
|
||||
uint16_t v = *pc++;
|
||||
frame_ptr fp = frame_get_level(&jq->frame_stk, frame_current(&jq->frame_stk), level);
|
||||
jv* var = frame_local_var(fp, v);
|
||||
stackval val = stack_pop(jq);
|
||||
if (jq->debug_trace_enabled) {
|
||||
printf("V%d = ", v);
|
||||
jv_dump(jv_copy(val.value), 0);
|
||||
printf("\n");
|
||||
}
|
||||
jv_free(*var);
|
||||
*var = val.value;
|
||||
break;
|
||||
}
|
||||
|
||||
case GETPATH: {
|
||||
stackval path_end = stack_pop(jq);
|
||||
stackval path_start = stack_pop(jq);
|
||||
jv_free(path_end.value);
|
||||
jv path = jv_array();
|
||||
for (int i=path_start.pathidx; i<path_end.pathidx; i++) {
|
||||
path = jv_array_set(path, i, jv_copy(jq->pathbuf[i]));
|
||||
}
|
||||
stack_push(jq, stackval_replace(path_start, path));
|
||||
break;
|
||||
}
|
||||
|
||||
case INDEX: {
|
||||
stackval t = stack_pop(jq);
|
||||
jv k = stack_pop(jq).value;
|
||||
int pathidx = path_push(jq, t, jv_copy(k));
|
||||
jv v = jv_get(t.value, k);
|
||||
if (jv_is_valid(v)) {
|
||||
stackval sv;
|
||||
sv.value = v;
|
||||
sv.pathidx = pathidx;
|
||||
stack_push(jq, sv);
|
||||
} else {
|
||||
print_error(v);
|
||||
goto do_backtrack;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case JUMP: {
|
||||
uint16_t offset = *pc++;
|
||||
pc += offset;
|
||||
break;
|
||||
}
|
||||
|
||||
case JUMP_F: {
|
||||
uint16_t offset = *pc++;
|
||||
stackval t = stack_pop(jq);
|
||||
jv_kind kind = jv_get_kind(t.value);
|
||||
if (kind == JV_KIND_FALSE || kind == JV_KIND_NULL) {
|
||||
pc += offset;
|
||||
}
|
||||
stack_push(jq, t); // FIXME do this better
|
||||
break;
|
||||
}
|
||||
|
||||
case EACH:
|
||||
stack_push(jq, stackval_root(jv_number(-1)));
|
||||
// fallthrough
|
||||
case ON_BACKTRACK(EACH): {
|
||||
int idx = jv_number_value(stack_pop(jq).value);
|
||||
stackval container = stack_pop(jq);
|
||||
|
||||
int keep_going;
|
||||
jv key, value;
|
||||
if (jv_get_kind(container.value) == JV_KIND_ARRAY) {
|
||||
if (opcode == EACH) idx = 0;
|
||||
else idx = idx + 1;
|
||||
keep_going = idx < jv_array_length(jv_copy(container.value));
|
||||
if (keep_going) {
|
||||
key = jv_number(idx);
|
||||
value = jv_array_get(jv_copy(container.value), idx);
|
||||
}
|
||||
} else if (jv_get_kind(container.value) == JV_KIND_OBJECT) {
|
||||
if (opcode == EACH) idx = jv_object_iter(container.value);
|
||||
else idx = jv_object_iter_next(container.value, idx);
|
||||
keep_going = jv_object_iter_valid(container.value, idx);
|
||||
if (keep_going) {
|
||||
key = jv_object_iter_key(container.value, idx);
|
||||
value = jv_object_iter_value(container.value, idx);
|
||||
}
|
||||
} else {
|
||||
assert(opcode == EACH);
|
||||
print_error(jv_invalid_with_msg(jv_string_fmt("Cannot iterate over %s",
|
||||
jv_kind_name(jv_get_kind(container.value)))));
|
||||
keep_going = 0;
|
||||
}
|
||||
|
||||
if (!keep_going) {
|
||||
jv_free(container.value);
|
||||
goto do_backtrack;
|
||||
} else {
|
||||
stack_save(jq);
|
||||
stack_push(jq, container);
|
||||
stack_push(jq, stackval_root(jv_number(idx)));
|
||||
frame_push_backtrack(&jq->frame_stk, pc - 1);
|
||||
stack_switch(jq);
|
||||
|
||||
stackval sv = {value,
|
||||
path_push(jq, container, key)};
|
||||
stack_push(jq, sv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
do_backtrack:
|
||||
case BACKTRACK: {
|
||||
if (!stack_restore(jq)) {
|
||||
return jv_invalid();
|
||||
}
|
||||
pc = *frame_current_retaddr(&jq->frame_stk);
|
||||
frame_pop(&jq->frame_stk);
|
||||
backtracking = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case FORK: {
|
||||
stack_save(jq);
|
||||
frame_push_backtrack(&jq->frame_stk, pc - 1);
|
||||
stack_switch(jq);
|
||||
pc++; // skip offset this time
|
||||
break;
|
||||
}
|
||||
|
||||
case ON_BACKTRACK(FORK): {
|
||||
uint16_t offset = *pc++;
|
||||
pc += offset;
|
||||
break;
|
||||
}
|
||||
|
||||
case YIELD: {
|
||||
jv value = stack_pop(jq).value;
|
||||
frame_push_backtrack(&jq->frame_stk, pc);
|
||||
return value;
|
||||
}
|
||||
|
||||
case CALL_BUILTIN: {
|
||||
int nargs = *pc++;
|
||||
stackval top = stack_pop(jq);
|
||||
cfunc_input[0] = top.value;
|
||||
for (int i = 1; i < nargs; i++) {
|
||||
cfunc_input[i] = stack_pop(jq).value;
|
||||
}
|
||||
struct cfunction* func = &frame_current_bytecode(&jq->frame_stk)->globals->cfunctions[*pc++];
|
||||
top.value = cfunction_invoke(func, cfunc_input);
|
||||
if (jv_is_valid(top.value)) {
|
||||
stack_push(jq, top);
|
||||
} else {
|
||||
print_error(top.value);
|
||||
goto do_backtrack;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CALL_JQ: {
|
||||
uint16_t nclosures = *pc++;
|
||||
uint16_t* retaddr = pc + 2 + nclosures*2;
|
||||
frame_ptr new_frame = frame_push(&jq->frame_stk,
|
||||
make_closure(&jq->frame_stk, frame_current(&jq->frame_stk), pc),
|
||||
retaddr);
|
||||
pc += 2;
|
||||
frame_ptr old_frame = forkable_stack_peek_next(&jq->frame_stk, new_frame);
|
||||
assert(nclosures == frame_self(new_frame)->bc->nclosures);
|
||||
for (int i=0; i<nclosures; i++) {
|
||||
*frame_closure_arg(new_frame, i) = make_closure(&jq->frame_stk, old_frame, pc);
|
||||
pc += 2;
|
||||
}
|
||||
|
||||
pc = frame_current_bytecode(&jq->frame_stk)->code;
|
||||
break;
|
||||
}
|
||||
|
||||
case RET: {
|
||||
pc = *frame_current_retaddr(&jq->frame_stk);
|
||||
frame_pop(&jq->frame_stk);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void jq_init(struct bytecode* bc, jv input, jq_state **jq, int flags) {
|
||||
jq_state *new_jq;
|
||||
new_jq = jv_mem_alloc(sizeof(*new_jq));
|
||||
memset(new_jq, 0, sizeof(*new_jq));
|
||||
forkable_stack_init(&new_jq->data_stk, sizeof(stackval) * 100);
|
||||
forkable_stack_init(&new_jq->frame_stk, 1024);
|
||||
forkable_stack_init(&new_jq->fork_stk, 1024);
|
||||
|
||||
stack_push(new_jq, stackval_root(input));
|
||||
struct closure top = {bc, -1};
|
||||
frame_push(&new_jq->frame_stk, top, 0);
|
||||
frame_push_backtrack(&new_jq->frame_stk, bc->code);
|
||||
if (flags & JQ_DEBUG_TRACE) {
|
||||
new_jq->debug_trace_enabled = 1;
|
||||
} else {
|
||||
new_jq->debug_trace_enabled = 0;
|
||||
}
|
||||
*jq = new_jq;
|
||||
}
|
||||
|
||||
void jq_teardown(jq_state **jq) {
|
||||
jq_state *old_jq = *jq;
|
||||
if (old_jq == NULL)
|
||||
return;
|
||||
*jq = NULL;
|
||||
|
||||
while (stack_restore(old_jq)) {}
|
||||
|
||||
assert(forkable_stack_empty(&old_jq->fork_stk));
|
||||
assert(forkable_stack_empty(&old_jq->data_stk));
|
||||
assert(forkable_stack_empty(&old_jq->frame_stk));
|
||||
forkable_stack_free(&old_jq->fork_stk);
|
||||
forkable_stack_free(&old_jq->data_stk);
|
||||
forkable_stack_free(&old_jq->frame_stk);
|
||||
|
||||
for (int i=0; i<old_jq->pathsize; i++) {
|
||||
jv_free(old_jq->pathbuf[i]);
|
||||
}
|
||||
jv_mem_free(old_jq->pathbuf);
|
||||
jv_mem_free(old_jq);
|
||||
}
|
||||
|
||||
struct bytecode* jq_compile_args(const char* str, jv args) {
|
||||
assert(jv_get_kind(args) == JV_KIND_ARRAY);
|
||||
struct locfile locations;
|
||||
locfile_init(&locations, str, strlen(str));
|
||||
block program;
|
||||
struct bytecode* bc = 0;
|
||||
int nerrors = jq_parse(&locations, &program);
|
||||
if (nerrors == 0) {
|
||||
for (int i=0; i<jv_array_length(jv_copy(args)); i++) {
|
||||
jv arg = jv_array_get(jv_copy(args), i);
|
||||
jv name = jv_object_get(jv_copy(arg), jv_string("name"));
|
||||
jv value = jv_object_get(arg, jv_string("value"));
|
||||
program = gen_var_binding(gen_const(value), jv_string_value(name), program);
|
||||
jv_free(name);
|
||||
}
|
||||
jv_free(args);
|
||||
program = builtins_bind(program);
|
||||
nerrors = block_compile(program, &locations, &bc);
|
||||
}
|
||||
if (nerrors) {
|
||||
fprintf(stderr, "%d compile %s\n", nerrors, nerrors > 1 ? "errors" : "error");
|
||||
}
|
||||
locfile_free(&locations);
|
||||
return bc;
|
||||
}
|
||||
|
||||
struct bytecode* jq_compile(const char* str) {
|
||||
return jq_compile_args(str, jv_array());
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef EXECUTE_H
|
||||
#define EXECUTE_H
|
||||
#include "bytecode.h"
|
||||
|
||||
|
||||
|
||||
struct bytecode* jq_compile(const char* str);
|
||||
|
||||
/* args must be an array of the form [{name:"foo", value:"thing"}, {name:"bar",value:3}] */
|
||||
struct bytecode* jq_compile_args(const char* str, jv args);
|
||||
|
||||
typedef struct jq_state jq_state;
|
||||
enum {JQ_DEBUG_TRACE = 1};
|
||||
|
||||
void jq_init(struct bytecode* bc, jv value, jq_state **, int flags);
|
||||
jv jq_next(jq_state *);
|
||||
void jq_teardown(jq_state **);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,172 +0,0 @@
|
||||
#ifndef FORKABLE_STACK_H
|
||||
#define FORKABLE_STACK_H
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "jv_alloc.h"
|
||||
|
||||
struct forkable_stack_header {
|
||||
/* distance in bytes between this header and the header
|
||||
of the next object on the stack */
|
||||
int next_delta;
|
||||
};
|
||||
|
||||
#define FORKABLE_STACK_HEADER struct forkable_stack_header fk_header_
|
||||
|
||||
struct forkable_stack {
|
||||
// Stack grows down from stk+length
|
||||
char* stk;
|
||||
|
||||
// stk+length is just past end of allocated area
|
||||
// stk = jv_mem_alloc(length)
|
||||
int length;
|
||||
|
||||
// stk+pos is header of top object, or stk+length if empty
|
||||
int pos;
|
||||
|
||||
// everything after-or-including stk+savedlimit must be preserved
|
||||
int savedlimit;
|
||||
};
|
||||
|
||||
static void forkable_stack_check(struct forkable_stack* s) {
|
||||
assert(s->stk);
|
||||
assert(s->length > 0);
|
||||
assert(s->pos >= 0 && s->pos <= s->length);
|
||||
assert(s->savedlimit >= 0 && s->savedlimit <= s->length);
|
||||
}
|
||||
|
||||
static int forkable_stack_empty(struct forkable_stack* s) {
|
||||
return s->pos == s->length;
|
||||
}
|
||||
|
||||
static void forkable_stack_init(struct forkable_stack* s, size_t sz) {
|
||||
s->stk = jv_mem_alloc(sz);
|
||||
s->length = sz;
|
||||
s->pos = s->length;
|
||||
s->savedlimit = s->length;
|
||||
forkable_stack_check(s);
|
||||
}
|
||||
|
||||
static void forkable_stack_free(struct forkable_stack* s) {
|
||||
assert(forkable_stack_empty(s));
|
||||
assert(s->savedlimit == s->length);
|
||||
jv_mem_free(s->stk);
|
||||
s->stk = 0;
|
||||
}
|
||||
|
||||
static void* forkable_stack_push(struct forkable_stack* s, size_t sz_size) {
|
||||
assert(sz_size > 0 && sz_size % sizeof(struct forkable_stack_header) == 0);
|
||||
int size = (int)sz_size;
|
||||
forkable_stack_check(s);
|
||||
int curr = s->pos < s->savedlimit ? s->pos : s->savedlimit;
|
||||
if (curr - size < 0) {
|
||||
int oldlen = s->length;
|
||||
s->length = (size + oldlen + 1024) * 2;
|
||||
s->stk = jv_mem_realloc(s->stk, s->length);
|
||||
int shift = s->length - oldlen;
|
||||
memmove(s->stk + shift, s->stk, oldlen);
|
||||
s->pos += shift;
|
||||
s->savedlimit += shift;
|
||||
curr += shift;
|
||||
}
|
||||
int newpos = curr - size;
|
||||
assert(newpos < s->pos);
|
||||
void* ret = (void*)(s->stk + newpos);
|
||||
((struct forkable_stack_header*)ret)->next_delta = s->pos - newpos;
|
||||
s->pos = newpos;
|
||||
forkable_stack_check(s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void* forkable_stack_peek(struct forkable_stack* s) {
|
||||
assert(!forkable_stack_empty(s));
|
||||
forkable_stack_check(s);
|
||||
return (void*)(s->stk + s->pos);
|
||||
}
|
||||
|
||||
static void* forkable_stack_peek_next(struct forkable_stack* s, void* top) {
|
||||
forkable_stack_check(s);
|
||||
struct forkable_stack_header* elem = top;
|
||||
int elempos = (char*)top - s->stk;
|
||||
assert(elempos >= 0 && elempos < s->length);
|
||||
assert(elempos + elem->next_delta <= s->length);
|
||||
if (elempos + elem->next_delta < s->length) {
|
||||
return (void*)(s->stk + elempos + elem->next_delta);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns 1 if the next forkable_stack_pop will permanently remove an
|
||||
// object from the stack (i.e. the top object was not saved with a fork)
|
||||
static int forkable_stack_pop_will_free(struct forkable_stack* s) {
|
||||
return s->pos < s->savedlimit;
|
||||
}
|
||||
|
||||
static void forkable_stack_pop(struct forkable_stack* s) {
|
||||
forkable_stack_check(s);
|
||||
struct forkable_stack_header* elem = forkable_stack_peek(s);
|
||||
int reclaim_upto = s->pos + elem->next_delta < s->savedlimit ?
|
||||
s->pos + elem->next_delta : s->savedlimit;
|
||||
assert(reclaim_upto <= s->length);
|
||||
int reclaimed = reclaim_upto > s->pos ? reclaim_upto - s->pos : 0;
|
||||
assert(0 <= reclaimed && s->pos + reclaimed <= s->length);
|
||||
// s->pos <= i < reclaim_upto means that position i is to be freed
|
||||
assert((reclaimed > 0) == forkable_stack_pop_will_free(s));
|
||||
int new_pos = s->pos + elem->next_delta;
|
||||
jv_mem_invalidate(elem, reclaimed);
|
||||
s->pos = new_pos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct forkable_stack_state {
|
||||
// We save the previous pos, savedlimit as
|
||||
// length-pos, length-savedlimit since these
|
||||
// values are stable across stack reallocations.
|
||||
int prev_pos_delta, prev_limit_delta;
|
||||
};
|
||||
|
||||
static void forkable_stack_save(struct forkable_stack* s, struct forkable_stack_state* state) {
|
||||
forkable_stack_check(s);
|
||||
state->prev_pos_delta = s->length - s->pos;
|
||||
state->prev_limit_delta = s->length - s->savedlimit;
|
||||
if (s->pos < s->savedlimit) s->savedlimit = s->pos;
|
||||
}
|
||||
|
||||
static void forkable_stack_switch(struct forkable_stack* s, struct forkable_stack_state* state) {
|
||||
forkable_stack_check(s);
|
||||
int curr_pos = s->pos;
|
||||
s->pos = s->length - state->prev_pos_delta;
|
||||
state->prev_pos_delta = s->length - curr_pos;
|
||||
|
||||
int curr_limit = s->savedlimit;
|
||||
if (curr_pos < curr_limit) s->savedlimit = curr_pos;
|
||||
//state->prevlimit = curr_limit; FIXME clean up
|
||||
forkable_stack_check(s);
|
||||
}
|
||||
|
||||
static void forkable_stack_restore(struct forkable_stack* s, struct forkable_stack_state* state) {
|
||||
forkable_stack_check(s);
|
||||
assert(s->savedlimit <= s->length - state->prev_pos_delta);
|
||||
assert(s->savedlimit <= s->length - state->prev_limit_delta);
|
||||
s->pos = s->length - state->prev_pos_delta;
|
||||
s->savedlimit = s->length - state->prev_limit_delta;
|
||||
forkable_stack_check(s);
|
||||
}
|
||||
|
||||
typedef int stack_idx;
|
||||
|
||||
static stack_idx forkable_stack_to_idx(struct forkable_stack* s, void* ptr) {
|
||||
char* item = ptr;
|
||||
int pos = item - s->stk;
|
||||
assert(pos >= 0 && pos < s->length);
|
||||
return s->length - pos;
|
||||
}
|
||||
|
||||
static void* forkable_stack_from_idx(struct forkable_stack* s, stack_idx idx) {
|
||||
assert(idx >= 1 && idx <= s->length);
|
||||
return &s->stk[s->length - idx];
|
||||
}
|
||||
|
||||
#endif
|
||||
-118
@@ -1,118 +0,0 @@
|
||||
#ifndef FRAME_LAYOUT_H
|
||||
#include "forkable_stack.h"
|
||||
#include "bytecode.h"
|
||||
|
||||
struct closure {
|
||||
struct bytecode* bc;
|
||||
stack_idx env;
|
||||
};
|
||||
|
||||
struct continuation {
|
||||
struct bytecode* bc;
|
||||
stack_idx env;
|
||||
uint16_t* retaddr;
|
||||
// FIXME: probably not necessary as a separate field
|
||||
int is_backtrack_frame;
|
||||
};
|
||||
|
||||
typedef union frame_elem {
|
||||
FORKABLE_STACK_HEADER;
|
||||
struct continuation cont;
|
||||
struct closure closure;
|
||||
jv jsonval;
|
||||
} *frame_ptr;
|
||||
|
||||
/*
|
||||
* Frame layout
|
||||
* fr[0] - FORKABLE_STACK_HEADER (next pointer)
|
||||
* fr[1] - self (used to store return addresses, etc)
|
||||
* fr[2...nclosures+2] - closure params
|
||||
* fr[nclosures+2..nclosures+nlocals+2] - local variables
|
||||
*/
|
||||
|
||||
static int frame_size(struct bytecode* bc) {
|
||||
return sizeof(union frame_elem) * (bc->nclosures + bc->nlocals + 2);
|
||||
}
|
||||
|
||||
static struct continuation* frame_self(frame_ptr fr) {
|
||||
return &fr[1].cont;
|
||||
}
|
||||
|
||||
static struct closure* frame_closure_arg(frame_ptr fr, int closure) {
|
||||
assert(closure >= 0);
|
||||
assert(closure < frame_self(fr)->bc->nclosures);
|
||||
return &fr[2+closure].closure;
|
||||
}
|
||||
|
||||
static jv* frame_local_var(frame_ptr fr, int var) {
|
||||
assert(var >= 0);
|
||||
assert(var < frame_self(fr)->bc->nlocals);
|
||||
return &fr[2 + frame_self(fr)->bc->nclosures + var].jsonval;
|
||||
}
|
||||
|
||||
|
||||
static frame_ptr frame_current(struct forkable_stack* stk) {
|
||||
frame_ptr fp = forkable_stack_peek(stk);
|
||||
if (forkable_stack_peek_next(stk, fp)) {
|
||||
struct bytecode* bc = frame_self(forkable_stack_peek_next(stk, fp))->bc;
|
||||
assert(frame_self(fp)->retaddr >= bc->code && frame_self(fp)->retaddr < bc->code + bc->codelen);
|
||||
} else {
|
||||
assert(frame_self(fp)->retaddr == 0);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
static struct bytecode* frame_current_bytecode(struct forkable_stack* stk) {
|
||||
return frame_self(frame_current(stk))->bc;
|
||||
}
|
||||
static uint16_t** frame_current_retaddr(struct forkable_stack* stk) {
|
||||
return &frame_self(frame_current(stk))->retaddr;
|
||||
}
|
||||
|
||||
static frame_ptr frame_get_parent(struct forkable_stack* stk, frame_ptr fr) {
|
||||
return forkable_stack_from_idx(stk, frame_self(fr)->env);
|
||||
}
|
||||
|
||||
static frame_ptr frame_get_level(struct forkable_stack* stk, frame_ptr fr, int level) {
|
||||
for (int i=0; i<level; i++) {
|
||||
fr = frame_get_parent(stk, fr);
|
||||
}
|
||||
return fr;
|
||||
}
|
||||
|
||||
static frame_ptr frame_push(struct forkable_stack* stk, struct closure cl, uint16_t* retaddr) {
|
||||
frame_ptr fp = forkable_stack_push(stk, frame_size(cl.bc));
|
||||
struct continuation* cc = frame_self(fp);
|
||||
cc->bc = cl.bc;
|
||||
cc->env = cl.env;
|
||||
cc->retaddr = retaddr;
|
||||
cc->is_backtrack_frame = 0;
|
||||
for (int i=0; i<cl.bc->nlocals; i++) {
|
||||
*frame_local_var(fp, i) = jv_invalid();
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
static frame_ptr frame_push_backtrack(struct forkable_stack* stk, uint16_t* retaddr) {
|
||||
struct continuation cc = *frame_self(frame_current(stk));
|
||||
frame_ptr fp = forkable_stack_push(stk, sizeof(union frame_elem) * 2);
|
||||
assert(!cc.is_backtrack_frame);
|
||||
cc.is_backtrack_frame = 1;
|
||||
cc.retaddr = retaddr;
|
||||
*frame_self(fp) = cc;
|
||||
return fp;
|
||||
}
|
||||
|
||||
static void frame_pop(struct forkable_stack* stk) {
|
||||
frame_ptr fp = frame_current(stk);
|
||||
if (forkable_stack_pop_will_free(stk) &&
|
||||
!frame_self(fp)->is_backtrack_frame) {
|
||||
int nlocals = frame_self(fp)->bc->nlocals;
|
||||
for (int i=0; i<nlocals; i++) {
|
||||
jv_free(*frame_local_var(fp, i));
|
||||
}
|
||||
}
|
||||
forkable_stack_pop(stk);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,39 +0,0 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "JQ" "1" "May 2013" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBjq\fR \- Command\-line JSON processor
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
\fBjq\fR can transform JSON in various ways, by selecting, iterating, reducing and otherwise mangling JSON documents\.
|
||||
.
|
||||
.P
|
||||
This version of \fBjq\fR was built without a manual, so this manpage is a stub\. For full documentation of the \fBjq\fR language, see:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
http://stedolan\.github\.com/jq
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "BUGS"
|
||||
Presumably\. Report them or discuss them at:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
https://github\.com/stedolan/jq/issues
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "AUTHOR"
|
||||
Stephen Dolan \fB<mu@netsoc\.tcd\.ie>\fR
|
||||
+3674
File diff suppressed because it is too large.
Load diff
@@ -5,7 +5,7 @@ Name: jq
|
||||
Version: %{myver}
|
||||
Release: %{myrel}%{?dist}
|
||||
Source0: jq-%{myver}.tar.gz
|
||||
URL: https://github.com/stedolan/jq
|
||||
URL: https://jqlang.github.io/jq
|
||||
License: BSD
|
||||
AutoReqProv: no
|
||||
#BuildPrereq: autoconf, libtool, automake, flex, bison, python
|
||||
@@ -52,11 +52,15 @@ rm -rf %{buildroot}
|
||||
%endif
|
||||
%{_datadir}/doc/%{name}/AUTHORS
|
||||
%{_datadir}/doc/%{name}/COPYING
|
||||
%{_datadir}/doc/%{name}/INSTALL
|
||||
%{_datadir}/doc/%{name}/NEWS
|
||||
%{_datadir}/doc/%{name}/README
|
||||
%{_datadir}/doc/%{name}/README.md
|
||||
%{_datadir}/man/man1/jq.1
|
||||
%{_includedir}/jq.h
|
||||
%{_includedir}/jv.h
|
||||
%{_prefix}/lib/libjq.a
|
||||
%{_prefix}/lib/libjq.la
|
||||
%{_prefix}/lib/libjq.so
|
||||
%{_prefix}/lib/libjq.so.1
|
||||
%{_prefix}/lib/libjq.so.1.0.4
|
||||
|
||||
%changelog
|
||||
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "jv.h"
|
||||
#include "execute.h"
|
||||
|
||||
static void jv_test();
|
||||
static void run_jq_tests();
|
||||
|
||||
|
||||
int jq_testsuite(int argc, char* argv[]) {
|
||||
jv_test();
|
||||
run_jq_tests(stdin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int skipline(const char* buf) {
|
||||
int p = 0;
|
||||
while (buf[p] == ' ' || buf[p] == '\t') p++;
|
||||
if (buf[p] == '#' || buf[p] == '\n' || buf[p] == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void run_jq_tests(FILE *testdata) {
|
||||
char buf[4096];
|
||||
int tests = 0, passed = 0, invalid = 0;
|
||||
jq_state *jq = NULL;
|
||||
|
||||
while (1) {
|
||||
if (!fgets(buf, sizeof(buf), testdata)) break;
|
||||
if (skipline(buf)) continue;
|
||||
if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
|
||||
printf("Testing %s\n", buf);
|
||||
int pass = 1;
|
||||
tests++;
|
||||
struct bytecode* bc = jq_compile(buf);
|
||||
if (!bc) {invalid++; continue;}
|
||||
printf("Disassembly:\n");
|
||||
dump_disassembly(2, bc);
|
||||
printf("\n");
|
||||
fgets(buf, sizeof(buf), testdata);
|
||||
jv input = jv_parse(buf);
|
||||
if (!jv_is_valid(input)){ invalid++; continue; }
|
||||
jq_init(bc, input, &jq, JQ_DEBUG_TRACE);
|
||||
|
||||
while (fgets(buf, sizeof(buf), testdata)) {
|
||||
if (skipline(buf)) break;
|
||||
jv expected = jv_parse(buf);
|
||||
if (!jv_is_valid(expected)){ invalid++; continue; }
|
||||
jv actual = jq_next(jq);
|
||||
if (!jv_is_valid(actual)) {
|
||||
jv_free(actual);
|
||||
printf("*** Insufficient results\n");
|
||||
pass = 0;
|
||||
break;
|
||||
} else if (!jv_equal(jv_copy(expected), jv_copy(actual))) {
|
||||
printf("*** Expected ");
|
||||
jv_dump(jv_copy(expected), 0);
|
||||
printf(", but got ");
|
||||
jv_dump(jv_copy(actual), 0);
|
||||
printf("\n");
|
||||
pass = 0;
|
||||
}
|
||||
jv as_string = jv_dump_string(jv_copy(expected), rand() & ~JV_PRINT_COLOUR);
|
||||
jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length(jv_copy(as_string)));
|
||||
assert(jv_equal(jv_copy(expected), jv_copy(reparsed)));
|
||||
jv_free(as_string);
|
||||
jv_free(reparsed);
|
||||
jv_free(expected);
|
||||
jv_free(actual);
|
||||
}
|
||||
if (pass) {
|
||||
jv extra = jq_next(jq);
|
||||
if (jv_is_valid(extra)) {
|
||||
printf("*** Superfluous result: ");
|
||||
jv_dump(extra, 0);
|
||||
printf("\n");
|
||||
pass = 0;
|
||||
} else {
|
||||
jv_free(extra);
|
||||
}
|
||||
}
|
||||
jq_teardown(&jq);
|
||||
bytecode_free(bc);
|
||||
passed+=pass;
|
||||
}
|
||||
printf("%d of %d tests passed (%d malformed)\n", passed,tests,invalid);
|
||||
if (passed != tests) exit(1);
|
||||
}
|
||||
|
||||
|
||||
static void jv_test() {
|
||||
/// Arrays and numbers
|
||||
{
|
||||
jv a = jv_array();
|
||||
assert(jv_get_kind(a) == JV_KIND_ARRAY);
|
||||
assert(jv_array_length(jv_copy(a)) == 0);
|
||||
assert(jv_array_length(jv_copy(a)) == 0);
|
||||
|
||||
a = jv_array_append(a, jv_number(42));
|
||||
assert(jv_array_length(jv_copy(a)) == 1);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42);
|
||||
|
||||
jv a2 = jv_array_append(jv_array(), jv_number(42));
|
||||
assert(jv_equal(jv_copy(a), jv_copy(a)));
|
||||
assert(jv_equal(jv_copy(a2), jv_copy(a2)));
|
||||
assert(jv_equal(jv_copy(a), jv_copy(a2)));
|
||||
assert(jv_equal(jv_copy(a2), jv_copy(a)));
|
||||
jv_free(a2);
|
||||
|
||||
a2 = jv_array_append(jv_array(), jv_number(19));
|
||||
assert(!jv_equal(jv_copy(a), jv_copy(a2)));
|
||||
assert(!jv_equal(jv_copy(a2), jv_copy(a)));
|
||||
jv_free(a2);
|
||||
|
||||
|
||||
assert(a.val.complex.ptr->count == 1);
|
||||
a = jv_array_append(a, jv_copy(a));
|
||||
assert(a.val.complex.ptr->count == 1);
|
||||
|
||||
assert(jv_array_length(jv_copy(a)) == 2);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42);
|
||||
|
||||
for (int i=0; i<10; i++) {
|
||||
jv subarray = jv_array_get(jv_copy(a), 1);
|
||||
assert(jv_get_kind(subarray) == JV_KIND_ARRAY);
|
||||
assert(jv_array_length(jv_copy(subarray)) == 1);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(subarray), 0)) == 42);
|
||||
jv_free(subarray);
|
||||
}
|
||||
|
||||
|
||||
jv subarray = jv_array_get(jv_copy(a), 1);
|
||||
assert(jv_get_kind(subarray) == JV_KIND_ARRAY);
|
||||
assert(jv_array_length(jv_copy(subarray)) == 1);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(subarray), 0)) == 42);
|
||||
|
||||
jv sub2 = jv_copy(subarray);
|
||||
sub2 = jv_array_append(sub2, jv_number(19));
|
||||
|
||||
assert(jv_get_kind(sub2) == JV_KIND_ARRAY);
|
||||
assert(jv_array_length(jv_copy(sub2)) == 2);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(sub2), 0)) == 42);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(sub2), 1)) == 19);
|
||||
|
||||
assert(jv_get_kind(subarray) == JV_KIND_ARRAY);
|
||||
assert(jv_array_length(jv_copy(subarray)) == 1);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(subarray), 0)) == 42);
|
||||
|
||||
jv_free(subarray);
|
||||
|
||||
void* before = sub2.val.complex.ptr;
|
||||
sub2 = jv_array_append(sub2, jv_number(200));
|
||||
void* after = sub2.val.complex.ptr;
|
||||
assert(before == after);
|
||||
jv_free(sub2);
|
||||
|
||||
jv a3 = jv_array_append(jv_copy(a), jv_number(19));
|
||||
assert(jv_array_length(jv_copy(a3)) == 3);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(a3), 0)) == 42);
|
||||
assert(jv_array_length(jv_array_get(jv_copy(a3), 1)) == 1);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(a3), 2)) == 19);
|
||||
jv_free(a3);
|
||||
|
||||
|
||||
assert(jv_array_length(jv_copy(a)) == 2);
|
||||
assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42);
|
||||
assert(jv_array_length(jv_array_get(jv_copy(a), 1)) == 1);
|
||||
|
||||
|
||||
jv_dump(jv_copy(a), 0); printf("\n");
|
||||
jv_free(a);
|
||||
}
|
||||
|
||||
|
||||
/// Strings
|
||||
{
|
||||
assert(jv_equal(jv_string("foo"), jv_string_sized("foo", 3)));
|
||||
char nasty[] = "foo\0";
|
||||
jv shortstr = jv_string(nasty), longstr = jv_string_sized(nasty, sizeof(nasty));
|
||||
assert(jv_string_length(shortstr) == (int)strlen(nasty));
|
||||
assert(jv_string_length(longstr) == (int)sizeof(nasty));
|
||||
|
||||
|
||||
char a1s[] = "hello", a2s[] = "hello", bs[] = "goodbye";
|
||||
jv a1 = jv_string(a1s), a2 = jv_string(a2s), b = jv_string(bs);
|
||||
assert(jv_equal(jv_copy(a1), jv_copy(a2)));
|
||||
assert(jv_equal(jv_copy(a2), jv_copy(a1)));
|
||||
assert(!jv_equal(jv_copy(a1), jv_copy(b)));
|
||||
|
||||
assert(jv_string_hash(jv_copy(a1)) == jv_string_hash(jv_copy(a1)));
|
||||
assert(jv_string_hash(jv_copy(a1)) == jv_string_hash(jv_copy(a2)));
|
||||
assert(jv_string_hash(jv_copy(b)) != jv_string_hash(jv_copy(a1)));
|
||||
jv_free(a1);
|
||||
jv_free(a2);
|
||||
jv_free(b);
|
||||
|
||||
assert(jv_equal(jv_string("hello42!"), jv_string_fmt("hello%d%s", 42, "!")));
|
||||
char big[20000];
|
||||
for (int i=0; i<(int)sizeof(big); i++) big[i] = 'a';
|
||||
big[sizeof(big)-1] = 0;
|
||||
jv str = jv_string_fmt("%s", big);
|
||||
assert(jv_string_length(jv_copy(str)) == sizeof(big) - 1);
|
||||
assert(!strcmp(big, jv_string_value(str)));
|
||||
jv_free(str);
|
||||
}
|
||||
|
||||
/// Objects
|
||||
{
|
||||
jv o1 = jv_object();
|
||||
o1 = jv_object_set(o1, jv_string("foo"), jv_number(42));
|
||||
o1 = jv_object_set(o1, jv_string("bar"), jv_number(24));
|
||||
assert(jv_number_value(jv_object_get(jv_copy(o1), jv_string("foo"))) == 42);
|
||||
assert(jv_number_value(jv_object_get(jv_copy(o1), jv_string("bar"))) == 24);
|
||||
|
||||
jv o2 = jv_object_set(jv_copy(o1), jv_string("foo"), jv_number(420));
|
||||
o2 = jv_object_set(o2, jv_string("bar"), jv_number(240));
|
||||
assert(jv_number_value(jv_object_get(jv_copy(o1), jv_string("foo"))) == 42);
|
||||
assert(jv_number_value(jv_object_get(jv_copy(o1), jv_string("bar"))) == 24);
|
||||
assert(jv_number_value(jv_object_get(jv_copy(o2), jv_string("foo"))) == 420);
|
||||
jv_free(o1);
|
||||
assert(jv_number_value(jv_object_get(jv_copy(o2), jv_string("bar"))) == 240);
|
||||
|
||||
jv_dump(jv_copy(o2), 0); printf("\n");
|
||||
|
||||
jv_free(o2);
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
#ifndef JV_H
|
||||
#define JV_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
JV_KIND_INVALID,
|
||||
JV_KIND_NULL,
|
||||
JV_KIND_FALSE,
|
||||
JV_KIND_TRUE,
|
||||
JV_KIND_NUMBER,
|
||||
JV_KIND_STRING,
|
||||
JV_KIND_ARRAY,
|
||||
JV_KIND_OBJECT
|
||||
} jv_kind;
|
||||
|
||||
typedef struct {
|
||||
size_t count;
|
||||
} jv_refcnt;
|
||||
|
||||
typedef struct{
|
||||
jv_refcnt* ptr;
|
||||
int i[2];
|
||||
} jv_complex;
|
||||
|
||||
typedef struct {
|
||||
jv_kind kind;
|
||||
union {
|
||||
double number;
|
||||
jv_complex complex;
|
||||
} val;
|
||||
} jv;
|
||||
|
||||
/*
|
||||
* All jv_* functions consume (decref) input and produce (incref) output
|
||||
* Except jv_copy
|
||||
*/
|
||||
|
||||
jv_kind jv_get_kind(jv);
|
||||
const char* jv_kind_name(jv_kind);
|
||||
static int jv_is_valid(jv x) { return jv_get_kind(x) != JV_KIND_INVALID; }
|
||||
|
||||
jv jv_copy(jv);
|
||||
void jv_free(jv);
|
||||
|
||||
int jv_equal(jv, jv);
|
||||
int jv_contains(jv, jv);
|
||||
|
||||
jv jv_invalid();
|
||||
jv jv_invalid_with_msg(jv);
|
||||
jv jv_invalid_get_msg(jv);
|
||||
int jv_invalid_has_msg(jv);
|
||||
|
||||
|
||||
jv jv_null();
|
||||
jv jv_true();
|
||||
jv jv_false();
|
||||
jv jv_bool(int);
|
||||
|
||||
jv jv_number(double);
|
||||
double jv_number_value(jv);
|
||||
|
||||
jv jv_array();
|
||||
jv jv_array_sized(int);
|
||||
int jv_array_length(jv);
|
||||
jv jv_array_get(jv, int);
|
||||
jv jv_array_set(jv, int, jv);
|
||||
jv jv_array_append(jv, jv);
|
||||
jv jv_array_concat(jv, jv);
|
||||
jv jv_array_slice(jv, int, int);
|
||||
#define jv_array_foreach(a, i, x) \
|
||||
for (int jv_len__ = jv_array_length(jv_copy(a)), i=0, jv_j__ = 1; \
|
||||
jv_j__; jv_j__ = 0) \
|
||||
for (jv x; \
|
||||
i < jv_len__ ? \
|
||||
(x = jv_array_get(jv_copy(a), i), 1) : 0; \
|
||||
i++)
|
||||
|
||||
jv jv_string(const char*);
|
||||
jv jv_string_sized(const char*, int);
|
||||
int jv_string_length(jv);
|
||||
uint32_t jv_string_hash(jv);
|
||||
const char* jv_string_value(jv);
|
||||
jv jv_string_concat(jv, jv);
|
||||
jv jv_string_fmt(const char*, ...);
|
||||
jv jv_string_append_buf(jv a, const char* buf, int len);
|
||||
jv jv_string_append_str(jv a, const char* str);
|
||||
|
||||
jv jv_object();
|
||||
jv jv_object_get(jv object, jv key);
|
||||
jv jv_object_set(jv object, jv key, jv value);
|
||||
jv jv_object_delete(jv object, jv key);
|
||||
int jv_object_length(jv object);
|
||||
jv jv_object_merge(jv, jv);
|
||||
|
||||
int jv_object_iter(jv);
|
||||
int jv_object_iter_next(jv, int);
|
||||
int jv_object_iter_valid(jv, int);
|
||||
jv jv_object_iter_key(jv, int);
|
||||
jv jv_object_iter_value(jv, int);
|
||||
#define jv_object_foreach(t, k, v) \
|
||||
for (int jv_i__ = jv_object_iter(t), jv_j__ = 1; jv_j__; jv_j__ = 0) \
|
||||
for (jv k, v; \
|
||||
jv_object_iter_valid((t), jv_i__) ? \
|
||||
(k = jv_object_iter_key(t, jv_i__), \
|
||||
v = jv_object_iter_value(t, jv_i__), \
|
||||
1) \
|
||||
: 0; \
|
||||
jv_i__ = jv_object_iter_next(t, jv_i__)) \
|
||||
|
||||
|
||||
|
||||
int jv_get_refcnt(jv);
|
||||
|
||||
enum { JV_PRINT_PRETTY = 1, JV_PRINT_ASCII = 2, JV_PRINT_COLOUR = 4 };
|
||||
void jv_dump(jv, int flags);
|
||||
jv jv_dump_string(jv, int flags);
|
||||
|
||||
jv jv_parse(const char* string);
|
||||
jv jv_parse_sized(const char* string, int length);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
||||
true/false/null:
|
||||
check kind
|
||||
|
||||
number:
|
||||
introduce/eliminate jv
|
||||
to integer
|
||||
|
||||
array:
|
||||
copy
|
||||
free
|
||||
slice
|
||||
index
|
||||
update
|
||||
|
||||
updateslice?
|
||||
|
||||
|
||||
*/
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "jv_alloc.h"
|
||||
|
||||
static void memory_exhausted() {
|
||||
fprintf(stderr, "error: cannot allocate memory\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
void* jv_mem_alloc(size_t sz) {
|
||||
void* p = malloc(sz);
|
||||
if (!p) {
|
||||
memory_exhausted();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void jv_mem_free(void* p) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
void* jv_mem_realloc(void* p, size_t sz) {
|
||||
p = realloc(p, sz);
|
||||
if (!p) {
|
||||
memory_exhausted();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
volatile char jv_mem_uninitialised;
|
||||
__attribute__((constructor)) void jv_mem_uninit_setup(){
|
||||
char* p = malloc(1);
|
||||
jv_mem_uninitialised = *p;
|
||||
free(p);
|
||||
}
|
||||
#endif
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
#ifndef JV_ALLOC_H
|
||||
#define JV_ALLOC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
extern volatile char jv_mem_uninitialised;
|
||||
#endif
|
||||
|
||||
static void jv_mem_invalidate(void* mem, size_t n) {
|
||||
#ifndef NDEBUG
|
||||
char* m = mem;
|
||||
while (n--) *m++ ^= jv_mem_uninitialised ^ jv_mem_uninitialised;
|
||||
#endif
|
||||
}
|
||||
|
||||
void* jv_mem_alloc(size_t);
|
||||
void jv_mem_free(void*);
|
||||
__attribute__((warn_unused_result)) void* jv_mem_realloc(void*, size_t);
|
||||
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef JV_AUX_H
|
||||
#define JV_AUX_H
|
||||
|
||||
#include "jv.h"
|
||||
|
||||
jv jv_get(jv t, jv k);
|
||||
jv jv_set(jv t, jv k, jv v);
|
||||
jv jv_has(jv t, jv k);
|
||||
jv jv_setpath(jv root, jv path, jv value);
|
||||
jv jv_getpath(jv root, jv path);
|
||||
jv jv_delpaths(jv root, jv paths);
|
||||
|
||||
jv jv_keys(jv /*object or array*/);
|
||||
int jv_cmp(jv, jv);
|
||||
|
||||
jv jv_group(jv objects, jv keys);
|
||||
jv jv_sort(jv objects, jv keys);
|
||||
|
||||
|
||||
#endif
|
||||
-446
@@ -1,446 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jv.h"
|
||||
#include "jv_dtoa.h"
|
||||
#include "jv_parse.h"
|
||||
#include "jv_unicode.h"
|
||||
#include "jv_alloc.h"
|
||||
|
||||
typedef const char* presult;
|
||||
|
||||
#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
|
||||
#ifdef __GNUC__
|
||||
#define pfunc __attribute__((warn_unused_result)) presult
|
||||
#else
|
||||
#define pfunc presult
|
||||
#endif
|
||||
|
||||
void jv_parser_init(struct jv_parser* p) {
|
||||
p->stack = 0;
|
||||
p->stacklen = p->stackpos = 0;
|
||||
p->next = jv_invalid();
|
||||
p->tokenbuf = 0;
|
||||
p->tokenlen = p->tokenpos = 0;
|
||||
p->st = JV_PARSER_NORMAL;
|
||||
p->curr_buf = 0;
|
||||
p->curr_buf_length = p->curr_buf_pos = p->curr_buf_is_partial = 0;
|
||||
p->bom_strip_position = 0;
|
||||
p->line = 1;
|
||||
p->column = 0;
|
||||
jvp_dtoa_context_init(&p->dtoa);
|
||||
}
|
||||
|
||||
void jv_parser_free(struct jv_parser* p) {
|
||||
jv_free(p->next);
|
||||
for (int i=0; i<p->stackpos; i++)
|
||||
jv_free(p->stack[i]);
|
||||
jv_mem_free(p->stack);
|
||||
jv_mem_free(p->tokenbuf);
|
||||
jvp_dtoa_context_free(&p->dtoa);
|
||||
}
|
||||
|
||||
static pfunc value(struct jv_parser* p, jv val) {
|
||||
if (jv_is_valid(p->next)) return "Expected separator between values";
|
||||
jv_free(p->next);
|
||||
p->next = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void push(struct jv_parser* p, jv v) {
|
||||
assert(p->stackpos <= p->stacklen);
|
||||
if (p->stackpos == p->stacklen) {
|
||||
p->stacklen = p->stacklen * 2 + 10;
|
||||
p->stack = jv_mem_realloc(p->stack, p->stacklen * sizeof(jv));
|
||||
}
|
||||
assert(p->stackpos < p->stacklen);
|
||||
p->stack[p->stackpos++] = v;
|
||||
}
|
||||
|
||||
static pfunc token(struct jv_parser* p, char ch) {
|
||||
switch (ch) {
|
||||
case '[':
|
||||
if (jv_is_valid(p->next)) return "Expected separator between values";
|
||||
push(p, jv_array());
|
||||
break;
|
||||
|
||||
case '{':
|
||||
if (jv_is_valid(p->next)) return "Expected separator between values";
|
||||
push(p, jv_object());
|
||||
break;
|
||||
|
||||
case ':':
|
||||
if (!jv_is_valid(p->next))
|
||||
return "Expected string key before ':'";
|
||||
if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)
|
||||
return "':' not as part of an object";
|
||||
if (jv_get_kind(p->next) != JV_KIND_STRING)
|
||||
return "Object keys must be strings";
|
||||
push(p, p->next);
|
||||
p->next = jv_invalid();
|
||||
break;
|
||||
|
||||
case ',':
|
||||
if (!jv_is_valid(p->next))
|
||||
return "Expected value before ','";
|
||||
if (p->stackpos == 0)
|
||||
return "',' not as part of an object or array";
|
||||
if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_ARRAY) {
|
||||
p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);
|
||||
p->next = jv_invalid();
|
||||
} else if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_STRING) {
|
||||
assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);
|
||||
p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],
|
||||
p->stack[p->stackpos-1], p->next);
|
||||
p->stackpos--;
|
||||
p->next = jv_invalid();
|
||||
} else {
|
||||
// this case hits on input like {"a", "b"}
|
||||
return "Objects must consist of key:value pairs";
|
||||
}
|
||||
break;
|
||||
|
||||
case ']':
|
||||
if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_ARRAY)
|
||||
return "Unmatched ']'";
|
||||
if (jv_is_valid(p->next)) {
|
||||
p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);
|
||||
p->next = jv_invalid();
|
||||
} else {
|
||||
if (jv_array_length(jv_copy(p->stack[p->stackpos-1])) != 0) {
|
||||
// this case hits on input like [1,2,3,]
|
||||
return "Expected another array element";
|
||||
}
|
||||
}
|
||||
jv_free(p->next);
|
||||
p->next = p->stack[--p->stackpos];
|
||||
break;
|
||||
|
||||
case '}':
|
||||
if (p->stackpos == 0)
|
||||
return "Unmatched '}'";
|
||||
if (jv_is_valid(p->next)) {
|
||||
if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_STRING)
|
||||
return "Objects must consist of key:value pairs";
|
||||
assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);
|
||||
p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],
|
||||
p->stack[p->stackpos-1], p->next);
|
||||
p->stackpos--;
|
||||
p->next = jv_invalid();
|
||||
} else {
|
||||
if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)
|
||||
return "Unmatched '}'";
|
||||
if (jv_object_length(jv_copy(p->stack[p->stackpos-1])) != 0)
|
||||
return "Expected another key-value pair";
|
||||
}
|
||||
jv_free(p->next);
|
||||
p->next = p->stack[--p->stackpos];
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void tokenadd(struct jv_parser* p, char c) {
|
||||
assert(p->tokenpos <= p->tokenlen);
|
||||
if (p->tokenpos == p->tokenlen) {
|
||||
p->tokenlen = p->tokenlen*2 + 256;
|
||||
p->tokenbuf = jv_mem_realloc(p->tokenbuf, p->tokenlen);
|
||||
}
|
||||
assert(p->tokenpos < p->tokenlen);
|
||||
p->tokenbuf[p->tokenpos++] = c;
|
||||
}
|
||||
|
||||
static int unhex4(char* hex) {
|
||||
int r = 0;
|
||||
for (int i=0; i<4; i++) {
|
||||
char c = *hex++;
|
||||
int n;
|
||||
if ('0' <= c && c <= '9') n = c - '0';
|
||||
else if ('a' <= c && c <= 'f') n = c - 'a' + 10;
|
||||
else if ('A' <= c && c <= 'F') n = c - 'A' + 10;
|
||||
else return -1;
|
||||
r <<= 4;
|
||||
r |= n;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
static pfunc found_string(struct jv_parser* p) {
|
||||
char* in = p->tokenbuf;
|
||||
char* out = p->tokenbuf;
|
||||
char* end = p->tokenbuf + p->tokenpos;
|
||||
|
||||
while (in < end) {
|
||||
char c = *in++;
|
||||
if (c == '\\') {
|
||||
if (in >= end)
|
||||
return "Expected escape character at end of string";
|
||||
c = *in++;
|
||||
switch (c) {
|
||||
case '\\':
|
||||
case '"':
|
||||
case '/': *out++ = c; break;
|
||||
case 'b': *out++ = '\b'; break;
|
||||
case 'f': *out++ = '\f'; break;
|
||||
case 't': *out++ = '\t'; break;
|
||||
case 'n': *out++ = '\n'; break;
|
||||
case 'r': *out++ = '\r'; break;
|
||||
|
||||
case 'u':
|
||||
/* ahh, the complicated case */
|
||||
if (in + 4 > end)
|
||||
return "Invalid \\uXXXX escape";
|
||||
int hexvalue = unhex4(in);
|
||||
if (hexvalue < 0)
|
||||
return "Invalid characters in \\uXXXX escape";
|
||||
unsigned long codepoint = (unsigned long)hexvalue;
|
||||
in += 4;
|
||||
if (0xD800 <= codepoint && codepoint <= 0xDBFF) {
|
||||
/* who thought UTF-16 surrogate pairs were a good idea? */
|
||||
if (in + 6 > end || in[0] != '\\' || in[1] != 'u')
|
||||
return "Invalid \\uXXXX\\uXXXX surrogate pair escape";
|
||||
unsigned long surrogate = unhex4(in+2);
|
||||
if (!(0xDC00 <= surrogate && surrogate <= 0xDFFF))
|
||||
return "Invalid \\uXXXX\\uXXXX surrogate pair escape";
|
||||
in += 6;
|
||||
codepoint = 0x10000 + (((codepoint - 0xD800) << 10)
|
||||
|(surrogate - 0xDC00));
|
||||
}
|
||||
// FIXME assert valid codepoint
|
||||
out += jvp_utf8_encode(codepoint, out);
|
||||
break;
|
||||
|
||||
default:
|
||||
return "Invalid escape";
|
||||
}
|
||||
} else {
|
||||
*out++ = c;
|
||||
}
|
||||
}
|
||||
TRY(value(p, jv_string_sized(p->tokenbuf, out - p->tokenbuf)));
|
||||
p->tokenpos = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static pfunc check_literal(struct jv_parser* p) {
|
||||
if (p->tokenpos == 0) return 0;
|
||||
|
||||
const char* pattern = 0;
|
||||
int plen;
|
||||
jv v;
|
||||
switch (p->tokenbuf[0]) {
|
||||
case 't': pattern = "true"; plen = 4; v = jv_true(); break;
|
||||
case 'f': pattern = "false"; plen = 5; v = jv_false(); break;
|
||||
case 'n': pattern = "null"; plen = 4; v = jv_null(); break;
|
||||
}
|
||||
if (pattern) {
|
||||
if (p->tokenpos != plen) return "Invalid literal";
|
||||
for (int i=0; i<plen; i++)
|
||||
if (p->tokenbuf[i] != pattern[i])
|
||||
return "Invalid literal";
|
||||
TRY(value(p, v));
|
||||
} else {
|
||||
// FIXME: better parser
|
||||
p->tokenbuf[p->tokenpos] = 0; // FIXME: invalid
|
||||
char* end = 0;
|
||||
double d = jvp_strtod(&p->dtoa, p->tokenbuf, &end);
|
||||
if (end == 0 || *end != 0)
|
||||
return "Invalid numeric literal";
|
||||
TRY(value(p, jv_number(d)));
|
||||
}
|
||||
p->tokenpos = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
LITERAL,
|
||||
WHITESPACE,
|
||||
STRUCTURE,
|
||||
QUOTE,
|
||||
INVALID
|
||||
} chclass;
|
||||
|
||||
static chclass classify(char c) {
|
||||
switch (c) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\r':
|
||||
case '\n':
|
||||
return WHITESPACE;
|
||||
case '"':
|
||||
return QUOTE;
|
||||
case '[':
|
||||
case ',':
|
||||
case ']':
|
||||
case '{':
|
||||
case ':':
|
||||
case '}':
|
||||
return STRUCTURE;
|
||||
default:
|
||||
return LITERAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const presult OK = "output produced";
|
||||
|
||||
static int check_done(struct jv_parser* p, jv* out) {
|
||||
if (p->stackpos == 0 && jv_is_valid(p->next)) {
|
||||
*out = p->next;
|
||||
p->next = jv_invalid();
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static pfunc scan(struct jv_parser* p, char ch, jv* out) {
|
||||
p->column++;
|
||||
if (ch == '\n') {
|
||||
p->line++;
|
||||
p->column = 0;
|
||||
}
|
||||
presult answer = 0;
|
||||
if (p->st == JV_PARSER_NORMAL) {
|
||||
chclass cls = classify(ch);
|
||||
if (cls != LITERAL) {
|
||||
TRY(check_literal(p));
|
||||
if (check_done(p, out)) answer = OK;
|
||||
}
|
||||
switch (cls) {
|
||||
case LITERAL:
|
||||
tokenadd(p, ch);
|
||||
break;
|
||||
case WHITESPACE:
|
||||
break;
|
||||
case QUOTE:
|
||||
p->st = JV_PARSER_STRING;
|
||||
break;
|
||||
case STRUCTURE:
|
||||
TRY(token(p, ch));
|
||||
break;
|
||||
case INVALID:
|
||||
return "Invalid character";
|
||||
}
|
||||
if (check_done(p, out)) answer = OK;
|
||||
} else {
|
||||
if (ch == '"' && p->st == JV_PARSER_STRING) {
|
||||
TRY(found_string(p));
|
||||
p->st = JV_PARSER_NORMAL;
|
||||
if (check_done(p, out)) answer = OK;
|
||||
} else {
|
||||
tokenadd(p, ch);
|
||||
if (ch == '\\' && p->st == JV_PARSER_STRING) {
|
||||
p->st = JV_PARSER_STRING_ESCAPE;
|
||||
} else {
|
||||
p->st = JV_PARSER_STRING;
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
static const unsigned char UTF8_BOM[] = {0xEF,0xBB,0xBF};
|
||||
|
||||
void jv_parser_set_buf(struct jv_parser* p, const char* buf, int length, int is_partial) {
|
||||
assert((p->curr_buf == 0 || p->curr_buf_pos == p->curr_buf_length)
|
||||
&& "previous buffer not exhausted");
|
||||
while (p->bom_strip_position < sizeof(UTF8_BOM)) {
|
||||
if ((unsigned char)*buf == UTF8_BOM[p->bom_strip_position]) {
|
||||
// matched a BOM character
|
||||
buf++;
|
||||
length--;
|
||||
p->bom_strip_position++;
|
||||
} else {
|
||||
if (p->bom_strip_position == 0) {
|
||||
// no BOM in this document
|
||||
p->bom_strip_position = sizeof(UTF8_BOM);
|
||||
} else {
|
||||
// malformed BOM (prefix present, rest missing)
|
||||
p->bom_strip_position = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
p->curr_buf = buf;
|
||||
p->curr_buf_length = length;
|
||||
p->curr_buf_pos = 0;
|
||||
p->curr_buf_is_partial = is_partial;
|
||||
}
|
||||
|
||||
jv jv_parser_next(struct jv_parser* p) {
|
||||
assert(p->curr_buf && "a buffer must be provided");
|
||||
if (p->bom_strip_position == 0xff) return jv_invalid_with_msg(jv_string("Malformed BOM"));
|
||||
jv value;
|
||||
presult msg = 0;
|
||||
while (!msg && p->curr_buf_pos < p->curr_buf_length) {
|
||||
char ch = p->curr_buf[p->curr_buf_pos++];
|
||||
msg = scan(p, ch, &value);
|
||||
}
|
||||
if (msg == OK) {
|
||||
return value;
|
||||
} else if (msg) {
|
||||
return jv_invalid_with_msg(jv_string_fmt("%s at line %d, column %d", msg, p->line, p->column));
|
||||
} else if (p->curr_buf_is_partial) {
|
||||
assert(p->curr_buf_pos == p->curr_buf_length);
|
||||
// need another buffer
|
||||
return jv_invalid();
|
||||
} else {
|
||||
assert(p->curr_buf_pos == p->curr_buf_length);
|
||||
// at EOF
|
||||
if (p->st != JV_PARSER_NORMAL)
|
||||
return jv_invalid_with_msg(jv_string("Unfinished string"));
|
||||
if ((msg = check_literal(p)))
|
||||
return jv_invalid_with_msg(jv_string(msg));
|
||||
if (p->stackpos != 0)
|
||||
return jv_invalid_with_msg(jv_string("Unfinished JSON term"));
|
||||
// p->next is either invalid (nothing here but no syntax error)
|
||||
// or valid (this is the value). either way it's the thing to return
|
||||
value = p->next;
|
||||
p->next = jv_invalid();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
jv jv_parse_sized(const char* string, int length) {
|
||||
struct jv_parser parser;
|
||||
jv_parser_init(&parser);
|
||||
jv_parser_set_buf(&parser, string, length, 0);
|
||||
jv value = jv_parser_next(&parser);
|
||||
if (jv_is_valid(value)) {
|
||||
jv next = jv_parser_next(&parser);
|
||||
if (jv_is_valid(next)) {
|
||||
// multiple JSON values, we only wanted one
|
||||
jv_free(value);
|
||||
jv_free(next);
|
||||
value = jv_invalid_with_msg(jv_string("Unexpected extra JSON values"));
|
||||
} else if (jv_invalid_has_msg(jv_copy(next))) {
|
||||
// parser error after the first JSON value
|
||||
jv_free(value);
|
||||
value = next;
|
||||
} else {
|
||||
// a single valid JSON value
|
||||
jv_free(next);
|
||||
}
|
||||
} else if (jv_invalid_has_msg(jv_copy(value))) {
|
||||
// parse error, we'll return it
|
||||
} else {
|
||||
// no value at all
|
||||
jv_free(value);
|
||||
value = jv_invalid_with_msg(jv_string("Expected JSON value"));
|
||||
}
|
||||
jv_parser_free(&parser);
|
||||
|
||||
if (!jv_is_valid(value) && jv_invalid_has_msg(jv_copy(value))) {
|
||||
jv msg = jv_invalid_get_msg(value);
|
||||
value = jv_invalid_with_msg(jv_string_fmt("%s (while parsing '%s')",
|
||||
jv_string_value(msg),
|
||||
string));
|
||||
jv_free(msg);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
jv jv_parse(const char* string) {
|
||||
return jv_parse_sized(string, strlen(string));
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
#ifndef JV_PARSE_H
|
||||
#define JV_PARSE_H
|
||||
#include "jv_dtoa.h"
|
||||
struct jv_parser {
|
||||
const char* curr_buf;
|
||||
int curr_buf_length;
|
||||
int curr_buf_pos;
|
||||
int curr_buf_is_partial;
|
||||
unsigned bom_strip_position;
|
||||
|
||||
jv* stack;
|
||||
int stackpos;
|
||||
int stacklen;
|
||||
jv next;
|
||||
|
||||
char* tokenbuf;
|
||||
int tokenpos;
|
||||
int tokenlen;
|
||||
|
||||
int line, column;
|
||||
|
||||
struct dtoa_context dtoa;
|
||||
|
||||
enum {
|
||||
JV_PARSER_NORMAL,
|
||||
JV_PARSER_STRING,
|
||||
JV_PARSER_STRING_ESCAPE
|
||||
} st;
|
||||
};
|
||||
|
||||
void jv_parser_init(struct jv_parser* p);
|
||||
void jv_parser_free(struct jv_parser* p);
|
||||
|
||||
void jv_parser_set_buf(struct jv_parser* p, const char* buf, int length, int is_partial);
|
||||
|
||||
jv jv_parser_next(struct jv_parser* p);
|
||||
#endif
|
||||
Loaded 100 of 271 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user