On Fri, Apr 28, 2006 at 06:43:14PM +0000, Luis Rivera wrote:

> AFAIK, LyX still works on Win95/Cygwin (on an Intel486!).  Slow as anything 
> can 
> be, but works.  On Win98 it greatly improves, thanks to the hardware. The 
> real 
> mess seems to be the path handling.  On Cygwin everything is normal POSIX, so 
> LyX doesn't complain; while Windows... well, you know, is Windows ;-)

Cygwin runs on top of Windows. It works because it is developed by
competent people which know how to deal with various Windows flavors.

The path handling is not a mess in my copy of LyX, perhaps it is
in the official sources. Attached you can find a patch for 1.4.x
letting you use a Cygwin LyX as a native application with respect
to paths. I have been using it for two months now and it works
without a glitch. I also attach a script for configuring LyX.
After extracting the LyX sources go to the top srcdir and do
(notice the dot)

lyxconfig-x11 .

When the script finishes do

cd build-x11
make
make install

Obviously you need a cygwin installation and the development tools.

If you want to try a Cygwin LyX without X11, please have a look at
http://wiki.lyx.org/LyX/LyXOnCygwin

However, I am not sure that it will work on Win98 as it uses Qt/Win
without the cygwin parachute.

If you do not want have trouble compiling it, then you could try
ftp://ftp.lyx.org/pub/lyx/bin/1.4.1/lyx-1.4.1-cygwin.tar.gz

wehere you can find both LyX/Win and LyX/X11. Be warned that the
patch for native path styles is not applied to this copy, though.

-- 
Enrico
Index: src/lyxfunc.C
===================================================================
--- src/lyxfunc.C       (revision 13782)
+++ src/lyxfunc.C       (working copy)
@@ -1977,6 +1977,11 @@ void actOnUpdatedPrefs(LyXRC const & lyx
                        namespace os = lyx::support::os;
                        os::cygwin_path_fix(lyxrc_new.cygwin_path_fix);
                }
+       case LyXRC::RC_CYGWIN_STYLE_PATHS:
+               if (lyxrc_orig.cygwin_style_paths != 
lyxrc_new.cygwin_style_paths) {
+                       namespace os = lyx::support::os;
+                       os::cygwin_style_paths(lyxrc_new.cygwin_style_paths);
+               }
        case LyXRC::RC_DATE_INSERT_FORMAT:
        case LyXRC::RC_DEFAULT_LANGUAGE:
        case LyXRC::RC_DEFAULT_PAPERSIZE:
Index: src/frontends/qt2/QPrefs.C
===================================================================
--- src/frontends/qt2/QPrefs.C  (revision 13782)
+++ src/frontends/qt2/QPrefs.C  (working copy)
@@ -204,7 +204,7 @@ void QPrefs::apply()
 
 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
        QPrefCygwinPathModule * cygwinmod(dialog_->cygwinpathModule);
-       rc.cygwin_path_fix = !cygwinmod->pathCB->isChecked();
+       rc.cygwin_style_paths = cygwinmod->pathCB->isChecked();
 #endif
 
        QPrefLatexModule * latexmod(dialog_->latexModule);
@@ -546,7 +546,7 @@ void QPrefs::update_contents()
 
 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
        QPrefCygwinPathModule * cygwinmod(dialog_->cygwinpathModule);
-       cygwinmod->pathCB->setChecked(!rc.cygwin_path_fix);
+       cygwinmod->pathCB->setChecked(rc.cygwin_style_paths);
 #endif
 
        QPrefLatexModule * latexmod(dialog_->latexModule);
Index: src/frontends/qt2/FileDialog.C
===================================================================
--- src/frontends/qt2/FileDialog.C      (revision 13782)
+++ 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/frontends/xforms/FormPreferences.C
===================================================================
--- src/frontends/xforms/FormPreferences.C      (revision 13782)
+++ src/frontends/xforms/FormPreferences.C      (working copy)
@@ -2074,7 +2074,7 @@ void FormPreferences::OutputsMisc::apply
        rc.auto_reset_options = 
fl_get_button(dialog_->check_autoreset_classopt);
 
 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
-       rc.cygwin_path_fix = fl_get_button(dialog_->check_cygwin_path);
+        rc.cygwin_style_paths = fl_get_button(dialog_->check_cygwin_path);
 #endif
 }
 
@@ -2143,9 +2143,10 @@ FormPreferences::OutputsMisc::feedback(F
        if (ob == dialog_->check_cygwin_path)
                return _("Select if LyX should output Cygwin-style paths "
                         "rather than Windows-style paths. Useful if you're "
-                        "using the Cygwin teTeX rather than a native Windows "
-                        "MikTeX. Note, however, that you'll need to write "
-                        "shell script wrappers for all your converters.");
+                        "using Cygwin rather than native Windows programs. "
+                        "Note that if you use both Cygwin and native programs "
+                        "at the same time, you may need to write shell "
+                        "script wrappers for some of your converters.");
 #endif
        return string();
 }
@@ -2172,7 +2173,7 @@ void FormPreferences::OutputsMisc::updat
        fl_set_button(dialog_->check_autoreset_classopt,
                      rc.auto_reset_options);
 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
-       fl_set_button(dialog_->check_cygwin_path, rc.cygwin_path_fix);
+       fl_set_button(dialog_->check_cygwin_path, rc.cygwin_style_paths);
 #endif
 }
 
Index: src/support/os_unix.C
===================================================================
--- src/support/os_unix.C       (revision 13782)
+++ src/support/os_unix.C       (working copy)
@@ -115,6 +115,10 @@ char path_separator()
 void cygwin_path_fix(bool)
 {}
 
+
+void cygwin_style_paths(bool)
+{}
+
 } // namespace os
 } // namespace support
 } // namespace lyx
Index: src/support/os.h
===================================================================
--- src/support/os.h    (revision 13782)
+++ src/support/os.h    (working copy)
@@ -74,11 +74,30 @@ char const * popen_read_mode();
  */
 char path_separator();
 
+/** If @c fix_cygwin_paths is true, LyX will output cygwin style paths
+ *  rather than native Win32 ones in latex files. Obviously, this option
+ *  is used only under Cygwin.
+ */
+void cygwin_path_fix(bool fix_cygwin_paths);
+
 /** If @c use_cygwin_paths is true, LyX will output cygwin style paths
  *  rather than native Win32 ones. Obviously, this option is used only
  *  under Cygwin.
  */
-void cygwin_path_fix(bool use_cygwin_paths);
+void cygwin_style_paths(bool use_cygwin_paths);
+
+#if defined(__CYGWIN__) || defined(__CYGWIN32__)
+enum PathStyle {
+       posix,
+       windows
+};
+
+/// Converts a path to a target style.
+std::string convert_path(std::string const & p, PathStyle const & target);
+
+/// Converts a path list to a target style.
+std::string convert_path_list(std::string const & p, PathStyle const & target);
+#endif
 
 } // namespace os
 } // namespace support
Index: src/support/os_win32.C
===================================================================
--- src/support/os_win32.C      (revision 13782)
+++ src/support/os_win32.C      (working copy)
@@ -283,6 +283,10 @@ void cygwin_path_fix(bool)
 {}
 
 
+void cygwin_style_paths(bool)
+{}
+
+
 namespace {
 
 void bail_out()
Index: src/support/os_cygwin.C
===================================================================
--- src/support/os_cygwin.C     (revision 13782)
+++ src/support/os_cygwin.C     (working copy)
@@ -67,6 +67,7 @@ string::size_type common_path(string con
 namespace {
 
 bool cygwin_path_fix_ = false;
+bool cygwin_style_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
@@ -86,11 +87,7 @@ bool is_windows_path(string const & p)
                (!contains(p, '\\') && (p.length() <= 1 || p[1] == ':'));
 }
 
-
-enum PathStyle {
-    posix,
-    windows
-};
+} // namespace anon
 
 
 string convert_path(string const & p, PathStyle const & target)
@@ -139,26 +136,24 @@ string convert_path_list(string const & 
        return subst(p, '\\', '/');
 }
 
-} // namespace anon
-
 
 string external_path(string const & p)
 {
-       return convert_path(p, cygwin_path_fix_ ? PathStyle(windows)
-                                               : PathStyle(posix));
+       return internal_path(p);
 }
 
 
 string internal_path(string const & p)
 {
-       return convert_path(p, PathStyle(posix));
+       return convert_path(p, cygwin_style_paths_ ? PathStyle(posix)
+                                                  : PathStyle(windows));
 }
 
 
 string external_path_list(string const & p)
 {
-       return convert_path_list(p, cygwin_path_fix_ ? PathStyle(windows)
-                                                    : PathStyle(posix));
+       return convert_path_list(p, cygwin_style_paths_ ? PathStyle(posix)
+                                                       : PathStyle(windows));
 }
 
 
@@ -174,16 +169,11 @@ string latex_path(string const & p)
        // on cygwin_path_fix_), but we use always forward slashes, since it
        // gets written into a .tex file.
 
-       if (cygwin_path_fix_ && is_absolute_path(p)) {
-               string dos_path = convert_path(p, PathStyle(windows));
-               lyxerr[Debug::LATEX]
-                       << "<Cygwin path correction> ["
-                       << p << "]->>["
-                       << dos_path << ']' << endl;
-               return dos_path;
-       }
+       if (is_absolute_path(p))
+               return convert_path(p, cygwin_path_fix_ ? PathStyle(windows)
+                                                       : PathStyle(posix));
 
-       return convert_path(p, PathStyle(posix));
+       return p;
 }
 
 
@@ -226,9 +216,15 @@ char path_separator()
 }
 
 
-void cygwin_path_fix(bool use_cygwin_paths)
+void cygwin_path_fix(bool fix_cygwin_paths)
+{
+       cygwin_path_fix_ = fix_cygwin_paths;
+}
+
+
+void cygwin_style_paths(bool use_cygwin_paths)
 {
-       cygwin_path_fix_ = use_cygwin_paths;
+       cygwin_style_paths_ = use_cygwin_paths;
 }
 
 } // namespace os
Index: src/support/environment.C
===================================================================
--- src/support/environment.C   (revision 13782)
+++ 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::convert_path(*it, os::posix);
 #else
                ss << os::external_path(*it);
 #endif
Index: src/support/package.C.in
===================================================================
--- src/support/package.C.in    (revision 13782)
+++ src/support/package.C.in    (working copy)
@@ -361,7 +361,7 @@ string const get_temp_dir()
        GetTempPath(PATH_MAX, path);
        return os::internal_path(path);
 #else // Posix-like.
-       return "/tmp";
+       return os::internal_path("/tmp");
 #endif
 }
 
Index: src/lyxrc.C
===================================================================
--- src/lyxrc.C (revision 13782)
+++ src/lyxrc.C (working copy)
@@ -81,6 +81,7 @@ keyword_item lyxrcTags[] = {
        { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
        { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
        { "\\cygwin_path_fix_needed", LyXRC::RC_CYGWIN_PATH_FIX },
+       { "\\cygwin_style_paths", LyXRC::RC_CYGWIN_STYLE_PATHS },
        { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
        { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
        { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
@@ -271,6 +272,7 @@ void LyXRC::setDefaults() {
        default_language = "english";
        show_banner = true;
        cygwin_path_fix = false;
+       cygwin_style_paths = false;
        tex_allows_spaces = false;
        date_insert_format = "%A, %e %B %Y";
        cursor_follows_scrollbar = false;
@@ -394,6 +396,12 @@ int LyXRC::read(LyXLex & lexrc)
                        }
                        break;
 
+               case RC_CYGWIN_STYLE_PATHS:
+                       if (lexrc.next()) {
+                               cygwin_style_paths = lexrc.getBool();
+                       }
+                       break;
+
                case RC_TEX_ALLOWS_SPACES:
                        if (lexrc.next()) {
                                tex_allows_spaces = lexrc.getBool();
@@ -1342,6 +1350,12 @@ void LyXRC::write(ostream & os, bool ign
                        os << "\\cygwin_path_fix_needed "
                           << convert<string>(cygwin_path_fix) << '\n';
                }
+       case RC_CYGWIN_STYLE_PATHS:
+               if (ignore_system_lyxrc ||
+                   cygwin_style_paths != system_lyxrc.cygwin_style_paths) {
+                       os << "\\cygwin_style_paths "
+                          << convert<string>(cygwin_style_paths) << '\n';
+               }
        case RC_TEX_ALLOWS_SPACES:
                if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
                        os << "\\tex_allows_spaces "
@@ -2137,6 +2151,9 @@ string const LyXRC::getDescription(LyXRC
                break;
 
        case RC_CYGWIN_PATH_FIX:
+               break;
+
+       case RC_CYGWIN_STYLE_PATHS:
                break;
 
        case RC_DATE_INSERT_FORMAT:
Index: src/lyxrc.h
===================================================================
--- src/lyxrc.h (revision 13782)
+++ src/lyxrc.h (working copy)
@@ -52,6 +52,7 @@ public:
                RC_CUSTOM_EXPORT_COMMAND,
                RC_CUSTOM_EXPORT_FORMAT,
                RC_CYGWIN_PATH_FIX,
+               RC_CYGWIN_STYLE_PATHS,
                RC_DATE_INSERT_FORMAT,
                RC_DEFAULT_LANGUAGE,
                RC_DEFAULT_PAPERSIZE,
@@ -376,8 +377,10 @@ public:
        std::string user_name;
        /// user email
        std::string user_email;
-       ///
+       /// True if the TeX engine needs pseudo-windows style paths
        bool cygwin_path_fix;
+       /// True if LyX should output posix style paths on cygwin
+       bool cygwin_style_paths;
        /// True if the TeX engine can handle file names containing spaces
        bool tex_allows_spaces;
        /** Prepend paths to the PATH environment variable.
Index: src/lyx_main.C
===================================================================
--- src/lyx_main.C      (revision 13782)
+++ src/lyx_main.C      (working copy)
@@ -472,6 +472,7 @@ void LyX::init(bool gui)
                lyxrc.print();
 
        os::cygwin_path_fix(lyxrc.cygwin_path_fix);
+       os::cygwin_style_paths(lyxrc.cygwin_style_paths);
        if (!lyxrc.path_prefix.empty())
                prependEnvPath("PATH", lyxrc.path_prefix);
 
#! /bin/sh

# Configuration of the LyX sources suitable for compilation
# of a X11 build using the cygwin compiler.

# author Angus Leeming, modified by Enrico Forestieri

Error () {
    test $# -gt 0 && {
        echo $* >&2
        echo >&2
    }

    echo "Expecting \"`basename $0` dir [buildtype]\"" >&2
    echo "where dir is 'devel','13x', etc. and buildtype is 'debug' or 
'release'" >&2
    exit 1
}

test \( $# -eq 1 \) -o \( $# -eq 2 \) || Error
test -d "$1" || Error "Directory '$1' does not exist."

SRCDIR=$1
test -s "${SRCDIR}/configure" || \
    Error "'${SRCDIR}/configure' does not exist. Run './autogen.sh' in 
'${SRCDIR}'."

test $# -eq 2 && BUILDTYPE=$2 || BUILDTYPE=release
test \( "$BUILDTYPE" = "debug" \) -o \( "$BUILDTYPE" = "release" \) || \
    Error "Unrecognized debugopt: $BUILDTYPE"

echo "Configuring ${SRCDIR} for a ${BUILDTYPE} build"

FRONTEND=qt
QTDIR=/usr/local/qt-x11
FRONTEND_FLAGS="--with-qt-dir='${QTDIR}'"
QT_LD_SCRIPT=/usr/local/qt-x11/lib/i386pe.x-no-rdata
BUILDDIR=${SRCDIR}/build-x11

test "${BUILDDIR}" != "${SRCDIR}" -a ! -d "${BUILDDIR}" && {
    mkdir "${BUILDDIR}" || Error "Unable to create build dir, ${BUILDDIR}."
}

test "$BUILDTYPE" = "release" && {
   LDFLAGS="-Wl,--enable-runtime-pseudo-reloc -Wl,--script,$QT_LD_SCRIPT -Wl,-s"
   OPTFLAG="-O2"
} || {
   LDFLAGS="-Wl,--enable-runtime-pseudo-reloc -Wl,--script,$QT_LD_SCRIPT"
   OPTFLAG="-g"
}

CONFIGURE="../configure-x11"
QT_EXTRALIBS="-L\/usr\/X11R6\/lib -lXrender -lXrandr -lXcursor -lXft -lfreetype 
-lfontconfig -lXext -lX11"

sed "
# Let's speed up recognition of the single-threaded Qt library
/for libname in -lqt-mt/s/\(-lqt-mt\)\(.*\)\(-lqt\);/\3\2\1;/
# Omit -Wl,--export-all-symbols in LDFLAGS
/LDFLAGS=\"\$LDFLAGS \$WIN32_LD_EXPORT_ALL_SYMBOLS\"/s/LDFLAGS/true\t\#LDFLAGS/
# Add required libraries to the tests for the Qt library
/LIBS=\"\$LIBS \$libname\"/s/libname/libname $QT_EXTRALIBS/
/LIBS=\"\$LIBS \$QT_LIB\"/s/QT_LIB/QT_LIB $QT_EXTRALIBS/" \
        ${SRCDIR}/configure > ${SRCDIR}/configure-x11

chmod u+x ${SRCDIR}/configure-x11

# Set up configure itself
#========================
CONFIGURE="${CONFIGURE} --disable-maintainer-mode --disable-assertions \
--disable-debug --disable-stdlib-debug --enable-optimization='${OPTFLAG}' \
--disable-pch --disable-concept-checks \
--with-included-gettext --with-aspell \
--with-frontend='${FRONTEND}' ${FRONTEND_FLAGS} \
--with-extra-lib=/usr/local/lib \
--prefix=/usr/local \
LDFLAGS='${LDFLAGS}'"

echo "Build directory is ${BUILDDIR}"
echo "${CONFIGURE}"
cd "${BUILDDIR}"
eval "${CONFIGURE}"

# The end

Reply via email to