"Richard M. Stallman" <[EMAIL PROTECTED]> writes: > Shouldn't the MAXPATHLEN present in the emacs source code be > removed to avoid incompatibilities with hurd? > > Yes. And we want to get rid of arbitrary limits anyway. > > I found only one place where MAXPATHLEN is used, > aside from conditionals for specific proprietary systems. > That is in init_buffer. Would someone like to convert it > to extend its buffer when needed? Hi, This little patch should fix it. If something is wrong comments are well accepted.
--- src/buffer.c.old 2005-07-28 19:14:42.000000000 +0200 +++ src/buffer.c 2005-07-29 02:21:03.000000000 +0200 @@ -5114,7 +5114,7 @@ void init_buffer () { - char buf[MAXPATHLEN + 1]; + char *buf; char *pwd; struct stat dotstat, pwdstat; Lisp_Object temp; @@ -5146,14 +5146,47 @@ && 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 = malloc(strlen(pwd)+1); + if(!buf) + fatal ("`malloc' failed in init_buffer\n"); + strcpy (buf, pwd); + } +#ifdef _GNU_SOURCE + else + { + buf = get_current_dir_name(); + if(!buf) + fatal ("`get_current_dir_name' failed in init_buffer\n"); + } +#elif HAVE_GETCWD + else + { + buf = malloc(MAXPATHLEN+1); + if(!buf) + fatal ("`malloc' failed in init_buffer\n"); + if(buf) + { + if(getcdwd (buf, MAXPATHLEN+1) == 0) + fatal ("`getwd' failed: %s\n", buf); + } + } #else - else if (getwd (buf) == 0) - fatal ("`getwd' failed: %s\n", buf); + else + { + buf = malloc(MAXPATHLEN+1); + if(!buf) + fatal ("`malloc' failed in init_buffer\n"); + if(buf) + { + if(getwd (buf) == 0) + fatal ("`getwd' failed: %s\n", buf); + } + } #endif #ifndef VMS @@ -5189,6 +5222,7 @@ temp = get_minibuffer (0); XBUFFER (temp)->directory = current_buffer->directory; + free(buf); } /* initialize the buffer routines */ I worked on the xsmfns.c file too. I am not sure if this is required for the hurd compatibility. --- src/xsmfns.c.old 2005-07-28 19:51:24.000000000 +0200 +++ src/xsmfns.c 2005-07-28 21:30:11.000000000 +0200 @@ -56,7 +56,6 @@ #define MAXPATHLEN 1024 #endif /* not MAXPATHLEN */ - /* The user login name. */ extern Lisp_Object Vuser_login_name; @@ -205,7 +204,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 +258,28 @@ 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 _GNU_SOURCE + cwd = get_current_dir_name(); + if(!cwd) + fatal ("`get_current_dir_name' failed in smc_save_yourself_CB\n"); +#elif HAVE_GETCWD + cwd = malloc(MAXPATHLEN+1); + if(!cwd) + fatal ("`malloc' failed in failed in smc_save_yourself_CB\n"); + if(cwd) + { + if(getcdwd (cwd, MAXPATHLEN+1) == 0) + fatal ("`getwd' failed: %s\n", cwd); + } #else - if (getwd (cwd) != 0) + cwd = malloc(MAXPATHLEN+1); + if(!cwd) + fatal ("`malloc' failed in smc_save_yourself_CB\n"); + if(getwd (cwd) == 0) + fatal ("`getwd' failed: %s\n", cwd); #endif + + if(!cwd) { props[props_idx] = &prop_ptr[props_idx]; props[props_idx]->name = SmCurrentDirectory; @@ -280,6 +295,7 @@ SmcSetProperties (smcConn, props_idx, props); xfree (smid_opt); + free(cwd); /* See if we maybe shall interact with the user. */ if (interactStyle != SmInteractStyleAny Regards, Giuseppe Scrivano _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel