mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-04 19:29:37 +00:00
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs into feature/pgtk
This commit is contained in:
commit
b64089c37b
182 changed files with 4996 additions and 1986 deletions
|
@ -251,7 +251,6 @@ get_current_dir_name (void)
|
|||
bufsize_max = min (bufsize_max, PATH_MAX);
|
||||
#endif
|
||||
|
||||
char *buf;
|
||||
struct stat dotstat, pwdstat;
|
||||
size_t pwdlen;
|
||||
/* If PWD is accurate, use it instead of calling getcwd. PWD is
|
||||
|
@ -265,37 +264,23 @@ get_current_dir_name (void)
|
|||
&& stat (".", &dotstat) == 0
|
||||
&& dotstat.st_ino == pwdstat.st_ino
|
||||
&& dotstat.st_dev == pwdstat.st_dev)
|
||||
{
|
||||
buf = xmalloc (strlen (pwd) + 1);
|
||||
strcpy (buf, pwd);
|
||||
}
|
||||
return strdup (pwd);
|
||||
else
|
||||
{
|
||||
size_t buf_size = 1024;
|
||||
ptrdiff_t buf_size = min (bufsize_max, 1024);
|
||||
for (;;)
|
||||
{
|
||||
int tmp_errno;
|
||||
buf = malloc (buf_size);
|
||||
if (! buf)
|
||||
break;
|
||||
if (getcwd (buf, buf_size) == buf)
|
||||
break;
|
||||
tmp_errno = errno;
|
||||
{
|
||||
char *buf = malloc (buf_size);
|
||||
if (!buf)
|
||||
return NULL;
|
||||
if (getcwd (buf, buf_size) == buf)
|
||||
return buf;
|
||||
free (buf);
|
||||
if (tmp_errno != ERANGE)
|
||||
{
|
||||
errno = tmp_errno;
|
||||
return NULL;
|
||||
}
|
||||
buf_size *= 2;
|
||||
if (! buf_size)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (errno != ERANGE || buf_size == bufsize_max)
|
||||
return NULL;
|
||||
buf_size = buf_size <= bufsize_max / 2 ? 2 * buf_size : bufsize_max;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue