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

Function _get_cmd_arg

win/win32/NetHackW.c:260–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260TCHAR *
261_get_cmd_arg(TCHAR *pCmdLine)
262{
263 static TCHAR *pArgs = NULL;
264 TCHAR *pRetArg;
265 BOOL bQuoted;
266
267 if (!pCmdLine && !pArgs)
268 return NULL;
269 if (!pArgs)
270 pArgs = pCmdLine;
271
272 /* skip whitespace */
273 for (pRetArg = pArgs; *pRetArg && _istspace(*pRetArg);
274 pRetArg = CharNext(pRetArg))
275 ;
276 if (!*pRetArg) {
277 pArgs = NULL;
278 return NULL;
279 }
280
281 /* check for quote */
282 if (*pRetArg == TEXT('"')) {
283 bQuoted = TRUE;
284 pRetArg = CharNext(pRetArg);
285 pArgs = _tcschr(pRetArg, TEXT('"'));
286 } else {
287 /* skip to whitespace */
288 for (pArgs = pRetArg; *pArgs && !_istspace(*pArgs);
289 pArgs = CharNext(pArgs))
290 ;
291 }
292
293 if (pArgs && *pArgs) {
294 TCHAR *p;
295 p = pArgs;
296 pArgs = CharNext(pArgs);
297 *p = (TCHAR) 0;
298 } else {
299 pArgs = NULL;
300 }
301 nhUse(bQuoted);
302 return pRetArg;
303}
304
305/* Get the version of the Common Control library on this machine.
306 Copied from the Microsoft SDK

Callers 1

WinMainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected