aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c110
1 files changed, 55 insertions, 55 deletions
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 "<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;
}