diff options
author | Henrik Nord <[email protected]> | 2015-12-18 12:25:03 +0100 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2015-12-18 12:25:03 +0100 |
commit | fc3ec3e298b8908a7065297c7a824de5eec13a51 (patch) | |
tree | 6a356bb53a8400cd8e561740b43e8a0b27a57aff /erts/etc/common/escript.c | |
parent | e6a733c5a903fafb52b73f7813fed72e4e29be6c (diff) | |
parent | 21d6192389a04024f7a41ced9d0911a9cce6f4e8 (diff) | |
download | otp-fc3ec3e298b8908a7065297c7a824de5eec13a51.tar.gz otp-fc3ec3e298b8908a7065297c7a824de5eec13a51.tar.bz2 otp-fc3ec3e298b8908a7065297c7a824de5eec13a51.zip |
Merge branch 'maint'
Conflicts:
OTP_VERSION
erts/vsn.mk
Diffstat (limited to 'erts/etc/common/escript.c')
-rw-r--r-- | erts/etc/common/escript.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/erts/etc/common/escript.c b/erts/etc/common/escript.c index a5c6d0d40b..7fd02ed436 100644 --- a/erts/etc/common/escript.c +++ b/erts/etc/common/escript.c @@ -74,6 +74,7 @@ static void error(char* format, ...); static char* emalloc(size_t size); static void efree(void *p); 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__ @@ -431,7 +432,7 @@ main(int argc, char** argv) emulator = get_default_emulator(argv[0]); } - if (strlen(emulator) >= MAXPATHLEN) + if (strlen(emulator) >= PMAX) error("Value of environment variable ESCRIPT_EMULATOR is too large"); /* @@ -444,7 +445,7 @@ main(int argc, char** argv) eargv_base = (char **) emalloc(eargv_size*sizeof(char*)); eargv = eargv_base; eargc = 0; - PUSH(strsave(emulator)); + push_words(emulator); eargc_base = eargc; eargv = eargv + eargv_size/2; eargc = 0; @@ -553,6 +554,26 @@ main(int argc, char** argv) return run_erlang(eargv[0], eargv); } +static void +push_words(char* src) +{ + char sbuf[PMAX]; + 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) { |