mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
finish merging of the bits of win32 port that have been sent to me
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2846 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3c15d4e3bd
commit
c8aeaa9552
@ -1,3 +1,13 @@
|
||||
2001-10-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* filetools.C (AbsolutePath): Use os::is_absolute_path() (also in
|
||||
several methods)
|
||||
(findtexfile): oops! the change from last friday was wrong...
|
||||
|
||||
* os_win32.C (is_absolute_path):
|
||||
* os_unix.C (is_absolute_path):
|
||||
* os_os2.C (is_absolute_path): new method
|
||||
|
||||
2001-10-05 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* filetools.C (findtexfile): apply os::internal_path to the result.
|
||||
|
@ -6,7 +6,7 @@
|
||||
Parts Copyright 1985, 1990, 1993 Free Software Foundation, Inc.
|
||||
Parts Copyright 1996 Asger Alstrup
|
||||
|
||||
See also filetools.H.
|
||||
See also filetools.h.
|
||||
|
||||
lyx-filetool.C : tools functions for file/path handling
|
||||
this file is part of LyX, the High Level Word Processor
|
||||
@ -557,7 +557,7 @@ string const OnlyPath(string const & Filename)
|
||||
string const MakeAbsPath(string const & RelPath, string const & BasePath)
|
||||
{
|
||||
// checks for already absolute path
|
||||
if (AbsolutePath(RelPath))
|
||||
if (os::is_absolute_path(RelPath))
|
||||
return RelPath;
|
||||
|
||||
// Copies given paths
|
||||
@ -567,7 +567,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath)
|
||||
|
||||
string TempBase;
|
||||
|
||||
if (AbsolutePath(BasePath))
|
||||
if (os::is_absolute_path(BasePath))
|
||||
TempBase = BasePath;
|
||||
else
|
||||
TempBase = AddPath(lyx::getcwd(), BasePath);
|
||||
@ -651,24 +651,21 @@ string const OnlyFilename(string const & fname)
|
||||
}
|
||||
|
||||
|
||||
// Is a filename/path absolute?
|
||||
/// Returns true is path is absolute
|
||||
bool AbsolutePath(string const & path)
|
||||
{
|
||||
#ifndef __EMX__
|
||||
return (!path.empty() && path[0] == '/');
|
||||
#else
|
||||
return (!path.empty() && isalpha(static_cast<unsigned char>(path[0])) && path.length() > 1 && path[1] == ':');
|
||||
#endif
|
||||
return os::is_absolute_path(path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Create absolute path. If impossible, don't do anything
|
||||
// Supports ./ and ~/. Later we can add support for ~logname/. (Asger)
|
||||
string const ExpandPath(string const & path)
|
||||
{
|
||||
// checks for already absolute path
|
||||
string RTemp(ReplaceEnvironmentPath(path));
|
||||
if (AbsolutePath(RTemp))
|
||||
if (os::is_absolute_path(RTemp))
|
||||
return RTemp;
|
||||
|
||||
string Temp;
|
||||
@ -698,7 +695,7 @@ string const NormalizePath(string const & path)
|
||||
string RTemp;
|
||||
string Temp;
|
||||
|
||||
if (AbsolutePath(path))
|
||||
if (os::is_absolute_path(path))
|
||||
RTemp = path;
|
||||
else
|
||||
// Make implicit current directory explicit
|
||||
@ -958,7 +955,7 @@ MakeDisplayPath (string const & path, unsigned int threshold)
|
||||
|
||||
// If we backup from home or don't have a relative path,
|
||||
// this try is no good
|
||||
if (prefixIs(relhome, "../") || AbsolutePath(relhome)) {
|
||||
if (prefixIs(relhome, "../") || os::is_absolute_path(relhome)) {
|
||||
// relative path was no good, just use the original path
|
||||
relhome = path;
|
||||
l2 = l1;
|
||||
@ -1076,11 +1073,8 @@ findtexfile(string const & fil, string const & /*format*/)
|
||||
lyxerr[Debug::LATEX] << "kpse status = " << c.first << "\n"
|
||||
<< "kpse result = `" << strip(c.second, '\n')
|
||||
<< "'" << endl;
|
||||
string fullpath;
|
||||
if (c.first != -1)
|
||||
fullpath = os::internal_path(strip(strip(c.second,
|
||||
'\n'),
|
||||
'\r'));
|
||||
return os::internal_path(strip(strip(c.second, '\n'), '\r'));
|
||||
else
|
||||
return string();
|
||||
}
|
||||
|
@ -116,9 +116,6 @@ string const MakeLatexName(string const & file);
|
||||
/// Put the name in quotes suitable for the current shell
|
||||
string const QuoteName(string const & file);
|
||||
|
||||
/// Is a filename/path absolute?
|
||||
bool AbsolutePath(string const & path);
|
||||
|
||||
/// Add a filename to a path. Any path from filename is stripped first.
|
||||
string const AddName(string const & path, string const & fname);
|
||||
|
||||
@ -135,6 +132,9 @@ ChangeExtension(string const & oldname, string const & extension);
|
||||
/// Return the extension of the file (not including the .)
|
||||
string const GetExtension(string const & name);
|
||||
|
||||
/// Returns true is path is absolute
|
||||
bool AbsolutePath(string const & path);
|
||||
|
||||
/// Create absolute path. If impossible, don't do anything
|
||||
string const ExpandPath(string const & path);
|
||||
|
||||
|
@ -41,14 +41,19 @@ public:
|
||||
static os::shell_type shell() {return _shell;};
|
||||
|
||||
// DBCS aware!
|
||||
static string::size_type common_path(string const &p1, string const &p2);
|
||||
static string::size_type common_path(string const &p1,
|
||||
string const &p2);
|
||||
|
||||
// no-op on UNIX, '\\'->'/' on OS/2 and Win32, ':'->'/' on MacOS, etc.
|
||||
static string slashify_path(string p);
|
||||
// converts a host OS path to unix style
|
||||
static string external_path(string p);
|
||||
static string external_path(string const &p);
|
||||
// converts a unix path to host OS style
|
||||
static string internal_path(string p);
|
||||
static string internal_path(string const &p);
|
||||
// is path absolute?
|
||||
static bool is_absolute_path(string const & p);
|
||||
|
||||
//
|
||||
static void warn(string mesg);
|
||||
private:
|
||||
static string binpath_;
|
||||
|
@ -155,10 +155,20 @@ string os::slashify_path(string p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
string os::external_path(string p) {
|
||||
|
||||
string os::external_path(string const &p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
string os::internal_path(string p) {
|
||||
|
||||
string os::internal_path(string const &p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
bool os::is_absolute_path(string const & p)
|
||||
{
|
||||
return (p.length() > 1
|
||||
&& isalpha(static_cast<unsigned char>(p[0]))
|
||||
&& p[1] == ':');
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ void os::init(int * /*argc*/, char ** argv[]) /* :cp_(0), _shell(os::UNIX) */ {
|
||||
string tmp = *argv[0];
|
||||
binname_ = OnlyFilename(tmp);
|
||||
tmp = ExpandPath(tmp); // This expands ./ and ~/
|
||||
if (!AbsolutePath(tmp)) {
|
||||
if (!os::is_absolute_path(tmp)) {
|
||||
string binsearchpath = GetEnvPath("PATH");
|
||||
// This will make "src/lyx" work always :-)
|
||||
binsearchpath += ";.";
|
||||
@ -34,7 +34,7 @@ void os::init(int * /*argc*/, char ** argv[]) /* :cp_(0), _shell(os::UNIX) */ {
|
||||
|
||||
// In case we are running in place and compiled with shared libraries
|
||||
if (suffixIs(tmp, "/.libs/"))
|
||||
tmp.erase(tmp.length()-6, string::npos);
|
||||
tmp.erase(tmp.length() - 6, string::npos);
|
||||
binpath_ = tmp;
|
||||
}
|
||||
|
||||
@ -64,10 +64,15 @@ string os::slashify_path(string p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
string os::external_path(string p) {
|
||||
string os::external_path(string const &p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
string os::internal_path(string p) {
|
||||
string os::internal_path(string const &p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
bool os::is_absolute_path(string const & p)
|
||||
{
|
||||
return (!p.empty() && p[0] == '/');
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ void os::init(int * argc, char ** argv[]) {
|
||||
binname_ = OnlyFilename(tmp);
|
||||
tmp = ExpandPath(tmp); // This expands ./ and ~/
|
||||
|
||||
if (!AbsolutePath(tmp)) {
|
||||
if (!is_absolute_path(tmp)) {
|
||||
string binsearchpath = GetEnvPath("PATH");
|
||||
// This will make "src/lyx" work always :-)
|
||||
binsearchpath += ";.";
|
||||
@ -68,9 +68,9 @@ string os::slashify_path(string p) {
|
||||
return subst(p, '\\', '/');
|
||||
}
|
||||
|
||||
string os::external_path(string p) {
|
||||
string os::external_path(string const & p) {
|
||||
string dos_path=p;
|
||||
if (AbsolutePath(p)) {
|
||||
if (is_absolute_path(p)) {
|
||||
char dp[255];
|
||||
cygwin_conv_to_full_win32_path(p.c_str(), dp);
|
||||
dos_path=subst(dp,'\\','/');
|
||||
@ -82,11 +82,12 @@ string os::external_path(string p) {
|
||||
return dos_path;
|
||||
}
|
||||
|
||||
|
||||
// (Claus H.) Parsing the latex log file in an Win32 environment all
|
||||
// files are mentioned in Win32/DOS syntax. Because LyX uses the dep file
|
||||
// entries to check if any file has been changed we must retranslate
|
||||
// the Win32/DOS pathnames into Cygwin pathnames.
|
||||
string os::internal_path(string p) {
|
||||
string os::internal_path(string const &p) {
|
||||
char pp[256];
|
||||
cygwin_conv_to_posix_path(p.c_str(), pp);
|
||||
string const posix_path = MakeLatexName(pp);
|
||||
@ -96,3 +97,20 @@ string os::internal_path(string p) {
|
||||
<< posix_path << "]" << endl;
|
||||
return posix_path;
|
||||
}
|
||||
|
||||
// (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
|
||||
// followed by a colon. Because a colon is not valid in pathes in Unix
|
||||
// and at another location in Win32 testing just for the existance
|
||||
// of the colon in the 2nd position seems to be enough!
|
||||
bool os::is_absolute_path(string const & p)
|
||||
{
|
||||
if (p.empty())
|
||||
return false;
|
||||
|
||||
bool isDosPath = (path.length() > 1 && path[1] == ':');
|
||||
bool isUnixPath = (path[0] == '/');
|
||||
|
||||
return isDosPath | isUnixPath;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user