From 7958bfe952186caa08f46c1ec99cc1ea40a8edb2 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 18 Oct 2016 23:40:21 +0200 Subject: Cleanup --- compile.c | 110 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 03fe833..6366a3d 100644 --- a/compile.c +++ b/compile.c @@ -32,16 +32,16 @@ SOFTWARE. #include "Clean.h" char* cleanstoc(CleanString s) { - char* cs = calloc(sizeof(char), CleanStringLength(s) + 1); - if (cs == NULL) - return NULL; - - int i; - for (i = 0; i < CleanStringLength(s); i++) - cs[i] = CleanStringCharacters(s)[i]; - cs[i] = '\0'; - - return cs; + char* cs = calloc(sizeof(char), CleanStringLength(s) + 1); + if (cs == NULL) + return NULL; + + int i; + for (i = 0; i < CleanStringLength(s); i++) + cs[i] = CleanStringCharacters(s)[i]; + cs[i] = '\0'; + + return cs; } /** @@ -56,29 +56,29 @@ char* cleanstoc(CleanString s) { * @return int the result of clm */ int64_t compile(CleanString path, CleanString module) { - char* pathchars, * modulechars; - - pathchars = cleanstoc(path); - modulechars = cleanstoc(module); - - if (modulechars == NULL || pathchars == NULL) { - printf("Couldn't allocate memory\n"); - exit(-1); - } - - // Build command: - // cd "" && clm -ms -nw -b -nt -o - char cmd[182]; - snprintf(cmd, 181, "cd \"%s\" && clm -ms -nw -I $CLEAN_HOME/lib/StdLib -I " - "$CLEAN_HOME/lib/Generics -I $CLEAN_HOME/lib/Dynamics -dynamics " - "-I $CLEAN_HOME/lib/Gast -b -nt %s -o %s", - pathchars, modulechars, modulechars); - - free(pathchars); - free(modulechars); - - // Call clm - return system(cmd); + char* pathchars, * modulechars; + + pathchars = cleanstoc(path); + modulechars = cleanstoc(module); + + if (modulechars == NULL || pathchars == NULL) { + printf("Couldn't allocate memory\n"); + exit(-1); + } + + // Build command: + // cd "" && clm -ms -nw -b -nt -o + char cmd[182]; + snprintf(cmd, 181, "cd \"%s\" && clm -ms -nw -I $CLEAN_HOME/lib/StdLib -I " + "$CLEAN_HOME/lib/Generics -I $CLEAN_HOME/lib/Dynamics -dynamics " + "-I $CLEAN_HOME/lib/Gast -b -nt %s -o %s", + pathchars, modulechars, modulechars); + + free(pathchars); + free(modulechars); + + // Call clm + return system(cmd); } /** @@ -92,26 +92,26 @@ int64_t compile(CleanString path, CleanString module) { * @return void */ int64_t run(CleanString executable) { - char* execchars; - int execlength; - - // Copy CleanString to char[] - execlength = CleanStringLength(executable); - - execchars = calloc(1, execlength + 1); - if (execchars == NULL) { - printf("Couldn't allocate memory\n"); - exit(-1); - } - - int i; - for (i=0;i