Mercurial > emacs
comparison src/buffer.c @ 90227:10fe5fadaf89
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-81
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 532-541)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 112-115)
- Update from CVS
| author | Miles Bader <miles@gnu.org> |
|---|---|
| date | Sun, 11 Sep 2005 22:21:01 +0000 |
| parents | 2d92f5c9d6ae 1ffe6d4d0fc4 |
| children | 5e2d3828e89f |
comparison
equal
deleted
inserted
replaced
| 90226:df78f2fb8f6a | 90227:10fe5fadaf89 |
|---|---|
| 30 | 30 |
| 31 #ifndef USE_CRT_DLL | 31 #ifndef USE_CRT_DLL |
| 32 extern int errno; | 32 extern int errno; |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 #ifndef MAXPATHLEN | |
| 36 /* in 4.1 [probably SunOS? -stef] , param.h fails to define this. */ | |
| 37 #define MAXPATHLEN 1024 | |
| 38 #endif /* not MAXPATHLEN */ | |
| 39 | 35 |
| 40 #ifdef HAVE_UNISTD_H | 36 #ifdef HAVE_UNISTD_H |
| 41 #include <unistd.h> | 37 #include <unistd.h> |
| 42 #endif | 38 #endif |
| 43 | 39 |
| 5129 } | 5125 } |
| 5130 | 5126 |
| 5131 void | 5127 void |
| 5132 init_buffer () | 5128 init_buffer () |
| 5133 { | 5129 { |
| 5134 char buf[MAXPATHLEN + 1]; | |
| 5135 char *pwd; | 5130 char *pwd; |
| 5136 struct stat dotstat, pwdstat; | 5131 struct stat dotstat, pwdstat; |
| 5137 Lisp_Object temp; | 5132 Lisp_Object temp; |
| 5138 int rc; | 5133 int rc; |
| 5139 | 5134 |
| 5152 | 5147 |
| 5153 Fset_buffer (Fget_buffer_create (build_string ("*scratch*"))); | 5148 Fset_buffer (Fget_buffer_create (build_string ("*scratch*"))); |
| 5154 if (NILP (buffer_defaults.enable_multibyte_characters)) | 5149 if (NILP (buffer_defaults.enable_multibyte_characters)) |
| 5155 Fset_buffer_multibyte (Qnil); | 5150 Fset_buffer_multibyte (Qnil); |
| 5156 | 5151 |
| 5157 /* If PWD is accurate, use it instead of calling getwd. PWD is | 5152 pwd = get_current_dir_name (); |
| 5158 sometimes a nicer name, and using it may avoid a fatal error if a | 5153 |
| 5159 parent directory is searchable but not readable. */ | 5154 if (!pwd) |
| 5160 if ((pwd = getenv ("PWD")) != 0 | 5155 fatal ("`get_current_dir_name' failed: %s\n", strerror (errno)); |
| 5161 && (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1]))) | |
| 5162 && stat (pwd, &pwdstat) == 0 | |
| 5163 && stat (".", &dotstat) == 0 | |
| 5164 && dotstat.st_ino == pwdstat.st_ino | |
| 5165 && dotstat.st_dev == pwdstat.st_dev | |
| 5166 && strlen (pwd) < MAXPATHLEN) | |
| 5167 strcpy (buf, pwd); | |
| 5168 #ifdef HAVE_GETCWD | |
| 5169 else if (getcwd (buf, MAXPATHLEN+1) == 0) | |
| 5170 fatal ("`getcwd' failed: %s\n", strerror (errno)); | |
| 5171 #else | |
| 5172 else if (getwd (buf) == 0) | |
| 5173 fatal ("`getwd' failed: %s\n", buf); | |
| 5174 #endif | |
| 5175 | 5156 |
| 5176 #ifndef VMS | 5157 #ifndef VMS |
| 5177 /* Maybe this should really use some standard subroutine | 5158 /* Maybe this should really use some standard subroutine |
| 5178 whose definition is filename syntax dependent. */ | 5159 whose definition is filename syntax dependent. */ |
| 5179 rc = strlen (buf); | 5160 rc = strlen (pwd); |
| 5180 if (!(IS_DIRECTORY_SEP (buf[rc - 1]))) | 5161 if (!(IS_DIRECTORY_SEP (pwd[rc - 1]))) |
| 5181 { | 5162 { |
| 5182 buf[rc] = DIRECTORY_SEP; | 5163 /* Grow buffer to add directory separator and '\0'. */ |
| 5183 buf[rc + 1] = '\0'; | 5164 pwd = (char *) xrealloc (pwd, rc + 2); |
| 5165 pwd[rc] = DIRECTORY_SEP; | |
| 5166 pwd[rc + 1] = '\0'; | |
| 5184 } | 5167 } |
| 5185 #endif /* not VMS */ | 5168 #endif /* not VMS */ |
| 5186 | 5169 |
| 5187 current_buffer->directory = make_unibyte_string (buf, strlen (buf)); | 5170 current_buffer->directory = make_unibyte_string (pwd, strlen (pwd)); |
| 5188 if (! NILP (buffer_defaults.enable_multibyte_characters)) | 5171 if (! NILP (buffer_defaults.enable_multibyte_characters)) |
| 5189 /* At this momemnt, we still don't know how to decode the | 5172 /* At this moment, we still don't know how to decode the |
| 5190 direcotry name. So, we keep the bytes in multibyte form so | 5173 directory name. So, we keep the bytes in multibyte form so |
| 5191 that ENCODE_FILE correctly gets the original bytes. */ | 5174 that ENCODE_FILE correctly gets the original bytes. */ |
| 5192 current_buffer->directory | 5175 current_buffer->directory |
| 5193 = string_to_multibyte (current_buffer->directory); | 5176 = string_to_multibyte (current_buffer->directory); |
| 5194 | 5177 |
| 5195 /* Add /: to the front of the name | 5178 /* Add /: to the front of the name |
| 5204 current_buffer->directory | 5187 current_buffer->directory |
| 5205 = concat2 (build_string ("/:"), current_buffer->directory); | 5188 = concat2 (build_string ("/:"), current_buffer->directory); |
| 5206 | 5189 |
| 5207 temp = get_minibuffer (0); | 5190 temp = get_minibuffer (0); |
| 5208 XBUFFER (temp)->directory = current_buffer->directory; | 5191 XBUFFER (temp)->directory = current_buffer->directory; |
| 5192 | |
| 5193 free (pwd); | |
| 5209 } | 5194 } |
| 5210 | 5195 |
| 5211 /* initialize the buffer routines */ | 5196 /* initialize the buffer routines */ |
| 5212 void | 5197 void |
| 5213 syms_of_buffer () | 5198 syms_of_buffer () |
