- DepList tmp;
- // we want const_iterator (Lgb)
- for (DepList::iterator cit = deplist.begin();
- cit != deplist.end(); ++cit) {
- if (!suffixIs(cit->first, suf))
- tmp[cit->first] = cit->second;
+ DepList::iterator cit = deplist.begin();
+ DepList::iterator end = deplist.end();
+ while (cit != end) {
+ if (suffixIs(cit->first, suf)) {
+ // Can't erase the current iterator, but we
+ // can increment and then erase.
+ // Deplist is a map so only the erased
+ // iterator is invalidated.
+ DepList::iterator doomed = cit++;
+ deplist.erase(doomed);
+ continue;
+ }
+ ++cit;
+ }
+}
+
+
+void DepTable::remove_file(string const & filename)
+{
+ DepList::iterator cit = deplist.begin();
+ DepList::iterator end = deplist.end();
+ while (cit != end) {
+ if (OnlyFilename(cit->first) == filename) {
+ // Can't erase the current iterator, but we
+ // can increment and then erase.
+ // deplist is a map so only the erased
+ // iterator is invalidated.
+ DepList::iterator doomed = cit++;
+ deplist.erase(doomed);
+ continue;
+ }
+ ++cit;