| 244 | } |
| 245 | |
| 246 | bool HandlePopFrontCommand(std::vector<std::string> const& args, |
| 247 | cmExecutionStatus& status) |
| 248 | { |
| 249 | assert(args.size() >= 2); |
| 250 | |
| 251 | cmMakefile& makefile = status.GetMakefile(); |
| 252 | auto ai = args.cbegin(); |
| 253 | ++ai; // Skip subcommand name |
| 254 | std::string const& listName = *ai++; |
| 255 | auto list = GetList(listName, makefile); |
| 256 | |
| 257 | if (!list) { |
| 258 | // Can't get the list definition... undefine any vars given after. |
| 259 | for (; ai != args.cend(); ++ai) { |
| 260 | makefile.RemoveDefinition(*ai); |
| 261 | } |
| 262 | return true; |
| 263 | } |
| 264 | |
| 265 | if (!list->empty()) { |
| 266 | if (ai == args.cend()) { |
| 267 | // No variables are given... Just remove one element. |
| 268 | list->pop_front(); |
| 269 | } else { |
| 270 | // Ok, assign elements to be removed to the given variables |
| 271 | auto vi = list->begin(); |
| 272 | for (; vi != list->end() && ai != args.cend(); ++ai, ++vi) { |
| 273 | assert(!ai->empty()); |
| 274 | makefile.AddDefinition(*ai, *vi); |
| 275 | } |
| 276 | list->erase(list->begin(), vi); |
| 277 | // Undefine the rest variables if the list gets empty earlier... |
| 278 | for (; ai != args.cend(); ++ai) { |
| 279 | makefile.RemoveDefinition(*ai); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | makefile.AddDefinition(listName, list->to_string()); |
| 284 | |
| 285 | } else if (ai != |
| 286 | args.cend()) { // The list is empty, but some args were given |
| 287 | // Need to *undefine* 'em all, cuz there are no items to assign... |
| 288 | for (; ai != args.cend(); ++ai) { |
| 289 | makefile.RemoveDefinition(*ai); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | return true; |
| 294 | } |
| 295 | |
| 296 | bool HandleFindCommand(std::vector<std::string> const& args, |
| 297 | cmExecutionStatus& status) |
nothing calls this directly
no test coverage detected
searching dependent graphs…