You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2016/06/30 16:38:41 UTC
lucy-clownfish git commit: Regenerate charmonizer.c for Windows fix
Repository: lucy-clownfish
Updated Branches:
refs/heads/master 8b83e41b8 -> 2d1687d48
Regenerate charmonizer.c for Windows fix
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/2d1687d4
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/2d1687d4
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/2d1687d4
Branch: refs/heads/master
Commit: 2d1687d483c17ea182129f1281fcc8bf37b5b904
Parents: 8b83e41
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Jun 30 18:37:32 2016 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu Jun 30 18:37:32 2016 +0200
----------------------------------------------------------------------
compiler/common/charmonizer.c | 37 ++++++++++++++++++-------------------
runtime/common/charmonizer.c | 37 ++++++++++++++++++-------------------
2 files changed, 36 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2d1687d4/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index c722d82..dc42893 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -5456,7 +5456,7 @@ static struct {
} chaz_OS = { "", "", "", "", 0, 0 };
static int
-chaz_OS_run_sh_via_cmd_exe(const char *command);
+chaz_OS_run_sh_via_cmd_exe(const char *command, const char *path);
void
chaz_OS_init(void) {
@@ -5615,6 +5615,9 @@ int
chaz_OS_run_redirected(const char *command, const char *path) {
int retval = 1;
char *quiet_command = NULL;
+ if (chaz_OS.run_sh_via_cmd_exe) {
+ return chaz_OS_run_sh_via_cmd_exe(command, path);
+ }
if (chaz_OS.shell_type == CHAZ_OS_POSIX
|| chaz_OS.shell_type == CHAZ_OS_CMD_EXE
) {
@@ -5623,27 +5626,23 @@ chaz_OS_run_redirected(const char *command, const char *path) {
else {
chaz_Util_die("Don't know the shell type");
}
- if (chaz_OS.run_sh_via_cmd_exe) {
- retval = chaz_OS_run_sh_via_cmd_exe(quiet_command);
- }
- else {
- retval = system(quiet_command);
- }
+ retval = system(quiet_command);
free(quiet_command);
return retval;
}
static int
-chaz_OS_run_sh_via_cmd_exe(const char *command) {
+chaz_OS_run_sh_via_cmd_exe(const char *command, const char *path) {
size_t i;
size_t size;
- char *sh_command;
+ char *escaped_command;
+ char *wrapped_command;
char *p;
int retval;
/* Compute size. */
- size = sizeof("sh -c \"\"");
+ size = 0;
for (i = 0; command[i] != '\0'; i++) {
char c = command[i];
@@ -5667,10 +5666,8 @@ chaz_OS_run_sh_via_cmd_exe(const char *command) {
/* Build sh command. */
- sh_command = (char*)malloc(size);
- p = sh_command;
- memcpy(p, "sh -c \"", 7);
- p += 7;
+ escaped_command = (char*)malloc(size + 1);
+ p = escaped_command;
/* Escape special characters. */
@@ -5700,14 +5697,16 @@ chaz_OS_run_sh_via_cmd_exe(const char *command) {
}
}
- /* Finish and run sh command. */
-
- *p++ = '"';
*p++ = '\0';
- retval = system(sh_command);
+ /* Run sh command. */
+
+ wrapped_command = chaz_Util_join("", "sh -c \"", escaped_command, "\" > ",
+ path, " 2>&1", NULL);
+ retval = system(wrapped_command);
- free(sh_command);
+ free(wrapped_command);
+ free(escaped_command);
return retval;
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2d1687d4/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index 62355e8..7aed304 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -5456,7 +5456,7 @@ static struct {
} chaz_OS = { "", "", "", "", 0, 0 };
static int
-chaz_OS_run_sh_via_cmd_exe(const char *command);
+chaz_OS_run_sh_via_cmd_exe(const char *command, const char *path);
void
chaz_OS_init(void) {
@@ -5615,6 +5615,9 @@ int
chaz_OS_run_redirected(const char *command, const char *path) {
int retval = 1;
char *quiet_command = NULL;
+ if (chaz_OS.run_sh_via_cmd_exe) {
+ return chaz_OS_run_sh_via_cmd_exe(command, path);
+ }
if (chaz_OS.shell_type == CHAZ_OS_POSIX
|| chaz_OS.shell_type == CHAZ_OS_CMD_EXE
) {
@@ -5623,27 +5626,23 @@ chaz_OS_run_redirected(const char *command, const char *path) {
else {
chaz_Util_die("Don't know the shell type");
}
- if (chaz_OS.run_sh_via_cmd_exe) {
- retval = chaz_OS_run_sh_via_cmd_exe(quiet_command);
- }
- else {
- retval = system(quiet_command);
- }
+ retval = system(quiet_command);
free(quiet_command);
return retval;
}
static int
-chaz_OS_run_sh_via_cmd_exe(const char *command) {
+chaz_OS_run_sh_via_cmd_exe(const char *command, const char *path) {
size_t i;
size_t size;
- char *sh_command;
+ char *escaped_command;
+ char *wrapped_command;
char *p;
int retval;
/* Compute size. */
- size = sizeof("sh -c \"\"");
+ size = 0;
for (i = 0; command[i] != '\0'; i++) {
char c = command[i];
@@ -5667,10 +5666,8 @@ chaz_OS_run_sh_via_cmd_exe(const char *command) {
/* Build sh command. */
- sh_command = (char*)malloc(size);
- p = sh_command;
- memcpy(p, "sh -c \"", 7);
- p += 7;
+ escaped_command = (char*)malloc(size + 1);
+ p = escaped_command;
/* Escape special characters. */
@@ -5700,14 +5697,16 @@ chaz_OS_run_sh_via_cmd_exe(const char *command) {
}
}
- /* Finish and run sh command. */
-
- *p++ = '"';
*p++ = '\0';
- retval = system(sh_command);
+ /* Run sh command. */
+
+ wrapped_command = chaz_Util_join("", "sh -c \"", escaped_command, "\" > ",
+ path, " 2>&1", NULL);
+ retval = system(wrapped_command);
- free(sh_command);
+ free(wrapped_command);
+ free(escaped_command);
return retval;
}