summaryrefslogtreecommitdiff
path: root/ruby-runner.c
diff options
context:
space:
mode:
Diffstat (limited to 'ruby-runner.c')
-rw-r--r--ruby-runner.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ruby-runner.c b/ruby-runner.c
index bbc2b78fa0..48acf4396e 100644
--- a/ruby-runner.c
+++ b/ruby-runner.c
@@ -7,6 +7,10 @@
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef _WIN32
+# error This feature is unnecessary on Windows in favor of SxS.
+#endif
+
#include "ruby-runner.h"
static void
@@ -25,12 +29,24 @@ insert_env_path(const char *envname, const char *paths, size_t size, int prepend
char *e = malloc(size+n+1);
size_t pos = 0;
if (prepend) {
+ if (size == n || (size < n && env[size] == PATH_SEP)) {
+ if (strncmp(paths, env, size) == 0) {
+ free(e);
+ return;
+ }
+ }
memcpy(e, paths, pos = size-1);
e[pos++] = PATH_SEP;
}
memcpy(e+pos, env, n);
pos += n;
if (!prepend) {
+ if (size == n || (size < n && env[n-size-1] == PATH_SEP)) {
+ if (strncmp(paths, &env[n-size], size) == 0) {
+ free(e);
+ return;
+ }
+ }
e[pos++] = PATH_SEP;
memcpy(e+pos, paths, size-1);
pos += size-1;