diff options
| author | Gerd Moellmann | 2001-09-13 14:01:54 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-09-13 14:01:54 +0000 |
| commit | 81c3310d7b1ddb7970077a85068b1dc8b502042a (patch) | |
| tree | 2b2bad13c6cc87e0d122f81ac249623d818a835a /src | |
| parent | 06fd37928647545543f38e46c115406add2339e2 (diff) | |
| download | emacs-81c3310d7b1ddb7970077a85068b1dc8b502042a.tar.gz emacs-81c3310d7b1ddb7970077a85068b1dc8b502042a.zip | |
(Ffile_symlink_p): If readlink returns ERANGE, take
that to mean that the buffer is too small.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/fileio.c | 31 |
2 files changed, 22 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d1741c8a7ce..c053a1530d1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2001-09-13 Gerd Moellmann <gerd@gnu.org> | 1 | 2001-09-13 Gerd Moellmann <gerd@gnu.org> |
| 2 | 2 | ||
| 3 | * fileio.c (Ffile_symlink_p): If readlink returns ERANGE, take | ||
| 4 | that to mean that the buffer is too small. | ||
| 5 | |||
| 3 | * xdisp.c (reseat_1): Set IT's multibyte_p flag according to the | 6 | * xdisp.c (reseat_1): Set IT's multibyte_p flag according to the |
| 4 | current buffer's multibyteness when discarding the iterator's | 7 | current buffer's multibyteness when discarding the iterator's |
| 5 | stack. | 8 | stack. |
diff --git a/src/fileio.c b/src/fileio.c index 1a90e511322..eba2ac0bbaf 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -3096,22 +3096,29 @@ Otherwise returns nil.") | |||
| 3096 | 3096 | ||
| 3097 | filename = ENCODE_FILE (filename); | 3097 | filename = ENCODE_FILE (filename); |
| 3098 | 3098 | ||
| 3099 | bufsize = 100; | 3099 | bufsize = 50; |
| 3100 | while (1) | 3100 | buf = NULL; |
| 3101 | do | ||
| 3101 | { | 3102 | { |
| 3102 | buf = (char *) xmalloc (bufsize); | 3103 | bufsize *= 2; |
| 3104 | buf = (char *) xrealloc (buf, bufsize); | ||
| 3103 | bzero (buf, bufsize); | 3105 | bzero (buf, bufsize); |
| 3106 | |||
| 3107 | errno = 0; | ||
| 3104 | valsize = readlink (XSTRING (filename)->data, buf, bufsize); | 3108 | valsize = readlink (XSTRING (filename)->data, buf, bufsize); |
| 3105 | if (valsize < bufsize) break; | 3109 | if (valsize == -1 |
| 3106 | /* Buffer was not long enough */ | 3110 | #ifdef ERANGE |
| 3107 | xfree (buf); | 3111 | /* HP-UX reports ERANGE if buffer is too small. */ |
| 3108 | bufsize *= 2; | 3112 | && errno != ERANGE |
| 3109 | } | 3113 | #endif |
| 3110 | if (valsize == -1) | 3114 | ) |
| 3111 | { | 3115 | { |
| 3112 | xfree (buf); | 3116 | xfree (buf); |
| 3113 | return Qnil; | 3117 | return Qnil; |
| 3118 | } | ||
| 3114 | } | 3119 | } |
| 3120 | while (valsize >= bufsize); | ||
| 3121 | |||
| 3115 | val = make_string (buf, valsize); | 3122 | val = make_string (buf, valsize); |
| 3116 | if (buf[0] == '/' && index (buf, ':')) | 3123 | if (buf[0] == '/' && index (buf, ':')) |
| 3117 | val = concat2 (build_string ("/:"), val); | 3124 | val = concat2 (build_string ("/:"), val); |