diff options
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/src/lread.c b/src/lread.c index 78ff195e990..d24da729df6 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1124,6 +1124,22 @@ Return t if the file exists and loads successfully. */) | |||
| 1124 | handler = Ffind_file_name_handler (found, Qload); | 1124 | handler = Ffind_file_name_handler (found, Qload); |
| 1125 | if (! NILP (handler)) | 1125 | if (! NILP (handler)) |
| 1126 | return call5 (handler, Qload, found, noerror, nomessage, Qt); | 1126 | return call5 (handler, Qload, found, noerror, nomessage, Qt); |
| 1127 | #ifdef DOS_NT | ||
| 1128 | /* Tramp has to deal with semi-broken packages that prepend | ||
| 1129 | drive letters to remote files. For that reason, Tramp | ||
| 1130 | catches file operations that test for file existence, which | ||
| 1131 | makes openp think X:/foo.elc files are remote. However, | ||
| 1132 | Tramp does not catch `load' operations for such files, so we | ||
| 1133 | end up with a nil as the `load' handler above. If we would | ||
| 1134 | continue with fd = -2, we will behave wrongly, and in | ||
| 1135 | particular try reading a .elc file in the "rt" mode instead | ||
| 1136 | of "rb". See bug #9311 for the results. To work around | ||
| 1137 | this, we try to open the file locally, and go with that if it | ||
| 1138 | succeeds. */ | ||
| 1139 | fd = emacs_open (SSDATA (ENCODE_FILE (found)), O_RDONLY, 0); | ||
| 1140 | if (fd == -1) | ||
| 1141 | fd = -2; | ||
| 1142 | #endif | ||
| 1127 | } | 1143 | } |
| 1128 | 1144 | ||
| 1129 | /* Check if we're stuck in a recursive load cycle. | 1145 | /* Check if we're stuck in a recursive load cycle. |
| @@ -1247,9 +1263,17 @@ Return t if the file exists and loads successfully. */) | |||
| 1247 | GCPRO3 (file, found, hist_file_name); | 1263 | GCPRO3 (file, found, hist_file_name); |
| 1248 | 1264 | ||
| 1249 | #ifdef WINDOWSNT | 1265 | #ifdef WINDOWSNT |
| 1250 | emacs_close (fd); | ||
| 1251 | efound = ENCODE_FILE (found); | 1266 | efound = ENCODE_FILE (found); |
| 1252 | stream = fopen (SSDATA (efound), fmode); | 1267 | /* If we somehow got here with fd == -2, meaning the file is deemed |
| 1268 | to be remote, don't even try to reopen the file locally; just | ||
| 1269 | force a failure instead. */ | ||
| 1270 | if (fd >= 0) | ||
| 1271 | { | ||
| 1272 | emacs_close (fd); | ||
| 1273 | stream = fopen (SSDATA (efound), fmode); | ||
| 1274 | } | ||
| 1275 | else | ||
| 1276 | stream = NULL; | ||
| 1253 | #else /* not WINDOWSNT */ | 1277 | #else /* not WINDOWSNT */ |
| 1254 | stream = fdopen (fd, fmode); | 1278 | stream = fdopen (fd, fmode); |
| 1255 | #endif /* not WINDOWSNT */ | 1279 | #endif /* not WINDOWSNT */ |
| @@ -2613,14 +2637,14 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2613 | 2637 | ||
| 2614 | if (saved_doc_string_size == 0) | 2638 | if (saved_doc_string_size == 0) |
| 2615 | { | 2639 | { |
| 2640 | saved_doc_string = (char *) xmalloc (nskip + extra); | ||
| 2616 | saved_doc_string_size = nskip + extra; | 2641 | saved_doc_string_size = nskip + extra; |
| 2617 | saved_doc_string = (char *) xmalloc (saved_doc_string_size); | ||
| 2618 | } | 2642 | } |
| 2619 | if (nskip > saved_doc_string_size) | 2643 | if (nskip > saved_doc_string_size) |
| 2620 | { | 2644 | { |
| 2621 | saved_doc_string_size = nskip + extra; | ||
| 2622 | saved_doc_string = (char *) xrealloc (saved_doc_string, | 2645 | saved_doc_string = (char *) xrealloc (saved_doc_string, |
| 2623 | saved_doc_string_size); | 2646 | nskip + extra); |
| 2647 | saved_doc_string_size = nskip + extra; | ||
| 2624 | } | 2648 | } |
| 2625 | 2649 | ||
| 2626 | saved_doc_string_position = file_tell (instream); | 2650 | saved_doc_string_position = file_tell (instream); |
| @@ -2883,7 +2907,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2883 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 2907 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 2884 | memory_full (SIZE_MAX); | 2908 | memory_full (SIZE_MAX); |
| 2885 | read_buffer = (char *) xrealloc (read_buffer, | 2909 | read_buffer = (char *) xrealloc (read_buffer, |
| 2886 | read_buffer_size *= 2); | 2910 | read_buffer_size * 2); |
| 2911 | read_buffer_size *= 2; | ||
| 2887 | p = read_buffer + offset; | 2912 | p = read_buffer + offset; |
| 2888 | end = read_buffer + read_buffer_size; | 2913 | end = read_buffer + read_buffer_size; |
| 2889 | } | 2914 | } |
| @@ -3026,7 +3051,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3026 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 3051 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 3027 | memory_full (SIZE_MAX); | 3052 | memory_full (SIZE_MAX); |
| 3028 | read_buffer = (char *) xrealloc (read_buffer, | 3053 | read_buffer = (char *) xrealloc (read_buffer, |
| 3029 | read_buffer_size *= 2); | 3054 | read_buffer_size * 2); |
| 3055 | read_buffer_size *= 2; | ||
| 3030 | p = read_buffer + offset; | 3056 | p = read_buffer + offset; |
| 3031 | end = read_buffer + read_buffer_size; | 3057 | end = read_buffer + read_buffer_size; |
| 3032 | } | 3058 | } |
| @@ -3056,7 +3082,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3056 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 3082 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 3057 | memory_full (SIZE_MAX); | 3083 | memory_full (SIZE_MAX); |
| 3058 | read_buffer = (char *) xrealloc (read_buffer, | 3084 | read_buffer = (char *) xrealloc (read_buffer, |
| 3059 | read_buffer_size *= 2); | 3085 | read_buffer_size * 2); |
| 3086 | read_buffer_size *= 2; | ||
| 3060 | p = read_buffer + offset; | 3087 | p = read_buffer + offset; |
| 3061 | end = read_buffer + read_buffer_size; | 3088 | end = read_buffer + read_buffer_size; |
| 3062 | } | 3089 | } |
| @@ -3938,6 +3965,7 @@ void | |||
| 3938 | init_obarray (void) | 3965 | init_obarray (void) |
| 3939 | { | 3966 | { |
| 3940 | Lisp_Object oblength; | 3967 | Lisp_Object oblength; |
| 3968 | ptrdiff_t size = 100 + MAX_MULTIBYTE_LENGTH; | ||
| 3941 | 3969 | ||
| 3942 | XSETFASTINT (oblength, OBARRAY_SIZE); | 3970 | XSETFASTINT (oblength, OBARRAY_SIZE); |
| 3943 | 3971 | ||
| @@ -3970,8 +3998,8 @@ init_obarray (void) | |||
| 3970 | 3998 | ||
| 3971 | DEFSYM (Qvariable_documentation, "variable-documentation"); | 3999 | DEFSYM (Qvariable_documentation, "variable-documentation"); |
| 3972 | 4000 | ||
| 3973 | read_buffer_size = 100 + MAX_MULTIBYTE_LENGTH; | 4001 | read_buffer = (char *) xmalloc (size); |
| 3974 | read_buffer = (char *) xmalloc (read_buffer_size); | 4002 | read_buffer_size = size; |
| 3975 | } | 4003 | } |
| 3976 | 4004 | ||
| 3977 | void | 4005 | void |