2009/6/24 Reini Urban <rurban(a)x-ray.at>:
So I have several improvements.
Patches inlined because gmail uploader fails on my proxy
Forget the previous attempt. It double-freed an arg.
This patch works now fine.
2009-06-30 Reini Urban <rurban(a)x-ray.at>
* lib-src/winclient.c: adapt to cygwin paths, add more startup sleep to
let xemacs init the DDE server.
diff -u xemacs-21.5.28/lib-src/winclient.c.orig
xemacs-21.5.28/lib-src/winclient.c
--- xemacs-21.5.28/lib-src/winclient.c.orig 2009-06-24 09:30:22.234375000 +0200
+++ xemacs-21.5.28/lib-src/winclient.c 2009-06-30 08:28:29.046875000 +0200
@@ -1,5 +1,6 @@
/* DDE client for XEmacs.
Copyright (C) 2002 Alastair J. Houghton
+ Copyright (C) 2009 Reini Urban
This file is part of XEmacs.
@@ -31,6 +32,9 @@
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+#endif
static void error (const char* s1, const char* s2);
static void fatal (const char *s1, const char *s2);
@@ -40,6 +44,8 @@
/* -- Post-Include Defines
-------------------------------------------------- */
/* Timeouts & delays */
+#define STARTUP_DELAY 3000 /* ms */
+#define CONNECT_RETRIES 10
#define CONNECT_DELAY 500 /* ms */
#define TRANSACTION_TIMEOUT 5000 /* ms */
#define MAX_INPUT_IDLE_WAIT INFINITE /* ms */
@@ -205,12 +211,15 @@
/* Wait for the process to enter an idle state */
WaitForInputIdle (pi.hProcess, MAX_INPUT_IDLE_WAIT);
+ /* Wait longer to let the process init the GUI and initialize
the DDE server */
+ Sleep (STARTUP_DELAY);
+
/* Close the handles */
CloseHandle (pi.hThread);
CloseHandle (pi.hProcess);
- /* Try to connect */
- for (n = 0; n < 5; n++)
+ /* Try to connect. Process startup and XEmacs init might be slow */
+ for (n = 0; n < CONNECT_RETRIES; n++)
{
Sleep (CONNECT_DELAY);
@@ -272,6 +281,24 @@
char *buf = NULL;
unsigned len;
+ /* On Cygwin convert the path - first part - back to POSIX */
+#ifdef __CYGWIN__
+ int err;
+ int pathlen;
+ char *fullpath;
+
+ pathlen = strlen(lpszFileName1) + 260 + 1001;
+ fullpath = (char *) xmalloc (pathlen);
+ err = cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE,
+ lpszFileName1, fullpath, pathlen);
+# ifdef DEBUG
+ fprintf(stderr, "DEBUG doFile(hConv, \"%s\", \"%s\")\n",
lpszFileName1, lpszFileName2);
+ fprintf(stderr, "DEBUG W2P \"%s\" => \"%s\"
err=%d\n",
lpszFileName1, fullpath, err);
+# endif
+ if (!err)
+ strcpy(lpszFileName1, fullpath);
+#endif
+
/* Calculate the buffer length */
len = strlen (lpszFileName1) + strlen (lpszFileName2)
+ strlen (COMMAND_FORMAT);
@@ -296,6 +323,13 @@
DdeClientTransaction (buf, len, hConv, NULL,
0, XTYP_EXECUTE, TRANSACTION_TIMEOUT, NULL);
+#ifdef __CYGWIN__
+# ifdef DEBUG
+ fprintf(stderr, "DEBUG DDE => %s\n", buf);
+# endif
+ if (!err)
+ free (fullpath);
+#endif
free (buf);
return 0;
@@ -404,13 +438,20 @@
int ret = 0;
HANDLE hFindFile = NULL;
WIN32_FIND_DATA wfd;
+#ifdef __CYGWIN__
+ int err;
+#endif
/* Retrieve arguments */
while ((arg = getNextArg ((const char**)&lpszCommandLine, &len)) != NULL)
{
/* First find the canonical path name */
fullpath = filepart = NULL;
+#ifdef __CYGWIN__
+ pathlen = len + 260 + 1001;
+#else
pathlen = GetFullPathName (arg, 0, fullpath, &filepart);
+#endif
fullpath = (char *) xmalloc (pathlen);
@@ -425,6 +466,17 @@
break;
}
+#ifdef __CYGWIN__
+ err = cygwin_conv_path(CCP_POSIX_TO_WIN_A | CCP_RELATIVE, arg,
fullpath, pathlen);
+# ifdef DEBUG
+ fprintf(stderr, "DEBUG P2W \"%s\" => \"%s\"
err=%d\n", arg,
fullpath, err);
+# endif
+ if (err)
+ ret = doFile (hConv, "", arg);
+ else
+ arg = fullpath;
+#endif
+
GetFullPathName (arg, pathlen, fullpath, &filepart);
/* Find the first matching file */
@@ -454,7 +506,10 @@
/* Release the path name buffers */
free (fullpath);
- free (arg);
+#ifdef __CYGWIN__
+ if (err)
+ free (arg);
+#endif
if (ret)
break;
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta