summaryrefslogtreecommitdiff
path: root/erts/etc
diff options
context:
space:
mode:
Diffstat (limited to 'erts/etc')
-rw-r--r--erts/etc/common/Makefile.in17
-rw-r--r--erts/etc/common/ct_run.c24
-rw-r--r--erts/etc/common/erlc.c5
-rw-r--r--erts/etc/common/erlexec.c65
-rw-r--r--erts/etc/common/escript.c2
-rw-r--r--erts/etc/common/etc_common.h1
-rw-r--r--erts/etc/unix/to_erl.c24
-rw-r--r--erts/etc/win32/Install.c31
-rw-r--r--erts/etc/win32/Makefile1
-rw-r--r--erts/etc/win32/erl.c22
-rw-r--r--erts/etc/win32/nsis/erlang20.nsi2
-rw-r--r--erts/etc/win32/win_erlexec.c121
12 files changed, 100 insertions, 215 deletions
diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in
index 42d4395eb2..2a569d3513 100644
--- a/erts/etc/common/Makefile.in
+++ b/erts/etc/common/Makefile.in
@@ -168,7 +168,6 @@ INSTALL_PROGS = \
$(BINDIR)/erlsrv.exe \
$(BINDIR)/erl.exe \
$(BINDIR)/erl_log.exe\
- $(BINDIR)/werl.exe \
$(BINDIR)/$(ERLEXEC) \
$(INSTALL_EMBEDDED_PROGS)
@@ -216,6 +215,12 @@ INSTALL_PROGS = \
$(INSTALL_EMBEDDED_PROGS)
endif
+CREATE_DIRS=$(OBJDIR) $(BINDIR)
+
+ifneq ($(strip $(CREATE_DIRS)),)
+_create_dirs := $(shell mkdir -p $(CREATE_DIRS))
+endif
+
.PHONY: etc
etc: $(ENTRY_OBJ) $(INSTALL_PROGS) $(EXTRA_LIBS) $(INSTALL_LIBS) $(TEXTFILES) $(INSTALL_TOP_BIN)
@@ -267,13 +272,12 @@ endif
rm -f $(ERL_TOP)/erts/obj*/$(TARGET)/vxcall.o
rm -f $(ERL_TOP)/erts/obj*/$(TARGET)/erl.o
rm -f $(ERL_TOP)/erts/obj*/$(TARGET)/erl_log.o
- rm -f $(ERL_TOP)/erts/obj*/$(TARGET)/werl.o
rm -f $(TEXTFILES)
rm -f *~ core
#------------------------------------------------------------------------
# Windows specific targets
-# The windows platform is quite different from the others. erl/werl are small C programs
+# The windows platform is quite different from the others. erl are small C programs
# loading a DLL. INI files are used instead of environment variables and the Install
# script is actually a program, also Install has an INI file which tells of emulator
# versions etc.
@@ -287,9 +291,6 @@ $(BINDIR)/$(ERLEXEC): $(OBJDIR)/erlexec.o $(OBJDIR)/win_erlexec.o $(OBJDIR)/init
$(BINDIR)/erl@EXEEXT@: $(OBJDIR)/erl.o $(OBJDIR)/init_file.o $(OBJDIR)/$(ERLRES_OBJ)
$(V_LD) $(LDFLAGS) -o $@ $(OBJDIR)/erl.o $(OBJDIR)/init_file.o $(OBJDIR)/$(ERLRES_OBJ)
-$(BINDIR)/werl@EXEEXT@: $(OBJDIR)/werl.o $(OBJDIR)/init_file.o $(OBJDIR)/$(ERLRES_OBJ)
- $(V_LD) $(LDFLAGS) -o $@ $(OBJDIR)/werl.o $(OBJDIR)/init_file.o $(OBJDIR)/$(ERLRES_OBJ)
-
$(BINDIR)/erl_log@EXEEXT@: $(OBJDIR)/erl_log.o
$(V_LD) $(LDFLAGS) -o $@ $(OBJDIR)/erl_log.o
@@ -367,10 +368,6 @@ $(OBJDIR)/erlsrv_util.o: $(WINETC)/erlsrv/erlsrv_util.c $(ERLSRV_HEADERS) \
$(OBJDIR)/erlsrv_logmess.h $(RC_GENERATED)
$(V_CC) $(CFLAGS) -I$(OBJDIR) $(MT_FLAG) -o $@ -c $<
-$(OBJDIR)/werl.o: $(WINETC)/erl.c $(WINETC)/init_file.h $(RC_GENERATED)
- $(V_CC) $(CFLAGS) -DBUILD_TYPE=\"-$(TYPE)\" -DERL_RUN_SHARED_LIB=1 \
- -DWIN32_WERL -o $@ -c $(WINETC)/erl.c
-
$(OBJDIR)/erl_log.o: $(WINETC)/erl_log.c $(RC_GENERATED)
$(V_CC) $(CFLAGS) -DBUILD_TYPE=\"-$(TYPE)\" -DERL_RUN_SHARED_LIB=1 \
-o $@ -c $(WINETC)/erl_log.c
diff --git a/erts/etc/common/ct_run.c b/erts/etc/common/ct_run.c
index 0e9c2bea83..522c427691 100644
--- a/erts/etc/common/ct_run.c
+++ b/erts/etc/common/ct_run.c
@@ -77,7 +77,6 @@ static void* emalloc(size_t size);
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);
static char* get_default_emulator(char* progname);
#ifdef __WIN32__
@@ -187,8 +186,7 @@ int main(int argc, char** argv)
eargv_base = (char **) emalloc(eargv_size*sizeof(char*));
eargv = eargv_base;
eargc = 0;
- push_words(emulator);
- free(emulator);
+ PUSH(emulator);
eargc_base = eargc;
eargv = eargv + eargv_size/2;
eargc = 0;
@@ -319,26 +317,6 @@ int main(int argc, char** argv)
return run_erlang(eargv[0], eargv);
}
-static void
-push_words(char* src)
-{
- char sbuf[MAXPATHLEN];
- char* dst;
-
- dst = sbuf;
- while ((*dst++ = *src++) != '\0') {
- if (isspace((int)*src)) {
- *dst = '\0';
- PUSH(strsave(sbuf));
- dst = sbuf;
- do {
- src++;
- } while (isspace((int)*src));
- }
- }
- if (sbuf[0])
- PUSH(strsave(sbuf));
-}
#ifdef __WIN32__
wchar_t *make_commandline(char **argv)
{
diff --git a/erts/etc/common/erlc.c b/erts/etc/common/erlc.c
index 6cded37733..da378a8654 100644
--- a/erts/etc/common/erlc.c
+++ b/erts/etc/common/erlc.c
@@ -742,14 +742,14 @@ call_compile_server(char** argv)
ei_x_encode_atom(&args, "encoding");
ei_x_encode_atom(&args, get_encoding());
ei_x_encode_atom(&args, "cwd");
- ei_x_encode_string(&args, cwd);
+ ei_x_encode_binary(&args, cwd, strlen(cwd));
ei_x_encode_atom(&args, "env");
encode_env(&args);
ei_x_encode_atom(&args, "command_line");
argc = 0;
while (argv[argc]) {
ei_x_encode_list_header(&args, 1);
- ei_x_encode_string(&args, possibly_unquote(argv[argc]));
+ ei_x_encode_binary(&args, possibly_unquote(argv[argc]), strlen(argv[argc]));
argc++;
}
ei_x_encode_empty_list(&args); /* End of command_line */
@@ -773,7 +773,6 @@ call_compile_server(char** argv)
/*
* Decode the answer.
*/
-
dec_index = 0;
if (ei_decode_atom(reply.buff, &dec_index, atom) == 0 &&
strcmp(atom, "wrong_config") == 0) {
diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c
index 3e44ad2b77..f8e7fb09d7 100644
--- a/erts/etc/common/erlexec.c
+++ b/erts/etc/common/erlexec.c
@@ -39,14 +39,12 @@
#define DIRSEP "\\"
#define PATHSEP ";"
#define NULL_DEVICE "nul"
-#define BINARY_EXT ""
#define DLL_EXT ".dll"
#define EMULATOR_EXECUTABLE "beam.dll"
#else
#define PATHSEP ":"
#define DIRSEP "/"
#define NULL_DEVICE "/dev/null"
-#define BINARY_EXT ""
#define EMULATOR_EXECUTABLE "beam"
#endif
@@ -219,7 +217,6 @@ static char* possibly_quote(char* arg);
/*
* Functions from win_erlexec.c
*/
-int start_win_emulator(char* emu, char *startprog,char** argv, int start_detached);
int start_emulator(char* emu, char*start_prog, char** argv, int start_detached);
#endif
@@ -247,7 +244,7 @@ static const char* emu_flavor = DEFAULT_SUFFIX; /* Flavor of emulator (smp, jit
#ifdef __WIN32__
static char *start_emulator_program = NULL; /* For detached mode -
- erl.exe/werl.exe */
+ erl.exe */
static char* key_val_name = ERLANG_VERSION; /* Used by the registry
* access functions.
*/
@@ -257,7 +254,6 @@ static int config_script_cnt = 0;
static int got_start_erl = 0;
static HANDLE this_module_handle;
-static int run_werl;
static WCHAR *utf8_to_utf16(unsigned char *bytes);
static char *utf16_to_utf8(WCHAR *wstr);
static WCHAR *latin1_to_utf16(char *str);
@@ -415,7 +411,7 @@ static void add_boot_config(void)
#define NEXT_ARG_CHECK() NEXT_ARG_CHECK_NAMED(argv[i])
#ifdef __WIN32__
-__declspec(dllexport) int win_erlexec(int argc, char **argv, HANDLE module, int windowed)
+__declspec(dllexport) int win_erlexec(int argc, char **argv, HANDLE module)
#else
int main(int argc, char **argv)
#endif
@@ -436,7 +432,6 @@ int main(int argc, char **argv)
#ifdef __WIN32__
this_module_handle = module;
- run_werl = windowed;
/* if we started this erl just to get a detached emulator,
* the arguments are already prepared for beam, so we skip
* directly to start_emulator */
@@ -454,6 +449,18 @@ int main(int argc, char **argv)
Eargsp[argc] = NULL;
emu = argv[0];
start_emulator_program = strsave(argv[0]);
+ /* We set the stdandard handles to nul in order for prim_tty_nif
+ and erlang:display_string to work without returning ebadf for
+ detached emulators */
+ SetStdHandle(STD_INPUT_HANDLE,
+ CreateFile("nul", GENERIC_READ, 0, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL));
+ SetStdHandle(STD_OUTPUT_HANDLE,
+ CreateFile("nul", GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL));
+ SetStdHandle(STD_ERROR_HANDLE,
+ CreateFile("nul", GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL));
goto skip_arg_massage;
}
free_env_val(s);
@@ -523,7 +530,7 @@ int main(int argc, char **argv)
emu = add_extra_suffixes(emu);
emu_name = strsave(emu);
- erts_snprintf(tmpStr, sizeof(tmpStr), "%s" DIRSEP "%s" BINARY_EXT, bindir, emu);
+ erts_snprintf(tmpStr, sizeof(tmpStr), "%s" DIRSEP "%s", bindir, emu);
emu = strsave(tmpStr);
s = get_env("ESCRIPT_NAME");
@@ -651,13 +658,12 @@ int main(int argc, char **argv)
break;
case 'd':
- if (strcmp(argv[i], "-detached") != 0) {
- add_arg(argv[i]);
- } else {
- start_detached = 1;
- add_args("-noshell", "-noinput", NULL);
- }
- break;
+ add_arg(argv[i]);
+ if (strcmp(argv[i], "-detached") == 0) {
+ start_detached = 1;
+ add_args("-noshell", "-noinput", NULL);
+ }
+ break;
case 'e':
if (strcmp(argv[i], "-extra") == 0) {
@@ -1117,24 +1123,7 @@ int main(int argc, char **argv)
skip_arg_massage:
/*DebugBreak();*/
- if (run_werl) {
- if (start_detached) {
- char *p;
- /* transform werl to erl */
- p = start_emulator_program+strlen(start_emulator_program);
- while (--p >= start_emulator_program && *p != '/' && *p != '\\' &&
- *p != 'W' && *p != 'w')
- ;
- if (p >= start_emulator_program && (*p == 'W' || *p == 'w') &&
- (p[1] == 'E' || p[1] == 'e') && (p[2] == 'R' || p[2] == 'r') &&
- (p[3] == 'L' || p[3] == 'l')) {
- memmove(p,p+1,strlen(p));
- }
- }
- return start_win_emulator(emu, start_emulator_program, Eargsp, start_detached);
- } else {
- return start_emulator(emu, start_emulator_program, Eargsp, start_detached);
- }
+ return start_emulator(emu, start_emulator_program, Eargsp, start_detached);
#else
@@ -1232,7 +1221,7 @@ usage_aux(void)
"[-emu_type TYPE] [-emu_flavor FLAVOR] "
"[-args_file FILENAME] [+A THREADS] [+a SIZE] [+B[c|d|i]] [+c [BOOLEAN]] "
"[+C MODE] [+dcg DECENTRALIZED_COUNTER_GROUPS_LIMIT] [+h HEAP_SIZE_OPTION] "
- "[+J[Pperf] JIT_OPTION] "
+ "[+J[Pperf|Msingle] JIT_OPTION] "
"[+M<SUBSWITCH> <ARGUMENT>] [+P MAX_PROCS] [+Q MAX_PORTS] "
"[+R COMPAT_REL] "
"[+r] [+rg READER_GROUPS_LIMIT] [+s<SUBSWITCH> SCHEDULER_OPTION] "
@@ -1600,6 +1589,14 @@ static void get_parameters(int argc, char** argv)
emu = EMULATOR_EXECUTABLE;
start_emulator_program = strsave(argv[0]);
+ /* in wsl argv[0] is given as "erl.exe", but start_emulator_program should be
+ an absolute path, so we prepend BINDIR to it */
+ if (strcmp(start_emulator_program, "erl.exe") == 0) {
+ erts_snprintf(tmpStr, sizeof(tmpStr), "%s" DIRSEP "%s", bindir,
+ start_emulator_program);
+ start_emulator_program = strsave(tmpStr);
+ }
+
free(ini_filename);
}
diff --git a/erts/etc/common/escript.c b/erts/etc/common/escript.c
index 078937e676..e418daf430 100644
--- a/erts/etc/common/escript.c
+++ b/erts/etc/common/escript.c
@@ -510,8 +510,8 @@ main(int argc, char** argv)
PUSH(emulator);
PUSH("+B");
- PUSH2("-boot", "no_dot_erlang");
PUSH("-noshell");
+ PUSH2("-boot", "no_dot_erlang");
/*
* Read options from the %%! row in the script and add them as args
diff --git a/erts/etc/common/etc_common.h b/erts/etc/common/etc_common.h
index 289a33b42a..865cb6a6c6 100644
--- a/erts/etc/common/etc_common.h
+++ b/erts/etc/common/etc_common.h
@@ -35,6 +35,7 @@
# include <io.h>
# include <winbase.h>
# include <process.h>
+# include <direct.h> // _getcwd
#endif
#include <errno.h>
diff --git a/erts/etc/unix/to_erl.c b/erts/etc/unix/to_erl.c
index f9ca5f6373..6ebe793edc 100644
--- a/erts/etc/unix/to_erl.c
+++ b/erts/etc/unix/to_erl.c
@@ -82,13 +82,13 @@
# define STRERROR(x) ""
#endif
-#define noDEBUG
+#define noDEBUG_TOERL
#define PIPE_DIR "/tmp/"
#define PIPE_STUBNAME "erlang.pipe"
#define PIPE_STUBLEN strlen(PIPE_STUBNAME)
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
#define STATUS(s) { fprintf(stderr, (s)); fflush(stderr); }
#else
#define STATUS(s)
@@ -106,7 +106,7 @@ static int protocol_ver = RUN_ERL_LO_VER; /* assume lowest to begin with */
static int write_all(int fd, const char* buf, int len);
static int window_size_seq(char* buf, size_t bufsz);
static int version_handshake(char* buf, int len, int wfd);
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
static void show_terminal_settings(struct termios *);
#endif
@@ -155,7 +155,7 @@ int main(int argc, char **argv)
pipeIx = 2;
}
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
fprintf(stderr, "%s: pid is : %d\n", argv[0], (int)getpid());
#endif
@@ -209,25 +209,25 @@ int main(int argc, char **argv)
}
if ((rfd = open (FIFO1, O_RDONLY|DONT_BLOCK_PLEASE, 0)) < 0) {
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
fprintf(stderr, "Could not open FIFO %s for reading.\n", FIFO1);
#endif
fprintf(stderr, "No running Erlang on pipe %s: %s\n", pipename, strerror(errno));
exit(1);
}
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
fprintf(stderr, "to_erl: %s opened for reading\n", FIFO1);
#endif
if ((wfd = open (FIFO2, O_WRONLY|DONT_BLOCK_PLEASE, 0)) < 0) {
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
fprintf(stderr, "Could not open FIFO %s for writing.\n", FIFO2);
#endif
fprintf(stderr, "No running Erlang on pipe %s: %s\n", pipename, strerror(errno));
close(rfd);
exit(1);
}
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
fprintf(stderr, "to_erl: %s opened for writing\n", FIFO2);
#endif
@@ -245,7 +245,7 @@ int main(int argc, char **argv)
}
tty_smode = tty_rmode;
tty_eof = '\004'; /* Ctrl+D to exit */
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
show_terminal_settings(&tty_rmode);
#endif
tty_smode.c_iflag =
@@ -347,7 +347,7 @@ int main(int argc, char **argv)
tcsetattr(0, TCSADRAIN, &tty_smode);
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
show_terminal_settings(&tty_smode);
#endif
/*
@@ -420,7 +420,7 @@ int main(int argc, char **argv)
}
if (len) {
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
write_all(1, buf, len);
#endif
if (write_all(wfd, buf, len) != len) {
@@ -580,7 +580,7 @@ static int version_handshake(char* buf, int len, int wfd)
}
-#ifdef DEBUG
+#ifdef DEBUG_TOERL
#define S(x) ((x) > 0 ? 1 : 0)
static void show_terminal_settings(struct termios *t)
diff --git a/erts/etc/win32/Install.c b/erts/etc/win32/Install.c
index 1b8f894dc9..497dd537fd 100644
--- a/erts/etc/win32/Install.c
+++ b/erts/etc/win32/Install.c
@@ -24,6 +24,7 @@
*/
#include <windows.h>
+#include <winerror.h>
#include <stdio.h>
#include <stdlib.h>
#include "init_file.h"
@@ -47,11 +48,12 @@ int wmain(int argc, wchar_t **argv)
InitFile *ini_file;
InitSection *ini_section;
HANDLE module = GetModuleHandle(NULL);
- wchar_t *binaries[] = { L"erl.exe", L"werl.exe", L"erlc.exe", L"erl_call.exe",
+ wchar_t *binaries[] = { L"erl.exe", L"erlc.exe", L"erl_call.exe",
L"dialyzer.exe",
L"typer.exe",
L"escript.exe", L"ct_run.exe", NULL };
wchar_t *scripts[] = { L"start_clean.boot", L"start_sasl.boot", L"no_dot_erlang.boot", NULL };
+ wchar_t *links[][2] = { { L"erl.exe", L"werl.exe" }, NULL };
wchar_t fromname[MAX_PATH];
wchar_t toname[MAX_PATH];
size_t converted;
@@ -175,7 +177,32 @@ int wmain(int argc, wchar_t **argv)
fprintf(stderr,"Continuing installation anyway...\n");
}
}
-
+
+ for (i = 0; links[i][0] != NULL; ++i) {
+ swprintf(toname,MAX_PATH,L"%s\\%s",bin_dir,links[i][1]);
+ if (!CreateSymbolicLinkW(toname,links[i][0],0)) {
+ DWORD err = GetLastError();
+ if (err == ERROR_PRIVILEGE_NOT_HELD) {
+ fprintf(stderr,"Must be administrator to create link, copying %S instead.\n",
+ links[i][0]);
+ swprintf(fromname,MAX_PATH,L"%s\\%s",bin_dir,links[i][0]);
+ if (!CopyFileW(fromname,toname,FALSE)) {
+ fprintf(stderr,"Could not copy file %S to %S\n",
+ fromname,toname);
+ fprintf(stderr,"Continuing installation anyway...\n");
+ }
+ } else {
+ wchar_t buf[256];
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ buf, (sizeof(buf) / sizeof(wchar_t)), NULL);
+ fprintf(stderr,"Could not create links from %S to %S %d: %S\n",
+ fromname, toname, err, buf);
+ fprintf(stderr,"Continuing installation anyway...\n");
+ }
+ }
+ }
+
for (i = 0; scripts[i] != NULL; ++i) {
swprintf(fromname,MAX_PATH,L"%s\\%s",release_dir,scripts[i]);
swprintf(toname,MAX_PATH,L"%s\\%s",bin_dir,scripts[i]);
diff --git a/erts/etc/win32/Makefile b/erts/etc/win32/Makefile
index c6376ebe74..f553f83e92 100644
--- a/erts/etc/win32/Makefile
+++ b/erts/etc/win32/Makefile
@@ -39,7 +39,6 @@ ROOTDIR = $(ERL_TOP)/erts
INSTALL_PROGS = \
$(BINDIR)/inet_gethost.exe \
$(BINDIR)/erl.exe \
- $(BINDIR)/werl.exe \
$(BINDIR)/heart.exe \
$(BINDIR)/erlc.exe \
$(BINDIR)/erlsrv.exe \
diff --git a/erts/etc/win32/erl.c b/erts/etc/win32/erl.c
index 99a41b99e5..31650de831 100644
--- a/erts/etc/win32/erl.c
+++ b/erts/etc/win32/erl.c
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include "init_file.h"
-typedef int ErlexecFunction(int, char **, HANDLE, int);
+typedef int ErlexecFunction(int, char **, HANDLE);
#define INI_FILENAME L"erl.ini"
#define INI_SECTION "erlang"
@@ -35,18 +35,8 @@ static void error(char* format, ...);
static wchar_t *erlexec_name;
static wchar_t *erlexec_dir;
-#ifdef WIN32_WERL
-#define WERL 1
-int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- PWSTR szCmdLine, int iCmdShow)
-{
- int argc = __argc;
- wchar_t **argv = __wargv;
-#else
-#define WERL 0
int wmain(int argc, wchar_t **argv)
{
-#endif
HANDLE erlexec_handle; /* Instance */
ErlexecFunction *win_erlexec;
wchar_t *path = malloc(100*sizeof(wchar_t));
@@ -120,7 +110,7 @@ int wmain(int argc, wchar_t **argv)
}
#endif
- return (*win_erlexec)(argc,utf8argv,erlexec_handle,WERL);
+ return (*win_erlexec)(argc,utf8argv,erlexec_handle);
}
@@ -316,7 +306,6 @@ static void get_parameters(void)
free(ini_filename);
}
-
static void error(char* format, ...)
{
char sbuf[2048];
@@ -326,11 +315,6 @@ static void error(char* format, ...)
vsprintf(sbuf, format, ap);
va_end(ap);
-#ifndef WIN32_WERL
- fprintf(stderr, "%s\n", sbuf);
-#else
- MessageBox(NULL, sbuf, "Werl", MB_OK|MB_ICONERROR);
-#endif
+ fprintf(stderr, "%s\n", sbuf);
exit(1);
}
-
diff --git a/erts/etc/win32/nsis/erlang20.nsi b/erts/etc/win32/nsis/erlang20.nsi
index ae933f59af..2e317fd362 100644
--- a/erts/etc/win32/nsis/erlang20.nsi
+++ b/erts/etc/win32/nsis/erlang20.nsi
@@ -190,7 +190,7 @@ cp_files:
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
continue_create:
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Erlang.lnk" \
- "$INSTDIR\bin\werl.exe"
+ "$INSTDIR\bin\erl.exe"
!insertmacro MUI_STARTMENU_WRITE_END
; And once again, the verbosity...
diff --git a/erts/etc/win32/win_erlexec.c b/erts/etc/win32/win_erlexec.c
index 7b21ed3785..53b1ac92b0 100644
--- a/erts/etc/win32/win_erlexec.c
+++ b/erts/etc/win32/win_erlexec.c
@@ -48,7 +48,6 @@ static char* win32_errorstr(int error);
static int has_console(void);
static char** fnuttify_argv(char **argv);
static void free_fnuttified(char **v);
-static int windowed = 0;
#ifdef LOAD_BEAM_DYNAMICALLY
typedef int SysGetKeyFunction(int);
@@ -133,103 +132,6 @@ free_env_val(char *value)
free(value);
}
-
-int
-start_win_emulator(char* utf8emu, char *utf8start_prog, char** utf8argv, int start_detached)
-{
- int len;
- int argc = 0;
-
- windowed = 1;
- while (utf8argv[argc] != NULL) {
- ++argc;
- }
-
- if (start_detached) {
- wchar_t *start_prog=NULL;
- int result;
- int i;
- wchar_t **argv;
- close(0);
- close(1);
- close(2);
-
- set_env("ERL_CONSOLE_MODE", "detached");
- set_env(DLL_ENV, utf8emu);
-
- utf8argv[0] = utf8start_prog;
- utf8argv = fnuttify_argv(utf8argv);
-
- len = MultiByteToWideChar(CP_UTF8, 0, utf8start_prog, -1, NULL, 0);
- start_prog = malloc(len*sizeof(wchar_t));
- MultiByteToWideChar(CP_UTF8, 0, utf8start_prog, -1, start_prog, len);
-
- /* Convert utf8argv to multibyte argv */
- argv = malloc((argc+1) * sizeof(wchar_t*));
- for (i=0; i<argc; i++) {
- len = MultiByteToWideChar(CP_UTF8, 0, utf8argv[i], -1, NULL, 0);
- argv[i] = malloc(len*sizeof(wchar_t));
- MultiByteToWideChar(CP_UTF8, 0, utf8argv[i], -1, argv[i], len);
- }
- argv[argc] = NULL;
-
-#ifdef ARGS_HARDDEBUG
- {
- wchar_t tempbuf[2048] = L"";
- wchar_t *sbuf;
- int i;
- sbuf=tempbuf;
- sbuf += swprintf(sbuf, 2048, L"utf16: %s\n", start_prog);
- for (i = 0; i < argc; ++i) {
- sbuf += swprintf(sbuf, 2048, L"|%s|", argv[i]);
- };
- sbuf += swprintf(sbuf, 2048, L"\nutf8: \n");
- for (i = 0; i < argc; ++i) {
- sbuf += swprintf(sbuf, 2048, L"|%S|", utf8argv[i]);
- };
- MessageBoxW(NULL, tempbuf, L"respawn args", MB_OK|MB_ICONERROR);
- }
-#endif
-
- result = _wspawnv(_P_DETACH, start_prog, argv);
- free_fnuttified(utf8argv);
- if (result == -1) {
- error("Failed to execute %S: %s", start_prog, win32_errorstr(_doserrno));
- }
- } else {
- wchar_t *emu=NULL;
-#ifdef LOAD_BEAM_DYNAMICALLY
- HMODULE beam_module = NULL;
- len = MultiByteToWideChar(CP_UTF8, 0, utf8emu, -1, NULL, 0);
- emu = malloc(len*sizeof(wchar_t));
- MultiByteToWideChar(CP_UTF8, 0, utf8emu, -1, emu, len);
-#ifdef ARGS_HARDDEBUG
- {
- char sbuf[2048] = "";
- int i;
- strcat(sbuf,utf8emu);
- strcat(sbuf,":");
- for (i = 0; i < argc; ++i) {
- strcat(sbuf,"|");
- strcat(sbuf, utf8argv[i]);
- strcat(sbuf,"| ");
- }
- MessageBox(NULL, sbuf, "erl_start args", MB_OK|MB_ICONERROR);
- }
-#endif
- beam_module = load_win_beam_dll(emu);
-#endif
- set_env("ERL_CONSOLE_MODE", "window");
-#ifdef LOAD_BEAM_DYNAMICALLY
- (*sys_primitive_init_p)(beam_module);
- (*erl_start_p)(argc,utf8argv);
-#else
- erl_start(argc,utf8argv);
-#endif
- }
- return 0;
-}
-
void __cdecl
do_keep_window(void)
{
@@ -244,8 +146,6 @@ do_keep_window(void)
int
start_emulator(char* utf8emu, char *utf8start_prog, char** utf8argv, int start_detached)
{
- static char console_mode[] = "tty:ccc";
- char* fd_type;
char* title;
int len;
int argc = 0;
@@ -254,8 +154,6 @@ start_emulator(char* utf8emu, char *utf8start_prog, char** utf8argv, int start_d
fprintf(stderr,"utf8emu = %s, start_prog = %s\n", utf8emu, utf8start_prog);
#endif
- fd_type = strchr(console_mode, ':');
- fd_type++;
_flushall();
while (utf8argv[argc] != NULL) {
@@ -312,7 +210,14 @@ start_emulator(char* utf8emu, char *utf8start_prog, char** utf8argv, int start_d
if (result == (HANDLE)-1) {
#ifdef ARGS_HARDDEBUG
- MessageBox(NULL, "_wspawnv failed","Start detached",MB_OK);
+ wchar_t buf[256], buffer[256], path[1024];
+ DWORD err = GetLastError();
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ buf, (sizeof(buf) / sizeof(wchar_t)), NULL);
+ GetEnvironmentVariableW(L"PATH",path,sizeof(path) / sizeof(wchar_t));
+ wsprintfW(buffer,L"_wspawnv failed %s(%d)\nPATH=%s", buf, err, path);
+ MessageBoxW(NULL, buffer , L"Start detached",MB_OK);
#endif
return 1;
}
@@ -339,7 +244,7 @@ start_emulator(char* utf8emu, char *utf8start_prog, char** utf8argv, int start_d
}
#endif
beam_module = load_win_beam_dll(emu);
-#endif
+#endif
/*
* Start the emulator.
@@ -350,8 +255,8 @@ start_emulator(char* utf8emu, char *utf8start_prog, char** utf8argv, int start_d
SetConsoleTitle(title);
}
free_env_val(title);
-
- set_env("ERL_CONSOLE_MODE", console_mode);
+
+ set_env("ERL_CONSOLE_MODE", "windowed");
if (keep_window) {
atexit(do_keep_window);
}
@@ -387,10 +292,8 @@ error(char* format, ...)
vsprintf(sbuf, format, ap);
va_end(ap);
- if (!windowed && has_console()) {
+ if (has_console()) {
fprintf(stderr, "%s\n", sbuf);
- } else {
- MessageBox(NULL, sbuf, "Werl", MB_OK|MB_ICONERROR);
}
exit(1);
}