/[emacs]/emacs/src/buffer.c
ViewVC logotype

Diff of /emacs/src/buffer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.488 by ttn, Sun Aug 7 12:33:16 2005 UTC revision 1.489 by eliz, Sat Sep 10 11:30:06 2005 UTC
# Line 32  Boston, MA 02110-1301, USA.  */ Line 32  Boston, MA 02110-1301, USA.  */
32  extern int errno;  extern int errno;
33  #endif  #endif
34    
 #ifndef MAXPATHLEN  
 /* in 4.1 [probably SunOS? -stef] , param.h fails to define this. */  
 #define MAXPATHLEN 1024  
 #endif /* not MAXPATHLEN */  
35    
36  #ifdef HAVE_UNISTD_H  #ifdef HAVE_UNISTD_H
37  #include <unistd.h>  #include <unistd.h>
# Line 54  extern int errno; Line 50  extern int errno;
50  #include "keymap.h"  #include "keymap.h"
51  #include "frame.h"  #include "frame.h"
52    
53    extern char * get_current_dir_name ();
54    
55  struct buffer *current_buffer;          /* the current buffer */  struct buffer *current_buffer;          /* the current buffer */
56    
57  /* First buffer in chain of all buffers (in reverse order of creation).  /* First buffer in chain of all buffers (in reverse order of creation).
# Line 5115  init_buffer_once () Line 5113  init_buffer_once ()
5113  void  void
5114  init_buffer ()  init_buffer ()
5115  {  {
   char buf[MAXPATHLEN + 1];  
5116    char *pwd;    char *pwd;
5117    struct stat dotstat, pwdstat;    struct stat dotstat, pwdstat;
5118    Lisp_Object temp;    Lisp_Object temp;
# Line 5138  init_buffer () Line 5135  init_buffer ()
5135    if (NILP (buffer_defaults.enable_multibyte_characters))    if (NILP (buffer_defaults.enable_multibyte_characters))
5136      Fset_buffer_multibyte (Qnil);      Fset_buffer_multibyte (Qnil);
5137    
5138    /* If PWD is accurate, use it instead of calling getwd.  PWD is    pwd = get_current_dir_name ();
5139       sometimes a nicer name, and using it may avoid a fatal error if a  
5140       parent directory is searchable but not readable.  */    if(!pwd)
5141    if ((pwd = getenv ("PWD")) != 0      fatal ("`get_cwd' failed: %s\n", strerror (errno));
       && (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));  
 #else  
   else if (getwd (buf) == 0)  
     fatal ("`getwd' failed: %s\n", buf);  
 #endif  
5142    
5143  #ifndef VMS  #ifndef VMS
5144    /* Maybe this should really use some standard subroutine    /* Maybe this should really use some standard subroutine
5145       whose definition is filename syntax dependent.  */       whose definition is filename syntax dependent.  */
5146    rc = strlen (buf);    rc = strlen (pwd);
5147    if (!(IS_DIRECTORY_SEP (buf[rc - 1])))    if (!(IS_DIRECTORY_SEP (pwd[rc - 1])))
5148      {      {
5149        buf[rc] = DIRECTORY_SEP;        pwd[rc] = DIRECTORY_SEP;
5150        buf[rc + 1] = '\0';        pwd[rc + 1] = '\0';
5151      }      }
5152  #endif /* not VMS */  #endif /* not VMS */
5153    
5154    current_buffer->directory = make_unibyte_string (buf, strlen (buf));    current_buffer->directory = make_unibyte_string (pwd, strlen (pwd));
5155    if (! NILP (buffer_defaults.enable_multibyte_characters))    if (! NILP (buffer_defaults.enable_multibyte_characters))
5156      /* At this momemnt, we still don't know how to decode the      /* At this momemnt, we still don't know how to decode the
5157         direcotry name.  So, we keep the bytes in multibyte form so         direcotry name.  So, we keep the bytes in multibyte form so
# Line 5190  init_buffer () Line 5173  init_buffer ()
5173    
5174    temp = get_minibuffer (0);    temp = get_minibuffer (0);
5175    XBUFFER (temp)->directory = current_buffer->directory;    XBUFFER (temp)->directory = current_buffer->directory;
5176    
5177      free (pwd);
5178  }  }
5179    
5180  /* initialize the buffer routines */  /* initialize the buffer routines */

Legend:
Removed from v.1.488  
changed lines
  Added in v.1.489

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26