# Patch for
# http://rubyforge.org/tracker/index.php?func=detail&aid=3399&group_id=426&atid=1698
old
|
new
|
|
1033 | 1033 | rb_progname = rb_tainted_str_new(s, i); |
1034 | 1034 | #else |
1035 | 1035 | if (len == 0) { |
1036 | | char *s = origargv[0]; |
1037 | | int i; |
| 1036 | char *s1 = origargv[0]; |
| 1037 | int j; |
1038 | 1038 | |
1039 | | s += strlen(s); |
| 1039 | s1 += strlen(s1); |
1040 | 1040 | /* See if all the arguments are contiguous in memory */ |
1041 | | for (i = 1; i < origargc; i++) { |
1042 | | if (origargv[i] == s + 1) { |
1043 | | s++; |
1044 | | s += strlen(s); /* this one is ok too */ |
| 1041 | for (j = 1; j < origargc; j++) { |
| 1042 | if (origargv[j] == s1 + 1) { |
| 1043 | s1++; |
| 1044 | s1 += strlen(s1); /* this one is ok too */ |
1045 | 1045 | } |
1046 | 1046 | else { |
1047 | 1047 | break; |
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | #ifndef DOSISH |
1051 | | if (s + 1 == envspace.begin) { |
1052 | | s = envspace.end; |
| 1051 | if (s1 + 1 == envspace.begin) { |
| 1052 | s1 = envspace.end; |
1053 | 1053 | ruby_setenv("", NULL); /* duplicate environ vars */ |
1054 | 1054 | } |
1055 | 1055 | #endif |
1056 | | len = s - origargv[0]; |
| 1056 | len = s1 - origargv[0]; |
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | if (i >= len) { |
1060 | 1060 | i = len; |
1061 | | memcpy(origargv[0], s, i); |
1062 | | origargv[0][i] = '\0'; |
1063 | 1061 | } |
1064 | | else { |
1065 | | memcpy(origargv[0], s, i); |
1066 | | s = origargv[0]+i; |
1067 | | *s++ = '\0'; |
1068 | | while (++i < len) |
1069 | | *s++ = ' '; |
1070 | | for (i = 1; i < origargc; i++) |
1071 | | origargv[i] = 0; |
| 1062 | memcpy(origargv[0], s, i); |
| 1063 | memset(origargv[0] + i, '\0', len - i + 1); |
| 1064 | |
| 1065 | /* If the new program name is longer than the original one, then |
| 1066 | * have any command line arguments that were written over be |
| 1067 | * empty strings. */ |
| 1068 | s = origargv[0] + i; |
| 1069 | for (i = 1; i < origargc; ++i) { |
| 1070 | if (origargv[i] < s ) { |
| 1071 | origargv[i] = s; |
| 1072 | } else { |
| 1073 | break; |
| 1074 | } |
1072 | 1075 | } |
| 1076 | |
1073 | 1077 | rb_progname = rb_tainted_str_new2(origargv[0]); |
1074 | 1078 | #endif |
1075 | 1079 | } |