Jean-Marc Lasgouttes wrote: > What I would do is: > > 1/take the name up to the first space. If it is a known file name, > stop there > > 2/ add the token up to next space; if the file exists stop, otherwise, > go back to 2/. > > This is getting a bit too complicated for my taste, but it should > work. Of course, what is missing here is a stopping condition, > probably str.length() < MAX_PATH.
This looks complicated indeed. How about the other way round? Strikes me easier. Have a look at the attached patch. Jürgen
Index: src/LaTeX.C =================================================================== --- src/LaTeX.C (Revision 17164) +++ src/LaTeX.C (Arbeitskopie) @@ -49,6 +49,7 @@ using support::quoteName; using support::removeExtension; using support::rtrim; +using support::rsplit; using support::split; using support::subst; using support::suffixIs; @@ -725,7 +726,7 @@ void handleFoundFile(string const & ff, DepTable & head) { // convert from native os path to unix path - string const foundfile = os::internal_path(trim(ff)); + string foundfile = os::internal_path(trim(ff)); lyxerr[Debug::DEPEND] << "Found file: " << foundfile << endl; @@ -752,9 +753,24 @@ return; } - string const onlyfile = onlyFilename(foundfile); - FileName const absname(makeAbsPath(onlyfile)); + string onlyfile = onlyFilename(foundfile); + FileName absname(makeAbsPath(onlyfile)); + // check for spaces + while (contains(foundfile, " ")) { + if (fs::exists(absname.toFilesystemEncoding())) + // everything o.k. + break; + else { + // strip off part after last space and try again + string strippedfile; + string const stripoff = rsplit(foundfile, strippedfile, ' '); + foundfile = strippedfile; + onlyfile = onlyFilename(strippedfile); + absname = makeAbsPath(onlyfile); + } + } + // (2) foundfile is in the tmpdir // insert it into head if (fs::exists(absname.toFilesystemEncoding())) { @@ -846,9 +863,8 @@ token = to_utf8(from_filesystem8bit(token)); if (regex_match(token, sub, reg1)) { - // search for strings in (...) that must not contain - // a blank, but must contain a dot - static regex reg1_1("\\(([^()]+\\.+[^ ()]+)"); + // search for strings in (...) that must contain a dot + static regex reg1_1("\\(([^()]+\\.[^()]+)"); smatch what; string::const_iterator first = token.begin(); string::const_iterator end = token.end();