aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-11-16 19:47:06 +0200
committerEli Zaretskii2013-11-16 19:47:06 +0200
commita868f601ebc7b6e81a55b5869fa6c0ab74bde633 (patch)
tree28d55454ad96410f40504c9bba4b4c6ab50b7b21 /src
parent8dc689ce3897b6a11877ecf9140fec859f1b95a5 (diff)
downloademacs-a868f601ebc7b6e81a55b5869fa6c0ab74bde633.tar.gz
emacs-a868f601ebc7b6e81a55b5869fa6c0ab74bde633.zip
Converted and fixed w32_delayed_load.
Diffstat (limited to 'src')
-rw-r--r--src/w32.c70
1 files changed, 53 insertions, 17 deletions
diff --git a/src/w32.c b/src/w32.c
index ac2878a95fd..6f8a59c5703 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -8119,7 +8119,7 @@ sys_localtime (const time_t *t)
8119HMODULE 8119HMODULE
8120w32_delayed_load (Lisp_Object library_id) 8120w32_delayed_load (Lisp_Object library_id)
8121{ 8121{
8122 HMODULE library_dll = NULL; 8122 HMODULE dll_handle = NULL;
8123 8123
8124 CHECK_SYMBOL (library_id); 8124 CHECK_SYMBOL (library_id);
8125 8125
@@ -8132,26 +8132,56 @@ w32_delayed_load (Lisp_Object library_id)
8132 if (CONSP (dlls)) 8132 if (CONSP (dlls))
8133 for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls)) 8133 for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls))
8134 { 8134 {
8135 CHECK_STRING_CAR (dlls); 8135 Lisp_Object dll = XCAR (dlls);
8136 if ((library_dll = LoadLibrary (SDATA (XCAR (dlls))))) 8136 char name[MAX_UTF8_PATH];
8137 { 8137 DWORD res = -1;
8138 char name[MAX_PATH]; 8138
8139 DWORD len; 8139 CHECK_STRING (dll);
8140 8140 dll = ENCODE_FILE (dll);
8141 len = GetModuleFileNameA (library_dll, name, sizeof (name)); 8141 if (w32_unicode_filenames)
8142 found = Fcons (XCAR (dlls), 8142 {
8143 (len > 0) 8143 wchar_t name_w[MAX_PATH];
8144 /* Possibly truncated */ 8144
8145 ? make_specified_string (name, -1, len, 1) 8145 filename_to_utf16 (SSDATA (dll), name_w);
8146 : Qnil); 8146 dll_handle = LoadLibraryW (name_w);
8147 break; 8147 if (dll_handle)
8148 } 8148 {
8149 } 8149 res = GetModuleFileNameW (dll_handle, name_w,
8150 sizeof (name_w));
8151 if (res > 0)
8152 filename_from_utf16 (name_w, name);
8153 }
8154 }
8155 else
8156 {
8157 char name_a[MAX_PATH];
8158
8159 filename_to_ansi (SSDATA (dll), name_a);
8160 dll_handle = LoadLibraryA (name_a);
8161 if (dll_handle)
8162 {
8163 res = GetModuleFileNameA (dll_handle, name_a,
8164 sizeof (name_a));
8165 if (res > 0)
8166 filename_from_ansi (name_a, name);
8167 }
8168 }
8169 if (dll_handle)
8170 {
8171 ptrdiff_t len = strlen (name);
8172 found = Fcons (dll,
8173 (res > 0)
8174 /* Possibly truncated */
8175 ? make_specified_string (name, -1, len, 1)
8176 : Qnil);
8177 break;
8178 }
8179 }
8150 8180
8151 Fput (library_id, QCloaded_from, found); 8181 Fput (library_id, QCloaded_from, found);
8152 } 8182 }
8153 8183
8154 return library_dll; 8184 return dll_handle;
8155} 8185}
8156 8186
8157 8187
@@ -8170,6 +8200,12 @@ check_windows_init_file (void)
8170 Lisp_Object init_file; 8200 Lisp_Object init_file;
8171 int fd; 8201 int fd;
8172 8202
8203 /* Implementation note: this function runs early during Emacs
8204 startup, before startup.el is run. So Vload_path is still in
8205 its initial unibyte form, holding ANSI-encoded file names.
8206 That is why we never bother to ENCODE_FILE here, nor use wide
8207 APIs for file names: we will never get UTF-8 encoded file
8208 names here. */
8173 init_file = build_string ("term/w32-win"); 8209 init_file = build_string ("term/w32-win");
8174 fd = openp (Vload_path, init_file, Fget_load_suffixes (), NULL, Qnil); 8210 fd = openp (Vload_path, init_file, Fget_load_suffixes (), NULL, Qnil);
8175 if (fd < 0) 8211 if (fd < 0)