Home | Info | Community | Development | myReactOS | Contact Us
[static]
Definition at line 416 of file parser.c.
Referenced by ParseCommandPart().
{ PARSED_COMMAND *Cmd = cmd_alloc(sizeof(PARSED_COMMAND)); TCHAR List[CMDLINE_LENGTH]; TCHAR *Pos = List; memset(Cmd, 0, sizeof(PARSED_COMMAND)); Cmd->Type = C_FOR; while (1) { if (_tcsicmp(CurrentToken, _T("/D")) == 0) Cmd->For.Switches |= FOR_DIRS; else if (_tcsicmp(CurrentToken, _T("/F")) == 0) { Cmd->For.Switches |= FOR_F; if (!Cmd->For.Params) { ParseToken(0, STANDARD_SEPS); if (CurrentToken[0] == _T('/') || CurrentToken[0] == _T('%')) break; Cmd->For.Params = cmd_dup(CurrentToken); } } else if (_tcsicmp(CurrentToken, _T("/L")) == 0) Cmd->For.Switches |= FOR_LOOP; else if (_tcsicmp(CurrentToken, _T("/R")) == 0) { Cmd->For.Switches |= FOR_RECURSIVE; if (!Cmd->For.Params) { ParseToken(0, STANDARD_SEPS); if (CurrentToken[0] == _T('/') || CurrentToken[0] == _T('%')) break; StripQuotes(CurrentToken); Cmd->For.Params = cmd_dup(CurrentToken); } } else break; ParseToken(0, STANDARD_SEPS); } /* Make sure there aren't two different switches specified * at the same time, unless they're /D and /R */ if ((Cmd->For.Switches & (Cmd->For.Switches - 1)) != 0 && Cmd->For.Switches != (FOR_DIRS | FOR_RECURSIVE)) { goto error; } /* Variable name should be % and just one other character */ if (CurrentToken[0] != _T('%') || _tcslen(CurrentToken) != 2) goto error; Cmd->For.Variable = CurrentToken[1]; ParseToken(0, STANDARD_SEPS); if (_tcsicmp(CurrentToken, _T("in")) != 0) goto error; if (ParseToken(_T('('), STANDARD_SEPS) != TOK_BEGIN_BLOCK) goto error; while (1) { int Type; /* Pretend we're inside a block so the tokenizer will stop on ')' */ InsideBlock++; Type = ParseToken(0, STANDARD_SEPS); InsideBlock--; if (Type == TOK_END_BLOCK) break; if (Type != TOK_NORMAL) goto error; if (Pos != List) *Pos++ = _T(' '); if (Pos + _tcslen(CurrentToken) >= &List[CMDLINE_LENGTH]) goto error; Pos = _stpcpy(Pos, CurrentToken); } *Pos = _T('\0'); Cmd->For.List = cmd_dup(List); ParseToken(0, STANDARD_SEPS); if (_tcsicmp(CurrentToken, _T("do")) != 0) goto error; Cmd->Subcommands = ParseCommandOp(C_OP_LOWEST); if (Cmd->Subcommands == NULL) { FreeCommand(Cmd); return NULL; } return Cmd; error: FreeCommand(Cmd); ParseError(); return NULL; }