Martin Buchholz <martin(a)xemacs.org> writes:
> Tomonori's patch makes my crash go away. Thank you.
>
> So it is indeed Dan's patch. Dan's patch has made a fundamental
> redesign of realpath.c, by including lisp.h and sysfile.h, which were
> previously _deliberately_ excluded. I think in the original design,
> realpath.c was supposed to be able to use stuff only from config.h.
>
> Rethinking is advised. Unfortunately, it's hard for someone to do
> this right without experience in both Mule and Windows.
Terribly sorry. Mea culpa. Etc.
I must admit that I don't know anything about Mule, and that I didn't
even come close to realize that including sysfile.h and lisp.h meant a
fundamental redesign. Sorry again.
A feeble attempt to fix this mess:
I assume that the real problem is the inclusion of sysfile.h, and my
stupid, conflicting naming "sys_realpath" for an internal macro. I
really can't do without lisp.h, however (I need DIRECTORY_SEP, etc.),
so I just pray that's ok...
So, I've restored most of the original includes and the definition of
PATH_MAX, removed the inclusion of sysfile.h, and renamed my macro
sys_readlink to system_readlink.
This works well on native windows and cygwin, but I'm not able to test
under Linux and, therefore, not under Mule.
/dan
Index: realpath.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/realpath.c,v
retrieving revision 1.6.2.8
diff -u -r1.6.2.8 realpath.c
--- realpath.c 2000/12/01 12:44:53 1.6.2.8
+++ realpath.c 2000/12/04 22:50:54
@@ -24,11 +24,21 @@
#include <config.h>
#include "lisp.h"
-#include "sysfile.h"
+#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if defined (HAVE_SYS_PARAM_H) && !defined (WIN32_NATIVE)
+#include <sys/param.h>
+#endif
+
+#ifdef WIN32_NATIVE
+#include <direct.h>
+#endif
+
+#include <sys/stat.h> /* for S_IFLNK */
/* First char after start of absolute filename. */
#define ABS_START(name) (name + ABS_LENGTH (name))
@@ -38,15 +48,15 @@
# define ABS_LENGTH(name) (win32_abs_start (name))
static int win32_abs_start (const char * name);
/* System dependent version of readlink. */
-# define sys_readlink(name, buf, size) win32_readlink (name, buf, size)
+# define system_readlink win32_readlink
#else
# ifdef CYGWIN
# define ABS_LENGTH(name) (IS_DIRECTORY_SEP (*name) ? \
(IS_DIRECTORY_SEP (name[1]) ? 2 : 1) : 0)
-# define sys_readlink(name, buf, size) cygwin_readlink (name, buf, size)
+# define system_readlink cygwin_readlink
# else
# define ABS_LENGTH(name) (IS_DIRECTORY_SEP (*name) ? 1 : 0)
-# define sys_readlink(name, buf, size) readlink (name, buf, size)
+# define system_readlink readlink
# endif /* CYGWIN */
#endif /* WIN32_NATIVE */
@@ -162,6 +172,16 @@
#define getcwd(buffer, len) getwd (buffer)
#endif
+#ifndef PATH_MAX
+# if defined (_POSIX_PATH_MAX)
+# define PATH_MAX _POSIX_PATH_MAX
+# elif defined (MAXPATHLEN)
+# define PATH_MAX MAXPATHLEN
+# else
+# define PATH_MAX 1024
+# endif
+#endif
+
#define MAX_READLINKS 32
char * xrealpath (const char *path, char resolved_path []);
@@ -274,7 +294,7 @@
#if defined (S_IFLNK) || defined (WIN32_NATIVE)
/* See if latest pathname component is a symlink. */
*new_path = '\0';
- n = sys_readlink (resolved_path, link_path, PATH_MAX - 1);
+ n = system_readlink (resolved_path, link_path, PATH_MAX - 1);
if (n < 0)
{
--
Dan Ola Holmsand
IB
dan(a)eyebee.com