diff options
| author | Eli Zaretskii | 2020-04-16 09:14:07 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2020-04-16 09:14:07 +0300 |
| commit | 490f279c7e05e81bcc07e03c315aead27524f0a7 (patch) | |
| tree | 5b65367ce52a4029ee67d2c8c3e81a4e2596c453 /src | |
| parent | e16374507f8c51c61f0f1a276308144baf8d6489 (diff) | |
| download | emacs-490f279c7e05e81bcc07e03c315aead27524f0a7.tar.gz emacs-490f279c7e05e81bcc07e03c315aead27524f0a7.zip | |
File-handling cleanup in w32image.c
* src/w32image.c (w32_load_image): Encode the image file name and
convert it via 'map_w32_filename'. No need to do anything special
when 'w32_unicode_filenames' is zero, since file names are in
UTF-8 internally, and this code will never run on Windows 9X.
* src/w32.h (map_w32_filename): Add prototype; removed prototypes
from all *.c files.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 2 | ||||
| -rw-r--r-- | src/w32.h | 1 | ||||
| -rw-r--r-- | src/w32fns.c | 1 | ||||
| -rw-r--r-- | src/w32image.c | 19 |
4 files changed, 9 insertions, 14 deletions
| @@ -3441,8 +3441,6 @@ is_fat_volume (const char * name, const char ** pPath) | |||
| 3441 | /* Convert all slashes in a filename to backslashes, and map filename | 3441 | /* Convert all slashes in a filename to backslashes, and map filename |
| 3442 | to a valid 8.3 name if necessary. The result is a pointer to a | 3442 | to a valid 8.3 name if necessary. The result is a pointer to a |
| 3443 | static buffer, so CAVEAT EMPTOR! */ | 3443 | static buffer, so CAVEAT EMPTOR! */ |
| 3444 | const char *map_w32_filename (const char *, const char **); | ||
| 3445 | |||
| 3446 | const char * | 3444 | const char * |
| 3447 | map_w32_filename (const char * name, const char ** pPath) | 3445 | map_w32_filename (const char * name, const char ** pPath) |
| 3448 | { | 3446 | { |
| @@ -194,6 +194,7 @@ extern void syms_of_ntproc (void); | |||
| 194 | extern void syms_of_ntterm (void); | 194 | extern void syms_of_ntterm (void); |
| 195 | extern void dostounix_filename (register char *); | 195 | extern void dostounix_filename (register char *); |
| 196 | extern void unixtodos_filename (register char *); | 196 | extern void unixtodos_filename (register char *); |
| 197 | extern const char *map_w32_filename (const char *, const char **); | ||
| 197 | extern int filename_from_ansi (const char *, char *); | 198 | extern int filename_from_ansi (const char *, char *); |
| 198 | extern int filename_to_ansi (const char *, char *); | 199 | extern int filename_to_ansi (const char *, char *); |
| 199 | extern int filename_from_utf16 (const wchar_t *, char *); | 200 | extern int filename_from_utf16 (const wchar_t *, char *); |
diff --git a/src/w32fns.c b/src/w32fns.c index 4f7cbed249d..e595b0285a7 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -80,7 +80,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 80 | extern int w32_console_toggle_lock_key (int, Lisp_Object); | 80 | extern int w32_console_toggle_lock_key (int, Lisp_Object); |
| 81 | extern void w32_menu_display_help (HWND, HMENU, UINT, UINT); | 81 | extern void w32_menu_display_help (HWND, HMENU, UINT, UINT); |
| 82 | extern void w32_free_menu_strings (HWND); | 82 | extern void w32_free_menu_strings (HWND); |
| 83 | extern const char *map_w32_filename (const char *, const char **); | ||
| 84 | 83 | ||
| 85 | #ifndef IDC_HAND | 84 | #ifndef IDC_HAND |
| 86 | #define IDC_HAND MAKEINTRESOURCE(32649) | 85 | #define IDC_HAND MAKEINTRESOURCE(32649) |
diff --git a/src/w32image.c b/src/w32image.c index fb36dc9a9f6..80c3247e97d 100644 --- a/src/w32image.c +++ b/src/w32image.c | |||
| @@ -32,6 +32,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 32 | #include <shlwapi.h> | 32 | #include <shlwapi.h> |
| 33 | #include "w32common.h" | 33 | #include "w32common.h" |
| 34 | #include "w32term.h" | 34 | #include "w32term.h" |
| 35 | #ifdef WINDOWSNT | ||
| 36 | #include "w32.h" /* for map_w32_filename, filename_to_utf16 */ | ||
| 37 | #endif | ||
| 35 | #include "frame.h" | 38 | #include "frame.h" |
| 36 | #include "coding.h" | 39 | #include "coding.h" |
| 37 | 40 | ||
| @@ -334,17 +337,11 @@ w32_load_image (struct frame *f, struct image *img, | |||
| 334 | and succeeded. We have a valid token and GDI+ is active. */ | 337 | and succeeded. We have a valid token and GDI+ is active. */ |
| 335 | if (STRINGP (spec_file)) | 338 | if (STRINGP (spec_file)) |
| 336 | { | 339 | { |
| 337 | if (w32_unicode_filenames) | 340 | spec_file = ENCODE_FILE (spec_file); |
| 338 | { | 341 | const char *fn = map_w32_filename (SSDATA (spec_file), NULL); |
| 339 | wchar_t filename[MAX_PATH]; | 342 | wchar_t filename_w[MAX_PATH]; |
| 340 | filename_to_utf16 (SSDATA (spec_file), filename); | 343 | filename_to_utf16 (fn, filename_w); |
| 341 | status = GdipCreateBitmapFromFile (filename, &pBitmap); | 344 | status = GdipCreateBitmapFromFile (filename_w, &pBitmap); |
| 342 | } | ||
| 343 | else | ||
| 344 | { | ||
| 345 | add_to_log ("GDI+ requires w32-unicode-filenames to be T"); | ||
| 346 | status = GenericError; | ||
| 347 | } | ||
| 348 | } | 345 | } |
| 349 | else if (STRINGP (spec_data)) | 346 | else if (STRINGP (spec_data)) |
| 350 | { | 347 | { |