Am Donnerstag, 23. März 2006 21:26 schrieb Enrico Forestieri: > Your theory is right and I wasn't fearless enough, not having the time > to study the code. So, the attached is apparently the right fix. While > testing this patch I run up against another bug. > > 1) File->New > 2) Insert->File->Child Document (say we input ~/test.tex) > 3) File->Export->LaTeX > > LyX pops up a dialog telling me that ~/test.tex already exists and > asking for overwriting it. I say yes, overwrite it, but newfile1.lyx > is normally created and ~/test.tex is not overwritten. This is > independent from the fact that the buffer has been given a name or not. > This also happens on Solaris and I could not find a similar bug > reported in bugzilla.
I will have a look. > Uhm, I don't think so. The code after "else return p;" gets executed when > the previous if() clause is satisfied. Oh yes, you are right. > Many thanks for your helpful and appreciated comments. I hope they are not too disappointing :-) Unfortunately I have another one: > Index: src/support/filetools.C > =================================================================== > --- src/support/filetools.C (revision 13463) > +++ src/support/filetools.C (working copy) > @@ -86,7 +86,9 @@ string const latex_path(string const & o > latex_path_extension extension, > latex_path_dots dots) > { > - string path = subst(original_path, "\\", "/"); > + // The call to os::external_path is only needed for Cygwin. > + string path = subst(os::external_path(original_path), "\\", "/"); Here you basically revert external_path on non-cygwin windows. This is a bit ugly, so I moved this into a new function lyx::support::os::latex_path(). This is a noop except on cygwin, where it is identical to external_path(). Shall I put this in? Georg
Index: src/support/os_unix.C =================================================================== --- src/support/os_unix.C (Revision 13467) +++ src/support/os_unix.C (Arbeitskopie) @@ -63,6 +63,12 @@ string internal_path(string const & p) } +string latex_path(string const & p) +{ + return p; +} + + bool is_absolute_path(string const & p) { return !p.empty() && p[0] == '/'; Index: src/support/os.h =================================================================== --- src/support/os.h (Revision 13467) +++ src/support/os.h (Arbeitskopie) @@ -47,6 +47,14 @@ std::string external_path(std::string co /// Converts a host OS style path to unix style. std::string internal_path(std::string const & p); +/** + * Converts a unix style path into a form suitable for inclusion in a LaTeX + * document. + * Caution: This function handles only the OS specific part of that task. + * Never use it directly, use lyx::support::latex_path instead. + */ +std::string latex_path(std::string const & p); + /// Is the path absolute? bool is_absolute_path(std::string const & p); Index: src/support/filetools.C =================================================================== --- src/support/filetools.C (Revision 13467) +++ src/support/filetools.C (Arbeitskopie) @@ -87,6 +87,8 @@ string const latex_path(string const & o latex_path_dots dots) { string path = subst(original_path, "\\", "/"); + // On cygwin, we may need windows or posix style paths. + path = os::latex_path(path); path = subst(path, "~", "\\string~"); if (path.find(' ') != string::npos) { // We can't use '"' because " is sometimes active (e.g. if Index: src/support/os_win32.C =================================================================== --- src/support/os_win32.C (Revision 13467) +++ src/support/os_win32.C (Arbeitskopie) @@ -216,6 +216,12 @@ string internal_path(string const & p) } +string latex_path(string const & p) +{ + return p; +} + + // (Claus H.) On Win32 both Unix and Win32/DOS pathnames are used. // Therefore an absolute path could be either a pathname starting // with a slash (Unix) or a pathname starting with a drive letter Index: src/support/os_cygwin.C =================================================================== --- src/support/os_cygwin.C (Revision 13467) +++ src/support/os_cygwin.C (Arbeitskopie) @@ -102,6 +102,15 @@ string internal_path(string const & p) } +string latex_path(string const & p) +{ + // We may need a posix style path or a windows style path (depending + // on cygwin_path_fix_), but we use always forward slashes, since it + // gets written into a .tex file. + return external_path(p); +} + + bool is_absolute_path(string const & p) { if (p.empty())