From a6a4029f0d4fd78d7cd0971e1f6ad3b6bfd1cd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Wed, 21 Feb 2007 09:53:50 +0000 Subject: [PATCH] * src/LaTeX.C - (insertIfExists): new helper function. - (handleFoundFile): minor refactoring. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17289 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LaTeX.C | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/LaTeX.C b/src/LaTeX.C index 1f40977cfb..979e813af2 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -723,6 +723,17 @@ int LaTeX::scanLogFile(TeXErrors & terr) namespace { +bool insertIfExists(FileName const & absname, DepTable & head) +{ + fs::path const path = absname.toFilesystemEncoding(); + if (fs::exists(path) && !fs::is_directory(path)) { + head.insert(absname, true); + return true; + } + return false; +} + + bool handleFoundFile(string const & ff, DepTable & head) { // convert from native os path to unix path @@ -746,11 +757,7 @@ bool handleFoundFile(string const & ff, DepTable & head) // since this file cannot be a file generated by // the latex run. FileName absname(foundfile); - if (fs::exists(absname.toFilesystemEncoding()) && - !fs::is_directory(absname.toFilesystemEncoding())) { - head.insert(absname, true); - return true; - } else { + if (!insertIfExists(absname, head)) { // check for spaces string strippedfile = foundfile; while (contains(strippedfile, " ")) { @@ -759,11 +766,8 @@ bool handleFoundFile(string const & ff, DepTable & head) string const stripoff = rsplit(tmp, strippedfile, ' '); absname.set(strippedfile); - if (fs::exists(absname.toFilesystemEncoding()) && - !fs::is_directory(absname.toFilesystemEncoding())) { - head.insert(absname, true); + if (insertIfExists(absname, head)) return true; - } } } } @@ -788,8 +792,8 @@ bool handleFoundFile(string const & ff, DepTable & head) // (2) foundfile is in the tmpdir // insert it into head - if (fs::exists(absname.toFilesystemEncoding()) && - !fs::is_directory(absname.toFilesystemEncoding())) { + fs::path const path = absname.toFilesystemEncoding(); + if (fs::exists(path) && !fs::is_directory(path)) { static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$"); if (regex_match(onlyfile, unwanted)) { lyxerr[Debug::DEPEND]