From 5f2602bc02c94963d9571b8913d5ab885991a754 Mon Sep 17 00:00:00 2001 From: Akuli Date: Wed, 13 Dec 2023 17:30:33 +0200 Subject: [PATCH] move run_exe() to separate file --- src/output.c | 24 ------------------------ src/run.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 src/run.c diff --git a/src/output.c b/src/output.c index 375d9ebc..a7e51e0a 100644 --- a/src/output.c +++ b/src/output.c @@ -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; -} diff --git a/src/run.c b/src/run.c new file mode 100644 index 00000000..b92dfe3c --- /dev/null +++ b/src/run.c @@ -0,0 +1,29 @@ +#include +#include +#include +#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; +}