X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=test.c;h=7722af26a4a5caae39c636fcfc6ee78be72e40e4;hp=d9a991fa8e2786cd7e7fd83897f0bc69d91bc115;hb=4c4aa5534c34a35560ab1936bc84d37ee6e869e6;hpb=19c57c03cc8fdc804766136a27d1f6a57548dd5b diff --git a/test.c b/test.c old mode 100755 new mode 100644 index d9a991f..7722af2 --- a/test.c +++ b/test.c @@ -26,7 +26,7 @@ opts_cmd_t opts; -const char *task_bins[] = { +static const char *task_bins[] = { "./gmqcc", "./qcvm" }; @@ -116,9 +116,9 @@ FILE ** task_popen(const char *command, const char *mode) { close(errhandle[0]); /* see piping documentation for this sillyness :P */ - close(0), dup(inhandle [0]); - close(1), dup(outhandle[1]); - close(2), dup(errhandle[1]); + close(0); (void)!dup(inhandle [0]); + close(1); (void)!dup(outhandle[1]); + close(2); (void)!dup(errhandle[1]); execvp(*argv, argv); exit(EXIT_FAILURE); @@ -152,19 +152,15 @@ int task_pclose(FILE **handles) { return status; } #else - /* - * Bidirectional piping implementation for windows using CreatePipe and DuplicateHandle + - * other hacks. - */ typedef struct { - char name_err[L_tmpnam]; - char name_out[L_tmpnam]; + FILE *handles[3]; + char name_err[L_tmpnam]; + char name_out[L_tmpnam]; } popen_t; FILE **task_popen(const char *command, const char *mode) { - FILE **handles = NULL; - char *cmd = NULL; - popen_t *open = (popen_t*)mem_a(sizeof(popen_t) * 3); + char *cmd = NULL; + popen_t *open = (popen_t*)mem_a(sizeof(popen_t)); tmpnam(open->name_err); tmpnam(open->name_out); @@ -174,18 +170,17 @@ int task_pclose(FILE **handles) { util_asprintf(&cmd, "%s -redirout=%s -redirerr=%s", command, open->name_out, open->name_err); system(cmd); /* HACK */ - handles = (FILE**)(open + 1); - handles[0] = NULL; - handles[1] = fs_file_open(open->name_out, "r"); - handles[2] = fs_file_open(open->name_err, "r"); + open->handles[0] = NULL; + open->handles[1] = fs_file_open(open->name_out, "r"); + open->handles[2] = fs_file_open(open->name_err, "r"); mem_d(cmd); - return handles; + return open->handles; } void task_pclose(FILE **files) { - popen_t *open = ((popen_t*)files) - 1; + popen_t *open = ((popen_t*)files); fs_file_close(files[1]); fs_file_close(files[2]); remove(open->name_err); @@ -659,7 +654,7 @@ typedef struct { bool compiled; } task_t; -task_t *task_tasks = NULL; +static task_t *task_tasks = NULL; /* * Read a directory and searches for all template files in it