Catch potential segfaulting behavior in generated binaries

This commit is contained in:
Jeremiah Orians 2020-11-08 21:13:12 -05:00
parent 39915de931
commit 57264eb157
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
20 changed files with 131 additions and 96 deletions

3
cc.c
View File

@ -36,6 +36,7 @@ int main(int argc, char** argv)
FILE* destination_file = stdout;
Architecture = KNIGHT_NATIVE; /* Assume Knight-native */
char* arch;
char* name;
int i = 1;
while(i <= argc)
@ -46,7 +47,7 @@ int main(int argc, char** argv)
}
else if(match(argv[i], "-f") || match(argv[i], "--file"))
{
char* name = argv[i + 1];
name = argv[i + 1];
in = fopen(name, "r");
if(NULL == in)
{

View File

@ -1093,6 +1093,14 @@ void expression()
/* Process local variable */
void collect_local()
{
if(NULL != break_target_func)
{
file_print("Local variable initialized inside of loop in file: ", stderr);
line_error();
file_print("\nMove the variable outside of the loop to resolve\n", stderr);
file_print("Otherwise the binary will segfault while running\n", stderr);
exit(EXIT_FAILURE);
}
struct type* type_size = type_name();
struct token_list* a = sym_declare(global_token->s, type_size, function->locals);
if(match("main", function->s) && (NULL == function->locals))

View File

@ -184,9 +184,10 @@ reset:
struct token_list* reverse_list(struct token_list* head)
{
struct token_list* root = NULL;
struct token_list* next;
while(NULL != head)
{
struct token_list* next = head->next;
next = head->next;
head->next = root;
root = head;
head = next;

View File

@ -40,12 +40,12 @@ b7386a02503542ad6994aed246fd9b01dc646988d9d94270db9cf818b755cf4b test/results/t
169d83f5dd34a1d764716342149f56db492b1f790ce323c5e93b4d577f772e7b test/results/test0006-knight-native-binary
b177d769ae44c3509d9a08d0ee631ec69654dc5d723408bf0decdc67c42aae27 test/results/test0006-knight-posix-binary
18939a0f44cb65c97f413bf0d8ff157ef56886425e66a47884d67e8840da0a5d test/results/test0006-x86-binary
337710e1cf55ee54424442f281e6fd1cdc00ee1f52e6c95d8e3664323fa9723f test/results/test0007-aarch64-binary
46d2d160f4df0bf5562842726ac5ce45171d5257359382be72618884d4fc7790 test/results/test0007-amd64-binary
a7e4ed6b2d5c0e3e375f9141f6c4934c58b94fcbd2d860b23b1b53812fd3dc8e test/results/test0007-armv7l-binary
525ba92027d697564cd7d7611aa32c33486e55e2e60ecf19d700bf2884571975 test/results/test0007-knight-native-binary
9159c4ba8196b24ec78bc9ebfbc7066d510ddbf03461736e7795a48634134dc5 test/results/test0007-knight-posix-binary
b62cfbf5653df5e26fd184c012697aed4bba48d434b68ccedeedd1ad749ec92f test/results/test0007-x86-binary
a7d52ec3d68f759f163a894b798a453072fc8e529dada7c373cce4d2a812a895 test/results/test0007-aarch64-binary
20681d9935c919ce876f27392060154d8f7a853bbce6df6f8e493e66496d2401 test/results/test0007-amd64-binary
12706d068d962b93a2b54128adf2d6ab4fa6dd2bcee31ab6bea796c278b2f315 test/results/test0007-armv7l-binary
33adb20e6febc8f63ea5cb7b64b61d7404e3b332bc2baff3639af838dd6d9a2f test/results/test0007-knight-native-binary
c937339120fd4ea873b49e7a8872c84735860490fe6cd4de0739c02a402338c7 test/results/test0007-knight-posix-binary
fede201188d1b997e7c0bace34ff09cfe0d1cd4c718f0a15adaa5956264a15b1 test/results/test0007-x86-binary
a7bb65722a9a5365721e32ac4ec3aa0f79ba170f0406aeb746f5b296185b0493 test/results/test0008-aarch64-binary
2d0f89e696b4526f71887f2d3a5d0d14d79b811dea436821d3d876a23fb24f20 test/results/test0008-amd64-binary
371e2c7b12829e9081c720eea917dc78c039996b7881f799882c59c89eb22cdd test/results/test0008-armv7l-binary
@ -64,24 +64,24 @@ f8e123ac44a5443bf335ec3e7e767649eb29e5b60b36588206c7f8fbc69ed0a5 test/results/t
e01b615db5df31392bd1054c45141dcff936b11dfb1cad270edc0aa67653f5a1 test/results/test0010-knight-native-binary
c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test0010-knight-posix-binary
df9a8884564339e469d5dc1bea19880f3865ebcd324abd1187c17c172c4a9c15 test/results/test0010-x86-binary
1f3d14ae4684c90aa403ff0ba24ac4e1effe412c901f055f5abd2b16b5e17bf1 test/results/test0011-aarch64-binary
ed95fa4411d4601d4cc6b5d1fe6c33dac5eb80dcf18b50938c10a42fe83ae267 test/results/test0011-amd64-binary
a99f1a47d36c3b1a71e413a0d5a85d9a0b4710cff8c10e87caf6c2cf6bf4a0f1 test/results/test0011-armv7l-binary
7115c4a552eb4b2c1a868ac3dca43be7d040c8e89b7b66851d0522d298429af9 test/results/test0011-knight-native-binary
63fd5fbf389d1b19031026df193ec55e98d923b8568007125b80bc246c094496 test/results/test0011-knight-posix-binary
c95210154dc562a7444ef4ffbd0e237189587160c9775a65cdc9fe43f605548e test/results/test0011-x86-binary
154029b7834cefa4a5efab6e594ed14f04a1b7370d50b3e69d51fa44f8007c64 test/results/test0012-aarch64-binary
7cc8cf1507fc011528e16ff24c595ebb83a89ea5ef10aa9bceced349d09a1e0d test/results/test0012-amd64-binary
97fa429b7ead8280fdda24db61be2f7326ddfcbfb3032b6133d5c3cf21128bc3 test/results/test0012-armv7l-binary
61d043a6b25c34d470b01e8b8458427c32350574ba9f69eeed01ad1cde444167 test/results/test0012-knight-native-binary
313536f9209d29d4c3b40f6ada898f81c1fb3b650ca1a84754f90b1db3b9e001 test/results/test0012-knight-posix-binary
16d8a625ab4435ed8fae9a215fe8c56ccad9bd786a0a20e84470abefb15ca859 test/results/test0012-x86-binary
7742664a559bc4f6a702d9dcf69c684b698c7b93c3aaf388d4c766b97b3563ba test/results/test0013-aarch64-binary
f5003692cfbb87d7ce8772f510d7456d9a13d3c935d2ad919e9d08a720069d74 test/results/test0013-amd64-binary
743639eb3a21ce59db4e218af476d44190c4db46ed91443ea2356a4a5552ae22 test/results/test0013-armv7l-binary
291900015203744afc992273d19517e5c1aa9babca7d6d04a2f31b502b163414 test/results/test0013-knight-native-binary
e50c97ba330823cb5cbe938bb9d1575340b083e60fc42db8edefcfd95851daa2 test/results/test0013-knight-posix-binary
3f40a368c4d456384e4bf50f11149f78539a31b997b422038a81b883db616d24 test/results/test0013-x86-binary
6b506e21767d3b3945c6506a7b0aa6e194162dc2e6e9f3676a8a1c12170903e3 test/results/test0011-aarch64-binary
eea0efca30881a43444c2d7ade16ed8b5e66079910a77052c5ca290be4a3a90b test/results/test0011-amd64-binary
b28bce3cd08600951c0bfbc8e9493a9b1b3f5c11f5920099a8573ffdc814c740 test/results/test0011-armv7l-binary
48c74209ec3232242d7c6d6fc4e1560a0775550f7196560ee01a5d2940a105cb test/results/test0011-knight-native-binary
d41f58803d35fc65dcf1faf9db82617deaa0200adb84a038d428d9fe56d12d83 test/results/test0011-knight-posix-binary
91d60cba7c79e6d31542470f4a6978e428157a72f5362f70a2ecb03e95eccd03 test/results/test0011-x86-binary
649cb947d1794a304add002938827345ef37dfe3f7ebd5affa84eb13488de76e test/results/test0012-aarch64-binary
c5c52f9b8be8f344913a505d1aa0c42a1d3118f66a780a33783d4cfd0fb73e25 test/results/test0012-amd64-binary
92c194b98b704a9ea04ce32868f6e7df8121e13840409240c8aa0d7a20b9f4a4 test/results/test0012-armv7l-binary
162b90996d249f36448f5f2b7829dbf06c0c13158f7e415062c19fb4a8d51ecb test/results/test0012-knight-native-binary
65bd43f6255a6c191c43264eb7957ee4ad42b90a4e02410288f94781fb393e66 test/results/test0012-knight-posix-binary
f6cef5d9ffd57496fc05fe4af6e3e71cc8383449bee58cb440dc16ac40c9d881 test/results/test0012-x86-binary
874c02af05377f659ef3d24fa9c8cc67d411c58d9f5331eb0b819e2e7c7d878d test/results/test0013-aarch64-binary
d6f8fc5c0c898f2f4a70aacdca44d8d7727a57c1525f18a297b7c85e55a2c866 test/results/test0013-amd64-binary
fb26bd9a45f829e843e619e1ed643eb4169019e444ac74a12872774d415bc237 test/results/test0013-armv7l-binary
6eeb67ab322141f5022558ec438498e8a6208f9b62e186df3a5d008c30ab24fd test/results/test0013-knight-native-binary
de701a3e9a8c019f6f657a9dc19e50cb1c71c1d17f442e5e3f452e59bfe01728 test/results/test0013-knight-posix-binary
0c0efec42e93d781282c74d061174c9fa0d677c11d4a616b56ca55fea4f719f9 test/results/test0013-x86-binary
1486bd40eac8394d0b5d195cb648370f5726fb3daa2bbd008cbe5df6b77b7c88 test/results/test0014-aarch64-binary
3fde6df916fcb273770ee83eb0bc757fe6dedd022cfbe6cb91641ff335f7e3fd test/results/test0014-amd64-binary
390deb0728a6ee883ef4ccd4720041ee77a69d0d218b25403846704f6300d3e2 test/results/test0014-armv7l-binary
@ -92,11 +92,11 @@ e783d1a24a892f326ef8166d9fd0bf318d93fa7112b244973569e4332d9c5f0d test/results/t
469ae52e773e33a06332e6372eee87c9243d833ea16153e9aeef33ebcc06deb7 test/results/test0015-armv7l-binary
1635f0389cda6d976855850993168240605012d67a214f1adc14902204da7f5c test/results/test0015-knight-posix-binary
fe84418a5aa71ba024a3910d66ff0ea809c855a47383cd64a8dac00a329e32aa test/results/test0015-x86-binary
6d38948c21ea9252d6ba8a9f67c441953905a4811ee1900bd03c672d062bdc98 test/results/test0016-aarch64-binary
1bcee53d9fe695dbdeab93bd8be7ee75b7dffef1b3b0458b93e076a42d9658b2 test/results/test0016-amd64-binary
1eab12d44e214ddd3ca1d830edbd26415b78c75055845e540375068dd26fc876 test/results/test0016-armv7l-binary
602c12a1989ee26bbe437b8a40ce9b99b7be3936495de89a4823fa182f012c7a test/results/test0016-knight-posix-binary
71ed1297fedcd77634d5060ca673ee2d191089f109832178f669034d997c1df6 test/results/test0016-x86-binary
43dbac35148ffffc561a68ef4179161f6d84112a35e20d01f6520b3fa49d0b18 test/results/test0016-aarch64-binary
44916f3c2efb03442a359e41eb9768d8c395c626c6b364b55079318265929583 test/results/test0016-amd64-binary
910e97d9a9a8bc8b6e5979641c5a2516acdbd45709fe67462602d7fd429fee15 test/results/test0016-armv7l-binary
5ec7f36bd7b18bd6be245df9d8908fdb32019a5435a6a11c87a0186f54bc9f20 test/results/test0016-knight-posix-binary
5e617d9934312d4a9d27870af995fb2171cb9c5fb6f7b12c118df797dc47a1c9 test/results/test0016-x86-binary
ca186d12b91ad4f89141c05345680fe83a161766ba4bb49ff0ea28bde77e89b1 test/results/test0017-aarch64-binary
bd70143ec9764bd5681c72e173b6baaca7a486c9330974ca82fb7e997249f572 test/results/test0017-amd64-binary
4618cba0ac8a2aa09c434388be9e2275cfb512c457a9f10e2ec64c06a3f4cf2c test/results/test0017-armv7l-binary
@ -135,42 +135,42 @@ f0d50c97a4014a9a49a9cb6636234f289c321a6634d65503d12ec4a3a4693aba test/results/t
afd5d479066402228964a3216235f091065b0922b76576a7c972e93f0fb88684 test/results/test0023-armv7l-binary
720334fcaf22a1e8ec13f722ab1b6da1882bedef7289e188157b29e6ab708716 test/results/test0023-knight-posix-binary
c487702062d19227e59c1f6280ef5f24d48f9c652801f4a1eaa0412ec9dda92d test/results/test0023-x86-binary
44a5d13146df48ea39ad3bdb7627d7e60c6974778c612bb16583b130506f9195 test/results/test0100-aarch64-binary
6a7bfc651df8c98e61c4aecd1b43e4bfd1dbf79c33bcb7fdb9bade398f2ad667 test/results/test0100-amd64-binary
da64739046a84214ee6ee3edbec864bfd1c702a22a063a39ee83abe09c008393 test/results/test0100-armv7l-binary
7b439e2b7297f165cebbd17477924a077d713ed2313609c77015f9321a2d5738 test/results/test0100-knight-posix-binary
ee0fe808b0d79b8fcfdbf3e21fba95d96d6c89b56f43c9c579473784f88cca63 test/results/test0100-x86-binary
86dd73d63bd484400be8f0dacc1bf5b27a08851b58cab0e3a77209a123e5a17a test/results/test0101-aarch64-binary
33f5fa27de5dd7f81976c50ff900062ba4fb6a89f157fd13bf3f45903b926f8f test/results/test0101-amd64-binary
06f49d4acc84feeec133f9736841b7bd2f9702bc93b5de5f5b303aaa603d7a69 test/results/test0101-armv7l-binary
10077e30c5754affd18880b8b70b6e8ca424b0383944555dd0b1d4b1268cc0b2 test/results/test0101-knight-posix-binary
5de130a152c382fe4eda6d0b6b7697a26af6bffc30117c84cfc6ab9e74521663 test/results/test0101-x86-binary
7624de3657ba7f662c2d560128aeab979e36005c8af7dfaef2aef9114820599b test/results/test0102-aarch64-binary
f1b89393aaa7f349950462939b2e61b4404e731134e689e86d5e7012866f3f87 test/results/test0102-amd64-binary
413f429d5a5dfed9c254d5e9f5f87a3f4b240002cab7f2ecc60700d47adf8c81 test/results/test0102-armv7l-binary
2fd1859cf73d3785a39409a559818e2043f07dcc0e87c38d73a1ffb606946e57 test/results/test0102-knight-posix-binary
ae505ccf9cc5e1976c3a0f0e18ddd3a3752d15f36e4a58855323501b8edf2994 test/results/test0102-x86-binary
53326b67c8932da0d61c18511245a5c740e037a928aa5d882741bf0099ba5ef4 test/results/test0100-aarch64-binary
ed42d7ef7b3f1e99b1266c9d8cc5032bd17f29880e2c1ddca7031795459a1aa7 test/results/test0100-amd64-binary
3abd9279114df2afa56fa3bbc2a5529174f8fb5d63878dc37f289ca48ef70f41 test/results/test0100-armv7l-binary
0186bd14060ee2f85cd18f5405532ecb62516065d1e487a88212a61978fe3db0 test/results/test0100-knight-posix-binary
c21664610539bb9046895a98c46d8f30d24726278ad24f5ab7676d1f3b5d4925 test/results/test0100-x86-binary
01fa7569765d179495d97444e5b82dbeff36c41a4636674d3a6751401e4a7b6d test/results/test0101-aarch64-binary
0fcfca746f697fb2037cec05a934667efb8a7d15d1c5bb62c90a11c8bbe75eb8 test/results/test0101-amd64-binary
6e40185d52f0df1f55a0cc4a69780e4ef94e1ca5b11a5420964941b7b9bba7a9 test/results/test0101-armv7l-binary
d016c10cc61cc9c52cfd54f98423eb957aaf89738949bc47b94e6bc83569a9f5 test/results/test0101-knight-posix-binary
551fd272d788bb5bcfb2bd54ac762ba8c5e6e1b67fd6a1a64ed1394d0a997781 test/results/test0101-x86-binary
f447d08dd1f3071818e3b1b8ce94f191d87a918c00d2ceb85e95bd2dc13dc5ec test/results/test0102-aarch64-binary
619ff519a0e8616caa9de00d148bca6c5bdeb712f72b86406274b597c25075c5 test/results/test0102-amd64-binary
f541aa70901e0c1ba1da23d702da2de34e7f525fd43cf9e4238638cc317f2bb5 test/results/test0102-armv7l-binary
1a422238b969fbdb00f2dad06e11e1626d8760c283d9cc35ae2c726935ad8381 test/results/test0102-knight-posix-binary
b92f51933626f78c25592a9ac66d230379484e760196e48cc7cea67ae25dd342 test/results/test0102-x86-binary
368f12e4e708439156a5d3f777efd2c09130dd0ea6d6959f9400e905fe3c23e1 test/results/test0103-aarch64-binary
f2114b5217c12952a85d580ad5914dd679888d93d176ee132ace9e8773916b3b test/results/test0103-amd64-binary
79cbb69a747b07d729db736bc177b52b344106387831a0210ff18fce92edf1cc test/results/test0103-armv7l-binary
aa0658748cb076122f6166bc1a5759ae7e8fda92f952e139bb848ef52c5f9e69 test/results/test0103-knight-posix-binary
87c3c6ac883900334d2caa6695cab42628d2cb554e2216a5d541ec349df458b0 test/results/test0103-x86-binary
1c111888781d8f2c559c67607e7364d46d97bd8595954606a318ebdece778781 test/results/test0104-aarch64-binary
78250cc06d1c12ba73dd75f14e127cac7e0595ac84173c4ebb5504281be7a70e test/results/test0104-amd64-binary
d95b5af43752ec3031ef0a9490723960cb5b373a4042e1b78a754fdb0d60df14 test/results/test0104-armv7l-binary
3f448ba0dddf5bc69c11b787f51cf929f53aa0e9fd2d4cc6885b70c2ec87ca35 test/results/test0104-x86-binary
b2d50750bbf78a780475c1c30c16d448504bcc92ad6f0ae094d8edf32aea59c2 test/results/test0105-aarch64-binary
96a7b2fc48cebbbe2b00875d9facab766e750ea2c1b2d89ccd00b3b143607a05 test/results/test0105-amd64-binary
04ac97e210a0d3b48c9a8ac4b0d6720325d787ab4dad2fdafc1d3bcfcd3da2ca test/results/test0105-armv7l-binary
107b2d27dd779d0d954cca657b2f909863448cbf2045dee1875e13facf10bc3d test/results/test0105-x86-binary
6ebfeb72ea3c0bb5a88bef45dbb3cbabd506c7063db7438d93126d2d8fa4a367 test/results/test0106-aarch64-binary
5f5b00c90e77da4ffebb6ebc7607a1ad0db02c0c0d85770efedaca8088d59287 test/results/test0106-amd64-binary
c22dabd4d371e23ed10389080eaa241f31a3822f08c64c934776c80b2e376a51 test/results/test0106-armv7l-binary
6eb826151abe3ea2d7c1f16079e61f1b80d651a20f8341fbb77574f7b5c41fb3 test/results/test0106-knight-native-binary
61cdce452cb287467efbf315da67f3d107f5d3a9c3cf5b086bf51dcc67d78971 test/results/test0106-knight-posix-binary
55804110c3b2d5a5e5130a8ed11f0888f4460ee32ad6a86fde877ec914624a6d test/results/test0106-x86-binary
b952f44841f440020baa6ef5243ec223fb85f7a1f2326c0b40ee16b65dbebe49 test/results/test1000-aarch64-binary
23875877e8721ed56c3e0ef625ac264bd39d9ed594905adebf1c2e933e33cca5 test/results/test1000-amd64-binary
ef705712c741acb90464ab58154c16832658a980bc7a55c48aea64e59ea93ebc test/results/test1000-armv7l-binary
7d7b4dbeea3aac3a91fb093ddd4b37baf8898ddf5f8f2af8006529f737b75a93 test/results/test1000-knight-posix-binary
3b8bec2a562ac0a5c6a623563ad7622a987b24e47937885d1f21d2ea17871e34 test/results/test1000-x86-binary
2c98174518a8936a8c74af385ee10660e17bdfde350f477adf7f8455098ba4f1 test/results/test0104-aarch64-binary
2cc54e3c7a1f5eec07071dfb422c8a96e2a6bbd6eb8c99e25122e1abbcf89ed9 test/results/test0104-amd64-binary
5172743dab7c449c49d0ef8a6bebba4de8bdcb5fa490ec55fe41f6829064ee8d test/results/test0104-armv7l-binary
add5e186f05adf1a05331ecc5e5b259c9a3de2a7ea3bad535e8204c5acef67b0 test/results/test0104-x86-binary
74c04f3b7f0fcf2eb3f03b42bd1b22b20fd7a930e53d002440159fd03c8f9fa9 test/results/test0105-aarch64-binary
a4cceec8c46c3f0e55d82286d5a67e52e44338b8f3af10e9de7671703e413053 test/results/test0105-amd64-binary
450ca9e7a1786c6f8ee55efd27a0006f991277f16965f6ada14d6e7df15b40f8 test/results/test0105-armv7l-binary
80313d5c34c9da2a7fac4c34e7351f0a9ced5c4396ecdd3d5e0cd9d88f71b3db test/results/test0105-x86-binary
f7118896ebec71429b08a951e11d8b9ed4eb1f52f6e8738e0087e4a8dc9e84eb test/results/test0106-aarch64-binary
748feb37b35f89c16e00045c6bb5c787e7478023b128404cedd7a67b256b974c test/results/test0106-amd64-binary
a2a83f42119e646b389b98647cf6cf2aa9597185997c9453db746178c8c4c0bf test/results/test0106-armv7l-binary
6c10f796fdb986a3a52a4ed8ad1a4eb4c1023c5dd99101a2aeadd9bad4d064ef test/results/test0106-knight-native-binary
6852a8f33ec49d43bcfb3ffff1e04900ad146806aeb67ed1749d15baed50bcb5 test/results/test0106-knight-posix-binary
3e026925ec537c817f815b4748e19e4edc0487643b66d8df00a831c73229059e test/results/test0106-x86-binary
faccfa595a90874aaf7a28f3000f6869bcc85ace8a5622f3e6d853814e76687c test/results/test1000-aarch64-binary
258068d01c1cd86d8edf7a30d62be32c463f35aed8db79e48230a82df706846a test/results/test1000-amd64-binary
a541e31ba118cdc8dc8e21b0209a2452e8bab2031cc0296b3e11eaee0201a1a5 test/results/test1000-armv7l-binary
eee2d17b91000fdbb7d978c449044c7943d660ddeded3cbc0b85fa317d43ae72 test/results/test1000-knight-posix-binary
cde5373a30c8cc2be97f82a186ddc2f01ab65b47943d7b2068d540199988c62d test/results/test1000-x86-binary

View File

@ -20,9 +20,10 @@
int main()
{
int i = 65;
int j;
do
{
int j = i;
j = i;
do
{
putchar(j);

View File

@ -32,9 +32,10 @@ int main()
putchar(10);
i = 65;
int j;
do
{
int j = i;
j = i;
do
{
if(70 == i)

View File

@ -31,9 +31,10 @@ int main()
putchar(10);
int j;
for(i = 65; i <= 120; i = i + 1)
{
int j = i;
j = i;
for(j = i; j <= 90; j = j + 1)
{
if(70 == i)

View File

@ -32,9 +32,10 @@ int main()
putchar(10);
i = 65;
int j;
while (i <= 120)
{
int j = i;
j = i;
while (j <= 90)
{
if(70 == i)

View File

@ -19,9 +19,10 @@
void write_string(FILE* f)
{
int i = 65;
int j;
do
{
int j = i;
j = i;
do
{
fputc(j, f);

View File

@ -174,6 +174,7 @@ int main(int argc, char **argv)
struct entry* input = NULL;
output = stdout;
char* output_file = "";
struct entry* temp;
int option_index = 1;
while(option_index <= argc)
@ -191,7 +192,7 @@ int main(int argc, char **argv)
}
else if(match(argv[option_index], "-f") || match(argv[option_index], "--file"))
{
struct entry* temp = calloc(1, sizeof(struct entry));
temp = calloc(1, sizeof(struct entry));
temp->name = argv[option_index + 1];
temp->next = input;
input = temp;

View File

@ -214,9 +214,10 @@ void outputPointer(int displacement, int number_of_bytes)
}
else
{ /* Deal with LittleEndian */
unsigned byte;
while(number_of_bytes > 0)
{
unsigned byte = value % 256;
byte = value % 256;
value = value / 256;
fputc(byte, output);
number_of_bytes = number_of_bytes - 1;
@ -546,6 +547,7 @@ int main(int argc, char **argv)
ByteMode = 16;
scratch = calloc(max_string + 1, sizeof(char));
char* arch;
struct input_files* temp;
int option_index = 1;
while(option_index <= argc)
@ -606,7 +608,7 @@ int main(int argc, char **argv)
}
else if(match(argv[option_index], "-f") || match(argv[option_index], "--file"))
{
struct input_files* temp = calloc(1, sizeof(struct input_files));
temp = calloc(1, sizeof(struct input_files));
temp->filename = argv[option_index + 1];
temp->next = input;
input = temp;

View File

@ -90,9 +90,10 @@ struct Token* newToken(char* filename, int linenumber)
struct Token* reverse_list(struct Token* head)
{
struct Token* root = NULL;
struct Token* next;
while(NULL != head)
{
struct Token* next = head->next;
next = head->next;
head->next = root;
root = head;
head = next;
@ -366,11 +367,12 @@ char* pad_nulls(int size, char* nil)
void preserve_other(struct Token* p)
{
struct Token* i;
char c;
for(i = p; NULL != i; i = i->next)
{
if((NULL == i->Expression) && !(i->type & MACRO))
{
char c = i->Text[0];
c = i->Text[0];
if(in_set(c, "!@$~%&:^"))
{
@ -560,6 +562,7 @@ char* express_number(int value, char c)
void eval_immediates(struct Token* p)
{
struct Token* i;
int value;
for(i = p; NULL != i; i = i->next)
{
if(MACRO == i->type) continue;
@ -567,7 +570,6 @@ void eval_immediates(struct Token* p)
else if('<' == i->Text[0]) continue;
else if(NULL == i->Expression)
{
int value;
if((1 == Architecture) || (2 == Architecture) || (40 == Architecture))
{
value = numerate_string(i->Text + 1);

View File

@ -222,6 +222,9 @@ int check_envar(char* token)
int j;
int equal_found;
equal_found = 0;
int found;
char c;
for(j = 0; j < string_length(token); j = j + 1)
{
if(token[j] == '=')
@ -231,9 +234,7 @@ int check_envar(char* token)
}
else
{ /* Should be A-z */
int found;
found = 0;
char c;
/* Represented numerically; 0 = 48 through 9 = 57 */
for(c = 48; c <= 57; c = c + 1)
{
@ -266,17 +267,27 @@ int check_envar(char* token)
/* Function for executing our programs with desired arguments */
void execute_commands(FILE* script, char** envp, int envp_length)
{
char* PATH;
char* USERNAME;
int i;
int status;
char* result;
int j;
int is_envar;
char* program;
int f;
while(1)
{
tokens = calloc(max_args, sizeof(char*));
char* PATH = env_lookup("PATH=", envp);
PATH = env_lookup("PATH=", envp);
if(NULL != PATH)
{
PATH = calloc(max_string, sizeof(char));
copy_string(PATH, env_lookup("PATH=", envp));
}
char* USERNAME = env_lookup("LOGNAME=", envp);
USERNAME = env_lookup("LOGNAME=", envp);
if((NULL == PATH) && (NULL == USERNAME))
{
PATH = calloc(max_string, sizeof(char));
@ -287,12 +298,12 @@ void execute_commands(FILE* script, char** envp, int envp_length)
PATH = prepend_string("/home/", prepend_string(USERNAME,"/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"));
}
int i = 0;
int status = 0;
i = 0;
status = 0;
command_done = 0;
do
{
char* result = collect_token(script);
result = collect_token(script);
if(0 != result)
{ /* Not a comment string but an actual argument */
tokens[i] = result;
@ -303,7 +314,6 @@ void execute_commands(FILE* script, char** envp, int envp_length)
if(VERBOSE && (0 < i))
{
file_print(" +> ", stdout);
int j;
for(j = 0; j < i; j = j + 1)
{
file_print(tokens[j], stdout);
@ -314,7 +324,6 @@ void execute_commands(FILE* script, char** envp, int envp_length)
if(0 < i)
{ /* Not a line comment */
int is_envar;
is_envar = 0;
if(check_envar(tokens[0]) == 0)
{ /* It's an envar! */
@ -325,7 +334,7 @@ void execute_commands(FILE* script, char** envp, int envp_length)
if(is_envar == 0)
{ /* Stuff to exec */
char* program = find_executable(tokens[0], PATH);
program = find_executable(tokens[0], PATH);
if(NULL == program)
{
file_print(tokens[0], stderr);
@ -334,7 +343,7 @@ void execute_commands(FILE* script, char** envp, int envp_length)
exit(EXIT_FAILURE);
}
int f = fork();
f = fork();
if (f == -1)
{
file_print("fork() failure", stderr);

View File

@ -71,6 +71,7 @@ int main(int argc, char **argv)
file_output = fopen("/dev/null", "w");
console_output = stdout;
struct file_list* essential = NULL;
struct file_list* new;
int i = 1;
while(i <= argc)
@ -93,7 +94,7 @@ int main(int argc, char **argv)
}
else if(match(argv[i], "-f") || match(argv[i], "--file"))
{
struct file_list* new = calloc(1, sizeof(struct file_list));
new = calloc(1, sizeof(struct file_list));
new->file = fopen(argv[i + 1], "r");
if(NULL == new->file)
{

View File

@ -99,11 +99,12 @@ void relocate_cell(struct cell* current, struct cell* target, struct cell* list)
struct cell* pop_cons();
void compact(struct cell* list)
{
struct cell* temp;
for(; NULL != list; list = list->cdr)
{
if((FREE != list->type) && (list > free_cells ))
{
struct cell* temp = pop_cons();
temp = pop_cons();
temp->type = list->type;
temp->car = list->car;
temp->cdr = list->cdr;

View File

@ -40,10 +40,11 @@ struct cell* tokenize(struct cell* head, char* fullstring, int size)
}
char *store = calloc(MAX_STRING + 1, sizeof(char));
int c;
do
{
int c = fullstring[i];
c = fullstring[i];
if((i > size) || (MAX_STRING <= i))
{
done = TRUE;
@ -190,9 +191,10 @@ struct cell* readlist()
struct cell* reverse_list(struct cell* head)
{
struct cell* root = NULL;
struct cell* next;
while(NULL != head)
{
struct cell* next = head->cdr;
next = head->cdr;
head->cdr = root;
root = head;
head = next;

View File

@ -214,9 +214,10 @@ void sym_declare(char *s, int type, int value)
{
int t = table_pos;
i = 0;
int x;
while (s[i] != 0) {
if (table_size <= t + 10) {
int x = (t + 10) << 1;
x = (t + 10) << 1;
table = my_realloc(table, table_size, x);
table_size = x;
}
@ -725,6 +726,7 @@ void statement()
void program()
{
int current_symbol;
int n;
while (token[0]) {
type_name();
current_symbol = sym_declare_global(token);
@ -734,7 +736,7 @@ void program()
emit(4, "\x00\x00\x00\x00");
}
else if (accept("(")) {
int n = table_pos;
n = table_pos;
number_of_args = 0;
while (accept(")") == 0) {
number_of_args = number_of_args + 1;

View File

@ -1 +1 @@
5ab41b5e38ef0a29ad3fcd66b9e339d050b870d9160a83e9405d3f0444e72a33 test/test0106/cc1
c21a536928bab3b581f000882078821f8780f175f0870adf045f6fa3154cf5a9 test/test0106/cc1

View File

@ -1 +1 @@
5ab41b5e38ef0a29ad3fcd66b9e339d050b870d9160a83e9405d3f0444e72a33 test/test0106/cc2
c21a536928bab3b581f000882078821f8780f175f0870adf045f6fa3154cf5a9 test/test0106/cc2

View File

@ -1 +1 @@
df2c542a46a5367f62b3a573256942bc139fdcd5cd49547b43257ab889c50bad test/test1000/proof
793a85cf64a6895751cd45388c4899f3f3c83fb0f06af7e455d034771ddcb5da test/test1000/proof