]> git.lyx.org Git - features.git/commitdiff
* Replace all use of 'slashify_path' with 'internal_path'.
authorAngus Leeming <leeming@lyx.org>
Mon, 20 Dec 2004 16:59:33 +0000 (16:59 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 20 Dec 2004 16:59:33 +0000 (16:59 +0000)
* Specialise 'internal_path' and 'external_path' for Windows and Cygwin.
* Enable LyX to find its system_lyxdir on Windows.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9401 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
src/ChangeLog
src/buffer.C
src/frontends/gtk/ChangeLog
src/frontends/gtk/lyx_gui.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/lyx_gui.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/lyx_gui.C
src/support/ChangeLog
src/support/filename.C
src/support/filetools.C
src/support/os.h
src/support/os_os2.C
src/support/os_unix.C
src/support/os_win32.C
src/support/path_defines.C.in

index b7c72090982ef914a2ac01e592eb0c52b301e79a..79a8c5dd8ae6e14b3d21c79c4333794ef896b77a 100644 (file)
@@ -1,3 +1,7 @@
+2004-12-19  Angus Leeming  <leeming@lyx.org>
+
+       * buffer.C (save): s/slashify_path/internal_path/.
+
 2004-12-20  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * lyxfind.C (findChange): do not search for end of pars, because
index 610a56a78c31966d50500f7a84852f6a4a70fc0f..daf0f402832c33b76315bced7793c384e5b537c7 100644 (file)
@@ -681,7 +681,7 @@ bool Buffer::save() const
                s = fileName() + '~';
                if (!lyxrc.backupdir_path.empty())
                        s = AddName(lyxrc.backupdir_path,
-                                   subst(os::slashify_path(s),'/','!'));
+                                   subst(os::internal_path(s),'/','!'));
 
                // Rename is the wrong way of making a backup,
                // this is the correct way.
index 2215ca052c00bdfa1a33c64de28243a0ff118ac9..ac4bfac61e063410f00a3f42430474c506368f12 100644 (file)
@@ -1,3 +1,7 @@
+2004-12-19  Angus Leeming  <leeming@lyx.org>
+
+       * lyx_gui.C (start): s/slashify_path/internal_path/
+
 2004-12-19  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * ghelpers.C (getDefaultUnit): add return statement to shut up the
index d84074d25f91f872762bd04e1cda4036c2872b43..68fd498501aa59756ccb75d7843079e890689a44 100644 (file)
@@ -345,7 +345,7 @@ void lyx_gui::start(string const & batch, std::vector<string> const & files)
 
        lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
        lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
-                         os::slashify_path(os::getTmpDir() + "/lyxsocket"));
+                         os::internal_path(os::getTmpDir() + "/lyxsocket"));
 
        for_each(files.begin(), files.end(),
                 bind(&BufferView::loadLyXFile, view.view(), _1, true));
index d419ee23243846900664fd74752af353aed0318c..76d103119e72029eabfd15c135728f06f3b5ec8f 100644 (file)
@@ -1,3 +1,7 @@
+2004-12-19  Angus Leeming  <leeming@lyx.org>
+
+       * lyx_gui.C (start): s/slashify_path/internal_path/
+
 2004-12-16  Angus Leeming  <leeming@lyx.org>
 
        * qt_helpers.C (fromqstr): Don't use std::string(0) to construct
index 0495ae770fb782f2d661790fba5b708faad52454..ea2f84ae2a9a77d357e797028e6568b17a1f1239 100644 (file)
@@ -229,7 +229,7 @@ void start(string const & batch, vector<string> const & files)
 
        lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
        lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
-                         os::slashify_path(os::getTmpDir() + "/lyxsocket"));
+                         os::internal_path(os::getTmpDir() + "/lyxsocket"));
 
        for_each(files.begin(), files.end(),
                 bind(&BufferView::loadLyXFile, view.view(), _1, true));
index bd2a7b185c909b88cc8c25b80671b84579c892a6..25f2ef7e2b9fb6737788f52dbd2e70f568178e5f 100644 (file)
@@ -1,3 +1,7 @@
+2004-12-19  Angus Leeming  <leeming@lyx.org>
+
+       * lyx_gui.C (start): s/slashify_path/internal_path/
+
 2004-12-16  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * FormMathsBitmap.C: Do not split strings with blank into two
index de220cdc583e3b7f6abef03ce04cbd5985785b1a..5340ca36cf60e5a508f5ef5c75522bf62ab8b5fe 100644 (file)
@@ -302,7 +302,7 @@ void start(string const & batch, vector<string> const & files)
 
        lyxserver = new LyXServer(&view->getLyXFunc(), lyxrc.lyxpipes);
        lyxsocket = new LyXServerSocket(&view->getLyXFunc(),
-                         os::slashify_path(os::getTmpDir() + "/lyxsocket"));
+                         os::internal_path(os::getTmpDir() + "/lyxsocket"));
 
        for_each(files.begin(), files.end(),
                bind(&BufferView::loadLyXFile, view->view(), _1, true));
index 7c72859aff0e88c7f628bdba8b2f2ccf5d4d751e..3fcaf0c9ac4ce531b833bee782fda8fa2e3dddaa 100644 (file)
@@ -1,3 +1,23 @@
+2004-12-19  Angus Leeming  <leeming@lyx.org>
+
+       * path_defines.C.in (setLyxPaths): on a Windows build,
+       remove the ".exe" extension from the name of the LyX binary when
+       trying to ascertain the name of the LyX system directory.
+       (Usually, <path to binary>/../share/<name of binary>/).
+
+       * os.h, os_os2.C, os_unix.C, os_win32.C (slashify_path): remove.
+
+       * os_win32.C (init): ensure that the name of the lyx executable is
+       stored internally with a unix-style path.
+
+       * os_win32.C (internal_path, external_path): differentiate between
+       cygwin and windows builds.
+
+       * filetools.C (FileOpenSearch, GetEnvPath, createDirectory,
+       MakeAbsPath, AddName, MakeRelPath, ChangeExtension):
+       * filename.C (mangledFilename):
+       s/slashify_path/internal_path/.
+
 2004-12-16  Angus Leeming  <leeming@lyx.org>
 
        * filename.C (mangledFilename): Given a Windows-style path, don't
index e56956cac3fd247186881a436f961172eb94fec9..3f5020f46b62519d81291a1ab0d3d2252b069d0d 100644 (file)
@@ -77,7 +77,7 @@ string const FileName::mangledFilename() const
                return (*it).second;
 
        // Now the real work
-       string mname = os::slashify_path(name_);
+       string mname = os::internal_path(name_);
        // Remove the extension.
        mname = ChangeExtension(name_, string());
        // Replace '/' in the file name with '_'
index 78149fa4c57020d2c16bb47073b5435e8694cb3c..481b8ec8867afc963c43eeebddad50e8b85e0103 100644 (file)
@@ -185,7 +185,7 @@ string const FileOpenSearch(string const & path, string const & name,
        string tmppath = split(path, path_element, ';');
 
        while (notfound && !path_element.empty()) {
-               path_element = os::slashify_path(path_element);
+               path_element = os::internal_path(path_element);
                if (!suffixIs(path_element, '/'))
                        path_element+= '/';
                path_element = subst(path_element, "$$LyX", system_lyxdir());
@@ -394,7 +394,7 @@ string const GetEnvPath(string const & name)
 #ifndef __EMX__
        string const pathlist = subst(GetEnv(name), ':', ';');
 #else
-       string const pathlist = os::slashify_path(GetEnv(name));
+       string const pathlist = os::internal_path(GetEnv(name));
 #endif
        return rtrim(pathlist, ";");
 }
@@ -538,7 +538,7 @@ string const createLyXTmpDir(string const & deflt)
 
 bool createDirectory(string const & path, int permission)
 {
-       string temp(rtrim(os::slashify_path(path), "/"));
+       string temp(rtrim(os::internal_path(path), "/"));
 
        BOOST_ASSERT(!temp.empty());
 
@@ -573,7 +573,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath)
                return RelPath;
 
        // Copies given paths
-       string TempRel(os::slashify_path(RelPath));
+       string TempRel(os::internal_path(RelPath));
        // Since TempRel is NOT absolute, we can safely replace "//" with "/"
        TempRel = subst(TempRel, "//", "/");
 
@@ -624,7 +624,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath)
        }
 
        // returns absolute path
-       return os::slashify_path(TempBase);
+       return os::internal_path(TempBase);
 }
 
 
@@ -639,7 +639,7 @@ string const AddName(string const & path, string const & fname)
        string buf;
 
        if (path != "." && path != "./" && !path.empty()) {
-               buf = os::slashify_path(path);
+               buf = os::internal_path(path);
                if (!suffixIs(path, '/'))
                        buf += '/';
        }
@@ -840,10 +840,10 @@ string const MakeRelPath(string const & abspath, string const & basepath)
 string const AddPath(string const & path, string const & path_2)
 {
        string buf;
-       string const path2 = os::slashify_path(path_2);
+       string const path2 = os::internal_path(path_2);
 
        if (!path.empty() && path != "." && path != "./") {
-               buf = os::slashify_path(path);
+               buf = os::internal_path(path);
                if (path[path.length() - 1] != '/')
                        buf += '/';
        }
@@ -877,7 +877,7 @@ string const ChangeExtension(string const & oldname, string const & extension)
        else
                ext = extension;
 
-       return os::slashify_path(oldname.substr(0, last_dot) + ext);
+       return os::internal_path(oldname.substr(0, last_dot) + ext);
 }
 
 
index 86b44e1bb7c347d578113f707d547c6a0b07298a..bb4a0231391a7b11a0709704ab1de049a2405448 100644 (file)
@@ -47,8 +47,6 @@ std::string current_root();
 shell_type shell();
 // DBCS aware!
 std::string::size_type common_path(std::string const & p1, std::string const & p2);
-// no-op on UNIX, '\\'->'/' on OS/2 and Win32, ':'->'/' on MacOS, etc.
-std::string slashify_path(std::string const & p);
 // Converts a unix style path to host OS style.
 std::string external_path(std::string const & p);
 // Converts a host OS style path to unix style.
index 1b7c1465cc56c7895ac040c361aace2110f4c657..ac4b33e98f9d59e3d723d0490ddd957bcaf91b24 100644 (file)
@@ -56,7 +56,7 @@ void init(int argc, char * argv[])
        if (rc != NO_ERROR)
                exit(rc);
        string p = tmp.get();
-       p = slashify_path(p);
+       p = internal_path(p);
        binname_ = OnlyFilename(p);
        binname_.erase(binname_.length()-4, string::npos);
        binpath_ = OnlyPath(p);
@@ -128,8 +128,8 @@ string::size_type common_path(string const & p1, string const & p2)
        COUNTRYCODE cntry;
        cntry.country = 0;
        cntry.codepage = cp_;
-       string temp1 = slashify_path(p1);
-       string temp2 = slashify_path(p2);
+       string temp1 = internal_path(p1);
+       string temp2 = internal_path(p2);
        char * tmp1 = const_cast<char *> (temp1.c_str());
        char * tmp2 = const_cast<char *> (temp2.c_str());
        /* rc = */ DosMapCase(p1.length(), &cntry, tmp1);
@@ -157,7 +157,7 @@ string::size_type common_path(string const & p1, string const & p2)
 }
 
 
-string slashify_path(string const & p)
+string internal_path(string const & p)
 {
        static bool initialized = false;
        static bool leadbyte[256] = {false};
@@ -202,12 +202,6 @@ string external_path(string const & p)
 }
 
 
-string internal_path(string const & p)
-{
-       return p;
-}
-
-
 bool is_absolute_path(string const & p)
 {
        return (p.length() > 1
index 1d13cd50861e4700bf102e1e819e35a9be269dd9..53594714e35622b369963910b150cf1b78d6f448 100644 (file)
@@ -96,12 +96,6 @@ string::size_type common_path(string const & p1, string const & p2)
 }
 
 
-string slashify_path(string const & p)
-{
-       return p;
-}
-
-
 string external_path(string const & p)
 {
        return p;
index 862d7431642b3584fdaa40791e5493156e8ca7ef..d8df19d39f961f891941e31c646e219fdea644b0 100644 (file)
@@ -49,7 +49,7 @@ void init(int /* argc */, char * argv[])
                return;
        initialized = true;
 
-       string tmp = argv[0];
+       string tmp = internal_path(argv[0]);
        binname_ = OnlyFilename(tmp);
        tmp = ExpandPath(tmp); // This expands ./ and ~/
 
@@ -57,7 +57,7 @@ void init(int /* argc */, char * argv[])
                string binsearchpath = GetEnvPath("PATH");
                // This will make "src/lyx" work always :-)
                binsearchpath += ";.";
-               tmp = argv[0];
+               tmp = internal_path(argv[0]);
                tmp = FileOpenSearch(binsearchpath, tmp);
        }
 
@@ -113,20 +113,25 @@ string::size_type common_path(string const & p1, string const & p2)
 }
 
 
-string slashify_path(string const & p)
-{
-       return subst(p, '\\', '/');
-}
-
-
 string external_path(string const & p)
 {
-       string dos_path = p;
+       string dos_path;
+#ifdef __CYGWIN__
+       // Translate from cygwin path syntax to dos path syntax
        if (is_absolute_path(p)) {
-               char dp[255];
+               char dp[MAX_PATH];
                cygwin_conv_to_full_win32_path(p.c_str(), dp);
-               dos_path = subst(dp,'\\','/');
+               dos_path = !dp ? "" : dp;
        }
+
+       else return p;
+#else // regular Win32
+       dos_path = p;
+#endif
+       
+       //No backslashes in LaTeX files
+       dos_path = subst(dos_path,'\\','/');
+
        lyxerr[Debug::LATEX]
                << "<Win32 path correction> ["
                << p << "]->>["
@@ -141,9 +146,13 @@ string external_path(string const & p)
 // the Win32/DOS pathnames into Cygwin pathnames.
 string internal_path(string const & p)
 {
-       char pp[256];
+#ifdef __CYGWIN__
+       char pp[MAX_PATH];
        cygwin_conv_to_posix_path(p.c_str(), pp);
        string const posix_path = MakeLatexName(pp);
+#else
+       string const posix_path = subst(p,"\\","/");
+#endif
        lyxerr[Debug::DEPEND]
                << "<Win32 path correction> ["
                << p << "]->>["
index e6b6e558755ae92f345d9973c0416aa1c80b9f65..dfe7062efb274395531da49a61478c172be4b5a8 100644 (file)
@@ -217,8 +217,18 @@ bool setLyxPaths()
        bool followlink;
        do {
                // Path of binary/../share/name of binary/
-               searchpath += NormalizePath(AddPath(binpath, "../share/") +
-                     OnlyFilename(binname)) + ';';
+               string const exe_name = OnlyFilename(binname);
+#ifdef _WIN32
+               string const lyx_system_dir_name =
+                       suffixIs(exe_name, ".exe") ?
+                               ChangeExtension(exe_name, "") :
+                               exe_name;
+#else
+               string const lyx_system_dir_name = exe_name;
+#endif
+               string const shared_dir_name =
+                       NormalizePath(AddPath(binpath, "../share/"));
+               searchpath += shared_dir_name + lyx_system_dir_name + ';';
 
                // Follow Symlinks
                FileInfo file(fullbinpath, true);