| 289 | } |
| 290 | |
| 291 | bool HandleInMode(std::vector<std::string> const& args, |
| 292 | std::vector<std::string>::const_iterator kwInIter, |
| 293 | cmMakefile& makefile) |
| 294 | { |
| 295 | assert("A valid iterator expected" && kwInIter != args.end()); |
| 296 | |
| 297 | auto fb = cm::make_unique<cmForEachFunctionBlocker>(&makefile); |
| 298 | |
| 299 | // Copy iteration variable names first |
| 300 | std::copy(args.begin(), kwInIter, std::back_inserter(fb->Args)); |
| 301 | // Remember the count of given iteration variable names |
| 302 | auto const varsCount = fb->Args.size(); |
| 303 | fb->SetIterationVarsCount(varsCount); |
| 304 | |
| 305 | enum Doing |
| 306 | { |
| 307 | DoingNone, |
| 308 | DoingLists, |
| 309 | DoingItems, |
| 310 | DoingZipLists |
| 311 | }; |
| 312 | Doing doing = DoingNone; |
| 313 | // Iterate over arguments past the "IN" keyword |
| 314 | for (std::string const& arg : cmMakeRange(++kwInIter, args.end())) { |
| 315 | if (arg == "LISTS") { |
| 316 | if (doing == DoingZipLists) { |
| 317 | makefile.IssueMessage(MessageType::FATAL_ERROR, |
| 318 | "ZIP_LISTS can not be used with LISTS or ITEMS"); |
| 319 | return true; |
| 320 | } |
| 321 | if (varsCount != 1u) { |
| 322 | makefile.IssueMessage( |
| 323 | MessageType::FATAL_ERROR, |
| 324 | "ITEMS or LISTS require exactly one iteration variable"); |
| 325 | return true; |
| 326 | } |
| 327 | doing = DoingLists; |
| 328 | |
| 329 | } else if (arg == "ITEMS") { |
| 330 | if (doing == DoingZipLists) { |
| 331 | makefile.IssueMessage(MessageType::FATAL_ERROR, |
| 332 | "ZIP_LISTS can not be used with LISTS or ITEMS"); |
| 333 | return true; |
| 334 | } |
| 335 | if (varsCount != 1u) { |
| 336 | makefile.IssueMessage( |
| 337 | MessageType::FATAL_ERROR, |
| 338 | "ITEMS or LISTS require exactly one iteration variable"); |
| 339 | return true; |
| 340 | } |
| 341 | doing = DoingItems; |
| 342 | |
| 343 | } else if (arg == "ZIP_LISTS") { |
| 344 | if (doing != DoingNone) { |
| 345 | makefile.IssueMessage(MessageType::FATAL_ERROR, |
| 346 | "ZIP_LISTS can not be used with LISTS or ITEMS"); |
| 347 | return true; |
| 348 | } |
no test coverage detected
searching dependent graphs…