diff options
| author | K. Handa | 2014-12-28 22:18:39 +0900 |
|---|---|---|
| committer | K. Handa | 2014-12-28 22:18:39 +0900 |
| commit | c2f9c07aa02d1c8cba4efdd503463642a910cd6b (patch) | |
| tree | 8e25338f25fe6d71a72cddff77f4c368192379ef /src | |
| parent | 5979af512bf5d6a28acea24299b67c7939d9e703 (diff) | |
| parent | e092accb6bb8aea08dab1796d707b3adce55a38c (diff) | |
| download | emacs-c2f9c07aa02d1c8cba4efdd503463642a910cd6b.tar.gz emacs-c2f9c07aa02d1c8cba4efdd503463642a910cd6b.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 123 | ||||
| -rw-r--r-- | src/buffer.c | 4 | ||||
| -rw-r--r-- | src/callproc.c | 7 | ||||
| -rw-r--r-- | src/composite.c | 3 | ||||
| -rw-r--r-- | src/dbusbind.c | 2 | ||||
| -rw-r--r-- | src/decompress.c | 51 | ||||
| -rw-r--r-- | src/dispextern.h | 5 | ||||
| -rw-r--r-- | src/doc.c | 33 | ||||
| -rw-r--r-- | src/editfns.c | 5 | ||||
| -rw-r--r-- | src/frame.c | 20 | ||||
| -rw-r--r-- | src/gnutls.c | 775 | ||||
| -rw-r--r-- | src/gtkutil.c | 6 | ||||
| -rw-r--r-- | src/image.c | 932 | ||||
| -rw-r--r-- | src/keyboard.c | 2 | ||||
| -rw-r--r-- | src/nsimage.m | 8 | ||||
| -rw-r--r-- | src/tparam.c | 4 | ||||
| -rw-r--r-- | src/w32.c | 13 | ||||
| -rw-r--r-- | src/w32.h | 13 | ||||
| -rw-r--r-- | src/w32menu.c | 6 | ||||
| -rw-r--r-- | src/w32proc.c | 15 | ||||
| -rw-r--r-- | src/xdisp.c | 171 | ||||
| -rw-r--r-- | src/xfns.c | 34 | ||||
| -rw-r--r-- | src/xml.c | 94 | ||||
| -rw-r--r-- | src/xrdb.c | 44 | ||||
| -rw-r--r-- | src/xselect.c | 95 | ||||
| -rw-r--r-- | src/xsettings.c | 94 | ||||
| -rw-r--r-- | src/xsmfns.c | 34 | ||||
| -rw-r--r-- | src/xterm.c | 10 | ||||
| -rw-r--r-- | src/xterm.h | 10 |
29 files changed, 1377 insertions, 1236 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b90471e8dea..9e3fb904b93 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,120 @@ | |||
| 1 | 2014-12-28 Paul Eggert <eggert@Penguin.CS.UCLA.EDU> | ||
| 2 | |||
| 3 | Wrap dll functions more simply | ||
| 4 | * decompress.c, gnutls.c, image.c, xml.c: | ||
| 5 | If WINDOWSNT, use '#define FOO fn_FOO' to wrap dll functions, | ||
| 6 | rather than the inverse when not WINDOWSNT. This isolates the | ||
| 7 | fn_* business into the WINDOWSNT-specific section of the code, | ||
| 8 | which makes it easier to maintain the generic code. | ||
| 9 | * decompress.c (DEF_ZLIB_FN, LOAD_ZLIB_FN): | ||
| 10 | * gnutls.c (DEF_GNUTLS_FN, LOAD_GNUTLS_FN): | ||
| 11 | * image.c (DEF_IMGLIB_FN, LOAD_IMGLIB_FN): | ||
| 12 | * xml.c (DEF_XML2_FN, LOAD_XML2_FN): | ||
| 13 | Remove. All uses replaced by DEF_DLL_FN. | ||
| 14 | * decompress.c (inflateInit2): Remove; no longer needed. | ||
| 15 | * w32.h (DEF_DLL_FN, LOAD_DLL_FN): New macros. | ||
| 16 | |||
| 17 | Port memory-full checking to GnuTLS 3.3 | ||
| 18 | Instead of using gnutls_global_set_mem_functions, check every call | ||
| 19 | to a GnuTLS function that might return an indication of memory | ||
| 20 | exhaustion. Suggested by Dmitry Antipov in: | ||
| 21 | http://lists.gnu.org/archive/html/emacs-devel/2014-12/msg02056.html | ||
| 22 | * gnutls.c (gnutls_global_set_mem_functions) [WINDOWSNT]: Remove. | ||
| 23 | (init_gnutls_functions): Do not load gnutls_global_set_mem_functions. | ||
| 24 | (fn_gnutls_global_set_mem_functions) [!WINDOWSNT]: Remove. | ||
| 25 | All uses removed. | ||
| 26 | (check_memory_full): New function. | ||
| 27 | (emacs_gnutls_handshake, emacs_gnutls_handle_error) | ||
| 28 | (gnutls_make_error, gnutls_certificate_details, Fgnutls_peer_status) | ||
| 29 | (Fgnutls_boot): Use it. | ||
| 30 | (emacs_gnutls_global_init): Avoid gnutls_global_set_mem_functions. | ||
| 31 | |||
| 32 | 2014-12-27 Paul Eggert <eggert@cs.ucla.edu> | ||
| 33 | |||
| 34 | Fix parse_settings to match internal documentation | ||
| 35 | * xsettings.c (parse_settings): Return the number of settings seen. | ||
| 36 | Count the settings changes accurately. | ||
| 37 | (read_settings): Don't confuse number of settings changes with | ||
| 38 | the return code from XGetWindowProperty. | ||
| 39 | |||
| 40 | 2014-12-27 Eli Zaretskii <eliz@gnu.org> | ||
| 41 | |||
| 42 | * xdisp.c (set_iterator_to_next) <GET_FROM_STRING>: Limit search in | ||
| 43 | composition_compute_stop_pos to the number of characters in the | ||
| 44 | string. (Bug#19435) | ||
| 45 | <GET_FROM_BUFFER, GET_FROM_STRING>: Simplify code. | ||
| 46 | |||
| 47 | * composite.c (composition_compute_stop_pos): If no composition | ||
| 48 | was found in a string before ENDPOS, and ENDPOS is the string end, | ||
| 49 | no need to back up to a safe point. | ||
| 50 | |||
| 51 | * dispextern.h (struct it) <end_charpos>: Improve commentary. | ||
| 52 | |||
| 53 | 2014-12-27 Jan Djärv <jan.h.d@swipnet.se> | ||
| 54 | |||
| 55 | * nsimage.m (allocInitFromFile:): Initialize bmRep. | ||
| 56 | (dealloc): Release bmRep. | ||
| 57 | (setPixmapData): Make bmRep local so class member is not | ||
| 58 | set (Bug#19133). | ||
| 59 | (setPixmapData): Rename local variable bmRep to avoid compiler | ||
| 60 | warning. | ||
| 61 | |||
| 62 | 2014-12-27 Jan Djärv <jan.h.d@swipnet.se> | ||
| 63 | |||
| 64 | * xterm.c (do_ewmh_fullscreen): Don't remove maximized_horz/vert | ||
| 65 | when going to fullscreen (Bug#0x180004f). | ||
| 66 | |||
| 67 | 2014-12-27 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 68 | |||
| 69 | * buffer.c (syms_of_buffer) <Vafter_change_functions>: fix docstring. | ||
| 70 | |||
| 71 | 2014-12-27 Eli Zaretskii <eliz@gnu.org> | ||
| 72 | |||
| 73 | * gnutls.c (gnutls_init): Fix deprecation warning from GCC. | ||
| 74 | |||
| 75 | 2014-12-26 Paul Eggert <eggert@cs.ucla.edu> | ||
| 76 | |||
| 77 | Use bool for boolean in xselect.c, xsettings.c | ||
| 78 | * xselect.c (x_get_local_selection, struct selection_data) | ||
| 79 | (x_selection_request_lisp_error, struct prop_location) | ||
| 80 | (x_handle_selection_request, x_convert_selection) | ||
| 81 | (waiting_for_other_props_on_window, expect_property_change) | ||
| 82 | (wait_for_property_change, x_handle_property_notify) | ||
| 83 | (x_get_foreign_selection, x_get_window_property) | ||
| 84 | (receive_incremental_selection) | ||
| 85 | (x_get_window_property_as_lisp_data) | ||
| 86 | (lisp_data_to_selection_data, Fx_get_selection_internal) | ||
| 87 | (x_send_client_event): | ||
| 88 | * xselect.c, xterm.h (x_handle_dnd_message): | ||
| 89 | * xsettings.c (dpyinfo_valid, parse_settings, read_settings) | ||
| 90 | (apply_xft_settings, read_and_apply_settings) | ||
| 91 | (xft_settings_event, init_gsettings, init_xsettings) | ||
| 92 | (syms_of_xsettings): | ||
| 93 | Use bool for boolean. | ||
| 94 | * xselect.c (x_get_window_property): Omit last arg, which was an | ||
| 95 | unused boolean. | ||
| 96 | * xsettings.c (apply_xft_settings): Remove 2nd arg, which was | ||
| 97 | always true. All callers changed. | ||
| 98 | |||
| 99 | 2014-12-26 Eli Zaretskii <eliz@gnu.org> | ||
| 100 | |||
| 101 | * w32proc.c (sys_spawnve, get_lcid_callback): Use strcpy instead | ||
| 102 | of strcat. | ||
| 103 | |||
| 104 | * w32menu.c (add_menu_item): Use stpcpy instead of strcat. | ||
| 105 | |||
| 106 | * w32.c (sys_readdir, stat_worker, symlink): Use strcpy instead of | ||
| 107 | strcat. | ||
| 108 | |||
| 109 | 2014-12-26 Paul Eggert <eggert@cs.ucla.edu> | ||
| 110 | |||
| 111 | Use bool for boolean in xsmfns.c | ||
| 112 | * xsmfns.c, xterm.h (x_session_have_connection): | ||
| 113 | * xsmfns.c (doing_interact, smc_interact_CB, Fhandle_save_session): | ||
| 114 | Use bool for boolean. | ||
| 115 | (x_session_initialize, Fhandle_save_session): | ||
| 116 | Prefer NILP (x) to EQ (x, Qnil). | ||
| 117 | |||
| 1 | 2014-12-23 Didier Verna <didier@didierverna.net> (tiny change). | 118 | 2014-12-23 Didier Verna <didier@didierverna.net> (tiny change). |
| 2 | 119 | ||
| 3 | * nsselect.m (Fns_selection_owner_p): Return a Lisp boolean, not a | 120 | * nsselect.m (Fns_selection_owner_p): Return a Lisp boolean, not a |
| @@ -202,6 +319,10 @@ | |||
| 202 | Call gnutls_certificate_set_x509_system_trust. Log an error message if | 319 | Call gnutls_certificate_set_x509_system_trust. Log an error message if |
| 203 | it fails. | 320 | it fails. |
| 204 | 321 | ||
| 322 | 2014-12-14 Paul Eggert <eggert@cs.ucla.edu> | ||
| 323 | |||
| 324 | * regex.c (analyze_first): Rename from analyze_first. | ||
| 325 | |||
| 205 | 2014-12-13 Paul Eggert <eggert@cs.ucla.edu> | 326 | 2014-12-13 Paul Eggert <eggert@cs.ucla.edu> |
| 206 | 327 | ||
| 207 | * alloc.c (XMALLOC_BASE_ALIGNMENT): Use max_align_t instead of | 328 | * alloc.c (XMALLOC_BASE_ALIGNMENT): Use max_align_t instead of |
| @@ -871,6 +992,8 @@ | |||
| 871 | * fileio.c (Fexpand_file_name): Use make_unibyte_string, not | 992 | * fileio.c (Fexpand_file_name): Use make_unibyte_string, not |
| 872 | build_string, when importing a home directory. (Bug#18873) | 993 | build_string, when importing a home directory. (Bug#18873) |
| 873 | 994 | ||
| 995 | 2014-12-27 Eli Zaretskii <eliz@gnu.org> | ||
| 996 | |||
| 874 | * dispnew.c (buffer_posn_from_coords): | 997 | * dispnew.c (buffer_posn_from_coords): |
| 875 | Use WINDOW_WANTS_HEADER_LINE_P, not WINDOW_WANTS_MODELINE_P, to | 998 | Use WINDOW_WANTS_HEADER_LINE_P, not WINDOW_WANTS_MODELINE_P, to |
| 876 | account for the header-line height. (Bug#18839) | 999 | account for the header-line height. (Bug#18839) |
diff --git a/src/buffer.c b/src/buffer.c index b57d968e73a..9a5c4a8824f 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -6066,9 +6066,9 @@ from happening repeatedly and making Emacs nonfunctional. */); | |||
| 6066 | doc: /* List of functions to call after each text change. | 6066 | doc: /* List of functions to call after each text change. |
| 6067 | Three arguments are passed to each function: the positions of | 6067 | Three arguments are passed to each function: the positions of |
| 6068 | the beginning and end of the range of changed text, | 6068 | the beginning and end of the range of changed text, |
| 6069 | and the length in bytes of the pre-change text replaced by that range. | 6069 | and the length in chars of the pre-change text replaced by that range. |
| 6070 | \(For an insertion, the pre-change length is zero; | 6070 | \(For an insertion, the pre-change length is zero; |
| 6071 | for a deletion, that length is the number of bytes deleted, | 6071 | for a deletion, that length is the number of chars deleted, |
| 6072 | and the post-change beginning and end are at the same place.) | 6072 | and the post-change beginning and end are at the same place.) |
| 6073 | 6073 | ||
| 6074 | Buffer changes made while executing the `after-change-functions' | 6074 | Buffer changes made while executing the `after-change-functions' |
diff --git a/src/callproc.c b/src/callproc.c index a677334b3b7..f40ed3244a5 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1315,13 +1315,10 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp, | |||
| 1315 | 1315 | ||
| 1316 | if (STRINGP (display)) | 1316 | if (STRINGP (display)) |
| 1317 | { | 1317 | { |
| 1318 | char *vdata; | ||
| 1319 | |||
| 1320 | if (MAX_ALLOCA - sizeof "DISPLAY=" < SBYTES (display)) | 1318 | if (MAX_ALLOCA - sizeof "DISPLAY=" < SBYTES (display)) |
| 1321 | exec_failed (new_argv[0], ENOMEM); | 1319 | exec_failed (new_argv[0], ENOMEM); |
| 1322 | vdata = alloca (sizeof "DISPLAY=" + SBYTES (display)); | 1320 | char *vdata = alloca (sizeof "DISPLAY=" + SBYTES (display)); |
| 1323 | strcpy (vdata, "DISPLAY="); | 1321 | lispstpcpy (stpcpy (vdata, "DISPLAY="), display); |
| 1324 | strcat (vdata, SSDATA (display)); | ||
| 1325 | new_env = add_env (env, new_env, vdata); | 1322 | new_env = add_env (env, new_env, vdata); |
| 1326 | } | 1323 | } |
| 1327 | 1324 | ||
diff --git a/src/composite.c b/src/composite.c index 8982c904096..0b52a9fcd2b 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -1032,7 +1032,8 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, | |||
| 1032 | } | 1032 | } |
| 1033 | } | 1033 | } |
| 1034 | } | 1034 | } |
| 1035 | if (charpos == endpos) | 1035 | if (charpos == endpos |
| 1036 | && !(STRINGP (string) && endpos == SCHARS (string))) | ||
| 1036 | { | 1037 | { |
| 1037 | /* We couldn't find a composition point before ENDPOS. But, | 1038 | /* We couldn't find a composition point before ENDPOS. But, |
| 1038 | some character after ENDPOS may be composed with | 1039 | some character after ENDPOS may be composed with |
diff --git a/src/dbusbind.c b/src/dbusbind.c index 4852739d8e4..983b05c4206 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -357,7 +357,7 @@ xd_signature_cat (char *signature, char const *x) | |||
| 357 | ptrdiff_t xlen = strlen (x); | 357 | ptrdiff_t xlen = strlen (x); |
| 358 | if (DBUS_MAXIMUM_SIGNATURE_LENGTH - xlen <= siglen) | 358 | if (DBUS_MAXIMUM_SIGNATURE_LENGTH - xlen <= siglen) |
| 359 | string_overflow (); | 359 | string_overflow (); |
| 360 | strcat (signature, x); | 360 | strcpy (signature + siglen, x); |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | /* Compute SIGNATURE of OBJECT. It must have a form that it can be | 363 | /* Compute SIGNATURE of OBJECT. It must have a form that it can be |
diff --git a/src/decompress.c b/src/decompress.c index 24ce852245c..f86aa6facbf 100644 --- a/src/decompress.c +++ b/src/decompress.c | |||
| @@ -31,26 +31,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 31 | static Lisp_Object Qzlib_dll; | 31 | static Lisp_Object Qzlib_dll; |
| 32 | 32 | ||
| 33 | #ifdef WINDOWSNT | 33 | #ifdef WINDOWSNT |
| 34 | #include <windows.h> | 34 | # include <windows.h> |
| 35 | #include "w32.h" | 35 | # include "w32.h" |
| 36 | 36 | ||
| 37 | /* Macro for defining functions that will be loaded from the zlib DLL. */ | 37 | DEF_DLL_FN (int, inflateInit2_, |
| 38 | #define DEF_ZLIB_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args | 38 | (z_streamp strm, int windowBits, const char *version, |
| 39 | 39 | int stream_size)); | |
| 40 | /* Macro for loading zlib functions from the library. */ | 40 | DEF_DLL_FN (int, inflate, (z_streamp strm, int flush)); |
| 41 | #define LOAD_ZLIB_FN(lib,func) { \ | 41 | DEF_DLL_FN (int, inflateEnd, (z_streamp strm)); |
| 42 | fn_##func = (void *) GetProcAddress (lib, #func); \ | ||
| 43 | if (!fn_##func) return false; \ | ||
| 44 | } | ||
| 45 | |||
| 46 | DEF_ZLIB_FN (int, inflateInit2_, | ||
| 47 | (z_streamp strm, int windowBits, const char *version, int stream_size)); | ||
| 48 | |||
| 49 | DEF_ZLIB_FN (int, inflate, | ||
| 50 | (z_streamp strm, int flush)); | ||
| 51 | |||
| 52 | DEF_ZLIB_FN (int, inflateEnd, | ||
| 53 | (z_streamp strm)); | ||
| 54 | 42 | ||
| 55 | static bool zlib_initialized; | 43 | static bool zlib_initialized; |
| 56 | 44 | ||
| @@ -62,20 +50,19 @@ init_zlib_functions (void) | |||
| 62 | if (!library) | 50 | if (!library) |
| 63 | return false; | 51 | return false; |
| 64 | 52 | ||
| 65 | LOAD_ZLIB_FN (library, inflateInit2_); | 53 | LOAD_DLL_FN (library, inflateInit2_); |
| 66 | LOAD_ZLIB_FN (library, inflate); | 54 | LOAD_DLL_FN (library, inflate); |
| 67 | LOAD_ZLIB_FN (library, inflateEnd); | 55 | LOAD_DLL_FN (library, inflateEnd); |
| 68 | return true; | 56 | return true; |
| 69 | } | 57 | } |
| 70 | 58 | ||
| 71 | #define fn_inflateInit2(strm, windowBits) \ | 59 | # undef inflate |
| 72 | fn_inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) | 60 | # undef inflateEnd |
| 73 | 61 | # undef inflateInit2_ | |
| 74 | #else /* !WINDOWSNT */ | ||
| 75 | 62 | ||
| 76 | #define fn_inflateInit2 inflateInit2 | 63 | # define inflate fn_inflate |
| 77 | #define fn_inflate inflate | 64 | # define inflateEnd fn_inflateEnd |
| 78 | #define fn_inflateEnd inflateEnd | 65 | # define inflateInit2_ fn_inflateInit2_ |
| 79 | 66 | ||
| 80 | #endif /* WINDOWSNT */ | 67 | #endif /* WINDOWSNT */ |
| 81 | 68 | ||
| @@ -90,7 +77,7 @@ static void | |||
| 90 | unwind_decompress (void *ddata) | 77 | unwind_decompress (void *ddata) |
| 91 | { | 78 | { |
| 92 | struct decompress_unwind_data *data = ddata; | 79 | struct decompress_unwind_data *data = ddata; |
| 93 | fn_inflateEnd (data->stream); | 80 | inflateEnd (data->stream); |
| 94 | 81 | ||
| 95 | /* Delete any uncompressed data already inserted on error. */ | 82 | /* Delete any uncompressed data already inserted on error. */ |
| 96 | if (data->start) | 83 | if (data->start) |
| @@ -167,7 +154,7 @@ This function can be called only in unibyte buffers. */) | |||
| 167 | 154 | ||
| 168 | /* The magic number 32 apparently means "autodetect both the gzip and | 155 | /* The magic number 32 apparently means "autodetect both the gzip and |
| 169 | zlib formats" according to zlib.h. */ | 156 | zlib formats" according to zlib.h. */ |
| 170 | if (fn_inflateInit2 (&stream, MAX_WBITS + 32) != Z_OK) | 157 | if (inflateInit2 (&stream, MAX_WBITS + 32) != Z_OK) |
| 171 | return Qnil; | 158 | return Qnil; |
| 172 | 159 | ||
| 173 | unwind_data.start = iend; | 160 | unwind_data.start = iend; |
| @@ -197,7 +184,7 @@ This function can be called only in unibyte buffers. */) | |||
| 197 | stream.avail_in = avail_in; | 184 | stream.avail_in = avail_in; |
| 198 | stream.next_out = GPT_ADDR; | 185 | stream.next_out = GPT_ADDR; |
| 199 | stream.avail_out = avail_out; | 186 | stream.avail_out = avail_out; |
| 200 | inflate_status = fn_inflate (&stream, Z_NO_FLUSH); | 187 | inflate_status = inflate (&stream, Z_NO_FLUSH); |
| 201 | pos_byte += avail_in - stream.avail_in; | 188 | pos_byte += avail_in - stream.avail_in; |
| 202 | decompressed = avail_out - stream.avail_out; | 189 | decompressed = avail_out - stream.avail_out; |
| 203 | insert_from_gap (decompressed, decompressed, 0); | 190 | insert_from_gap (decompressed, decompressed, 0); |
diff --git a/src/dispextern.h b/src/dispextern.h index 8fd3ef935f6..051629641ed 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -2235,7 +2235,10 @@ struct it | |||
| 2235 | ptrdiff_t base_level_stop; | 2235 | ptrdiff_t base_level_stop; |
| 2236 | 2236 | ||
| 2237 | /* Maximum string or buffer position + 1. ZV when iterating over | 2237 | /* Maximum string or buffer position + 1. ZV when iterating over |
| 2238 | current_buffer. */ | 2238 | current_buffer. When iterating over a string in display_string, |
| 2239 | this can be smaller or greater than the number of string | ||
| 2240 | characters, depending on the values of PRECISION and FIELD_WIDTH | ||
| 2241 | with which display_string was called. */ | ||
| 2239 | ptrdiff_t end_charpos; | 2242 | ptrdiff_t end_charpos; |
| 2240 | 2243 | ||
| 2241 | /* C string to iterate over. Non-null means get characters from | 2244 | /* C string to iterate over. Non-null means get characters from |
| @@ -42,6 +42,8 @@ static ptrdiff_t get_doc_string_buffer_size; | |||
| 42 | 42 | ||
| 43 | static unsigned char *read_bytecode_pointer; | 43 | static unsigned char *read_bytecode_pointer; |
| 44 | 44 | ||
| 45 | static char const sibling_etc[] = "../etc/"; | ||
| 46 | |||
| 45 | /* `readchar' in lread.c calls back here to fetch the next byte. | 47 | /* `readchar' in lread.c calls back here to fetch the next byte. |
| 46 | If UNREADFLAG is 1, we unread a byte. */ | 48 | If UNREADFLAG is 1, we unread a byte. */ |
| 47 | 49 | ||
| @@ -80,7 +82,6 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 80 | { | 82 | { |
| 81 | char *from, *to, *name, *p, *p1; | 83 | char *from, *to, *name, *p, *p1; |
| 82 | int fd; | 84 | int fd; |
| 83 | ptrdiff_t minsize; | ||
| 84 | int offset; | 85 | int offset; |
| 85 | EMACS_INT position; | 86 | EMACS_INT position; |
| 86 | Lisp_Object file, tem, pos; | 87 | Lisp_Object file, tem, pos; |
| @@ -113,21 +114,14 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 113 | 114 | ||
| 114 | tem = Ffile_name_absolute_p (file); | 115 | tem = Ffile_name_absolute_p (file); |
| 115 | file = ENCODE_FILE (file); | 116 | file = ENCODE_FILE (file); |
| 116 | if (NILP (tem)) | 117 | Lisp_Object docdir |
| 117 | { | 118 | = NILP (tem) ? ENCODE_FILE (Vdoc_directory) : empty_unibyte_string; |
| 118 | Lisp_Object docdir = ENCODE_FILE (Vdoc_directory); | 119 | ptrdiff_t docdir_sizemax = SBYTES (docdir) + 1; |
| 119 | minsize = SCHARS (docdir); | 120 | #ifndef CANNOT_DUMP |
| 120 | /* sizeof ("../etc/") == 8 */ | 121 | docdir_sizemax = max (docdir_sizemax, sizeof sibling_etc); |
| 121 | if (minsize < 8) | 122 | #endif |
| 122 | minsize = 8; | 123 | name = SAFE_ALLOCA (docdir_sizemax + SBYTES (file)); |
| 123 | name = SAFE_ALLOCA (minsize + SCHARS (file) + 8); | 124 | lispstpcpy (lispstpcpy (name, docdir), file); |
| 124 | char *z = lispstpcpy (name, docdir); | ||
| 125 | strcpy (z, SSDATA (file)); | ||
| 126 | } | ||
| 127 | else | ||
| 128 | { | ||
| 129 | name = SSDATA (file); | ||
| 130 | } | ||
| 131 | 125 | ||
| 132 | fd = emacs_open (name, O_RDONLY, 0); | 126 | fd = emacs_open (name, O_RDONLY, 0); |
| 133 | if (fd < 0) | 127 | if (fd < 0) |
| @@ -137,8 +131,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 137 | { | 131 | { |
| 138 | /* Preparing to dump; DOC file is probably not installed. | 132 | /* Preparing to dump; DOC file is probably not installed. |
| 139 | So check in ../etc. */ | 133 | So check in ../etc. */ |
| 140 | strcpy (name, "../etc/"); | 134 | lispstpcpy (stpcpy (name, sibling_etc), file); |
| 141 | strcat (name, SSDATA (file)); | ||
| 142 | 135 | ||
| 143 | fd = emacs_open (name, O_RDONLY, 0); | 136 | fd = emacs_open (name, O_RDONLY, 0); |
| 144 | } | 137 | } |
| @@ -580,7 +573,6 @@ the same file name is found in the `doc-directory'. */) | |||
| 580 | (0) | 573 | (0) |
| 581 | #endif /* CANNOT_DUMP */ | 574 | #endif /* CANNOT_DUMP */ |
| 582 | { | 575 | { |
| 583 | static char const sibling_etc[] = "../etc/"; | ||
| 584 | dirname = sibling_etc; | 576 | dirname = sibling_etc; |
| 585 | dirlen = sizeof sibling_etc - 1; | 577 | dirlen = sizeof sibling_etc - 1; |
| 586 | } | 578 | } |
| @@ -594,8 +586,7 @@ the same file name is found in the `doc-directory'. */) | |||
| 594 | count = SPECPDL_INDEX (); | 586 | count = SPECPDL_INDEX (); |
| 595 | USE_SAFE_ALLOCA; | 587 | USE_SAFE_ALLOCA; |
| 596 | name = SAFE_ALLOCA (dirlen + SBYTES (filename) + 1); | 588 | name = SAFE_ALLOCA (dirlen + SBYTES (filename) + 1); |
| 597 | strcpy (name, dirname); | 589 | lispstpcpy (stpcpy (name, dirname), filename); /*** Add this line ***/ |
| 598 | strcat (name, SSDATA (filename)); /*** Add this line ***/ | ||
| 599 | 590 | ||
| 600 | /* Vbuild_files is nil when temacs is run, and non-nil after that. */ | 591 | /* Vbuild_files is nil when temacs is run, and non-nil after that. */ |
| 601 | if (NILP (Vbuild_files)) | 592 | if (NILP (Vbuild_files)) |
diff --git a/src/editfns.c b/src/editfns.c index 0a07886934c..430c4c91fb3 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1350,10 +1350,9 @@ name, or nil if there is no such user. */) | |||
| 1350 | USE_SAFE_ALLOCA; | 1350 | USE_SAFE_ALLOCA; |
| 1351 | char *r = SAFE_ALLOCA (strlen (p) + SBYTES (login) + 1); | 1351 | char *r = SAFE_ALLOCA (strlen (p) + SBYTES (login) + 1); |
| 1352 | memcpy (r, p, q - p); | 1352 | memcpy (r, p, q - p); |
| 1353 | r[q - p] = 0; | 1353 | char *s = lispstpcpy (&r[q - p], login); |
| 1354 | strcat (r, SSDATA (login)); | ||
| 1355 | r[q - p] = upcase ((unsigned char) r[q - p]); | 1354 | r[q - p] = upcase ((unsigned char) r[q - p]); |
| 1356 | strcat (r, q + 1); | 1355 | strcpy (s, q + 1); |
| 1357 | full = build_string (r); | 1356 | full = build_string (r); |
| 1358 | SAFE_FREE (); | 1357 | SAFE_FREE (); |
| 1359 | } | 1358 | } |
diff --git a/src/frame.c b/src/frame.c index 31273665e88..2ad1c1b52b7 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -4076,23 +4076,23 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li | |||
| 4076 | 4076 | ||
| 4077 | /* Start with emacs.FRAMENAME for the name (the specific one) | 4077 | /* Start with emacs.FRAMENAME for the name (the specific one) |
| 4078 | and with `Emacs' for the class key (the general one). */ | 4078 | and with `Emacs' for the class key (the general one). */ |
| 4079 | lispstpcpy (name_key, Vx_resource_name); | 4079 | char *nz = lispstpcpy (name_key, Vx_resource_name); |
| 4080 | lispstpcpy (class_key, Vx_resource_class); | 4080 | char *cz = lispstpcpy (class_key, Vx_resource_class); |
| 4081 | 4081 | ||
| 4082 | strcat (class_key, "."); | 4082 | *cz++ = '.'; |
| 4083 | strcat (class_key, SSDATA (class)); | 4083 | cz = lispstpcpy (cz, class); |
| 4084 | 4084 | ||
| 4085 | if (!NILP (component)) | 4085 | if (!NILP (component)) |
| 4086 | { | 4086 | { |
| 4087 | strcat (class_key, "."); | 4087 | *cz++ = '.'; |
| 4088 | strcat (class_key, SSDATA (subclass)); | 4088 | lispstpcpy (cz, subclass); |
| 4089 | 4089 | ||
| 4090 | strcat (name_key, "."); | 4090 | *nz++ = '.'; |
| 4091 | strcat (name_key, SSDATA (component)); | 4091 | nz = lispstpcpy (nz, component); |
| 4092 | } | 4092 | } |
| 4093 | 4093 | ||
| 4094 | strcat (name_key, "."); | 4094 | *nz++ = '.'; |
| 4095 | strcat (name_key, SSDATA (attribute)); | 4095 | lispstpcpy (nz, attribute); |
| 4096 | 4096 | ||
| 4097 | char *value = x_get_string_resource (rdb, name_key, class_key); | 4097 | char *value = x_get_string_resource (rdb, name_key, class_key); |
| 4098 | SAFE_FREE(); | 4098 | SAFE_FREE(); |
diff --git a/src/gnutls.c b/src/gnutls.c index bf9f1323546..f945778cc91 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -71,142 +71,129 @@ enum extra_peer_verification | |||
| 71 | 71 | ||
| 72 | #ifdef WINDOWSNT | 72 | #ifdef WINDOWSNT |
| 73 | 73 | ||
| 74 | /* Macro for defining functions that will be loaded from the GnuTLS DLL. */ | 74 | DEF_DLL_FN (gnutls_alert_description_t, gnutls_alert_get, |
| 75 | #define DEF_GNUTLS_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args | 75 | (gnutls_session_t)); |
| 76 | 76 | DEF_DLL_FN (const char *, gnutls_alert_get_name, | |
| 77 | /* Macro for loading GnuTLS functions from the library. */ | 77 | (gnutls_alert_description_t)); |
| 78 | #define LOAD_GNUTLS_FN(lib,func) { \ | 78 | DEF_DLL_FN (int, gnutls_alert_send_appropriate, (gnutls_session_t, int)); |
| 79 | fn_##func = (void *) GetProcAddress (lib, #func); \ | 79 | DEF_DLL_FN (int, gnutls_anon_allocate_client_credentials, |
| 80 | if (!fn_##func) return 0; \ | 80 | (gnutls_anon_client_credentials_t *)); |
| 81 | } | 81 | DEF_DLL_FN (void, gnutls_anon_free_client_credentials, |
| 82 | 82 | (gnutls_anon_client_credentials_t)); | |
| 83 | DEF_GNUTLS_FN (gnutls_alert_description_t, gnutls_alert_get, | 83 | DEF_DLL_FN (int, gnutls_bye, (gnutls_session_t, gnutls_close_request_t)); |
| 84 | (gnutls_session_t)); | 84 | DEF_DLL_FN (int, gnutls_certificate_allocate_credentials, |
| 85 | DEF_GNUTLS_FN (const char *, gnutls_alert_get_name, | 85 | (gnutls_certificate_credentials_t *)); |
| 86 | (gnutls_alert_description_t)); | 86 | DEF_DLL_FN (void, gnutls_certificate_free_credentials, |
| 87 | DEF_GNUTLS_FN (int, gnutls_alert_send_appropriate, (gnutls_session_t, int)); | 87 | (gnutls_certificate_credentials_t)); |
| 88 | DEF_GNUTLS_FN (int, gnutls_anon_allocate_client_credentials, | 88 | DEF_DLL_FN (const gnutls_datum_t *, gnutls_certificate_get_peers, |
| 89 | (gnutls_anon_client_credentials_t *)); | 89 | (gnutls_session_t, unsigned int *)); |
| 90 | DEF_GNUTLS_FN (void, gnutls_anon_free_client_credentials, | 90 | DEF_DLL_FN (void, gnutls_certificate_set_verify_flags, |
| 91 | (gnutls_anon_client_credentials_t)); | 91 | (gnutls_certificate_credentials_t, unsigned int)); |
| 92 | DEF_GNUTLS_FN (int, gnutls_bye, (gnutls_session_t, gnutls_close_request_t)); | 92 | DEF_DLL_FN (int, gnutls_certificate_set_x509_crl_file, |
| 93 | DEF_GNUTLS_FN (int, gnutls_certificate_allocate_credentials, | 93 | (gnutls_certificate_credentials_t, const char *, |
| 94 | (gnutls_certificate_credentials_t *)); | 94 | gnutls_x509_crt_fmt_t)); |
| 95 | DEF_GNUTLS_FN (void, gnutls_certificate_free_credentials, | 95 | DEF_DLL_FN (int, gnutls_certificate_set_x509_key_file, |
| 96 | (gnutls_certificate_credentials_t)); | 96 | (gnutls_certificate_credentials_t, const char *, const char *, |
| 97 | DEF_GNUTLS_FN (const gnutls_datum_t *, gnutls_certificate_get_peers, | 97 | gnutls_x509_crt_fmt_t)); |
| 98 | (gnutls_session_t, unsigned int *)); | 98 | # if ((GNUTLS_VERSION_MAJOR \ |
| 99 | DEF_GNUTLS_FN (void, gnutls_certificate_set_verify_flags, | 99 | + (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20)) \ |
| 100 | (gnutls_certificate_credentials_t, unsigned int)); | 100 | > 3) |
| 101 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_crl_file, | 101 | DEF_DLL_FN (int, gnutls_certificate_set_x509_system_trust, |
| 102 | (gnutls_certificate_credentials_t, const char *, | 102 | (gnutls_certificate_credentials_t)); |
| 103 | gnutls_x509_crt_fmt_t)); | 103 | # endif |
| 104 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_key_file, | 104 | DEF_DLL_FN (int, gnutls_certificate_set_x509_trust_file, |
| 105 | (gnutls_certificate_credentials_t, const char *, const char *, | 105 | (gnutls_certificate_credentials_t, const char *, |
| 106 | gnutls_x509_crt_fmt_t)); | 106 | gnutls_x509_crt_fmt_t)); |
| 107 | #if GNUTLS_VERSION_MAJOR + \ | 107 | DEF_DLL_FN (gnutls_certificate_type_t, gnutls_certificate_type_get, |
| 108 | (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3 | 108 | (gnutls_session_t)); |
| 109 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_system_trust, | 109 | DEF_DLL_FN (int, gnutls_certificate_verify_peers2, |
| 110 | (gnutls_certificate_credentials_t)); | 110 | (gnutls_session_t, unsigned int *)); |
| 111 | #endif | 111 | DEF_DLL_FN (int, gnutls_credentials_set, |
| 112 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_trust_file, | 112 | (gnutls_session_t, gnutls_credentials_type_t, void *)); |
| 113 | (gnutls_certificate_credentials_t, const char *, | 113 | DEF_DLL_FN (void, gnutls_deinit, (gnutls_session_t)); |
| 114 | gnutls_x509_crt_fmt_t)); | 114 | DEF_DLL_FN (void, gnutls_dh_set_prime_bits, |
| 115 | DEF_GNUTLS_FN (gnutls_certificate_type_t, gnutls_certificate_type_get, | 115 | (gnutls_session_t, unsigned int)); |
| 116 | (gnutls_session_t)); | 116 | DEF_DLL_FN (int, gnutls_dh_get_prime_bits, (gnutls_session_t)); |
| 117 | DEF_GNUTLS_FN (int, gnutls_certificate_verify_peers2, | 117 | DEF_DLL_FN (int, gnutls_error_is_fatal, (int)); |
| 118 | (gnutls_session_t, unsigned int *)); | 118 | DEF_DLL_FN (int, gnutls_global_init, (void)); |
| 119 | DEF_GNUTLS_FN (int, gnutls_credentials_set, | 119 | DEF_DLL_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); |
| 120 | (gnutls_session_t, gnutls_credentials_type_t, void *)); | 120 | # ifdef HAVE_GNUTLS3 |
| 121 | DEF_GNUTLS_FN (void, gnutls_deinit, (gnutls_session_t)); | 121 | DEF_DLL_FN (void, gnutls_global_set_audit_log_function, (gnutls_audit_log_func)); |
| 122 | DEF_GNUTLS_FN (void, gnutls_dh_set_prime_bits, | 122 | # endif |
| 123 | (gnutls_session_t, unsigned int)); | 123 | DEF_DLL_FN (void, gnutls_global_set_log_level, (int)); |
| 124 | DEF_GNUTLS_FN (int, gnutls_dh_get_prime_bits, (gnutls_session_t)); | 124 | DEF_DLL_FN (int, gnutls_handshake, (gnutls_session_t)); |
| 125 | DEF_GNUTLS_FN (int, gnutls_error_is_fatal, (int)); | 125 | DEF_DLL_FN (int, gnutls_init, (gnutls_session_t *, unsigned int)); |
| 126 | DEF_GNUTLS_FN (int, gnutls_global_init, (void)); | 126 | DEF_DLL_FN (int, gnutls_priority_set_direct, |
| 127 | DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); | 127 | (gnutls_session_t, const char *, const char **)); |
| 128 | #ifdef HAVE_GNUTLS3 | 128 | DEF_DLL_FN (size_t, gnutls_record_check_pending, (gnutls_session_t)); |
| 129 | DEF_GNUTLS_FN (void, gnutls_global_set_audit_log_function, (gnutls_audit_log_func)); | 129 | DEF_DLL_FN (ssize_t, gnutls_record_recv, (gnutls_session_t, void *, size_t)); |
| 130 | #endif | 130 | DEF_DLL_FN (ssize_t, gnutls_record_send, |
| 131 | DEF_GNUTLS_FN (void, gnutls_global_set_log_level, (int)); | 131 | (gnutls_session_t, const void *, size_t)); |
| 132 | DEF_GNUTLS_FN (void, gnutls_global_set_mem_functions, | 132 | DEF_DLL_FN (const char *, gnutls_strerror, (int)); |
| 133 | (gnutls_alloc_function, gnutls_alloc_function, | 133 | DEF_DLL_FN (void, gnutls_transport_set_errno, (gnutls_session_t, int)); |
| 134 | gnutls_is_secure_function, gnutls_realloc_function, | 134 | DEF_DLL_FN (const char *, gnutls_check_version, (const char *)); |
| 135 | gnutls_free_function)); | 135 | DEF_DLL_FN (void, gnutls_transport_set_lowat, (gnutls_session_t, int)); |
| 136 | DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t)); | 136 | DEF_DLL_FN (void, gnutls_transport_set_ptr2, |
| 137 | DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); | 137 | (gnutls_session_t, gnutls_transport_ptr_t, |
| 138 | DEF_GNUTLS_FN (int, gnutls_priority_set_direct, | 138 | gnutls_transport_ptr_t)); |
| 139 | (gnutls_session_t, const char *, const char **)); | 139 | DEF_DLL_FN (void, gnutls_transport_set_pull_function, |
| 140 | DEF_GNUTLS_FN (size_t, gnutls_record_check_pending, (gnutls_session_t)); | 140 | (gnutls_session_t, gnutls_pull_func)); |
| 141 | DEF_GNUTLS_FN (ssize_t, gnutls_record_recv, (gnutls_session_t, void *, size_t)); | 141 | DEF_DLL_FN (void, gnutls_transport_set_push_function, |
| 142 | DEF_GNUTLS_FN (ssize_t, gnutls_record_send, | 142 | (gnutls_session_t, gnutls_push_func)); |
| 143 | (gnutls_session_t, const void *, size_t)); | 143 | DEF_DLL_FN (int, gnutls_x509_crt_check_hostname, |
| 144 | DEF_GNUTLS_FN (const char *, gnutls_strerror, (int)); | 144 | (gnutls_x509_crt_t, const char *)); |
| 145 | DEF_GNUTLS_FN (void, gnutls_transport_set_errno, (gnutls_session_t, int)); | 145 | DEF_DLL_FN (void, gnutls_x509_crt_deinit, (gnutls_x509_crt_t)); |
| 146 | DEF_GNUTLS_FN (const char *, gnutls_check_version, (const char *)); | 146 | DEF_DLL_FN (int, gnutls_x509_crt_import, |
| 147 | DEF_GNUTLS_FN (void, gnutls_transport_set_lowat, (gnutls_session_t, int)); | 147 | (gnutls_x509_crt_t, const gnutls_datum_t *, |
| 148 | DEF_GNUTLS_FN (void, gnutls_transport_set_ptr2, | 148 | gnutls_x509_crt_fmt_t)); |
| 149 | (gnutls_session_t, gnutls_transport_ptr_t, | 149 | DEF_DLL_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *)); |
| 150 | gnutls_transport_ptr_t)); | 150 | DEF_DLL_FN (int, gnutls_x509_crt_get_fingerprint, |
| 151 | DEF_GNUTLS_FN (void, gnutls_transport_set_pull_function, | 151 | (gnutls_x509_crt_t, |
| 152 | (gnutls_session_t, gnutls_pull_func)); | 152 | gnutls_digest_algorithm_t, void *, size_t *)); |
| 153 | DEF_GNUTLS_FN (void, gnutls_transport_set_push_function, | 153 | DEF_DLL_FN (int, gnutls_x509_crt_get_version, |
| 154 | (gnutls_session_t, gnutls_push_func)); | 154 | (gnutls_x509_crt_t)); |
| 155 | DEF_GNUTLS_FN (int, gnutls_x509_crt_check_hostname, | 155 | DEF_DLL_FN (int, gnutls_x509_crt_get_serial, |
| 156 | (gnutls_x509_crt_t, const char *)); | 156 | (gnutls_x509_crt_t, void *, size_t *)); |
| 157 | DEF_GNUTLS_FN (void, gnutls_x509_crt_deinit, (gnutls_x509_crt_t)); | 157 | DEF_DLL_FN (int, gnutls_x509_crt_get_issuer_dn, |
| 158 | DEF_GNUTLS_FN (int, gnutls_x509_crt_import, | 158 | (gnutls_x509_crt_t, char *, size_t *)); |
| 159 | (gnutls_x509_crt_t, const gnutls_datum_t *, | 159 | DEF_DLL_FN (time_t, gnutls_x509_crt_get_activation_time, |
| 160 | gnutls_x509_crt_fmt_t)); | 160 | (gnutls_x509_crt_t)); |
| 161 | DEF_GNUTLS_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *)); | 161 | DEF_DLL_FN (time_t, gnutls_x509_crt_get_expiration_time, |
| 162 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_fingerprint, | 162 | (gnutls_x509_crt_t)); |
| 163 | (gnutls_x509_crt_t, | 163 | DEF_DLL_FN (int, gnutls_x509_crt_get_dn, |
| 164 | gnutls_digest_algorithm_t, void *, size_t *)); | 164 | (gnutls_x509_crt_t, char *, size_t *)); |
| 165 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_version, | 165 | DEF_DLL_FN (int, gnutls_x509_crt_get_pk_algorithm, |
| 166 | (gnutls_x509_crt_t)); | 166 | (gnutls_x509_crt_t, unsigned int *)); |
| 167 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_serial, | 167 | DEF_DLL_FN (const char*, gnutls_pk_algorithm_get_name, |
| 168 | (gnutls_x509_crt_t, void *, size_t *)); | 168 | (gnutls_pk_algorithm_t)); |
| 169 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_issuer_dn, | 169 | DEF_DLL_FN (int, gnutls_pk_bits_to_sec_param, |
| 170 | (gnutls_x509_crt_t, char *, size_t *)); | 170 | (gnutls_pk_algorithm_t, unsigned int)); |
| 171 | DEF_GNUTLS_FN (time_t, gnutls_x509_crt_get_activation_time, | 171 | DEF_DLL_FN (int, gnutls_x509_crt_get_issuer_unique_id, |
| 172 | (gnutls_x509_crt_t)); | 172 | (gnutls_x509_crt_t, char *, size_t *)); |
| 173 | DEF_GNUTLS_FN (time_t, gnutls_x509_crt_get_expiration_time, | 173 | DEF_DLL_FN (int, gnutls_x509_crt_get_subject_unique_id, |
| 174 | (gnutls_x509_crt_t)); | 174 | (gnutls_x509_crt_t, char *, size_t *)); |
| 175 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_dn, | 175 | DEF_DLL_FN (int, gnutls_x509_crt_get_signature_algorithm, |
| 176 | (gnutls_x509_crt_t, char *, size_t *)); | 176 | (gnutls_x509_crt_t)); |
| 177 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_pk_algorithm, | 177 | DEF_DLL_FN (int, gnutls_x509_crt_get_signature, |
| 178 | (gnutls_x509_crt_t, unsigned int *)); | 178 | (gnutls_x509_crt_t, char *, size_t *)); |
| 179 | DEF_GNUTLS_FN (const char*, gnutls_pk_algorithm_get_name, | 179 | DEF_DLL_FN (int, gnutls_x509_crt_get_key_id, |
| 180 | (gnutls_pk_algorithm_t)); | 180 | (gnutls_x509_crt_t, unsigned int, unsigned char *, size_t *_size)); |
| 181 | DEF_GNUTLS_FN (int, gnutls_pk_bits_to_sec_param, | 181 | DEF_DLL_FN (const char*, gnutls_sec_param_get_name, (gnutls_sec_param_t)); |
| 182 | (gnutls_pk_algorithm_t, unsigned int)); | 182 | DEF_DLL_FN (const char*, gnutls_sign_get_name, (gnutls_sign_algorithm_t)); |
| 183 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_issuer_unique_id, | 183 | DEF_DLL_FN (int, gnutls_server_name_set, |
| 184 | (gnutls_x509_crt_t, char *, size_t *)); | 184 | (gnutls_session_t, gnutls_server_name_type_t, |
| 185 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_subject_unique_id, | 185 | const void *, size_t)); |
| 186 | (gnutls_x509_crt_t, char *, size_t *)); | 186 | DEF_DLL_FN (gnutls_kx_algorithm_t, gnutls_kx_get, (gnutls_session_t)); |
| 187 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_signature_algorithm, | 187 | DEF_DLL_FN (const char*, gnutls_kx_get_name, (gnutls_kx_algorithm_t)); |
| 188 | (gnutls_x509_crt_t)); | 188 | DEF_DLL_FN (gnutls_protocol_t, gnutls_protocol_get_version, |
| 189 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_signature, | 189 | (gnutls_session_t)); |
| 190 | (gnutls_x509_crt_t, char *, size_t *)); | 190 | DEF_DLL_FN (const char*, gnutls_protocol_get_name, (gnutls_protocol_t)); |
| 191 | DEF_GNUTLS_FN (int, gnutls_x509_crt_get_key_id, | 191 | DEF_DLL_FN (gnutls_cipher_algorithm_t, gnutls_cipher_get, |
| 192 | (gnutls_x509_crt_t, unsigned int, | 192 | (gnutls_session_t)); |
| 193 | unsigned char *, size_t *_size)); | 193 | DEF_DLL_FN (const char*, gnutls_cipher_get_name, |
| 194 | DEF_GNUTLS_FN (const char*, gnutls_sec_param_get_name, (gnutls_sec_param_t)); | 194 | (gnutls_cipher_algorithm_t)); |
| 195 | DEF_GNUTLS_FN (const char*, gnutls_sign_get_name, (gnutls_sign_algorithm_t)); | 195 | DEF_DLL_FN (gnutls_mac_algorithm_t, gnutls_mac_get, (gnutls_session_t)); |
| 196 | DEF_GNUTLS_FN (int, gnutls_server_name_set, (gnutls_session_t, | 196 | DEF_DLL_FN (const char*, gnutls_mac_get_name, (gnutls_mac_algorithm_t)); |
| 197 | gnutls_server_name_type_t, | ||
| 198 | const void *, size_t)); | ||
| 199 | DEF_GNUTLS_FN (gnutls_kx_algorithm_t, gnutls_kx_get, (gnutls_session_t)); | ||
| 200 | DEF_GNUTLS_FN (const char*, gnutls_kx_get_name, (gnutls_kx_algorithm_t)); | ||
| 201 | DEF_GNUTLS_FN (gnutls_protocol_t, gnutls_protocol_get_version, | ||
| 202 | (gnutls_session_t)); | ||
| 203 | DEF_GNUTLS_FN (const char*, gnutls_protocol_get_name, (gnutls_protocol_t)); | ||
| 204 | DEF_GNUTLS_FN (gnutls_cipher_algorithm_t, gnutls_cipher_get, | ||
| 205 | (gnutls_session_t)); | ||
| 206 | DEF_GNUTLS_FN (const char*, gnutls_cipher_get_name, | ||
| 207 | (gnutls_cipher_algorithm_t)); | ||
| 208 | DEF_GNUTLS_FN (gnutls_mac_algorithm_t, gnutls_mac_get, (gnutls_session_t)); | ||
| 209 | DEF_GNUTLS_FN (const char*, gnutls_mac_get_name, (gnutls_mac_algorithm_t)); | ||
| 210 | 197 | ||
| 211 | 198 | ||
| 212 | static bool | 199 | static bool |
| @@ -221,83 +208,83 @@ init_gnutls_functions (void) | |||
| 221 | return 0; | 208 | return 0; |
| 222 | } | 209 | } |
| 223 | 210 | ||
| 224 | LOAD_GNUTLS_FN (library, gnutls_alert_get); | 211 | LOAD_DLL_FN (library, gnutls_alert_get); |
| 225 | LOAD_GNUTLS_FN (library, gnutls_alert_get_name); | 212 | LOAD_DLL_FN (library, gnutls_alert_get_name); |
| 226 | LOAD_GNUTLS_FN (library, gnutls_alert_send_appropriate); | 213 | LOAD_DLL_FN (library, gnutls_alert_send_appropriate); |
| 227 | LOAD_GNUTLS_FN (library, gnutls_anon_allocate_client_credentials); | 214 | LOAD_DLL_FN (library, gnutls_anon_allocate_client_credentials); |
| 228 | LOAD_GNUTLS_FN (library, gnutls_anon_free_client_credentials); | 215 | LOAD_DLL_FN (library, gnutls_anon_free_client_credentials); |
| 229 | LOAD_GNUTLS_FN (library, gnutls_bye); | 216 | LOAD_DLL_FN (library, gnutls_bye); |
| 230 | LOAD_GNUTLS_FN (library, gnutls_certificate_allocate_credentials); | 217 | LOAD_DLL_FN (library, gnutls_certificate_allocate_credentials); |
| 231 | LOAD_GNUTLS_FN (library, gnutls_certificate_free_credentials); | 218 | LOAD_DLL_FN (library, gnutls_certificate_free_credentials); |
| 232 | LOAD_GNUTLS_FN (library, gnutls_certificate_get_peers); | 219 | LOAD_DLL_FN (library, gnutls_certificate_get_peers); |
| 233 | LOAD_GNUTLS_FN (library, gnutls_certificate_set_verify_flags); | 220 | LOAD_DLL_FN (library, gnutls_certificate_set_verify_flags); |
| 234 | LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_crl_file); | 221 | LOAD_DLL_FN (library, gnutls_certificate_set_x509_crl_file); |
| 235 | LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_key_file); | 222 | LOAD_DLL_FN (library, gnutls_certificate_set_x509_key_file); |
| 236 | #if GNUTLS_VERSION_MAJOR + \ | 223 | # if ((GNUTLS_VERSION_MAJOR \ |
| 237 | (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3 | 224 | + (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20)) \ |
| 238 | LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_system_trust); | 225 | > 3) |
| 239 | #endif | 226 | LOAD_DLL_FN (library, gnutls_certificate_set_x509_system_trust); |
| 240 | LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_trust_file); | 227 | # endif |
| 241 | LOAD_GNUTLS_FN (library, gnutls_certificate_type_get); | 228 | LOAD_DLL_FN (library, gnutls_certificate_set_x509_trust_file); |
| 242 | LOAD_GNUTLS_FN (library, gnutls_certificate_verify_peers2); | 229 | LOAD_DLL_FN (library, gnutls_certificate_type_get); |
| 243 | LOAD_GNUTLS_FN (library, gnutls_credentials_set); | 230 | LOAD_DLL_FN (library, gnutls_certificate_verify_peers2); |
| 244 | LOAD_GNUTLS_FN (library, gnutls_deinit); | 231 | LOAD_DLL_FN (library, gnutls_credentials_set); |
| 245 | LOAD_GNUTLS_FN (library, gnutls_dh_set_prime_bits); | 232 | LOAD_DLL_FN (library, gnutls_deinit); |
| 246 | LOAD_GNUTLS_FN (library, gnutls_dh_get_prime_bits); | 233 | LOAD_DLL_FN (library, gnutls_dh_set_prime_bits); |
| 247 | LOAD_GNUTLS_FN (library, gnutls_error_is_fatal); | 234 | LOAD_DLL_FN (library, gnutls_dh_get_prime_bits); |
| 248 | LOAD_GNUTLS_FN (library, gnutls_global_init); | 235 | LOAD_DLL_FN (library, gnutls_error_is_fatal); |
| 249 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_function); | 236 | LOAD_DLL_FN (library, gnutls_global_init); |
| 250 | #ifdef HAVE_GNUTLS3 | 237 | LOAD_DLL_FN (library, gnutls_global_set_log_function); |
| 251 | LOAD_GNUTLS_FN (library, gnutls_global_set_audit_log_function); | 238 | # ifdef HAVE_GNUTLS3 |
| 252 | #endif | 239 | LOAD_DLL_FN (library, gnutls_global_set_audit_log_function); |
| 253 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_level); | 240 | # endif |
| 254 | LOAD_GNUTLS_FN (library, gnutls_global_set_mem_functions); | 241 | LOAD_DLL_FN (library, gnutls_global_set_log_level); |
| 255 | LOAD_GNUTLS_FN (library, gnutls_handshake); | 242 | LOAD_DLL_FN (library, gnutls_handshake); |
| 256 | LOAD_GNUTLS_FN (library, gnutls_init); | 243 | LOAD_DLL_FN (library, gnutls_init); |
| 257 | LOAD_GNUTLS_FN (library, gnutls_priority_set_direct); | 244 | LOAD_DLL_FN (library, gnutls_priority_set_direct); |
| 258 | LOAD_GNUTLS_FN (library, gnutls_record_check_pending); | 245 | LOAD_DLL_FN (library, gnutls_record_check_pending); |
| 259 | LOAD_GNUTLS_FN (library, gnutls_record_recv); | 246 | LOAD_DLL_FN (library, gnutls_record_recv); |
| 260 | LOAD_GNUTLS_FN (library, gnutls_record_send); | 247 | LOAD_DLL_FN (library, gnutls_record_send); |
| 261 | LOAD_GNUTLS_FN (library, gnutls_strerror); | 248 | LOAD_DLL_FN (library, gnutls_strerror); |
| 262 | LOAD_GNUTLS_FN (library, gnutls_transport_set_errno); | 249 | LOAD_DLL_FN (library, gnutls_transport_set_errno); |
| 263 | LOAD_GNUTLS_FN (library, gnutls_check_version); | 250 | LOAD_DLL_FN (library, gnutls_check_version); |
| 264 | /* We don't need to call gnutls_transport_set_lowat in GnuTLS 2.11.1 | 251 | /* We don't need to call gnutls_transport_set_lowat in GnuTLS 2.11.1 |
| 265 | and later, and the function was removed entirely in 3.0.0. */ | 252 | and later, and the function was removed entirely in 3.0.0. */ |
| 266 | if (!fn_gnutls_check_version ("2.11.1")) | 253 | if (!fn_gnutls_check_version ("2.11.1")) |
| 267 | LOAD_GNUTLS_FN (library, gnutls_transport_set_lowat); | 254 | LOAD_DLL_FN (library, gnutls_transport_set_lowat); |
| 268 | LOAD_GNUTLS_FN (library, gnutls_transport_set_ptr2); | 255 | LOAD_DLL_FN (library, gnutls_transport_set_ptr2); |
| 269 | LOAD_GNUTLS_FN (library, gnutls_transport_set_pull_function); | 256 | LOAD_DLL_FN (library, gnutls_transport_set_pull_function); |
| 270 | LOAD_GNUTLS_FN (library, gnutls_transport_set_push_function); | 257 | LOAD_DLL_FN (library, gnutls_transport_set_push_function); |
| 271 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_check_hostname); | 258 | LOAD_DLL_FN (library, gnutls_x509_crt_check_hostname); |
| 272 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_deinit); | 259 | LOAD_DLL_FN (library, gnutls_x509_crt_deinit); |
| 273 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_import); | 260 | LOAD_DLL_FN (library, gnutls_x509_crt_import); |
| 274 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_init); | 261 | LOAD_DLL_FN (library, gnutls_x509_crt_init); |
| 275 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_fingerprint); | 262 | LOAD_DLL_FN (library, gnutls_x509_crt_get_fingerprint); |
| 276 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_version); | 263 | LOAD_DLL_FN (library, gnutls_x509_crt_get_version); |
| 277 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_serial); | 264 | LOAD_DLL_FN (library, gnutls_x509_crt_get_serial); |
| 278 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_issuer_dn); | 265 | LOAD_DLL_FN (library, gnutls_x509_crt_get_issuer_dn); |
| 279 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_activation_time); | 266 | LOAD_DLL_FN (library, gnutls_x509_crt_get_activation_time); |
| 280 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_expiration_time); | 267 | LOAD_DLL_FN (library, gnutls_x509_crt_get_expiration_time); |
| 281 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_dn); | 268 | LOAD_DLL_FN (library, gnutls_x509_crt_get_dn); |
| 282 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_pk_algorithm); | 269 | LOAD_DLL_FN (library, gnutls_x509_crt_get_pk_algorithm); |
| 283 | LOAD_GNUTLS_FN (library, gnutls_pk_algorithm_get_name); | 270 | LOAD_DLL_FN (library, gnutls_pk_algorithm_get_name); |
| 284 | LOAD_GNUTLS_FN (library, gnutls_pk_bits_to_sec_param); | 271 | LOAD_DLL_FN (library, gnutls_pk_bits_to_sec_param); |
| 285 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_issuer_unique_id); | 272 | LOAD_DLL_FN (library, gnutls_x509_crt_get_issuer_unique_id); |
| 286 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_subject_unique_id); | 273 | LOAD_DLL_FN (library, gnutls_x509_crt_get_subject_unique_id); |
| 287 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_signature_algorithm); | 274 | LOAD_DLL_FN (library, gnutls_x509_crt_get_signature_algorithm); |
| 288 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_signature); | 275 | LOAD_DLL_FN (library, gnutls_x509_crt_get_signature); |
| 289 | LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_key_id); | 276 | LOAD_DLL_FN (library, gnutls_x509_crt_get_key_id); |
| 290 | LOAD_GNUTLS_FN (library, gnutls_sec_param_get_name); | 277 | LOAD_DLL_FN (library, gnutls_sec_param_get_name); |
| 291 | LOAD_GNUTLS_FN (library, gnutls_sign_get_name); | 278 | LOAD_DLL_FN (library, gnutls_sign_get_name); |
| 292 | LOAD_GNUTLS_FN (library, gnutls_server_name_set); | 279 | LOAD_DLL_FN (library, gnutls_server_name_set); |
| 293 | LOAD_GNUTLS_FN (library, gnutls_kx_get); | 280 | LOAD_DLL_FN (library, gnutls_kx_get); |
| 294 | LOAD_GNUTLS_FN (library, gnutls_kx_get_name); | 281 | LOAD_DLL_FN (library, gnutls_kx_get_name); |
| 295 | LOAD_GNUTLS_FN (library, gnutls_protocol_get_version); | 282 | LOAD_DLL_FN (library, gnutls_protocol_get_version); |
| 296 | LOAD_GNUTLS_FN (library, gnutls_protocol_get_name); | 283 | LOAD_DLL_FN (library, gnutls_protocol_get_name); |
| 297 | LOAD_GNUTLS_FN (library, gnutls_cipher_get); | 284 | LOAD_DLL_FN (library, gnutls_cipher_get); |
| 298 | LOAD_GNUTLS_FN (library, gnutls_cipher_get_name); | 285 | LOAD_DLL_FN (library, gnutls_cipher_get_name); |
| 299 | LOAD_GNUTLS_FN (library, gnutls_mac_get); | 286 | LOAD_DLL_FN (library, gnutls_mac_get); |
| 300 | LOAD_GNUTLS_FN (library, gnutls_mac_get_name); | 287 | LOAD_DLL_FN (library, gnutls_mac_get_name); |
| 301 | 288 | ||
| 302 | max_log_level = global_gnutls_log_level; | 289 | max_log_level = global_gnutls_log_level; |
| 303 | 290 | ||
| @@ -310,80 +297,89 @@ init_gnutls_functions (void) | |||
| 310 | return 1; | 297 | return 1; |
| 311 | } | 298 | } |
| 312 | 299 | ||
| 313 | #else /* !WINDOWSNT */ | 300 | # define gnutls_alert_get fn_gnutls_alert_get |
| 314 | 301 | # define gnutls_alert_get_name fn_gnutls_alert_get_name | |
| 315 | #define fn_gnutls_alert_get gnutls_alert_get | 302 | # define gnutls_alert_send_appropriate fn_gnutls_alert_send_appropriate |
| 316 | #define fn_gnutls_alert_get_name gnutls_alert_get_name | 303 | # define gnutls_anon_allocate_client_credentials fn_gnutls_anon_allocate_client_credentials |
| 317 | #define fn_gnutls_alert_send_appropriate gnutls_alert_send_appropriate | 304 | # define gnutls_anon_free_client_credentials fn_gnutls_anon_free_client_credentials |
| 318 | #define fn_gnutls_anon_allocate_client_credentials gnutls_anon_allocate_client_credentials | 305 | # define gnutls_bye fn_gnutls_bye |
| 319 | #define fn_gnutls_anon_free_client_credentials gnutls_anon_free_client_credentials | 306 | # define gnutls_certificate_allocate_credentials fn_gnutls_certificate_allocate_credentials |
| 320 | #define fn_gnutls_bye gnutls_bye | 307 | # define gnutls_certificate_free_credentials fn_gnutls_certificate_free_credentials |
| 321 | #define fn_gnutls_certificate_allocate_credentials gnutls_certificate_allocate_credentials | 308 | # define gnutls_certificate_get_peers fn_gnutls_certificate_get_peers |
| 322 | #define fn_gnutls_certificate_free_credentials gnutls_certificate_free_credentials | 309 | # define gnutls_certificate_set_verify_flags fn_gnutls_certificate_set_verify_flags |
| 323 | #define fn_gnutls_certificate_get_peers gnutls_certificate_get_peers | 310 | # define gnutls_certificate_set_x509_crl_file fn_gnutls_certificate_set_x509_crl_file |
| 324 | #define fn_gnutls_certificate_set_verify_flags gnutls_certificate_set_verify_flags | 311 | # define gnutls_certificate_set_x509_key_file fn_gnutls_certificate_set_x509_key_file |
| 325 | #define fn_gnutls_certificate_set_x509_crl_file gnutls_certificate_set_x509_crl_file | 312 | # define gnutls_certificate_set_x509_system_trust fn_gnutls_certificate_set_x509_system_trust |
| 326 | #define fn_gnutls_certificate_set_x509_key_file gnutls_certificate_set_x509_key_file | 313 | # define gnutls_certificate_set_x509_trust_file fn_gnutls_certificate_set_x509_trust_file |
| 327 | #if GNUTLS_VERSION_MAJOR + \ | 314 | # define gnutls_certificate_type_get fn_gnutls_certificate_type_get |
| 328 | (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3 | 315 | # define gnutls_certificate_verify_peers2 fn_gnutls_certificate_verify_peers2 |
| 329 | #define fn_gnutls_certificate_set_x509_system_trust gnutls_certificate_set_x509_system_trust | 316 | # define gnutls_check_version fn_gnutls_check_version |
| 330 | #endif | 317 | # define gnutls_cipher_get fn_gnutls_cipher_get |
| 331 | #define fn_gnutls_certificate_set_x509_trust_file gnutls_certificate_set_x509_trust_file | 318 | # define gnutls_cipher_get_name fn_gnutls_cipher_get_name |
| 332 | #define fn_gnutls_certificate_type_get gnutls_certificate_type_get | 319 | # define gnutls_credentials_set fn_gnutls_credentials_set |
| 333 | #define fn_gnutls_certificate_verify_peers2 gnutls_certificate_verify_peers2 | 320 | # define gnutls_deinit fn_gnutls_deinit |
| 334 | #define fn_gnutls_cipher_get gnutls_cipher_get | 321 | # define gnutls_dh_get_prime_bits fn_gnutls_dh_get_prime_bits |
| 335 | #define fn_gnutls_cipher_get_name gnutls_cipher_get_name | 322 | # define gnutls_dh_set_prime_bits fn_gnutls_dh_set_prime_bits |
| 336 | #define fn_gnutls_credentials_set gnutls_credentials_set | 323 | # define gnutls_error_is_fatal fn_gnutls_error_is_fatal |
| 337 | #define fn_gnutls_deinit gnutls_deinit | 324 | # define gnutls_global_init fn_gnutls_global_init |
| 338 | #define fn_gnutls_dh_get_prime_bits gnutls_dh_get_prime_bits | 325 | # define gnutls_global_set_audit_log_function fn_gnutls_global_set_audit_log_function |
| 339 | #define fn_gnutls_dh_set_prime_bits gnutls_dh_set_prime_bits | 326 | # define gnutls_global_set_log_function fn_gnutls_global_set_log_function |
| 340 | #define fn_gnutls_error_is_fatal gnutls_error_is_fatal | 327 | # define gnutls_global_set_log_level fn_gnutls_global_set_log_level |
| 341 | #define fn_gnutls_global_init gnutls_global_init | 328 | # define gnutls_handshake fn_gnutls_handshake |
| 342 | #ifdef HAVE_GNUTLS3 | 329 | # define gnutls_init fn_gnutls_init |
| 343 | #define fn_gnutls_global_set_audit_log_function gnutls_global_set_audit_log_function | 330 | # define gnutls_kx_get fn_gnutls_kx_get |
| 331 | # define gnutls_kx_get_name fn_gnutls_kx_get_name | ||
| 332 | # define gnutls_mac_get fn_gnutls_mac_get | ||
| 333 | # define gnutls_mac_get_name fn_gnutls_mac_get_name | ||
| 334 | # define gnutls_pk_algorithm_get_name fn_gnutls_pk_algorithm_get_name | ||
| 335 | # define gnutls_pk_bits_to_sec_param fn_gnutls_pk_bits_to_sec_param | ||
| 336 | # define gnutls_priority_set_direct fn_gnutls_priority_set_direct | ||
| 337 | # define gnutls_protocol_get_name fn_gnutls_protocol_get_name | ||
| 338 | # define gnutls_protocol_get_version fn_gnutls_protocol_get_version | ||
| 339 | # define gnutls_record_check_pending fn_gnutls_record_check_pending | ||
| 340 | # define gnutls_record_recv fn_gnutls_record_recv | ||
| 341 | # define gnutls_record_send fn_gnutls_record_send | ||
| 342 | # define gnutls_sec_param_get_name fn_gnutls_sec_param_get_name | ||
| 343 | # define gnutls_server_name_set fn_gnutls_server_name_set | ||
| 344 | # define gnutls_sign_get_name fn_gnutls_sign_get_name | ||
| 345 | # define gnutls_strerror fn_gnutls_strerror | ||
| 346 | # define gnutls_transport_set_errno fn_gnutls_transport_set_errno | ||
| 347 | # define gnutls_transport_set_lowat fn_gnutls_transport_set_lowat | ||
| 348 | # define gnutls_transport_set_ptr2 fn_gnutls_transport_set_ptr2 | ||
| 349 | # define gnutls_transport_set_pull_function fn_gnutls_transport_set_pull_function | ||
| 350 | # define gnutls_transport_set_push_function fn_gnutls_transport_set_push_function | ||
| 351 | # define gnutls_x509_crt_check_hostname fn_gnutls_x509_crt_check_hostname | ||
| 352 | # define gnutls_x509_crt_deinit fn_gnutls_x509_crt_deinit | ||
| 353 | # define gnutls_x509_crt_get_activation_time fn_gnutls_x509_crt_get_activation_time | ||
| 354 | # define gnutls_x509_crt_get_dn fn_gnutls_x509_crt_get_dn | ||
| 355 | # define gnutls_x509_crt_get_expiration_time fn_gnutls_x509_crt_get_expiration_time | ||
| 356 | # define gnutls_x509_crt_get_fingerprint fn_gnutls_x509_crt_get_fingerprint | ||
| 357 | # define gnutls_x509_crt_get_issuer_dn fn_gnutls_x509_crt_get_issuer_dn | ||
| 358 | # define gnutls_x509_crt_get_issuer_unique_id fn_gnutls_x509_crt_get_issuer_unique_id | ||
| 359 | # define gnutls_x509_crt_get_key_id fn_gnutls_x509_crt_get_key_id | ||
| 360 | # define gnutls_x509_crt_get_pk_algorithm fn_gnutls_x509_crt_get_pk_algorithm | ||
| 361 | # define gnutls_x509_crt_get_serial fn_gnutls_x509_crt_get_serial | ||
| 362 | # define gnutls_x509_crt_get_signature fn_gnutls_x509_crt_get_signature | ||
| 363 | # define gnutls_x509_crt_get_signature_algorithm fn_gnutls_x509_crt_get_signature_algorithm | ||
| 364 | # define gnutls_x509_crt_get_subject_unique_id fn_gnutls_x509_crt_get_subject_unique_id | ||
| 365 | # define gnutls_x509_crt_get_version fn_gnutls_x509_crt_get_version | ||
| 366 | # define gnutls_x509_crt_import fn_gnutls_x509_crt_import | ||
| 367 | # define gnutls_x509_crt_init fn_gnutls_x509_crt_init | ||
| 368 | |||
| 344 | #endif | 369 | #endif |
| 345 | #define fn_gnutls_global_set_log_function gnutls_global_set_log_function | ||
| 346 | #define fn_gnutls_global_set_log_level gnutls_global_set_log_level | ||
| 347 | #define fn_gnutls_global_set_mem_functions gnutls_global_set_mem_functions | ||
| 348 | #define fn_gnutls_handshake gnutls_handshake | ||
| 349 | #define fn_gnutls_init gnutls_init | ||
| 350 | #define fn_gnutls_kx_get gnutls_kx_get | ||
| 351 | #define fn_gnutls_kx_get_name gnutls_kx_get_name | ||
| 352 | #define fn_gnutls_mac_get gnutls_mac_get | ||
| 353 | #define fn_gnutls_mac_get_name gnutls_mac_get_name | ||
| 354 | #define fn_gnutls_pk_algorithm_get_name gnutls_pk_algorithm_get_name | ||
| 355 | #define fn_gnutls_pk_bits_to_sec_param gnutls_pk_bits_to_sec_param | ||
| 356 | #define fn_gnutls_priority_set_direct gnutls_priority_set_direct | ||
| 357 | #define fn_gnutls_protocol_get_name gnutls_protocol_get_name | ||
| 358 | #define fn_gnutls_protocol_get_version gnutls_protocol_get_version | ||
| 359 | #define fn_gnutls_record_check_pending gnutls_record_check_pending | ||
| 360 | #define fn_gnutls_record_recv gnutls_record_recv | ||
| 361 | #define fn_gnutls_record_send gnutls_record_send | ||
| 362 | #define fn_gnutls_sec_param_get_name gnutls_sec_param_get_name | ||
| 363 | #define fn_gnutls_server_name_set gnutls_server_name_set | ||
| 364 | #define fn_gnutls_sign_get_name gnutls_sign_get_name | ||
| 365 | #define fn_gnutls_strerror gnutls_strerror | ||
| 366 | #define fn_gnutls_transport_set_ptr2 gnutls_transport_set_ptr2 | ||
| 367 | #define fn_gnutls_x509_crt_check_hostname gnutls_x509_crt_check_hostname | ||
| 368 | #define fn_gnutls_x509_crt_deinit gnutls_x509_crt_deinit | ||
| 369 | #define fn_gnutls_x509_crt_get_activation_time gnutls_x509_crt_get_activation_time | ||
| 370 | #define fn_gnutls_x509_crt_get_dn gnutls_x509_crt_get_dn | ||
| 371 | #define fn_gnutls_x509_crt_get_expiration_time gnutls_x509_crt_get_expiration_time | ||
| 372 | #define fn_gnutls_x509_crt_get_fingerprint gnutls_x509_crt_get_fingerprint | ||
| 373 | #define fn_gnutls_x509_crt_get_issuer_dn gnutls_x509_crt_get_issuer_dn | ||
| 374 | #define fn_gnutls_x509_crt_get_issuer_unique_id gnutls_x509_crt_get_issuer_unique_id | ||
| 375 | #define fn_gnutls_x509_crt_get_key_id gnutls_x509_crt_get_key_id | ||
| 376 | #define fn_gnutls_x509_crt_get_pk_algorithm gnutls_x509_crt_get_pk_algorithm | ||
| 377 | #define fn_gnutls_x509_crt_get_serial gnutls_x509_crt_get_serial | ||
| 378 | #define fn_gnutls_x509_crt_get_signature_algorithm gnutls_x509_crt_get_signature_algorithm | ||
| 379 | #define fn_gnutls_x509_crt_get_subject_unique_id gnutls_x509_crt_get_subject_unique_id | ||
| 380 | #define fn_gnutls_x509_crt_get_version gnutls_x509_crt_get_version | ||
| 381 | #define fn_gnutls_x509_crt_import gnutls_x509_crt_import | ||
| 382 | #define fn_gnutls_x509_crt_init gnutls_x509_crt_init | ||
| 383 | |||
| 384 | #endif /* !WINDOWSNT */ | ||
| 385 | 370 | ||
| 386 | 371 | ||
| 372 | /* Report memory exhaustion if ERR is an out-of-memory indication. */ | ||
| 373 | static void | ||
| 374 | check_memory_full (int err) | ||
| 375 | { | ||
| 376 | /* When GnuTLS exhausts memory, it doesn't say how much memory it | ||
| 377 | asked for, so tell the Emacs allocator that GnuTLS asked for no | ||
| 378 | bytes. This isn't accurate, but it's good enough. */ | ||
| 379 | if (err == GNUTLS_E_MEMORY_ERROR) | ||
| 380 | memory_full (0); | ||
| 381 | } | ||
| 382 | |||
| 387 | #ifdef HAVE_GNUTLS3 | 383 | #ifdef HAVE_GNUTLS3 |
| 388 | /* Log a simple audit message. */ | 384 | /* Log a simple audit message. */ |
| 389 | static void | 385 | static void |
| @@ -432,11 +428,11 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) | |||
| 432 | /* On W32 we cannot transfer socket handles between different runtime | 428 | /* On W32 we cannot transfer socket handles between different runtime |
| 433 | libraries, so we tell GnuTLS to use our special push/pull | 429 | libraries, so we tell GnuTLS to use our special push/pull |
| 434 | functions. */ | 430 | functions. */ |
| 435 | fn_gnutls_transport_set_ptr2 (state, | 431 | gnutls_transport_set_ptr2 (state, |
| 436 | (gnutls_transport_ptr_t) proc, | 432 | (gnutls_transport_ptr_t) proc, |
| 437 | (gnutls_transport_ptr_t) proc); | 433 | (gnutls_transport_ptr_t) proc); |
| 438 | fn_gnutls_transport_set_push_function (state, &emacs_gnutls_push); | 434 | gnutls_transport_set_push_function (state, &emacs_gnutls_push); |
| 439 | fn_gnutls_transport_set_pull_function (state, &emacs_gnutls_pull); | 435 | gnutls_transport_set_pull_function (state, &emacs_gnutls_pull); |
| 440 | 436 | ||
| 441 | /* For non blocking sockets or other custom made pull/push | 437 | /* For non blocking sockets or other custom made pull/push |
| 442 | functions the gnutls_transport_set_lowat must be called, with | 438 | functions the gnutls_transport_set_lowat must be called, with |
| @@ -449,15 +445,15 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) | |||
| 449 | zero by default in version 2.11.1, and the function | 445 | zero by default in version 2.11.1, and the function |
| 450 | gnutls_transport_set_lowat was removed from the library in | 446 | gnutls_transport_set_lowat was removed from the library in |
| 451 | version 2.99.0. */ | 447 | version 2.99.0. */ |
| 452 | if (!fn_gnutls_check_version ("2.11.1")) | 448 | if (!gnutls_check_version ("2.11.1")) |
| 453 | fn_gnutls_transport_set_lowat (state, 0); | 449 | gnutls_transport_set_lowat (state, 0); |
| 454 | #else | 450 | #else |
| 455 | /* This is how GnuTLS takes sockets: as file descriptors passed | 451 | /* This is how GnuTLS takes sockets: as file descriptors passed |
| 456 | in. For an Emacs process socket, infd and outfd are the | 452 | in. For an Emacs process socket, infd and outfd are the |
| 457 | same but we use this two-argument version for clarity. */ | 453 | same but we use this two-argument version for clarity. */ |
| 458 | fn_gnutls_transport_set_ptr2 (state, | 454 | gnutls_transport_set_ptr2 (state, |
| 459 | (void *) (intptr_t) proc->infd, | 455 | (void *) (intptr_t) proc->infd, |
| 460 | (void *) (intptr_t) proc->outfd); | 456 | (void *) (intptr_t) proc->outfd); |
| 461 | #endif | 457 | #endif |
| 462 | 458 | ||
| 463 | proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; | 459 | proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; |
| @@ -465,11 +461,11 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) | |||
| 465 | 461 | ||
| 466 | do | 462 | do |
| 467 | { | 463 | { |
| 468 | ret = fn_gnutls_handshake (state); | 464 | ret = gnutls_handshake (state); |
| 469 | emacs_gnutls_handle_error (state, ret); | 465 | emacs_gnutls_handle_error (state, ret); |
| 470 | QUIT; | 466 | QUIT; |
| 471 | } | 467 | } |
| 472 | while (ret < 0 && fn_gnutls_error_is_fatal (ret) == 0); | 468 | while (ret < 0 && gnutls_error_is_fatal (ret) == 0); |
| 473 | 469 | ||
| 474 | proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; | 470 | proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; |
| 475 | 471 | ||
| @@ -480,7 +476,7 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) | |||
| 480 | } | 476 | } |
| 481 | else | 477 | else |
| 482 | { | 478 | { |
| 483 | fn_gnutls_alert_send_appropriate (state, ret); | 479 | check_memory_full (gnutls_alert_send_appropriate (state, ret)); |
| 484 | } | 480 | } |
| 485 | return ret; | 481 | return ret; |
| 486 | } | 482 | } |
| @@ -488,14 +484,14 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) | |||
| 488 | ptrdiff_t | 484 | ptrdiff_t |
| 489 | emacs_gnutls_record_check_pending (gnutls_session_t state) | 485 | emacs_gnutls_record_check_pending (gnutls_session_t state) |
| 490 | { | 486 | { |
| 491 | return fn_gnutls_record_check_pending (state); | 487 | return gnutls_record_check_pending (state); |
| 492 | } | 488 | } |
| 493 | 489 | ||
| 494 | #ifdef WINDOWSNT | 490 | #ifdef WINDOWSNT |
| 495 | void | 491 | void |
| 496 | emacs_gnutls_transport_set_errno (gnutls_session_t state, int err) | 492 | emacs_gnutls_transport_set_errno (gnutls_session_t state, int err) |
| 497 | { | 493 | { |
| 498 | fn_gnutls_transport_set_errno (state, err); | 494 | gnutls_transport_set_errno (state, err); |
| 499 | } | 495 | } |
| 500 | #endif | 496 | #endif |
| 501 | 497 | ||
| @@ -516,7 +512,7 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte) | |||
| 516 | 512 | ||
| 517 | while (nbyte > 0) | 513 | while (nbyte > 0) |
| 518 | { | 514 | { |
| 519 | rtnval = fn_gnutls_record_send (state, buf, nbyte); | 515 | rtnval = gnutls_record_send (state, buf, nbyte); |
| 520 | 516 | ||
| 521 | if (rtnval < 0) | 517 | if (rtnval < 0) |
| 522 | { | 518 | { |
| @@ -568,7 +564,7 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte) | |||
| 568 | proc->gnutls_handshakes_tried = 0; | 564 | proc->gnutls_handshakes_tried = 0; |
| 569 | return 0; | 565 | return 0; |
| 570 | } | 566 | } |
| 571 | rtnval = fn_gnutls_record_recv (state, buf, nbyte); | 567 | rtnval = gnutls_record_recv (state, buf, nbyte); |
| 572 | if (rtnval >= 0) | 568 | if (rtnval >= 0) |
| 573 | return rtnval; | 569 | return rtnval; |
| 574 | else if (rtnval == GNUTLS_E_UNEXPECTED_PACKET_LENGTH) | 570 | else if (rtnval == GNUTLS_E_UNEXPECTED_PACKET_LENGTH) |
| @@ -597,15 +593,17 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err) | |||
| 597 | if (err >= 0) | 593 | if (err >= 0) |
| 598 | return 1; | 594 | return 1; |
| 599 | 595 | ||
| 596 | check_memory_full (err); | ||
| 597 | |||
| 600 | max_log_level = global_gnutls_log_level; | 598 | max_log_level = global_gnutls_log_level; |
| 601 | 599 | ||
| 602 | /* TODO: use gnutls-error-fatalp and gnutls-error-string. */ | 600 | /* TODO: use gnutls-error-fatalp and gnutls-error-string. */ |
| 603 | 601 | ||
| 604 | str = fn_gnutls_strerror (err); | 602 | str = gnutls_strerror (err); |
| 605 | if (!str) | 603 | if (!str) |
| 606 | str = "unknown"; | 604 | str = "unknown"; |
| 607 | 605 | ||
| 608 | if (fn_gnutls_error_is_fatal (err)) | 606 | if (gnutls_error_is_fatal (err)) |
| 609 | { | 607 | { |
| 610 | ret = 0; | 608 | ret = 0; |
| 611 | GNUTLS_LOG2 (1, max_log_level, "fatal error:", str); | 609 | GNUTLS_LOG2 (1, max_log_level, "fatal error:", str); |
| @@ -632,9 +630,9 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err) | |||
| 632 | if (err == GNUTLS_E_WARNING_ALERT_RECEIVED | 630 | if (err == GNUTLS_E_WARNING_ALERT_RECEIVED |
| 633 | || err == GNUTLS_E_FATAL_ALERT_RECEIVED) | 631 | || err == GNUTLS_E_FATAL_ALERT_RECEIVED) |
| 634 | { | 632 | { |
| 635 | int alert = fn_gnutls_alert_get (session); | 633 | int alert = gnutls_alert_get (session); |
| 636 | int level = (err == GNUTLS_E_FATAL_ALERT_RECEIVED) ? 0 : 1; | 634 | int level = (err == GNUTLS_E_FATAL_ALERT_RECEIVED) ? 0 : 1; |
| 637 | str = fn_gnutls_alert_get_name (alert); | 635 | str = gnutls_alert_get_name (alert); |
| 638 | if (!str) | 636 | if (!str) |
| 639 | str = "unknown"; | 637 | str = "unknown"; |
| 640 | 638 | ||
| @@ -662,6 +660,7 @@ gnutls_make_error (int err) | |||
| 662 | return Qgnutls_e_invalid_session; | 660 | return Qgnutls_e_invalid_session; |
| 663 | } | 661 | } |
| 664 | 662 | ||
| 663 | check_memory_full (err); | ||
| 665 | return make_number (err); | 664 | return make_number (err); |
| 666 | } | 665 | } |
| 667 | 666 | ||
| @@ -680,20 +679,20 @@ emacs_gnutls_deinit (Lisp_Object proc) | |||
| 680 | if (XPROCESS (proc)->gnutls_x509_cred) | 679 | if (XPROCESS (proc)->gnutls_x509_cred) |
| 681 | { | 680 | { |
| 682 | GNUTLS_LOG (2, log_level, "Deallocating x509 credentials"); | 681 | GNUTLS_LOG (2, log_level, "Deallocating x509 credentials"); |
| 683 | fn_gnutls_certificate_free_credentials (XPROCESS (proc)->gnutls_x509_cred); | 682 | gnutls_certificate_free_credentials (XPROCESS (proc)->gnutls_x509_cred); |
| 684 | XPROCESS (proc)->gnutls_x509_cred = NULL; | 683 | XPROCESS (proc)->gnutls_x509_cred = NULL; |
| 685 | } | 684 | } |
| 686 | 685 | ||
| 687 | if (XPROCESS (proc)->gnutls_anon_cred) | 686 | if (XPROCESS (proc)->gnutls_anon_cred) |
| 688 | { | 687 | { |
| 689 | GNUTLS_LOG (2, log_level, "Deallocating anon credentials"); | 688 | GNUTLS_LOG (2, log_level, "Deallocating anon credentials"); |
| 690 | fn_gnutls_anon_free_client_credentials (XPROCESS (proc)->gnutls_anon_cred); | 689 | gnutls_anon_free_client_credentials (XPROCESS (proc)->gnutls_anon_cred); |
| 691 | XPROCESS (proc)->gnutls_anon_cred = NULL; | 690 | XPROCESS (proc)->gnutls_anon_cred = NULL; |
| 692 | } | 691 | } |
| 693 | 692 | ||
| 694 | if (XPROCESS (proc)->gnutls_state) | 693 | if (XPROCESS (proc)->gnutls_state) |
| 695 | { | 694 | { |
| 696 | fn_gnutls_deinit (XPROCESS (proc)->gnutls_state); | 695 | gnutls_deinit (XPROCESS (proc)->gnutls_state); |
| 697 | XPROCESS (proc)->gnutls_state = NULL; | 696 | XPROCESS (proc)->gnutls_state = NULL; |
| 698 | if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) | 697 | if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) |
| 699 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1; | 698 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1; |
| @@ -750,7 +749,7 @@ Usage: (gnutls-error-fatalp ERROR) */) | |||
| 750 | if (! TYPE_RANGED_INTEGERP (int, err)) | 749 | if (! TYPE_RANGED_INTEGERP (int, err)) |
| 751 | error ("Not an error symbol or code"); | 750 | error ("Not an error symbol or code"); |
| 752 | 751 | ||
| 753 | if (0 == fn_gnutls_error_is_fatal (XINT (err))) | 752 | if (0 == gnutls_error_is_fatal (XINT (err))) |
| 754 | return Qnil; | 753 | return Qnil; |
| 755 | 754 | ||
| 756 | return Qt; | 755 | return Qt; |
| @@ -782,7 +781,7 @@ usage: (gnutls-error-string ERROR) */) | |||
| 782 | if (! TYPE_RANGED_INTEGERP (int, err)) | 781 | if (! TYPE_RANGED_INTEGERP (int, err)) |
| 783 | return build_string ("Not an error symbol or code"); | 782 | return build_string ("Not an error symbol or code"); |
| 784 | 783 | ||
| 785 | return build_string (fn_gnutls_strerror (XINT (err))); | 784 | return build_string (gnutls_strerror (XINT (err))); |
| 786 | } | 785 | } |
| 787 | 786 | ||
| 788 | DEFUN ("gnutls-deinit", Fgnutls_deinit, Sgnutls_deinit, 1, 1, 0, | 787 | DEFUN ("gnutls-deinit", Fgnutls_deinit, Sgnutls_deinit, 1, 1, 0, |
| @@ -821,7 +820,8 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 821 | 820 | ||
| 822 | /* Version. */ | 821 | /* Version. */ |
| 823 | { | 822 | { |
| 824 | int version = fn_gnutls_x509_crt_get_version (cert); | 823 | int version = gnutls_x509_crt_get_version (cert); |
| 824 | check_memory_full (version); | ||
| 825 | if (version >= GNUTLS_E_SUCCESS) | 825 | if (version >= GNUTLS_E_SUCCESS) |
| 826 | res = nconc2 (res, list2 (intern (":version"), | 826 | res = nconc2 (res, list2 (intern (":version"), |
| 827 | make_number (version))); | 827 | make_number (version))); |
| @@ -829,11 +829,13 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 829 | 829 | ||
| 830 | /* Serial. */ | 830 | /* Serial. */ |
| 831 | buf_size = 0; | 831 | buf_size = 0; |
| 832 | err = fn_gnutls_x509_crt_get_serial (cert, NULL, &buf_size); | 832 | err = gnutls_x509_crt_get_serial (cert, NULL, &buf_size); |
| 833 | check_memory_full (err); | ||
| 833 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) | 834 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) |
| 834 | { | 835 | { |
| 835 | void *serial = xmalloc (buf_size); | 836 | void *serial = xmalloc (buf_size); |
| 836 | err = fn_gnutls_x509_crt_get_serial (cert, serial, &buf_size); | 837 | err = gnutls_x509_crt_get_serial (cert, serial, &buf_size); |
| 838 | check_memory_full (err); | ||
| 837 | if (err >= GNUTLS_E_SUCCESS) | 839 | if (err >= GNUTLS_E_SUCCESS) |
| 838 | res = nconc2 (res, list2 (intern (":serial-number"), | 840 | res = nconc2 (res, list2 (intern (":serial-number"), |
| 839 | gnutls_hex_string (serial, buf_size, ""))); | 841 | gnutls_hex_string (serial, buf_size, ""))); |
| @@ -842,11 +844,13 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 842 | 844 | ||
| 843 | /* Issuer. */ | 845 | /* Issuer. */ |
| 844 | buf_size = 0; | 846 | buf_size = 0; |
| 845 | err = fn_gnutls_x509_crt_get_issuer_dn (cert, NULL, &buf_size); | 847 | err = gnutls_x509_crt_get_issuer_dn (cert, NULL, &buf_size); |
| 848 | check_memory_full (err); | ||
| 846 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) | 849 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) |
| 847 | { | 850 | { |
| 848 | char *dn = xmalloc (buf_size); | 851 | char *dn = xmalloc (buf_size); |
| 849 | err = fn_gnutls_x509_crt_get_issuer_dn (cert, dn, &buf_size); | 852 | err = gnutls_x509_crt_get_issuer_dn (cert, dn, &buf_size); |
| 853 | check_memory_full (err); | ||
| 850 | if (err >= GNUTLS_E_SUCCESS) | 854 | if (err >= GNUTLS_E_SUCCESS) |
| 851 | res = nconc2 (res, list2 (intern (":issuer"), | 855 | res = nconc2 (res, list2 (intern (":issuer"), |
| 852 | make_string (dn, buf_size))); | 856 | make_string (dn, buf_size))); |
| @@ -859,23 +863,25 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 859 | that might add 1 to the year length. */ | 863 | that might add 1 to the year length. */ |
| 860 | char buf[INT_STRLEN_BOUND (int) + 1 + sizeof "-12-31"]; | 864 | char buf[INT_STRLEN_BOUND (int) + 1 + sizeof "-12-31"]; |
| 861 | struct tm t; | 865 | struct tm t; |
| 862 | time_t tim = fn_gnutls_x509_crt_get_activation_time (cert); | 866 | time_t tim = gnutls_x509_crt_get_activation_time (cert); |
| 863 | 867 | ||
| 864 | if (gmtime_r (&tim, &t) && strftime (buf, sizeof buf, "%Y-%m-%d", &t)) | 868 | if (gmtime_r (&tim, &t) && strftime (buf, sizeof buf, "%Y-%m-%d", &t)) |
| 865 | res = nconc2 (res, list2 (intern (":valid-from"), build_string (buf))); | 869 | res = nconc2 (res, list2 (intern (":valid-from"), build_string (buf))); |
| 866 | 870 | ||
| 867 | tim = fn_gnutls_x509_crt_get_expiration_time (cert); | 871 | tim = gnutls_x509_crt_get_expiration_time (cert); |
| 868 | if (gmtime_r (&tim, &t) && strftime (buf, sizeof buf, "%Y-%m-%d", &t)) | 872 | if (gmtime_r (&tim, &t) && strftime (buf, sizeof buf, "%Y-%m-%d", &t)) |
| 869 | res = nconc2 (res, list2 (intern (":valid-to"), build_string (buf))); | 873 | res = nconc2 (res, list2 (intern (":valid-to"), build_string (buf))); |
| 870 | } | 874 | } |
| 871 | 875 | ||
| 872 | /* Subject. */ | 876 | /* Subject. */ |
| 873 | buf_size = 0; | 877 | buf_size = 0; |
| 874 | err = fn_gnutls_x509_crt_get_dn (cert, NULL, &buf_size); | 878 | err = gnutls_x509_crt_get_dn (cert, NULL, &buf_size); |
| 879 | check_memory_full (err); | ||
| 875 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) | 880 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) |
| 876 | { | 881 | { |
| 877 | char *dn = xmalloc (buf_size); | 882 | char *dn = xmalloc (buf_size); |
| 878 | err = fn_gnutls_x509_crt_get_dn (cert, dn, &buf_size); | 883 | err = gnutls_x509_crt_get_dn (cert, dn, &buf_size); |
| 884 | check_memory_full (err); | ||
| 879 | if (err >= GNUTLS_E_SUCCESS) | 885 | if (err >= GNUTLS_E_SUCCESS) |
| 880 | res = nconc2 (res, list2 (intern (":subject"), | 886 | res = nconc2 (res, list2 (intern (":subject"), |
| 881 | make_string (dn, buf_size))); | 887 | make_string (dn, buf_size))); |
| @@ -888,16 +894,17 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 888 | { | 894 | { |
| 889 | unsigned int bits; | 895 | unsigned int bits; |
| 890 | 896 | ||
| 891 | err = fn_gnutls_x509_crt_get_pk_algorithm (cert, &bits); | 897 | err = gnutls_x509_crt_get_pk_algorithm (cert, &bits); |
| 898 | check_memory_full (err); | ||
| 892 | if (err >= GNUTLS_E_SUCCESS) | 899 | if (err >= GNUTLS_E_SUCCESS) |
| 893 | { | 900 | { |
| 894 | const char *name = fn_gnutls_pk_algorithm_get_name (err); | 901 | const char *name = gnutls_pk_algorithm_get_name (err); |
| 895 | if (name) | 902 | if (name) |
| 896 | res = nconc2 (res, list2 (intern (":public-key-algorithm"), | 903 | res = nconc2 (res, list2 (intern (":public-key-algorithm"), |
| 897 | build_string (name))); | 904 | build_string (name))); |
| 898 | 905 | ||
| 899 | name = fn_gnutls_sec_param_get_name (fn_gnutls_pk_bits_to_sec_param | 906 | name = gnutls_sec_param_get_name (gnutls_pk_bits_to_sec_param |
| 900 | (err, bits)); | 907 | (err, bits)); |
| 901 | res = nconc2 (res, list2 (intern (":certificate-security-level"), | 908 | res = nconc2 (res, list2 (intern (":certificate-security-level"), |
| 902 | build_string (name))); | 909 | build_string (name))); |
| 903 | } | 910 | } |
| @@ -905,11 +912,13 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 905 | 912 | ||
| 906 | /* Unique IDs. */ | 913 | /* Unique IDs. */ |
| 907 | buf_size = 0; | 914 | buf_size = 0; |
| 908 | err = fn_gnutls_x509_crt_get_issuer_unique_id (cert, NULL, &buf_size); | 915 | err = gnutls_x509_crt_get_issuer_unique_id (cert, NULL, &buf_size); |
| 916 | check_memory_full (err); | ||
| 909 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) | 917 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) |
| 910 | { | 918 | { |
| 911 | char *buf = xmalloc (buf_size); | 919 | char *buf = xmalloc (buf_size); |
| 912 | err = fn_gnutls_x509_crt_get_issuer_unique_id (cert, buf, &buf_size); | 920 | err = gnutls_x509_crt_get_issuer_unique_id (cert, buf, &buf_size); |
| 921 | check_memory_full (err); | ||
| 913 | if (err >= GNUTLS_E_SUCCESS) | 922 | if (err >= GNUTLS_E_SUCCESS) |
| 914 | res = nconc2 (res, list2 (intern (":issuer-unique-id"), | 923 | res = nconc2 (res, list2 (intern (":issuer-unique-id"), |
| 915 | make_string (buf, buf_size))); | 924 | make_string (buf, buf_size))); |
| @@ -917,11 +926,13 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 917 | } | 926 | } |
| 918 | 927 | ||
| 919 | buf_size = 0; | 928 | buf_size = 0; |
| 920 | err = fn_gnutls_x509_crt_get_subject_unique_id (cert, NULL, &buf_size); | 929 | err = gnutls_x509_crt_get_subject_unique_id (cert, NULL, &buf_size); |
| 930 | check_memory_full (err); | ||
| 921 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) | 931 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) |
| 922 | { | 932 | { |
| 923 | char *buf = xmalloc (buf_size); | 933 | char *buf = xmalloc (buf_size); |
| 924 | err = fn_gnutls_x509_crt_get_subject_unique_id (cert, buf, &buf_size); | 934 | err = gnutls_x509_crt_get_subject_unique_id (cert, buf, &buf_size); |
| 935 | check_memory_full (err); | ||
| 925 | if (err >= GNUTLS_E_SUCCESS) | 936 | if (err >= GNUTLS_E_SUCCESS) |
| 926 | res = nconc2 (res, list2 (intern (":subject-unique-id"), | 937 | res = nconc2 (res, list2 (intern (":subject-unique-id"), |
| 927 | make_string (buf, buf_size))); | 938 | make_string (buf, buf_size))); |
| @@ -930,10 +941,11 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 930 | #endif | 941 | #endif |
| 931 | 942 | ||
| 932 | /* Signature. */ | 943 | /* Signature. */ |
| 933 | err = fn_gnutls_x509_crt_get_signature_algorithm (cert); | 944 | err = gnutls_x509_crt_get_signature_algorithm (cert); |
| 945 | check_memory_full (err); | ||
| 934 | if (err >= GNUTLS_E_SUCCESS) | 946 | if (err >= GNUTLS_E_SUCCESS) |
| 935 | { | 947 | { |
| 936 | const char *name = fn_gnutls_sign_get_name (err); | 948 | const char *name = gnutls_sign_get_name (err); |
| 937 | if (name) | 949 | if (name) |
| 938 | res = nconc2 (res, list2 (intern (":signature-algorithm"), | 950 | res = nconc2 (res, list2 (intern (":signature-algorithm"), |
| 939 | build_string (name))); | 951 | build_string (name))); |
| @@ -941,11 +953,13 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 941 | 953 | ||
| 942 | /* Public key ID. */ | 954 | /* Public key ID. */ |
| 943 | buf_size = 0; | 955 | buf_size = 0; |
| 944 | err = fn_gnutls_x509_crt_get_key_id (cert, 0, NULL, &buf_size); | 956 | err = gnutls_x509_crt_get_key_id (cert, 0, NULL, &buf_size); |
| 957 | check_memory_full (err); | ||
| 945 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) | 958 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) |
| 946 | { | 959 | { |
| 947 | void *buf = xmalloc (buf_size); | 960 | void *buf = xmalloc (buf_size); |
| 948 | err = fn_gnutls_x509_crt_get_key_id (cert, 0, buf, &buf_size); | 961 | err = gnutls_x509_crt_get_key_id (cert, 0, buf, &buf_size); |
| 962 | check_memory_full (err); | ||
| 949 | if (err >= GNUTLS_E_SUCCESS) | 963 | if (err >= GNUTLS_E_SUCCESS) |
| 950 | res = nconc2 (res, list2 (intern (":public-key-id"), | 964 | res = nconc2 (res, list2 (intern (":public-key-id"), |
| 951 | gnutls_hex_string (buf, buf_size, "sha1:"))); | 965 | gnutls_hex_string (buf, buf_size, "sha1:"))); |
| @@ -954,13 +968,15 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) | |||
| 954 | 968 | ||
| 955 | /* Certificate fingerprint. */ | 969 | /* Certificate fingerprint. */ |
| 956 | buf_size = 0; | 970 | buf_size = 0; |
| 957 | err = fn_gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1, | 971 | err = gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1, |
| 958 | NULL, &buf_size); | 972 | NULL, &buf_size); |
| 973 | check_memory_full (err); | ||
| 959 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) | 974 | if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) |
| 960 | { | 975 | { |
| 961 | void *buf = xmalloc (buf_size); | 976 | void *buf = xmalloc (buf_size); |
| 962 | err = fn_gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1, | 977 | err = gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1, |
| 963 | buf, &buf_size); | 978 | buf, &buf_size); |
| 979 | check_memory_full (err); | ||
| 964 | if (err >= GNUTLS_E_SUCCESS) | 980 | if (err >= GNUTLS_E_SUCCESS) |
| 965 | res = nconc2 (res, list2 (intern (":certificate-id"), | 981 | res = nconc2 (res, list2 (intern (":certificate-id"), |
| 966 | gnutls_hex_string (buf, buf_size, "sha1:"))); | 982 | gnutls_hex_string (buf, buf_size, "sha1:"))); |
| @@ -1061,7 +1077,8 @@ The return value is a property list with top-level keys :warnings and | |||
| 1061 | 1077 | ||
| 1062 | /* Diffie-Hellman prime bits. */ | 1078 | /* Diffie-Hellman prime bits. */ |
| 1063 | { | 1079 | { |
| 1064 | int bits = fn_gnutls_dh_get_prime_bits (state); | 1080 | int bits = gnutls_dh_get_prime_bits (state); |
| 1081 | check_memory_full (bits); | ||
| 1065 | if (bits > 0) | 1082 | if (bits > 0) |
| 1066 | result = nconc2 (result, list2 (intern (":diffie-hellman-prime-bits"), | 1083 | result = nconc2 (result, list2 (intern (":diffie-hellman-prime-bits"), |
| 1067 | make_number (bits))); | 1084 | make_number (bits))); |
| @@ -1070,26 +1087,26 @@ The return value is a property list with top-level keys :warnings and | |||
| 1070 | /* Key exchange. */ | 1087 | /* Key exchange. */ |
| 1071 | result = nconc2 | 1088 | result = nconc2 |
| 1072 | (result, list2 (intern (":key-exchange"), | 1089 | (result, list2 (intern (":key-exchange"), |
| 1073 | build_string (fn_gnutls_kx_get_name | 1090 | build_string (gnutls_kx_get_name |
| 1074 | (fn_gnutls_kx_get (state))))); | 1091 | (gnutls_kx_get (state))))); |
| 1075 | 1092 | ||
| 1076 | /* Protocol name. */ | 1093 | /* Protocol name. */ |
| 1077 | result = nconc2 | 1094 | result = nconc2 |
| 1078 | (result, list2 (intern (":protocol"), | 1095 | (result, list2 (intern (":protocol"), |
| 1079 | build_string (fn_gnutls_protocol_get_name | 1096 | build_string (gnutls_protocol_get_name |
| 1080 | (fn_gnutls_protocol_get_version (state))))); | 1097 | (gnutls_protocol_get_version (state))))); |
| 1081 | 1098 | ||
| 1082 | /* Cipher name. */ | 1099 | /* Cipher name. */ |
| 1083 | result = nconc2 | 1100 | result = nconc2 |
| 1084 | (result, list2 (intern (":cipher"), | 1101 | (result, list2 (intern (":cipher"), |
| 1085 | build_string (fn_gnutls_cipher_get_name | 1102 | build_string (gnutls_cipher_get_name |
| 1086 | (fn_gnutls_cipher_get (state))))); | 1103 | (gnutls_cipher_get (state))))); |
| 1087 | 1104 | ||
| 1088 | /* MAC name. */ | 1105 | /* MAC name. */ |
| 1089 | result = nconc2 | 1106 | result = nconc2 |
| 1090 | (result, list2 (intern (":mac"), | 1107 | (result, list2 (intern (":mac"), |
| 1091 | build_string (fn_gnutls_mac_get_name | 1108 | build_string (gnutls_mac_get_name |
| 1092 | (fn_gnutls_mac_get (state))))); | 1109 | (gnutls_mac_get (state))))); |
| 1093 | 1110 | ||
| 1094 | 1111 | ||
| 1095 | return result; | 1112 | return result; |
| @@ -1104,11 +1121,8 @@ emacs_gnutls_global_init (void) | |||
| 1104 | int ret = GNUTLS_E_SUCCESS; | 1121 | int ret = GNUTLS_E_SUCCESS; |
| 1105 | 1122 | ||
| 1106 | if (!gnutls_global_initialized) | 1123 | if (!gnutls_global_initialized) |
| 1107 | { | 1124 | ret = gnutls_global_init (); |
| 1108 | fn_gnutls_global_set_mem_functions (xmalloc, xmalloc, NULL, | 1125 | |
| 1109 | xrealloc, xfree); | ||
| 1110 | ret = fn_gnutls_global_init (); | ||
| 1111 | } | ||
| 1112 | gnutls_global_initialized = 1; | 1126 | gnutls_global_initialized = 1; |
| 1113 | 1127 | ||
| 1114 | return gnutls_make_error (ret); | 1128 | return gnutls_make_error (ret); |
| @@ -1257,11 +1271,11 @@ one trustfile (usually a CA bundle). */) | |||
| 1257 | 1271 | ||
| 1258 | if (TYPE_RANGED_INTEGERP (int, loglevel)) | 1272 | if (TYPE_RANGED_INTEGERP (int, loglevel)) |
| 1259 | { | 1273 | { |
| 1260 | fn_gnutls_global_set_log_function (gnutls_log_function); | 1274 | gnutls_global_set_log_function (gnutls_log_function); |
| 1261 | #ifdef HAVE_GNUTLS3 | 1275 | #ifdef HAVE_GNUTLS3 |
| 1262 | fn_gnutls_global_set_audit_log_function (gnutls_audit_log_function); | 1276 | gnutls_global_set_audit_log_function (gnutls_audit_log_function); |
| 1263 | #endif | 1277 | #endif |
| 1264 | fn_gnutls_global_set_log_level (XINT (loglevel)); | 1278 | gnutls_global_set_log_level (XINT (loglevel)); |
| 1265 | max_log_level = XINT (loglevel); | 1279 | max_log_level = XINT (loglevel); |
| 1266 | XPROCESS (proc)->gnutls_log_level = max_log_level; | 1280 | XPROCESS (proc)->gnutls_log_level = max_log_level; |
| 1267 | } | 1281 | } |
| @@ -1291,7 +1305,7 @@ one trustfile (usually a CA bundle). */) | |||
| 1291 | unsigned int gnutls_verify_flags = GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT; | 1305 | unsigned int gnutls_verify_flags = GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT; |
| 1292 | 1306 | ||
| 1293 | GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); | 1307 | GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); |
| 1294 | fn_gnutls_certificate_allocate_credentials (&x509_cred); | 1308 | check_memory_full (gnutls_certificate_allocate_credentials (&x509_cred)); |
| 1295 | XPROCESS (proc)->gnutls_x509_cred = x509_cred; | 1309 | XPROCESS (proc)->gnutls_x509_cred = x509_cred; |
| 1296 | 1310 | ||
| 1297 | verify_flags = Fplist_get (proplist, QCgnutls_bootprop_verify_flags); | 1311 | verify_flags = Fplist_get (proplist, QCgnutls_bootprop_verify_flags); |
| @@ -1305,12 +1319,12 @@ one trustfile (usually a CA bundle). */) | |||
| 1305 | else | 1319 | else |
| 1306 | GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags"); | 1320 | GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags"); |
| 1307 | 1321 | ||
| 1308 | fn_gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags); | 1322 | gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags); |
| 1309 | } | 1323 | } |
| 1310 | else /* Qgnutls_anon: */ | 1324 | else /* Qgnutls_anon: */ |
| 1311 | { | 1325 | { |
| 1312 | GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); | 1326 | GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); |
| 1313 | fn_gnutls_anon_allocate_client_credentials (&anon_cred); | 1327 | check_memory_full (gnutls_anon_allocate_client_credentials (&anon_cred)); |
| 1314 | XPROCESS (proc)->gnutls_anon_cred = anon_cred; | 1328 | XPROCESS (proc)->gnutls_anon_cred = anon_cred; |
| 1315 | } | 1329 | } |
| 1316 | 1330 | ||
| @@ -1324,10 +1338,13 @@ one trustfile (usually a CA bundle). */) | |||
| 1324 | 1338 | ||
| 1325 | #if GNUTLS_VERSION_MAJOR + \ | 1339 | #if GNUTLS_VERSION_MAJOR + \ |
| 1326 | (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3 | 1340 | (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3 |
| 1327 | ret = fn_gnutls_certificate_set_x509_system_trust (x509_cred); | 1341 | ret = gnutls_certificate_set_x509_system_trust (x509_cred); |
| 1328 | if (ret < GNUTLS_E_SUCCESS) | 1342 | if (ret < GNUTLS_E_SUCCESS) |
| 1329 | GNUTLS_LOG2i (4, max_log_level, | 1343 | { |
| 1330 | "setting system trust failed with code ", ret); | 1344 | check_memory_full (ret); |
| 1345 | GNUTLS_LOG2i (4, max_log_level, | ||
| 1346 | "setting system trust failed with code ", ret); | ||
| 1347 | } | ||
| 1331 | #endif | 1348 | #endif |
| 1332 | 1349 | ||
| 1333 | for (tail = trustfiles; CONSP (tail); tail = XCDR (tail)) | 1350 | for (tail = trustfiles; CONSP (tail); tail = XCDR (tail)) |
| @@ -1344,7 +1361,7 @@ one trustfile (usually a CA bundle). */) | |||
| 1344 | name using the current ANSI codepage. */ | 1361 | name using the current ANSI codepage. */ |
| 1345 | trustfile = ansi_encode_filename (trustfile); | 1362 | trustfile = ansi_encode_filename (trustfile); |
| 1346 | #endif | 1363 | #endif |
| 1347 | ret = fn_gnutls_certificate_set_x509_trust_file | 1364 | ret = gnutls_certificate_set_x509_trust_file |
| 1348 | (x509_cred, | 1365 | (x509_cred, |
| 1349 | SSDATA (trustfile), | 1366 | SSDATA (trustfile), |
| 1350 | file_format); | 1367 | file_format); |
| @@ -1370,7 +1387,7 @@ one trustfile (usually a CA bundle). */) | |||
| 1370 | #ifdef WINDOWSNT | 1387 | #ifdef WINDOWSNT |
| 1371 | crlfile = ansi_encode_filename (crlfile); | 1388 | crlfile = ansi_encode_filename (crlfile); |
| 1372 | #endif | 1389 | #endif |
| 1373 | ret = fn_gnutls_certificate_set_x509_crl_file | 1390 | ret = gnutls_certificate_set_x509_crl_file |
| 1374 | (x509_cred, SSDATA (crlfile), file_format); | 1391 | (x509_cred, SSDATA (crlfile), file_format); |
| 1375 | 1392 | ||
| 1376 | if (ret < GNUTLS_E_SUCCESS) | 1393 | if (ret < GNUTLS_E_SUCCESS) |
| @@ -1399,7 +1416,7 @@ one trustfile (usually a CA bundle). */) | |||
| 1399 | keyfile = ansi_encode_filename (keyfile); | 1416 | keyfile = ansi_encode_filename (keyfile); |
| 1400 | certfile = ansi_encode_filename (certfile); | 1417 | certfile = ansi_encode_filename (certfile); |
| 1401 | #endif | 1418 | #endif |
| 1402 | ret = fn_gnutls_certificate_set_x509_key_file | 1419 | ret = gnutls_certificate_set_x509_key_file |
| 1403 | (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_format); | 1420 | (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_format); |
| 1404 | 1421 | ||
| 1405 | if (ret < GNUTLS_E_SUCCESS) | 1422 | if (ret < GNUTLS_E_SUCCESS) |
| @@ -1421,7 +1438,7 @@ one trustfile (usually a CA bundle). */) | |||
| 1421 | /* Call gnutls_init here: */ | 1438 | /* Call gnutls_init here: */ |
| 1422 | 1439 | ||
| 1423 | GNUTLS_LOG (1, max_log_level, "gnutls_init"); | 1440 | GNUTLS_LOG (1, max_log_level, "gnutls_init"); |
| 1424 | ret = fn_gnutls_init (&state, GNUTLS_CLIENT); | 1441 | ret = gnutls_init (&state, GNUTLS_CLIENT); |
| 1425 | XPROCESS (proc)->gnutls_state = state; | 1442 | XPROCESS (proc)->gnutls_state = state; |
| 1426 | if (ret < GNUTLS_E_SUCCESS) | 1443 | if (ret < GNUTLS_E_SUCCESS) |
| 1427 | return gnutls_make_error (ret); | 1444 | return gnutls_make_error (ret); |
| @@ -1440,27 +1457,25 @@ one trustfile (usually a CA bundle). */) | |||
| 1440 | } | 1457 | } |
| 1441 | 1458 | ||
| 1442 | GNUTLS_LOG (1, max_log_level, "setting the priority string"); | 1459 | GNUTLS_LOG (1, max_log_level, "setting the priority string"); |
| 1443 | ret = fn_gnutls_priority_set_direct (state, | 1460 | ret = gnutls_priority_set_direct (state, priority_string_ptr, NULL); |
| 1444 | priority_string_ptr, | ||
| 1445 | NULL); | ||
| 1446 | if (ret < GNUTLS_E_SUCCESS) | 1461 | if (ret < GNUTLS_E_SUCCESS) |
| 1447 | return gnutls_make_error (ret); | 1462 | return gnutls_make_error (ret); |
| 1448 | 1463 | ||
| 1449 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_PRIORITY; | 1464 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_PRIORITY; |
| 1450 | 1465 | ||
| 1451 | if (INTEGERP (prime_bits)) | 1466 | if (INTEGERP (prime_bits)) |
| 1452 | fn_gnutls_dh_set_prime_bits (state, XUINT (prime_bits)); | 1467 | gnutls_dh_set_prime_bits (state, XUINT (prime_bits)); |
| 1453 | 1468 | ||
| 1454 | ret = EQ (type, Qgnutls_x509pki) | 1469 | ret = EQ (type, Qgnutls_x509pki) |
| 1455 | ? fn_gnutls_credentials_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred) | 1470 | ? gnutls_credentials_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred) |
| 1456 | : fn_gnutls_credentials_set (state, GNUTLS_CRD_ANON, anon_cred); | 1471 | : gnutls_credentials_set (state, GNUTLS_CRD_ANON, anon_cred); |
| 1457 | if (ret < GNUTLS_E_SUCCESS) | 1472 | if (ret < GNUTLS_E_SUCCESS) |
| 1458 | return gnutls_make_error (ret); | 1473 | return gnutls_make_error (ret); |
| 1459 | 1474 | ||
| 1460 | if (!gnutls_ip_address_p (c_hostname)) | 1475 | if (!gnutls_ip_address_p (c_hostname)) |
| 1461 | { | 1476 | { |
| 1462 | ret = fn_gnutls_server_name_set (state, GNUTLS_NAME_DNS, c_hostname, | 1477 | ret = gnutls_server_name_set (state, GNUTLS_NAME_DNS, c_hostname, |
| 1463 | strlen (c_hostname)); | 1478 | strlen (c_hostname)); |
| 1464 | if (ret < GNUTLS_E_SUCCESS) | 1479 | if (ret < GNUTLS_E_SUCCESS) |
| 1465 | return gnutls_make_error (ret); | 1480 | return gnutls_make_error (ret); |
| 1466 | } | 1481 | } |
| @@ -1476,7 +1491,7 @@ one trustfile (usually a CA bundle). */) | |||
| 1476 | check of the certificate's hostname with | 1491 | check of the certificate's hostname with |
| 1477 | gnutls_x509_crt_check_hostname against :hostname. */ | 1492 | gnutls_x509_crt_check_hostname against :hostname. */ |
| 1478 | 1493 | ||
| 1479 | ret = fn_gnutls_certificate_verify_peers2 (state, &peer_verification); | 1494 | ret = gnutls_certificate_verify_peers2 (state, &peer_verification); |
| 1480 | if (ret < GNUTLS_E_SUCCESS) | 1495 | if (ret < GNUTLS_E_SUCCESS) |
| 1481 | return gnutls_make_error (ret); | 1496 | return gnutls_make_error (ret); |
| 1482 | 1497 | ||
| @@ -1514,47 +1529,50 @@ one trustfile (usually a CA bundle). */) | |||
| 1514 | /* Up to here the process is the same for X.509 certificates and | 1529 | /* Up to here the process is the same for X.509 certificates and |
| 1515 | OpenPGP keys. From now on X.509 certificates are assumed. This | 1530 | OpenPGP keys. From now on X.509 certificates are assumed. This |
| 1516 | can be easily extended to work with openpgp keys as well. */ | 1531 | can be easily extended to work with openpgp keys as well. */ |
| 1517 | if (fn_gnutls_certificate_type_get (state) == GNUTLS_CRT_X509) | 1532 | if (gnutls_certificate_type_get (state) == GNUTLS_CRT_X509) |
| 1518 | { | 1533 | { |
| 1519 | gnutls_x509_crt_t gnutls_verify_cert; | 1534 | gnutls_x509_crt_t gnutls_verify_cert; |
| 1520 | const gnutls_datum_t *gnutls_verify_cert_list; | 1535 | const gnutls_datum_t *gnutls_verify_cert_list; |
| 1521 | unsigned int gnutls_verify_cert_list_size; | 1536 | unsigned int gnutls_verify_cert_list_size; |
| 1522 | 1537 | ||
| 1523 | ret = fn_gnutls_x509_crt_init (&gnutls_verify_cert); | 1538 | ret = gnutls_x509_crt_init (&gnutls_verify_cert); |
| 1524 | if (ret < GNUTLS_E_SUCCESS) | 1539 | if (ret < GNUTLS_E_SUCCESS) |
| 1525 | return gnutls_make_error (ret); | 1540 | return gnutls_make_error (ret); |
| 1526 | 1541 | ||
| 1527 | gnutls_verify_cert_list = | 1542 | gnutls_verify_cert_list = |
| 1528 | fn_gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); | 1543 | gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); |
| 1529 | 1544 | ||
| 1530 | if (gnutls_verify_cert_list == NULL) | 1545 | if (gnutls_verify_cert_list == NULL) |
| 1531 | { | 1546 | { |
| 1532 | fn_gnutls_x509_crt_deinit (gnutls_verify_cert); | 1547 | gnutls_x509_crt_deinit (gnutls_verify_cert); |
| 1533 | emacs_gnutls_deinit (proc); | 1548 | emacs_gnutls_deinit (proc); |
| 1534 | error ("No x509 certificate was found\n"); | 1549 | error ("No x509 certificate was found\n"); |
| 1535 | } | 1550 | } |
| 1536 | 1551 | ||
| 1537 | /* We only check the first certificate in the given chain. */ | 1552 | /* We only check the first certificate in the given chain. */ |
| 1538 | ret = fn_gnutls_x509_crt_import (gnutls_verify_cert, | 1553 | ret = gnutls_x509_crt_import (gnutls_verify_cert, |
| 1539 | &gnutls_verify_cert_list[0], | 1554 | &gnutls_verify_cert_list[0], |
| 1540 | GNUTLS_X509_FMT_DER); | 1555 | GNUTLS_X509_FMT_DER); |
| 1541 | 1556 | ||
| 1542 | if (ret < GNUTLS_E_SUCCESS) | 1557 | if (ret < GNUTLS_E_SUCCESS) |
| 1543 | { | 1558 | { |
| 1544 | fn_gnutls_x509_crt_deinit (gnutls_verify_cert); | 1559 | gnutls_x509_crt_deinit (gnutls_verify_cert); |
| 1545 | return gnutls_make_error (ret); | 1560 | return gnutls_make_error (ret); |
| 1546 | } | 1561 | } |
| 1547 | 1562 | ||
| 1548 | XPROCESS (proc)->gnutls_certificate = gnutls_verify_cert; | 1563 | XPROCESS (proc)->gnutls_certificate = gnutls_verify_cert; |
| 1549 | 1564 | ||
| 1550 | if (!fn_gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname)) | 1565 | int err = gnutls_x509_crt_check_hostname (gnutls_verify_cert, |
| 1566 | c_hostname); | ||
| 1567 | check_memory_full (err); | ||
| 1568 | if (!err) | ||
| 1551 | { | 1569 | { |
| 1552 | XPROCESS (proc)->gnutls_extra_peer_verification |= | 1570 | XPROCESS (proc)->gnutls_extra_peer_verification |= |
| 1553 | CERTIFICATE_NOT_MATCHING; | 1571 | CERTIFICATE_NOT_MATCHING; |
| 1554 | if (verify_error_all | 1572 | if (verify_error_all |
| 1555 | || !NILP (Fmember (QCgnutls_bootprop_hostname, verify_error))) | 1573 | || !NILP (Fmember (QCgnutls_bootprop_hostname, verify_error))) |
| 1556 | { | 1574 | { |
| 1557 | fn_gnutls_x509_crt_deinit (gnutls_verify_cert); | 1575 | gnutls_x509_crt_deinit (gnutls_verify_cert); |
| 1558 | emacs_gnutls_deinit (proc); | 1576 | emacs_gnutls_deinit (proc); |
| 1559 | error ("The x509 certificate does not match \"%s\"", c_hostname); | 1577 | error ("The x509 certificate does not match \"%s\"", c_hostname); |
| 1560 | } | 1578 | } |
| @@ -1595,10 +1613,9 @@ This function may also return `gnutls-e-again', or | |||
| 1595 | 1613 | ||
| 1596 | state = XPROCESS (proc)->gnutls_state; | 1614 | state = XPROCESS (proc)->gnutls_state; |
| 1597 | 1615 | ||
| 1598 | fn_gnutls_x509_crt_deinit (XPROCESS (proc)->gnutls_certificate); | 1616 | gnutls_x509_crt_deinit (XPROCESS (proc)->gnutls_certificate); |
| 1599 | 1617 | ||
| 1600 | ret = fn_gnutls_bye (state, | 1618 | ret = gnutls_bye (state, NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR); |
| 1601 | NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR); | ||
| 1602 | 1619 | ||
| 1603 | return gnutls_make_error (ret); | 1620 | return gnutls_make_error (ret); |
| 1604 | } | 1621 | } |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 9465d5479df..f61cbc2c85c 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -1839,12 +1839,12 @@ xg_get_file_with_chooser (struct frame *f, | |||
| 1839 | 1839 | ||
| 1840 | if (x_gtk_file_dialog_help_text) | 1840 | if (x_gtk_file_dialog_help_text) |
| 1841 | { | 1841 | { |
| 1842 | msgbuf[0] = '\0'; | 1842 | char *z = msgbuf; |
| 1843 | /* Gtk+ 2.10 has the file name text entry box integrated in the dialog. | 1843 | /* Gtk+ 2.10 has the file name text entry box integrated in the dialog. |
| 1844 | Show the C-l help text only for versions < 2.10. */ | 1844 | Show the C-l help text only for versions < 2.10. */ |
| 1845 | if (gtk_check_version (2, 10, 0) && action != GTK_FILE_CHOOSER_ACTION_SAVE) | 1845 | if (gtk_check_version (2, 10, 0) && action != GTK_FILE_CHOOSER_ACTION_SAVE) |
| 1846 | strcat (msgbuf, "\nType C-l to display a file name text entry box.\n"); | 1846 | z = stpcpy (z, "\nType C-l to display a file name text entry box.\n"); |
| 1847 | strcat (msgbuf, "\nIf you don't like this file selector, use the " | 1847 | strcpy (z, "\nIf you don't like this file selector, use the " |
| 1848 | "corresponding\nkey binding or customize " | 1848 | "corresponding\nkey binding or customize " |
| 1849 | "use-file-dialog to turn it off."); | 1849 | "use-file-dialog to turn it off."); |
| 1850 | 1850 | ||
diff --git a/src/image.c b/src/image.c index a73a7251753..4cba8863b88 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -1859,19 +1859,6 @@ mark_image_cache (struct image_cache *c) | |||
| 1859 | X / NS / W32 support code | 1859 | X / NS / W32 support code |
| 1860 | ***********************************************************************/ | 1860 | ***********************************************************************/ |
| 1861 | 1861 | ||
| 1862 | #ifdef WINDOWSNT | ||
| 1863 | |||
| 1864 | /* Macro for defining functions that will be loaded from image DLLs. */ | ||
| 1865 | #define DEF_IMGLIB_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args | ||
| 1866 | |||
| 1867 | /* Macro for loading those image functions from the library. */ | ||
| 1868 | #define LOAD_IMGLIB_FN(lib,func) { \ | ||
| 1869 | fn_##func = (void *) GetProcAddress (lib, #func); \ | ||
| 1870 | if (!fn_##func) return 0; \ | ||
| 1871 | } | ||
| 1872 | |||
| 1873 | #endif /* WINDOWSNT */ | ||
| 1874 | |||
| 1875 | /* Return true if XIMG's size WIDTH x HEIGHT doesn't break the | 1862 | /* Return true if XIMG's size WIDTH x HEIGHT doesn't break the |
| 1876 | windowing system. | 1863 | windowing system. |
| 1877 | WIDTH and HEIGHT must both be positive. | 1864 | WIDTH and HEIGHT must both be positive. |
| @@ -3377,12 +3364,14 @@ xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void * | |||
| 3377 | 3364 | ||
| 3378 | /* XPM library details. */ | 3365 | /* XPM library details. */ |
| 3379 | 3366 | ||
| 3380 | DEF_IMGLIB_FN (void, XpmFreeAttributes, (XpmAttributes *)); | 3367 | DEF_DLL_FN (void, XpmFreeAttributes, (XpmAttributes *)); |
| 3381 | DEF_IMGLIB_FN (int, XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **, | 3368 | DEF_DLL_FN (int, XpmCreateImageFromBuffer, |
| 3382 | xpm_XImage **, XpmAttributes *)); | 3369 | (Display *, char *, xpm_XImage **, |
| 3383 | DEF_IMGLIB_FN (int, XpmReadFileToImage, (Display *, char *, xpm_XImage **, | 3370 | xpm_XImage **, XpmAttributes *)); |
| 3384 | xpm_XImage **, XpmAttributes *)); | 3371 | DEF_DLL_FN (int, XpmReadFileToImage, |
| 3385 | DEF_IMGLIB_FN (void, XImageFree, (xpm_XImage *)); | 3372 | (Display *, char *, xpm_XImage **, |
| 3373 | xpm_XImage **, XpmAttributes *)); | ||
| 3374 | DEF_DLL_FN (void, XImageFree, (xpm_XImage *)); | ||
| 3386 | 3375 | ||
| 3387 | static bool | 3376 | static bool |
| 3388 | init_xpm_functions (void) | 3377 | init_xpm_functions (void) |
| @@ -3392,22 +3381,24 @@ init_xpm_functions (void) | |||
| 3392 | if (!(library = w32_delayed_load (Qxpm))) | 3381 | if (!(library = w32_delayed_load (Qxpm))) |
| 3393 | return 0; | 3382 | return 0; |
| 3394 | 3383 | ||
| 3395 | LOAD_IMGLIB_FN (library, XpmFreeAttributes); | 3384 | LOAD_DLL_FN (library, XpmFreeAttributes); |
| 3396 | LOAD_IMGLIB_FN (library, XpmCreateImageFromBuffer); | 3385 | LOAD_DLL_FN (library, XpmCreateImageFromBuffer); |
| 3397 | LOAD_IMGLIB_FN (library, XpmReadFileToImage); | 3386 | LOAD_DLL_FN (library, XpmReadFileToImage); |
| 3398 | LOAD_IMGLIB_FN (library, XImageFree); | 3387 | LOAD_DLL_FN (library, XImageFree); |
| 3399 | return 1; | 3388 | return 1; |
| 3400 | } | 3389 | } |
| 3401 | 3390 | ||
| 3402 | #endif /* WINDOWSNT */ | 3391 | # undef XImageFree |
| 3392 | # undef XpmCreateImageFromBuffer | ||
| 3393 | # undef XpmFreeAttributes | ||
| 3394 | # undef XpmReadFileToImage | ||
| 3403 | 3395 | ||
| 3404 | #if defined HAVE_NTGUI && !defined WINDOWSNT | 3396 | # define XImageFree fn_XImageFree |
| 3405 | /* Glue for code below */ | 3397 | # define XpmCreateImageFromBuffer fn_XpmCreateImageFromBuffer |
| 3406 | #define fn_XpmReadFileToImage XpmReadFileToImage | 3398 | # define XpmFreeAttributes fn_XpmFreeAttributes |
| 3407 | #define fn_XpmCreateImageFromBuffer XpmCreateImageFromBuffer | 3399 | # define XpmReadFileToImage fn_XpmReadFileToImage |
| 3408 | #define fn_XImageFree XImageFree | 3400 | |
| 3409 | #define fn_XpmFreeAttributes XpmFreeAttributes | 3401 | #endif /* WINDOWSNT */ |
| 3410 | #endif /* HAVE_NTGUI && !WINDOWSNT */ | ||
| 3411 | 3402 | ||
| 3412 | /* Value is true if COLOR_SYMBOLS is a valid color symbols list | 3403 | /* Value is true if COLOR_SYMBOLS is a valid color symbols list |
| 3413 | for XPM images. Such a list must consist of conses whose car and | 3404 | for XPM images. Such a list must consist of conses whose car and |
| @@ -3624,9 +3615,9 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3624 | #endif | 3615 | #endif |
| 3625 | /* XpmReadFileToPixmap is not available in the Windows port of | 3616 | /* XpmReadFileToPixmap is not available in the Windows port of |
| 3626 | libxpm. But XpmReadFileToImage almost does what we want. */ | 3617 | libxpm. But XpmReadFileToImage almost does what we want. */ |
| 3627 | rc = fn_XpmReadFileToImage (&hdc, SDATA (file), | 3618 | rc = XpmReadFileToImage (&hdc, SDATA (file), |
| 3628 | &xpm_image, &xpm_mask, | 3619 | &xpm_image, &xpm_mask, |
| 3629 | &attrs); | 3620 | &attrs); |
| 3630 | #else | 3621 | #else |
| 3631 | rc = XpmReadFileToImage (FRAME_X_DISPLAY (f), SSDATA (file), | 3622 | rc = XpmReadFileToImage (FRAME_X_DISPLAY (f), SSDATA (file), |
| 3632 | &img->ximg, &img->mask_img, | 3623 | &img->ximg, &img->mask_img, |
| @@ -3648,9 +3639,9 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3648 | #ifdef HAVE_NTGUI | 3639 | #ifdef HAVE_NTGUI |
| 3649 | /* XpmCreatePixmapFromBuffer is not available in the Windows port | 3640 | /* XpmCreatePixmapFromBuffer is not available in the Windows port |
| 3650 | of libxpm. But XpmCreateImageFromBuffer almost does what we want. */ | 3641 | of libxpm. But XpmCreateImageFromBuffer almost does what we want. */ |
| 3651 | rc = fn_XpmCreateImageFromBuffer (&hdc, SDATA (buffer), | 3642 | rc = XpmCreateImageFromBuffer (&hdc, SDATA (buffer), |
| 3652 | &xpm_image, &xpm_mask, | 3643 | &xpm_image, &xpm_mask, |
| 3653 | &attrs); | 3644 | &attrs); |
| 3654 | #else | 3645 | #else |
| 3655 | rc = XpmCreateImageFromBuffer (FRAME_X_DISPLAY (f), SSDATA (buffer), | 3646 | rc = XpmCreateImageFromBuffer (FRAME_X_DISPLAY (f), SSDATA (buffer), |
| 3656 | &img->ximg, &img->mask_img, | 3647 | &img->ximg, &img->mask_img, |
| @@ -3699,7 +3690,7 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3699 | img->pixmap = xpm_image->bitmap; | 3690 | img->pixmap = xpm_image->bitmap; |
| 3700 | /* XImageFree in libXpm frees XImage struct without destroying | 3691 | /* XImageFree in libXpm frees XImage struct without destroying |
| 3701 | the bitmap, which is what we want. */ | 3692 | the bitmap, which is what we want. */ |
| 3702 | fn_XImageFree (xpm_image); | 3693 | XImageFree (xpm_image); |
| 3703 | } | 3694 | } |
| 3704 | if (xpm_mask && xpm_mask->bitmap) | 3695 | if (xpm_mask && xpm_mask->bitmap) |
| 3705 | { | 3696 | { |
| @@ -3713,7 +3704,7 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3713 | SelectObject (hdc, old_obj); | 3704 | SelectObject (hdc, old_obj); |
| 3714 | 3705 | ||
| 3715 | img->mask = xpm_mask->bitmap; | 3706 | img->mask = xpm_mask->bitmap; |
| 3716 | fn_XImageFree (xpm_mask); | 3707 | XImageFree (xpm_mask); |
| 3717 | DeleteDC (hdc); | 3708 | DeleteDC (hdc); |
| 3718 | } | 3709 | } |
| 3719 | 3710 | ||
| @@ -3737,11 +3728,7 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3737 | eassert (img->width > 0 && img->height > 0); | 3728 | eassert (img->width > 0 && img->height > 0); |
| 3738 | 3729 | ||
| 3739 | /* The call to XpmFreeAttributes below frees attrs.alloc_pixels. */ | 3730 | /* The call to XpmFreeAttributes below frees attrs.alloc_pixels. */ |
| 3740 | #ifdef HAVE_NTGUI | ||
| 3741 | fn_XpmFreeAttributes (&attrs); | ||
| 3742 | #else | ||
| 3743 | XpmFreeAttributes (&attrs); | 3731 | XpmFreeAttributes (&attrs); |
| 3744 | #endif /* HAVE_NTGUI */ | ||
| 3745 | 3732 | ||
| 3746 | #ifdef HAVE_X_WINDOWS | 3733 | #ifdef HAVE_X_WINDOWS |
| 3747 | /* Maybe fill in the background field while we have ximg handy. */ | 3734 | /* Maybe fill in the background field while we have ximg handy. */ |
| @@ -5535,39 +5522,42 @@ png_image_p (Lisp_Object object) | |||
| 5535 | 5522 | ||
| 5536 | #if defined HAVE_PNG && !defined HAVE_NS | 5523 | #if defined HAVE_PNG && !defined HAVE_NS |
| 5537 | 5524 | ||
| 5538 | #ifdef WINDOWSNT | 5525 | # ifdef WINDOWSNT |
| 5539 | /* PNG library details. */ | 5526 | /* PNG library details. */ |
| 5540 | 5527 | ||
| 5541 | DEF_IMGLIB_FN (png_voidp, png_get_io_ptr, (png_structp)); | 5528 | DEF_DLL_FN (png_voidp, png_get_io_ptr, (png_structp)); |
| 5542 | DEF_IMGLIB_FN (int, png_sig_cmp, (png_bytep, png_size_t, png_size_t)); | 5529 | DEF_DLL_FN (int, png_sig_cmp, (png_bytep, png_size_t, png_size_t)); |
| 5543 | DEF_IMGLIB_FN (png_structp, png_create_read_struct, (png_const_charp, png_voidp, | 5530 | DEF_DLL_FN (png_structp, png_create_read_struct, |
| 5544 | png_error_ptr, png_error_ptr)); | 5531 | (png_const_charp, png_voidp, png_error_ptr, png_error_ptr)); |
| 5545 | DEF_IMGLIB_FN (png_infop, png_create_info_struct, (png_structp)); | 5532 | DEF_DLL_FN (png_infop, png_create_info_struct, (png_structp)); |
| 5546 | DEF_IMGLIB_FN (void, png_destroy_read_struct, (png_structpp, png_infopp, png_infopp)); | 5533 | DEF_DLL_FN (void, png_destroy_read_struct, |
| 5547 | DEF_IMGLIB_FN (void, png_set_read_fn, (png_structp, png_voidp, png_rw_ptr)); | 5534 | (png_structpp, png_infopp, png_infopp)); |
| 5548 | DEF_IMGLIB_FN (void, png_set_sig_bytes, (png_structp, int)); | 5535 | DEF_DLL_FN (void, png_set_read_fn, (png_structp, png_voidp, png_rw_ptr)); |
| 5549 | DEF_IMGLIB_FN (void, png_read_info, (png_structp, png_infop)); | 5536 | DEF_DLL_FN (void, png_set_sig_bytes, (png_structp, int)); |
| 5550 | DEF_IMGLIB_FN (png_uint_32, png_get_IHDR, (png_structp, png_infop, | 5537 | DEF_DLL_FN (void, png_read_info, (png_structp, png_infop)); |
| 5551 | png_uint_32 *, png_uint_32 *, | 5538 | DEF_DLL_FN (png_uint_32, png_get_IHDR, |
| 5552 | int *, int *, int *, int *, int *)); | 5539 | (png_structp, png_infop, png_uint_32 *, png_uint_32 *, |
| 5553 | DEF_IMGLIB_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32)); | 5540 | int *, int *, int *, int *, int *)); |
| 5554 | DEF_IMGLIB_FN (void, png_set_strip_16, (png_structp)); | 5541 | DEF_DLL_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32)); |
| 5555 | DEF_IMGLIB_FN (void, png_set_expand, (png_structp)); | 5542 | DEF_DLL_FN (void, png_set_strip_16, (png_structp)); |
| 5556 | DEF_IMGLIB_FN (void, png_set_gray_to_rgb, (png_structp)); | 5543 | DEF_DLL_FN (void, png_set_expand, (png_structp)); |
| 5557 | DEF_IMGLIB_FN (void, png_set_background, (png_structp, png_color_16p, | 5544 | DEF_DLL_FN (void, png_set_gray_to_rgb, (png_structp)); |
| 5558 | int, int, double)); | 5545 | DEF_DLL_FN (void, png_set_background, |
| 5559 | DEF_IMGLIB_FN (png_uint_32, png_get_bKGD, (png_structp, png_infop, png_color_16p *)); | 5546 | (png_structp, png_color_16p, int, int, double)); |
| 5560 | DEF_IMGLIB_FN (void, png_read_update_info, (png_structp, png_infop)); | 5547 | DEF_DLL_FN (png_uint_32, png_get_bKGD, |
| 5561 | DEF_IMGLIB_FN (png_byte, png_get_channels, (png_structp, png_infop)); | 5548 | (png_structp, png_infop, png_color_16p *)); |
| 5562 | DEF_IMGLIB_FN (png_size_t, png_get_rowbytes, (png_structp, png_infop)); | 5549 | DEF_DLL_FN (void, png_read_update_info, (png_structp, png_infop)); |
| 5563 | DEF_IMGLIB_FN (void, png_read_image, (png_structp, png_bytepp)); | 5550 | DEF_DLL_FN (png_byte, png_get_channels, (png_structp, png_infop)); |
| 5564 | DEF_IMGLIB_FN (void, png_read_end, (png_structp, png_infop)); | 5551 | DEF_DLL_FN (png_size_t, png_get_rowbytes, (png_structp, png_infop)); |
| 5565 | DEF_IMGLIB_FN (void, png_error, (png_structp, png_const_charp)); | 5552 | DEF_DLL_FN (void, png_read_image, (png_structp, png_bytepp)); |
| 5566 | 5553 | DEF_DLL_FN (void, png_read_end, (png_structp, png_infop)); | |
| 5567 | #if (PNG_LIBPNG_VER >= 10500) | 5554 | DEF_DLL_FN (void, png_error, (png_structp, png_const_charp)); |
| 5568 | DEF_IMGLIB_FN (void, png_longjmp, (png_structp, int)) PNG_NORETURN; | 5555 | |
| 5569 | DEF_IMGLIB_FN (jmp_buf *, png_set_longjmp_fn, (png_structp, png_longjmp_ptr, size_t)); | 5556 | # if (PNG_LIBPNG_VER >= 10500) |
| 5570 | #endif /* libpng version >= 1.5 */ | 5557 | DEF_DLL_FN (void, png_longjmp, (png_structp, int)) PNG_NORETURN; |
| 5558 | DEF_DLL_FN (jmp_buf *, png_set_longjmp_fn, | ||
| 5559 | (png_structp, png_longjmp_ptr, size_t)); | ||
| 5560 | # endif /* libpng version >= 1.5 */ | ||
| 5571 | 5561 | ||
| 5572 | static bool | 5562 | static bool |
| 5573 | init_png_functions (void) | 5563 | init_png_functions (void) |
| @@ -5577,87 +5567,107 @@ init_png_functions (void) | |||
| 5577 | if (!(library = w32_delayed_load (Qpng))) | 5567 | if (!(library = w32_delayed_load (Qpng))) |
| 5578 | return 0; | 5568 | return 0; |
| 5579 | 5569 | ||
| 5580 | LOAD_IMGLIB_FN (library, png_get_io_ptr); | 5570 | LOAD_DLL_FN (library, png_get_io_ptr); |
| 5581 | LOAD_IMGLIB_FN (library, png_sig_cmp); | 5571 | LOAD_DLL_FN (library, png_sig_cmp); |
| 5582 | LOAD_IMGLIB_FN (library, png_create_read_struct); | 5572 | LOAD_DLL_FN (library, png_create_read_struct); |
| 5583 | LOAD_IMGLIB_FN (library, png_create_info_struct); | 5573 | LOAD_DLL_FN (library, png_create_info_struct); |
| 5584 | LOAD_IMGLIB_FN (library, png_destroy_read_struct); | 5574 | LOAD_DLL_FN (library, png_destroy_read_struct); |
| 5585 | LOAD_IMGLIB_FN (library, png_set_read_fn); | 5575 | LOAD_DLL_FN (library, png_set_read_fn); |
| 5586 | LOAD_IMGLIB_FN (library, png_set_sig_bytes); | 5576 | LOAD_DLL_FN (library, png_set_sig_bytes); |
| 5587 | LOAD_IMGLIB_FN (library, png_read_info); | 5577 | LOAD_DLL_FN (library, png_read_info); |
| 5588 | LOAD_IMGLIB_FN (library, png_get_IHDR); | 5578 | LOAD_DLL_FN (library, png_get_IHDR); |
| 5589 | LOAD_IMGLIB_FN (library, png_get_valid); | 5579 | LOAD_DLL_FN (library, png_get_valid); |
| 5590 | LOAD_IMGLIB_FN (library, png_set_strip_16); | 5580 | LOAD_DLL_FN (library, png_set_strip_16); |
| 5591 | LOAD_IMGLIB_FN (library, png_set_expand); | 5581 | LOAD_DLL_FN (library, png_set_expand); |
| 5592 | LOAD_IMGLIB_FN (library, png_set_gray_to_rgb); | 5582 | LOAD_DLL_FN (library, png_set_gray_to_rgb); |
| 5593 | LOAD_IMGLIB_FN (library, png_set_background); | 5583 | LOAD_DLL_FN (library, png_set_background); |
| 5594 | LOAD_IMGLIB_FN (library, png_get_bKGD); | 5584 | LOAD_DLL_FN (library, png_get_bKGD); |
| 5595 | LOAD_IMGLIB_FN (library, png_read_update_info); | 5585 | LOAD_DLL_FN (library, png_read_update_info); |
| 5596 | LOAD_IMGLIB_FN (library, png_get_channels); | 5586 | LOAD_DLL_FN (library, png_get_channels); |
| 5597 | LOAD_IMGLIB_FN (library, png_get_rowbytes); | 5587 | LOAD_DLL_FN (library, png_get_rowbytes); |
| 5598 | LOAD_IMGLIB_FN (library, png_read_image); | 5588 | LOAD_DLL_FN (library, png_read_image); |
| 5599 | LOAD_IMGLIB_FN (library, png_read_end); | 5589 | LOAD_DLL_FN (library, png_read_end); |
| 5600 | LOAD_IMGLIB_FN (library, png_error); | 5590 | LOAD_DLL_FN (library, png_error); |
| 5601 | 5591 | ||
| 5602 | #if (PNG_LIBPNG_VER >= 10500) | 5592 | # if (PNG_LIBPNG_VER >= 10500) |
| 5603 | LOAD_IMGLIB_FN (library, png_longjmp); | 5593 | LOAD_DLL_FN (library, png_longjmp); |
| 5604 | LOAD_IMGLIB_FN (library, png_set_longjmp_fn); | 5594 | LOAD_DLL_FN (library, png_set_longjmp_fn); |
| 5605 | #endif /* libpng version >= 1.5 */ | 5595 | # endif /* libpng version >= 1.5 */ |
| 5606 | 5596 | ||
| 5607 | return 1; | 5597 | return 1; |
| 5608 | } | 5598 | } |
| 5609 | #else | ||
| 5610 | |||
| 5611 | #define fn_png_get_io_ptr png_get_io_ptr | ||
| 5612 | #define fn_png_sig_cmp png_sig_cmp | ||
| 5613 | #define fn_png_create_read_struct png_create_read_struct | ||
| 5614 | #define fn_png_create_info_struct png_create_info_struct | ||
| 5615 | #define fn_png_destroy_read_struct png_destroy_read_struct | ||
| 5616 | #define fn_png_set_read_fn png_set_read_fn | ||
| 5617 | #define fn_png_set_sig_bytes png_set_sig_bytes | ||
| 5618 | #define fn_png_read_info png_read_info | ||
| 5619 | #define fn_png_get_IHDR png_get_IHDR | ||
| 5620 | #define fn_png_get_valid png_get_valid | ||
| 5621 | #define fn_png_set_strip_16 png_set_strip_16 | ||
| 5622 | #define fn_png_set_expand png_set_expand | ||
| 5623 | #define fn_png_set_gray_to_rgb png_set_gray_to_rgb | ||
| 5624 | #define fn_png_set_background png_set_background | ||
| 5625 | #define fn_png_get_bKGD png_get_bKGD | ||
| 5626 | #define fn_png_read_update_info png_read_update_info | ||
| 5627 | #define fn_png_get_channels png_get_channels | ||
| 5628 | #define fn_png_get_rowbytes png_get_rowbytes | ||
| 5629 | #define fn_png_read_image png_read_image | ||
| 5630 | #define fn_png_read_end png_read_end | ||
| 5631 | #define fn_png_error png_error | ||
| 5632 | |||
| 5633 | #if (PNG_LIBPNG_VER >= 10500) | ||
| 5634 | #define fn_png_longjmp png_longjmp | ||
| 5635 | #define fn_png_set_longjmp_fn png_set_longjmp_fn | ||
| 5636 | #endif /* libpng version >= 1.5 */ | ||
| 5637 | 5599 | ||
| 5638 | #endif /* WINDOWSNT */ | 5600 | # undef png_create_info_struct |
| 5601 | # undef png_create_read_struct | ||
| 5602 | # undef png_destroy_read_struct | ||
| 5603 | # undef png_error | ||
| 5604 | # undef png_get_bKGD | ||
| 5605 | # undef png_get_channels | ||
| 5606 | # undef png_get_IHDR | ||
| 5607 | # undef png_get_io_ptr | ||
| 5608 | # undef png_get_rowbytes | ||
| 5609 | # undef png_get_valid | ||
| 5610 | # undef png_longjmp | ||
| 5611 | # undef png_read_end | ||
| 5612 | # undef png_read_image | ||
| 5613 | # undef png_read_info | ||
| 5614 | # undef png_read_update_info | ||
| 5615 | # undef png_set_background | ||
| 5616 | # undef png_set_expand | ||
| 5617 | # undef png_set_gray_to_rgb | ||
| 5618 | # undef png_set_longjmp_fn | ||
| 5619 | # undef png_set_read_fn | ||
| 5620 | # undef png_set_sig_bytes | ||
| 5621 | # undef png_set_strip_16 | ||
| 5622 | # undef png_sig_cmp | ||
| 5623 | |||
| 5624 | # define png_create_info_struct fn_png_create_info_struct | ||
| 5625 | # define png_create_read_struct fn_png_create_read_struct | ||
| 5626 | # define png_destroy_read_struct fn_png_destroy_read_struct | ||
| 5627 | # define png_error fn_png_error | ||
| 5628 | # define png_get_bKGD fn_png_get_bKGD | ||
| 5629 | # define png_get_channels fn_png_get_channels | ||
| 5630 | # define png_get_IHDR fn_png_get_IHDR | ||
| 5631 | # define png_get_io_ptr fn_png_get_io_ptr | ||
| 5632 | # define png_get_rowbytes fn_png_get_rowbytes | ||
| 5633 | # define png_get_valid fn_png_get_valid | ||
| 5634 | # define png_longjmp fn_png_longjmp | ||
| 5635 | # define png_read_end fn_png_read_end | ||
| 5636 | # define png_read_image fn_png_read_image | ||
| 5637 | # define png_read_info fn_png_read_info | ||
| 5638 | # define png_read_update_info fn_png_read_update_info | ||
| 5639 | # define png_set_background fn_png_set_background | ||
| 5640 | # define png_set_expand fn_png_set_expand | ||
| 5641 | # define png_set_gray_to_rgb fn_png_set_gray_to_rgb | ||
| 5642 | # define png_set_longjmp_fn fn_png_set_longjmp_fn | ||
| 5643 | # define png_set_read_fn fn_png_set_read_fn | ||
| 5644 | # define png_set_sig_bytes fn_png_set_sig_bytes | ||
| 5645 | # define png_set_strip_16 fn_png_set_strip_16 | ||
| 5646 | # define png_sig_cmp fn_png_sig_cmp | ||
| 5647 | |||
| 5648 | # endif /* WINDOWSNT */ | ||
| 5639 | 5649 | ||
| 5640 | /* Fast implementations of setjmp and longjmp. Although setjmp and longjmp | 5650 | /* Fast implementations of setjmp and longjmp. Although setjmp and longjmp |
| 5641 | will do, POSIX _setjmp and _longjmp (if available) are often faster. | 5651 | will do, POSIX _setjmp and _longjmp (if available) are often faster. |
| 5642 | Do not use sys_setjmp, as PNG supports only jmp_buf. | 5652 | Do not use sys_setjmp, as PNG supports only jmp_buf. |
| 5643 | It's OK if the longjmp substitute restores the signal mask. */ | 5653 | It's OK if the longjmp substitute restores the signal mask. */ |
| 5644 | #ifdef HAVE__SETJMP | 5654 | # ifdef HAVE__SETJMP |
| 5645 | # define FAST_SETJMP(j) _setjmp (j) | 5655 | # define FAST_SETJMP(j) _setjmp (j) |
| 5646 | # define FAST_LONGJMP _longjmp | 5656 | # define FAST_LONGJMP _longjmp |
| 5647 | #else | 5657 | # else |
| 5648 | # define FAST_SETJMP(j) setjmp (j) | 5658 | # define FAST_SETJMP(j) setjmp (j) |
| 5649 | # define FAST_LONGJMP longjmp | 5659 | # define FAST_LONGJMP longjmp |
| 5650 | #endif | 5660 | # endif |
| 5651 | 5661 | ||
| 5652 | #if PNG_LIBPNG_VER < 10500 | 5662 | # if PNG_LIBPNG_VER < 10500 |
| 5653 | #define PNG_LONGJMP(ptr) FAST_LONGJMP ((ptr)->jmpbuf, 1) | 5663 | # define PNG_LONGJMP(ptr) FAST_LONGJMP ((ptr)->jmpbuf, 1) |
| 5654 | #define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) | 5664 | # define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) |
| 5655 | #else | 5665 | # else |
| 5656 | /* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ | 5666 | /* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ |
| 5657 | #define PNG_LONGJMP(ptr) fn_png_longjmp (ptr, 1) | 5667 | # define PNG_LONGJMP(ptr) png_longjmp (ptr, 1) |
| 5658 | #define PNG_JMPBUF(ptr) \ | 5668 | # define PNG_JMPBUF(ptr) \ |
| 5659 | (*fn_png_set_longjmp_fn (ptr, FAST_LONGJMP, sizeof (jmp_buf))) | 5669 | (*png_set_longjmp_fn (ptr, FAST_LONGJMP, sizeof (jmp_buf))) |
| 5660 | #endif | 5670 | # endif |
| 5661 | 5671 | ||
| 5662 | /* Error and warning handlers installed when the PNG library | 5672 | /* Error and warning handlers installed when the PNG library |
| 5663 | is initialized. */ | 5673 | is initialized. */ |
| @@ -5697,10 +5707,10 @@ struct png_memory_storage | |||
| 5697 | static void | 5707 | static void |
| 5698 | png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length) | 5708 | png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length) |
| 5699 | { | 5709 | { |
| 5700 | struct png_memory_storage *tbr = fn_png_get_io_ptr (png_ptr); | 5710 | struct png_memory_storage *tbr = png_get_io_ptr (png_ptr); |
| 5701 | 5711 | ||
| 5702 | if (length > tbr->len - tbr->index) | 5712 | if (length > tbr->len - tbr->index) |
| 5703 | fn_png_error (png_ptr, "Read error"); | 5713 | png_error (png_ptr, "Read error"); |
| 5704 | 5714 | ||
| 5705 | memcpy (data, tbr->bytes + tbr->index, length); | 5715 | memcpy (data, tbr->bytes + tbr->index, length); |
| 5706 | tbr->index = tbr->index + length; | 5716 | tbr->index = tbr->index + length; |
| @@ -5714,10 +5724,10 @@ png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length) | |||
| 5714 | static void | 5724 | static void |
| 5715 | png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length) | 5725 | png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length) |
| 5716 | { | 5726 | { |
| 5717 | FILE *fp = fn_png_get_io_ptr (png_ptr); | 5727 | FILE *fp = png_get_io_ptr (png_ptr); |
| 5718 | 5728 | ||
| 5719 | if (fread (data, 1, length, fp) < length) | 5729 | if (fread (data, 1, length, fp) < length) |
| 5720 | fn_png_error (png_ptr, "Read error"); | 5730 | png_error (png_ptr, "Read error"); |
| 5721 | } | 5731 | } |
| 5722 | 5732 | ||
| 5723 | 5733 | ||
| @@ -5779,7 +5789,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5779 | 5789 | ||
| 5780 | /* Check PNG signature. */ | 5790 | /* Check PNG signature. */ |
| 5781 | if (fread (sig, 1, sizeof sig, fp) != sizeof sig | 5791 | if (fread (sig, 1, sizeof sig, fp) != sizeof sig |
| 5782 | || fn_png_sig_cmp (sig, 0, sizeof sig)) | 5792 | || png_sig_cmp (sig, 0, sizeof sig)) |
| 5783 | { | 5793 | { |
| 5784 | fclose (fp); | 5794 | fclose (fp); |
| 5785 | image_error ("Not a PNG file: `%s'", file, Qnil); | 5795 | image_error ("Not a PNG file: `%s'", file, Qnil); |
| @@ -5801,7 +5811,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5801 | 5811 | ||
| 5802 | /* Check PNG signature. */ | 5812 | /* Check PNG signature. */ |
| 5803 | if (tbr.len < sizeof sig | 5813 | if (tbr.len < sizeof sig |
| 5804 | || fn_png_sig_cmp (tbr.bytes, 0, sizeof sig)) | 5814 | || png_sig_cmp (tbr.bytes, 0, sizeof sig)) |
| 5805 | { | 5815 | { |
| 5806 | image_error ("Not a PNG image: `%s'", img->spec, Qnil); | 5816 | image_error ("Not a PNG image: `%s'", img->spec, Qnil); |
| 5807 | return 0; | 5817 | return 0; |
| @@ -5812,13 +5822,13 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5812 | } | 5822 | } |
| 5813 | 5823 | ||
| 5814 | /* Initialize read and info structs for PNG lib. */ | 5824 | /* Initialize read and info structs for PNG lib. */ |
| 5815 | png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, | 5825 | png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, |
| 5816 | NULL, my_png_error, | 5826 | NULL, my_png_error, |
| 5817 | my_png_warning); | 5827 | my_png_warning); |
| 5818 | if (png_ptr) | 5828 | if (png_ptr) |
| 5819 | { | 5829 | { |
| 5820 | info_ptr = fn_png_create_info_struct (png_ptr); | 5830 | info_ptr = png_create_info_struct (png_ptr); |
| 5821 | end_info = fn_png_create_info_struct (png_ptr); | 5831 | end_info = png_create_info_struct (png_ptr); |
| 5822 | } | 5832 | } |
| 5823 | 5833 | ||
| 5824 | c->png_ptr = png_ptr; | 5834 | c->png_ptr = png_ptr; |
| @@ -5830,7 +5840,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5830 | 5840 | ||
| 5831 | if (! (info_ptr && end_info)) | 5841 | if (! (info_ptr && end_info)) |
| 5832 | { | 5842 | { |
| 5833 | fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); | 5843 | png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); |
| 5834 | png_ptr = 0; | 5844 | png_ptr = 0; |
| 5835 | } | 5845 | } |
| 5836 | if (! png_ptr) | 5846 | if (! png_ptr) |
| @@ -5845,7 +5855,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5845 | { | 5855 | { |
| 5846 | error: | 5856 | error: |
| 5847 | if (c->png_ptr) | 5857 | if (c->png_ptr) |
| 5848 | fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); | 5858 | png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); |
| 5849 | xfree (c->pixels); | 5859 | xfree (c->pixels); |
| 5850 | xfree (c->rows); | 5860 | xfree (c->rows); |
| 5851 | if (c->fp) | 5861 | if (c->fp) |
| @@ -5858,14 +5868,14 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5858 | 5868 | ||
| 5859 | /* Read image info. */ | 5869 | /* Read image info. */ |
| 5860 | if (!NILP (specified_data)) | 5870 | if (!NILP (specified_data)) |
| 5861 | fn_png_set_read_fn (png_ptr, &tbr, png_read_from_memory); | 5871 | png_set_read_fn (png_ptr, &tbr, png_read_from_memory); |
| 5862 | else | 5872 | else |
| 5863 | fn_png_set_read_fn (png_ptr, fp, png_read_from_file); | 5873 | png_set_read_fn (png_ptr, fp, png_read_from_file); |
| 5864 | 5874 | ||
| 5865 | fn_png_set_sig_bytes (png_ptr, sizeof sig); | 5875 | png_set_sig_bytes (png_ptr, sizeof sig); |
| 5866 | fn_png_read_info (png_ptr, info_ptr); | 5876 | png_read_info (png_ptr, info_ptr); |
| 5867 | fn_png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, | 5877 | png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, |
| 5868 | &interlace_type, NULL, NULL); | 5878 | &interlace_type, NULL, NULL); |
| 5869 | 5879 | ||
| 5870 | if (! (width <= INT_MAX && height <= INT_MAX | 5880 | if (! (width <= INT_MAX && height <= INT_MAX |
| 5871 | && check_image_size (f, width, height))) | 5881 | && check_image_size (f, width, height))) |
| @@ -5881,7 +5891,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5881 | 5891 | ||
| 5882 | /* If image contains simply transparency data, we prefer to | 5892 | /* If image contains simply transparency data, we prefer to |
| 5883 | construct a clipping mask. */ | 5893 | construct a clipping mask. */ |
| 5884 | if (fn_png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) | 5894 | if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) |
| 5885 | transparent_p = 1; | 5895 | transparent_p = 1; |
| 5886 | else | 5896 | else |
| 5887 | transparent_p = 0; | 5897 | transparent_p = 0; |
| @@ -5892,16 +5902,16 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5892 | 5902 | ||
| 5893 | /* Strip more than 8 bits per channel. */ | 5903 | /* Strip more than 8 bits per channel. */ |
| 5894 | if (bit_depth == 16) | 5904 | if (bit_depth == 16) |
| 5895 | fn_png_set_strip_16 (png_ptr); | 5905 | png_set_strip_16 (png_ptr); |
| 5896 | 5906 | ||
| 5897 | /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel | 5907 | /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel |
| 5898 | if available. */ | 5908 | if available. */ |
| 5899 | fn_png_set_expand (png_ptr); | 5909 | png_set_expand (png_ptr); |
| 5900 | 5910 | ||
| 5901 | /* Convert grayscale images to RGB. */ | 5911 | /* Convert grayscale images to RGB. */ |
| 5902 | if (color_type == PNG_COLOR_TYPE_GRAY | 5912 | if (color_type == PNG_COLOR_TYPE_GRAY |
| 5903 | || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) | 5913 | || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) |
| 5904 | fn_png_set_gray_to_rgb (png_ptr); | 5914 | png_set_gray_to_rgb (png_ptr); |
| 5905 | 5915 | ||
| 5906 | /* Handle alpha channel by combining the image with a background | 5916 | /* Handle alpha channel by combining the image with a background |
| 5907 | color. Do this only if a real alpha channel is supplied. For | 5917 | color. Do this only if a real alpha channel is supplied. For |
| @@ -5927,24 +5937,24 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5927 | bg.green = color.green >> shift; | 5937 | bg.green = color.green >> shift; |
| 5928 | bg.blue = color.blue >> shift; | 5938 | bg.blue = color.blue >> shift; |
| 5929 | 5939 | ||
| 5930 | fn_png_set_background (png_ptr, &bg, | 5940 | png_set_background (png_ptr, &bg, |
| 5931 | PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); | 5941 | PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); |
| 5932 | } | 5942 | } |
| 5933 | } | 5943 | } |
| 5934 | 5944 | ||
| 5935 | /* Update info structure. */ | 5945 | /* Update info structure. */ |
| 5936 | fn_png_read_update_info (png_ptr, info_ptr); | 5946 | png_read_update_info (png_ptr, info_ptr); |
| 5937 | 5947 | ||
| 5938 | /* Get number of channels. Valid values are 1 for grayscale images | 5948 | /* Get number of channels. Valid values are 1 for grayscale images |
| 5939 | and images with a palette, 2 for grayscale images with transparency | 5949 | and images with a palette, 2 for grayscale images with transparency |
| 5940 | information (alpha channel), 3 for RGB images, and 4 for RGB | 5950 | information (alpha channel), 3 for RGB images, and 4 for RGB |
| 5941 | images with alpha channel, i.e. RGBA. If conversions above were | 5951 | images with alpha channel, i.e. RGBA. If conversions above were |
| 5942 | sufficient we should only have 3 or 4 channels here. */ | 5952 | sufficient we should only have 3 or 4 channels here. */ |
| 5943 | channels = fn_png_get_channels (png_ptr, info_ptr); | 5953 | channels = png_get_channels (png_ptr, info_ptr); |
| 5944 | eassert (channels == 3 || channels == 4); | 5954 | eassert (channels == 3 || channels == 4); |
| 5945 | 5955 | ||
| 5946 | /* Number of bytes needed for one row of the image. */ | 5956 | /* Number of bytes needed for one row of the image. */ |
| 5947 | row_bytes = fn_png_get_rowbytes (png_ptr, info_ptr); | 5957 | row_bytes = png_get_rowbytes (png_ptr, info_ptr); |
| 5948 | 5958 | ||
| 5949 | /* Allocate memory for the image. */ | 5959 | /* Allocate memory for the image. */ |
| 5950 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height | 5960 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height |
| @@ -5956,8 +5966,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 5956 | rows[i] = pixels + i * row_bytes; | 5966 | rows[i] = pixels + i * row_bytes; |
| 5957 | 5967 | ||
| 5958 | /* Read the entire image. */ | 5968 | /* Read the entire image. */ |
| 5959 | fn_png_read_image (png_ptr, rows); | 5969 | png_read_image (png_ptr, rows); |
| 5960 | fn_png_read_end (png_ptr, info_ptr); | 5970 | png_read_end (png_ptr, info_ptr); |
| 5961 | if (fp) | 5971 | if (fp) |
| 5962 | { | 5972 | { |
| 5963 | fclose (fp); | 5973 | fclose (fp); |
| @@ -6021,21 +6031,21 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 6021 | overrode it. */ | 6031 | overrode it. */ |
| 6022 | { | 6032 | { |
| 6023 | png_color_16 *bg; | 6033 | png_color_16 *bg; |
| 6024 | if (fn_png_get_bKGD (png_ptr, info_ptr, &bg)) | 6034 | if (png_get_bKGD (png_ptr, info_ptr, &bg)) |
| 6025 | { | 6035 | { |
| 6026 | img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue); | 6036 | img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue); |
| 6027 | img->background_valid = 1; | 6037 | img->background_valid = 1; |
| 6028 | } | 6038 | } |
| 6029 | } | 6039 | } |
| 6030 | 6040 | ||
| 6031 | #ifdef COLOR_TABLE_SUPPORT | 6041 | # ifdef COLOR_TABLE_SUPPORT |
| 6032 | /* Remember colors allocated for this image. */ | 6042 | /* Remember colors allocated for this image. */ |
| 6033 | img->colors = colors_in_color_table (&img->ncolors); | 6043 | img->colors = colors_in_color_table (&img->ncolors); |
| 6034 | free_color_table (); | 6044 | free_color_table (); |
| 6035 | #endif /* COLOR_TABLE_SUPPORT */ | 6045 | # endif /* COLOR_TABLE_SUPPORT */ |
| 6036 | 6046 | ||
| 6037 | /* Clean up. */ | 6047 | /* Clean up. */ |
| 6038 | fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); | 6048 | png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); |
| 6039 | xfree (rows); | 6049 | xfree (rows); |
| 6040 | xfree (pixels); | 6050 | xfree (pixels); |
| 6041 | 6051 | ||
| @@ -6170,15 +6180,15 @@ jpeg_image_p (Lisp_Object object) | |||
| 6170 | 6180 | ||
| 6171 | /* Work around a warning about HAVE_STDLIB_H being redefined in | 6181 | /* Work around a warning about HAVE_STDLIB_H being redefined in |
| 6172 | jconfig.h. */ | 6182 | jconfig.h. */ |
| 6173 | #ifdef HAVE_STDLIB_H | 6183 | # ifdef HAVE_STDLIB_H |
| 6174 | #undef HAVE_STDLIB_H | 6184 | # undef HAVE_STDLIB_H |
| 6175 | #endif /* HAVE_STLIB_H */ | 6185 | # endif |
| 6176 | 6186 | ||
| 6177 | #if defined (HAVE_NTGUI) && !defined (__WIN32__) | 6187 | # if defined (HAVE_NTGUI) && !defined (__WIN32__) |
| 6178 | /* In older releases of the jpeg library, jpeglib.h will define boolean | 6188 | /* In older releases of the jpeg library, jpeglib.h will define boolean |
| 6179 | differently depending on __WIN32__, so make sure it is defined. */ | 6189 | differently depending on __WIN32__, so make sure it is defined. */ |
| 6180 | #define __WIN32__ 1 | 6190 | # define __WIN32__ 1 |
| 6181 | #endif | 6191 | # endif |
| 6182 | 6192 | ||
| 6183 | /* rpcndr.h (via windows.h) and jpeglib.h both define boolean types. | 6193 | /* rpcndr.h (via windows.h) and jpeglib.h both define boolean types. |
| 6184 | Some versions of jpeglib try to detect whether rpcndr.h is loaded, | 6194 | Some versions of jpeglib try to detect whether rpcndr.h is loaded, |
| @@ -6194,23 +6204,25 @@ jpeg_image_p (Lisp_Object object) | |||
| 6194 | different name. This name, jpeg_boolean, remains in effect through | 6204 | different name. This name, jpeg_boolean, remains in effect through |
| 6195 | the rest of image.c. | 6205 | the rest of image.c. |
| 6196 | */ | 6206 | */ |
| 6197 | #if defined CYGWIN && defined HAVE_NTGUI | 6207 | # if defined CYGWIN && defined HAVE_NTGUI |
| 6198 | #define boolean jpeg_boolean | 6208 | # define boolean jpeg_boolean |
| 6199 | #endif | 6209 | # endif |
| 6200 | #include <jpeglib.h> | 6210 | # include <jpeglib.h> |
| 6201 | #include <jerror.h> | 6211 | # include <jerror.h> |
| 6202 | 6212 | ||
| 6203 | #ifdef WINDOWSNT | 6213 | # ifdef WINDOWSNT |
| 6204 | 6214 | ||
| 6205 | /* JPEG library details. */ | 6215 | /* JPEG library details. */ |
| 6206 | DEF_IMGLIB_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); | 6216 | DEF_DLL_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); |
| 6207 | DEF_IMGLIB_FN (boolean, jpeg_start_decompress, (j_decompress_ptr)); | 6217 | DEF_DLL_FN (boolean, jpeg_start_decompress, (j_decompress_ptr)); |
| 6208 | DEF_IMGLIB_FN (boolean, jpeg_finish_decompress, (j_decompress_ptr)); | 6218 | DEF_DLL_FN (boolean, jpeg_finish_decompress, (j_decompress_ptr)); |
| 6209 | DEF_IMGLIB_FN (void, jpeg_destroy_decompress, (j_decompress_ptr)); | 6219 | DEF_DLL_FN (void, jpeg_destroy_decompress, (j_decompress_ptr)); |
| 6210 | DEF_IMGLIB_FN (int, jpeg_read_header, (j_decompress_ptr, boolean)); | 6220 | DEF_DLL_FN (int, jpeg_read_header, (j_decompress_ptr, boolean)); |
| 6211 | DEF_IMGLIB_FN (JDIMENSION, jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, JDIMENSION)); | 6221 | DEF_DLL_FN (JDIMENSION, jpeg_read_scanlines, |
| 6212 | DEF_IMGLIB_FN (struct jpeg_error_mgr *, jpeg_std_error, (struct jpeg_error_mgr *)); | 6222 | (j_decompress_ptr, JSAMPARRAY, JDIMENSION)); |
| 6213 | DEF_IMGLIB_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int)); | 6223 | DEF_DLL_FN (struct jpeg_error_mgr *, jpeg_std_error, |
| 6224 | (struct jpeg_error_mgr *)); | ||
| 6225 | DEF_DLL_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int)); | ||
| 6214 | 6226 | ||
| 6215 | static bool | 6227 | static bool |
| 6216 | init_jpeg_functions (void) | 6228 | init_jpeg_functions (void) |
| @@ -6220,37 +6232,46 @@ init_jpeg_functions (void) | |||
| 6220 | if (!(library = w32_delayed_load (Qjpeg))) | 6232 | if (!(library = w32_delayed_load (Qjpeg))) |
| 6221 | return 0; | 6233 | return 0; |
| 6222 | 6234 | ||
| 6223 | LOAD_IMGLIB_FN (library, jpeg_finish_decompress); | 6235 | LOAD_DLL_FN (library, jpeg_finish_decompress); |
| 6224 | LOAD_IMGLIB_FN (library, jpeg_read_scanlines); | 6236 | LOAD_DLL_FN (library, jpeg_read_scanlines); |
| 6225 | LOAD_IMGLIB_FN (library, jpeg_start_decompress); | 6237 | LOAD_DLL_FN (library, jpeg_start_decompress); |
| 6226 | LOAD_IMGLIB_FN (library, jpeg_read_header); | 6238 | LOAD_DLL_FN (library, jpeg_read_header); |
| 6227 | LOAD_IMGLIB_FN (library, jpeg_CreateDecompress); | 6239 | LOAD_DLL_FN (library, jpeg_CreateDecompress); |
| 6228 | LOAD_IMGLIB_FN (library, jpeg_destroy_decompress); | 6240 | LOAD_DLL_FN (library, jpeg_destroy_decompress); |
| 6229 | LOAD_IMGLIB_FN (library, jpeg_std_error); | 6241 | LOAD_DLL_FN (library, jpeg_std_error); |
| 6230 | LOAD_IMGLIB_FN (library, jpeg_resync_to_restart); | 6242 | LOAD_DLL_FN (library, jpeg_resync_to_restart); |
| 6231 | return 1; | 6243 | return 1; |
| 6232 | } | 6244 | } |
| 6233 | 6245 | ||
| 6246 | # undef jpeg_CreateDecompress | ||
| 6247 | # undef jpeg_destroy_decompress | ||
| 6248 | # undef jpeg_finish_decompress | ||
| 6249 | # undef jpeg_read_header | ||
| 6250 | # undef jpeg_read_scanlines | ||
| 6251 | # undef jpeg_resync_to_restart | ||
| 6252 | # undef jpeg_start_decompress | ||
| 6253 | # undef jpeg_std_error | ||
| 6254 | |||
| 6255 | # define jpeg_CreateDecompress fn_jpeg_CreateDecompress | ||
| 6256 | # define jpeg_destroy_decompress fn_jpeg_destroy_decompress | ||
| 6257 | # define jpeg_finish_decompress fn_jpeg_finish_decompress | ||
| 6258 | # define jpeg_read_header fn_jpeg_read_header | ||
| 6259 | # define jpeg_read_scanlines fn_jpeg_read_scanlines | ||
| 6260 | # define jpeg_resync_to_restart fn_jpeg_resync_to_restart | ||
| 6261 | # define jpeg_start_decompress fn_jpeg_start_decompress | ||
| 6262 | # define jpeg_std_error fn_jpeg_std_error | ||
| 6263 | |||
| 6234 | /* Wrapper since we can't directly assign the function pointer | 6264 | /* Wrapper since we can't directly assign the function pointer |
| 6235 | to another function pointer that was declared more completely easily. */ | 6265 | to another function pointer that was declared more completely easily. */ |
| 6236 | static boolean | 6266 | static boolean |
| 6237 | jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired) | 6267 | jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired) |
| 6238 | { | 6268 | { |
| 6239 | return fn_jpeg_resync_to_restart (cinfo, desired); | 6269 | return jpeg_resync_to_restart (cinfo, desired); |
| 6240 | } | 6270 | } |
| 6271 | # undef jpeg_resync_to_restart | ||
| 6272 | # define jpeg_resync_to_restart jpeg_resync_to_restart_wrapper | ||
| 6241 | 6273 | ||
| 6242 | #else | 6274 | # endif /* WINDOWSNT */ |
| 6243 | |||
| 6244 | #define fn_jpeg_CreateDecompress(a,b,c) jpeg_create_decompress (a) | ||
| 6245 | #define fn_jpeg_start_decompress jpeg_start_decompress | ||
| 6246 | #define fn_jpeg_finish_decompress jpeg_finish_decompress | ||
| 6247 | #define fn_jpeg_destroy_decompress jpeg_destroy_decompress | ||
| 6248 | #define fn_jpeg_read_header jpeg_read_header | ||
| 6249 | #define fn_jpeg_read_scanlines jpeg_read_scanlines | ||
| 6250 | #define fn_jpeg_std_error jpeg_std_error | ||
| 6251 | #define jpeg_resync_to_restart_wrapper jpeg_resync_to_restart | ||
| 6252 | |||
| 6253 | #endif /* WINDOWSNT */ | ||
| 6254 | 6275 | ||
| 6255 | struct my_jpeg_error_mgr | 6276 | struct my_jpeg_error_mgr |
| 6256 | { | 6277 | { |
| @@ -6358,7 +6379,7 @@ jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, ptrdiff_t len) | |||
| 6358 | src->init_source = our_common_init_source; | 6379 | src->init_source = our_common_init_source; |
| 6359 | src->fill_input_buffer = our_memory_fill_input_buffer; | 6380 | src->fill_input_buffer = our_memory_fill_input_buffer; |
| 6360 | src->skip_input_data = our_memory_skip_input_data; | 6381 | src->skip_input_data = our_memory_skip_input_data; |
| 6361 | src->resync_to_restart = jpeg_resync_to_restart_wrapper; /* Use default method. */ | 6382 | src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */ |
| 6362 | src->term_source = our_common_term_source; | 6383 | src->term_source = our_common_term_source; |
| 6363 | src->bytes_in_buffer = len; | 6384 | src->bytes_in_buffer = len; |
| 6364 | src->next_input_byte = data; | 6385 | src->next_input_byte = data; |
| @@ -6464,7 +6485,7 @@ jpeg_file_src (j_decompress_ptr cinfo, FILE *fp) | |||
| 6464 | src->mgr.init_source = our_common_init_source; | 6485 | src->mgr.init_source = our_common_init_source; |
| 6465 | src->mgr.fill_input_buffer = our_stdio_fill_input_buffer; | 6486 | src->mgr.fill_input_buffer = our_stdio_fill_input_buffer; |
| 6466 | src->mgr.skip_input_data = our_stdio_skip_input_data; | 6487 | src->mgr.skip_input_data = our_stdio_skip_input_data; |
| 6467 | src->mgr.resync_to_restart = jpeg_resync_to_restart_wrapper; /* Use default method. */ | 6488 | src->mgr.resync_to_restart = jpeg_resync_to_restart; /* Use default. */ |
| 6468 | src->mgr.term_source = our_common_term_source; | 6489 | src->mgr.term_source = our_common_term_source; |
| 6469 | src->mgr.bytes_in_buffer = 0; | 6490 | src->mgr.bytes_in_buffer = 0; |
| 6470 | src->mgr.next_input_byte = NULL; | 6491 | src->mgr.next_input_byte = NULL; |
| @@ -6515,7 +6536,7 @@ jpeg_load_body (struct frame *f, struct image *img, | |||
| 6515 | 6536 | ||
| 6516 | /* Customize libjpeg's error handling to call my_error_exit when an | 6537 | /* Customize libjpeg's error handling to call my_error_exit when an |
| 6517 | error is detected. This function will perform a longjmp. */ | 6538 | error is detected. This function will perform a longjmp. */ |
| 6518 | mgr->cinfo.err = fn_jpeg_std_error (&mgr->pub); | 6539 | mgr->cinfo.err = jpeg_std_error (&mgr->pub); |
| 6519 | mgr->pub.error_exit = my_error_exit; | 6540 | mgr->pub.error_exit = my_error_exit; |
| 6520 | if (sys_setjmp (mgr->setjmp_buffer)) | 6541 | if (sys_setjmp (mgr->setjmp_buffer)) |
| 6521 | { | 6542 | { |
| @@ -6541,7 +6562,7 @@ jpeg_load_body (struct frame *f, struct image *img, | |||
| 6541 | /* Close the input file and destroy the JPEG object. */ | 6562 | /* Close the input file and destroy the JPEG object. */ |
| 6542 | if (fp) | 6563 | if (fp) |
| 6543 | fclose (fp); | 6564 | fclose (fp); |
| 6544 | fn_jpeg_destroy_decompress (&mgr->cinfo); | 6565 | jpeg_destroy_decompress (&mgr->cinfo); |
| 6545 | 6566 | ||
| 6546 | /* If we already have an XImage, free that. */ | 6567 | /* If we already have an XImage, free that. */ |
| 6547 | x_destroy_x_image (ximg); | 6568 | x_destroy_x_image (ximg); |
| @@ -6553,7 +6574,7 @@ jpeg_load_body (struct frame *f, struct image *img, | |||
| 6553 | 6574 | ||
| 6554 | /* Create the JPEG decompression object. Let it read from fp. | 6575 | /* Create the JPEG decompression object. Let it read from fp. |
| 6555 | Read the JPEG image header. */ | 6576 | Read the JPEG image header. */ |
| 6556 | fn_jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo); | 6577 | jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo); |
| 6557 | 6578 | ||
| 6558 | if (NILP (specified_data)) | 6579 | if (NILP (specified_data)) |
| 6559 | jpeg_file_src (&mgr->cinfo, fp); | 6580 | jpeg_file_src (&mgr->cinfo, fp); |
| @@ -6561,12 +6582,12 @@ jpeg_load_body (struct frame *f, struct image *img, | |||
| 6561 | jpeg_memory_src (&mgr->cinfo, SDATA (specified_data), | 6582 | jpeg_memory_src (&mgr->cinfo, SDATA (specified_data), |
| 6562 | SBYTES (specified_data)); | 6583 | SBYTES (specified_data)); |
| 6563 | 6584 | ||
| 6564 | fn_jpeg_read_header (&mgr->cinfo, 1); | 6585 | jpeg_read_header (&mgr->cinfo, 1); |
| 6565 | 6586 | ||
| 6566 | /* Customize decompression so that color quantization will be used. | 6587 | /* Customize decompression so that color quantization will be used. |
| 6567 | Start decompression. */ | 6588 | Start decompression. */ |
| 6568 | mgr->cinfo.quantize_colors = 1; | 6589 | mgr->cinfo.quantize_colors = 1; |
| 6569 | fn_jpeg_start_decompress (&mgr->cinfo); | 6590 | jpeg_start_decompress (&mgr->cinfo); |
| 6570 | width = img->width = mgr->cinfo.output_width; | 6591 | width = img->width = mgr->cinfo.output_width; |
| 6571 | height = img->height = mgr->cinfo.output_height; | 6592 | height = img->height = mgr->cinfo.output_height; |
| 6572 | 6593 | ||
| @@ -6629,14 +6650,14 @@ jpeg_load_body (struct frame *f, struct image *img, | |||
| 6629 | JPOOL_IMAGE, row_stride, 1); | 6650 | JPOOL_IMAGE, row_stride, 1); |
| 6630 | for (y = 0; y < height; ++y) | 6651 | for (y = 0; y < height; ++y) |
| 6631 | { | 6652 | { |
| 6632 | fn_jpeg_read_scanlines (&mgr->cinfo, buffer, 1); | 6653 | jpeg_read_scanlines (&mgr->cinfo, buffer, 1); |
| 6633 | for (x = 0; x < mgr->cinfo.output_width; ++x) | 6654 | for (x = 0; x < mgr->cinfo.output_width; ++x) |
| 6634 | XPutPixel (ximg, x, y, colors[buffer[0][x]]); | 6655 | XPutPixel (ximg, x, y, colors[buffer[0][x]]); |
| 6635 | } | 6656 | } |
| 6636 | 6657 | ||
| 6637 | /* Clean up. */ | 6658 | /* Clean up. */ |
| 6638 | fn_jpeg_finish_decompress (&mgr->cinfo); | 6659 | jpeg_finish_decompress (&mgr->cinfo); |
| 6639 | fn_jpeg_destroy_decompress (&mgr->cinfo); | 6660 | jpeg_destroy_decompress (&mgr->cinfo); |
| 6640 | if (fp) | 6661 | if (fp) |
| 6641 | fclose (fp); | 6662 | fclose (fp); |
| 6642 | 6663 | ||
| @@ -6760,22 +6781,22 @@ tiff_image_p (Lisp_Object object) | |||
| 6760 | 6781 | ||
| 6761 | #ifdef HAVE_TIFF | 6782 | #ifdef HAVE_TIFF |
| 6762 | 6783 | ||
| 6763 | #include <tiffio.h> | 6784 | # include <tiffio.h> |
| 6764 | 6785 | ||
| 6765 | #ifdef WINDOWSNT | 6786 | # ifdef WINDOWSNT |
| 6766 | 6787 | ||
| 6767 | /* TIFF library details. */ | 6788 | /* TIFF library details. */ |
| 6768 | DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler)); | 6789 | DEF_DLL_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler)); |
| 6769 | DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetWarningHandler, (TIFFErrorHandler)); | 6790 | DEF_DLL_FN (TIFFErrorHandler, TIFFSetWarningHandler, (TIFFErrorHandler)); |
| 6770 | DEF_IMGLIB_FN (TIFF *, TIFFOpen, (const char *, const char *)); | 6791 | DEF_DLL_FN (TIFF *, TIFFOpen, (const char *, const char *)); |
| 6771 | DEF_IMGLIB_FN (TIFF *, TIFFClientOpen, (const char *, const char *, thandle_t, | 6792 | DEF_DLL_FN (TIFF *, TIFFClientOpen, |
| 6772 | TIFFReadWriteProc, TIFFReadWriteProc, | 6793 | (const char *, const char *, thandle_t, TIFFReadWriteProc, |
| 6773 | TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, | 6794 | TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, |
| 6774 | TIFFMapFileProc, TIFFUnmapFileProc)); | 6795 | TIFFMapFileProc, TIFFUnmapFileProc)); |
| 6775 | DEF_IMGLIB_FN (int, TIFFGetField, (TIFF *, ttag_t, ...)); | 6796 | DEF_DLL_FN (int, TIFFGetField, (TIFF *, ttag_t, ...)); |
| 6776 | DEF_IMGLIB_FN (int, TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int)); | 6797 | DEF_DLL_FN (int, TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int)); |
| 6777 | DEF_IMGLIB_FN (void, TIFFClose, (TIFF *)); | 6798 | DEF_DLL_FN (void, TIFFClose, (TIFF *)); |
| 6778 | DEF_IMGLIB_FN (int, TIFFSetDirectory, (TIFF *, tdir_t)); | 6799 | DEF_DLL_FN (int, TIFFSetDirectory, (TIFF *, tdir_t)); |
| 6779 | 6800 | ||
| 6780 | static bool | 6801 | static bool |
| 6781 | init_tiff_functions (void) | 6802 | init_tiff_functions (void) |
| @@ -6785,28 +6806,36 @@ init_tiff_functions (void) | |||
| 6785 | if (!(library = w32_delayed_load (Qtiff))) | 6806 | if (!(library = w32_delayed_load (Qtiff))) |
| 6786 | return 0; | 6807 | return 0; |
| 6787 | 6808 | ||
| 6788 | LOAD_IMGLIB_FN (library, TIFFSetErrorHandler); | 6809 | LOAD_DLL_FN (library, TIFFSetErrorHandler); |
| 6789 | LOAD_IMGLIB_FN (library, TIFFSetWarningHandler); | 6810 | LOAD_DLL_FN (library, TIFFSetWarningHandler); |
| 6790 | LOAD_IMGLIB_FN (library, TIFFOpen); | 6811 | LOAD_DLL_FN (library, TIFFOpen); |
| 6791 | LOAD_IMGLIB_FN (library, TIFFClientOpen); | 6812 | LOAD_DLL_FN (library, TIFFClientOpen); |
| 6792 | LOAD_IMGLIB_FN (library, TIFFGetField); | 6813 | LOAD_DLL_FN (library, TIFFGetField); |
| 6793 | LOAD_IMGLIB_FN (library, TIFFReadRGBAImage); | 6814 | LOAD_DLL_FN (library, TIFFReadRGBAImage); |
| 6794 | LOAD_IMGLIB_FN (library, TIFFClose); | 6815 | LOAD_DLL_FN (library, TIFFClose); |
| 6795 | LOAD_IMGLIB_FN (library, TIFFSetDirectory); | 6816 | LOAD_DLL_FN (library, TIFFSetDirectory); |
| 6796 | return 1; | 6817 | return 1; |
| 6797 | } | 6818 | } |
| 6798 | 6819 | ||
| 6799 | #else | 6820 | # undef TIFFClientOpen |
| 6821 | # undef TIFFClose | ||
| 6822 | # undef TIFFGetField | ||
| 6823 | # undef TIFFOpen | ||
| 6824 | # undef TIFFReadRGBAImage | ||
| 6825 | # undef TIFFSetDirectory | ||
| 6826 | # undef TIFFSetErrorHandler | ||
| 6827 | # undef TIFFSetWarningHandler | ||
| 6800 | 6828 | ||
| 6801 | #define fn_TIFFSetErrorHandler TIFFSetErrorHandler | 6829 | # define TIFFClientOpen fn_TIFFClientOpen |
| 6802 | #define fn_TIFFSetWarningHandler TIFFSetWarningHandler | 6830 | # define TIFFClose fn_TIFFClose |
| 6803 | #define fn_TIFFOpen TIFFOpen | 6831 | # define TIFFGetField fn_TIFFGetField |
| 6804 | #define fn_TIFFClientOpen TIFFClientOpen | 6832 | # define TIFFOpen fn_TIFFOpen |
| 6805 | #define fn_TIFFGetField TIFFGetField | 6833 | # define TIFFReadRGBAImage fn_TIFFReadRGBAImage |
| 6806 | #define fn_TIFFReadRGBAImage TIFFReadRGBAImage | 6834 | # define TIFFSetDirectory fn_TIFFSetDirectory |
| 6807 | #define fn_TIFFClose TIFFClose | 6835 | # define TIFFSetErrorHandler fn_TIFFSetErrorHandler |
| 6808 | #define fn_TIFFSetDirectory TIFFSetDirectory | 6836 | # define TIFFSetWarningHandler fn_TIFFSetWarningHandler |
| 6809 | #endif /* WINDOWSNT */ | 6837 | |
| 6838 | # endif /* WINDOWSNT */ | ||
| 6810 | 6839 | ||
| 6811 | 6840 | ||
| 6812 | /* Reading from a memory buffer for TIFF images Based on the PNG | 6841 | /* Reading from a memory buffer for TIFF images Based on the PNG |
| @@ -6904,11 +6933,11 @@ tiff_size_of_memory (thandle_t data) | |||
| 6904 | compiler error compiling tiff_handler, see Bugzilla bug #17406 | 6933 | compiler error compiling tiff_handler, see Bugzilla bug #17406 |
| 6905 | (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17406). Declaring | 6934 | (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17406). Declaring |
| 6906 | this function as external works around that problem. */ | 6935 | this function as external works around that problem. */ |
| 6907 | #if defined (__MINGW32__) && __GNUC__ == 3 | 6936 | # if defined (__MINGW32__) && __GNUC__ == 3 |
| 6908 | # define MINGW_STATIC | 6937 | # define MINGW_STATIC |
| 6909 | #else | 6938 | # else |
| 6910 | # define MINGW_STATIC static | 6939 | # define MINGW_STATIC static |
| 6911 | #endif | 6940 | # endif |
| 6912 | 6941 | ||
| 6913 | MINGW_STATIC void | 6942 | MINGW_STATIC void |
| 6914 | tiff_handler (const char *, const char *, const char *, va_list) | 6943 | tiff_handler (const char *, const char *, const char *, va_list) |
| @@ -6927,7 +6956,7 @@ tiff_handler (const char *log_format, const char *title, | |||
| 6927 | add_to_log (log_format, build_string (title), | 6956 | add_to_log (log_format, build_string (title), |
| 6928 | make_string (buf, max (0, min (len, sizeof buf - 1)))); | 6957 | make_string (buf, max (0, min (len, sizeof buf - 1)))); |
| 6929 | } | 6958 | } |
| 6930 | #undef MINGW_STATIC | 6959 | # undef MINGW_STATIC |
| 6931 | 6960 | ||
| 6932 | static void tiff_error_handler (const char *, const char *, va_list) | 6961 | static void tiff_error_handler (const char *, const char *, va_list) |
| 6933 | ATTRIBUTE_FORMAT_PRINTF (2, 0); | 6962 | ATTRIBUTE_FORMAT_PRINTF (2, 0); |
| @@ -6966,8 +6995,8 @@ tiff_load (struct frame *f, struct image *img) | |||
| 6966 | specified_file = image_spec_value (img->spec, QCfile, NULL); | 6995 | specified_file = image_spec_value (img->spec, QCfile, NULL); |
| 6967 | specified_data = image_spec_value (img->spec, QCdata, NULL); | 6996 | specified_data = image_spec_value (img->spec, QCdata, NULL); |
| 6968 | 6997 | ||
| 6969 | fn_TIFFSetErrorHandler ((TIFFErrorHandler) tiff_error_handler); | 6998 | TIFFSetErrorHandler ((TIFFErrorHandler) tiff_error_handler); |
| 6970 | fn_TIFFSetWarningHandler ((TIFFErrorHandler) tiff_warning_handler); | 6999 | TIFFSetWarningHandler ((TIFFErrorHandler) tiff_warning_handler); |
| 6971 | 7000 | ||
| 6972 | if (NILP (specified_data)) | 7001 | if (NILP (specified_data)) |
| 6973 | { | 7002 | { |
| @@ -6978,12 +7007,12 @@ tiff_load (struct frame *f, struct image *img) | |||
| 6978 | image_error ("Cannot find image file `%s'", specified_file, Qnil); | 7007 | image_error ("Cannot find image file `%s'", specified_file, Qnil); |
| 6979 | return 0; | 7008 | return 0; |
| 6980 | } | 7009 | } |
| 6981 | #ifdef WINDOWSNT | 7010 | # ifdef WINDOWSNT |
| 6982 | file = ansi_encode_filename (file); | 7011 | file = ansi_encode_filename (file); |
| 6983 | #endif | 7012 | # endif |
| 6984 | 7013 | ||
| 6985 | /* Try to open the image file. */ | 7014 | /* Try to open the image file. */ |
| 6986 | tiff = fn_TIFFOpen (SSDATA (file), "r"); | 7015 | tiff = TIFFOpen (SSDATA (file), "r"); |
| 6987 | if (tiff == NULL) | 7016 | if (tiff == NULL) |
| 6988 | { | 7017 | { |
| 6989 | image_error ("Cannot open `%s'", file, Qnil); | 7018 | image_error ("Cannot open `%s'", file, Qnil); |
| @@ -7003,14 +7032,14 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7003 | memsrc.len = SBYTES (specified_data); | 7032 | memsrc.len = SBYTES (specified_data); |
| 7004 | memsrc.index = 0; | 7033 | memsrc.index = 0; |
| 7005 | 7034 | ||
| 7006 | tiff = fn_TIFFClientOpen ("memory_source", "r", (thandle_t)&memsrc, | 7035 | tiff = TIFFClientOpen ("memory_source", "r", (thandle_t)&memsrc, |
| 7007 | tiff_read_from_memory, | 7036 | tiff_read_from_memory, |
| 7008 | tiff_write_from_memory, | 7037 | tiff_write_from_memory, |
| 7009 | tiff_seek_in_memory, | 7038 | tiff_seek_in_memory, |
| 7010 | tiff_close_memory, | 7039 | tiff_close_memory, |
| 7011 | tiff_size_of_memory, | 7040 | tiff_size_of_memory, |
| 7012 | tiff_mmap_memory, | 7041 | tiff_mmap_memory, |
| 7013 | tiff_unmap_memory); | 7042 | tiff_unmap_memory); |
| 7014 | 7043 | ||
| 7015 | if (!tiff) | 7044 | if (!tiff) |
| 7016 | { | 7045 | { |
| @@ -7024,24 +7053,24 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7024 | { | 7053 | { |
| 7025 | EMACS_INT ino = XFASTINT (image); | 7054 | EMACS_INT ino = XFASTINT (image); |
| 7026 | if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t) | 7055 | if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t) |
| 7027 | && fn_TIFFSetDirectory (tiff, ino))) | 7056 | && TIFFSetDirectory (tiff, ino))) |
| 7028 | { | 7057 | { |
| 7029 | image_error ("Invalid image number `%s' in image `%s'", | 7058 | image_error ("Invalid image number `%s' in image `%s'", |
| 7030 | image, img->spec); | 7059 | image, img->spec); |
| 7031 | fn_TIFFClose (tiff); | 7060 | TIFFClose (tiff); |
| 7032 | return 0; | 7061 | return 0; |
| 7033 | } | 7062 | } |
| 7034 | } | 7063 | } |
| 7035 | 7064 | ||
| 7036 | /* Get width and height of the image, and allocate a raster buffer | 7065 | /* Get width and height of the image, and allocate a raster buffer |
| 7037 | of width x height 32-bit values. */ | 7066 | of width x height 32-bit values. */ |
| 7038 | fn_TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); | 7067 | TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); |
| 7039 | fn_TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); | 7068 | TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); |
| 7040 | 7069 | ||
| 7041 | if (!check_image_size (f, width, height)) | 7070 | if (!check_image_size (f, width, height)) |
| 7042 | { | 7071 | { |
| 7043 | image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); | 7072 | image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); |
| 7044 | fn_TIFFClose (tiff); | 7073 | TIFFClose (tiff); |
| 7045 | return 0; | 7074 | return 0; |
| 7046 | } | 7075 | } |
| 7047 | 7076 | ||
| @@ -7050,16 +7079,16 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7050 | && image_create_x_image_and_pixmap (f, img, width, height, 0, | 7079 | && image_create_x_image_and_pixmap (f, img, width, height, 0, |
| 7051 | &ximg, 0))) | 7080 | &ximg, 0))) |
| 7052 | { | 7081 | { |
| 7053 | fn_TIFFClose (tiff); | 7082 | TIFFClose (tiff); |
| 7054 | return 0; | 7083 | return 0; |
| 7055 | } | 7084 | } |
| 7056 | 7085 | ||
| 7057 | buf = xmalloc (sizeof *buf * width * height); | 7086 | buf = xmalloc (sizeof *buf * width * height); |
| 7058 | 7087 | ||
| 7059 | rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0); | 7088 | rc = TIFFReadRGBAImage (tiff, width, height, buf, 0); |
| 7060 | 7089 | ||
| 7061 | /* Count the number of images in the file. */ | 7090 | /* Count the number of images in the file. */ |
| 7062 | for (count = 1; fn_TIFFSetDirectory (tiff, count); count++) | 7091 | for (count = 1; TIFFSetDirectory (tiff, count); count++) |
| 7063 | continue; | 7092 | continue; |
| 7064 | 7093 | ||
| 7065 | if (count > 1) | 7094 | if (count > 1) |
| @@ -7067,7 +7096,7 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7067 | Fcons (make_number (count), | 7096 | Fcons (make_number (count), |
| 7068 | img->lisp_data)); | 7097 | img->lisp_data)); |
| 7069 | 7098 | ||
| 7070 | fn_TIFFClose (tiff); | 7099 | TIFFClose (tiff); |
| 7071 | if (!rc) | 7100 | if (!rc) |
| 7072 | { | 7101 | { |
| 7073 | image_error ("Error reading TIFF image `%s'", img->spec, Qnil); | 7102 | image_error ("Error reading TIFF image `%s'", img->spec, Qnil); |
| @@ -7093,11 +7122,11 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7093 | } | 7122 | } |
| 7094 | } | 7123 | } |
| 7095 | 7124 | ||
| 7096 | #ifdef COLOR_TABLE_SUPPORT | 7125 | # ifdef COLOR_TABLE_SUPPORT |
| 7097 | /* Remember the colors allocated for the image. Free the color table. */ | 7126 | /* Remember the colors allocated for the image. Free the color table. */ |
| 7098 | img->colors = colors_in_color_table (&img->ncolors); | 7127 | img->colors = colors_in_color_table (&img->ncolors); |
| 7099 | free_color_table (); | 7128 | free_color_table (); |
| 7100 | #endif /* COLOR_TABLE_SUPPORT */ | 7129 | # endif /* COLOR_TABLE_SUPPORT */ |
| 7101 | 7130 | ||
| 7102 | img->width = width; | 7131 | img->width = width; |
| 7103 | img->height = height; | 7132 | img->height = height; |
| @@ -7114,9 +7143,8 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7114 | return 1; | 7143 | return 1; |
| 7115 | } | 7144 | } |
| 7116 | 7145 | ||
| 7117 | #else /* HAVE_TIFF */ | 7146 | #elif defined HAVE_NS |
| 7118 | 7147 | ||
| 7119 | #ifdef HAVE_NS | ||
| 7120 | static bool | 7148 | static bool |
| 7121 | tiff_load (struct frame *f, struct image *img) | 7149 | tiff_load (struct frame *f, struct image *img) |
| 7122 | { | 7150 | { |
| @@ -7124,9 +7152,8 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7124 | image_spec_value (img->spec, QCfile, NULL), | 7152 | image_spec_value (img->spec, QCfile, NULL), |
| 7125 | image_spec_value (img->spec, QCdata, NULL)); | 7153 | image_spec_value (img->spec, QCdata, NULL)); |
| 7126 | } | 7154 | } |
| 7127 | #endif /* HAVE_NS */ | ||
| 7128 | 7155 | ||
| 7129 | #endif /* !HAVE_TIFF */ | 7156 | #endif |
| 7130 | 7157 | ||
| 7131 | 7158 | ||
| 7132 | 7159 | ||
| @@ -7226,54 +7253,54 @@ gif_image_p (Lisp_Object object) | |||
| 7226 | 7253 | ||
| 7227 | #ifdef HAVE_GIF | 7254 | #ifdef HAVE_GIF |
| 7228 | 7255 | ||
| 7229 | #if defined (HAVE_NTGUI) | 7256 | # ifdef HAVE_NTGUI |
| 7230 | 7257 | ||
| 7231 | /* winuser.h might define DrawText to DrawTextA or DrawTextW. | 7258 | /* winuser.h might define DrawText to DrawTextA or DrawTextW. |
| 7232 | Undefine before redefining to avoid a preprocessor warning. */ | 7259 | Undefine before redefining to avoid a preprocessor warning. */ |
| 7233 | #ifdef DrawText | 7260 | # ifdef DrawText |
| 7234 | #undef DrawText | 7261 | # undef DrawText |
| 7235 | #endif | 7262 | # endif |
| 7236 | /* avoid conflict with QuickdrawText.h */ | 7263 | /* avoid conflict with QuickdrawText.h */ |
| 7237 | #define DrawText gif_DrawText | 7264 | # define DrawText gif_DrawText |
| 7238 | #include <gif_lib.h> | 7265 | # include <gif_lib.h> |
| 7239 | #undef DrawText | 7266 | # undef DrawText |
| 7240 | 7267 | ||
| 7241 | /* Giflib before 5.0 didn't define these macros (used only if HAVE_NTGUI). */ | 7268 | /* Giflib before 5.0 didn't define these macros (used only if HAVE_NTGUI). */ |
| 7242 | #ifndef GIFLIB_MINOR | 7269 | # ifndef GIFLIB_MINOR |
| 7243 | #define GIFLIB_MINOR 0 | 7270 | # define GIFLIB_MINOR 0 |
| 7244 | #endif | 7271 | # endif |
| 7245 | #ifndef GIFLIB_RELEASE | 7272 | # ifndef GIFLIB_RELEASE |
| 7246 | #define GIFLIB_RELEASE 0 | 7273 | # define GIFLIB_RELEASE 0 |
| 7247 | #endif | 7274 | # endif |
| 7248 | 7275 | ||
| 7249 | #else /* HAVE_NTGUI */ | 7276 | # else /* HAVE_NTGUI */ |
| 7250 | 7277 | ||
| 7251 | #include <gif_lib.h> | 7278 | # include <gif_lib.h> |
| 7252 | 7279 | ||
| 7253 | #endif /* HAVE_NTGUI */ | 7280 | # endif /* HAVE_NTGUI */ |
| 7254 | 7281 | ||
| 7255 | /* Giflib before 5.0 didn't define these macros. */ | 7282 | /* Giflib before 5.0 didn't define these macros. */ |
| 7256 | #ifndef GIFLIB_MAJOR | 7283 | # ifndef GIFLIB_MAJOR |
| 7257 | #define GIFLIB_MAJOR 4 | 7284 | # define GIFLIB_MAJOR 4 |
| 7258 | #endif | 7285 | # endif |
| 7259 | 7286 | ||
| 7260 | #ifdef WINDOWSNT | 7287 | # ifdef WINDOWSNT |
| 7261 | 7288 | ||
| 7262 | /* GIF library details. */ | 7289 | /* GIF library details. */ |
| 7263 | #if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR) | 7290 | # if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR) |
| 7264 | DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *, int *)); | 7291 | DEF_DLL_FN (int, DGifCloseFile, (GifFileType *, int *)); |
| 7265 | #else | 7292 | # else |
| 7266 | DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *)); | 7293 | DEF_DLL_FN (int, DGifCloseFile, (GifFileType *)); |
| 7267 | #endif | 7294 | # endif |
| 7268 | DEF_IMGLIB_FN (int, DGifSlurp, (GifFileType *)); | 7295 | DEF_DLL_FN (int, DGifSlurp, (GifFileType *)); |
| 7269 | #if GIFLIB_MAJOR < 5 | 7296 | # if GIFLIB_MAJOR < 5 |
| 7270 | DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc)); | 7297 | DEF_DLL_FN (GifFileType *, DGifOpen, (void *, InputFunc)); |
| 7271 | DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *)); | 7298 | DEF_DLL_FN (GifFileType *, DGifOpenFileName, (const char *)); |
| 7272 | #else | 7299 | # else |
| 7273 | DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc, int *)); | 7300 | DEF_DLL_FN (GifFileType *, DGifOpen, (void *, InputFunc, int *)); |
| 7274 | DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *, int *)); | 7301 | DEF_DLL_FN (GifFileType *, DGifOpenFileName, (const char *, int *)); |
| 7275 | DEF_IMGLIB_FN (char *, GifErrorString, (int)); | 7302 | DEF_DLL_FN (char *, GifErrorString, (int)); |
| 7276 | #endif | 7303 | # endif |
| 7277 | 7304 | ||
| 7278 | static bool | 7305 | static bool |
| 7279 | init_gif_functions (void) | 7306 | init_gif_functions (void) |
| @@ -7283,27 +7310,29 @@ init_gif_functions (void) | |||
| 7283 | if (!(library = w32_delayed_load (Qgif))) | 7310 | if (!(library = w32_delayed_load (Qgif))) |
| 7284 | return 0; | 7311 | return 0; |
| 7285 | 7312 | ||
| 7286 | LOAD_IMGLIB_FN (library, DGifCloseFile); | 7313 | LOAD_DLL_FN (library, DGifCloseFile); |
| 7287 | LOAD_IMGLIB_FN (library, DGifSlurp); | 7314 | LOAD_DLL_FN (library, DGifSlurp); |
| 7288 | LOAD_IMGLIB_FN (library, DGifOpen); | 7315 | LOAD_DLL_FN (library, DGifOpen); |
| 7289 | LOAD_IMGLIB_FN (library, DGifOpenFileName); | 7316 | LOAD_DLL_FN (library, DGifOpenFileName); |
| 7290 | #if GIFLIB_MAJOR >= 5 | 7317 | # if GIFLIB_MAJOR >= 5 |
| 7291 | LOAD_IMGLIB_FN (library, GifErrorString); | 7318 | LOAD_DLL_FN (library, GifErrorString); |
| 7292 | #endif | 7319 | # endif |
| 7293 | return 1; | 7320 | return 1; |
| 7294 | } | 7321 | } |
| 7295 | 7322 | ||
| 7296 | #else | 7323 | # undef DGifCloseFile |
| 7324 | # undef DGifOpen | ||
| 7325 | # undef DGifOpenFileName | ||
| 7326 | # undef DGifSlurp | ||
| 7327 | # undef GifErrorString | ||
| 7297 | 7328 | ||
| 7298 | #define fn_DGifCloseFile DGifCloseFile | 7329 | # define DGifCloseFile fn_DGifCloseFile |
| 7299 | #define fn_DGifSlurp DGifSlurp | 7330 | # define DGifOpen fn_DGifOpen |
| 7300 | #define fn_DGifOpen DGifOpen | 7331 | # define DGifOpenFileName fn_DGifOpenFileName |
| 7301 | #define fn_DGifOpenFileName DGifOpenFileName | 7332 | # define DGifSlurp fn_DGifSlurp |
| 7302 | #if 5 <= GIFLIB_MAJOR | 7333 | # define GifErrorString fn_GifErrorString |
| 7303 | # define fn_GifErrorString GifErrorString | ||
| 7304 | #endif | ||
| 7305 | 7334 | ||
| 7306 | #endif /* WINDOWSNT */ | 7335 | # endif /* WINDOWSNT */ |
| 7307 | 7336 | ||
| 7308 | /* Reading a GIF image from memory | 7337 | /* Reading a GIF image from memory |
| 7309 | Based on the PNG memory stuff to a certain extent. */ | 7338 | Based on the PNG memory stuff to a certain extent. */ |
| @@ -7340,9 +7369,9 @@ gif_close (GifFileType *gif, int *err) | |||
| 7340 | int retval; | 7369 | int retval; |
| 7341 | 7370 | ||
| 7342 | #if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR) | 7371 | #if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR) |
| 7343 | retval = fn_DGifCloseFile (gif, err); | 7372 | retval = DGifCloseFile (gif, err); |
| 7344 | #else | 7373 | #else |
| 7345 | retval = fn_DGifCloseFile (gif); | 7374 | retval = DGifCloseFile (gif); |
| 7346 | #if GIFLIB_MAJOR >= 5 | 7375 | #if GIFLIB_MAJOR >= 5 |
| 7347 | if (err) | 7376 | if (err) |
| 7348 | *err = gif->Error; | 7377 | *err = gif->Error; |
| @@ -7390,18 +7419,18 @@ gif_load (struct frame *f, struct image *img) | |||
| 7390 | 7419 | ||
| 7391 | /* Open the GIF file. */ | 7420 | /* Open the GIF file. */ |
| 7392 | #if GIFLIB_MAJOR < 5 | 7421 | #if GIFLIB_MAJOR < 5 |
| 7393 | gif = fn_DGifOpenFileName (SSDATA (file)); | 7422 | gif = DGifOpenFileName (SSDATA (file)); |
| 7394 | if (gif == NULL) | 7423 | if (gif == NULL) |
| 7395 | { | 7424 | { |
| 7396 | image_error ("Cannot open `%s'", file, Qnil); | 7425 | image_error ("Cannot open `%s'", file, Qnil); |
| 7397 | return 0; | 7426 | return 0; |
| 7398 | } | 7427 | } |
| 7399 | #else | 7428 | #else |
| 7400 | gif = fn_DGifOpenFileName (SSDATA (file), &gif_err); | 7429 | gif = DGifOpenFileName (SSDATA (file), &gif_err); |
| 7401 | if (gif == NULL) | 7430 | if (gif == NULL) |
| 7402 | { | 7431 | { |
| 7403 | image_error ("Cannot open `%s': %s", | 7432 | image_error ("Cannot open `%s': %s", |
| 7404 | file, build_string (fn_GifErrorString (gif_err))); | 7433 | file, build_string (GifErrorString (gif_err))); |
| 7405 | return 0; | 7434 | return 0; |
| 7406 | } | 7435 | } |
| 7407 | #endif | 7436 | #endif |
| @@ -7421,18 +7450,18 @@ gif_load (struct frame *f, struct image *img) | |||
| 7421 | memsrc.index = 0; | 7450 | memsrc.index = 0; |
| 7422 | 7451 | ||
| 7423 | #if GIFLIB_MAJOR < 5 | 7452 | #if GIFLIB_MAJOR < 5 |
| 7424 | gif = fn_DGifOpen (&memsrc, gif_read_from_memory); | 7453 | gif = DGifOpen (&memsrc, gif_read_from_memory); |
| 7425 | if (!gif) | 7454 | if (!gif) |
| 7426 | { | 7455 | { |
| 7427 | image_error ("Cannot open memory source `%s'", img->spec, Qnil); | 7456 | image_error ("Cannot open memory source `%s'", img->spec, Qnil); |
| 7428 | return 0; | 7457 | return 0; |
| 7429 | } | 7458 | } |
| 7430 | #else | 7459 | #else |
| 7431 | gif = fn_DGifOpen (&memsrc, gif_read_from_memory, &gif_err); | 7460 | gif = DGifOpen (&memsrc, gif_read_from_memory, &gif_err); |
| 7432 | if (!gif) | 7461 | if (!gif) |
| 7433 | { | 7462 | { |
| 7434 | image_error ("Cannot open memory source `%s': %s", | 7463 | image_error ("Cannot open memory source `%s': %s", |
| 7435 | img->spec, build_string (fn_GifErrorString (gif_err))); | 7464 | img->spec, build_string (GifErrorString (gif_err))); |
| 7436 | return 0; | 7465 | return 0; |
| 7437 | } | 7466 | } |
| 7438 | #endif | 7467 | #endif |
| @@ -7447,7 +7476,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 7447 | } | 7476 | } |
| 7448 | 7477 | ||
| 7449 | /* Read entire contents. */ | 7478 | /* Read entire contents. */ |
| 7450 | rc = fn_DGifSlurp (gif); | 7479 | rc = DGifSlurp (gif); |
| 7451 | if (rc == GIF_ERROR || gif->ImageCount <= 0) | 7480 | if (rc == GIF_ERROR || gif->ImageCount <= 0) |
| 7452 | { | 7481 | { |
| 7453 | image_error ("Error reading `%s'", img->spec, Qnil); | 7482 | image_error ("Error reading `%s'", img->spec, Qnil); |
| @@ -7681,7 +7710,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 7681 | if (gif_close (gif, &gif_err) == GIF_ERROR) | 7710 | if (gif_close (gif, &gif_err) == GIF_ERROR) |
| 7682 | { | 7711 | { |
| 7683 | #if 5 <= GIFLIB_MAJOR | 7712 | #if 5 <= GIFLIB_MAJOR |
| 7684 | char *error_text = fn_GifErrorString (gif_err); | 7713 | char *error_text = GifErrorString (gif_err); |
| 7685 | 7714 | ||
| 7686 | if (error_text) | 7715 | if (error_text) |
| 7687 | image_error ("Error closing `%s': %s", | 7716 | image_error ("Error closing `%s': %s", |
| @@ -8593,7 +8622,7 @@ and `imagemagick-types-inhibit'. */) | |||
| 8593 | SVG | 8622 | SVG |
| 8594 | ***********************************************************************/ | 8623 | ***********************************************************************/ |
| 8595 | 8624 | ||
| 8596 | #if defined (HAVE_RSVG) | 8625 | #ifdef HAVE_RSVG |
| 8597 | 8626 | ||
| 8598 | /* Function prototypes. */ | 8627 | /* Function prototypes. */ |
| 8599 | 8628 | ||
| @@ -8641,11 +8670,11 @@ static const struct image_keyword svg_format[SVG_LAST] = | |||
| 8641 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | 8670 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} |
| 8642 | }; | 8671 | }; |
| 8643 | 8672 | ||
| 8644 | #if defined HAVE_NTGUI && defined WINDOWSNT | 8673 | # if defined HAVE_NTGUI && defined WINDOWSNT |
| 8645 | static bool init_svg_functions (void); | 8674 | static bool init_svg_functions (void); |
| 8646 | #else | 8675 | # else |
| 8647 | #define init_svg_functions NULL | 8676 | #define init_svg_functions NULL |
| 8648 | #endif | 8677 | # endif |
| 8649 | 8678 | ||
| 8650 | /* Structure describing the image type `svg'. Its the same type of | 8679 | /* Structure describing the image type `svg'. Its the same type of |
| 8651 | structure defined for all image formats, handled by emacs image | 8680 | structure defined for all image formats, handled by emacs image |
| @@ -8679,32 +8708,34 @@ svg_image_p (Lisp_Object object) | |||
| 8679 | return fmt[SVG_FILE].count + fmt[SVG_DATA].count == 1; | 8708 | return fmt[SVG_FILE].count + fmt[SVG_DATA].count == 1; |
| 8680 | } | 8709 | } |
| 8681 | 8710 | ||
| 8682 | #include <librsvg/rsvg.h> | 8711 | # include <librsvg/rsvg.h> |
| 8683 | 8712 | ||
| 8684 | #ifdef WINDOWSNT | 8713 | # ifdef WINDOWSNT |
| 8685 | 8714 | ||
| 8686 | /* SVG library functions. */ | 8715 | /* SVG library functions. */ |
| 8687 | DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new, (void)); | 8716 | DEF_DLL_FN (RsvgHandle *, rsvg_handle_new, (void)); |
| 8688 | DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions, (RsvgHandle *, RsvgDimensionData *)); | 8717 | DEF_DLL_FN (void, rsvg_handle_get_dimensions, |
| 8689 | DEF_IMGLIB_FN (gboolean, rsvg_handle_write, (RsvgHandle *, const guchar *, gsize, GError **)); | 8718 | (RsvgHandle *, RsvgDimensionData *)); |
| 8690 | DEF_IMGLIB_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **)); | 8719 | DEF_DLL_FN (gboolean, rsvg_handle_write, |
| 8691 | DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *)); | 8720 | (RsvgHandle *, const guchar *, gsize, GError **)); |
| 8692 | DEF_IMGLIB_FN (void, rsvg_handle_set_base_uri, (RsvgHandle *, const char *)); | 8721 | DEF_DLL_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **)); |
| 8693 | 8722 | DEF_DLL_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *)); | |
| 8694 | DEF_IMGLIB_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *)); | 8723 | DEF_DLL_FN (void, rsvg_handle_set_base_uri, (RsvgHandle *, const char *)); |
| 8695 | DEF_IMGLIB_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *)); | 8724 | |
| 8696 | DEF_IMGLIB_FN (guchar *, gdk_pixbuf_get_pixels, (const GdkPixbuf *)); | 8725 | DEF_DLL_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *)); |
| 8697 | DEF_IMGLIB_FN (int, gdk_pixbuf_get_rowstride, (const GdkPixbuf *)); | 8726 | DEF_DLL_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *)); |
| 8698 | DEF_IMGLIB_FN (GdkColorspace, gdk_pixbuf_get_colorspace, (const GdkPixbuf *)); | 8727 | DEF_DLL_FN (guchar *, gdk_pixbuf_get_pixels, (const GdkPixbuf *)); |
| 8699 | DEF_IMGLIB_FN (int, gdk_pixbuf_get_n_channels, (const GdkPixbuf *)); | 8728 | DEF_DLL_FN (int, gdk_pixbuf_get_rowstride, (const GdkPixbuf *)); |
| 8700 | DEF_IMGLIB_FN (gboolean, gdk_pixbuf_get_has_alpha, (const GdkPixbuf *)); | 8729 | DEF_DLL_FN (GdkColorspace, gdk_pixbuf_get_colorspace, (const GdkPixbuf *)); |
| 8701 | DEF_IMGLIB_FN (int, gdk_pixbuf_get_bits_per_sample, (const GdkPixbuf *)); | 8730 | DEF_DLL_FN (int, gdk_pixbuf_get_n_channels, (const GdkPixbuf *)); |
| 8702 | 8731 | DEF_DLL_FN (gboolean, gdk_pixbuf_get_has_alpha, (const GdkPixbuf *)); | |
| 8703 | #if ! GLIB_CHECK_VERSION (2, 36, 0) | 8732 | DEF_DLL_FN (int, gdk_pixbuf_get_bits_per_sample, (const GdkPixbuf *)); |
| 8704 | DEF_IMGLIB_FN (void, g_type_init, (void)); | 8733 | |
| 8705 | #endif | 8734 | # if ! GLIB_CHECK_VERSION (2, 36, 0) |
| 8706 | DEF_IMGLIB_FN (void, g_object_unref, (gpointer)); | 8735 | DEF_DLL_FN (void, g_type_init, (void)); |
| 8707 | DEF_IMGLIB_FN (void, g_error_free, (GError *)); | 8736 | # endif |
| 8737 | DEF_DLL_FN (void, g_object_unref, (gpointer)); | ||
| 8738 | DEF_DLL_FN (void, g_error_free, (GError *)); | ||
| 8708 | 8739 | ||
| 8709 | Lisp_Object Qgdk_pixbuf, Qglib, Qgobject; | 8740 | Lisp_Object Qgdk_pixbuf, Qglib, Qgobject; |
| 8710 | 8741 | ||
| @@ -8724,56 +8755,71 @@ init_svg_functions (void) | |||
| 8724 | return 0; | 8755 | return 0; |
| 8725 | } | 8756 | } |
| 8726 | 8757 | ||
| 8727 | LOAD_IMGLIB_FN (library, rsvg_handle_new); | 8758 | LOAD_DLL_FN (library, rsvg_handle_new); |
| 8728 | LOAD_IMGLIB_FN (library, rsvg_handle_get_dimensions); | 8759 | LOAD_DLL_FN (library, rsvg_handle_get_dimensions); |
| 8729 | LOAD_IMGLIB_FN (library, rsvg_handle_write); | 8760 | LOAD_DLL_FN (library, rsvg_handle_write); |
| 8730 | LOAD_IMGLIB_FN (library, rsvg_handle_close); | 8761 | LOAD_DLL_FN (library, rsvg_handle_close); |
| 8731 | LOAD_IMGLIB_FN (library, rsvg_handle_get_pixbuf); | 8762 | LOAD_DLL_FN (library, rsvg_handle_get_pixbuf); |
| 8732 | LOAD_IMGLIB_FN (library, rsvg_handle_set_base_uri); | 8763 | LOAD_DLL_FN (library, rsvg_handle_set_base_uri); |
| 8733 | 8764 | ||
| 8734 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_width); | 8765 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_width); |
| 8735 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_height); | 8766 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_height); |
| 8736 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_pixels); | 8767 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_pixels); |
| 8737 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_rowstride); | 8768 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_rowstride); |
| 8738 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_colorspace); | 8769 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_colorspace); |
| 8739 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_n_channels); | 8770 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_n_channels); |
| 8740 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_has_alpha); | 8771 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_has_alpha); |
| 8741 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_bits_per_sample); | 8772 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_bits_per_sample); |
| 8742 | 8773 | ||
| 8743 | #if ! GLIB_CHECK_VERSION (2, 36, 0) | 8774 | # if ! GLIB_CHECK_VERSION (2, 36, 0) |
| 8744 | LOAD_IMGLIB_FN (gobject, g_type_init); | 8775 | LOAD_DLL_FN (gobject, g_type_init); |
| 8745 | #endif | 8776 | # endif |
| 8746 | LOAD_IMGLIB_FN (gobject, g_object_unref); | 8777 | LOAD_DLL_FN (gobject, g_object_unref); |
| 8747 | LOAD_IMGLIB_FN (glib, g_error_free); | 8778 | LOAD_DLL_FN (glib, g_error_free); |
| 8748 | 8779 | ||
| 8749 | return 1; | 8780 | return 1; |
| 8750 | } | 8781 | } |
| 8751 | 8782 | ||
| 8752 | #else | ||
| 8753 | /* The following aliases for library functions allow dynamic loading | 8783 | /* The following aliases for library functions allow dynamic loading |
| 8754 | to be used on some platforms. */ | 8784 | to be used on some platforms. */ |
| 8755 | #define fn_rsvg_handle_new rsvg_handle_new | ||
| 8756 | #define fn_rsvg_handle_get_dimensions rsvg_handle_get_dimensions | ||
| 8757 | #define fn_rsvg_handle_write rsvg_handle_write | ||
| 8758 | #define fn_rsvg_handle_close rsvg_handle_close | ||
| 8759 | #define fn_rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf | ||
| 8760 | #define fn_rsvg_handle_set_base_uri rsvg_handle_set_base_uri | ||
| 8761 | |||
| 8762 | #define fn_gdk_pixbuf_get_width gdk_pixbuf_get_width | ||
| 8763 | #define fn_gdk_pixbuf_get_height gdk_pixbuf_get_height | ||
| 8764 | #define fn_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels | ||
| 8765 | #define fn_gdk_pixbuf_get_rowstride gdk_pixbuf_get_rowstride | ||
| 8766 | #define fn_gdk_pixbuf_get_colorspace gdk_pixbuf_get_colorspace | ||
| 8767 | #define fn_gdk_pixbuf_get_n_channels gdk_pixbuf_get_n_channels | ||
| 8768 | #define fn_gdk_pixbuf_get_has_alpha gdk_pixbuf_get_has_alpha | ||
| 8769 | #define fn_gdk_pixbuf_get_bits_per_sample gdk_pixbuf_get_bits_per_sample | ||
| 8770 | 8785 | ||
| 8771 | #if ! GLIB_CHECK_VERSION (2, 36, 0) | 8786 | # undef gdk_pixbuf_get_bits_per_sample |
| 8772 | #define fn_g_type_init g_type_init | 8787 | # undef gdk_pixbuf_get_colorspace |
| 8773 | #endif | 8788 | # undef gdk_pixbuf_get_has_alpha |
| 8774 | #define fn_g_object_unref g_object_unref | 8789 | # undef gdk_pixbuf_get_height |
| 8775 | #define fn_g_error_free g_error_free | 8790 | # undef gdk_pixbuf_get_n_channels |
| 8776 | #endif /* !WINDOWSNT */ | 8791 | # undef gdk_pixbuf_get_pixels |
| 8792 | # undef gdk_pixbuf_get_rowstride | ||
| 8793 | # undef gdk_pixbuf_get_width | ||
| 8794 | # undef g_error_free | ||
| 8795 | # undef g_object_unref | ||
| 8796 | # undef g_type_init | ||
| 8797 | # undef rsvg_handle_close | ||
| 8798 | # undef rsvg_handle_get_dimensions | ||
| 8799 | # undef rsvg_handle_get_pixbuf | ||
| 8800 | # undef rsvg_handle_new | ||
| 8801 | # undef rsvg_handle_set_base_uri | ||
| 8802 | # undef rsvg_handle_write | ||
| 8803 | |||
| 8804 | # define gdk_pixbuf_get_bits_per_sample fn_gdk_pixbuf_get_bits_per_sample | ||
| 8805 | # define gdk_pixbuf_get_colorspace fn_gdk_pixbuf_get_colorspace | ||
| 8806 | # define gdk_pixbuf_get_has_alpha fn_gdk_pixbuf_get_has_alpha | ||
| 8807 | # define gdk_pixbuf_get_height fn_gdk_pixbuf_get_height | ||
| 8808 | # define gdk_pixbuf_get_n_channels fn_gdk_pixbuf_get_n_channels | ||
| 8809 | # define gdk_pixbuf_get_pixels fn_gdk_pixbuf_get_pixels | ||
| 8810 | # define gdk_pixbuf_get_rowstride fn_gdk_pixbuf_get_rowstride | ||
| 8811 | # define gdk_pixbuf_get_width fn_gdk_pixbuf_get_width | ||
| 8812 | # define g_error_free fn_g_error_free | ||
| 8813 | # define g_object_unref fn_g_object_unref | ||
| 8814 | # define g_type_init fn_g_type_init | ||
| 8815 | # define rsvg_handle_close fn_rsvg_handle_close | ||
| 8816 | # define rsvg_handle_get_dimensions fn_rsvg_handle_get_dimensions | ||
| 8817 | # define rsvg_handle_get_pixbuf fn_rsvg_handle_get_pixbuf | ||
| 8818 | # define rsvg_handle_new fn_rsvg_handle_new | ||
| 8819 | # define rsvg_handle_set_base_uri fn_rsvg_handle_set_base_uri | ||
| 8820 | # define rsvg_handle_write fn_rsvg_handle_write | ||
| 8821 | |||
| 8822 | # endif /* !WINDOWSNT */ | ||
| 8777 | 8823 | ||
| 8778 | /* Load SVG image IMG for use on frame F. Value is true if | 8824 | /* Load SVG image IMG for use on frame F. Value is true if |
| 8779 | successful. */ | 8825 | successful. */ |
| @@ -8862,28 +8908,28 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 8862 | #if ! GLIB_CHECK_VERSION (2, 36, 0) | 8908 | #if ! GLIB_CHECK_VERSION (2, 36, 0) |
| 8863 | /* g_type_init is a glib function that must be called prior to | 8909 | /* g_type_init is a glib function that must be called prior to |
| 8864 | using gnome type library functions (obsolete since 2.36.0). */ | 8910 | using gnome type library functions (obsolete since 2.36.0). */ |
| 8865 | fn_g_type_init (); | 8911 | g_type_init (); |
| 8866 | #endif | 8912 | #endif |
| 8867 | 8913 | ||
| 8868 | /* Make a handle to a new rsvg object. */ | 8914 | /* Make a handle to a new rsvg object. */ |
| 8869 | rsvg_handle = fn_rsvg_handle_new (); | 8915 | rsvg_handle = rsvg_handle_new (); |
| 8870 | 8916 | ||
| 8871 | /* Set base_uri for properly handling referenced images (via 'href'). | 8917 | /* Set base_uri for properly handling referenced images (via 'href'). |
| 8872 | See rsvg bug 596114 - "image refs are relative to curdir, not .svg file" | 8918 | See rsvg bug 596114 - "image refs are relative to curdir, not .svg file" |
| 8873 | (https://bugzilla.gnome.org/show_bug.cgi?id=596114). */ | 8919 | (https://bugzilla.gnome.org/show_bug.cgi?id=596114). */ |
| 8874 | if (filename) | 8920 | if (filename) |
| 8875 | fn_rsvg_handle_set_base_uri(rsvg_handle, filename); | 8921 | rsvg_handle_set_base_uri(rsvg_handle, filename); |
| 8876 | 8922 | ||
| 8877 | /* Parse the contents argument and fill in the rsvg_handle. */ | 8923 | /* Parse the contents argument and fill in the rsvg_handle. */ |
| 8878 | fn_rsvg_handle_write (rsvg_handle, contents, size, &err); | 8924 | rsvg_handle_write (rsvg_handle, contents, size, &err); |
| 8879 | if (err) goto rsvg_error; | 8925 | if (err) goto rsvg_error; |
| 8880 | 8926 | ||
| 8881 | /* The parsing is complete, rsvg_handle is ready to used, close it | 8927 | /* The parsing is complete, rsvg_handle is ready to used, close it |
| 8882 | for further writes. */ | 8928 | for further writes. */ |
| 8883 | fn_rsvg_handle_close (rsvg_handle, &err); | 8929 | rsvg_handle_close (rsvg_handle, &err); |
| 8884 | if (err) goto rsvg_error; | 8930 | if (err) goto rsvg_error; |
| 8885 | 8931 | ||
| 8886 | fn_rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); | 8932 | rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); |
| 8887 | if (! check_image_size (f, dimension_data.width, dimension_data.height)) | 8933 | if (! check_image_size (f, dimension_data.width, dimension_data.height)) |
| 8888 | { | 8934 | { |
| 8889 | image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); | 8935 | image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); |
| @@ -8892,26 +8938,26 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 8892 | 8938 | ||
| 8893 | /* We can now get a valid pixel buffer from the svg file, if all | 8939 | /* We can now get a valid pixel buffer from the svg file, if all |
| 8894 | went ok. */ | 8940 | went ok. */ |
| 8895 | pixbuf = fn_rsvg_handle_get_pixbuf (rsvg_handle); | 8941 | pixbuf = rsvg_handle_get_pixbuf (rsvg_handle); |
| 8896 | if (!pixbuf) goto rsvg_error; | 8942 | if (!pixbuf) goto rsvg_error; |
| 8897 | fn_g_object_unref (rsvg_handle); | 8943 | g_object_unref (rsvg_handle); |
| 8898 | 8944 | ||
| 8899 | /* Extract some meta data from the svg handle. */ | 8945 | /* Extract some meta data from the svg handle. */ |
| 8900 | width = fn_gdk_pixbuf_get_width (pixbuf); | 8946 | width = gdk_pixbuf_get_width (pixbuf); |
| 8901 | height = fn_gdk_pixbuf_get_height (pixbuf); | 8947 | height = gdk_pixbuf_get_height (pixbuf); |
| 8902 | pixels = fn_gdk_pixbuf_get_pixels (pixbuf); | 8948 | pixels = gdk_pixbuf_get_pixels (pixbuf); |
| 8903 | rowstride = fn_gdk_pixbuf_get_rowstride (pixbuf); | 8949 | rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
| 8904 | 8950 | ||
| 8905 | /* Validate the svg meta data. */ | 8951 | /* Validate the svg meta data. */ |
| 8906 | eassert (fn_gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB); | 8952 | eassert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB); |
| 8907 | eassert (fn_gdk_pixbuf_get_n_channels (pixbuf) == 4); | 8953 | eassert (gdk_pixbuf_get_n_channels (pixbuf) == 4); |
| 8908 | eassert (fn_gdk_pixbuf_get_has_alpha (pixbuf)); | 8954 | eassert (gdk_pixbuf_get_has_alpha (pixbuf)); |
| 8909 | eassert (fn_gdk_pixbuf_get_bits_per_sample (pixbuf) == 8); | 8955 | eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8); |
| 8910 | 8956 | ||
| 8911 | /* Try to create a x pixmap to hold the svg pixmap. */ | 8957 | /* Try to create a x pixmap to hold the svg pixmap. */ |
| 8912 | if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) | 8958 | if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) |
| 8913 | { | 8959 | { |
| 8914 | fn_g_object_unref (pixbuf); | 8960 | g_object_unref (pixbuf); |
| 8915 | return 0; | 8961 | return 0; |
| 8916 | } | 8962 | } |
| 8917 | 8963 | ||
| @@ -8968,7 +9014,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 8968 | free_color_table (); | 9014 | free_color_table (); |
| 8969 | #endif /* COLOR_TABLE_SUPPORT */ | 9015 | #endif /* COLOR_TABLE_SUPPORT */ |
| 8970 | 9016 | ||
| 8971 | fn_g_object_unref (pixbuf); | 9017 | g_object_unref (pixbuf); |
| 8972 | 9018 | ||
| 8973 | img->width = width; | 9019 | img->width = width; |
| 8974 | img->height = height; | 9020 | img->height = height; |
| @@ -8983,11 +9029,11 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 8983 | return 1; | 9029 | return 1; |
| 8984 | 9030 | ||
| 8985 | rsvg_error: | 9031 | rsvg_error: |
| 8986 | fn_g_object_unref (rsvg_handle); | 9032 | g_object_unref (rsvg_handle); |
| 8987 | /* FIXME: Use error->message so the user knows what is the actual | 9033 | /* FIXME: Use error->message so the user knows what is the actual |
| 8988 | problem with the image. */ | 9034 | problem with the image. */ |
| 8989 | image_error ("Error parsing SVG image `%s'", img->spec, Qnil); | 9035 | image_error ("Error parsing SVG image `%s'", img->spec, Qnil); |
| 8990 | fn_g_error_free (err); | 9036 | g_error_free (err); |
| 8991 | return 0; | 9037 | return 0; |
| 8992 | } | 9038 | } |
| 8993 | 9039 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index d76a8fcb783..5b66050aa92 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -276,7 +276,7 @@ bool input_pending; | |||
| 276 | /* True if more input was available last time we read an event. | 276 | /* True if more input was available last time we read an event. |
| 277 | 277 | ||
| 278 | Since redisplay can take a significant amount of time and is not | 278 | Since redisplay can take a significant amount of time and is not |
| 279 | indispensible to perform the user's commands, when input arrives | 279 | indispensable to perform the user's commands, when input arrives |
| 280 | "too fast", Emacs skips redisplay. More specifically, if the next | 280 | "too fast", Emacs skips redisplay. More specifically, if the next |
| 281 | command has already been input when we finish the previous command, | 281 | command has already been input when we finish the previous command, |
| 282 | we skip the intermediate redisplay. | 282 | we skip the intermediate redisplay. |
diff --git a/src/nsimage.m b/src/nsimage.m index 640dfcbc113..d5c06477f8b 100644 --- a/src/nsimage.m +++ b/src/nsimage.m | |||
| @@ -351,15 +351,15 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) | |||
| 351 | { | 351 | { |
| 352 | if ([rep respondsToSelector: @selector (getBitmapDataPlanes:)]) | 352 | if ([rep respondsToSelector: @selector (getBitmapDataPlanes:)]) |
| 353 | { | 353 | { |
| 354 | NSBitmapImageRep *bmRep = (NSBitmapImageRep *) rep; | 354 | NSBitmapImageRep *bmr = (NSBitmapImageRep *) rep; |
| 355 | 355 | ||
| 356 | if ([bmRep numberOfPlanes] >= 3) | 356 | if ([bmr numberOfPlanes] >= 3) |
| 357 | [bmRep getBitmapDataPlanes: pixmapData]; | 357 | [bmr getBitmapDataPlanes: pixmapData]; |
| 358 | 358 | ||
| 359 | /* The next two lines cause the DPI of the image to be ignored. | 359 | /* The next two lines cause the DPI of the image to be ignored. |
| 360 | This seems to be the behavior users expect. */ | 360 | This seems to be the behavior users expect. */ |
| 361 | [self setScalesWhenResized: YES]; | 361 | [self setScalesWhenResized: YES]; |
| 362 | [self setSize: NSMakeSize([bmRep pixelsWide], [bmRep pixelsHigh])]; | 362 | [self setSize: NSMakeSize([bmr pixelsWide], [bmr pixelsHigh])]; |
| 363 | 363 | ||
| 364 | break; | 364 | break; |
| 365 | } | 365 | } |
diff --git a/src/tparam.c b/src/tparam.c index e02cea3689e..b0cd0047ba2 100644 --- a/src/tparam.c +++ b/src/tparam.c | |||
| @@ -255,9 +255,9 @@ tparam1 (const char *string, char *outstring, int len, | |||
| 255 | } | 255 | } |
| 256 | *op = 0; | 256 | *op = 0; |
| 257 | while (doup-- > 0) | 257 | while (doup-- > 0) |
| 258 | strcat (op, up); | 258 | op = stpcpy (op, up); |
| 259 | while (doleft-- > 0) | 259 | while (doleft-- > 0) |
| 260 | strcat (op, left); | 260 | op = stpcpy (op, left); |
| 261 | return outstring; | 261 | return outstring; |
| 262 | } | 262 | } |
| 263 | 263 | ||
| @@ -3405,10 +3405,10 @@ sys_readdir (DIR *dirp) | |||
| 3405 | int ln; | 3405 | int ln; |
| 3406 | 3406 | ||
| 3407 | strcpy (filename, dir_pathname); | 3407 | strcpy (filename, dir_pathname); |
| 3408 | ln = strlen (filename) - 1; | 3408 | ln = strlen (filename); |
| 3409 | if (!IS_DIRECTORY_SEP (filename[ln])) | 3409 | if (!IS_DIRECTORY_SEP (filename[ln - 1])) |
| 3410 | strcat (filename, "\\"); | 3410 | filename[ln++] = '\\'; |
| 3411 | strcat (filename, "*"); | 3411 | strcpy (filename + ln, "*"); |
| 3412 | 3412 | ||
| 3413 | /* Note: No need to resolve symlinks in FILENAME, because | 3413 | /* Note: No need to resolve symlinks in FILENAME, because |
| 3414 | FindFirst opens the directory that is the target of a | 3414 | FindFirst opens the directory that is the target of a |
| @@ -4969,7 +4969,7 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks) | |||
| 4969 | { | 4969 | { |
| 4970 | /* Make sure root directories end in a slash. */ | 4970 | /* Make sure root directories end in a slash. */ |
| 4971 | if (!IS_DIRECTORY_SEP (name[len-1])) | 4971 | if (!IS_DIRECTORY_SEP (name[len-1])) |
| 4972 | strcat (name, "\\"); | 4972 | strcpy (name + len, "\\"); |
| 4973 | if (GetDriveType (name) < 2) | 4973 | if (GetDriveType (name) < 2) |
| 4974 | { | 4974 | { |
| 4975 | errno = ENOENT; | 4975 | errno = ENOENT; |
| @@ -5438,8 +5438,7 @@ symlink (char const *filename, char const *linkname) | |||
| 5438 | p--; | 5438 | p--; |
| 5439 | if (p > linkfn) | 5439 | if (p > linkfn) |
| 5440 | strncpy (tem, linkfn, p - linkfn); | 5440 | strncpy (tem, linkfn, p - linkfn); |
| 5441 | tem[p - linkfn] = '\0'; | 5441 | strcpy (tem + (p - linkfn), filename); |
| 5442 | strcat (tem, filename); | ||
| 5443 | dir_access = faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS); | 5442 | dir_access = faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS); |
| 5444 | } | 5443 | } |
| 5445 | else | 5444 | else |
| @@ -225,4 +225,17 @@ extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p, | |||
| 225 | const void* buf, size_t sz); | 225 | const void* buf, size_t sz); |
| 226 | #endif /* HAVE_GNUTLS */ | 226 | #endif /* HAVE_GNUTLS */ |
| 227 | 227 | ||
| 228 | /* Definine a function that will be loaded from a DLL. */ | ||
| 229 | #define DEF_DLL_FN(type, func, args) static type (FAR CDECL *fn_##func) args | ||
| 230 | |||
| 231 | /* Load a function from the DLL. */ | ||
| 232 | #define LOAD_DLL_FN(lib, func) \ | ||
| 233 | do \ | ||
| 234 | { \ | ||
| 235 | fn_##func = (void *) GetProcAddress (lib, #func); \ | ||
| 236 | if (!fn_##func) \ | ||
| 237 | return false; \ | ||
| 238 | } \ | ||
| 239 | while (false) | ||
| 240 | |||
| 228 | #endif /* EMACS_W32_H */ | 241 | #endif /* EMACS_W32_H */ |
diff --git a/src/w32menu.c b/src/w32menu.c index 6633ffddbcf..287062c702c 100644 --- a/src/w32menu.c +++ b/src/w32menu.c | |||
| @@ -1256,9 +1256,9 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 1256 | if (wv->key != NULL) | 1256 | if (wv->key != NULL) |
| 1257 | { | 1257 | { |
| 1258 | out_string = SAFE_ALLOCA (strlen (wv->name) + strlen (wv->key) + 2); | 1258 | out_string = SAFE_ALLOCA (strlen (wv->name) + strlen (wv->key) + 2); |
| 1259 | strcpy (out_string, wv->name); | 1259 | p = stpcpy (out_string, wv->name); |
| 1260 | strcat (out_string, "\t"); | 1260 | p = stpcpy (p, "\t"); |
| 1261 | strcat (out_string, wv->key); | 1261 | strcpy (p, wv->key); |
| 1262 | } | 1262 | } |
| 1263 | else | 1263 | else |
| 1264 | out_string = (char *)wv->name; | 1264 | out_string = (char *)wv->name; |
diff --git a/src/w32proc.c b/src/w32proc.c index 09e0c0530a4..c571726d70f 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -1665,10 +1665,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) | |||
| 1665 | if (egetenv ("CMDPROXY")) | 1665 | if (egetenv ("CMDPROXY")) |
| 1666 | strcpy (cmdname, egetenv ("CMDPROXY")); | 1666 | strcpy (cmdname, egetenv ("CMDPROXY")); |
| 1667 | else | 1667 | else |
| 1668 | { | 1668 | strcpy (lispstpcpy (cmdname, Vinvocation_directory), "cmdproxy.exe"); |
| 1669 | lispstpcpy (cmdname, Vinvocation_directory); | ||
| 1670 | strcat (cmdname, "cmdproxy.exe"); | ||
| 1671 | } | ||
| 1672 | 1669 | ||
| 1673 | /* Can't use unixtodos_filename here, since that needs its file | 1670 | /* Can't use unixtodos_filename here, since that needs its file |
| 1674 | name argument encoded in UTF-8. */ | 1671 | name argument encoded in UTF-8. */ |
| @@ -3183,18 +3180,20 @@ get_lcid_callback (LPTSTR locale_num_str) | |||
| 3183 | if (GetLocaleInfo (try_lcid, LOCALE_SABBREVLANGNAME, | 3180 | if (GetLocaleInfo (try_lcid, LOCALE_SABBREVLANGNAME, |
| 3184 | locval, LOCALE_NAME_MAX_LENGTH)) | 3181 | locval, LOCALE_NAME_MAX_LENGTH)) |
| 3185 | { | 3182 | { |
| 3183 | size_t locval_len; | ||
| 3184 | |||
| 3186 | /* This is for when they only specify the language, as in "ENU". */ | 3185 | /* This is for when they only specify the language, as in "ENU". */ |
| 3187 | if (stricmp (locval, lname) == 0) | 3186 | if (stricmp (locval, lname) == 0) |
| 3188 | { | 3187 | { |
| 3189 | found_lcid = try_lcid; | 3188 | found_lcid = try_lcid; |
| 3190 | return FALSE; | 3189 | return FALSE; |
| 3191 | } | 3190 | } |
| 3192 | strcat (locval, "_"); | 3191 | locval_len = strlen (locval); |
| 3192 | strcpy (locval + locval_len, "_"); | ||
| 3193 | if (GetLocaleInfo (try_lcid, LOCALE_SABBREVCTRYNAME, | 3193 | if (GetLocaleInfo (try_lcid, LOCALE_SABBREVCTRYNAME, |
| 3194 | locval + strlen (locval), LOCALE_NAME_MAX_LENGTH)) | 3194 | locval + locval_len + 1, LOCALE_NAME_MAX_LENGTH)) |
| 3195 | { | 3195 | { |
| 3196 | size_t locval_len = strlen (locval); | 3196 | locval_len = strlen (locval); |
| 3197 | |||
| 3198 | if (strnicmp (locval, lname, locval_len) == 0 | 3197 | if (strnicmp (locval, lname, locval_len) == 0 |
| 3199 | && (lname[locval_len] == '.' | 3198 | && (lname[locval_len] == '.' |
| 3200 | || lname[locval_len] == '\0')) | 3199 | || lname[locval_len] == '\0')) |
diff --git a/src/xdisp.c b/src/xdisp.c index 0e3e1a2bb69..e6bbd859fe7 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -7332,27 +7332,15 @@ set_iterator_to_next (struct it *it, int reseat_p) | |||
| 7332 | else if (it->cmp_it.id >= 0) | 7332 | else if (it->cmp_it.id >= 0) |
| 7333 | { | 7333 | { |
| 7334 | /* We are currently getting glyphs from a composition. */ | 7334 | /* We are currently getting glyphs from a composition. */ |
| 7335 | int i; | ||
| 7336 | |||
| 7337 | if (! it->bidi_p) | 7335 | if (! it->bidi_p) |
| 7338 | { | 7336 | { |
| 7339 | IT_CHARPOS (*it) += it->cmp_it.nchars; | 7337 | IT_CHARPOS (*it) += it->cmp_it.nchars; |
| 7340 | IT_BYTEPOS (*it) += it->cmp_it.nbytes; | 7338 | IT_BYTEPOS (*it) += it->cmp_it.nbytes; |
| 7341 | if (it->cmp_it.to < it->cmp_it.nglyphs) | ||
| 7342 | { | ||
| 7343 | it->cmp_it.from = it->cmp_it.to; | ||
| 7344 | } | ||
| 7345 | else | ||
| 7346 | { | ||
| 7347 | it->cmp_it.id = -1; | ||
| 7348 | composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), | ||
| 7349 | IT_BYTEPOS (*it), | ||
| 7350 | it->end_charpos, Qnil); | ||
| 7351 | } | ||
| 7352 | } | 7339 | } |
| 7353 | else if (! it->cmp_it.reversed_p) | 7340 | else |
| 7354 | { | 7341 | { |
| 7355 | /* Composition created while scanning forward. */ | 7342 | int i; |
| 7343 | |||
| 7356 | /* Update IT's char/byte positions to point to the first | 7344 | /* Update IT's char/byte positions to point to the first |
| 7357 | character of the next grapheme cluster, or to the | 7345 | character of the next grapheme cluster, or to the |
| 7358 | character visually after the current composition. */ | 7346 | character visually after the current composition. */ |
| @@ -7360,52 +7348,34 @@ set_iterator_to_next (struct it *it, int reseat_p) | |||
| 7360 | bidi_move_to_visually_next (&it->bidi_it); | 7348 | bidi_move_to_visually_next (&it->bidi_it); |
| 7361 | IT_BYTEPOS (*it) = it->bidi_it.bytepos; | 7349 | IT_BYTEPOS (*it) = it->bidi_it.bytepos; |
| 7362 | IT_CHARPOS (*it) = it->bidi_it.charpos; | 7350 | IT_CHARPOS (*it) = it->bidi_it.charpos; |
| 7351 | } | ||
| 7363 | 7352 | ||
| 7364 | if (it->cmp_it.to < it->cmp_it.nglyphs) | 7353 | if ((! it->bidi_p || ! it->cmp_it.reversed_p) |
| 7365 | { | 7354 | && it->cmp_it.to < it->cmp_it.nglyphs) |
| 7366 | /* Proceed to the next grapheme cluster. */ | 7355 | { |
| 7367 | it->cmp_it.from = it->cmp_it.to; | 7356 | /* Composition created while scanning forward. Proceed |
| 7368 | } | 7357 | to the next grapheme cluster. */ |
| 7369 | else | 7358 | it->cmp_it.from = it->cmp_it.to; |
| 7370 | { | 7359 | } |
| 7371 | /* No more grapheme clusters in this composition. | 7360 | else if ((it->bidi_p && it->cmp_it.reversed_p) |
| 7372 | Find the next stop position. */ | 7361 | && it->cmp_it.from > 0) |
| 7373 | ptrdiff_t stop = it->end_charpos; | 7362 | { |
| 7374 | if (it->bidi_it.scan_dir < 0) | 7363 | /* Composition created while scanning backward. Proceed |
| 7375 | /* Now we are scanning backward and don't know | 7364 | to the previous grapheme cluster. */ |
| 7376 | where to stop. */ | 7365 | it->cmp_it.to = it->cmp_it.from; |
| 7377 | stop = -1; | ||
| 7378 | composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), | ||
| 7379 | IT_BYTEPOS (*it), stop, Qnil); | ||
| 7380 | } | ||
| 7381 | } | 7366 | } |
| 7382 | else | 7367 | else |
| 7383 | { | 7368 | { |
| 7384 | /* Composition created while scanning backward. */ | 7369 | /* No more grapheme clusters in this composition. |
| 7385 | /* Update IT's char/byte positions to point to the last | 7370 | Find the next stop position. */ |
| 7386 | character of the previous grapheme cluster, or the | 7371 | ptrdiff_t stop = it->end_charpos; |
| 7387 | character visually after the current composition. */ | 7372 | |
| 7388 | for (i = 0; i < it->cmp_it.nchars; i++) | 7373 | if (it->bidi_it.scan_dir < 0) |
| 7389 | bidi_move_to_visually_next (&it->bidi_it); | 7374 | /* Now we are scanning backward and don't know |
| 7390 | IT_BYTEPOS (*it) = it->bidi_it.bytepos; | 7375 | where to stop. */ |
| 7391 | IT_CHARPOS (*it) = it->bidi_it.charpos; | 7376 | stop = -1; |
| 7392 | if (it->cmp_it.from > 0) | 7377 | composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), |
| 7393 | { | 7378 | IT_BYTEPOS (*it), stop, Qnil); |
| 7394 | /* Proceed to the previous grapheme cluster. */ | ||
| 7395 | it->cmp_it.to = it->cmp_it.from; | ||
| 7396 | } | ||
| 7397 | else | ||
| 7398 | { | ||
| 7399 | /* No more grapheme clusters in this composition. | ||
| 7400 | Find the next stop position. */ | ||
| 7401 | ptrdiff_t stop = it->end_charpos; | ||
| 7402 | if (it->bidi_it.scan_dir < 0) | ||
| 7403 | /* Now we are scanning backward and don't know | ||
| 7404 | where to stop. */ | ||
| 7405 | stop = -1; | ||
| 7406 | composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), | ||
| 7407 | IT_BYTEPOS (*it), stop, Qnil); | ||
| 7408 | } | ||
| 7409 | } | 7379 | } |
| 7410 | } | 7380 | } |
| 7411 | else | 7381 | else |
| @@ -7534,61 +7504,63 @@ set_iterator_to_next (struct it *it, int reseat_p) | |||
| 7534 | } | 7504 | } |
| 7535 | if (it->cmp_it.id >= 0) | 7505 | if (it->cmp_it.id >= 0) |
| 7536 | { | 7506 | { |
| 7537 | int i; | 7507 | /* We are delivering display elements from a composition. |
| 7538 | 7508 | Update the string position past the grapheme cluster | |
| 7509 | we've just processed. */ | ||
| 7539 | if (! it->bidi_p) | 7510 | if (! it->bidi_p) |
| 7540 | { | 7511 | { |
| 7541 | IT_STRING_CHARPOS (*it) += it->cmp_it.nchars; | 7512 | IT_STRING_CHARPOS (*it) += it->cmp_it.nchars; |
| 7542 | IT_STRING_BYTEPOS (*it) += it->cmp_it.nbytes; | 7513 | IT_STRING_BYTEPOS (*it) += it->cmp_it.nbytes; |
| 7543 | if (it->cmp_it.to < it->cmp_it.nglyphs) | ||
| 7544 | it->cmp_it.from = it->cmp_it.to; | ||
| 7545 | else | ||
| 7546 | { | ||
| 7547 | it->cmp_it.id = -1; | ||
| 7548 | composition_compute_stop_pos (&it->cmp_it, | ||
| 7549 | IT_STRING_CHARPOS (*it), | ||
| 7550 | IT_STRING_BYTEPOS (*it), | ||
| 7551 | it->end_charpos, it->string); | ||
| 7552 | } | ||
| 7553 | } | 7514 | } |
| 7554 | else if (! it->cmp_it.reversed_p) | 7515 | else |
| 7555 | { | 7516 | { |
| 7517 | int i; | ||
| 7518 | |||
| 7556 | for (i = 0; i < it->cmp_it.nchars; i++) | 7519 | for (i = 0; i < it->cmp_it.nchars; i++) |
| 7557 | bidi_move_to_visually_next (&it->bidi_it); | 7520 | bidi_move_to_visually_next (&it->bidi_it); |
| 7558 | IT_STRING_BYTEPOS (*it) = it->bidi_it.bytepos; | 7521 | IT_STRING_BYTEPOS (*it) = it->bidi_it.bytepos; |
| 7559 | IT_STRING_CHARPOS (*it) = it->bidi_it.charpos; | 7522 | IT_STRING_CHARPOS (*it) = it->bidi_it.charpos; |
| 7523 | } | ||
| 7560 | 7524 | ||
| 7561 | if (it->cmp_it.to < it->cmp_it.nglyphs) | 7525 | /* Did we exhaust all the grapheme clusters of this |
| 7562 | it->cmp_it.from = it->cmp_it.to; | 7526 | composition? */ |
| 7563 | else | 7527 | if ((! it->bidi_p || ! it->cmp_it.reversed_p) |
| 7564 | { | 7528 | && (it->cmp_it.to < it->cmp_it.nglyphs)) |
| 7565 | ptrdiff_t stop = it->end_charpos; | 7529 | { |
| 7566 | if (it->bidi_it.scan_dir < 0) | 7530 | /* Not all the grapheme clusters were processed yet; |
| 7567 | stop = -1; | 7531 | advance to the next cluster. */ |
| 7568 | composition_compute_stop_pos (&it->cmp_it, | 7532 | it->cmp_it.from = it->cmp_it.to; |
| 7569 | IT_STRING_CHARPOS (*it), | 7533 | } |
| 7570 | IT_STRING_BYTEPOS (*it), stop, | 7534 | else if ((it->bidi_p && it->cmp_it.reversed_p) |
| 7571 | it->string); | 7535 | && it->cmp_it.from > 0) |
| 7572 | } | 7536 | { |
| 7537 | /* Likewise: advance to the next cluster, but going in | ||
| 7538 | the reverse direction. */ | ||
| 7539 | it->cmp_it.to = it->cmp_it.from; | ||
| 7573 | } | 7540 | } |
| 7574 | else | 7541 | else |
| 7575 | { | 7542 | { |
| 7576 | for (i = 0; i < it->cmp_it.nchars; i++) | 7543 | /* This composition was fully processed; find the next |
| 7577 | bidi_move_to_visually_next (&it->bidi_it); | 7544 | candidate place for checking for composed |
| 7578 | IT_STRING_BYTEPOS (*it) = it->bidi_it.bytepos; | 7545 | characters. */ |
| 7579 | IT_STRING_CHARPOS (*it) = it->bidi_it.charpos; | 7546 | /* Always limit string searches to the string length; |
| 7580 | if (it->cmp_it.from > 0) | 7547 | any padding spaces are not part of the string, and |
| 7581 | it->cmp_it.to = it->cmp_it.from; | 7548 | there cannot be any compositions in that padding. */ |
| 7582 | else | 7549 | ptrdiff_t stop = SCHARS (it->string); |
| 7550 | |||
| 7551 | if (it->bidi_p && it->bidi_it.scan_dir < 0) | ||
| 7552 | stop = -1; | ||
| 7553 | else if (it->end_charpos < stop) | ||
| 7583 | { | 7554 | { |
| 7584 | ptrdiff_t stop = it->end_charpos; | 7555 | /* Cf. PRECISION in reseat_to_string: we might be |
| 7585 | if (it->bidi_it.scan_dir < 0) | 7556 | limited in how many of the string characters we |
| 7586 | stop = -1; | 7557 | need to deliver. */ |
| 7587 | composition_compute_stop_pos (&it->cmp_it, | 7558 | stop = it->end_charpos; |
| 7588 | IT_STRING_CHARPOS (*it), | ||
| 7589 | IT_STRING_BYTEPOS (*it), stop, | ||
| 7590 | it->string); | ||
| 7591 | } | 7559 | } |
| 7560 | composition_compute_stop_pos (&it->cmp_it, | ||
| 7561 | IT_STRING_CHARPOS (*it), | ||
| 7562 | IT_STRING_BYTEPOS (*it), stop, | ||
| 7563 | it->string); | ||
| 7592 | } | 7564 | } |
| 7593 | } | 7565 | } |
| 7594 | else | 7566 | else |
| @@ -7611,12 +7583,17 @@ set_iterator_to_next (struct it *it, int reseat_p) | |||
| 7611 | bidi_move_to_visually_next (&it->bidi_it); | 7583 | bidi_move_to_visually_next (&it->bidi_it); |
| 7612 | IT_STRING_BYTEPOS (*it) = it->bidi_it.bytepos; | 7584 | IT_STRING_BYTEPOS (*it) = it->bidi_it.bytepos; |
| 7613 | IT_STRING_CHARPOS (*it) = it->bidi_it.charpos; | 7585 | IT_STRING_CHARPOS (*it) = it->bidi_it.charpos; |
| 7586 | /* If the scan direction changes, we may need to update | ||
| 7587 | the place where to check for composed characters. */ | ||
| 7614 | if (prev_scan_dir != it->bidi_it.scan_dir) | 7588 | if (prev_scan_dir != it->bidi_it.scan_dir) |
| 7615 | { | 7589 | { |
| 7616 | ptrdiff_t stop = it->end_charpos; | 7590 | ptrdiff_t stop = SCHARS (it->string); |
| 7617 | 7591 | ||
| 7618 | if (it->bidi_it.scan_dir < 0) | 7592 | if (it->bidi_it.scan_dir < 0) |
| 7619 | stop = -1; | 7593 | stop = -1; |
| 7594 | else if (it->end_charpos < stop) | ||
| 7595 | stop = it->end_charpos; | ||
| 7596 | |||
| 7620 | composition_compute_stop_pos (&it->cmp_it, | 7597 | composition_compute_stop_pos (&it->cmp_it, |
| 7621 | IT_STRING_CHARPOS (*it), | 7598 | IT_STRING_CHARPOS (*it), |
| 7622 | IT_STRING_BYTEPOS (*it), stop, | 7599 | IT_STRING_BYTEPOS (*it), stop, |
diff --git a/src/xfns.c b/src/xfns.c index 1b17311f99c..ba2601daca4 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -1710,13 +1710,14 @@ xic_create_fontsetname (const char *base_fontname, int motif) | |||
| 1710 | { | 1710 | { |
| 1711 | const char *sep = motif ? ";" : ","; | 1711 | const char *sep = motif ? ";" : ","; |
| 1712 | char *fontsetname; | 1712 | char *fontsetname; |
| 1713 | char *z; | ||
| 1713 | 1714 | ||
| 1714 | /* Make a fontset name from the base font name. */ | 1715 | /* Make a fontset name from the base font name. */ |
| 1715 | if (xic_default_fontset == base_fontname) | 1716 | if (xic_default_fontset == base_fontname) |
| 1716 | { | 1717 | { |
| 1717 | /* There is no base font name, use the default. */ | 1718 | /* There is no base font name, use the default. */ |
| 1718 | fontsetname = xmalloc (strlen (base_fontname) + 2); | 1719 | fontsetname = xmalloc (strlen (base_fontname) + 2); |
| 1719 | strcpy (fontsetname, base_fontname); | 1720 | z = stpcpy (fontsetname, base_fontname); |
| 1720 | } | 1721 | } |
| 1721 | else | 1722 | else |
| 1722 | { | 1723 | { |
| @@ -1737,9 +1738,9 @@ xic_create_fontsetname (const char *base_fontname, int motif) | |||
| 1737 | Use the specified font plus the default. */ | 1738 | Use the specified font plus the default. */ |
| 1738 | fontsetname = xmalloc (strlen (base_fontname) | 1739 | fontsetname = xmalloc (strlen (base_fontname) |
| 1739 | + strlen (xic_default_fontset) + 3); | 1740 | + strlen (xic_default_fontset) + 3); |
| 1740 | strcpy (fontsetname, base_fontname); | 1741 | z = stpcpy (fontsetname, base_fontname); |
| 1741 | strcat (fontsetname, sep); | 1742 | z = stpcpy (z, sep); |
| 1742 | strcat (fontsetname, xic_default_fontset); | 1743 | z = stpcpy (z, xic_default_fontset); |
| 1743 | } | 1744 | } |
| 1744 | else | 1745 | else |
| 1745 | { | 1746 | { |
| @@ -1800,27 +1801,26 @@ xic_create_fontsetname (const char *base_fontname, int motif) | |||
| 1800 | /* Build the font spec that matches all. */ | 1801 | /* Build the font spec that matches all. */ |
| 1801 | len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; | 1802 | len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; |
| 1802 | font_all = alloca (len); | 1803 | font_all = alloca (len); |
| 1803 | strcpy (font_all, allfamilies); | 1804 | z = stpcpy (font_all, allfamilies); |
| 1804 | strcat (font_all, all); | 1805 | z = stpcpy (z, all); |
| 1805 | memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2); | 1806 | memcpy (z, p2, p - p2); |
| 1806 | strcpy (font_all + strlen (all) + strlen (allfamilies) + (p - p2), | 1807 | strcpy (z + (p - p2), allcs); |
| 1807 | allcs); | ||
| 1808 | 1808 | ||
| 1809 | /* Build the actual font set name. */ | 1809 | /* Build the actual font set name. */ |
| 1810 | len = strlen (base_fontname) + strlen (font_allcs) | 1810 | len = strlen (base_fontname) + strlen (font_allcs) |
| 1811 | + strlen (font_allfamilies) + strlen (font_all) + 5; | 1811 | + strlen (font_allfamilies) + strlen (font_all) + 5; |
| 1812 | fontsetname = xmalloc (len); | 1812 | fontsetname = xmalloc (len); |
| 1813 | strcpy (fontsetname, base_fontname); | 1813 | z = stpcpy (fontsetname, base_fontname); |
| 1814 | strcat (fontsetname, sep); | 1814 | z = stpcpy (z, sep); |
| 1815 | strcat (fontsetname, font_allcs); | 1815 | z = stpcpy (z, font_allcs); |
| 1816 | strcat (fontsetname, sep); | 1816 | z = stpcpy (z, sep); |
| 1817 | strcat (fontsetname, font_allfamilies); | 1817 | z = stpcpy (z, font_allfamilies); |
| 1818 | strcat (fontsetname, sep); | 1818 | z = stpcpy (z, sep); |
| 1819 | strcat (fontsetname, font_all); | 1819 | z = stpcpy (z, font_all); |
| 1820 | } | 1820 | } |
| 1821 | } | 1821 | } |
| 1822 | if (motif) | 1822 | if (motif) |
| 1823 | return strcat (fontsetname, ":"); | 1823 | strcpy (z, ":"); |
| 1824 | return fontsetname; | 1824 | return fontsetname; |
| 1825 | } | 1825 | } |
| 1826 | #endif /* HAVE_X_WINDOWS && USE_X_TOOLKIT */ | 1826 | #endif /* HAVE_X_WINDOWS && USE_X_TOOLKIT */ |
| @@ -33,26 +33,17 @@ static Lisp_Object Qlibxml2_dll; | |||
| 33 | 33 | ||
| 34 | #ifdef WINDOWSNT | 34 | #ifdef WINDOWSNT |
| 35 | 35 | ||
| 36 | #include <windows.h> | 36 | # include <windows.h> |
| 37 | #include "w32.h" | 37 | # include "w32.h" |
| 38 | 38 | ||
| 39 | /* Macro for defining functions that will be loaded from the libxml2 DLL. */ | 39 | DEF_DLL_FN (htmlDocPtr, htmlReadMemory, |
| 40 | #define DEF_XML2_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args | ||
| 41 | |||
| 42 | /* Macro for loading libxml2 functions from the library. */ | ||
| 43 | #define LOAD_XML2_FN(lib,func) { \ | ||
| 44 | fn_##func = (void *) GetProcAddress (lib, #func); \ | ||
| 45 | if (!fn_##func) goto bad_library; \ | ||
| 46 | } | ||
| 47 | |||
| 48 | DEF_XML2_FN (htmlDocPtr, htmlReadMemory, | ||
| 49 | (const char *, int, const char *, const char *, int)); | 40 | (const char *, int, const char *, const char *, int)); |
| 50 | DEF_XML2_FN (xmlDocPtr, xmlReadMemory, | 41 | DEF_DLL_FN (xmlDocPtr, xmlReadMemory, |
| 51 | (const char *, int, const char *, const char *, int)); | 42 | (const char *, int, const char *, const char *, int)); |
| 52 | DEF_XML2_FN (xmlNodePtr, xmlDocGetRootElement, (xmlDocPtr)); | 43 | DEF_DLL_FN (xmlNodePtr, xmlDocGetRootElement, (xmlDocPtr)); |
| 53 | DEF_XML2_FN (void, xmlFreeDoc, (xmlDocPtr)); | 44 | DEF_DLL_FN (void, xmlFreeDoc, (xmlDocPtr)); |
| 54 | DEF_XML2_FN (void, xmlCleanupParser, (void)); | 45 | DEF_DLL_FN (void, xmlCleanupParser, (void)); |
| 55 | DEF_XML2_FN (void, xmlCheckVersion, (int)); | 46 | DEF_DLL_FN (void, xmlCheckVersion, (int)); |
| 56 | 47 | ||
| 57 | static int | 48 | static int |
| 58 | libxml2_loaded_p (void) | 49 | libxml2_loaded_p (void) |
| @@ -64,14 +55,33 @@ libxml2_loaded_p (void) | |||
| 64 | return 0; | 55 | return 0; |
| 65 | } | 56 | } |
| 66 | 57 | ||
| 67 | #else /* !WINDOWSNT */ | 58 | # undef htmlReadMemory |
| 59 | # undef xmlCheckVersion | ||
| 60 | # undef xmlCleanupParser | ||
| 61 | # undef xmlDocGetRootElement | ||
| 62 | # undef xmlFreeDoc | ||
| 63 | # undef xmlReadMemory | ||
| 64 | |||
| 65 | # define htmlReadMemory fn_htmlReadMemory | ||
| 66 | # define xmlCheckVersion fn_xmlCheckVersion | ||
| 67 | # define xmlCleanupParser fn_xmlCleanupParser | ||
| 68 | # define xmlDocGetRootElement fn_xmlDocGetRootElement | ||
| 69 | # define xmlFreeDoc fn_xmlFreeDoc | ||
| 70 | # define xmlReadMemory fn_xmlReadMemory | ||
| 71 | |||
| 72 | static bool | ||
| 73 | load_dll_functions (HMODULE library) | ||
| 74 | { | ||
| 75 | LOAD_DLL_FN (library, htmlReadMemory); | ||
| 76 | LOAD_DLL_FN (library, xmlReadMemory); | ||
| 77 | LOAD_DLL_FN (library, xmlDocGetRootElement); | ||
| 78 | LOAD_DLL_FN (library, xmlFreeDoc); | ||
| 79 | LOAD_DLL_FN (library, xmlCleanupParser); | ||
| 80 | LOAD_DLL_FN (library, xmlCheckVersion); | ||
| 81 | return true; | ||
| 82 | } | ||
| 68 | 83 | ||
| 69 | #define fn_htmlReadMemory htmlReadMemory | 84 | #else /* !WINDOWSNT */ |
| 70 | #define fn_xmlReadMemory xmlReadMemory | ||
| 71 | #define fn_xmlDocGetRootElement xmlDocGetRootElement | ||
| 72 | #define fn_xmlFreeDoc xmlFreeDoc | ||
| 73 | #define fn_xmlCleanupParser xmlCleanupParser | ||
| 74 | #define fn_xmlCheckVersion xmlCheckVersion | ||
| 75 | 85 | ||
| 76 | static int | 86 | static int |
| 77 | libxml2_loaded_p (void) | 87 | libxml2_loaded_p (void) |
| @@ -97,14 +107,8 @@ init_libxml2_functions (void) | |||
| 97 | return 0; | 107 | return 0; |
| 98 | } | 108 | } |
| 99 | 109 | ||
| 100 | /* LOAD_XML2_FN jumps to bad_library if it fails to find the | 110 | if (! load_dll_functions (library)) |
| 101 | named function. */ | 111 | goto bad_library; |
| 102 | LOAD_XML2_FN (library, htmlReadMemory); | ||
| 103 | LOAD_XML2_FN (library, xmlReadMemory); | ||
| 104 | LOAD_XML2_FN (library, xmlDocGetRootElement); | ||
| 105 | LOAD_XML2_FN (library, xmlFreeDoc); | ||
| 106 | LOAD_XML2_FN (library, xmlCleanupParser); | ||
| 107 | LOAD_XML2_FN (library, xmlCheckVersion); | ||
| 108 | 112 | ||
| 109 | Vlibrary_cache = Fcons (Fcons (Qlibxml2_dll, Qt), Vlibrary_cache); | 113 | Vlibrary_cache = Fcons (Fcons (Qlibxml2_dll, Qt), Vlibrary_cache); |
| 110 | return 1; | 114 | return 1; |
| @@ -182,7 +186,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Obj | |||
| 182 | const char *burl = ""; | 186 | const char *burl = ""; |
| 183 | ptrdiff_t istart, iend, istart_byte, iend_byte; | 187 | ptrdiff_t istart, iend, istart_byte, iend_byte; |
| 184 | 188 | ||
| 185 | fn_xmlCheckVersion (LIBXML_VERSION); | 189 | xmlCheckVersion (LIBXML_VERSION); |
| 186 | 190 | ||
| 187 | validate_region (&start, &end); | 191 | validate_region (&start, &end); |
| 188 | 192 | ||
| @@ -201,16 +205,16 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Obj | |||
| 201 | } | 205 | } |
| 202 | 206 | ||
| 203 | if (htmlp) | 207 | if (htmlp) |
| 204 | doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), | 208 | doc = htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), |
| 205 | iend_byte - istart_byte, burl, "utf-8", | 209 | iend_byte - istart_byte, burl, "utf-8", |
| 206 | HTML_PARSE_RECOVER|HTML_PARSE_NONET| | 210 | HTML_PARSE_RECOVER|HTML_PARSE_NONET| |
| 207 | HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| | 211 | HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| |
| 208 | HTML_PARSE_NOBLANKS); | 212 | HTML_PARSE_NOBLANKS); |
| 209 | else | 213 | else |
| 210 | doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), | 214 | doc = xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), |
| 211 | iend_byte - istart_byte, burl, "utf-8", | 215 | iend_byte - istart_byte, burl, "utf-8", |
| 212 | XML_PARSE_NONET|XML_PARSE_NOWARNING| | 216 | XML_PARSE_NONET|XML_PARSE_NOWARNING| |
| 213 | XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); | 217 | XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); |
| 214 | 218 | ||
| 215 | if (doc != NULL) | 219 | if (doc != NULL) |
| 216 | { | 220 | { |
| @@ -232,14 +236,14 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Obj | |||
| 232 | if (NILP (result)) { | 236 | if (NILP (result)) { |
| 233 | /* The document doesn't have toplevel comments or we discarded | 237 | /* The document doesn't have toplevel comments or we discarded |
| 234 | them. Get the tree the proper way. */ | 238 | them. Get the tree the proper way. */ |
| 235 | xmlNode *node = fn_xmlDocGetRootElement (doc); | 239 | xmlNode *node = xmlDocGetRootElement (doc); |
| 236 | if (node != NULL) | 240 | if (node != NULL) |
| 237 | result = make_dom (node); | 241 | result = make_dom (node); |
| 238 | } else | 242 | } else |
| 239 | result = Fcons (intern ("top"), | 243 | result = Fcons (intern ("top"), |
| 240 | Fcons (Qnil, Fnreverse (Fcons (r, result)))); | 244 | Fcons (Qnil, Fnreverse (Fcons (r, result)))); |
| 241 | 245 | ||
| 242 | fn_xmlFreeDoc (doc); | 246 | xmlFreeDoc (doc); |
| 243 | } | 247 | } |
| 244 | 248 | ||
| 245 | return result; | 249 | return result; |
| @@ -249,7 +253,7 @@ void | |||
| 249 | xml_cleanup_parser (void) | 253 | xml_cleanup_parser (void) |
| 250 | { | 254 | { |
| 251 | if (libxml2_loaded_p ()) | 255 | if (libxml2_loaded_p ()) |
| 252 | fn_xmlCleanupParser (); | 256 | xmlCleanupParser (); |
| 253 | } | 257 | } |
| 254 | 258 | ||
| 255 | DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region, | 259 | DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region, |
diff --git a/src/xrdb.c b/src/xrdb.c index 32ad3c7f01e..e21206d0800 100644 --- a/src/xrdb.c +++ b/src/xrdb.c | |||
| @@ -232,9 +232,10 @@ gethomedir (void) | |||
| 232 | if (ptr == NULL) | 232 | if (ptr == NULL) |
| 233 | return xstrdup ("/"); | 233 | return xstrdup ("/"); |
| 234 | 234 | ||
| 235 | copy = xmalloc (strlen (ptr) + 2); | 235 | ptrdiff_t len = strlen (ptr); |
| 236 | strcpy (copy, ptr); | 236 | copy = xmalloc (len + 2); |
| 237 | return strcat (copy, "/"); | 237 | strcpy (copy + len, "/"); |
| 238 | return memcpy (copy, ptr, len); | ||
| 238 | } | 239 | } |
| 239 | 240 | ||
| 240 | 241 | ||
| @@ -334,6 +335,7 @@ get_user_app (const char *class) | |||
| 334 | return db; | 335 | return db; |
| 335 | } | 336 | } |
| 336 | 337 | ||
| 338 | static char const xdefaults[] = ".Xdefaults"; | ||
| 337 | 339 | ||
| 338 | static XrmDatabase | 340 | static XrmDatabase |
| 339 | get_user_db (Display *display) | 341 | get_user_db (Display *display) |
| @@ -351,16 +353,12 @@ get_user_db (Display *display) | |||
| 351 | db = XrmGetStringDatabase (xdefs); | 353 | db = XrmGetStringDatabase (xdefs); |
| 352 | else | 354 | else |
| 353 | { | 355 | { |
| 354 | char *home; | 356 | char *home = gethomedir (); |
| 355 | char *xdefault; | 357 | ptrdiff_t homelen = strlen (home); |
| 356 | 358 | char *filename = xrealloc (home, homelen + sizeof xdefaults); | |
| 357 | home = gethomedir (); | 359 | strcpy (filename + homelen, xdefaults); |
| 358 | xdefault = xmalloc (strlen (home) + sizeof ".Xdefaults"); | 360 | db = XrmGetFileDatabase (filename); |
| 359 | strcpy (xdefault, home); | 361 | xfree (filename); |
| 360 | strcat (xdefault, ".Xdefaults"); | ||
| 361 | db = XrmGetFileDatabase (xdefault); | ||
| 362 | xfree (home); | ||
| 363 | xfree (xdefault); | ||
| 364 | } | 362 | } |
| 365 | 363 | ||
| 366 | #ifdef HAVE_XSCREENRESOURCESTRING | 364 | #ifdef HAVE_XSCREENRESOURCESTRING |
| @@ -380,24 +378,22 @@ static XrmDatabase | |||
| 380 | get_environ_db (void) | 378 | get_environ_db (void) |
| 381 | { | 379 | { |
| 382 | XrmDatabase db; | 380 | XrmDatabase db; |
| 383 | char *p; | 381 | char *p = getenv ("XENVIRONMENT"); |
| 384 | char *path = 0; | 382 | char *filename = 0; |
| 385 | 383 | ||
| 386 | if ((p = getenv ("XENVIRONMENT")) == NULL) | 384 | if (!p) |
| 387 | { | 385 | { |
| 388 | static char const xdefaults[] = ".Xdefaults-"; | ||
| 389 | char *home = gethomedir (); | 386 | char *home = gethomedir (); |
| 390 | char const *host = SSDATA (Vsystem_name); | 387 | ptrdiff_t homelen = strlen (home); |
| 391 | ptrdiff_t pathsize = (strlen (home) + sizeof xdefaults | 388 | ptrdiff_t filenamesize = (homelen + sizeof xdefaults |
| 392 | + SBYTES (Vsystem_name)); | 389 | + SBYTES (Vsystem_name)); |
| 393 | path = xrealloc (home, pathsize); | 390 | p = filename = xrealloc (home, filenamesize); |
| 394 | strcat (strcat (path, xdefaults), host); | 391 | lispstpcpy (stpcpy (filename + homelen, xdefaults), Vsystem_name); |
| 395 | p = path; | ||
| 396 | } | 392 | } |
| 397 | 393 | ||
| 398 | db = XrmGetFileDatabase (p); | 394 | db = XrmGetFileDatabase (p); |
| 399 | 395 | ||
| 400 | xfree (path); | 396 | xfree (filename); |
| 401 | 397 | ||
| 402 | return db; | 398 | return db; |
| 403 | } | 399 | } |
diff --git a/src/xselect.c b/src/xselect.c index 92e89822293..3f8a1321954 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -46,9 +46,10 @@ struct prop_location; | |||
| 46 | struct selection_data; | 46 | struct selection_data; |
| 47 | 47 | ||
| 48 | static void x_decline_selection_request (struct input_event *); | 48 | static void x_decline_selection_request (struct input_event *); |
| 49 | static int x_convert_selection (struct input_event *, Lisp_Object, Lisp_Object, | 49 | static bool x_convert_selection (struct input_event *, Lisp_Object, |
| 50 | Atom, int, struct x_display_info *); | 50 | Lisp_Object, Atom, bool, |
| 51 | static int waiting_for_other_props_on_window (Display *, Window); | 51 | struct x_display_info *); |
| 52 | static bool waiting_for_other_props_on_window (Display *, Window); | ||
| 52 | static struct prop_location *expect_property_change (Display *, Window, | 53 | static struct prop_location *expect_property_change (Display *, Window, |
| 53 | Atom, int); | 54 | Atom, int); |
| 54 | static void unexpect_property_change (struct prop_location *); | 55 | static void unexpect_property_change (struct prop_location *); |
| @@ -360,7 +361,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value, | |||
| 360 | 361 | ||
| 361 | static Lisp_Object | 362 | static Lisp_Object |
| 362 | x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, | 363 | x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, |
| 363 | int local_request, struct x_display_info *dpyinfo) | 364 | bool local_request, struct x_display_info *dpyinfo) |
| 364 | { | 365 | { |
| 365 | Lisp_Object local_value; | 366 | Lisp_Object local_value; |
| 366 | Lisp_Object handler_fn, value, check; | 367 | Lisp_Object handler_fn, value, check; |
| @@ -470,7 +471,7 @@ struct selection_data | |||
| 470 | ptrdiff_t size; | 471 | ptrdiff_t size; |
| 471 | int format; | 472 | int format; |
| 472 | Atom type; | 473 | Atom type; |
| 473 | int nofree; | 474 | bool nofree; |
| 474 | Atom property; | 475 | Atom property; |
| 475 | /* This can be set to non-NULL during x_reply_selection_request, if | 476 | /* This can be set to non-NULL during x_reply_selection_request, if |
| 476 | the selection is waiting for an INCR transfer to complete. Don't | 477 | the selection is waiting for an INCR transfer to complete. Don't |
| @@ -498,7 +499,7 @@ x_selection_request_lisp_error (void) | |||
| 498 | for (cs = converted_selections; cs; cs = next) | 499 | for (cs = converted_selections; cs; cs = next) |
| 499 | { | 500 | { |
| 500 | next = cs->next; | 501 | next = cs->next; |
| 501 | if (cs->nofree == 0 && cs->data) | 502 | if (! cs->nofree && cs->data) |
| 502 | xfree (cs->data); | 503 | xfree (cs->data); |
| 503 | xfree (cs); | 504 | xfree (cs); |
| 504 | } | 505 | } |
| @@ -531,7 +532,7 @@ struct prop_location | |||
| 531 | Window window; | 532 | Window window; |
| 532 | Atom property; | 533 | Atom property; |
| 533 | int desired_state; | 534 | int desired_state; |
| 534 | int arrived; | 535 | bool arrived; |
| 535 | struct prop_location *next; | 536 | struct prop_location *next; |
| 536 | }; | 537 | }; |
| 537 | 538 | ||
| @@ -747,7 +748,7 @@ x_handle_selection_request (struct input_event *event) | |||
| 747 | Lisp_Object target_symbol = x_atom_to_symbol (dpyinfo, target); | 748 | Lisp_Object target_symbol = x_atom_to_symbol (dpyinfo, target); |
| 748 | Atom property = SELECTION_EVENT_PROPERTY (event); | 749 | Atom property = SELECTION_EVENT_PROPERTY (event); |
| 749 | Lisp_Object local_selection_data; | 750 | Lisp_Object local_selection_data; |
| 750 | int success = 0; | 751 | bool success = false; |
| 751 | ptrdiff_t count = SPECPDL_INDEX (); | 752 | ptrdiff_t count = SPECPDL_INDEX (); |
| 752 | GCPRO2 (local_selection_data, target_symbol); | 753 | GCPRO2 (local_selection_data, target_symbol); |
| 753 | 754 | ||
| @@ -805,9 +806,9 @@ x_handle_selection_request (struct input_event *event) | |||
| 805 | 806 | ||
| 806 | if (subproperty != None) | 807 | if (subproperty != None) |
| 807 | x_convert_selection (event, selection_symbol, subtarget, | 808 | x_convert_selection (event, selection_symbol, subtarget, |
| 808 | subproperty, 1, dpyinfo); | 809 | subproperty, true, dpyinfo); |
| 809 | } | 810 | } |
| 810 | success = 1; | 811 | success = true; |
| 811 | } | 812 | } |
| 812 | else | 813 | else |
| 813 | { | 814 | { |
| @@ -815,7 +816,7 @@ x_handle_selection_request (struct input_event *event) | |||
| 815 | property = SELECTION_EVENT_TARGET (event); | 816 | property = SELECTION_EVENT_TARGET (event); |
| 816 | success = x_convert_selection (event, selection_symbol, | 817 | success = x_convert_selection (event, selection_symbol, |
| 817 | target_symbol, property, | 818 | target_symbol, property, |
| 818 | 0, dpyinfo); | 819 | false, dpyinfo); |
| 819 | } | 820 | } |
| 820 | 821 | ||
| 821 | DONE: | 822 | DONE: |
| @@ -844,15 +845,15 @@ x_handle_selection_request (struct input_event *event) | |||
| 844 | 845 | ||
| 845 | /* Perform the requested selection conversion, and write the data to | 846 | /* Perform the requested selection conversion, and write the data to |
| 846 | the converted_selections linked list, where it can be accessed by | 847 | the converted_selections linked list, where it can be accessed by |
| 847 | x_reply_selection_request. If FOR_MULTIPLE is non-zero, write out | 848 | x_reply_selection_request. If FOR_MULTIPLE, write out |
| 848 | the data even if conversion fails, using conversion_fail_tag. | 849 | the data even if conversion fails, using conversion_fail_tag. |
| 849 | 850 | ||
| 850 | Return 0 if the selection failed to convert, 1 otherwise. */ | 851 | Return true iff successful. */ |
| 851 | 852 | ||
| 852 | static int | 853 | static bool |
| 853 | x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, | 854 | x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, |
| 854 | Lisp_Object target_symbol, Atom property, | 855 | Lisp_Object target_symbol, Atom property, |
| 855 | int for_multiple, struct x_display_info *dpyinfo) | 856 | bool for_multiple, struct x_display_info *dpyinfo) |
| 856 | { | 857 | { |
| 857 | struct gcpro gcpro1; | 858 | struct gcpro gcpro1; |
| 858 | Lisp_Object lisp_selection; | 859 | Lisp_Object lisp_selection; |
| @@ -861,7 +862,7 @@ x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, | |||
| 861 | 862 | ||
| 862 | lisp_selection | 863 | lisp_selection |
| 863 | = x_get_local_selection (selection_symbol, target_symbol, | 864 | = x_get_local_selection (selection_symbol, target_symbol, |
| 864 | 0, dpyinfo); | 865 | false, dpyinfo); |
| 865 | 866 | ||
| 866 | /* A nil return value means we can't perform the conversion. */ | 867 | /* A nil return value means we can't perform the conversion. */ |
| 867 | if (NILP (lisp_selection) | 868 | if (NILP (lisp_selection) |
| @@ -874,7 +875,7 @@ x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, | |||
| 874 | cs->size = 1; | 875 | cs->size = 1; |
| 875 | cs->format = 32; | 876 | cs->format = 32; |
| 876 | cs->type = XA_ATOM; | 877 | cs->type = XA_ATOM; |
| 877 | cs->nofree = 1; | 878 | cs->nofree = true; |
| 878 | cs->property = property; | 879 | cs->property = property; |
| 879 | cs->wait_object = NULL; | 880 | cs->wait_object = NULL; |
| 880 | cs->next = converted_selections; | 881 | cs->next = converted_selections; |
| @@ -882,20 +883,20 @@ x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, | |||
| 882 | } | 883 | } |
| 883 | 884 | ||
| 884 | UNGCPRO; | 885 | UNGCPRO; |
| 885 | return 0; | 886 | return false; |
| 886 | } | 887 | } |
| 887 | 888 | ||
| 888 | /* Otherwise, record the converted selection to binary. */ | 889 | /* Otherwise, record the converted selection to binary. */ |
| 889 | cs = xmalloc (sizeof *cs); | 890 | cs = xmalloc (sizeof *cs); |
| 890 | cs->data = NULL; | 891 | cs->data = NULL; |
| 891 | cs->nofree = 1; | 892 | cs->nofree = true; |
| 892 | cs->property = property; | 893 | cs->property = property; |
| 893 | cs->wait_object = NULL; | 894 | cs->wait_object = NULL; |
| 894 | cs->next = converted_selections; | 895 | cs->next = converted_selections; |
| 895 | converted_selections = cs; | 896 | converted_selections = cs; |
| 896 | lisp_data_to_selection_data (dpyinfo, lisp_selection, cs); | 897 | lisp_data_to_selection_data (dpyinfo, lisp_selection, cs); |
| 897 | UNGCPRO; | 898 | UNGCPRO; |
| 898 | return 1; | 899 | return true; |
| 899 | } | 900 | } |
| 900 | 901 | ||
| 901 | /* Handle a SelectionClear event EVENT, which indicates that some | 902 | /* Handle a SelectionClear event EVENT, which indicates that some |
| @@ -1012,19 +1013,16 @@ x_clear_frame_selections (struct frame *f) | |||
| 1012 | } | 1013 | } |
| 1013 | } | 1014 | } |
| 1014 | 1015 | ||
| 1015 | /* Nonzero if any properties for DISPLAY and WINDOW | 1016 | /* True if any properties for DISPLAY and WINDOW |
| 1016 | are on the list of what we are waiting for. */ | 1017 | are on the list of what we are waiting for. */ |
| 1017 | 1018 | ||
| 1018 | static int | 1019 | static bool |
| 1019 | waiting_for_other_props_on_window (Display *display, Window window) | 1020 | waiting_for_other_props_on_window (Display *display, Window window) |
| 1020 | { | 1021 | { |
| 1021 | struct prop_location *rest = property_change_wait_list; | 1022 | for (struct prop_location *p = property_change_wait_list; p; p = p->next) |
| 1022 | while (rest) | 1023 | if (p->display == display && p->window == window) |
| 1023 | if (rest->display == display && rest->window == window) | 1024 | return true; |
| 1024 | return 1; | 1025 | return false; |
| 1025 | else | ||
| 1026 | rest = rest->next; | ||
| 1027 | return 0; | ||
| 1028 | } | 1026 | } |
| 1029 | 1027 | ||
| 1030 | /* Add an entry to the list of property changes we are waiting for. | 1028 | /* Add an entry to the list of property changes we are waiting for. |
| @@ -1043,7 +1041,7 @@ expect_property_change (Display *display, Window window, | |||
| 1043 | pl->property = property; | 1041 | pl->property = property; |
| 1044 | pl->desired_state = state; | 1042 | pl->desired_state = state; |
| 1045 | pl->next = property_change_wait_list; | 1043 | pl->next = property_change_wait_list; |
| 1046 | pl->arrived = 0; | 1044 | pl->arrived = false; |
| 1047 | property_change_wait_list = pl; | 1045 | property_change_wait_list = pl; |
| 1048 | return pl; | 1046 | return pl; |
| 1049 | } | 1047 | } |
| @@ -1106,7 +1104,7 @@ wait_for_property_change (struct prop_location *location) | |||
| 1106 | EMACS_INT secs = timeout / 1000; | 1104 | EMACS_INT secs = timeout / 1000; |
| 1107 | int nsecs = (timeout % 1000) * 1000000; | 1105 | int nsecs = (timeout % 1000) * 1000000; |
| 1108 | TRACE2 (" Waiting %"pI"d secs, %d nsecs", secs, nsecs); | 1106 | TRACE2 (" Waiting %"pI"d secs, %d nsecs", secs, nsecs); |
| 1109 | wait_reading_process_output (secs, nsecs, 0, 0, | 1107 | wait_reading_process_output (secs, nsecs, 0, false, |
| 1110 | property_change_reply, NULL, 0); | 1108 | property_change_reply, NULL, 0); |
| 1111 | 1109 | ||
| 1112 | if (NILP (XCAR (property_change_reply))) | 1110 | if (NILP (XCAR (property_change_reply))) |
| @@ -1138,7 +1136,7 @@ x_handle_property_notify (const XPropertyEvent *event) | |||
| 1138 | (event->state == PropertyDelete ? "deletion" : "change"), | 1136 | (event->state == PropertyDelete ? "deletion" : "change"), |
| 1139 | XGetAtomName (event->display, event->atom)); | 1137 | XGetAtomName (event->display, event->atom)); |
| 1140 | 1138 | ||
| 1141 | rest->arrived = 1; | 1139 | rest->arrived = true; |
| 1142 | 1140 | ||
| 1143 | /* If this is the one wait_for_property_change is waiting for, | 1141 | /* If this is the one wait_for_property_change is waiting for, |
| 1144 | tell it to wake up. */ | 1142 | tell it to wake up. */ |
| @@ -1204,7 +1202,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, | |||
| 1204 | during this time. In fact, the SAVE_TARGETS mechanism requires | 1202 | during this time. In fact, the SAVE_TARGETS mechanism requires |
| 1205 | us to handle a clipboard manager's requests before it returns | 1203 | us to handle a clipboard manager's requests before it returns |
| 1206 | SelectionNotify. */ | 1204 | SelectionNotify. */ |
| 1207 | #if 0 | 1205 | #if false |
| 1208 | x_start_queuing_selection_requests (); | 1206 | x_start_queuing_selection_requests (); |
| 1209 | record_unwind_protect_void (x_stop_queuing_selection_requests); | 1207 | record_unwind_protect_void (x_stop_queuing_selection_requests); |
| 1210 | #endif | 1208 | #endif |
| @@ -1216,7 +1214,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, | |||
| 1216 | secs = timeout / 1000; | 1214 | secs = timeout / 1000; |
| 1217 | nsecs = (timeout % 1000) * 1000000; | 1215 | nsecs = (timeout % 1000) * 1000000; |
| 1218 | TRACE1 (" Start waiting %"pI"d secs for SelectionNotify", secs); | 1216 | TRACE1 (" Start waiting %"pI"d secs for SelectionNotify", secs); |
| 1219 | wait_reading_process_output (secs, nsecs, 0, 0, | 1217 | wait_reading_process_output (secs, nsecs, 0, false, |
| 1220 | reading_selection_reply, NULL, 0); | 1218 | reading_selection_reply, NULL, 0); |
| 1221 | TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply))); | 1219 | TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply))); |
| 1222 | 1220 | ||
| @@ -1240,7 +1238,7 @@ static void | |||
| 1240 | x_get_window_property (Display *display, Window window, Atom property, | 1238 | x_get_window_property (Display *display, Window window, Atom property, |
| 1241 | unsigned char **data_ret, ptrdiff_t *bytes_ret, | 1239 | unsigned char **data_ret, ptrdiff_t *bytes_ret, |
| 1242 | Atom *actual_type_ret, int *actual_format_ret, | 1240 | Atom *actual_type_ret, int *actual_format_ret, |
| 1243 | unsigned long *actual_size_ret, int delete_p) | 1241 | unsigned long *actual_size_ret) |
| 1244 | { | 1242 | { |
| 1245 | ptrdiff_t total_size; | 1243 | ptrdiff_t total_size; |
| 1246 | unsigned long bytes_remaining; | 1244 | unsigned long bytes_remaining; |
| @@ -1413,7 +1411,7 @@ receive_incremental_selection (struct x_display_info *dpyinfo, | |||
| 1413 | XFlush (display); | 1411 | XFlush (display); |
| 1414 | unblock_input (); | 1412 | unblock_input (); |
| 1415 | 1413 | ||
| 1416 | while (1) | 1414 | while (true) |
| 1417 | { | 1415 | { |
| 1418 | unsigned char *tmp_data; | 1416 | unsigned char *tmp_data; |
| 1419 | ptrdiff_t tmp_size_bytes; | 1417 | ptrdiff_t tmp_size_bytes; |
| @@ -1427,7 +1425,7 @@ receive_incremental_selection (struct x_display_info *dpyinfo, | |||
| 1427 | TRACE0 (" Get property value"); | 1425 | TRACE0 (" Get property value"); |
| 1428 | x_get_window_property (display, window, property, | 1426 | x_get_window_property (display, window, property, |
| 1429 | &tmp_data, &tmp_size_bytes, | 1427 | &tmp_data, &tmp_size_bytes, |
| 1430 | type_ret, format_ret, size_ret, 1); | 1428 | type_ret, format_ret, size_ret); |
| 1431 | 1429 | ||
| 1432 | TRACE1 (" Read increment of %"pD"d bytes", tmp_size_bytes); | 1430 | TRACE1 (" Read increment of %"pD"d bytes", tmp_size_bytes); |
| 1433 | 1431 | ||
| @@ -1488,13 +1486,12 @@ x_get_window_property_as_lisp_data (struct x_display_info *dpyinfo, | |||
| 1488 | TRACE0 ("Reading selection data"); | 1486 | TRACE0 ("Reading selection data"); |
| 1489 | 1487 | ||
| 1490 | x_get_window_property (display, window, property, &data, &bytes, | 1488 | x_get_window_property (display, window, property, &data, &bytes, |
| 1491 | &actual_type, &actual_format, &actual_size, 1); | 1489 | &actual_type, &actual_format, &actual_size); |
| 1492 | if (! data) | 1490 | if (! data) |
| 1493 | { | 1491 | { |
| 1494 | int there_is_a_selection_owner; | ||
| 1495 | block_input (); | 1492 | block_input (); |
| 1496 | there_is_a_selection_owner | 1493 | bool there_is_a_selection_owner |
| 1497 | = XGetSelectionOwner (display, selection_atom); | 1494 | = XGetSelectionOwner (display, selection_atom) != 0; |
| 1498 | unblock_input (); | 1495 | unblock_input (); |
| 1499 | if (there_is_a_selection_owner) | 1496 | if (there_is_a_selection_owner) |
| 1500 | signal_error ("Selection owner couldn't convert", | 1497 | signal_error ("Selection owner couldn't convert", |
| @@ -1687,7 +1684,7 @@ lisp_data_to_selection_data (struct x_display_info *dpyinfo, | |||
| 1687 | Lisp_Object type = Qnil; | 1684 | Lisp_Object type = Qnil; |
| 1688 | 1685 | ||
| 1689 | eassert (cs != NULL); | 1686 | eassert (cs != NULL); |
| 1690 | cs->nofree = 0; | 1687 | cs->nofree = false; |
| 1691 | 1688 | ||
| 1692 | if (CONSP (obj) && SYMBOLP (XCAR (obj))) | 1689 | if (CONSP (obj) && SYMBOLP (XCAR (obj))) |
| 1693 | { | 1690 | { |
| @@ -1714,7 +1711,7 @@ lisp_data_to_selection_data (struct x_display_info *dpyinfo, | |||
| 1714 | cs->format = 8; | 1711 | cs->format = 8; |
| 1715 | cs->size = SBYTES (obj); | 1712 | cs->size = SBYTES (obj); |
| 1716 | cs->data = SDATA (obj); | 1713 | cs->data = SDATA (obj); |
| 1717 | cs->nofree = 1; | 1714 | cs->nofree = true; |
| 1718 | } | 1715 | } |
| 1719 | else if (SYMBOLP (obj)) | 1716 | else if (SYMBOLP (obj)) |
| 1720 | { | 1717 | { |
| @@ -1981,7 +1978,7 @@ On Nextstep, TIME-STAMP and TERMINAL are unused. */) | |||
| 1981 | if (!f) | 1978 | if (!f) |
| 1982 | error ("X selection unavailable for this frame"); | 1979 | error ("X selection unavailable for this frame"); |
| 1983 | 1980 | ||
| 1984 | val = x_get_local_selection (selection_symbol, target_type, 1, | 1981 | val = x_get_local_selection (selection_symbol, target_type, true, |
| 1985 | FRAME_DISPLAY_INFO (f)); | 1982 | FRAME_DISPLAY_INFO (f)); |
| 1986 | 1983 | ||
| 1987 | if (NILP (val) && FRAME_LIVE_P (f)) | 1984 | if (NILP (val) && FRAME_LIVE_P (f)) |
| @@ -2432,7 +2429,7 @@ FRAME is on. If FRAME is nil, the selected frame is used. */) | |||
| 2432 | 2429 | ||
| 2433 | /* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */ | 2430 | /* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */ |
| 2434 | 2431 | ||
| 2435 | int | 2432 | bool |
| 2436 | x_handle_dnd_message (struct frame *f, const XClientMessageEvent *event, | 2433 | x_handle_dnd_message (struct frame *f, const XClientMessageEvent *event, |
| 2437 | struct x_display_info *dpyinfo, struct input_event *bufp) | 2434 | struct x_display_info *dpyinfo, struct input_event *bufp) |
| 2438 | { | 2435 | { |
| @@ -2448,7 +2445,7 @@ x_handle_dnd_message (struct frame *f, const XClientMessageEvent *event, | |||
| 2448 | for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i) | 2445 | for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i) |
| 2449 | if (dpyinfo->x_dnd_atoms[i] == event->message_type) break; | 2446 | if (dpyinfo->x_dnd_atoms[i] == event->message_type) break; |
| 2450 | 2447 | ||
| 2451 | if (i == dpyinfo->x_dnd_atoms_length) return 0; | 2448 | if (i == dpyinfo->x_dnd_atoms_length) return false; |
| 2452 | 2449 | ||
| 2453 | XSETFRAME (frame, f); | 2450 | XSETFRAME (frame, f); |
| 2454 | 2451 | ||
| @@ -2484,7 +2481,7 @@ x_handle_dnd_message (struct frame *f, const XClientMessageEvent *event, | |||
| 2484 | bufp->arg = vec; | 2481 | bufp->arg = vec; |
| 2485 | bufp->modifiers = 0; | 2482 | bufp->modifiers = 0; |
| 2486 | 2483 | ||
| 2487 | return 1; | 2484 | return true; |
| 2488 | } | 2485 | } |
| 2489 | 2486 | ||
| 2490 | DEFUN ("x-send-client-message", Fx_send_client_message, | 2487 | DEFUN ("x-send-client-message", Fx_send_client_message, |
| @@ -2535,7 +2532,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from, | |||
| 2535 | Window wdest; | 2532 | Window wdest; |
| 2536 | XEvent event; | 2533 | XEvent event; |
| 2537 | struct frame *f = decode_window_system_frame (from); | 2534 | struct frame *f = decode_window_system_frame (from); |
| 2538 | int to_root; | 2535 | bool to_root; |
| 2539 | 2536 | ||
| 2540 | CHECK_NUMBER (format); | 2537 | CHECK_NUMBER (format); |
| 2541 | CHECK_CONS (values); | 2538 | CHECK_CONS (values); |
| @@ -2592,7 +2589,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from, | |||
| 2592 | event then goes to clients selecting for events on the root window. */ | 2589 | event then goes to clients selecting for events on the root window. */ |
| 2593 | x_catch_errors (dpyinfo->display); | 2590 | x_catch_errors (dpyinfo->display); |
| 2594 | { | 2591 | { |
| 2595 | int propagate = to_root ? False : True; | 2592 | bool propagate = !to_root; |
| 2596 | long mask = to_root ? 0xffffff : 0; | 2593 | long mask = to_root ? 0xffffff : 0; |
| 2597 | 2594 | ||
| 2598 | XSendEvent (dpyinfo->display, wdest, propagate, mask, &event); | 2595 | XSendEvent (dpyinfo->display, wdest, propagate, mask, &event); |
diff --git a/src/xsettings.c b/src/xsettings.c index 5f4275df545..066f426d241 100644 --- a/src/xsettings.c +++ b/src/xsettings.c | |||
| @@ -68,11 +68,11 @@ store_config_changed_event (Lisp_Object arg, Lisp_Object display_name) | |||
| 68 | kbd_buffer_store_event (&event); | 68 | kbd_buffer_store_event (&event); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | /* Return non-zero if DPYINFO is still valid. */ | 71 | /* Return true if DPYINFO is still valid. */ |
| 72 | static int | 72 | static bool |
| 73 | dpyinfo_valid (struct x_display_info *dpyinfo) | 73 | dpyinfo_valid (struct x_display_info *dpyinfo) |
| 74 | { | 74 | { |
| 75 | int found = 0; | 75 | bool found = false; |
| 76 | if (dpyinfo != NULL) | 76 | if (dpyinfo != NULL) |
| 77 | { | 77 | { |
| 78 | struct x_display_info *d; | 78 | struct x_display_info *d; |
| @@ -404,7 +404,7 @@ parse_settings (unsigned char *prop, | |||
| 404 | 404 | ||
| 405 | /* First 4 bytes is a serial number, skip that. */ | 405 | /* First 4 bytes is a serial number, skip that. */ |
| 406 | 406 | ||
| 407 | if (bytes < 12) return BadLength; | 407 | if (bytes < 12) return settings_seen; |
| 408 | memcpy (&n_settings, prop+8, 4); | 408 | memcpy (&n_settings, prop+8, 4); |
| 409 | if (my_bo != that_bo) n_settings = bswap_32 (n_settings); | 409 | if (my_bo != that_bo) n_settings = bswap_32 (n_settings); |
| 410 | bytes_parsed = 12; | 410 | bytes_parsed = 12; |
| @@ -419,7 +419,7 @@ parse_settings (unsigned char *prop, | |||
| 419 | CARD32 vlen, ival = 0; | 419 | CARD32 vlen, ival = 0; |
| 420 | char name[128]; /* The names we are looking for are not this long. */ | 420 | char name[128]; /* The names we are looking for are not this long. */ |
| 421 | char sval[128]; /* The values we are looking for are not this long. */ | 421 | char sval[128]; /* The values we are looking for are not this long. */ |
| 422 | int want_this; | 422 | bool want_this; |
| 423 | int to_cpy; | 423 | int to_cpy; |
| 424 | 424 | ||
| 425 | sval[0] = '\0'; | 425 | sval[0] = '\0'; |
| @@ -429,8 +429,8 @@ parse_settings (unsigned char *prop, | |||
| 429 | memcpy (&nlen, prop+bytes_parsed, 2); | 429 | memcpy (&nlen, prop+bytes_parsed, 2); |
| 430 | bytes_parsed += 2; | 430 | bytes_parsed += 2; |
| 431 | if (my_bo != that_bo) nlen = bswap_16 (nlen); | 431 | if (my_bo != that_bo) nlen = bswap_16 (nlen); |
| 432 | if (bytes_parsed+nlen > bytes) return BadLength; | 432 | if (bytes_parsed + nlen > bytes) return settings_seen; |
| 433 | to_cpy = nlen > 127 ? 127 : nlen; | 433 | to_cpy = min (nlen, sizeof name - 1); |
| 434 | memcpy (name, prop+bytes_parsed, to_cpy); | 434 | memcpy (name, prop+bytes_parsed, to_cpy); |
| 435 | name[to_cpy] = '\0'; | 435 | name[to_cpy] = '\0'; |
| 436 | 436 | ||
| @@ -438,20 +438,19 @@ parse_settings (unsigned char *prop, | |||
| 438 | bytes_parsed = PAD (bytes_parsed); | 438 | bytes_parsed = PAD (bytes_parsed); |
| 439 | 439 | ||
| 440 | bytes_parsed += 4; /* Skip serial for this value */ | 440 | bytes_parsed += 4; /* Skip serial for this value */ |
| 441 | if (bytes_parsed > bytes) return BadLength; | 441 | if (bytes_parsed > bytes) return settings_seen; |
| 442 | 442 | ||
| 443 | want_this = | 443 | want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0; |
| 444 | #ifdef HAVE_XFT | 444 | #ifdef HAVE_XFT |
| 445 | (nlen > 6 && strncmp (name, "Xft/", 4) == 0) | 445 | if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0) |
| 446 | || strcmp (XSETTINGS_FONT_NAME, name) == 0 | 446 | || strcmp (XSETTINGS_FONT_NAME, name) == 0) |
| 447 | || | 447 | want_this = true; |
| 448 | #endif | 448 | #endif |
| 449 | strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0; | ||
| 450 | 449 | ||
| 451 | switch (type) | 450 | switch (type) |
| 452 | { | 451 | { |
| 453 | case 0: /* Integer */ | 452 | case 0: /* Integer */ |
| 454 | if (bytes_parsed+4 > bytes) return BadLength; | 453 | if (bytes_parsed + 4 > bytes) return settings_seen; |
| 455 | if (want_this) | 454 | if (want_this) |
| 456 | { | 455 | { |
| 457 | memcpy (&ival, prop+bytes_parsed, 4); | 456 | memcpy (&ival, prop+bytes_parsed, 4); |
| @@ -461,13 +460,13 @@ parse_settings (unsigned char *prop, | |||
| 461 | break; | 460 | break; |
| 462 | 461 | ||
| 463 | case 1: /* String */ | 462 | case 1: /* String */ |
| 464 | if (bytes_parsed+4 > bytes) return BadLength; | 463 | if (bytes_parsed + 4 > bytes) return settings_seen; |
| 465 | memcpy (&vlen, prop+bytes_parsed, 4); | 464 | memcpy (&vlen, prop+bytes_parsed, 4); |
| 466 | bytes_parsed += 4; | 465 | bytes_parsed += 4; |
| 467 | if (my_bo != that_bo) vlen = bswap_32 (vlen); | 466 | if (my_bo != that_bo) vlen = bswap_32 (vlen); |
| 468 | if (want_this) | 467 | if (want_this) |
| 469 | { | 468 | { |
| 470 | to_cpy = vlen > 127 ? 127 : vlen; | 469 | to_cpy = min (vlen, sizeof sval - 1); |
| 471 | memcpy (sval, prop+bytes_parsed, to_cpy); | 470 | memcpy (sval, prop+bytes_parsed, to_cpy); |
| 472 | sval[to_cpy] = '\0'; | 471 | sval[to_cpy] = '\0'; |
| 473 | } | 472 | } |
| @@ -477,17 +476,16 @@ parse_settings (unsigned char *prop, | |||
| 477 | 476 | ||
| 478 | case 2: /* RGB value */ | 477 | case 2: /* RGB value */ |
| 479 | /* No need to parse this */ | 478 | /* No need to parse this */ |
| 480 | if (bytes_parsed+8 > bytes) return BadLength; | 479 | if (bytes_parsed + 8 > bytes) return settings_seen; |
| 481 | bytes_parsed += 8; /* 4 values (r, b, g, alpha), 2 bytes each. */ | 480 | bytes_parsed += 8; /* 4 values (r, b, g, alpha), 2 bytes each. */ |
| 482 | break; | 481 | break; |
| 483 | 482 | ||
| 484 | default: /* Parse Error */ | 483 | default: /* Parse Error */ |
| 485 | return BadValue; | 484 | return settings_seen; |
| 486 | } | 485 | } |
| 487 | 486 | ||
| 488 | if (want_this) | 487 | if (want_this) |
| 489 | { | 488 | { |
| 490 | ++settings_seen; | ||
| 491 | if (strcmp (name, XSETTINGS_TOOL_BAR_STYLE) == 0) | 489 | if (strcmp (name, XSETTINGS_TOOL_BAR_STYLE) == 0) |
| 492 | { | 490 | { |
| 493 | dupstring (&settings->tb_style, sval); | 491 | dupstring (&settings->tb_style, sval); |
| @@ -557,6 +555,9 @@ parse_settings (unsigned char *prop, | |||
| 557 | settings->seen &= ~SEEN_LCDFILTER; | 555 | settings->seen &= ~SEEN_LCDFILTER; |
| 558 | } | 556 | } |
| 559 | #endif /* HAVE_XFT */ | 557 | #endif /* HAVE_XFT */ |
| 558 | else | ||
| 559 | want_this = false; | ||
| 560 | settings_seen += want_this; | ||
| 560 | } | 561 | } |
| 561 | } | 562 | } |
| 562 | 563 | ||
| @@ -565,9 +566,9 @@ parse_settings (unsigned char *prop, | |||
| 565 | 566 | ||
| 566 | /* Read settings from the XSettings property window on display for DPYINFO. | 567 | /* Read settings from the XSettings property window on display for DPYINFO. |
| 567 | Store settings read in SETTINGS. | 568 | Store settings read in SETTINGS. |
| 568 | Return non-zero if successful, zero if not. */ | 569 | Return true iff successful. */ |
| 569 | 570 | ||
| 570 | static int | 571 | static bool |
| 571 | read_settings (struct x_display_info *dpyinfo, struct xsettings *settings) | 572 | read_settings (struct x_display_info *dpyinfo, struct xsettings *settings) |
| 572 | { | 573 | { |
| 573 | Atom act_type; | 574 | Atom act_type; |
| @@ -576,6 +577,7 @@ read_settings (struct x_display_info *dpyinfo, struct xsettings *settings) | |||
| 576 | unsigned char *prop = NULL; | 577 | unsigned char *prop = NULL; |
| 577 | Display *dpy = dpyinfo->display; | 578 | Display *dpy = dpyinfo->display; |
| 578 | int rc; | 579 | int rc; |
| 580 | bool got_settings = false; | ||
| 579 | 581 | ||
| 580 | x_catch_errors (dpy); | 582 | x_catch_errors (dpy); |
| 581 | rc = XGetWindowProperty (dpy, | 583 | rc = XGetWindowProperty (dpy, |
| @@ -587,27 +589,26 @@ read_settings (struct x_display_info *dpyinfo, struct xsettings *settings) | |||
| 587 | 589 | ||
| 588 | if (rc == Success && prop != NULL && act_form == 8 && nitems > 0 | 590 | if (rc == Success && prop != NULL && act_form == 8 && nitems > 0 |
| 589 | && act_type == dpyinfo->Xatom_xsettings_prop) | 591 | && act_type == dpyinfo->Xatom_xsettings_prop) |
| 590 | rc = parse_settings (prop, nitems, settings); | 592 | got_settings = parse_settings (prop, nitems, settings) != 0; |
| 591 | 593 | ||
| 592 | XFree (prop); | 594 | XFree (prop); |
| 593 | 595 | ||
| 594 | x_uncatch_errors (); | 596 | x_uncatch_errors (); |
| 595 | 597 | ||
| 596 | return rc != 0; | 598 | return got_settings; |
| 597 | } | 599 | } |
| 598 | 600 | ||
| 599 | /* Apply Xft settings in SETTINGS to the Xft library. | 601 | /* Apply Xft settings in SETTINGS to the Xft library. |
| 600 | If SEND_EVENT_P is non-zero store a Lisp event that Xft settings changed. */ | 602 | Store a Lisp event that Xft settings changed. */ |
| 601 | 603 | ||
| 602 | static void | 604 | static void |
| 603 | apply_xft_settings (struct x_display_info *dpyinfo, | 605 | apply_xft_settings (struct x_display_info *dpyinfo, |
| 604 | int send_event_p, | ||
| 605 | struct xsettings *settings) | 606 | struct xsettings *settings) |
| 606 | { | 607 | { |
| 607 | #ifdef HAVE_XFT | 608 | #ifdef HAVE_XFT |
| 608 | FcPattern *pat; | 609 | FcPattern *pat; |
| 609 | struct xsettings oldsettings; | 610 | struct xsettings oldsettings; |
| 610 | int changed = 0; | 611 | bool changed = false; |
| 611 | 612 | ||
| 612 | memset (&oldsettings, 0, sizeof (oldsettings)); | 613 | memset (&oldsettings, 0, sizeof (oldsettings)); |
| 613 | pat = FcPatternCreate (); | 614 | pat = FcPatternCreate (); |
| @@ -627,7 +628,7 @@ apply_xft_settings (struct x_display_info *dpyinfo, | |||
| 627 | { | 628 | { |
| 628 | FcPatternDel (pat, FC_ANTIALIAS); | 629 | FcPatternDel (pat, FC_ANTIALIAS); |
| 629 | FcPatternAddBool (pat, FC_ANTIALIAS, settings->aa); | 630 | FcPatternAddBool (pat, FC_ANTIALIAS, settings->aa); |
| 630 | ++changed; | 631 | changed = true; |
| 631 | oldsettings.aa = settings->aa; | 632 | oldsettings.aa = settings->aa; |
| 632 | } | 633 | } |
| 633 | 634 | ||
| @@ -636,7 +637,7 @@ apply_xft_settings (struct x_display_info *dpyinfo, | |||
| 636 | { | 637 | { |
| 637 | FcPatternDel (pat, FC_HINTING); | 638 | FcPatternDel (pat, FC_HINTING); |
| 638 | FcPatternAddBool (pat, FC_HINTING, settings->hinting); | 639 | FcPatternAddBool (pat, FC_HINTING, settings->hinting); |
| 639 | ++changed; | 640 | changed = true; |
| 640 | oldsettings.hinting = settings->hinting; | 641 | oldsettings.hinting = settings->hinting; |
| 641 | } | 642 | } |
| 642 | if ((settings->seen & SEEN_RGBA) != 0 && oldsettings.rgba != settings->rgba) | 643 | if ((settings->seen & SEEN_RGBA) != 0 && oldsettings.rgba != settings->rgba) |
| @@ -644,7 +645,7 @@ apply_xft_settings (struct x_display_info *dpyinfo, | |||
| 644 | FcPatternDel (pat, FC_RGBA); | 645 | FcPatternDel (pat, FC_RGBA); |
| 645 | FcPatternAddInteger (pat, FC_RGBA, settings->rgba); | 646 | FcPatternAddInteger (pat, FC_RGBA, settings->rgba); |
| 646 | oldsettings.rgba = settings->rgba; | 647 | oldsettings.rgba = settings->rgba; |
| 647 | ++changed; | 648 | changed = true; |
| 648 | } | 649 | } |
| 649 | 650 | ||
| 650 | /* Older fontconfig versions don't have FC_LCD_FILTER. */ | 651 | /* Older fontconfig versions don't have FC_LCD_FILTER. */ |
| @@ -653,7 +654,7 @@ apply_xft_settings (struct x_display_info *dpyinfo, | |||
| 653 | { | 654 | { |
| 654 | FcPatternDel (pat, FC_LCD_FILTER); | 655 | FcPatternDel (pat, FC_LCD_FILTER); |
| 655 | FcPatternAddInteger (pat, FC_LCD_FILTER, settings->lcdfilter); | 656 | FcPatternAddInteger (pat, FC_LCD_FILTER, settings->lcdfilter); |
| 656 | ++changed; | 657 | changed = true; |
| 657 | oldsettings.lcdfilter = settings->lcdfilter; | 658 | oldsettings.lcdfilter = settings->lcdfilter; |
| 658 | } | 659 | } |
| 659 | 660 | ||
| @@ -663,7 +664,7 @@ apply_xft_settings (struct x_display_info *dpyinfo, | |||
| 663 | { | 664 | { |
| 664 | FcPatternDel (pat, FC_HINT_STYLE); | 665 | FcPatternDel (pat, FC_HINT_STYLE); |
| 665 | FcPatternAddInteger (pat, FC_HINT_STYLE, settings->hintstyle); | 666 | FcPatternAddInteger (pat, FC_HINT_STYLE, settings->hintstyle); |
| 666 | ++changed; | 667 | changed = true; |
| 667 | oldsettings.hintstyle = settings->hintstyle; | 668 | oldsettings.hintstyle = settings->hintstyle; |
| 668 | } | 669 | } |
| 669 | #endif | 670 | #endif |
| @@ -673,7 +674,7 @@ apply_xft_settings (struct x_display_info *dpyinfo, | |||
| 673 | { | 674 | { |
| 674 | FcPatternDel (pat, FC_DPI); | 675 | FcPatternDel (pat, FC_DPI); |
| 675 | FcPatternAddDouble (pat, FC_DPI, settings->dpi); | 676 | FcPatternAddDouble (pat, FC_DPI, settings->dpi); |
| 676 | ++changed; | 677 | changed = true; |
| 677 | oldsettings.dpi = settings->dpi; | 678 | oldsettings.dpi = settings->dpi; |
| 678 | 679 | ||
| 679 | /* Changing the DPI on this display affects all frames on it. | 680 | /* Changing the DPI on this display affects all frames on it. |
| @@ -699,9 +700,8 @@ apply_xft_settings (struct x_display_info *dpyinfo, | |||
| 699 | char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth]; | 700 | char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth]; |
| 700 | 701 | ||
| 701 | XftDefaultSet (dpyinfo->display, pat); | 702 | XftDefaultSet (dpyinfo->display, pat); |
| 702 | if (send_event_p) | 703 | store_config_changed_event (Qfont_render, |
| 703 | store_config_changed_event (Qfont_render, | 704 | XCAR (dpyinfo->name_list_element)); |
| 704 | XCAR (dpyinfo->name_list_element)); | ||
| 705 | Vxft_settings | 705 | Vxft_settings |
| 706 | = make_formatted_string (buf, format, | 706 | = make_formatted_string (buf, format, |
| 707 | oldsettings.aa, oldsettings.hinting, | 707 | oldsettings.aa, oldsettings.hinting, |
| @@ -715,17 +715,17 @@ apply_xft_settings (struct x_display_info *dpyinfo, | |||
| 715 | } | 715 | } |
| 716 | 716 | ||
| 717 | /* Read XSettings from the display for DPYINFO. | 717 | /* Read XSettings from the display for DPYINFO. |
| 718 | If SEND_EVENT_P is non-zero store a Lisp event settings that changed. */ | 718 | If SEND_EVENT_P store a Lisp event settings that changed. */ |
| 719 | 719 | ||
| 720 | static void | 720 | static void |
| 721 | read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p) | 721 | read_and_apply_settings (struct x_display_info *dpyinfo, bool send_event_p) |
| 722 | { | 722 | { |
| 723 | struct xsettings settings; | 723 | struct xsettings settings; |
| 724 | 724 | ||
| 725 | if (!read_settings (dpyinfo, &settings)) | 725 | if (!read_settings (dpyinfo, &settings)) |
| 726 | return; | 726 | return; |
| 727 | 727 | ||
| 728 | apply_xft_settings (dpyinfo, True, &settings); | 728 | apply_xft_settings (dpyinfo, &settings); |
| 729 | if (settings.seen & SEEN_TB_STYLE) | 729 | if (settings.seen & SEEN_TB_STYLE) |
| 730 | { | 730 | { |
| 731 | if (send_event_p) | 731 | if (send_event_p) |
| @@ -751,27 +751,27 @@ read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p) | |||
| 751 | void | 751 | void |
| 752 | xft_settings_event (struct x_display_info *dpyinfo, const XEvent *event) | 752 | xft_settings_event (struct x_display_info *dpyinfo, const XEvent *event) |
| 753 | { | 753 | { |
| 754 | bool check_window_p = 0, apply_settings_p = 0; | 754 | bool check_window_p = false, apply_settings_p = false; |
| 755 | 755 | ||
| 756 | switch (event->type) | 756 | switch (event->type) |
| 757 | { | 757 | { |
| 758 | case DestroyNotify: | 758 | case DestroyNotify: |
| 759 | if (dpyinfo->xsettings_window == event->xany.window) | 759 | if (dpyinfo->xsettings_window == event->xany.window) |
| 760 | check_window_p = 1; | 760 | check_window_p = true; |
| 761 | break; | 761 | break; |
| 762 | 762 | ||
| 763 | case ClientMessage: | 763 | case ClientMessage: |
| 764 | if (event->xclient.message_type == dpyinfo->Xatom_xsettings_mgr | 764 | if (event->xclient.message_type == dpyinfo->Xatom_xsettings_mgr |
| 765 | && event->xclient.data.l[1] == dpyinfo->Xatom_xsettings_sel | 765 | && event->xclient.data.l[1] == dpyinfo->Xatom_xsettings_sel |
| 766 | && event->xclient.window == dpyinfo->root_window) | 766 | && event->xclient.window == dpyinfo->root_window) |
| 767 | check_window_p = 1; | 767 | check_window_p = true; |
| 768 | break; | 768 | break; |
| 769 | 769 | ||
| 770 | case PropertyNotify: | 770 | case PropertyNotify: |
| 771 | if (event->xproperty.window == dpyinfo->xsettings_window | 771 | if (event->xproperty.window == dpyinfo->xsettings_window |
| 772 | && event->xproperty.state == PropertyNewValue | 772 | && event->xproperty.state == PropertyNewValue |
| 773 | && event->xproperty.atom == dpyinfo->Xatom_xsettings_prop) | 773 | && event->xproperty.atom == dpyinfo->Xatom_xsettings_prop) |
| 774 | apply_settings_p = 1; | 774 | apply_settings_p = true; |
| 775 | break; | 775 | break; |
| 776 | } | 776 | } |
| 777 | 777 | ||
| @@ -781,11 +781,11 @@ xft_settings_event (struct x_display_info *dpyinfo, const XEvent *event) | |||
| 781 | dpyinfo->xsettings_window = None; | 781 | dpyinfo->xsettings_window = None; |
| 782 | get_prop_window (dpyinfo); | 782 | get_prop_window (dpyinfo); |
| 783 | if (dpyinfo->xsettings_window != None) | 783 | if (dpyinfo->xsettings_window != None) |
| 784 | apply_settings_p = 1; | 784 | apply_settings_p = true; |
| 785 | } | 785 | } |
| 786 | 786 | ||
| 787 | if (apply_settings_p) | 787 | if (apply_settings_p) |
| 788 | read_and_apply_settings (dpyinfo, True); | 788 | read_and_apply_settings (dpyinfo, true); |
| 789 | } | 789 | } |
| 790 | 790 | ||
| 791 | /* Initialize GSettings and read startup values. */ | 791 | /* Initialize GSettings and read startup values. */ |
| @@ -795,7 +795,7 @@ init_gsettings (void) | |||
| 795 | { | 795 | { |
| 796 | #ifdef HAVE_GSETTINGS | 796 | #ifdef HAVE_GSETTINGS |
| 797 | GVariant *val; | 797 | GVariant *val; |
| 798 | int schema_found = 0; | 798 | bool schema_found = false; |
| 799 | 799 | ||
| 800 | #if ! GLIB_CHECK_VERSION (2, 36, 0) | 800 | #if ! GLIB_CHECK_VERSION (2, 36, 0) |
| 801 | g_type_init (); | 801 | g_type_init (); |
| @@ -937,7 +937,7 @@ init_xsettings (struct x_display_info *dpyinfo) | |||
| 937 | 937 | ||
| 938 | get_prop_window (dpyinfo); | 938 | get_prop_window (dpyinfo); |
| 939 | if (dpyinfo->xsettings_window != None) | 939 | if (dpyinfo->xsettings_window != None) |
| 940 | read_and_apply_settings (dpyinfo, False); | 940 | read_and_apply_settings (dpyinfo, false); |
| 941 | 941 | ||
| 942 | unblock_input (); | 942 | unblock_input (); |
| 943 | } | 943 | } |
| @@ -1030,7 +1030,7 @@ syms_of_xsettings (void) | |||
| 1030 | When this is non-nil and the system defined fixed width font changes, we | 1030 | When this is non-nil and the system defined fixed width font changes, we |
| 1031 | update frames dynamically. | 1031 | update frames dynamically. |
| 1032 | If this variable is nil, Emacs ignores system font changes. */); | 1032 | If this variable is nil, Emacs ignores system font changes. */); |
| 1033 | use_system_font = 0; | 1033 | use_system_font = false; |
| 1034 | 1034 | ||
| 1035 | DEFVAR_LISP ("xft-settings", Vxft_settings, | 1035 | DEFVAR_LISP ("xft-settings", Vxft_settings, |
| 1036 | doc: /* Font settings applied to Xft. */); | 1036 | doc: /* Font settings applied to Xft. */); |
diff --git a/src/xsmfns.c b/src/xsmfns.c index cd4f9ce57fa..a6c69855390 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c | |||
| @@ -53,7 +53,7 @@ static int ice_fd = -1; | |||
| 53 | 53 | ||
| 54 | /* A flag that says if we are in shutdown interactions or not. */ | 54 | /* A flag that says if we are in shutdown interactions or not. */ |
| 55 | 55 | ||
| 56 | static int doing_interact; | 56 | static bool doing_interact; |
| 57 | 57 | ||
| 58 | /* The session manager object for the session manager connection. */ | 58 | /* The session manager object for the session manager connection. */ |
| 59 | 59 | ||
| @@ -123,9 +123,9 @@ x_session_check_input (int fd, void *data) | |||
| 123 | kbd_buffer_store_event (&emacs_event); | 123 | kbd_buffer_store_event (&emacs_event); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | /* Return non-zero if we have a connection to a session manager. */ | 126 | /* Return true if we have a connection to a session manager. */ |
| 127 | 127 | ||
| 128 | int | 128 | bool |
| 129 | x_session_have_connection (void) | 129 | x_session_have_connection (void) |
| 130 | { | 130 | { |
| 131 | return ice_fd != -1; | 131 | return ice_fd != -1; |
| @@ -138,7 +138,7 @@ x_session_have_connection (void) | |||
| 138 | static void | 138 | static void |
| 139 | smc_interact_CB (SmcConn smcConn, SmPointer clientData) | 139 | smc_interact_CB (SmcConn smcConn, SmPointer clientData) |
| 140 | { | 140 | { |
| 141 | doing_interact = True; | 141 | doing_interact = true; |
| 142 | emacs_event.kind = SAVE_SESSION_EVENT; | 142 | emacs_event.kind = SAVE_SESSION_EVENT; |
| 143 | emacs_event.arg = Qnil; | 143 | emacs_event.arg = Qnil; |
| 144 | } | 144 | } |
| @@ -230,8 +230,7 @@ smc_save_yourself_CB (SmcConn smcConn, | |||
| 230 | props[props_idx]->vals[vp_idx++].value = emacs_program; | 230 | props[props_idx]->vals[vp_idx++].value = emacs_program; |
| 231 | 231 | ||
| 232 | smid_opt = xmalloc (strlen (SMID_OPT) + strlen (client_id) + 1); | 232 | smid_opt = xmalloc (strlen (SMID_OPT) + strlen (client_id) + 1); |
| 233 | strcpy (smid_opt, SMID_OPT); | 233 | strcpy (stpcpy (smid_opt, SMID_OPT), client_id); |
| 234 | strcat (smid_opt, client_id); | ||
| 235 | 234 | ||
| 236 | props[props_idx]->vals[vp_idx].length = strlen (smid_opt); | 235 | props[props_idx]->vals[vp_idx].length = strlen (smid_opt); |
| 237 | props[props_idx]->vals[vp_idx++].value = smid_opt; | 236 | props[props_idx]->vals[vp_idx++].value = smid_opt; |
| @@ -242,8 +241,7 @@ smc_save_yourself_CB (SmcConn smcConn, | |||
| 242 | if (cwd) | 241 | if (cwd) |
| 243 | { | 242 | { |
| 244 | chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (cwd) + 1); | 243 | chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (cwd) + 1); |
| 245 | strcpy (chdir_opt, CHDIR_OPT); | 244 | strcpy (stpcpy (chdir_opt, CHDIR_OPT), cwd); |
| 246 | strcat (chdir_opt, cwd); | ||
| 247 | 245 | ||
| 248 | props[props_idx]->vals[vp_idx].length = strlen (chdir_opt); | 246 | props[props_idx]->vals[vp_idx].length = strlen (chdir_opt); |
| 249 | props[props_idx]->vals[vp_idx++].value = chdir_opt; | 247 | props[props_idx]->vals[vp_idx++].value = chdir_opt; |
| @@ -400,15 +398,15 @@ x_session_initialize (struct x_display_info *dpyinfo) | |||
| 400 | ptrdiff_t name_len = 0; | 398 | ptrdiff_t name_len = 0; |
| 401 | 399 | ||
| 402 | ice_fd = -1; | 400 | ice_fd = -1; |
| 403 | doing_interact = False; | 401 | doing_interact = false; |
| 404 | 402 | ||
| 405 | /* Check if we where started by the session manager. If so, we will | 403 | /* Check if we where started by the session manager. If so, we will |
| 406 | have a previous id. */ | 404 | have a previous id. */ |
| 407 | if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) | 405 | if (! NILP (Vx_session_previous_id) && STRINGP (Vx_session_previous_id)) |
| 408 | previous_id = SSDATA (Vx_session_previous_id); | 406 | previous_id = SSDATA (Vx_session_previous_id); |
| 409 | 407 | ||
| 410 | /* Construct the path to the Emacs program. */ | 408 | /* Construct the path to the Emacs program. */ |
| 411 | if (! EQ (Vinvocation_directory, Qnil)) | 409 | if (! NILP (Vinvocation_directory)) |
| 412 | name_len += SBYTES (Vinvocation_directory); | 410 | name_len += SBYTES (Vinvocation_directory); |
| 413 | name_len += SBYTES (Vinvocation_name); | 411 | name_len += SBYTES (Vinvocation_name); |
| 414 | 412 | ||
| @@ -417,7 +415,7 @@ x_session_initialize (struct x_display_info *dpyinfo) | |||
| 417 | emacs_program = xmalloc (name_len + 1); | 415 | emacs_program = xmalloc (name_len + 1); |
| 418 | char *z = emacs_program; | 416 | char *z = emacs_program; |
| 419 | 417 | ||
| 420 | if (! EQ (Vinvocation_directory, Qnil)) | 418 | if (! NILP (Vinvocation_directory)) |
| 421 | z = lispstpcpy (z, Vinvocation_directory); | 419 | z = lispstpcpy (z, Vinvocation_directory); |
| 422 | lispstpcpy (z, Vinvocation_name); | 420 | lispstpcpy (z, Vinvocation_name); |
| 423 | 421 | ||
| @@ -491,21 +489,19 @@ is told to abort the window system shutdown. | |||
| 491 | Do not call this function yourself. */) | 489 | Do not call this function yourself. */) |
| 492 | (Lisp_Object event) | 490 | (Lisp_Object event) |
| 493 | { | 491 | { |
| 494 | int kill_emacs = CONSP (event) && CONSP (XCDR (event)) | 492 | bool kill_emacs = (CONSP (event) && CONSP (XCDR (event)) |
| 495 | && EQ (Qt, XCAR (XCDR (event))); | 493 | && EQ (Qt, XCAR (XCDR (event)))); |
| 496 | 494 | ||
| 497 | /* Check doing_interact so that we don't do anything if someone called | 495 | /* Check doing_interact so that we don't do anything if someone called |
| 498 | this at the wrong time. */ | 496 | this at the wrong time. */ |
| 499 | if (doing_interact && ! kill_emacs) | 497 | if (doing_interact && ! kill_emacs) |
| 500 | { | 498 | { |
| 501 | Bool cancel_shutdown = False; | 499 | bool cancel_shutdown = ! NILP (call0 (intern ("emacs-session-save"))); |
| 502 | |||
| 503 | cancel_shutdown = ! EQ (call0 (intern ("emacs-session-save")), Qnil); | ||
| 504 | 500 | ||
| 505 | SmcInteractDone (smc_conn, cancel_shutdown); | 501 | SmcInteractDone (smc_conn, cancel_shutdown); |
| 506 | SmcSaveYourselfDone (smc_conn, True); | 502 | SmcSaveYourselfDone (smc_conn, True); |
| 507 | 503 | ||
| 508 | doing_interact = False; | 504 | doing_interact = false; |
| 509 | } | 505 | } |
| 510 | else if (kill_emacs) | 506 | else if (kill_emacs) |
| 511 | { | 507 | { |
| @@ -513,7 +509,7 @@ Do not call this function yourself. */) | |||
| 513 | prevent. Fix this in next version. */ | 509 | prevent. Fix this in next version. */ |
| 514 | Fkill_emacs (Qnil); | 510 | Fkill_emacs (Qnil); |
| 515 | 511 | ||
| 516 | #if 0 | 512 | #if false |
| 517 | /* This will not be reached, but we want kill-emacs-hook to be run. */ | 513 | /* This will not be reached, but we want kill-emacs-hook to be run. */ |
| 518 | SmcCloseConnection (smc_conn, 0, 0); | 514 | SmcCloseConnection (smc_conn, 0, 0); |
| 519 | ice_connection_closed (); | 515 | ice_connection_closed (); |
diff --git a/src/xterm.c b/src/xterm.c index 0640208ca14..130174dff19 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -9230,13 +9230,9 @@ do_ewmh_fullscreen (struct frame *f) | |||
| 9230 | switch (f->want_fullscreen) | 9230 | switch (f->want_fullscreen) |
| 9231 | { | 9231 | { |
| 9232 | case FULLSCREEN_BOTH: | 9232 | case FULLSCREEN_BOTH: |
| 9233 | if (cur == FULLSCREEN_WIDTH || cur == FULLSCREEN_MAXIMIZED | 9233 | if (cur != FULLSCREEN_BOTH) |
| 9234 | || cur == FULLSCREEN_HEIGHT) | 9234 | set_wm_state (frame, true, dpyinfo->Xatom_net_wm_state_fullscreen, |
| 9235 | set_wm_state (frame, false, | 9235 | None); |
| 9236 | dpyinfo->Xatom_net_wm_state_maximized_horz, | ||
| 9237 | dpyinfo->Xatom_net_wm_state_maximized_vert); | ||
| 9238 | set_wm_state (frame, true, | ||
| 9239 | dpyinfo->Xatom_net_wm_state_fullscreen, None); | ||
| 9240 | break; | 9236 | break; |
| 9241 | case FULLSCREEN_WIDTH: | 9237 | case FULLSCREEN_WIDTH: |
| 9242 | if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_HEIGHT | 9238 | if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_HEIGHT |
diff --git a/src/xterm.h b/src/xterm.h index 31c3261e3b9..13877d33935 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -1049,10 +1049,10 @@ extern void x_send_client_event (Lisp_Object display, | |||
| 1049 | Lisp_Object format, | 1049 | Lisp_Object format, |
| 1050 | Lisp_Object values); | 1050 | Lisp_Object values); |
| 1051 | 1051 | ||
| 1052 | extern int x_handle_dnd_message (struct frame *, | 1052 | extern bool x_handle_dnd_message (struct frame *, |
| 1053 | const XClientMessageEvent *, | 1053 | const XClientMessageEvent *, |
| 1054 | struct x_display_info *, | 1054 | struct x_display_info *, |
| 1055 | struct input_event *); | 1055 | struct input_event *); |
| 1056 | extern int x_check_property_data (Lisp_Object); | 1056 | extern int x_check_property_data (Lisp_Object); |
| 1057 | extern void x_fill_property_data (Display *, | 1057 | extern void x_fill_property_data (Display *, |
| 1058 | Lisp_Object, | 1058 | Lisp_Object, |
| @@ -1107,7 +1107,7 @@ extern void initialize_frame_menubar (struct frame *); | |||
| 1107 | /* Defined in xsmfns.c */ | 1107 | /* Defined in xsmfns.c */ |
| 1108 | #ifdef HAVE_X_SM | 1108 | #ifdef HAVE_X_SM |
| 1109 | extern void x_session_initialize (struct x_display_info *dpyinfo); | 1109 | extern void x_session_initialize (struct x_display_info *dpyinfo); |
| 1110 | extern int x_session_have_connection (void); | 1110 | extern bool x_session_have_connection (void); |
| 1111 | extern void x_session_close (void); | 1111 | extern void x_session_close (void); |
| 1112 | #endif | 1112 | #endif |
| 1113 | 1113 | ||