On Sun, Jan 14, 2007 at 03:02:26AM +0100, Enrico Forestieri wrote:

> I attach here a new version of the README.cygwin file intended to
> replace the existing one. I cannot do it, so someone else will have to.

I think that for better compliance with the GPL the patch should be
put alongside the package, so I attach here a revised README.cygwin
file and the patch itself.

-- 
Enrico

PS: I would like to stop here this thread, so I will not reply to any
other follow-up.
The archive lyx-1.4.3-cygwin.tar.gz contains an unofficial cygwin version
of LyX. Here you can find both a native Qt3 GUI version of LyX (no X-server
needed) and an Xforms/X11 binary which maybe preferred by Win98/ME users due
to its low demanding on resources. Please take a look at the included README
for instructions on installing the package. Note that this version of LyX
is patched to use either Windows- or posix-style paths. You can find the
patch in the lyx-1.4.3-cygwin.patch file.

The directory cygwin-package is a repository for the official cygwin
Qt3/X11 version of LyX. You don't need dowloanding the files contained in this
directory (and indeed you shouldn't) in order to install the official cygwin
version of LyX. Instead, you should use the setup.exe cygwin installation
tool, point it to your nearest cygwin mirror and select LyX for installation.
Index: src/frontends/qt2/qfont_loader.C
===================================================================
--- src/frontends/qt2/qfont_loader.C    (revision 15112)
+++ src/frontends/qt2/qfont_loader.C    (working copy)
@@ -102,7 +102,11 @@ void FontLoader::initFontPath()
        for (int i = 0 ; i < num_fonts_truetype ; ++i) {
                string const font_current = 
                        AddName(fonts_dir, win_fonts_truetype[i] + ".ttf");
+#if defined(__CYGWIN__) || defined(__CYGWIN32__)
+               AddFontResource(os::windows_path(font_current).c_str());
+#else
                AddFontResource(os::external_path(font_current).c_str());
+#endif
        }
 #endif
 }
@@ -115,7 +119,11 @@ FontLoader::~FontLoader() {
        for(int i = 0 ; i < num_fonts_truetype ; ++i) {
                string const font_current = 
                        AddName(fonts_dir, win_fonts_truetype[i] + ".ttf");
+#if defined(__CYGWIN__) || defined(__CYGWIN32__)
+               RemoveFontResource(os::windows_path(font_current).c_str());
+#else
                RemoveFontResource(os::external_path(font_current).c_str());
+#endif
        }
 #endif
 }
Index: src/frontends/qt2/FileDialog.C
===================================================================
--- src/frontends/qt2/FileDialog.C      (revision 15112)
+++ src/frontends/qt2/FileDialog.C      (working copy)
@@ -20,6 +20,7 @@
 #include "gettext.h"
 
 #include "support/filefilterlist.h"
+#include "support/os.h"
 
 /** when this is defined, the code will use
  * QFileDialog::getOpenFileName and friends to create filedialogs.
@@ -30,7 +31,7 @@
  *
  * Therefore there is a tradeoff in enabling or disabling this (JMarc)
  */
-#ifdef Q_WS_MACX
+#if defined(Q_WS_MACX) || defined(Q_CYGWIN_WIN)
 #define USE_NATIVE_FILEDIALOG 1
 #endif
 
@@ -42,6 +43,8 @@ using lyx::support::MakeAbsPath;
 
 using lyx::support::FileFilterList;
 
+using lyx::support::os::internal_path;
+
 using std::endl;
 using std::string;
 
@@ -80,11 +83,11 @@ FileDialog::Result const FileDialog::sav
 
 #ifdef USE_NATIVE_FILEDIALOG
        string const startsWith = MakeAbsPath(suggested, path);
-       result.second = fromqstr(
+       result.second = internal_path(fromqstr(
                QFileDialog::getSaveFileName(toqstr(startsWith),
                                             toqstr(filters.as_string()),
                                             qApp->focusWidget() ? 
qApp->focusWidget() : qApp->mainWidget(),
-                                            title_.c_str()));
+                                            title_.c_str())));
 #else
        LyXFileDialog dlg(path, filters, title_, private_->b1, private_->b2);
        dlg.setMode(QFileDialog::AnyFile);
@@ -96,7 +99,7 @@ FileDialog::Result const FileDialog::sav
        int res = dlg.exec();
        lyxerr[Debug::GUI] << "result " << res << endl;
        if (res == QDialog::Accepted)
-               result.second = fromqstr(dlg.selectedFile());
+               result.second = internal_path(fromqstr(dlg.selectedFile()));
        dlg.hide();
 #endif
        return result;
@@ -115,11 +118,11 @@ FileDialog::Result const FileDialog::ope
 
 #ifdef USE_NATIVE_FILEDIALOG
        string const startsWith = MakeAbsPath(suggested, path);
-       result.second = fromqstr(
+       result.second = internal_path(fromqstr(
                QFileDialog::getOpenFileName(toqstr(startsWith),
                                             toqstr(filters.as_string()),
                                             qApp->focusWidget() ? 
qApp->focusWidget() : qApp->mainWidget(),
-                                            title_.c_str()));
+                                            title_.c_str())));
 #else
        LyXFileDialog dlg(path, filters, title_, private_->b1, private_->b2);
 
@@ -130,7 +133,7 @@ FileDialog::Result const FileDialog::ope
        int res = dlg.exec();
        lyxerr[Debug::GUI] << "result " << res << endl;
        if (res == QDialog::Accepted)
-               result.second = fromqstr(dlg.selectedFile());
+               result.second = internal_path(fromqstr(dlg.selectedFile()));
        dlg.hide();
 #endif
        return result;
@@ -147,10 +150,10 @@ FileDialog::Result const FileDialog::ope
 
 #ifdef USE_NATIVE_FILEDIALOG
        string const startsWith = MakeAbsPath(suggested, path);
-       result.second = fromqstr(
+       result.second = internal_path(fromqstr(
                QFileDialog::getExistingDirectory(toqstr(startsWith),
                                                  qApp->focusWidget() ? 
qApp->focusWidget() : qApp->mainWidget(),
-                                                 title_.c_str()));
+                                                 title_.c_str())));
 #else
        FileFilterList const filter(_("Directories"));
 
@@ -165,7 +168,7 @@ FileDialog::Result const FileDialog::ope
        int res = dlg.exec();
        lyxerr[Debug::GUI] << "result " << res << endl;
        if (res == QDialog::Accepted)
-               result.second = fromqstr(dlg.selectedFile());
+               result.second = internal_path(fromqstr(dlg.selectedFile()));
        dlg.hide();
 #endif
        return result;
Index: src/support/os.h
===================================================================
--- src/support/os.h    (revision 15112)
+++ src/support/os.h    (working copy)
@@ -53,6 +53,14 @@ std::string external_path_list(std::stri
 /// Converts a host OS style path list to unix style.
 std::string internal_path_list(std::string const & p);
 
+#if defined(__CYGWIN__) || defined(__CYGWIN32__)
+/// Converts whatever path style to unix style.
+std::string posix_path(std::string const & p);
+
+/// Converts whatever path style to windows style.
+std::string windows_path(std::string const & p);
+#endif
+
 /**
  * Converts a unix style path into a form suitable for inclusion in a LaTeX
  * document.
Index: src/support/os_cygwin.C
===================================================================
--- src/support/os_cygwin.C     (revision 15112)
+++ src/support/os_cygwin.C     (working copy)
@@ -40,6 +40,7 @@ namespace os {
 namespace {
 
 bool windows_style_tex_paths_ = false;
+bool windows_style_lyx_paths_ = false;
 
 // In both is_posix_path() and is_windows_path() it is assumed that
 // a valid posix or pseudo-windows path is passed. They simply tell
@@ -132,25 +133,20 @@ void os::init(int, char *[])
 
                if (var == "TEMP")
                        temp_seen = true;
+
+               if (var == "LYX_WINPATHS" && (val == "true" || val == "yes"))
+                       windows_style_lyx_paths_ = true;
                
                if (GetEnvironmentVariable(var.c_str(), curval, 2) == 0
                                && GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
                        /* Convert to Windows style where necessary */
                        if (var == "PATH" || var == "LD_LIBRARY_PATH") {
-                               string const winpathlist =
-                                   convert_path_list(val, PathStyle(windows));
-                               if (!winpathlist.empty()) {
-                                       SetEnvironmentVariable(var.c_str(),
-                                               winpathlist.c_str());
-                               }
+                               val = convert_path_list(val, 
PathStyle(windows));
                        } else if (var == "HOME" || var == "TMPDIR" ||
                                        var == "TMP" || var == "TEMP") {
-                               string const winpath =
-                                       convert_path(val, PathStyle(windows));
-                               SetEnvironmentVariable(var.c_str(), 
winpath.c_str());
-                       } else {
-                               SetEnvironmentVariable(var.c_str(), 
val.c_str());
+                               val = convert_path(val, PathStyle(windows));
                        }
+                       SetEnvironmentVariable(var.c_str(), val.c_str());
                }
        }
        if (!temp_seen) {
@@ -186,29 +182,36 @@ string::size_type common_path(string con
 }
 
 
-string external_path(string const & p)
+string windows_path(string const & p)
 {
-#ifdef X_DISPLAY_MISSING
        return convert_path(p, PathStyle(windows));
-#else
+}
+
+
+string posix_path(string const & p)
+{
        return convert_path(p, PathStyle(posix));
-#endif
 }
 
 
 string internal_path(string const & p)
 {
-       return convert_path(p, PathStyle(posix));
+       return convert_path(p, windows_style_lyx_paths_ ? PathStyle(windows)
+                                                      : PathStyle(posix));
+}
+
+
+string external_path(string const & p)
+{
+       return convert_path(p, windows_style_lyx_paths_ ? PathStyle(windows)
+                                                      : PathStyle(posix));
 }
 
 
 string external_path_list(string const & p)
 {
-#ifdef X_DISPLAY_MISSING
-       return convert_path_list(p, PathStyle(windows));
-#else
-       return convert_path_list(p, PathStyle(posix));
-#endif
+       return convert_path_list(p, windows_style_lyx_paths_ ?
+                                       PathStyle(windows) : PathStyle(posix));
 }
 
 
@@ -224,16 +227,18 @@ string latex_path(string const & p)
        // on windows_style_tex_paths_), but we use always forward slashes,
        // since it gets written into a .tex file.
 
-       if (windows_style_tex_paths_ && is_absolute_path(p)) {
-               string dos_path = convert_path(p, PathStyle(windows));
-               lyxerr[Debug::LATEX]
-                       << "<Path correction for LaTeX> ["
-                       << p << "]->>["
-                       << dos_path << ']' << endl;
-               return dos_path;
+       if (is_absolute_path(p)) {
+               string const tex_path = convert_path(p, 
windows_style_tex_paths_ ?
+                                       PathStyle(windows) : PathStyle(posix));
+               if (tex_path != p) {
+                       lyxerr[Debug::LATEX]
+                               << "<Path correction for LaTeX> ["
+                               << p << "]->>["
+                               << tex_path << ']' << endl;
+                       return tex_path;
+               }
        }
-
-       return convert_path(p, PathStyle(posix));
+       return p;
 }
 
 
Index: src/support/environment.C
===================================================================
--- src/support/environment.C   (revision 15112)
+++ src/support/environment.C   (working copy)
@@ -99,7 +99,7 @@ void setEnvPath(string const & name, vec
                // On cygwin, os::external_path returns either posix or
                // pseudo-win style paths, but here we always need posix style.
                // This fixes bug 2344.
-               ss << os::internal_path(*it);
+               ss << os::posix_path(*it);
 #else
                ss << os::external_path(*it);
 #endif
Index: src/support/package.C.in
===================================================================
--- src/support/package.C.in    (revision 15112)
+++ src/support/package.C.in    (working copy)
@@ -171,20 +171,20 @@ namespace {
 // configuration-time.
 string const top_srcdir()
 {
-       static string const dir("%TOP_SRCDIR%");
+       static string const dir = os::internal_path("%TOP_SRCDIR%");
        return dir;
 }
 
 
 string const hardcoded_localedir()
 {
-       return string("%LOCALEDIR%");
+       return os::internal_path("%LOCALEDIR%");
 }
 
 
 string const hardcoded_system_support_dir()
 {
-       return string("%LYX_DIR%");
+       return os::internal_path("%LYX_DIR%");
 }
 
 
@@ -201,7 +201,7 @@ string const & with_version_suffix()
 
 string const & Package::top_srcdir() const
 {
-       static string const dir("%TOP_SRCDIR%");
+       static string const dir = os::internal_path("%TOP_SRCDIR%");
        return dir;
 }
 
@@ -361,7 +361,7 @@ string const get_temp_dir()
        GetTempPath(MAX_PATH, path);
        return os::internal_path(path);
 #else // Posix-like.
-       return "/tmp";
+       return os::internal_path("/tmp");
 #endif
 }
 
Index: src/messages.C
===================================================================
--- src/messages.C      (revision 15112)
+++ src/messages.C      (working copy)
@@ -14,6 +14,9 @@
 #include "support/filetools.h"
 #include "support/environment.h"
 #include "support/package.h"
+#ifdef __CYGWIN__
+#include "support/os.h"
+#endif
 
 #include <boost/current_function.hpp>
 #include <boost/regex.hpp>
@@ -24,6 +27,10 @@ using lyx::support::package;
 using lyx::support::getEnv;
 using lyx::support::setEnv;
 
+#ifdef __CYGWIN__
+using lyx::support::os::posix_path;
+#endif
+
 using std::string;
 
 
@@ -142,7 +149,12 @@ public:
 
                setlocale(LC_CTYPE, lang_.c_str());
                errno = 0;
+#ifdef __CYGWIN__
+               string const locale_dir = posix_path(package().locale_dir());
+               char const * c = bindtextdomain(PACKAGE, locale_dir.c_str());
+#else
                char const * c = bindtextdomain(PACKAGE, 
package().locale_dir().c_str());
+#endif
                int e = errno;
                if (e) {
                        lyxerr[Debug::DEBUG]

Reply via email to