delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/04/26/06:34:39

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 <peuha AT cc DOT helsinki DOT fi>
Sender: peuha AT sirppi DOT helsinki DOT fi
To: Eli Zaretskii <eliz AT gnu DOT org>
cc: djgpp AT delorie DOT com
Subject: Re: Emacs oddity with TMPDIR
In-Reply-To: <3405-Fri23Apr2004164435+0300-eliz@gnu.org>
Message-ID: <Pine.OSF.4.58.0404261315380.5226@sirppi.helsinki.fi>
References: <Pine DOT OSF DOT 4 DOT 58 DOT 0404221114550 DOT 20168 AT sirppi DOT helsinki DOT fi>
<2914-Thu22Apr2004214547+0300-eliz AT gnu DOT org> <Pine DOT OSF DOT 4 DOT 58 DOT 0404231208140 DOT 31509 AT sirppi DOT helsinki DOT fi>
<3405-Fri23Apr2004164435+0300-eliz AT gnu DOT org>
MIME-Version: 1.0
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

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019