diff nt/runemacs.c @ 290:c9fe270a4101 r21-0b43

Import from CVS: tag r21-0b43
author cvs
date Mon, 13 Aug 2007 10:36:47 +0200
parents e121b013d1f0
children 19dcec799385
line wrap: on
line diff
--- a/nt/runemacs.c	Mon Aug 13 10:35:55 2007 +0200
+++ b/nt/runemacs.c	Mon Aug 13 10:36:47 2007 +0200
@@ -26,6 +26,11 @@
 #include <string.h>
 #include <malloc.h>
 
+#if defined(__CYGWIN32__)
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
 int WINAPI
 WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
 {
@@ -79,8 +84,44 @@
     strcat (p, " ");
   }
 #else
+#if defined(__CYGWIN32__)
+  {
+    struct stat stbuf;
+    char sym_link_name[MAX_PATH+1], real_name[MAX_PATH+1];
+    
+    strcpy(sym_link_name, new_cmdline);
+    strcat(sym_link_name, "\\xemacs");
+    if (lstat(sym_link_name, &stbuf) == 0)
+      {
+        if ((stbuf.st_mode & S_IFLNK) == S_IFLNK)
+          {
+	    if (readlink(sym_link_name, real_name, sizeof(real_name)) == -1)
+              {
+                MessageBox (NULL, "Error reading symbolic link for xemacs",
+                            "Error", MB_ICONSTOP);
+                return 1;
+              }
+            else
+              {
+		strcat(new_cmdline, "\\");
+                strcat(new_cmdline, real_name);
+		strcat(new_cmdline, " ");
+	      }
+          }
+        else
+          strcat(new_cmdline, "\\xemacs ");
+      }
+    else
+      {
+        MessageBox (NULL, "can't locate XEmacs executable",
+                    "Error", MB_ICONSTOP);
+	return 1;
+      }
+  }
+#else					
   strcat (new_cmdline, "\\xemacs.exe ");
 #endif
+#endif
 
   /* Append original arguments if any; first look for -wait as first
      argument, and apply that ourselves.  */