Add support for the newly released Cygwin 1.7.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32886 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2010-01-08 16:21:43 +00:00
parent b692466769
commit 9da28dca29
3 changed files with 47 additions and 13 deletions

View File

@ -15,9 +15,19 @@
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <cygwin/version.h>
#include <sys/cygwin.h>
#include <windows.h>
void convert_to_full_posix_path(char const * from, char *to)
{
#if CYGWIN_VERSION_DLL_MAJOR >= 1007
cygwin_conv_path(CCP_WIN_A_TO_POSIX, from, to, PATH_MAX);
#else
cygwin_conv_to_full_posix_path(from, to);
#endif
}
int main(int ac, char **av)
{
char buf[2 * PATH_MAX];
@ -30,11 +40,11 @@ int main(int ac, char **av)
}
if (ac == 3) {
cygwin_conv_to_full_posix_path(av[1], posixpath);
convert_to_full_posix_path(av[1], posixpath);
sprintf(buf, "lyxeditor.sh" PROGRAM_SUFFIX " '%s' %s",
posixpath, av[2]);
} else {
cygwin_conv_to_full_posix_path(av[2], posixpath);
convert_to_full_posix_path(av[2], posixpath);
sprintf(buf, "lyxclient" PROGRAM_SUFFIX " %s '%s' %s",
av[1], posixpath, av[3]);
}

View File

@ -22,9 +22,19 @@
#include <process.h>
#include <string.h>
#include <limits.h>
#include <cygwin/version.h>
#include <sys/cygwin.h>
#include <windows.h>
void convert_to_posix_path(char const * from, char *to)
{
#if CYGWIN_VERSION_DLL_MAJOR >= 1007
cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE, from, to, PATH_MAX);
#else
cygwin_conv_to_posix_path(from, to);
#endif
}
int main (int argc, char **argv, char **environ)
{
FILE *fp;
@ -44,7 +54,7 @@ int main (int argc, char **argv, char **environ)
&& strcasecmp(s, ".lyx") == 0;
/* Add initial quote */
strcat(cmd, "\"");
cygwin_conv_to_posix_path(argv[i], posixpath) ;
convert_to_posix_path(argv[i], posixpath) ;
/* Hack to account for shares */
if (lyxfile && argv[i][0] == '\\' && argv[i][1] != '\\')
strcat(cmd, "/");

View File

@ -154,26 +154,40 @@ void init(int /* argc */, char * argv[])
* lyx is invoked as a parameter of hidecmd.exe.
*/
// If cygwin is detected, query the cygdrive prefix
// If Cygwin is detected, query the cygdrive prefix
HKEY regKey;
char buf[MAX_PATH];
DWORD bufSize = sizeof(buf);
LONG retVal;
// Check for Cygwin 1.7 or later
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"Software\\Cygnus Solutions\\Cygwin\\mounts v2",
"Software\\Cygwin\\setup",
0, KEY_QUERY_VALUE, &regKey);
if (retVal != ERROR_SUCCESS) {
if (retVal != ERROR_SUCCESS)
retVal = RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\Cygwin\\setup",
0, KEY_QUERY_VALUE, &regKey);
// Check for older Cygwin versions
if (retVal != ERROR_SUCCESS)
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"Software\\Cygnus Solutions\\Cygwin\\mounts v2",
0, KEY_QUERY_VALUE, &regKey);
}
if (retVal != ERROR_SUCCESS)
retVal = RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\Cygnus Solutions\\Cygwin\\mounts v2",
0, KEY_QUERY_VALUE, &regKey);
if (retVal == ERROR_SUCCESS) {
retVal = RegQueryValueEx(regKey, "cygdrive prefix", NULL, NULL,
(LPBYTE) buf, &bufSize);
RegCloseKey(regKey);
if ((retVal == ERROR_SUCCESS) && (bufSize <= MAX_PATH))
cygdrive = rtrim(string(buf), "/");
cmd_ret const p = runCommand("mount --show-cygdrive-prefix");
// The output of the mount command is as follows:
// Prefix Type Flags
// /cygdrive system binmode
// So, we use the inner split to pass the second line to the
// outer split which sets cygdrive with its contents until
// the first blank, discarding the unneeded return value.
if (p.first != -1 && prefixIs(p.second, "Prefix"))
split(split(p.second, '\n'), cygdrive, ' ');
}
// Catch shutdown events.