Here is a minimal patch for cygwin. It fixes bug 2344 and the following two bugs:
- Export to latex fails when cygwin_path_fix is true, because prefixIs(p1,p2) in copyFile() fails to recognize that p2 is prefix of p1 when they are in different styles. - When a file is exported to latex and the extension is to be omitted, the file gets written in the .tex file in posix syntax, such that miktex will not be able to find it. These bugs are a result of the mess caused by letting cygwin_path_fix control both the style of the paths to be written in .tex files and to be used externally. Note that this is a "dirty" patch, in the sense that it do not solve the problem that the paths used internally by LyX are still partly in posix style and partly in pseudo-win32 style when cygwin_path_fix is true. The correct fix to this problem is my other patch in the thread "Cygwin polishing", which however, I admit tries to solve too much things in a single shot. -- Enrico
Index: src/bufferlist.C =================================================================== --- src/bufferlist.C (revision 13538) +++ src/bufferlist.C (working copy) @@ -28,6 +28,7 @@ #include "support/filetools.h" #include "support/package.h" +#include "support/os.h" #include <boost/bind.hpp> @@ -43,6 +44,8 @@ using lyx::support::removeAutosaveFile; using lyx::support::package; using lyx::support::prefixIs; +using lyx::support::os::internal_path; + using boost::bind; using std::auto_ptr; @@ -380,8 +383,11 @@ Buffer * BufferList::getBufferFromTmp(st { BufferStorage::iterator it = bstore.begin(); BufferStorage::iterator end = bstore.end(); + // On cygwin it is currently a mess: when cygwin_path_fix_ is true, + // some paths are in pseudo-win32 style, some other in posix style. + // So, we must make sure that both paths are in the same style. for (; it < end; ++it) - if (prefixIs(s, (*it)->temppath())) + if (prefixIs(internal_path(s), (*it)->temppath())) return *it; return 0; } Index: src/ChangeLog =================================================================== --- src/ChangeLog (revision 13538) +++ src/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2006-03-31 Enrico Forestieri <[EMAIL PROTECTED]> + * bufferlist.C (getBufferFromTmp): + * exporter.C (copyFile): Fix problem with paths as on cygwin they + maybe of different type (posix vs pseudo-windows). + 2006-03-16 Jürgen Spitzmüller <[EMAIL PROTECTED]> * text.C (delete): adjust cursor after backspace in change tracking Index: src/exporter.C =================================================================== --- src/exporter.C (revision 13538) +++ src/exporter.C (working copy) @@ -33,6 +33,7 @@ #include "support/filetools.h" #include "support/lyxlib.h" #include "support/package.h" +#include "support/os.h" #include <boost/filesystem/operations.hpp> @@ -47,6 +48,8 @@ using lyx::support::OnlyPath; using lyx::support::package; using lyx::support::prefixIs; +using lyx::support::os::internal_path; + using std::find; using std::string; using std::vector; @@ -111,7 +114,10 @@ CopyStatus copyFile(string const & forma // overwrite themselves. This check could be changed to // boost::filesystem::equivalent(sourceFile, destFile) if export to // other directories than the document directory is desired. - if (!prefixIs(OnlyPath(sourceFile), package().temp_dir())) + // On cygwin it is currently a mess: when cygwin_path_fix_ is true, + // some paths are in pseudo-win32 style, some other in posix style. + // So, we must make sure that both paths are in the same style. + if (!prefixIs(OnlyPath(internal_path(sourceFile)), package().temp_dir())) return ret; if (!force) { Index: src/support/os_unix.C =================================================================== --- src/support/os_unix.C (revision 13538) +++ src/support/os_unix.C (working copy) @@ -57,7 +57,7 @@ string external_path(string const & p) } -string internal_path(string const & p) +string internal_path(string const & p, path_target) { return p; } Index: src/support/os.h =================================================================== --- src/support/os.h (revision 13538) +++ src/support/os.h (working copy) @@ -26,6 +26,11 @@ enum shell_type { CMD_EXE }; +enum path_target { + DEFAULT, + LATEX +}; + /// Do some work just once. void init(int argc, char * argv[]); @@ -45,7 +50,7 @@ std::string::size_type common_path(std:: std::string external_path(std::string const & p); /// Converts a host OS style path to unix style. -std::string internal_path(std::string const & p); +std::string internal_path(std::string const & p, path_target target = DEFAULT); /** * Converts a unix style path into a form suitable for inclusion in a LaTeX Index: src/support/filetools.C =================================================================== --- src/support/filetools.C (revision 13538) +++ src/support/filetools.C (working copy) @@ -86,9 +86,8 @@ string const latex_path(string const & o latex_path_extension extension, latex_path_dots dots) { - string path = subst(original_path, "\\", "/"); // On cygwin, we may need windows or posix style paths. - path = os::latex_path(path); + string path = os::latex_path(original_path); path = subst(path, "~", "\\string~"); if (path.find(' ') != string::npos) { // We can't use '"' because " is sometimes active (e.g. if @@ -740,7 +739,7 @@ string const ChangeExtension(string cons else ext = extension; - return os::internal_path(oldname.substr(0, last_dot) + ext); + return os::internal_path(oldname.substr(0, last_dot) + ext, os::LATEX); } Index: src/support/os_win32.C =================================================================== --- src/support/os_win32.C (revision 13538) +++ src/support/os_win32.C (working copy) @@ -210,7 +210,7 @@ string const get_long_path(string const } // namespace anon -string internal_path(string const & p) +string internal_path(string const & p, path_target) { return subst(get_long_path(p), "\\", "/"); } @@ -218,7 +218,7 @@ string internal_path(string const & p) string latex_path(string const & p) { - return p; + return subst(p, '\\', '/'); } Index: src/support/ChangeLog =================================================================== --- src/support/ChangeLog (revision 13538) +++ src/support/ChangeLog (working copy) @@ -1,3 +1,15 @@ +2006-03-31 Enrico Forestieri <[EMAIL PROTECTED]> + * os.h: Added enum path_target, modified internal_path declaration + * os_unix.C (internal_path): Added argument path_target + * os_win32.C (internal_path, latex_path): Added argument path_target + to internal_path, updated latex_path. + * os_cygwin.C (internal_path): return an appropriate path style + based on path_target. + * environment.C: fix bug 2344: Wrong path_prefix handling in + cygwin builds + * filetools.C (latex_path, ChangeExtension): fix for the path + style to be written in .tex files (cygwin related). + 2006-03-15 Georg Baum <[EMAIL PROTECTED]> * filename.C (mangledFilename): truncate filename to 140 characters Index: src/support/os_cygwin.C =================================================================== --- src/support/os_cygwin.C (revision 13538) +++ src/support/os_cygwin.C (working copy) @@ -93,8 +93,11 @@ string external_path(string const & p) } -string internal_path(string const & p) +string internal_path(string const & p, path_target target) { + if (target == LATEX) + return latex_path(p); + char posix_path[PATH_MAX]; posix_path[0] = '\0'; cygwin_conv_to_posix_path(p.c_str(), posix_path); Index: src/support/environment.C =================================================================== --- src/support/environment.C (revision 13538) +++ src/support/environment.C (working copy) @@ -95,7 +95,12 @@ void setEnvPath(string const & name, vec for (; it != end; ++it) { if (it != begin) ss << separator; +#if defined(__CYGWIN__) || defined(__CYGWIN32__) + // Fix for bug 2344 on cygwin. + ss << os::internal_path(*it); +#else ss << os::external_path(*it); +#endif } setEnv(name, ss.str()); }