Add support for -D variable and -D variable=value

This commit is contained in:
Jeremiah Orians 2021-02-05 21:34:00 -05:00
parent 8007ae9ce6
commit a9d88e8e6c
No known key found for this signature in database
GPG Key ID: 6B3A3F198708F894
3 changed files with 25 additions and 6 deletions

19
cc.c
View File

@ -49,6 +49,8 @@ int main(int argc, char** argv)
init_macro_env("__M2__", "42", "__INTERNAL_M2__", 0); /* Setup __M2__ */
char* arch;
char* name;
int env=0;
char* val;
int i = 1;
while(i <= argc)
@ -134,6 +136,23 @@ int main(int argc, char** argv)
PREPROCESSOR_MODE = TRUE;
i = i + 1;
}
else if(match(argv[i], "-D"))
{
val = argv[i+1];
while(0 != val[0])
{
if('=' == val[0])
{
val[0] = 0;
val = val + 1;
break;
}
val = val + 1;
}
init_macro_env(argv[i+1], val, "__ARGV__", env);
env = env + 1;
i = i + 2;
}
else if(match(argv[i], "-V") || match(argv[i], "--version"))
{
file_print("M2-Planet v1.7.0\n", stderr);

View File

@ -179,8 +179,8 @@ ba2e2e1bbe66fea15d5984678175229fcb0adc6faa394be2cfde8bea1d3026de test/results/t
5afa9027627815aed92b0f239f4ac85318ca11c15c0c44ae0a0b9bc4ca599119 test/results/test0106-knight-native-binary
44d0b9e0433f12b5567ecddc9285b6a7d41ea646a7134e6fc3c394b4a973f6ba test/results/test0106-knight-posix-binary
1f83e1cbac44aabd9f87eae601e020b584b572e7edb738d6274972d6d100fa3c test/results/test0106-x86-binary
97b0faf131290244f627423e935168f5d5efb2a89d128c49fd7ad11711a9ea2f test/results/test1000-aarch64-binary
c68ae25541d200d184cd679ab8a5cb0c369d602f65a62ace73d103010983738d test/results/test1000-amd64-binary
615b5c95ee931e36e984aa7824a444fc550fdf0d218464e6808d5bbc3459092d test/results/test1000-armv7l-binary
eed78f27d9644cf465ed2223df05085bdaa4933d3d6a726734f568d5fcb82606 test/results/test1000-knight-posix-binary
c523cb219dc92a9c4c887d9104cc1b759845f96fd8cd9b680f86c7b45691b894 test/results/test1000-x86-binary
034a085bc57ce50806b126614a2b0756630568e1f17165364482a5386f7e0e11 test/results/test1000-aarch64-binary
5cb4bcb5eba5bef9869d8b29c58269019f6acad2e65cd6f1bcf0567ef157bf46 test/results/test1000-amd64-binary
0c03746a3e963815ae9723649d289102b8eee9ecbc96d455b85f7f687c5953be test/results/test1000-armv7l-binary
f384c9d740cf4645c6bb4e64b54ced79fc12765362bb8a8c4d9979a8f2e0f45d test/results/test1000-knight-posix-binary
8fbde579279c7c7a00601ac574468cebe67d9f807ea83a02b00b5496c0d70609 test/results/test1000-x86-binary

View File

@ -1 +1 @@
f8c98a3b045c02c171d3c0148d9f0f428cc6ada6d4d67e014ff3c1e33106c255 test/test1000/proof
7a185b3d3c099f93dd12619fae0d7f448ebe25b7f73e13e2d60c94f77ff7ee16 test/test1000/proof