MCPcopy Create free account
hub / github.com/NetHack/NetHack / _get_cmd_arg

Function _get_cmd_arg

outdated/sys/wince/winhack.c:277–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277TCHAR *
278_get_cmd_arg(TCHAR *pCmdLine)
279{
280 static TCHAR *pArgs = NULL;
281 TCHAR *pRetArg;
282 BOOL bQuoted;
283
284 if (!pCmdLine && !pArgs)
285 return NULL;
286 if (!pArgs)
287 pArgs = pCmdLine;
288
289 /* skip whitespace */
290 for (pRetArg = pArgs; *pRetArg && _istspace(*pRetArg);
291 pRetArg = CharNext(pRetArg))
292 ;
293 if (!*pRetArg) {
294 pArgs = NULL;
295 return NULL;
296 }
297
298 /* check for quote */
299 if (*pRetArg == TEXT('"')) {
300 bQuoted = TRUE;
301 pRetArg = CharNext(pRetArg);
302 pArgs = _tcschr(pRetArg, TEXT('"'));
303 } else {
304 /* skip to whitespace */
305 for (pArgs = pRetArg; *pArgs && !_istspace(*pArgs);
306 pArgs = CharNext(pArgs))
307 ;
308 }
309
310 if (pArgs && *pArgs) {
311 TCHAR *p;
312 p = pArgs;
313 pArgs = CharNext(pArgs);
314 *p = (TCHAR) 0;
315 } else {
316 pArgs = NULL;
317 }
318
319 return pRetArg;
320}
321
322/*
323 * Strip out troublesome file system characters.

Callers 1

WinMainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected