Cleared out non-essential string primitives and added support for --max-string

This commit is contained in:
Jeremiah Orians 2020-12-19 09:46:22 -05:00
parent d9504e3872
commit e7a0ecd244
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
12 changed files with 76 additions and 88 deletions

View File

@ -31,6 +31,7 @@ char* parse_string(char* string);
int main()
{
MAX_STRING = 4096;
hold_string = calloc(MAX_STRING, sizeof(char));
FILE* in = fopen("tape_01", "r");
FILE* destination_file = fopen("tape_02", "w");

18
cc.c
View File

@ -26,11 +26,11 @@ struct token_list* read_all_tokens(FILE* a, struct token_list* current, char* fi
struct token_list* reverse_list(struct token_list* head);
void program();
void recursive_output(struct token_list* i, FILE* out);
int numerate_string(char *a);
int main(int argc, char** argv)
{
hold_string = calloc(MAX_STRING, sizeof(char));
require(NULL != hold_string, "Impossible Exhustion has occured\n");
MAX_STRING = 4096;
int DEBUG = FALSE;
FILE* in = stdin;
FILE* destination_file = stdout;
@ -47,6 +47,12 @@ int main(int argc, char** argv)
}
else if(match(argv[i], "-f") || match(argv[i], "--file"))
{
if(NULL == hold_string)
{
hold_string = calloc(MAX_STRING, sizeof(char));
require(NULL != hold_string, "Impossible Exhustion has occured\n");
}
name = argv[i + 1];
in = fopen(name, "r");
if(NULL == in)
@ -89,6 +95,12 @@ int main(int argc, char** argv)
}
i = i + 2;
}
else if(match(argv[i], "--max-string"))
{
MAX_STRING = numerate_string(argv[i+1]);
require(0 < MAX_STRING, "Not a valid string size\nAbort and fix your --max-string\n");
i = i + 2;
}
else if(match(argv[i], "-g") || match(argv[i], "--debug"))
{
DEBUG = TRUE;
@ -114,6 +126,8 @@ int main(int argc, char** argv)
/* Deal with special case of wanting to read from standard input */
if(stdin == in)
{
hold_string = calloc(MAX_STRING, sizeof(char));
require(NULL != hold_string, "Impossible Exhustion has occured\n");
global_token = read_all_tokens(in, global_token, "STDIN");
}

2
cc.h
View File

@ -20,8 +20,6 @@
#include <stdio.h>
#include <string.h>
// CONSTANT MAX_STRING 4096
#define MAX_STRING 4096
// CONSTANT FALSE 0
#define FALSE 0
// CONSTANT TRUE 1

View File

@ -35,3 +35,5 @@ int string_index;
/* Our Target Architecture */
int Architecture;
int register_size;
int MAX_STRING;

View File

@ -35,3 +35,5 @@ extern int string_index;
/* Our Target Architecture */
extern int Architecture;
extern int register_size;
extern int MAX_STRING;

View File

@ -38,7 +38,7 @@ int consume_byte(int c)
{
hold_string[string_index] = c;
string_index = string_index + 1;
require(MAX_STRING > string_index, "Token exceeded 4096char limit\n");
require(MAX_STRING > string_index, "Token exceeded MAX_STRING char limit\nuse --max-string number to increase\n");
return fgetc(input);
}

View File

@ -32,7 +32,7 @@ char* numerate_number(int a)
char* result = calloc(16, sizeof(char));
if(NULL == result)
{
file_print("calloc failed in prepend_char\n", stderr);
file_print("calloc failed in numerate_number\n", stderr);
exit(EXIT_FAILURE);
}
int i = 0;

View File

@ -17,10 +17,6 @@
#include<stdlib.h>
#include<stdio.h>
#define MAX_STRING 4096
//CONSTANT MAX_STRING 4096
// void* calloc(int count, int size);
void file_print(char* s, FILE* f);
char* copy_string(char* target, char* source)
{
@ -33,44 +29,6 @@ char* copy_string(char* target, char* source)
return target;
}
char* postpend_char(char* s, char a)
{
char* ret = calloc(MAX_STRING, sizeof(char));
if(NULL == ret)
{
file_print("calloc failed in postpend_char\n", stderr);
exit(EXIT_FAILURE);
}
char* hold = copy_string(ret, s);
hold[0] = a;
return ret;
}
char* prepend_char(char a, char* s)
{
char* ret = calloc(MAX_STRING, sizeof(char));
if(NULL == ret)
{
file_print("calloc failed in prepend_char\n", stderr);
exit(EXIT_FAILURE);
}
ret[0] = a;
copy_string((ret+1), s);
return ret;
}
char* prepend_string(char* add, char* base)
{
char* ret = calloc(MAX_STRING, sizeof(char));
if(NULL == ret)
{
file_print("calloc failed in prepend_string\n", stderr);
exit(EXIT_FAILURE);
}
copy_string(copy_string(ret, add), base);
return ret;
}
int string_length(char* a)
{
int i = 0;

View File

@ -109,27 +109,27 @@ bdb95323821eea5b757445d1d4a8f79256a4b665c2a0666cbbb7931550ba4a6f test/results/t
cc0da63ac84b37fef8e0367246a01b3aea7be95dd410297d80500e8d43a54b32 test/results/test0018-knight-native-binary
a2cba152dd5dd47a574aec274d22fbda6efad301ddd942cdd928b69f92902fcb test/results/test0018-knight-posix-binary
b547b060881bbbd564d18575b5a96b4f5837ece88ea1f7a20bc5fb1b736361e4 test/results/test0018-x86-binary
de21e25c26b229c674461b28f3cc0e36c0a0d0b2287bece7590f8db47c3c8e37 test/results/test0019-aarch64-binary
5279026cb14f83907279c5372b9cc4b33f1481ed08f814b77fb82fab9382cb4a test/results/test0019-amd64-binary
6ff8fb4779ba53865a0f21b658c91db58a7fb11514978855acc6b1482d3ddbc0 test/results/test0019-armv7l-binary
829a00a8b9b90eca5ff6eb0100d1327e102f5a83e12a4e7073ae0b9bece81aa1 test/results/test0019-knight-posix-binary
18b7ab44902784a60444c120ec73fe01410a73ca89bbceb1cb2522e024ad0f2c test/results/test0019-x86-binary
b1e368b0646314160216099aa710ba13322fce4d2254571283f07eb2f7234b5d test/results/test0019-aarch64-binary
4408ec0de10d5acf615a993950e42f4e9d5cfcd6a4e734a3ad258fb94cfebda6 test/results/test0019-amd64-binary
7146c67402facbef9e1c5aa6551d6cf537ab48ab5ff232b919a311933a2099b7 test/results/test0019-armv7l-binary
806a8579971761a375b9bd8934f4aac7f7430821ffc6decf320e9a07629a9110 test/results/test0019-knight-posix-binary
780d1f741322cf286cdf002bc8e7bb49f958a2d5bc641ec4cb79686c330b4ddd test/results/test0019-x86-binary
6b31e8ee54270d38a1801f7614ae6247f59d44a2758f344b07a72794019290f4 test/results/test0020-aarch64-binary
6b2956b106dd16bb55d8d011b48e674ee3b70bbb0bb83efadca01d446666e21e test/results/test0020-amd64-binary
b29aca7f0b63659915fe431e290f821cf17071983613021aacb8985d376bb206 test/results/test0020-armv7l-binary
f1795d82f5d39e5d2995882a627c74fa972bc749675d4a294732f9285a5ae3c2 test/results/test0020-knight-native-binary
d2e5a7672854bf190dd6e2f08081a5dbea22c08d77b4a62f76af68db033aea14 test/results/test0020-knight-posix-binary
1183247a4f714b9d1b0ec78b40f49631df3769ae95b0303fa9996208193c4ec9 test/results/test0020-x86-binary
4bcc06013b48bc2fb95e0993835e1ba6980701ce7052fb01fe8fdd3ddc0f7a19 test/results/test0021-aarch64-binary
db58e65fb5c977ffabfd0284fe3b215c34db5ecc4bf67b9dcd62e4bd8a45807b test/results/test0021-amd64-binary
b56c9a9e68931081e18f855017729b90e8dffb5d81ab900acba1fa824e9b2cc5 test/results/test0021-armv7l-binary
c7bdb01426e19d1263cfd84d6c264585c8130f16801e7f6c2e0f2587aed8018d test/results/test0021-knight-posix-binary
602b8f095b401ec654d358f526787b4a53541fe03b235d5971bc6bdfa8f13878 test/results/test0021-x86-binary
26c3da7c1f26ddebaf0de705e98fc35b5ff9a645c69ee19848790df6e9f590a1 test/results/test0022-aarch64-binary
6c9cd235477fdd070e8cf4aa6255100554b1a907249e0a41b61b44df16e03bca test/results/test0022-amd64-binary
bccd51a074ea646ef4c39410196e32366e952e788e82ad055c408142d26cbfbf test/results/test0022-armv7l-binary
1ab881dd102849750ce0d4c58621934abb664e740ab54f9c2637e4c2255a0661 test/results/test0022-knight-posix-binary
a70738aa2f1c56fdaacfa45e3fcce8deb105259fac3f6c9cf2804925138a3745 test/results/test0022-x86-binary
baa510d2b782c31d1c9edd402271e2ddf00542aefd6f4780b6975db5a1665e0c test/results/test0021-aarch64-binary
f10d5378c91d716270ca8e876ed1acb0eb68b48a6e04d5d5e39b22dd4e3bf98c test/results/test0021-amd64-binary
a9c09864fd326b9b42bc5a32dc32d248dbfcfa87ccdd97cfd21ee95af39a3db9 test/results/test0021-armv7l-binary
d7710f837d6461d5eb2391614553c7f69fa7e6211b201dca7790d21eeac6150a test/results/test0021-knight-posix-binary
34eb0ed2014f57d0a5f55c4ce2d7e594f390287adbc2c4109149792f3ee04855 test/results/test0021-x86-binary
14b9a108bdee811c0e9ff3f1be1299767a0d8b49319efbfd9b5f269bf5a057ec test/results/test0022-aarch64-binary
55fe99fe544bf885da6f3e9ab5463d75cd79e85053179b65ee122716792cbc15 test/results/test0022-amd64-binary
2d63c3a5a2c5b5ae2ea2e93c430027b4b418e229a963c66b9a3bc34307a55eba test/results/test0022-armv7l-binary
142893c2ce1f06126493c2dd6b4c1a4f4c6c86a581c255b22dc405668750175a test/results/test0022-knight-posix-binary
fefd0c6fff7a65b1db820d731e425086e8051bb06fd0a47476feeb79e8b9b5a9 test/results/test0022-x86-binary
5a9a0a19187247ed89d55aeb0b02beebae792b2908e70cf558042887878dcbc3 test/results/test0023-aarch64-binary
8cd6f04e55eb1d2c73315df8f4959d691c1243550c29671c2e8adc3cdbf1990d test/results/test0023-amd64-binary
afd5d479066402228964a3216235f091065b0922b76576a7c972e93f0fb88684 test/results/test0023-armv7l-binary
@ -140,37 +140,37 @@ ed42d7ef7b3f1e99b1266c9d8cc5032bd17f29880e2c1ddca7031795459a1aa7 test/results/t
3abd9279114df2afa56fa3bbc2a5529174f8fb5d63878dc37f289ca48ef70f41 test/results/test0100-armv7l-binary
aaf4fa670df4bf3a4369ac13e2bb2685d49b20e61e70ed36ffc71db17cd992bd test/results/test0100-knight-posix-binary
c21664610539bb9046895a98c46d8f30d24726278ad24f5ab7676d1f3b5d4925 test/results/test0100-x86-binary
4143145e0b03df893c64cc481703f8e5eab4cc8e881ee8138d82ccb1cd3978b5 test/results/test0101-aarch64-binary
0fcfca746f697fb2037cec05a934667efb8a7d15d1c5bb62c90a11c8bbe75eb8 test/results/test0101-amd64-binary
6e40185d52f0df1f55a0cc4a69780e4ef94e1ca5b11a5420964941b7b9bba7a9 test/results/test0101-armv7l-binary
b49459649c771c4028dca40849423a7b6488520d99d7badcfcfb252ab3ef2d5e test/results/test0101-knight-posix-binary
551fd272d788bb5bcfb2bd54ac762ba8c5e6e1b67fd6a1a64ed1394d0a997781 test/results/test0101-x86-binary
bac1ee147a0ef0a6ae1f6612240ced7028a0d54cf9b1339663ec6f482cf08382 test/results/test0102-aarch64-binary
fc6cc80a36547e948faa1d21ebbc2207e506c4d40d3880ebc6233576eaf20013 test/results/test0102-amd64-binary
d133d452dedc09a1d29fd711ff58269a961da8f6074bb3dcd0104feac656c61f test/results/test0102-armv7l-binary
e82594cb968ee20eb5e2ebeb36fca526eba1d2d6ac440085d307967dd7977abf test/results/test0102-knight-posix-binary
4aa547b1a55d15b70a350f0b74f1a551e684eb17ebcd9e09ef5654c59eb0990c test/results/test0102-x86-binary
996e9bb6e1987af468736ff5dbed69aa84d8b82207b70f9752713d8e9139f0fb test/results/test0101-aarch64-binary
3aa111b5734f52718ae4072f05a93ecaa47e4f75cb0b7f2e8671b476e6ddffdd test/results/test0101-amd64-binary
3947f4b38f71419098aefb50e7fd95f76d7f8bd71104991c8f6723208c0ea673 test/results/test0101-armv7l-binary
51bc16cfd62ca165cb36b60daba3005e54476563f712f0d628cc5d3d6ba4679f test/results/test0101-knight-posix-binary
46f85b1c300ebe546b1ab9c12df053b85764e9b699e11e6e9b19d7f748e9befb test/results/test0101-x86-binary
f1a022b13449ddbe3733aa8ca7abc1b8ed8bff4f02fe5453098a37f0a754aec3 test/results/test0102-aarch64-binary
20f52eccef8c3b373550c3d060fc84f55d31594016144300bab3b25d0bb60a1c test/results/test0102-amd64-binary
6d998868c98f4a7cd196d278f6cbc86b261cc6ae9c401ebf822bd8739aff714c test/results/test0102-armv7l-binary
7cf4800be45917fde35688def88ffd0f87b2f1a1685ecf0bc4aca1285b50f13e test/results/test0102-knight-posix-binary
c2bb9376fd5f815f6205486cc58c64f98f87ca60a58547f388704943b8de4172 test/results/test0102-x86-binary
603fd4fe17f8ef9eac12116003941702849b720021da23dc32582ca41192a792 test/results/test0103-aarch64-binary
f2114b5217c12952a85d580ad5914dd679888d93d176ee132ace9e8773916b3b test/results/test0103-amd64-binary
79cbb69a747b07d729db736bc177b52b344106387831a0210ff18fce92edf1cc test/results/test0103-armv7l-binary
0f8f90238756cd49b2ab098ede160a7847365c99e20ccf742a3e3fefb65bfbd0 test/results/test0103-knight-posix-binary
87c3c6ac883900334d2caa6695cab42628d2cb554e2216a5d541ec349df458b0 test/results/test0103-x86-binary
091064c92141dd70480e9cd4f34995989dc7ad853ace160a77d89303d7a1cb01 test/results/test0104-aarch64-binary
9deb2f3e7d916041b50d61df8ef15244a5d1050c2326a303ac4b3b2f915868cd test/results/test0104-amd64-binary
897195bc2aee17bdaf2064db6989b74a9c0e60805d22fddd970aeaf935235d7b test/results/test0104-armv7l-binary
9a9c974c104966882de5be4a68d85cf88f7cdfb4c95ae9dcfabe58b2c8232bb1 test/results/test0104-x86-binary
81dca0835beb3479c01b25058064e25a5ba42966c10a66ffdd06eb849d199f48 test/results/test0105-aarch64-binary
a498d43b19327f1342cb54e698db9fb237901ed0ab04890241bed00ff23eddbc test/results/test0105-amd64-binary
27af6c30cdf0e411edacbff6dc5c00f1b0d3b67e8a7923ebc8385bcb4486f4df test/results/test0105-armv7l-binary
f8ed88b69c3388c73a24b82702be0df9b06e06a8132ed9b75aed5aa8260f3b2d test/results/test0105-x86-binary
eb02e34879a5fc9ca214c76d57f4b0fef08f3218f35b49918e0008b56f763088 test/results/test0104-aarch64-binary
786a9b1c9816861a24a2918f07923db61fb860f4e266f74f995c162994ee310b test/results/test0104-amd64-binary
7e646f2719d6a77052dd7eba7613edf2bf2b5e01ab09e06931ec1009a9c5a8f6 test/results/test0104-armv7l-binary
2eba7a1531aac06e9b5d3fe6c8cb86ac3c79d5ac3e73210e8e4b8c9f8c164993 test/results/test0104-x86-binary
ab5a34d924f711217514a57bac99ca25fa0fca2d215370d14f8da80d328e0369 test/results/test0105-aarch64-binary
0cee078ac74d9ff745764ae1a824586bd38aa7c263c54242bce7cb715ac9006b test/results/test0105-amd64-binary
c0c23a81282875dc16d8c17a4943b371e560eeb3273844107cee2014b8043d6a test/results/test0105-armv7l-binary
554b19d6ff0098f730188874eaed1c6518c186b5cc5ee9d2a4fbc19a69d60c3d test/results/test0105-x86-binary
d405c1ed0b6dfb83bde9bfd22628a5884a92fd41aac8e89d89dbb7684528855d test/results/test0106-aarch64-binary
32a2990df4a353f5abf27b4cf9577f9e8b500270ebac0f6aa8c6a78c7f4856cb test/results/test0106-amd64-binary
ecfba440594147303a8c16a144498f4be517ec2f02bc440d0d21075e6a8bc8d3 test/results/test0106-armv7l-binary
99cb6024b886c9dc5ecaf38826dd70a3e823c3a647d20c5ccd2848628e54409f test/results/test0106-knight-native-binary
cad614f909f2b9ac0279b7b508193836bea3a050cecf987448d378f62f6af916 test/results/test0106-knight-posix-binary
c1f58b9b99e1d62814d911a853cce82c2e8220cdadf164c090bd0f3bf4d11caa test/results/test0106-x86-binary
d6186757e033c896f71a656bdf9c04802cb2d1ae70272d68ed8cd18d51ef0cff test/results/test1000-aarch64-binary
b8bbd62a6f6d720ee643504931e5a20b343d4a4e27dd5b47861ecad76e08cc62 test/results/test1000-amd64-binary
dd4c944ffeacae83bd229b69bbe82e849a3390aa6107dddcc83b8d7220f7a633 test/results/test1000-armv7l-binary
6e89d46094b0fad09c3b1fa158ce2c79c6d6f4e568d9cfd696b0abc7332e8544 test/results/test1000-knight-posix-binary
74e316ca24d9309f9ab1f8c3a179fc97f70188c1fe06561adfb451ea4022b653 test/results/test1000-x86-binary
dfd953297cf9c09fc729f368cce204bf7bd0f6ac8dbcfefc64b989edd212b71f test/results/test1000-aarch64-binary
8363fadf626f28a35b6e96ba8338edd3af611cb5c66f396285df95e54fb1c6f8 test/results/test1000-amd64-binary
ae04ca37aa19f3a6eaeddf4e9fa418ddd75c4a9cf5f163bba9768049dc98490b test/results/test1000-armv7l-binary
a92aa6a99fa61a369a4a0951d8b664589e2134841ed1e4dbf9b23bbc36520760 test/results/test1000-knight-posix-binary
412c50a0002f55e41d3596e6e3a1537d12bac19df748b503603594606a7c6083 test/results/test1000-x86-binary

View File

@ -26,7 +26,19 @@
int match(char* a, char* b);
char* get_current_dir_name();
char* copy_string(char* target, char* source);
char* prepend_string(char* add, char* base);
void file_print(char* s, FILE* f);
char* prepend_string(char* add, char* base)
{
char* ret = calloc(MAX_STRING, sizeof(char));
if(NULL == ret)
{
file_print("calloc failed in prepend_string\n", stderr);
exit(EXIT_FAILURE);
}
copy_string(copy_string(ret, add), base);
return ret;
}
int main()
{

View File

@ -39,6 +39,7 @@ int VERBOSE;
int STRICT;
int envp_length;
/* Function for purging line comments */
void collect_comment(FILE* input)
{

View File

@ -1 +1 @@
926e28a7c05db19f84afea41eb65ba59f1a08c10ad1b45875cfa37d5076e5112 test/test1000/proof
b878abf150b768fbbaa77f12652fc50eadb9d8cfa1ee07ff6eea8297d08cf5c4 test/test1000/proof