diff options
| author | Karoly Lorentey | 2005-09-11 08:23:50 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2005-09-11 08:23:50 +0000 |
| commit | 26cbc0482aa9ff3ad74430e3f6a56e831a831aff (patch) | |
| tree | 4db9b173720de80d72f0d9bdc6d625d03c9515b8 /src | |
| parent | 9148bda213c00500b9cfc0dca9e64be85dd88a12 (diff) | |
| parent | f9962371041b25c0772a35b0fcbfd313bcffdb87 (diff) | |
| download | emacs-26cbc0482aa9ff3ad74430e3f6a56e831a831aff.tar.gz emacs-26cbc0482aa9ff3ad74430e3f6a56e831a831aff.zip | |
Merged in changes from CVS trunk.
Patches applied:
* lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-6
Update from CVS
* lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-7
Sync with miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-539.
* lorentey@elte.hu--2004/emacs--cvs-trunk--0--version-0
Branch closed. Use miles@gnu.org--gnu-2005/emacs--cvs-trunk--0 instead.
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-475
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-476
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-477
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-478
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-479
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-480
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-481
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-482
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-483
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-484
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-485
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-486
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-487
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-488
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-489
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-490
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-491
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-492
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-493
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-494
Update from CVS: lisp/startup.el (command-line): Fix typo.
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-495
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-496
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-497
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-498
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-499
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-500
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-501
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-502
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-503
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-504
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-505
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-506
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-507
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-508
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-509
Update from CVS: .cvsignore: Add `lock'.
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-510
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-511
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-512
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-514
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-515
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-516
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-517
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-518
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-519
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-520
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-521
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-522
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-523
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-524
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-525
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-526
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-527
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-528
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-529
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-530
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-531
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-532
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-533
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-534
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-535
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-537
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-538
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-539
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-88
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-89
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-90
Update FSF's address in GPL notices
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-91
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-92
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-93
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-94
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-95
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-96
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-97
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-98
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-99
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-100
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-101
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-102
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-103
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-104
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-105
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-106
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-107
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-108
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-109
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-110
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-111
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-112
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-113
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-114
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-416
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 32 | ||||
| -rw-r--r-- | src/buffer.c | 45 | ||||
| -rw-r--r-- | src/config.in | 3 | ||||
| -rw-r--r-- | src/lisp.h | 3 | ||||
| -rw-r--r-- | src/sysdep.c | 77 | ||||
| -rw-r--r-- | src/xsmfns.c | 19 |
6 files changed, 136 insertions, 43 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index deb2b4ce3eb..e3fb1e07ab8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,35 @@ | |||
| 1 | 2005-09-10 Romain Francoise <romain@orebokech.com> | ||
| 2 | |||
| 3 | * buffer.c (init_buffer): Grow buffer to add directory separator | ||
| 4 | and terminal zero. Fix typos. | ||
| 5 | |||
| 6 | 2005-09-10 Eli Zaretskii <eliz@gnu.org> | ||
| 7 | |||
| 8 | * buffer.c (init_buffer): Fix error message for failed call to | ||
| 9 | get_current_dir_name. | ||
| 10 | (get_current_dir_name): Remove prototype. | ||
| 11 | |||
| 12 | * xsmfns.c: (get_current_dir_name): Remove prototype. | ||
| 13 | |||
| 14 | * lisp.h: (get_current_dir_name) [!HAVE_GET_CURRENT_DIR_NAME]: Add | ||
| 15 | prototype. | ||
| 16 | |||
| 17 | * sysdep.c [WINDOWSNT]: Add prototype for getwd. | ||
| 18 | Don't #undef NULL after including blockinput.h. | ||
| 19 | |||
| 20 | * config.in: Regenerated. | ||
| 21 | |||
| 22 | 2005-09-10 Giuseppe Scrivano <gscrivano@gmail.com> | ||
| 23 | |||
| 24 | Remove the MAXPATHLEN limitations: | ||
| 25 | |||
| 26 | * sysdep.c (get_current_dir_name) [!HAVE_GET_CURRENT_DIR_NAME]: | ||
| 27 | New function. | ||
| 28 | |||
| 29 | * buffer.c (init_buffer): Use it. | ||
| 30 | |||
| 31 | * xsmfns.c (smc_save_yourself_CB): Ditto. | ||
| 32 | |||
| 1 | 2005-09-09 Kim F. Storm <storm@cua.dk> | 33 | 2005-09-09 Kim F. Storm <storm@cua.dk> |
| 2 | 34 | ||
| 3 | * doc.c (Fsubstitute_command_keys): Lookup key binding for | 35 | * doc.c (Fsubstitute_command_keys): Lookup key binding for |
diff --git a/src/buffer.c b/src/buffer.c index 30626f11a24..fb1ff1c22e9 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -32,10 +32,6 @@ Boston, MA 02110-1301, USA. */ | |||
| 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> |
| @@ -5115,7 +5111,6 @@ init_buffer_once () | |||
| 5115 | void | 5111 | void |
| 5116 | init_buffer () | 5112 | init_buffer () |
| 5117 | { | 5113 | { |
| 5118 | char buf[MAXPATHLEN + 1]; | ||
| 5119 | char *pwd; | 5114 | char *pwd; |
| 5120 | struct stat dotstat, pwdstat; | 5115 | struct stat dotstat, pwdstat; |
| 5121 | Lisp_Object temp; | 5116 | Lisp_Object temp; |
| @@ -5138,40 +5133,28 @@ init_buffer () | |||
| 5138 | if (NILP (buffer_defaults.enable_multibyte_characters)) | 5133 | if (NILP (buffer_defaults.enable_multibyte_characters)) |
| 5139 | Fset_buffer_multibyte (Qnil); | 5134 | Fset_buffer_multibyte (Qnil); |
| 5140 | 5135 | ||
| 5141 | /* If PWD is accurate, use it instead of calling getwd. PWD is | 5136 | pwd = get_current_dir_name (); |
| 5142 | sometimes a nicer name, and using it may avoid a fatal error if a | 5137 | |
| 5143 | parent directory is searchable but not readable. */ | 5138 | if (!pwd) |
| 5144 | if ((pwd = getenv ("PWD")) != 0 | 5139 | fatal ("`get_current_dir_name' failed: %s\n", strerror (errno)); |
| 5145 | && (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1]))) | ||
| 5146 | && stat (pwd, &pwdstat) == 0 | ||
| 5147 | && stat (".", &dotstat) == 0 | ||
| 5148 | && dotstat.st_ino == pwdstat.st_ino | ||
| 5149 | && dotstat.st_dev == pwdstat.st_dev | ||
| 5150 | && strlen (pwd) < MAXPATHLEN) | ||
| 5151 | strcpy (buf, pwd); | ||
| 5152 | #ifdef HAVE_GETCWD | ||
| 5153 | else if (getcwd (buf, MAXPATHLEN+1) == 0) | ||
| 5154 | fatal ("`getcwd' failed: %s\n", strerror (errno)); | ||
| 5155 | #else | ||
| 5156 | else if (getwd (buf) == 0) | ||
| 5157 | fatal ("`getwd' failed: %s\n", buf); | ||
| 5158 | #endif | ||
| 5159 | 5140 | ||
| 5160 | #ifndef VMS | 5141 | #ifndef VMS |
| 5161 | /* Maybe this should really use some standard subroutine | 5142 | /* Maybe this should really use some standard subroutine |
| 5162 | whose definition is filename syntax dependent. */ | 5143 | whose definition is filename syntax dependent. */ |
| 5163 | rc = strlen (buf); | 5144 | rc = strlen (pwd); |
| 5164 | if (!(IS_DIRECTORY_SEP (buf[rc - 1]))) | 5145 | if (!(IS_DIRECTORY_SEP (pwd[rc - 1]))) |
| 5165 | { | 5146 | { |
| 5166 | buf[rc] = DIRECTORY_SEP; | 5147 | /* Grow buffer to add directory separator and '\0'. */ |
| 5167 | buf[rc + 1] = '\0'; | 5148 | pwd = (char *) xrealloc (pwd, rc + 2); |
| 5149 | pwd[rc] = DIRECTORY_SEP; | ||
| 5150 | pwd[rc + 1] = '\0'; | ||
| 5168 | } | 5151 | } |
| 5169 | #endif /* not VMS */ | 5152 | #endif /* not VMS */ |
| 5170 | 5153 | ||
| 5171 | current_buffer->directory = make_unibyte_string (buf, strlen (buf)); | 5154 | current_buffer->directory = make_unibyte_string (pwd, strlen (pwd)); |
| 5172 | if (! NILP (buffer_defaults.enable_multibyte_characters)) | 5155 | if (! NILP (buffer_defaults.enable_multibyte_characters)) |
| 5173 | /* At this momemnt, we still don't know how to decode the | 5156 | /* At this moment, we still don't know how to decode the |
| 5174 | direcotry name. So, we keep the bytes in multibyte form so | 5157 | directory name. So, we keep the bytes in multibyte form so |
| 5175 | that ENCODE_FILE correctly gets the original bytes. */ | 5158 | that ENCODE_FILE correctly gets the original bytes. */ |
| 5176 | current_buffer->directory | 5159 | current_buffer->directory |
| 5177 | = string_to_multibyte (current_buffer->directory); | 5160 | = string_to_multibyte (current_buffer->directory); |
| @@ -5190,6 +5173,8 @@ init_buffer () | |||
| 5190 | 5173 | ||
| 5191 | temp = get_minibuffer (0); | 5174 | temp = get_minibuffer (0); |
| 5192 | XBUFFER (temp)->directory = current_buffer->directory; | 5175 | XBUFFER (temp)->directory = current_buffer->directory; |
| 5176 | |||
| 5177 | free (pwd); | ||
| 5193 | } | 5178 | } |
| 5194 | 5179 | ||
| 5195 | /* initialize the buffer routines */ | 5180 | /* initialize the buffer routines */ |
diff --git a/src/config.in b/src/config.in index dc2c07667fb..69c7543bfab 100644 --- a/src/config.in +++ b/src/config.in | |||
| @@ -221,6 +221,9 @@ Boston, MA 02110-1301, USA. */ | |||
| 221 | /* Define to 1 if you have the `getwd' function. */ | 221 | /* Define to 1 if you have the `getwd' function. */ |
| 222 | #undef HAVE_GETWD | 222 | #undef HAVE_GETWD |
| 223 | 223 | ||
| 224 | /* Define to 1 if you have the `get_current_dir_name' function. */ | ||
| 225 | #undef HAVE_GET_CURRENT_DIR_NAME | ||
| 226 | |||
| 224 | /* Define to 1 if you have the ungif library (-lungif). */ | 227 | /* Define to 1 if you have the ungif library (-lungif). */ |
| 225 | #undef HAVE_GIF | 228 | #undef HAVE_GIF |
| 226 | 229 | ||
diff --git a/src/lisp.h b/src/lisp.h index 8f37c715c29..cba8bd31801 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3110,6 +3110,9 @@ struct tty_display_info; | |||
| 3110 | struct device; | 3110 | struct device; |
| 3111 | 3111 | ||
| 3112 | /* defined in sysdep.c */ | 3112 | /* defined in sysdep.c */ |
| 3113 | #ifndef HAVE_GET_CURRENT_DIR_NAME | ||
| 3114 | extern char *get_current_dir_name P_ ((void)); | ||
| 3115 | #endif | ||
| 3113 | extern void stuff_char P_ ((char c)); | 3116 | extern void stuff_char P_ ((char c)); |
| 3114 | extern void init_sigio P_ ((int)); | 3117 | extern void init_sigio P_ ((int)); |
| 3115 | extern void sys_subshell P_ ((void)); | 3118 | extern void sys_subshell P_ ((void)); |
diff --git a/src/sysdep.c b/src/sysdep.c index 9ffb167bdf0..114300b6784 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -49,7 +49,6 @@ extern void srandom P_ ((unsigned int)); | |||
| 49 | #include "sysselect.h" | 49 | #include "sysselect.h" |
| 50 | 50 | ||
| 51 | #include "blockinput.h" | 51 | #include "blockinput.h" |
| 52 | #undef NULL | ||
| 53 | 52 | ||
| 54 | #ifdef MAC_OS8 | 53 | #ifdef MAC_OS8 |
| 55 | /* It is essential to include stdlib.h so that this file picks up | 54 | /* It is essential to include stdlib.h so that this file picks up |
| @@ -190,6 +189,7 @@ extern int quit_char; | |||
| 190 | #define _P_WAIT 0 | 189 | #define _P_WAIT 0 |
| 191 | int _CRTAPI1 _spawnlp (int, const char *, const char *, ...); | 190 | int _CRTAPI1 _spawnlp (int, const char *, const char *, ...); |
| 192 | int _CRTAPI1 _getpid (void); | 191 | int _CRTAPI1 _getpid (void); |
| 192 | extern char *getwd (char *); | ||
| 193 | #endif | 193 | #endif |
| 194 | 194 | ||
| 195 | #ifdef NONSYSTEM_DIR_LIBRARY | 195 | #ifdef NONSYSTEM_DIR_LIBRARY |
| @@ -256,6 +256,81 @@ void hft_reset P_ ((struct tty_display_info *)); | |||
| 256 | 256 | ||
| 257 | SIGMASKTYPE sigprocmask_set; | 257 | SIGMASKTYPE sigprocmask_set; |
| 258 | 258 | ||
| 259 | |||
| 260 | #ifndef HAVE_GET_CURRENT_DIR_NAME | ||
| 261 | |||
| 262 | /* Return the current working directory. Returns NULL on errors. | ||
| 263 | Any other returned value must be freed with free. This is used | ||
| 264 | only when get_current_dir_name is not defined on the system. */ | ||
| 265 | char* | ||
| 266 | get_current_dir_name () | ||
| 267 | { | ||
| 268 | char *buf; | ||
| 269 | char *pwd; | ||
| 270 | struct stat dotstat, pwdstat; | ||
| 271 | /* If PWD is accurate, use it instead of calling getwd. PWD is | ||
| 272 | sometimes a nicer name, and using it may avoid a fatal error if a | ||
| 273 | parent directory is searchable but not readable. */ | ||
| 274 | if ((pwd = getenv ("PWD")) != 0 | ||
| 275 | && (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1]))) | ||
| 276 | && stat (pwd, &pwdstat) == 0 | ||
| 277 | && stat (".", &dotstat) == 0 | ||
| 278 | && dotstat.st_ino == pwdstat.st_ino | ||
| 279 | && dotstat.st_dev == pwdstat.st_dev | ||
| 280 | #ifdef MAXPATHLEN | ||
| 281 | && strlen (pwd) < MAXPATHLEN | ||
| 282 | #endif | ||
| 283 | ) | ||
| 284 | { | ||
| 285 | buf = (char *) malloc (strlen (pwd) + 1); | ||
| 286 | if (!buf) | ||
| 287 | return NULL; | ||
| 288 | strcpy (buf, pwd); | ||
| 289 | } | ||
| 290 | #ifdef HAVE_GETCWD | ||
| 291 | else | ||
| 292 | { | ||
| 293 | size_t buf_size = 1024; | ||
| 294 | buf = (char *) malloc (buf_size); | ||
| 295 | if (!buf) | ||
| 296 | return NULL; | ||
| 297 | for (;;) | ||
| 298 | { | ||
| 299 | if (getcwd (buf, buf_size) == buf) | ||
| 300 | break; | ||
| 301 | if (errno != ERANGE) | ||
| 302 | { | ||
| 303 | int tmp_errno = errno; | ||
| 304 | free (buf); | ||
| 305 | errno = tmp_errno; | ||
| 306 | return NULL; | ||
| 307 | } | ||
| 308 | buf_size *= 2; | ||
| 309 | buf = (char *) realloc (buf, buf_size); | ||
| 310 | if (!buf) | ||
| 311 | return NULL; | ||
| 312 | } | ||
| 313 | } | ||
| 314 | #else | ||
| 315 | else | ||
| 316 | { | ||
| 317 | /* We need MAXPATHLEN here. */ | ||
| 318 | buf = (char *) malloc (MAXPATHLEN + 1); | ||
| 319 | if (!buf) | ||
| 320 | return NULL; | ||
| 321 | if (getwd (buf) == NULL) | ||
| 322 | { | ||
| 323 | int tmp_errno = errno; | ||
| 324 | free (buf); | ||
| 325 | errno = tmp_errno; | ||
| 326 | return NULL; | ||
| 327 | } | ||
| 328 | } | ||
| 329 | #endif | ||
| 330 | return buf; | ||
| 331 | } | ||
| 332 | #endif | ||
| 333 | |||
| 259 | 334 | ||
| 260 | /* Discard pending input on all input descriptors. */ | 335 | /* Discard pending input on all input descriptors. */ |
| 261 | 336 | ||
diff --git a/src/xsmfns.c b/src/xsmfns.c index fc427a29790..dc5ebdf1ebd 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c | |||
| @@ -53,11 +53,6 @@ Boston, MA 02110-1301, USA. */ | |||
| 53 | #include "termopts.h" | 53 | #include "termopts.h" |
| 54 | #include "xterm.h" | 54 | #include "xterm.h" |
| 55 | 55 | ||
| 56 | #ifndef MAXPATHLEN | ||
| 57 | #define MAXPATHLEN 1024 | ||
| 58 | #endif /* not MAXPATHLEN */ | ||
| 59 | |||
| 60 | |||
| 61 | /* The user login name. */ | 56 | /* The user login name. */ |
| 62 | 57 | ||
| 63 | extern Lisp_Object Vuser_login_name; | 58 | extern Lisp_Object Vuser_login_name; |
| @@ -206,7 +201,7 @@ smc_save_yourself_CB (smcConn, | |||
| 206 | int val_idx = 0; | 201 | int val_idx = 0; |
| 207 | int props_idx = 0; | 202 | int props_idx = 0; |
| 208 | 203 | ||
| 209 | char cwd[MAXPATHLEN+1]; | 204 | char *cwd = NULL; |
| 210 | char *smid_opt; | 205 | char *smid_opt; |
| 211 | 206 | ||
| 212 | /* How to start a new instance of Emacs. */ | 207 | /* How to start a new instance of Emacs. */ |
| @@ -260,12 +255,9 @@ smc_save_yourself_CB (smcConn, | |||
| 260 | props[props_idx]->vals[0].value = SDATA (Vuser_login_name); | 255 | props[props_idx]->vals[0].value = SDATA (Vuser_login_name); |
| 261 | ++props_idx; | 256 | ++props_idx; |
| 262 | 257 | ||
| 263 | /* The current directory property, not mandatory. */ | 258 | cwd = get_current_dir_name (); |
| 264 | #ifdef HAVE_GETCWD | 259 | |
| 265 | if (getcwd (cwd, MAXPATHLEN+1) != 0) | 260 | if (cwd) |
| 266 | #else | ||
| 267 | if (getwd (cwd) != 0) | ||
| 268 | #endif | ||
| 269 | { | 261 | { |
| 270 | props[props_idx] = &prop_ptr[props_idx]; | 262 | props[props_idx] = &prop_ptr[props_idx]; |
| 271 | props[props_idx]->name = SmCurrentDirectory; | 263 | props[props_idx]->name = SmCurrentDirectory; |
| @@ -282,6 +274,9 @@ smc_save_yourself_CB (smcConn, | |||
| 282 | 274 | ||
| 283 | xfree (smid_opt); | 275 | xfree (smid_opt); |
| 284 | 276 | ||
| 277 | if (cwd) | ||
| 278 | free (cwd); | ||
| 279 | |||
| 285 | /* See if we maybe shall interact with the user. */ | 280 | /* See if we maybe shall interact with the user. */ |
| 286 | if (interactStyle != SmInteractStyleAny | 281 | if (interactStyle != SmInteractStyleAny |
| 287 | || ! shutdown | 282 | || ! shutdown |