From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Giuseppe Scrivano Newsgroups: gmane.emacs.devel Subject: Re: emacs & MAXPATHLEN Date: Fri, 29 Jul 2005 02:22:37 +0200 Message-ID: <87pst2h35e.fsf@gmail.com> References: <87fytzj6a7.fsf@gmail.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1122597411 10903 80.91.229.2 (29 Jul 2005 00:36:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 29 Jul 2005 00:36:51 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 29 02:36:43 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DyIrh-0008RE-9e for ged-emacs-devel@m.gmane.org; Fri, 29 Jul 2005 02:36:41 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyIuA-0001Rr-7D for ged-emacs-devel@m.gmane.org; Thu, 28 Jul 2005 20:39:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DyImI-0006QD-Qx for emacs-devel@gnu.org; Thu, 28 Jul 2005 20:31:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DyImA-0006KD-8L for emacs-devel@gnu.org; Thu, 28 Jul 2005 20:31:00 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyIm4-0006Ee-Na for emacs-devel@gnu.org; Thu, 28 Jul 2005 20:30:52 -0400 Original-Received: from [64.233.170.207] (helo=rproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DyIpM-0004Gb-KI for emacs-devel@gnu.org; Thu, 28 Jul 2005 20:34:16 -0400 Original-Received: by rproxy.gmail.com with SMTP id c16so898973rne for ; Thu, 28 Jul 2005 17:22:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:to:cc:subject:references:from:date:in-reply-to:message-id:user-agent:mime-version:content-type; b=Asg8MjXd7qZ4cxE32xUGM5Eb+1DqwLIDGcyTd8zhI4LCwbGk5fO50gMA+PB3gO+YZBOxUW1TeXLv4zqhLpPZY9liygst7eWWgFH/JUrQXckcxJ00//9pYwSJjbxyCof0Qqr3drem5hrYzfrQ91Y4Doko6+rChf2OsJzmWBJlhlU= Original-Received: by 10.38.10.12 with SMTP id 12mr1449777rnj; Thu, 28 Jul 2005 17:22:34 -0700 (PDT) Original-Received: from steel ([80.181.159.241]) by mx.gmail.com with ESMTP id a67sm579234rne.2005.07.28.17.22.33; Thu, 28 Jul 2005 17:22:34 -0700 (PDT) Original-Received: from gscrivano by steel with local (Exim 4.52) id 1DyIe5-00039O-KD; Fri, 29 Jul 2005 02:22:37 +0200 Original-To: rms@gnu.org In-Reply-To: (Richard M. Stallman's message of "Thu, 28 Jul 2005 20:11:26 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:41283 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41283 "Richard M. Stallman" 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