mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
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:
parent
b692466769
commit
9da28dca29
@ -15,9 +15,19 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <cygwin/version.h>
|
||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include <windows.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)
|
int main(int ac, char **av)
|
||||||
{
|
{
|
||||||
char buf[2 * PATH_MAX];
|
char buf[2 * PATH_MAX];
|
||||||
@ -30,11 +40,11 @@ int main(int ac, char **av)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ac == 3) {
|
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",
|
sprintf(buf, "lyxeditor.sh" PROGRAM_SUFFIX " '%s' %s",
|
||||||
posixpath, av[2]);
|
posixpath, av[2]);
|
||||||
} else {
|
} 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",
|
sprintf(buf, "lyxclient" PROGRAM_SUFFIX " %s '%s' %s",
|
||||||
av[1], posixpath, av[3]);
|
av[1], posixpath, av[3]);
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,19 @@
|
|||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <cygwin/version.h>
|
||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include <windows.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)
|
int main (int argc, char **argv, char **environ)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -44,7 +54,7 @@ int main (int argc, char **argv, char **environ)
|
|||||||
&& strcasecmp(s, ".lyx") == 0;
|
&& strcasecmp(s, ".lyx") == 0;
|
||||||
/* Add initial quote */
|
/* Add initial quote */
|
||||||
strcat(cmd, "\"");
|
strcat(cmd, "\"");
|
||||||
cygwin_conv_to_posix_path(argv[i], posixpath) ;
|
convert_to_posix_path(argv[i], posixpath) ;
|
||||||
/* Hack to account for shares */
|
/* Hack to account for shares */
|
||||||
if (lyxfile && argv[i][0] == '\\' && argv[i][1] != '\\')
|
if (lyxfile && argv[i][0] == '\\' && argv[i][1] != '\\')
|
||||||
strcat(cmd, "/");
|
strcat(cmd, "/");
|
||||||
|
@ -154,26 +154,40 @@ void init(int /* argc */, char * argv[])
|
|||||||
* lyx is invoked as a parameter of hidecmd.exe.
|
* 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;
|
HKEY regKey;
|
||||||
char buf[MAX_PATH];
|
|
||||||
DWORD bufSize = sizeof(buf);
|
|
||||||
LONG retVal;
|
LONG retVal;
|
||||||
|
|
||||||
|
// Check for Cygwin 1.7 or later
|
||||||
|
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||||
|
"Software\\Cygwin\\setup",
|
||||||
|
0, KEY_QUERY_VALUE, ®Key);
|
||||||
|
if (retVal != ERROR_SUCCESS)
|
||||||
|
retVal = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||||
|
"Software\\Cygwin\\setup",
|
||||||
|
0, KEY_QUERY_VALUE, ®Key);
|
||||||
|
|
||||||
|
// Check for older Cygwin versions
|
||||||
|
if (retVal != ERROR_SUCCESS)
|
||||||
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||||
"Software\\Cygnus Solutions\\Cygwin\\mounts v2",
|
"Software\\Cygnus Solutions\\Cygwin\\mounts v2",
|
||||||
0, KEY_QUERY_VALUE, ®Key);
|
0, KEY_QUERY_VALUE, ®Key);
|
||||||
if (retVal != ERROR_SUCCESS) {
|
if (retVal != ERROR_SUCCESS)
|
||||||
retVal = RegOpenKeyEx(HKEY_CURRENT_USER,
|
retVal = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||||
"Software\\Cygnus Solutions\\Cygwin\\mounts v2",
|
"Software\\Cygnus Solutions\\Cygwin\\mounts v2",
|
||||||
0, KEY_QUERY_VALUE, ®Key);
|
0, KEY_QUERY_VALUE, ®Key);
|
||||||
}
|
|
||||||
if (retVal == ERROR_SUCCESS) {
|
if (retVal == ERROR_SUCCESS) {
|
||||||
retVal = RegQueryValueEx(regKey, "cygdrive prefix", NULL, NULL,
|
|
||||||
(LPBYTE) buf, &bufSize);
|
|
||||||
RegCloseKey(regKey);
|
RegCloseKey(regKey);
|
||||||
if ((retVal == ERROR_SUCCESS) && (bufSize <= MAX_PATH))
|
cmd_ret const p = runCommand("mount --show-cygdrive-prefix");
|
||||||
cygdrive = rtrim(string(buf), "/");
|
// 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.
|
// Catch shutdown events.
|
||||||
|
Loading…
Reference in New Issue
Block a user