stub.c: use argv[0] unchanged

* win32/stub.c (stub_sysinit): use argv[0] unchanged and just
  insert full path name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-04-04 01:00:45 +00:00
parent c28fabfdfe
commit 8fb5a1aceb

View File

@ -21,7 +21,7 @@ stub_sysinit(int *argc, char ***argv)
for (i = 1; i < ac; ++i) { for (i = 1; i < ac; ++i) {
lenall += strlen(av[i]) + 1; lenall += strlen(av[i]) + 1;
} }
av = realloc(av, lenall + (lenexe + 1) * 2 + sizeof(char *) * (i + 2)); av = realloc(av, lenall + len0 + (lenexe + 1) + sizeof(char *) * (i + 2));
if (!av) { if (!av) {
perror("realloc command line"); perror("realloc command line");
exit(-1); exit(-1);
@ -29,11 +29,10 @@ stub_sysinit(int *argc, char ***argv)
*argv = av; *argv = av;
*argc = ++ac; *argc = ++ac;
p = (char *)(av + i + 2); p = (char *)(av + i + 2);
memmove(p + (lenexe + 1) * 2, (char *)(av + ac) + len0, lenall); memmove(p + len0 + lenexe + 1, (char *)(av + ac) + len0, lenall);
memcpy(p, exename, lenexe); memmove(p, (char *)(av + ac), len0);
p[lenexe] = '\0';
*av++ = p; *av++ = p;
p += lenexe + 1; p += len0;
memcpy(p, exename, lenexe); memcpy(p, exename, lenexe);
p[lenexe] = '\0'; p[lenexe] = '\0';
*av++ = p; *av++ = p;