Hi Hugs folks,
I ported hugs to the Hurd, which is the GNU operating system.
The only issue was the unconditionalized use of MAXPATHLEN if realpath is
available in machdep.c, to canonicalize a file name.
POSIX mandates that applications should query the runtime limit of max path
length with pathconf(). If there is no limit, pathconf will return -1. Most
unices define a hard limit, not only at run time but even at compile time
through MAX_PATH or MAXPATHLEN, but the Hurd doesn't, because the Hurd
supports file systems with arbitrary file length.
So, the correct solution in case pathconf returns -1 is to check if realpath
returns ENAMETOOLONG and adjust with realloc(). Nobody is patient enough for
that, but that's what we get using a broken interface (realpath). Luckily,
the GNU C library makes things easier for us, we can simply use the
non-standard interface char *canonicalize_file_name(char *f), which
allocates a long enough string for us. We just have to free() it after use.
That's what I did in my path. I hope you like it and add it to the next
version, so Hurd users can enjoy hugs. To use the non standard interface,
you have to define _GNU_SOURCE. If you find out how to do it with autoconf,
you could define it only if __GLIBC__ or HAVE_CANONICALIZE_FILE_NAME is
defined, but I didn't bother.
Two further notes: You should regenerate the configure files after applying
the patch. HAVE_CANONICALIZE_FILE_NAME must be checked before HAVE_REALPATH,
as the Hurd defines both but not MAXPATHLEN.
If you don't like the fix, please let me know so we can hopefully work out
something different.
Thanks,
Marcus
--
`Rhubarb is no Egyptian god.' Debian http://www.debian.org Check Key server
Marcus Brinkmann GNU http://www.gnu.org for public PGP Key
[EMAIL PROTECTED], [EMAIL PROTECTED] PGP Key ID 36E7CD09
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/ [EMAIL PROTECTED]
diff -ru hugs98-98.199911.orig/src/machdep.c hugs98-98.199911/src/machdep.c
--- hugs98-98.199911.orig/src/machdep.c Tue Nov 16 20:16:00 1999
+++ hugs98-98.199911/src/machdep.c Sat Jan 8 00:28:39 2000
@@ -318,6 +318,11 @@
#if HAVE__FULLPATH /* eg DOS */
static char path[FILENAME_MAX+1];
_fullpath(path,s,FILENAME_MAX+1);
+#elif HAVE_CANONICALIZE_FILE_NAME /* eg GNU */
+ static char *path = NULL;
+ if (path != NULL)
+ free(path);
+ path = canonicalize_file_name(s);
#elif HAVE_REALPATH /* eg Unix */
static char path[MAXPATHLEN+1];
realpath(s,path);
@@ -336,6 +341,15 @@
static char path2[FILENAME_MAX+1];
_fullpath(path1,p1,FILENAME_MAX+1);
_fullpath(path2,p2,FILENAME_MAX+1);
+#elif HAVE_CANONICALIZE_FILE_NAME /* eg GNU */
+ static char *path1 = NULL;
+ static char *path2 = NULL;
+ if (path1 != NULL)
+ free(path1);
+ if (path2 != NULL)
+ free(path2);
+ path1 = canonicalize_file_name(p1);
+ path2 = canonicalize_file_name(p2);
#elif HAVE_REALPATH /* eg Unix */
static char path1[MAXPATHLEN+1];
static char path2[MAXPATHLEN+1];
diff -ru hugs98-98.199911.orig/src/unix/configure.in
hugs98-98.199911/src/unix/configure.in
--- hugs98-98.199911.orig/src/unix/configure.in Sat Jan 8 00:47:19 2000
+++ hugs98-98.199911/src/unix/configure.in Sat Jan 8 00:37:39 2000
@@ -113,9 +113,12 @@
AC_DEFINE(HAVE_GETMODULEFILENAME)
fi
+dnl We sould probably check for GNU C library first
+AC_DEFINE(_GNU_SOURCE)
+
AC_CHECK_FUNCS(strcasecmp _stricmp stricmp strcmpi)
AC_CHECK_FUNCS(strcmp)
-AC_CHECK_FUNCS(realpath _fullpath)
+AC_CHECK_FUNCS(canonicalize_file_name realpath _fullpath)
AC_CHECK_FUNCS(PBHSetVolSync macsystem)
AC_CHECK_FUNCS(fgetpos fsetpos fseek ftell)
AC_CHECK_FUNCS(vsnprintf _vsnprintf)