diff options
| author | Eli Zaretskii | 2013-12-03 17:29:48 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-12-03 17:29:48 +0200 |
| commit | 9ab69568723b5f3e7c668ab6de2b383106f84c2d (patch) | |
| tree | 00e77ad2fbb8f25883381acef5c53d35e58dfaa2 /src | |
| parent | d45c90885962da97a8d72d2ffb8ce38046d8cb58 (diff) | |
| download | emacs-9ab69568723b5f3e7c668ab6de2b383106f84c2d.tar.gz emacs-9ab69568723b5f3e7c668ab6de2b383106f84c2d.zip | |
Converted image.c and gnutls.c functions that accept file names.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gnutls.c | 18 | ||||
| -rw-r--r-- | src/image.c | 15 | ||||
| -rw-r--r-- | src/w32.c | 30 | ||||
| -rw-r--r-- | src/w32.h | 1 |
4 files changed, 64 insertions, 0 deletions
diff --git a/src/gnutls.c b/src/gnutls.c index 82b2fc8baa4..19617cea4b2 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -21,6 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 21 | 21 | ||
| 22 | #include "lisp.h" | 22 | #include "lisp.h" |
| 23 | #include "process.h" | 23 | #include "process.h" |
| 24 | #include "coding.h" | ||
| 24 | 25 | ||
| 25 | #ifdef HAVE_GNUTLS | 26 | #ifdef HAVE_GNUTLS |
| 26 | #include <gnutls/gnutls.h> | 27 | #include <gnutls/gnutls.h> |
| @@ -895,6 +896,13 @@ one trustfile (usually a CA bundle). */) | |||
| 895 | { | 896 | { |
| 896 | GNUTLS_LOG2 (1, max_log_level, "setting the trustfile: ", | 897 | GNUTLS_LOG2 (1, max_log_level, "setting the trustfile: ", |
| 897 | SSDATA (trustfile)); | 898 | SSDATA (trustfile)); |
| 899 | trustfile = ENCODE_FILE (trustfile); | ||
| 900 | #ifdef WINDOWSNT | ||
| 901 | /* Since GnuTLS doesn't support UTF-8 or UTF-16 encoded | ||
| 902 | file names on Windows, we need to re-encode the file | ||
| 903 | name using the current ANSI codepage. */ | ||
| 904 | trustfile = ansi_encode_filename (trustfile); | ||
| 905 | #endif | ||
| 898 | ret = fn_gnutls_certificate_set_x509_trust_file | 906 | ret = fn_gnutls_certificate_set_x509_trust_file |
| 899 | (x509_cred, | 907 | (x509_cred, |
| 900 | SSDATA (trustfile), | 908 | SSDATA (trustfile), |
| @@ -917,6 +925,10 @@ one trustfile (usually a CA bundle). */) | |||
| 917 | { | 925 | { |
| 918 | GNUTLS_LOG2 (1, max_log_level, "setting the CRL file: ", | 926 | GNUTLS_LOG2 (1, max_log_level, "setting the CRL file: ", |
| 919 | SSDATA (crlfile)); | 927 | SSDATA (crlfile)); |
| 928 | crlfile = ENCODE_FILE (crlfile); | ||
| 929 | #ifdef WINDOWSNT | ||
| 930 | crlfile = ansi_encode_filename (crlfile); | ||
| 931 | #endif | ||
| 920 | ret = fn_gnutls_certificate_set_x509_crl_file | 932 | ret = fn_gnutls_certificate_set_x509_crl_file |
| 921 | (x509_cred, SSDATA (crlfile), file_format); | 933 | (x509_cred, SSDATA (crlfile), file_format); |
| 922 | 934 | ||
| @@ -940,6 +952,12 @@ one trustfile (usually a CA bundle). */) | |||
| 940 | SSDATA (keyfile)); | 952 | SSDATA (keyfile)); |
| 941 | GNUTLS_LOG2 (1, max_log_level, "setting the client cert file: ", | 953 | GNUTLS_LOG2 (1, max_log_level, "setting the client cert file: ", |
| 942 | SSDATA (certfile)); | 954 | SSDATA (certfile)); |
| 955 | keyfile = ENCODE_FILE (keyfile); | ||
| 956 | certfile = ENCODE_FILE (certfile); | ||
| 957 | #ifdef WINDOWSNT | ||
| 958 | keyfile = ansi_encode_filename (keyfile); | ||
| 959 | certfile = ansi_encode_filename (certfile); | ||
| 960 | #endif | ||
| 943 | ret = fn_gnutls_certificate_set_x509_key_file | 961 | ret = fn_gnutls_certificate_set_x509_key_file |
| 944 | (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_format); | 962 | (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_format); |
| 945 | 963 | ||
diff --git a/src/image.c b/src/image.c index 37a19e4f5a5..89e4f863d53 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -3590,6 +3590,12 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3590 | } | 3590 | } |
| 3591 | 3591 | ||
| 3592 | #ifdef HAVE_NTGUI | 3592 | #ifdef HAVE_NTGUI |
| 3593 | #ifdef WINDOWSNT | ||
| 3594 | /* FILE is encoded in UTF-8, but image libraries on Windows | ||
| 3595 | support neither UTF-8 nor UTF-16 encoded file names. So we | ||
| 3596 | need to re-encode it in ANSI. */ | ||
| 3597 | file = ansi_encode_filename (file); | ||
| 3598 | #endif | ||
| 3593 | /* XpmReadFileToPixmap is not available in the Windows port of | 3599 | /* XpmReadFileToPixmap is not available in the Windows port of |
| 3594 | libxpm. But XpmReadFileToImage almost does what we want. */ | 3600 | libxpm. But XpmReadFileToImage almost does what we want. */ |
| 3595 | rc = fn_XpmReadFileToImage (&hdc, SDATA (file), | 3601 | rc = fn_XpmReadFileToImage (&hdc, SDATA (file), |
| @@ -6968,6 +6974,9 @@ tiff_load (struct frame *f, struct image *img) | |||
| 6968 | image_error ("Cannot find image file `%s'", specified_file, Qnil); | 6974 | image_error ("Cannot find image file `%s'", specified_file, Qnil); |
| 6969 | return 0; | 6975 | return 0; |
| 6970 | } | 6976 | } |
| 6977 | #ifdef WINDOWSNT | ||
| 6978 | file = ansi_encode_filename (file); | ||
| 6979 | #endif | ||
| 6971 | 6980 | ||
| 6972 | /* Try to open the image file. */ | 6981 | /* Try to open the image file. */ |
| 6973 | tiff = fn_TIFFOpen (SSDATA (file), "r"); | 6982 | tiff = fn_TIFFOpen (SSDATA (file), "r"); |
| @@ -7353,6 +7362,9 @@ gif_load (struct frame *f, struct image *img) | |||
| 7353 | image_error ("Cannot find image file `%s'", specified_file, Qnil); | 7362 | image_error ("Cannot find image file `%s'", specified_file, Qnil); |
| 7354 | return 0; | 7363 | return 0; |
| 7355 | } | 7364 | } |
| 7365 | #ifdef WINDOWSNT | ||
| 7366 | file = ansi_encode_filename (file); | ||
| 7367 | #endif | ||
| 7356 | 7368 | ||
| 7357 | /* Open the GIF file. */ | 7369 | /* Open the GIF file. */ |
| 7358 | #if GIFLIB_MAJOR < 5 | 7370 | #if GIFLIB_MAJOR < 5 |
| @@ -8479,6 +8491,9 @@ imagemagick_load (struct frame *f, struct image *img) | |||
| 8479 | image_error ("Cannot find image file `%s'", file_name, Qnil); | 8491 | image_error ("Cannot find image file `%s'", file_name, Qnil); |
| 8480 | return 0; | 8492 | return 0; |
| 8481 | } | 8493 | } |
| 8494 | #ifdef WINDOWSNT | ||
| 8495 | file = ansi_encode_filename (file); | ||
| 8496 | #endif | ||
| 8482 | success_p = imagemagick_load_image (f, img, 0, 0, SSDATA (file)); | 8497 | success_p = imagemagick_load_image (f, img, 0, 0, SSDATA (file)); |
| 8483 | } | 8498 | } |
| 8484 | /* Else its not a file, its a lisp object. Load the image from a | 8499 | /* Else its not a file, its a lisp object. Load the image from a |
| @@ -2135,6 +2135,36 @@ w32_get_short_filename (char * name, char * buf, int size) | |||
| 2135 | } | 2135 | } |
| 2136 | } | 2136 | } |
| 2137 | 2137 | ||
| 2138 | /* Re-encode FILENAME, a UTF-8 encoded unibyte string, using the | ||
| 2139 | MS-Windows ANSI codepage. If FILENAME includes characters not | ||
| 2140 | supported by the ANSI codepage, return the 8+3 alias of FILENAME, | ||
| 2141 | if it exists. This is needed because the w32 build wants to | ||
| 2142 | support file names outside of the system locale, but image | ||
| 2143 | libraries typically don't support wide (a.k.a. "Unicode") APIs | ||
| 2144 | required for that. */ | ||
| 2145 | |||
| 2146 | Lisp_Object | ||
| 2147 | ansi_encode_filename (Lisp_Object filename) | ||
| 2148 | { | ||
| 2149 | Lisp_Object encoded_filename; | ||
| 2150 | char fname[MAX_PATH]; | ||
| 2151 | |||
| 2152 | filename_to_ansi (SSDATA (filename), fname); | ||
| 2153 | if (_mbspbrk (fname, "?")) | ||
| 2154 | { | ||
| 2155 | char shortname[MAX_PATH]; | ||
| 2156 | |||
| 2157 | if (w32_get_short_filename (SDATA (filename), shortname, MAX_PATH)) | ||
| 2158 | { | ||
| 2159 | dostounix_filename (shortname); | ||
| 2160 | encoded_filename = build_string (shortname); | ||
| 2161 | } | ||
| 2162 | } | ||
| 2163 | else | ||
| 2164 | encoded_filename = build_unibyte_string (fname); | ||
| 2165 | return encoded_filename; | ||
| 2166 | } | ||
| 2167 | |||
| 2138 | static int | 2168 | static int |
| 2139 | is_unc_volume (const char *filename) | 2169 | is_unc_volume (const char *filename) |
| 2140 | { | 2170 | { |
| @@ -184,6 +184,7 @@ extern int filename_from_ansi (const char *, char *); | |||
| 184 | extern int filename_to_ansi (const char *, char *); | 184 | extern int filename_to_ansi (const char *, char *); |
| 185 | extern int filename_from_utf16 (const wchar_t *, char *); | 185 | extern int filename_from_utf16 (const wchar_t *, char *); |
| 186 | extern int filename_to_utf16 (const char *, wchar_t *); | 186 | extern int filename_to_utf16 (const char *, wchar_t *); |
| 187 | extern Lisp_Object ansi_encode_filename (Lisp_Object); | ||
| 187 | 188 | ||
| 188 | extern BOOL init_winsock (int load_now); | 189 | extern BOOL init_winsock (int load_now); |
| 189 | extern void srandom (int); | 190 | extern void srandom (int); |