Commit 81c3310d authored by Gerd Moellmann's avatar Gerd Moellmann
Browse files

(Ffile_symlink_p): If readlink returns ERANGE, take

that to mean that the buffer is too small.
parent 06fd3792
2001-09-13 Gerd Moellmann <gerd@gnu.org>
* fileio.c (Ffile_symlink_p): If readlink returns ERANGE, take
that to mean that the buffer is too small.
* xdisp.c (reseat_1): Set IT's multibyte_p flag according to the
current buffer's multibyteness when discarding the iterator's
stack.
......
......@@ -3096,22 +3096,29 @@ Otherwise returns nil.")
filename = ENCODE_FILE (filename);
bufsize = 100;
while (1)
bufsize = 50;
buf = NULL;
do
{
buf = (char *) xmalloc (bufsize);
bufsize *= 2;
buf = (char *) xrealloc (buf, bufsize);
bzero (buf, bufsize);
errno = 0;
valsize = readlink (XSTRING (filename)->data, buf, bufsize);
if (valsize < bufsize) break;
/* Buffer was not long enough */
xfree (buf);
bufsize *= 2;
}
if (valsize == -1)
{
xfree (buf);
return Qnil;
if (valsize == -1
#ifdef ERANGE
/* HP-UX reports ERANGE if buffer is too small. */
&& errno != ERANGE
#endif
)
{
xfree (buf);
return Qnil;
}
}
while (valsize >= bufsize);
val = make_string (buf, valsize);
if (buf[0] == '/' && index (buf, ':'))
val = concat2 (build_string ("/:"), val);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment