X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FDepTable.C;h=0bc13ef436c0ef739596e4488b13f2006acbd0a9;hb=ab254289c832cd045c56e6012d14b048618cb833;hp=f28f744859d65c94d130122ac8079975f4ee6b22;hpb=a040c0bc6f017d0591bbc7ad1aa590589dbc40ff;p=lyx.git diff --git a/src/DepTable.C b/src/DepTable.C index f28f744859..0bc13ef436 100644 --- a/src/DepTable.C +++ b/src/DepTable.C @@ -2,10 +2,10 @@ * ====================================================== * * LyX, The Document Processor - * Copyright (C) 1995 Matthias Ettrich - * Copyright (C) 1995-1998 The LyX Team. + * Copyright 1995 Matthias Ettrich + * Copyright 1995-2001 The LyX Team. * - * This file is Copyright (C) 1996-1998 + * This file is Copyright 1996-2001 * Lars Gullik Bjønnes * * ====================================================== @@ -21,9 +21,11 @@ #include "support/lyxlib.h" #include "support/filetools.h" #include + using std::make_pair; using std::ofstream; using std::ifstream; +using std::endl; void DepTable::insert(string const & fi, bool upd, @@ -35,7 +37,7 @@ void DepTable::insert(string const & fi, if (deplist.find(f) == deplist.end()) { if (upd) { one = two; - two = lyxsum(f.c_str()); + two = lyx::sum(f); } deplist[f] = make_pair(one, two); } @@ -44,21 +46,24 @@ void DepTable::insert(string const & fi, void DepTable::update() { - for(DepList::iterator itr = deplist.begin(); + for (DepList::iterator itr = deplist.begin(); itr != deplist.end(); ++itr) { - unsigned long one = (*itr).second.second; - unsigned long two = lyxsum((*itr).first.c_str()); + unsigned long const one = (*itr).second.second; + unsigned long const two = lyx::sum((*itr).first); (*itr).second = make_pair(one, two); - if (lyxerr.debugging()) { - lyxerr << "update: " << (*itr).first << " " - << one << " " << two << endl; + if (lyxerr.debugging(Debug::DEPEND)) { + lyxerr << "Update dep: " << (*itr).first << " " + << one << " " << two; + if (one != two) + lyxerr << " +"; + lyxerr << endl; } } } -bool DepTable::sumchange() +bool DepTable::sumchange() const { for (DepList::const_iterator cit = deplist.begin(); cit != deplist.end(); @@ -69,7 +74,7 @@ bool DepTable::sumchange() } -bool DepTable::haschanged(string const & f) +bool DepTable::haschanged(string const & f) const { // not quite sure if this is the correct place for MakeAbsPath string fil = MakeAbsPath(f); @@ -83,28 +88,47 @@ bool DepTable::haschanged(string const & f) } -bool DepTable::extchanged(string const & ext) +bool DepTable::extchanged(string const & ext) const { for (DepList::const_iterator cit = deplist.begin(); cit != deplist.end(); ++cit) { - if (suffixIs((*cit).first, ext.c_str())) { + if (suffixIs((*cit).first, ext)) { if ((*cit).second.first != (*cit).second.second) return true; } } - return false; } -void DepTable::write(string const & f) +bool DepTable::exist(string const & fil) const +{ + DepList::const_iterator cit = deplist.find(fil); + if (cit != deplist.end()) return true; + return false; +} + + +void DepTable::remove_files_with_extension(string const & suf) +{ + 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.swap(tmp); +} + + +void DepTable::write(string const & f) const { ofstream ofs(f.c_str()); for (DepList::const_iterator cit = deplist.begin(); - cit != deplist.end(); - ++cit) { - if (lyxerr.debugging()) { + cit != deplist.end(); ++cit) { + if (lyxerr.debugging(Debug::DEPEND)) { lyxerr << "Write dep: " << (*cit).first << " " << (*cit).second.first << " " @@ -116,15 +140,16 @@ void DepTable::write(string const & f) } } -void DepTable::read(string const &f) + +void DepTable::read(string const & f) { ifstream ifs(f.c_str()); string nome; unsigned long one = 0; unsigned long two = 0; while(ifs >> nome >> one >> two) { - if (lyxerr.debugging()) { - lyxerr << "read dep: " + if (lyxerr.debugging(Debug::DEPEND)) { + lyxerr << "Read dep: " << nome << " " << one << " " << two << endl;