diff options
author | Camil Staps | 2016-10-18 23:40:21 +0200 |
---|---|---|
committer | Camil Staps | 2016-10-18 23:40:21 +0200 |
commit | 7958bfe952186caa08f46c1ec99cc1ea40a8edb2 (patch) | |
tree | 04b5954ec321ef02636e8d8ffe448daf73ff8631 /compile.c | |
parent | Add :undef (diff) |
Cleanup
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 110 |
1 files changed, 55 insertions, 55 deletions
@@ -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 "<path>" && clm -ms -nw -b -nt <module> -o <module> - 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 "<path>" && clm -ms -nw -b -nt <module> -o <module> + 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<execlength;i++) - execchars[i] = CleanStringCharacters(executable)[i]; - execchars[i] = 0x00; - - // Run command: - int r; - r = system(execchars); - free(execchars); - return r; + 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<execlength;i++) + execchars[i] = CleanStringCharacters(executable)[i]; + execchars[i] = 0x00; + + // Run command: + int r; + r = system(execchars); + free(execchars); + return r; } |