| 858 | } |
| 859 | |
| 860 | bool HandleRemoveAtCommand(std::vector<std::string> const& args, |
| 861 | cmExecutionStatus& status) |
| 862 | { |
| 863 | if (args.size() < 3) { |
| 864 | status.SetError("sub-command REMOVE_AT requires at least " |
| 865 | "two arguments."); |
| 866 | return false; |
| 867 | } |
| 868 | |
| 869 | std::string const& listName = args[1]; |
| 870 | // expand the variable |
| 871 | auto list = GetList(listName, status.GetMakefile()); |
| 872 | |
| 873 | if (!list || list->empty()) { |
| 874 | std::ostringstream str; |
| 875 | str << "index: "; |
| 876 | for (size_t i = 1; i < args.size(); ++i) { |
| 877 | str << args[i]; |
| 878 | if (i != args.size() - 1) { |
| 879 | str << ", "; |
| 880 | } |
| 881 | } |
| 882 | str << " out of range (0, 0)"; |
| 883 | status.SetError(str.str()); |
| 884 | return false; |
| 885 | } |
| 886 | |
| 887 | size_t cc; |
| 888 | std::vector<cmList::index_type> removed; |
| 889 | for (cc = 2; cc < args.size(); ++cc) { |
| 890 | int index; |
| 891 | if (!GetIndexArg(args[cc], &index, status.GetMakefile())) { |
| 892 | status.SetError(cmStrCat("index: ", args[cc], " is not a valid index")); |
| 893 | return false; |
| 894 | } |
| 895 | removed.push_back(index); |
| 896 | } |
| 897 | |
| 898 | try { |
| 899 | status.GetMakefile().AddDefinition( |
| 900 | listName, |
| 901 | list->remove_items(removed.begin(), removed.end()).to_string()); |
| 902 | return true; |
| 903 | } catch (std::out_of_range& e) { |
| 904 | status.SetError(e.what()); |
| 905 | return false; |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | bool HandleFilterCommand(std::vector<std::string> const& args, |
| 910 | cmExecutionStatus& status) |
nothing calls this directly
no test coverage detected
searching dependent graphs…