aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/common/dialyzer.c
diff options
context:
space:
mode:
Diffstat (limited to 'erts/etc/common/dialyzer.c')
-rw-r--r--erts/etc/common/dialyzer.c53
1 files changed, 42 insertions, 11 deletions
diff --git a/erts/etc/common/dialyzer.c b/erts/etc/common/dialyzer.c
index 6ba3605422..b45d5c7ca7 100644
--- a/erts/etc/common/dialyzer.c
+++ b/erts/etc/common/dialyzer.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2006-2016. All Rights Reserved.
+ * Copyright Ericsson AB 2006-2017. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,16 +20,8 @@
/*
* Purpose: Dialyzer front-end.
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "sys.h"
-#ifdef __WIN32__
-#include <winbase.h>
-#endif
-#include <ctype.h>
+#include "etc_common.h"
#define NO 0
#define YES 1
@@ -64,6 +56,9 @@ static int eargc; /* Number of arguments in eargv. */
static void error(char* format, ...);
static void* emalloc(size_t size);
+#ifdef HAVE_COPYING_PUTENV
+static void efree(void *p);
+#endif
static char* strsave(char* string);
static void push_words(char* src);
static int run_erlang(char* name, char** argv);
@@ -147,6 +142,29 @@ free_env_val(char *value)
#endif
}
+static void
+set_env(char *key, char *value)
+{
+#ifdef __WIN32__
+ WCHAR wkey[MAXPATHLEN];
+ WCHAR wvalue[MAXPATHLEN];
+ MultiByteToWideChar(CP_UTF8, 0, key, -1, wkey, MAXPATHLEN);
+ MultiByteToWideChar(CP_UTF8, 0, value, -1, wvalue, MAXPATHLEN);
+ if (!SetEnvironmentVariableW(wkey, wvalue))
+ error("SetEnvironmentVariable(\"%s\", \"%s\") failed!", key, value);
+#else
+ size_t size = strlen(key) + 1 + strlen(value) + 1;
+ char *str = emalloc(size);
+ sprintf(str, "%s=%s", key, value);
+ if (putenv(str) != 0)
+ error("putenv(\"%s\") failed!", str);
+#ifdef HAVE_COPYING_PUTENV
+ efree(str);
+#endif
+#endif
+}
+
+
#ifdef __WIN32__
int wmain(int argc, wchar_t **wcargv)
{
@@ -181,6 +199,11 @@ int main(int argc, char** argv)
error("Value of environment variable DIALYZER_EMULATOR is too large");
/*
+ * Add scriptname to env
+ */
+ set_env("ESCRIPT_NAME", argv[0]);
+
+ /*
* Allocate the argv vector to be used for arguments to Erlang.
* Arrange for starting to pushing information in the middle of
* the array, to allow easy addition of commands in the beginning.
@@ -232,7 +255,7 @@ int main(int argc, char** argv)
}
PUSH("+B");
- PUSH2("-boot", "start_clean");
+ PUSH2("-boot", "no_dot_erlang");
PUSH3("-run", "dialyzer", "plain_cl");
PUSH("-extra");
@@ -434,6 +457,14 @@ erealloc(void *p, size_t size)
}
#endif
+#ifdef HAVE_COPYING_PUTENV
+static void
+efree(void *p)
+{
+ free(p);
+}
+#endif
+
static char*
strsave(char* string)
{