# HG changeset patch # User Gerd Moellmann # Date 1000389694 0 # Node ID 269a01a4ee76da363115304c704caed1114f55c4 # Parent bc862ea297a8bc8a8b9ef4effa3ca122182d93e0 (Ffile_symlink_p): If readlink returns ERANGE, take that to mean that the buffer is too small. diff -r bc862ea297a8 -r 269a01a4ee76 src/fileio.c --- a/src/fileio.c Thu Sep 13 13:05:37 2001 +0000 +++ b/src/fileio.c Thu Sep 13 14:01:34 2001 +0000 @@ -3096,22 +3096,29 @@ 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 +#ifdef ERANGE + /* HP-UX reports ERANGE if buffer is too small. */ + && errno != ERANGE +#endif + ) + { + xfree (buf); + return Qnil; + } } - if (valsize == -1) - { - xfree (buf); - return Qnil; - } + while (valsize >= bufsize); + val = make_string (buf, valsize); if (buf[0] == '/' && index (buf, ':')) val = concat2 (build_string ("/:"), val);