Backport #3235 » ruby_envspace.patch
ruby-1.8.8-head/ruby.c (working copy) | ||
---|---|---|
get_arglen(int argc, char **argv)
|
||
{
|
||
char *s = argv[0];
|
||
int i;
|
||
int i, j;
|
||
if (!argc) return 0;
|
||
s += strlen(s);
|
||
... | ... | |
}
|
||
}
|
||
#if defined(USE_ENVSPACE_FOR_ARG0)
|
||
if (environ && (s+1 == environ[0])) {
|
||
s++;
|
||
s += strlen(s);
|
||
for (i = 1; environ[i]; i++) {
|
||
if (environ[i] == s + 1) {
|
||
if (environ) {
|
||
for (i = 0; environ[i] == s+1; i++) {
|
||
s++;
|
||
s += strlen(s); /* this one is ok too */
|
||
}
|
||
}
|
||
# if defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
|
||
{
|
||
char *t = malloc(s - environ[0] + 1);
|
||
for (i = 0; environ[i]; i++) {
|
||
size_t len = strlen(environ[i]) + 1;
|
||
memcpy(t, environ[i], len);
|
||
environ[i] = t;
|
||
for (j = 0; j<i && environ[j]; j++) {
|
||
size_t len = strlen(environ[j]) + 1;
|
||
memcpy(t, environ[j], len);
|
||
environ[j] = t;
|
||
t += len;
|
||
}
|
||
}
|
- « Previous
- 1
- 2
- Next »