29 * There are rules which govern the breaking of the arguments, and |
29 * There are rules which govern the breaking of the arguments, and |
30 * these rules are embodied in the regression tests below, and duplicated |
30 * these rules are embodied in the regression tests below, and duplicated |
31 * in the jdk regression tests. |
31 * in the jdk regression tests. |
32 */ |
32 */ |
33 |
33 |
|
34 #include <assert.h> |
|
35 |
34 #ifndef IDE_STANDALONE |
36 #ifndef IDE_STANDALONE |
35 #include "java.h" |
37 #include "java.h" |
36 #include "jli_util.h" |
38 #include "jli_util.h" |
37 #else /* IDE_STANDALONE */ |
39 #else /* IDE_STANDALONE */ |
38 // The defines we need for stand alone testing |
40 // The defines we need for stand alone testing |
198 int nargs = 0; |
200 int nargs = 0; |
199 StdArg* argv = NULL; |
201 StdArg* argv = NULL; |
200 jboolean wildcard = JNI_FALSE; |
202 jboolean wildcard = JNI_FALSE; |
201 char* src = cmdline; |
203 char* src = cmdline; |
202 JLI_List argsInFile; |
204 JLI_List argsInFile; |
|
205 size_t i, cnt; |
|
206 |
|
207 JLI_List envArgs = JLI_List_new(1); |
|
208 if (JLI_AddArgsFromEnvVar(envArgs, JAVA_OPTIONS)) { |
|
209 // JLI_SetTraceLauncher is not called yet |
|
210 // Show _JAVA_OPTIONS content along with JAVA_OPTIONS to aid diagnosis |
|
211 if (getenv(JLDEBUG_ENV_ENTRY)) { |
|
212 char *tmp = getenv("_JAVA_OPTIONS"); |
|
213 if (NULL != tmp) { |
|
214 JLI_ReportMessage(ARG_INFO_ENVVAR, "_JAVA_OPTIONS", tmp); |
|
215 } |
|
216 } |
|
217 } |
|
218 cnt = envArgs->size + 1; |
|
219 argv = JLI_MemAlloc(cnt * sizeof(StdArg)); |
203 |
220 |
204 // allocate arg buffer with sufficient space to receive the largest arg |
221 // allocate arg buffer with sufficient space to receive the largest arg |
205 char* arg = JLI_StringDup(cmdline); |
222 char* arg = JLI_StringDup(cmdline); |
206 |
223 |
207 do { |
224 src = next_arg(src, arg, &wildcard); |
|
225 // first argument is the app name, do not preprocess and make sure remains first |
|
226 argv[0].arg = JLI_StringDup(arg); |
|
227 argv[0].has_wildcard = wildcard; |
|
228 nargs++; |
|
229 |
|
230 for (i = 1; i < cnt; i++) { |
|
231 argv[i].arg = envArgs->elements[i - 1]; |
|
232 // wildcard is not supported in argfile |
|
233 argv[i].has_wildcard = JNI_FALSE; |
|
234 nargs++; |
|
235 } |
|
236 JLI_MemFree(envArgs->elements); |
|
237 JLI_MemFree(envArgs); |
|
238 |
|
239 assert ((size_t) nargs == cnt); |
|
240 *arg = '\0'; |
|
241 |
|
242 // iterate through rest of command line |
|
243 while (src != NULL) { |
208 src = next_arg(src, arg, &wildcard); |
244 src = next_arg(src, arg, &wildcard); |
209 argsInFile = JLI_PreprocessArg(arg); |
245 argsInFile = JLI_PreprocessArg(arg); |
210 if (argsInFile != NULL) { |
246 if (argsInFile != NULL) { |
211 size_t cnt, i; |
|
212 // resize to accommodate another Arg |
247 // resize to accommodate another Arg |
213 cnt = argsInFile->size; |
248 cnt = argsInFile->size; |
214 argv = (StdArg*) JLI_MemRealloc(argv, (nargs + cnt) * sizeof(StdArg)); |
249 argv = (StdArg*) JLI_MemRealloc(argv, (nargs + cnt) * sizeof(StdArg)); |
215 for (i = 0; i < cnt; i++) { |
250 for (i = 0; i < cnt; i++) { |
216 argv[nargs].arg = argsInFile->elements[i]; |
251 argv[nargs].arg = argsInFile->elements[i]; |