113
114 // All arguments arrive here must be a launcher argument,
115 // ie. by now, all argfile expansions must have been performed.
116 if (*arg == '-') {
117 expectingNoDashArg = JNI_FALSE;
118 if (IsWhiteSpaceOption(arg)) {
119 // expect an argument
120 expectingNoDashArg = JNI_TRUE;
121
122 if (JLI_StrCmp(arg, "-jar") == 0 ||
123 JLI_StrCmp(arg, "--module") == 0 ||
124 JLI_StrCmp(arg, "-m") == 0) {
125 // This is tricky, we do expect NoDashArg
126 // But that is considered main class to stop expansion
127 expectingNoDashArg = JNI_FALSE;
128 // We can not just update the idx here because if -jar @file
129 // still need expansion of @file to get the argument for -jar
130 }
131 } else if (JLI_StrCmp(arg, "--disable-@files") == 0) {
132 stopExpansion = JNI_TRUE;
133 }
134 } else {
135 if (!expectingNoDashArg) {
136 // this is main class, argsCount is index to next arg
137 idx = argsCount;
138 }
139 expectingNoDashArg = JNI_FALSE;
140 }
141 // only update on java mode and not yet found main class
142 if (firstAppArgIndex == NOT_FOUND && idx != 0) {
143 firstAppArgIndex = (int) idx;
144 }
145 }
146
147 /*
148 [\n\r] +------------+ +------------+ [\n\r]
149 +---------+ IN_COMMENT +<------+ | IN_ESCAPE +---------+
150 | +------------+ | +------------+ |
151 | [#] ^ |[#] ^ | |
152 | +----------+ | [\\]| |[^\n\r] |
432 checkArg(arg);
433 return NULL;
434 }
435
436 arg++;
437 if (arg[0] == '@') {
438 // escaped @argument
439 rv = JLI_List_new(1);
440 checkArg(arg);
441 JLI_List_add(rv, JLI_StringDup(arg));
442 } else {
443 rv = expandArgFile(arg);
444 }
445 return rv;
446 }
447
448 int isTerminalOpt(char *arg) {
449 return JLI_StrCmp(arg, "-jar") == 0 ||
450 JLI_StrCmp(arg, "-m") == 0 ||
451 JLI_StrCmp(arg, "--module") == 0 ||
452 JLI_StrCmp(arg, "--dry-run") == 0 ||
453 JLI_StrCmp(arg, "-h") == 0 ||
454 JLI_StrCmp(arg, "-?") == 0 ||
455 JLI_StrCmp(arg, "-help") == 0 ||
456 JLI_StrCmp(arg, "--help") == 0 ||
457 JLI_StrCmp(arg, "-X") == 0 ||
458 JLI_StrCmp(arg, "--help-extra") == 0 ||
459 JLI_StrCmp(arg, "-version") == 0 ||
460 JLI_StrCmp(arg, "--version") == 0 ||
461 JLI_StrCmp(arg, "-fullversion") == 0 ||
462 JLI_StrCmp(arg, "--full-version") == 0;
463 }
464
465 JNIEXPORT jboolean JNICALL
466 JLI_AddArgsFromEnvVar(JLI_List args, const char *var_name) {
467 char *env = getenv(var_name);
468
469 if (firstAppArgIndex == 0) {
470 // Not 'java', return
471 return JNI_FALSE;
|
113
114 // All arguments arrive here must be a launcher argument,
115 // ie. by now, all argfile expansions must have been performed.
116 if (*arg == '-') {
117 expectingNoDashArg = JNI_FALSE;
118 if (IsWhiteSpaceOption(arg)) {
119 // expect an argument
120 expectingNoDashArg = JNI_TRUE;
121
122 if (JLI_StrCmp(arg, "-jar") == 0 ||
123 JLI_StrCmp(arg, "--module") == 0 ||
124 JLI_StrCmp(arg, "-m") == 0) {
125 // This is tricky, we do expect NoDashArg
126 // But that is considered main class to stop expansion
127 expectingNoDashArg = JNI_FALSE;
128 // We can not just update the idx here because if -jar @file
129 // still need expansion of @file to get the argument for -jar
130 }
131 } else if (JLI_StrCmp(arg, "--disable-@files") == 0) {
132 stopExpansion = JNI_TRUE;
133 } else if (JLI_StrCCmp(arg, "--module=") == 0) {
134 idx = argsCount;
135 }
136 } else {
137 if (!expectingNoDashArg) {
138 // this is main class, argsCount is index to next arg
139 idx = argsCount;
140 }
141 expectingNoDashArg = JNI_FALSE;
142 }
143 // only update on java mode and not yet found main class
144 if (firstAppArgIndex == NOT_FOUND && idx != 0) {
145 firstAppArgIndex = (int) idx;
146 }
147 }
148
149 /*
150 [\n\r] +------------+ +------------+ [\n\r]
151 +---------+ IN_COMMENT +<------+ | IN_ESCAPE +---------+
152 | +------------+ | +------------+ |
153 | [#] ^ |[#] ^ | |
154 | +----------+ | [\\]| |[^\n\r] |
434 checkArg(arg);
435 return NULL;
436 }
437
438 arg++;
439 if (arg[0] == '@') {
440 // escaped @argument
441 rv = JLI_List_new(1);
442 checkArg(arg);
443 JLI_List_add(rv, JLI_StringDup(arg));
444 } else {
445 rv = expandArgFile(arg);
446 }
447 return rv;
448 }
449
450 int isTerminalOpt(char *arg) {
451 return JLI_StrCmp(arg, "-jar") == 0 ||
452 JLI_StrCmp(arg, "-m") == 0 ||
453 JLI_StrCmp(arg, "--module") == 0 ||
454 JLI_StrCCmp(arg, "--module=") == 0 ||
455 JLI_StrCmp(arg, "--dry-run") == 0 ||
456 JLI_StrCmp(arg, "-h") == 0 ||
457 JLI_StrCmp(arg, "-?") == 0 ||
458 JLI_StrCmp(arg, "-help") == 0 ||
459 JLI_StrCmp(arg, "--help") == 0 ||
460 JLI_StrCmp(arg, "-X") == 0 ||
461 JLI_StrCmp(arg, "--help-extra") == 0 ||
462 JLI_StrCmp(arg, "-version") == 0 ||
463 JLI_StrCmp(arg, "--version") == 0 ||
464 JLI_StrCmp(arg, "-fullversion") == 0 ||
465 JLI_StrCmp(arg, "--full-version") == 0;
466 }
467
468 JNIEXPORT jboolean JNICALL
469 JLI_AddArgsFromEnvVar(JLI_List args, const char *var_name) {
470 char *env = getenv(var_name);
471
472 if (firstAppArgIndex == 0) {
473 // Not 'java', return
474 return JNI_FALSE;
|