Skip to content

Commit

Permalink
move run_exe() to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Dec 13, 2023
1 parent 517f9e6 commit 5f2602b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
24 changes: 0 additions & 24 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,27 +184,3 @@ char *compile_to_object_file(LLVMModuleRef module)
assert(!error);
return path;
}

int run_exe(const char *exepath, bool valgrind)
{
char *command = malloc(strlen(exepath) + 1000);
#ifdef _WIN32
sprintf(command, "\"%s\"", exepath);
char *p;
while ((p = strchr(command, '/')))
*p = '\\';
#else
if (valgrind)
sprintf(command, "valgrind -q --leak-check=full --show-leak-kinds=all --error-exitcode=1 '%s'", exepath);
else
sprintf(command, "'%s'", exepath);
#endif

// Make sure that everything else shows up before the user's prints.
fflush(stdout);
fflush(stderr);

int ret = system(command);
free(command);
return !!ret;
}
29 changes: 29 additions & 0 deletions src/run.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "jou_compiler.h"


int run_exe(const char *exepath, bool valgrind)
{
char *command = malloc(strlen(exepath) + 1000);
#ifdef _WIN32
sprintf(command, "\"%s\"", exepath);
char *p;
while ((p = strchr(command, '/')))
*p = '\\';
#else
if (valgrind)
sprintf(command, "valgrind -q --leak-check=full --show-leak-kinds=all --error-exitcode=1 '%s'", exepath);
else
sprintf(command, "'%s'", exepath);
#endif

// Make sure that everything else shows up before the user's prints.
fflush(stdout);
fflush(stderr);

int ret = system(command);
free(command);
return !!ret;
}

0 comments on commit 5f2602b

Please sign in to comment.