X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Date: Mon, 26 Apr 2004 13:33:58 +0300 (EET DST) From: Esa A E Peuha Sender: peuha AT sirppi DOT helsinki DOT fi To: Eli Zaretskii cc: djgpp AT delorie DOT com Subject: Re: Emacs oddity with TMPDIR In-Reply-To: <3405-Fri23Apr2004164435+0300-eliz@gnu.org> Message-ID: References: <2914-Thu22Apr2004214547+0300-eliz AT gnu DOT org> <3405-Fri23Apr2004164435+0300-eliz AT gnu DOT org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: esa DOT peuha AT helsinki DOT fi Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Fri, 23 Apr 2004, Eli Zaretskii wrote: > If you send a patch to do that, I will check it into the Emacs CVS. This is untested (I'm not very willing to compile Emacs on my slow machine), but it should work. I use FILENAME_MAX instead of PATH_MAX because PATH_MAX is twice as large as DOS supports. *** msdos.c.orig Mon Apr 26 12:48:44 2004 --- msdos.c Mon Apr 26 13:09:24 2004 *************** *** 4408,4421 **** for (i = 0; i < imax ; i++) { const char *tmp = tempdirs[i]; if (*tmp == '$') ! tmp = getenv (tmp + 1); /* Note that `access' can lie to us if the directory resides on a read-only filesystem, like CD-ROM or a write-protected floppy. The only way to be really sure is to actually create a file and see if it succeeds. But I think that's too much to ask. */ ! if (tmp && access (tmp, D_OK) == 0) { setenv ("TMPDIR", tmp, 1); break; --- 4408,4437 ---- for (i = 0; i < imax ; i++) { const char *tmp = tempdirs[i]; + char buf[FILENAME_MAX]; if (*tmp == '$') ! { ! int tmp_len; ! ! tmp = getenv (tmp + 1); ! if (!tmp) ! continue; ! ! tmp_len = strlen(tmp); ! if (tmp[tmp_len - 1] != '/' && tmp[tmp_len - 1] != '\\') ! { ! strcpy(buf, tmp); ! buf[tmp_len++] = '/', buf[tmp_len] = 0; ! tmp = buf; ! } ! } ! /* Note that `access' can lie to us if the directory resides on a read-only filesystem, like CD-ROM or a write-protected floppy. The only way to be really sure is to actually create a file and see if it succeeds. But I think that's too much to ask. */ ! if (access (tmp, D_OK) == 0) { setenv ("TMPDIR", tmp, 1); break; -- Esa Peuha student of mathematics at the University of Helsinki http://www.helsinki.fi/~peuha/