| 401 | } // anonymous namespace |
| 402 | |
| 403 | bool cmForEachCommand(std::vector<std::string> const& args, |
| 404 | cmExecutionStatus& status) |
| 405 | { |
| 406 | if (args.empty()) { |
| 407 | status.SetError("called with incorrect number of arguments"); |
| 408 | return false; |
| 409 | } |
| 410 | auto kwInIter = std::find(args.begin(), args.end(), "IN"); |
| 411 | if (kwInIter != args.end()) { |
| 412 | return HandleInMode(args, kwInIter, status.GetMakefile()); |
| 413 | } |
| 414 | |
| 415 | // create a function blocker |
| 416 | auto fb = cm::make_unique<cmForEachFunctionBlocker>(&status.GetMakefile()); |
| 417 | if (args.size() > 1) { |
| 418 | if (args[1] == "RANGE") { |
| 419 | int start = 0; |
| 420 | int stop = 0; |
| 421 | int step = 0; |
| 422 | if (args.size() == 3) { |
| 423 | if (!TryParseInteger(status, args[2], stop)) { |
| 424 | return false; |
| 425 | } |
| 426 | } |
| 427 | if (args.size() == 4) { |
| 428 | if (!TryParseInteger(status, args[2], start)) { |
| 429 | return false; |
| 430 | } |
| 431 | if (!TryParseInteger(status, args[3], stop)) { |
| 432 | return false; |
| 433 | } |
| 434 | } |
| 435 | if (args.size() == 5) { |
| 436 | if (!TryParseInteger(status, args[2], start)) { |
| 437 | return false; |
| 438 | } |
| 439 | if (!TryParseInteger(status, args[3], stop)) { |
| 440 | return false; |
| 441 | } |
| 442 | if (!TryParseInteger(status, args[4], step)) { |
| 443 | return false; |
| 444 | } |
| 445 | } |
| 446 | if (step == 0) { |
| 447 | if (start > stop) { |
| 448 | step = -1; |
| 449 | } else { |
| 450 | step = 1; |
| 451 | } |
| 452 | } |
| 453 | if ((start > stop && step > 0) || (start < stop && step < 0) || |
| 454 | step == 0) { |
| 455 | status.SetError( |
| 456 | cmStrCat("called with incorrect range specification: start ", start, |
| 457 | ", stop ", stop, ", step ", step)); |
| 458 | cmSystemTools::SetFatalErrorOccurred(); |
| 459 | return false; |
| 460 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…