From 52727f6f9678cbb22c65a34d5b8c5baf40d8d2a9 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Mon, 12 Mar 2007 19:38:20 +0000 Subject: [PATCH] Improve fix for bug 3305 * src/LaTeX.C (insertIfExists): Instead of catching all fs exceptions, test for a valid filename before constructing a fs::path. This gets rid of the exceptions because of invalid names, but does still allow other expcetions to be thrown (e.g. because of file system problems). (handleFoundFile): ditto git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17424 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LaTeX.C | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/src/LaTeX.C b/src/LaTeX.C index 6943eb4b9f..2b0dd828e6 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -758,18 +758,14 @@ namespace { bool insertIfExists(FileName const & absname, DepTable & head) { - bool exists; - try { - fs::path const path = absname.toFilesystemEncoding(); - exists = fs::exists(path) && !fs::is_directory(path); - } - catch (fs::filesystem_error const & fe) { - // This was probably no file at all. - lyxerr[Debug::DEPEND] << "Got error `" << fe.what() - << "' while checking whether file `" << absname - << "' exists and is no directory." << endl; + // fs::path may throw an exception if absname is too strange + if (!fs::native(absname.toFilesystemEncoding())) { + lyxerr[Debug::DEPEND] << '`' << absname.absFilename() + << "' is no valid file name." << endl; + return false; } - if (exists) { + fs::path const path(absname.toFilesystemEncoding()); + if (fs::exists(path) && !fs::is_directory(path)) { head.insert(absname, true); return true; } @@ -820,15 +816,13 @@ bool handleFoundFile(string const & ff, DepTable & head) // check for spaces while (contains(foundfile, ' ')) { - bool exists; - try { + // fs::path may throw an exception if absname is too strange + bool exists = fs::native(absname.toFilesystemEncoding()); + if (exists) exists = fs::exists(absname.toFilesystemEncoding()); - } - catch (fs::filesystem_error const & fe) { - // This was probably no file at all. - lyxerr[Debug::DEPEND] << "Got error `" << fe.what() - << "' while checking whether file `" - << absname << "' exists." << endl; + else { + lyxerr[Debug::DEPEND] << '`' << absname.absFilename() + << "' is no valid file name." << endl; } if (exists) // everything o.k. @@ -846,16 +840,14 @@ bool handleFoundFile(string const & ff, DepTable & head) // (2) foundfile is in the tmpdir // insert it into head - bool exists; - try { + // fs::path may throw an exception if absname is too strange + bool exists = fs::native(absname.toFilesystemEncoding()); + if (exists) { fs::path const path = absname.toFilesystemEncoding(); exists = fs::exists(path) && !fs::is_directory(path); - } - catch (fs::filesystem_error const & fe) { - // This was probably no file at all. - lyxerr[Debug::DEPEND] << "Got error `" << fe.what() - << "' while checking whether file `" << absname - << "' exists and is no directory." << endl; + } else { + lyxerr[Debug::DEPEND] << '`' << absname.absFilename() + << "' is no valid file name." << endl; } if (exists) { static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$"); -- 2.39.2