This new version should follow all your hints: --- configure.in.old 2005-07-29 18:14:02.000000000 +0200 +++ configure.in 2005-07-29 18:19:26.000000000 +0200 @@ -2414,7 +2414,7 @@ AC_CHECK_HEADERS(maillock.h) AC_CHECK_FUNCS(gethostname getdomainname dup2 \ -rename closedir mkdir rmdir sysinfo getrusage \ +rename closedir mkdir rmdir sysinfo getrusage get_current_dir_name \ random lrand48 bcopy bcmp logb frexp fmod rint cbrt ftime res_init setsid \ strerror fpathconf select mktime euidaccess getpagesize tzset setlocale \ utimes setrlimit setpgid getcwd getwd shutdown getaddrinfo \ --- src/buffer.c.old 2005-07-28 19:14:42.000000000 +0200 +++ src/buffer.c 2005-07-30 15:29:08.000000000 +0200 @@ -31,10 +31,6 @@ extern int errno; #endif -#ifndef MAXPATHLEN -/* in 4.1 [probably SunOS? -stef] , param.h fails to define this. */ -#define MAXPATHLEN 1024 -#endif /* not MAXPATHLEN */ #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -5114,7 +5110,7 @@ void init_buffer () { - char buf[MAXPATHLEN + 1]; + char *buf; char *pwd; struct stat dotstat, pwdstat; Lisp_Object temp; @@ -5140,20 +5136,57 @@ /* If PWD is accurate, use it instead of calling getwd. PWD is sometimes a nicer name, and using it may avoid a fatal error if a parent directory is searchable but not readable. */ - if ((pwd = getenv ("PWD")) != 0 + if ((pwd = getenv ("PWD")) != 0 && (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1]))) && stat (pwd, &pwdstat) == 0 && stat (".", &dotstat) == 0 && dotstat.st_ino == pwdstat.st_ino && dotstat.st_dev == pwdstat.st_dev - && strlen (pwd) < MAXPATHLEN) - strcpy (buf, pwd); -#ifdef HAVE_GETCWD - else if (getcwd (buf, MAXPATHLEN+1) == 0) - fatal ("`getcwd' failed: %s\n", strerror (errno)); +#ifdef MAXPATHLEN + && strlen (pwd) < MAXPATHLEN +#endif + ) + { + buf = xmalloc (strlen (pwd) + 1); + strcpy (buf, pwd); + } +#ifdef HAVE_CURRENT_DIR_NAME + else + { + buf = get_current_dir_name (); + if (!buf) + fatal ("`get_current_dir_name' failed in init_buffer\n"); + } +#elif HAVE_GETCWD + else + { +#ifdef MAXPATHLEN + buf = xmalloc (MAXPATHLEN + 1); + if (getcwd (buf, MAXPATHLEN + 1) == NULL) + fatal ("`getcwd' failed: %s\n", buf); +#else + { + int buf_size = 1024; + buf = (char *) xmalloc (buf_size); + for (;;) + { + if (getcwd (buf, buf_size) == buf) + break; + if (errno != ERANGE) + fatal ("`getcwd' failed: %s\n", strerror (errno)); + buf_size *= 2; + buf = (char *) xrealloc (buf, buf_size); + } + } +#endif + } #else - else if (getwd (buf) == 0) - fatal ("`getwd' failed: %s\n", buf); + else + { + buf = xmalloc (MAXPATHLEN + 1); + if (getwd (buf) == NULL) + fatal ("`getwd' failed: %s\n", buf); + } #endif #ifndef VMS @@ -5189,6 +5222,12 @@ temp = get_minibuffer (0); XBUFFER (temp)->directory = current_buffer->directory; + +#ifdef HAVE_CURRENT_DIR_NAME + free (buf); +#else + xfree (buf); +#endif } /* initialize the buffer routines */ --- src/xsmfns.c.old 2005-07-28 19:51:24.000000000 +0200 +++ src/xsmfns.c 2005-07-30 15:31:16.000000000 +0200 @@ -45,6 +45,8 @@ #include <sys/param.h> #include <stdio.h> +#include <errno.h> + #include "systime.h" #include "sysselect.h" #include "lisp.h" @@ -52,10 +54,6 @@ #include "termopts.h" #include "xterm.h" -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif /* not MAXPATHLEN */ - /* The user login name. */ @@ -205,7 +203,7 @@ int val_idx = 0; int props_idx = 0; - char cwd[MAXPATHLEN+1]; + char *cwd = NULL; char *smid_opt; /* How to start a new instance of Emacs. */ @@ -259,12 +257,47 @@ props[props_idx]->vals[0].value = SDATA (Vuser_login_name); ++props_idx; - /* The current directory property, not mandatory. */ -#ifdef HAVE_GETCWD - if (getcwd (cwd, MAXPATHLEN+1) != 0) +#ifdef HAVE_GET_CURRENT_DIR_NAME + cwd = get_current_dir_name (); +#elif HAVE_GETCWD + +#ifdef MAXPATHLEN + cwd = (char *) xmalloc (MAXPATHLEN+1); + if (getcwd (cwd, MAXPATHLEN+1) == NULL) + { + xfree(cwd); + cwd = NULL; + } #else - if (getwd (cwd) != 0) + { + int cwd_size = 1024; + cwd = (char *) xmalloc (cwd_size); + for (;;) + { + if (getcwd (cwd, cwd_size) == cwd) + break; + if (errno != ERANGE) + { + xfree (cwd); + cwd = NULL; + break; + } + cwd_size *= 2; + cwd = (char *) xrealloc (cwd, cwd_size); + } + } #endif + +#else + cwd = xmalloc (MAXPATHLEN + 1); + if (getwd (cwd) == NULL) + { + xfree (cwd); + cwd = NULL; + } +#endif + + if (!cwd) { props[props_idx] = &prop_ptr[props_idx]; props[props_idx]->name = SmCurrentDirectory; @@ -281,6 +314,13 @@ xfree (smid_opt); + if (cwd) +#ifdef HAVE_CURRENT_DIR_NAME + free (cwd); +#else + xfree (cwd); +#endif + /* See if we maybe shall interact with the user. */ if (interactStyle != SmInteractStyleAny || ! shutdown
_______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel