src/java.base/windows/native/libjli/cmdtoargs.c

Print this page




 176             src += charLength;
 177         }
 178     }
 179     if (prev == L'\\') {
 180         for (i = 0; i < slashes; i++) {
 181             dest += copyCh(prev, dest);
 182         }
 183     }
 184     *dest = 0;
 185     return done ? src : NULL;
 186 }
 187 
 188 int JLI_GetStdArgc() {
 189     return stdargc;
 190 }
 191 
 192 StdArg* JLI_GetStdArgs() {
 193     return stdargs;
 194 }
 195 










 196 void JLI_CmdToArgs(char* cmdline) {
 197     int nargs = 0;
 198     StdArg* argv = NULL;
 199     jboolean wildcard = JNI_FALSE;
 200     char* src = cmdline;
 201 
 202     // allocate arg buffer with sufficient space to receive the largest arg
 203     char* arg = JLI_StringDup(cmdline);
 204 
 205     do {
 206         src = next_arg(src, arg, &wildcard);
 207         // resize to accommodate another Arg
 208         argv = (StdArg*) JLI_MemRealloc(argv, (nargs+1) * sizeof(StdArg));
 209         argv[nargs].arg = JLI_StringDup(arg);
 210         argv[nargs].has_wildcard = wildcard;
 211         *arg = '\0';
 212         nargs++;
 213     } while (src != NULL);
 214 
 215     JLI_MemFree(arg);




 176             src += charLength;
 177         }
 178     }
 179     if (prev == L'\\') {
 180         for (i = 0; i < slashes; i++) {
 181             dest += copyCh(prev, dest);
 182         }
 183     }
 184     *dest = 0;
 185     return done ? src : NULL;
 186 }
 187 
 188 int JLI_GetStdArgc() {
 189     return stdargc;
 190 }
 191 
 192 StdArg* JLI_GetStdArgs() {
 193     return stdargs;
 194 }
 195 
 196 void JLI_ReleaseStdArgs() {
 197     StdArg* stdarg;
 198     for (stdarg = stdargs; stdarg < stdargs + stdargc; ++stdarg) {
 199         JLI_MemFree(stdarg->arg);
 200     }
 201     JLI_MemFree(stdargs);
 202     stdargs = NULL;
 203     stdargc = 0;
 204 }
 205 
 206 void JLI_CmdToArgs(char* cmdline) {
 207     int nargs = 0;
 208     StdArg* argv = NULL;
 209     jboolean wildcard = JNI_FALSE;
 210     char* src = cmdline;
 211 
 212     // allocate arg buffer with sufficient space to receive the largest arg
 213     char* arg = JLI_StringDup(cmdline);
 214 
 215     do {
 216         src = next_arg(src, arg, &wildcard);
 217         // resize to accommodate another Arg
 218         argv = (StdArg*) JLI_MemRealloc(argv, (nargs+1) * sizeof(StdArg));
 219         argv[nargs].arg = JLI_StringDup(arg);
 220         argv[nargs].has_wildcard = wildcard;
 221         *arg = '\0';
 222         nargs++;
 223     } while (src != NULL);
 224 
 225     JLI_MemFree(arg);