aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-08-14 22:30:45 -0700
committerPaul Eggert2011-08-14 22:30:45 -0700
commitc881564470ef15bf3f1908c1ee9eb4c3e92953fd (patch)
tree9ba76bf1f20a84f2de8f37ab930e2f45bb6a6405 /src
parent70c60eb2f9e5120f609ba5b6f2d82eef26d21c15 (diff)
parentde148fee1a02003faedf49b831abecfec15f60e7 (diff)
downloademacs-c881564470ef15bf3f1908c1ee9eb4c3e92953fd.tar.gz
emacs-c881564470ef15bf3f1908c1ee9eb4c3e92953fd.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog43
-rw-r--r--src/gnutls.c416
-rw-r--r--src/nsfns.m42
-rw-r--r--src/nsterm.h3
-rw-r--r--src/nsterm.m10
-rw-r--r--src/process.c5
-rw-r--r--src/xdisp.c8
-rw-r--r--src/xfaces.c138
8 files changed, 395 insertions, 270 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9d7834fd053..0a1d11f58f6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,4 @@
12011-08-14 Paul Eggert <eggert@cs.ucla.edu> 12011-08-15 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Integer and memory overflow issues (Bug#9196). 3 Integer and memory overflow issues (Bug#9196).
4 4
@@ -409,6 +409,47 @@
409 (gs_load): Use printmax_t to print the widest integers possible. 409 (gs_load): Use printmax_t to print the widest integers possible.
410 Check for integer overflow when computing image height and width. 410 Check for integer overflow when computing image height and width.
411 411
4122011-08-14 Kenichi Handa <handa@m17n.org>
413
414 * process.c (create_process): Call setup_process_coding_systems
415 after the pid of the process is set to -1.
416
4172011-08-14 Eli Zaretskii <eliz@gnu.org>
418
419 * xdisp.c (move_it_in_display_line_to): Don't invoke
420 IT_RESET_X_ASCENT_DESCENT when iterator position was restored from
421 ppos_it. Fixes vertical cursor motion when line beginning is
422 covered by an image. (Bug#9296)
423
4242011-08-14 Jan Djärv <jan.h.d@swipnet.se>
425
426 * nsterm.h (ns_run_ascript): Declare.
427 (NSAPP_DATA2_RUNASSCRIPT): Define.
428
429 * nsfns.m (as_script, as_result, as_status): New static variables.
430 (ns_run_ascript): New function.
431 (Fns_do_applescript): Set variables as_*. Make an NSApplicationDefined
432 event with data2 set to NSAPP_DATA2_RUNASSCRIPT, post it and then start
433 the event loop. Get status from as_status (Bug#7276).
434
435 * nsterm.m (sendEvent): If event is NSApplicationDefined and
436 data2 is NSAPP_DATA2_RUNASSCRIPT, call ns_run_ascript and then exit
437 the event loop (Bug#7276).
438
4392011-08-14 Andreas Schwab <schwab@linux-m68k.org>
440
441 * gnutls.c (QCgnutls_bootprop_priority)
442 (QCgnutls_bootprop_trustfiles, QCgnutls_bootprop_keylist)
443 (QCgnutls_bootprop_crlfiles, QCgnutls_bootprop_callbacks)
444 (QCgnutls_bootprop_loglevel, QCgnutls_bootprop_hostname)
445 (QCgnutls_bootprop_min_prime_bits, QCgnutls_bootprop_verify_flags)
446 (QCgnutls_bootprop_verify_hostname_error)
447 (QCgnutls_bootprop_callbacks_verify): Rename from
448 Qgnutls_bootprop_..., all uses changed.
449
450 * xfaces.c (QCignore_defface): Rename from Qignore_defface, all
451 uses changed.
452
4122011-08-14 Paul Eggert <eggert@cs.ucla.edu> 4532011-08-14 Paul Eggert <eggert@cs.ucla.edu>
413 454
414 * xfaces.c (Qframe_set_background_mode): Now static. 455 * xfaces.c (Qframe_set_background_mode): Now static.
diff --git a/src/gnutls.c b/src/gnutls.c
index fc651d2c7e4..0743ef3f4ee 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -42,19 +42,19 @@ static Lisp_Object Qgnutls_e_interrupted, Qgnutls_e_again,
42static int gnutls_global_initialized; 42static int gnutls_global_initialized;
43 43
44/* The following are for the property list of `gnutls-boot'. */ 44/* The following are for the property list of `gnutls-boot'. */
45static Lisp_Object Qgnutls_bootprop_priority; 45static Lisp_Object QCgnutls_bootprop_priority;
46static Lisp_Object Qgnutls_bootprop_trustfiles; 46static Lisp_Object QCgnutls_bootprop_trustfiles;
47static Lisp_Object Qgnutls_bootprop_keylist; 47static Lisp_Object QCgnutls_bootprop_keylist;
48static Lisp_Object Qgnutls_bootprop_crlfiles; 48static Lisp_Object QCgnutls_bootprop_crlfiles;
49static Lisp_Object Qgnutls_bootprop_callbacks; 49static Lisp_Object QCgnutls_bootprop_callbacks;
50static Lisp_Object Qgnutls_bootprop_loglevel; 50static Lisp_Object QCgnutls_bootprop_loglevel;
51static Lisp_Object Qgnutls_bootprop_hostname; 51static Lisp_Object QCgnutls_bootprop_hostname;
52static Lisp_Object Qgnutls_bootprop_min_prime_bits; 52static Lisp_Object QCgnutls_bootprop_min_prime_bits;
53static Lisp_Object Qgnutls_bootprop_verify_flags; 53static Lisp_Object QCgnutls_bootprop_verify_flags;
54static Lisp_Object Qgnutls_bootprop_verify_hostname_error; 54static Lisp_Object QCgnutls_bootprop_verify_hostname_error;
55 55
56/* Callback keys for `gnutls-boot'. Unused currently. */ 56/* Callback keys for `gnutls-boot'. Unused currently. */
57static Lisp_Object Qgnutls_bootprop_callbacks_verify; 57static Lisp_Object QCgnutls_bootprop_callbacks_verify;
58 58
59static void gnutls_log_function (int, const char *); 59static void gnutls_log_function (int, const char *);
60static void gnutls_log_function2 (int, const char*, const char*); 60static void gnutls_log_function2 (int, const char*, const char*);
@@ -72,41 +72,41 @@ static void gnutls_log_function2 (int, const char*, const char*);
72 } 72 }
73 73
74DEF_GNUTLS_FN (gnutls_alert_description_t, gnutls_alert_get, 74DEF_GNUTLS_FN (gnutls_alert_description_t, gnutls_alert_get,
75 (gnutls_session_t)); 75 (gnutls_session_t));
76DEF_GNUTLS_FN (const char *, gnutls_alert_get_name, 76DEF_GNUTLS_FN (const char *, gnutls_alert_get_name,
77 (gnutls_alert_description_t)); 77 (gnutls_alert_description_t));
78DEF_GNUTLS_FN (int, gnutls_alert_send_appropriate, (gnutls_session_t, int)); 78DEF_GNUTLS_FN (int, gnutls_alert_send_appropriate, (gnutls_session_t, int));
79DEF_GNUTLS_FN (int, gnutls_anon_allocate_client_credentials, 79DEF_GNUTLS_FN (int, gnutls_anon_allocate_client_credentials,
80 (gnutls_anon_client_credentials_t *)); 80 (gnutls_anon_client_credentials_t *));
81DEF_GNUTLS_FN (void, gnutls_anon_free_client_credentials, 81DEF_GNUTLS_FN (void, gnutls_anon_free_client_credentials,
82 (gnutls_anon_client_credentials_t)); 82 (gnutls_anon_client_credentials_t));
83DEF_GNUTLS_FN (int, gnutls_bye, (gnutls_session_t, gnutls_close_request_t)); 83DEF_GNUTLS_FN (int, gnutls_bye, (gnutls_session_t, gnutls_close_request_t));
84DEF_GNUTLS_FN (int, gnutls_certificate_allocate_credentials, 84DEF_GNUTLS_FN (int, gnutls_certificate_allocate_credentials,
85 (gnutls_certificate_credentials_t *)); 85 (gnutls_certificate_credentials_t *));
86DEF_GNUTLS_FN (void, gnutls_certificate_free_credentials, 86DEF_GNUTLS_FN (void, gnutls_certificate_free_credentials,
87 (gnutls_certificate_credentials_t)); 87 (gnutls_certificate_credentials_t));
88DEF_GNUTLS_FN (const gnutls_datum_t *, gnutls_certificate_get_peers, 88DEF_GNUTLS_FN (const gnutls_datum_t *, gnutls_certificate_get_peers,
89 (gnutls_session_t, unsigned int *)); 89 (gnutls_session_t, unsigned int *));
90DEF_GNUTLS_FN (void, gnutls_certificate_set_verify_flags, 90DEF_GNUTLS_FN (void, gnutls_certificate_set_verify_flags,
91 (gnutls_certificate_credentials_t, unsigned int)); 91 (gnutls_certificate_credentials_t, unsigned int));
92DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_crl_file, 92DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_crl_file,
93 (gnutls_certificate_credentials_t, const char *, 93 (gnutls_certificate_credentials_t, const char *,
94 gnutls_x509_crt_fmt_t)); 94 gnutls_x509_crt_fmt_t));
95DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_key_file, 95DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_key_file,
96 (gnutls_certificate_credentials_t, const char *, const char *, 96 (gnutls_certificate_credentials_t, const char *, const char *,
97 gnutls_x509_crt_fmt_t)); 97 gnutls_x509_crt_fmt_t));
98DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_trust_file, 98DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_trust_file,
99 (gnutls_certificate_credentials_t, const char *, 99 (gnutls_certificate_credentials_t, const char *,
100 gnutls_x509_crt_fmt_t)); 100 gnutls_x509_crt_fmt_t));
101DEF_GNUTLS_FN (gnutls_certificate_type_t, gnutls_certificate_type_get, 101DEF_GNUTLS_FN (gnutls_certificate_type_t, gnutls_certificate_type_get,
102 (gnutls_session_t)); 102 (gnutls_session_t));
103DEF_GNUTLS_FN (int, gnutls_certificate_verify_peers2, 103DEF_GNUTLS_FN (int, gnutls_certificate_verify_peers2,
104 (gnutls_session_t, unsigned int *)); 104 (gnutls_session_t, unsigned int *));
105DEF_GNUTLS_FN (int, gnutls_credentials_set, 105DEF_GNUTLS_FN (int, gnutls_credentials_set,
106 (gnutls_session_t, gnutls_credentials_type_t, void *)); 106 (gnutls_session_t, gnutls_credentials_type_t, void *));
107DEF_GNUTLS_FN (void, gnutls_deinit, (gnutls_session_t)); 107DEF_GNUTLS_FN (void, gnutls_deinit, (gnutls_session_t));
108DEF_GNUTLS_FN (void, gnutls_dh_set_prime_bits, 108DEF_GNUTLS_FN (void, gnutls_dh_set_prime_bits,
109 (gnutls_session_t, unsigned int)); 109 (gnutls_session_t, unsigned int));
110DEF_GNUTLS_FN (int, gnutls_error_is_fatal, (int)); 110DEF_GNUTLS_FN (int, gnutls_error_is_fatal, (int));
111DEF_GNUTLS_FN (int, gnutls_global_init, (void)); 111DEF_GNUTLS_FN (int, gnutls_global_init, (void));
112DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); 112DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func));
@@ -118,27 +118,27 @@ DEF_GNUTLS_FN (void, gnutls_global_set_mem_functions,
118DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t)); 118DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t));
119DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); 119DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t));
120DEF_GNUTLS_FN (int, gnutls_priority_set_direct, 120DEF_GNUTLS_FN (int, gnutls_priority_set_direct,
121 (gnutls_session_t, const char *, const char **)); 121 (gnutls_session_t, const char *, const char **));
122DEF_GNUTLS_FN (size_t, gnutls_record_check_pending, (gnutls_session_t)); 122DEF_GNUTLS_FN (size_t, gnutls_record_check_pending, (gnutls_session_t));
123DEF_GNUTLS_FN (ssize_t, gnutls_record_recv, (gnutls_session_t, void *, size_t)); 123DEF_GNUTLS_FN (ssize_t, gnutls_record_recv, (gnutls_session_t, void *, size_t));
124DEF_GNUTLS_FN (ssize_t, gnutls_record_send, 124DEF_GNUTLS_FN (ssize_t, gnutls_record_send,
125 (gnutls_session_t, const void *, size_t)); 125 (gnutls_session_t, const void *, size_t));
126DEF_GNUTLS_FN (const char *, gnutls_strerror, (int)); 126DEF_GNUTLS_FN (const char *, gnutls_strerror, (int));
127DEF_GNUTLS_FN (void, gnutls_transport_set_errno, (gnutls_session_t, int)); 127DEF_GNUTLS_FN (void, gnutls_transport_set_errno, (gnutls_session_t, int));
128DEF_GNUTLS_FN (void, gnutls_transport_set_lowat, (gnutls_session_t, int)); 128DEF_GNUTLS_FN (void, gnutls_transport_set_lowat, (gnutls_session_t, int));
129DEF_GNUTLS_FN (void, gnutls_transport_set_ptr2, 129DEF_GNUTLS_FN (void, gnutls_transport_set_ptr2,
130 (gnutls_session_t, gnutls_transport_ptr_t, 130 (gnutls_session_t, gnutls_transport_ptr_t,
131 gnutls_transport_ptr_t)); 131 gnutls_transport_ptr_t));
132DEF_GNUTLS_FN (void, gnutls_transport_set_pull_function, 132DEF_GNUTLS_FN (void, gnutls_transport_set_pull_function,
133 (gnutls_session_t, gnutls_pull_func)); 133 (gnutls_session_t, gnutls_pull_func));
134DEF_GNUTLS_FN (void, gnutls_transport_set_push_function, 134DEF_GNUTLS_FN (void, gnutls_transport_set_push_function,
135 (gnutls_session_t, gnutls_push_func)); 135 (gnutls_session_t, gnutls_push_func));
136DEF_GNUTLS_FN (int, gnutls_x509_crt_check_hostname, 136DEF_GNUTLS_FN (int, gnutls_x509_crt_check_hostname,
137 (gnutls_x509_crt_t, const char *)); 137 (gnutls_x509_crt_t, const char *));
138DEF_GNUTLS_FN (void, gnutls_x509_crt_deinit, (gnutls_x509_crt_t)); 138DEF_GNUTLS_FN (void, gnutls_x509_crt_deinit, (gnutls_x509_crt_t));
139DEF_GNUTLS_FN (int, gnutls_x509_crt_import, 139DEF_GNUTLS_FN (int, gnutls_x509_crt_import,
140 (gnutls_x509_crt_t, const gnutls_datum_t *, 140 (gnutls_x509_crt_t, const gnutls_datum_t *,
141 gnutls_x509_crt_fmt_t)); 141 gnutls_x509_crt_fmt_t));
142DEF_GNUTLS_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *)); 142DEF_GNUTLS_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *));
143 143
144static int 144static int
@@ -196,7 +196,7 @@ init_gnutls_functions (Lisp_Object libraries)
196 max_log_level = global_gnutls_log_level; 196 max_log_level = global_gnutls_log_level;
197 197
198 GNUTLS_LOG2 (1, max_log_level, "GnuTLS library loaded:", 198 GNUTLS_LOG2 (1, max_log_level, "GnuTLS library loaded:",
199 SDATA (Fget (Qgnutls_dll, QCloaded_from))); 199 SDATA (Fget (Qgnutls_dll, QCloaded_from)));
200 return 1; 200 return 1;
201} 201}
202 202
@@ -267,29 +267,29 @@ emacs_gnutls_handshake (struct Lisp_Process *proc)
267 { 267 {
268#ifdef WINDOWSNT 268#ifdef WINDOWSNT
269 /* On W32 we cannot transfer socket handles between different runtime 269 /* On W32 we cannot transfer socket handles between different runtime
270 libraries, so we tell GnuTLS to use our special push/pull 270 libraries, so we tell GnuTLS to use our special push/pull
271 functions. */ 271 functions. */
272 fn_gnutls_transport_set_ptr2 (state, 272 fn_gnutls_transport_set_ptr2 (state,
273 (gnutls_transport_ptr_t) proc, 273 (gnutls_transport_ptr_t) proc,
274 (gnutls_transport_ptr_t) proc); 274 (gnutls_transport_ptr_t) proc);
275 fn_gnutls_transport_set_push_function (state, &emacs_gnutls_push); 275 fn_gnutls_transport_set_push_function (state, &emacs_gnutls_push);
276 fn_gnutls_transport_set_pull_function (state, &emacs_gnutls_pull); 276 fn_gnutls_transport_set_pull_function (state, &emacs_gnutls_pull);
277 277
278 /* For non blocking sockets or other custom made pull/push 278 /* For non blocking sockets or other custom made pull/push
279 functions the gnutls_transport_set_lowat must be called, with 279 functions the gnutls_transport_set_lowat must be called, with
280 a zero low water mark value. (GnuTLS 2.10.4 documentation) 280 a zero low water mark value. (GnuTLS 2.10.4 documentation)
281 281
282 (Note: this is probably not strictly necessary as the lowat 282 (Note: this is probably not strictly necessary as the lowat
283 value is only used when no custom pull/push functions are 283 value is only used when no custom pull/push functions are
284 set.) */ 284 set.) */
285 fn_gnutls_transport_set_lowat (state, 0); 285 fn_gnutls_transport_set_lowat (state, 0);
286#else 286#else
287 /* This is how GnuTLS takes sockets: as file descriptors passed 287 /* This is how GnuTLS takes sockets: as file descriptors passed
288 in. For an Emacs process socket, infd and outfd are the 288 in. For an Emacs process socket, infd and outfd are the
289 same but we use this two-argument version for clarity. */ 289 same but we use this two-argument version for clarity. */
290 fn_gnutls_transport_set_ptr2 (state, 290 fn_gnutls_transport_set_ptr2 (state,
291 (gnutls_transport_ptr_t) (long) proc->infd, 291 (gnutls_transport_ptr_t) (long) proc->infd,
292 (gnutls_transport_ptr_t) (long) proc->outfd); 292 (gnutls_transport_ptr_t) (long) proc->outfd);
293#endif 293#endif
294 294
295 proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; 295 proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET;
@@ -352,12 +352,12 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, EMACS_INT nbyte)
352 rtnval = fn_gnutls_record_send (state, buf, nbyte); 352 rtnval = fn_gnutls_record_send (state, buf, nbyte);
353 353
354 if (rtnval < 0) 354 if (rtnval < 0)
355 { 355 {
356 if (rtnval == GNUTLS_E_AGAIN || rtnval == GNUTLS_E_INTERRUPTED) 356 if (rtnval == GNUTLS_E_AGAIN || rtnval == GNUTLS_E_INTERRUPTED)
357 continue; 357 continue;
358 else 358 else
359 break; 359 break;
360 } 360 }
361 361
362 buf += rtnval; 362 buf += rtnval;
363 nbyte -= rtnval; 363 nbyte -= rtnval;
@@ -716,17 +716,17 @@ one trustfile (usually a CA bundle). */)
716 return gnutls_make_error (GNUTLS_EMACS_ERROR_NOT_LOADED); 716 return gnutls_make_error (GNUTLS_EMACS_ERROR_NOT_LOADED);
717 } 717 }
718 718
719 hostname = Fplist_get (proplist, Qgnutls_bootprop_hostname); 719 hostname = Fplist_get (proplist, QCgnutls_bootprop_hostname);
720 priority_string = Fplist_get (proplist, Qgnutls_bootprop_priority); 720 priority_string = Fplist_get (proplist, QCgnutls_bootprop_priority);
721 trustfiles = Fplist_get (proplist, Qgnutls_bootprop_trustfiles); 721 trustfiles = Fplist_get (proplist, QCgnutls_bootprop_trustfiles);
722 keylist = Fplist_get (proplist, Qgnutls_bootprop_keylist); 722 keylist = Fplist_get (proplist, QCgnutls_bootprop_keylist);
723 crlfiles = Fplist_get (proplist, Qgnutls_bootprop_crlfiles); 723 crlfiles = Fplist_get (proplist, QCgnutls_bootprop_crlfiles);
724 /* callbacks = Fplist_get (proplist, Qgnutls_bootprop_callbacks); */ 724 /* callbacks = Fplist_get (proplist, QCgnutls_bootprop_callbacks); */
725 loglevel = Fplist_get (proplist, Qgnutls_bootprop_loglevel); 725 loglevel = Fplist_get (proplist, QCgnutls_bootprop_loglevel);
726 verify_flags = Fplist_get (proplist, Qgnutls_bootprop_verify_flags); 726 verify_flags = Fplist_get (proplist, QCgnutls_bootprop_verify_flags);
727 /* verify_error = Fplist_get (proplist, Qgnutls_bootprop_verify_error); */ 727 /* verify_error = Fplist_get (proplist, QCgnutls_bootprop_verify_error); */
728 verify_hostname_error = Fplist_get (proplist, Qgnutls_bootprop_verify_hostname_error); 728 verify_hostname_error = Fplist_get (proplist, QCgnutls_bootprop_verify_hostname_error);
729 prime_bits = Fplist_get (proplist, Qgnutls_bootprop_min_prime_bits); 729 prime_bits = Fplist_get (proplist, QCgnutls_bootprop_min_prime_bits);
730 730
731 if (!STRINGP (hostname)) 731 if (!STRINGP (hostname))
732 error ("gnutls-boot: invalid :hostname parameter"); 732 error ("gnutls-boot: invalid :hostname parameter");
@@ -756,26 +756,26 @@ one trustfile (usually a CA bundle). */)
756 756
757 if (EQ (type, Qgnutls_x509pki)) 757 if (EQ (type, Qgnutls_x509pki))
758 { 758 {
759 GNUTLS_LOG (2, max_log_level, "deallocating x509 credentials"); 759 GNUTLS_LOG (2, max_log_level, "deallocating x509 credentials");
760 x509_cred = XPROCESS (proc)->gnutls_x509_cred; 760 x509_cred = XPROCESS (proc)->gnutls_x509_cred;
761 fn_gnutls_certificate_free_credentials (x509_cred); 761 fn_gnutls_certificate_free_credentials (x509_cred);
762 } 762 }
763 else if (EQ (type, Qgnutls_anon)) 763 else if (EQ (type, Qgnutls_anon))
764 { 764 {
765 GNUTLS_LOG (2, max_log_level, "deallocating anon credentials"); 765 GNUTLS_LOG (2, max_log_level, "deallocating anon credentials");
766 anon_cred = XPROCESS (proc)->gnutls_anon_cred; 766 anon_cred = XPROCESS (proc)->gnutls_anon_cred;
767 fn_gnutls_anon_free_client_credentials (anon_cred); 767 fn_gnutls_anon_free_client_credentials (anon_cred);
768 } 768 }
769 else 769 else
770 { 770 {
771 error ("unknown credential type"); 771 error ("unknown credential type");
772 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE; 772 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
773 } 773 }
774 774
775 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) 775 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT)
776 { 776 {
777 GNUTLS_LOG (1, max_log_level, "deallocating x509 credentials"); 777 GNUTLS_LOG (1, max_log_level, "deallocating x509 credentials");
778 Fgnutls_deinit (proc); 778 Fgnutls_deinit (proc);
779 } 779 }
780 } 780 }
781 781
@@ -790,20 +790,20 @@ one trustfile (usually a CA bundle). */)
790 fn_gnutls_certificate_allocate_credentials (&x509_cred); 790 fn_gnutls_certificate_allocate_credentials (&x509_cred);
791 791
792 if (NUMBERP (verify_flags)) 792 if (NUMBERP (verify_flags))
793 { 793 {
794 gnutls_verify_flags = XINT (verify_flags); 794 gnutls_verify_flags = XINT (verify_flags);
795 GNUTLS_LOG (2, max_log_level, "setting verification flags"); 795 GNUTLS_LOG (2, max_log_level, "setting verification flags");
796 } 796 }
797 else if (NILP (verify_flags)) 797 else if (NILP (verify_flags))
798 { 798 {
799 /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */ 799 /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */
800 GNUTLS_LOG (2, max_log_level, "using default verification flags"); 800 GNUTLS_LOG (2, max_log_level, "using default verification flags");
801 } 801 }
802 else 802 else
803 { 803 {
804 /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */ 804 /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */
805 GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags"); 805 GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags");
806 } 806 }
807 fn_gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags); 807 fn_gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags);
808 } 808 }
809 else if (EQ (type, Qgnutls_anon)) 809 else if (EQ (type, Qgnutls_anon))
@@ -828,76 +828,76 @@ one trustfile (usually a CA bundle). */)
828 for (tail = trustfiles; !NILP (tail); tail = Fcdr (tail)) 828 for (tail = trustfiles; !NILP (tail); tail = Fcdr (tail))
829 { 829 {
830 Lisp_Object trustfile = Fcar (tail); 830 Lisp_Object trustfile = Fcar (tail);
831 if (STRINGP (trustfile)) 831 if (STRINGP (trustfile))
832 { 832 {
833 GNUTLS_LOG2 (1, max_log_level, "setting the trustfile: ", 833 GNUTLS_LOG2 (1, max_log_level, "setting the trustfile: ",
834 SSDATA (trustfile)); 834 SSDATA (trustfile));
835 ret = fn_gnutls_certificate_set_x509_trust_file 835 ret = fn_gnutls_certificate_set_x509_trust_file
836 (x509_cred, 836 (x509_cred,
837 SSDATA (trustfile), 837 SSDATA (trustfile),
838 file_format); 838 file_format);
839 839
840 if (ret < GNUTLS_E_SUCCESS) 840 if (ret < GNUTLS_E_SUCCESS)
841 return gnutls_make_error (ret); 841 return gnutls_make_error (ret);
842 } 842 }
843 else 843 else
844 { 844 {
845 error ("Sorry, GnuTLS can't use non-string trustfile %s", 845 error ("Sorry, GnuTLS can't use non-string trustfile %s",
846 SDATA (trustfile)); 846 SDATA (trustfile));
847 } 847 }
848 } 848 }
849 849
850 for (tail = crlfiles; !NILP (tail); tail = Fcdr (tail)) 850 for (tail = crlfiles; !NILP (tail); tail = Fcdr (tail))
851 { 851 {
852 Lisp_Object crlfile = Fcar (tail); 852 Lisp_Object crlfile = Fcar (tail);
853 if (STRINGP (crlfile)) 853 if (STRINGP (crlfile))
854 { 854 {
855 GNUTLS_LOG2 (1, max_log_level, "setting the CRL file: ", 855 GNUTLS_LOG2 (1, max_log_level, "setting the CRL file: ",
856 SSDATA (crlfile)); 856 SSDATA (crlfile));
857 ret = fn_gnutls_certificate_set_x509_crl_file 857 ret = fn_gnutls_certificate_set_x509_crl_file
858 (x509_cred, 858 (x509_cred,
859 SSDATA (crlfile), 859 SSDATA (crlfile),
860 file_format); 860 file_format);
861 861
862 if (ret < GNUTLS_E_SUCCESS) 862 if (ret < GNUTLS_E_SUCCESS)
863 return gnutls_make_error (ret); 863 return gnutls_make_error (ret);
864 } 864 }
865 else 865 else
866 { 866 {
867 error ("Sorry, GnuTLS can't use non-string CRL file %s", 867 error ("Sorry, GnuTLS can't use non-string CRL file %s",
868 SDATA (crlfile)); 868 SDATA (crlfile));
869 } 869 }
870 } 870 }
871 871
872 for (tail = keylist; !NILP (tail); tail = Fcdr (tail)) 872 for (tail = keylist; !NILP (tail); tail = Fcdr (tail))
873 { 873 {
874 Lisp_Object keyfile = Fcar (Fcar (tail)); 874 Lisp_Object keyfile = Fcar (Fcar (tail));
875 Lisp_Object certfile = Fcar (Fcdr (tail)); 875 Lisp_Object certfile = Fcar (Fcdr (tail));
876 if (STRINGP (keyfile) && STRINGP (certfile)) 876 if (STRINGP (keyfile) && STRINGP (certfile))
877 { 877 {
878 GNUTLS_LOG2 (1, max_log_level, "setting the client key file: ", 878 GNUTLS_LOG2 (1, max_log_level, "setting the client key file: ",
879 SSDATA (keyfile)); 879 SSDATA (keyfile));
880 GNUTLS_LOG2 (1, max_log_level, "setting the client cert file: ", 880 GNUTLS_LOG2 (1, max_log_level, "setting the client cert file: ",
881 SSDATA (certfile)); 881 SSDATA (certfile));
882 ret = fn_gnutls_certificate_set_x509_key_file 882 ret = fn_gnutls_certificate_set_x509_key_file
883 (x509_cred, 883 (x509_cred,
884 SSDATA (certfile), 884 SSDATA (certfile),
885 SSDATA (keyfile), 885 SSDATA (keyfile),
886 file_format); 886 file_format);
887 887
888 if (ret < GNUTLS_E_SUCCESS) 888 if (ret < GNUTLS_E_SUCCESS)
889 return gnutls_make_error (ret); 889 return gnutls_make_error (ret);
890 } 890 }
891 else 891 else
892 { 892 {
893 if (STRINGP (keyfile)) 893 if (STRINGP (keyfile))
894 error ("Sorry, GnuTLS can't use non-string client cert file %s", 894 error ("Sorry, GnuTLS can't use non-string client cert file %s",
895 SDATA (certfile)); 895 SDATA (certfile));
896 else 896 else
897 error ("Sorry, GnuTLS can't use non-string client key file %s", 897 error ("Sorry, GnuTLS can't use non-string client key file %s",
898 SDATA (keyfile)); 898 SDATA (keyfile));
899 } 899 }
900 } 900 }
901 } 901 }
902 902
903 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES; 903 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES;
@@ -925,19 +925,19 @@ one trustfile (usually a CA bundle). */)
925 { 925 {
926 priority_string_ptr = SSDATA (priority_string); 926 priority_string_ptr = SSDATA (priority_string);
927 GNUTLS_LOG2 (1, max_log_level, "got non-default priority string:", 927 GNUTLS_LOG2 (1, max_log_level, "got non-default priority string:",
928 priority_string_ptr); 928 priority_string_ptr);
929 } 929 }
930 else 930 else
931 { 931 {
932 GNUTLS_LOG2 (1, max_log_level, "using default priority string:", 932 GNUTLS_LOG2 (1, max_log_level, "using default priority string:",
933 priority_string_ptr); 933 priority_string_ptr);
934 } 934 }
935 935
936 GNUTLS_LOG (1, max_log_level, "setting the priority string"); 936 GNUTLS_LOG (1, max_log_level, "setting the priority string");
937 937
938 ret = fn_gnutls_priority_set_direct (state, 938 ret = fn_gnutls_priority_set_direct (state,
939 priority_string_ptr, 939 priority_string_ptr,
940 NULL); 940 NULL);
941 941
942 if (ret < GNUTLS_E_SUCCESS) 942 if (ret < GNUTLS_E_SUCCESS)
943 return gnutls_make_error (ret); 943 return gnutls_make_error (ret);
@@ -990,44 +990,44 @@ one trustfile (usually a CA bundle). */)
990 990
991 if (XINT (loglevel) > 0 && peer_verification & GNUTLS_CERT_INVALID) 991 if (XINT (loglevel) > 0 && peer_verification & GNUTLS_CERT_INVALID)
992 message ("%s certificate could not be verified.", 992 message ("%s certificate could not be verified.",
993 c_hostname); 993 c_hostname);
994 994
995 if (peer_verification & GNUTLS_CERT_REVOKED) 995 if (peer_verification & GNUTLS_CERT_REVOKED)
996 GNUTLS_LOG2 (1, max_log_level, "certificate was revoked (CRL):", 996 GNUTLS_LOG2 (1, max_log_level, "certificate was revoked (CRL):",
997 c_hostname); 997 c_hostname);
998 998
999 if (peer_verification & GNUTLS_CERT_SIGNER_NOT_FOUND) 999 if (peer_verification & GNUTLS_CERT_SIGNER_NOT_FOUND)
1000 GNUTLS_LOG2 (1, max_log_level, "certificate signer was not found:", 1000 GNUTLS_LOG2 (1, max_log_level, "certificate signer was not found:",
1001 c_hostname); 1001 c_hostname);
1002 1002
1003 if (peer_verification & GNUTLS_CERT_SIGNER_NOT_CA) 1003 if (peer_verification & GNUTLS_CERT_SIGNER_NOT_CA)
1004 GNUTLS_LOG2 (1, max_log_level, "certificate signer is not a CA:", 1004 GNUTLS_LOG2 (1, max_log_level, "certificate signer is not a CA:",
1005 c_hostname); 1005 c_hostname);
1006 1006
1007 if (peer_verification & GNUTLS_CERT_INSECURE_ALGORITHM) 1007 if (peer_verification & GNUTLS_CERT_INSECURE_ALGORITHM)
1008 GNUTLS_LOG2 (1, max_log_level, 1008 GNUTLS_LOG2 (1, max_log_level,
1009 "certificate was signed with an insecure algorithm:", 1009 "certificate was signed with an insecure algorithm:",
1010 c_hostname); 1010 c_hostname);
1011 1011
1012 if (peer_verification & GNUTLS_CERT_NOT_ACTIVATED) 1012 if (peer_verification & GNUTLS_CERT_NOT_ACTIVATED)
1013 GNUTLS_LOG2 (1, max_log_level, "certificate is not yet activated:", 1013 GNUTLS_LOG2 (1, max_log_level, "certificate is not yet activated:",
1014 c_hostname); 1014 c_hostname);
1015 1015
1016 if (peer_verification & GNUTLS_CERT_EXPIRED) 1016 if (peer_verification & GNUTLS_CERT_EXPIRED)
1017 GNUTLS_LOG2 (1, max_log_level, "certificate has expired:", 1017 GNUTLS_LOG2 (1, max_log_level, "certificate has expired:",
1018 c_hostname); 1018 c_hostname);
1019 1019
1020 if (peer_verification != 0) 1020 if (peer_verification != 0)
1021 { 1021 {
1022 if (NILP (verify_hostname_error)) 1022 if (NILP (verify_hostname_error))
1023 { 1023 {
1024 GNUTLS_LOG2 (1, max_log_level, "certificate validation failed:", 1024 GNUTLS_LOG2 (1, max_log_level, "certificate validation failed:",
1025 c_hostname); 1025 c_hostname);
1026 } 1026 }
1027 else 1027 else
1028 { 1028 {
1029 error ("Certificate validation failed %s, verification code %d", 1029 error ("Certificate validation failed %s, verification code %d",
1030 c_hostname, peer_verification); 1030 c_hostname, peer_verification);
1031 } 1031 }
1032 } 1032 }
1033 1033
@@ -1039,41 +1039,41 @@ one trustfile (usually a CA bundle). */)
1039 ret = fn_gnutls_x509_crt_init (&gnutls_verify_cert); 1039 ret = fn_gnutls_x509_crt_init (&gnutls_verify_cert);
1040 1040
1041 if (ret < GNUTLS_E_SUCCESS) 1041 if (ret < GNUTLS_E_SUCCESS)
1042 return gnutls_make_error (ret); 1042 return gnutls_make_error (ret);
1043 1043
1044 gnutls_verify_cert_list = 1044 gnutls_verify_cert_list =
1045 fn_gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); 1045 fn_gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size);
1046 1046
1047 if (NULL == gnutls_verify_cert_list) 1047 if (NULL == gnutls_verify_cert_list)
1048 { 1048 {
1049 error ("No x509 certificate was found!\n"); 1049 error ("No x509 certificate was found!\n");
1050 } 1050 }
1051 1051
1052 /* We only check the first certificate in the given chain. */ 1052 /* We only check the first certificate in the given chain. */
1053 ret = fn_gnutls_x509_crt_import (gnutls_verify_cert, 1053 ret = fn_gnutls_x509_crt_import (gnutls_verify_cert,
1054 &gnutls_verify_cert_list[0], 1054 &gnutls_verify_cert_list[0],
1055 GNUTLS_X509_FMT_DER); 1055 GNUTLS_X509_FMT_DER);
1056 1056
1057 if (ret < GNUTLS_E_SUCCESS) 1057 if (ret < GNUTLS_E_SUCCESS)
1058 { 1058 {
1059 fn_gnutls_x509_crt_deinit (gnutls_verify_cert); 1059 fn_gnutls_x509_crt_deinit (gnutls_verify_cert);
1060 return gnutls_make_error (ret); 1060 return gnutls_make_error (ret);
1061 } 1061 }
1062 1062
1063 if (!fn_gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname)) 1063 if (!fn_gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname))
1064 { 1064 {
1065 if (NILP (verify_hostname_error)) 1065 if (NILP (verify_hostname_error))
1066 { 1066 {
1067 GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:", 1067 GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:",
1068 c_hostname); 1068 c_hostname);
1069 } 1069 }
1070 else 1070 else
1071 { 1071 {
1072 fn_gnutls_x509_crt_deinit (gnutls_verify_cert); 1072 fn_gnutls_x509_crt_deinit (gnutls_verify_cert);
1073 error ("The x509 certificate does not match \"%s\"", 1073 error ("The x509 certificate does not match \"%s\"",
1074 c_hostname); 1074 c_hostname);
1075 } 1075 }
1076 } 1076 }
1077 1077
1078 fn_gnutls_x509_crt_deinit (gnutls_verify_cert); 1078 fn_gnutls_x509_crt_deinit (gnutls_verify_cert);
1079 } 1079 }
@@ -1105,7 +1105,7 @@ This function may also return `gnutls-e-again', or
1105 state = XPROCESS (proc)->gnutls_state; 1105 state = XPROCESS (proc)->gnutls_state;
1106 1106
1107 ret = fn_gnutls_bye (state, 1107 ret = fn_gnutls_bye (state,
1108 NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR); 1108 NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR);
1109 1109
1110 return gnutls_make_error (ret); 1110 return gnutls_make_error (ret);
1111} 1111}
@@ -1119,33 +1119,33 @@ syms_of_gnutls (void)
1119 DEFSYM (Qgnutls_code, "gnutls-code"); 1119 DEFSYM (Qgnutls_code, "gnutls-code");
1120 DEFSYM (Qgnutls_anon, "gnutls-anon"); 1120 DEFSYM (Qgnutls_anon, "gnutls-anon");
1121 DEFSYM (Qgnutls_x509pki, "gnutls-x509pki"); 1121 DEFSYM (Qgnutls_x509pki, "gnutls-x509pki");
1122 DEFSYM (Qgnutls_bootprop_hostname, ":hostname"); 1122 DEFSYM (QCgnutls_bootprop_hostname, ":hostname");
1123 DEFSYM (Qgnutls_bootprop_priority, ":priority"); 1123 DEFSYM (QCgnutls_bootprop_priority, ":priority");
1124 DEFSYM (Qgnutls_bootprop_trustfiles, ":trustfiles"); 1124 DEFSYM (QCgnutls_bootprop_trustfiles, ":trustfiles");
1125 DEFSYM (Qgnutls_bootprop_keylist, ":keylist"); 1125 DEFSYM (QCgnutls_bootprop_keylist, ":keylist");
1126 DEFSYM (Qgnutls_bootprop_crlfiles, ":crlfiles"); 1126 DEFSYM (QCgnutls_bootprop_crlfiles, ":crlfiles");
1127 DEFSYM (Qgnutls_bootprop_callbacks, ":callbacks"); 1127 DEFSYM (QCgnutls_bootprop_callbacks, ":callbacks");
1128 DEFSYM (Qgnutls_bootprop_callbacks_verify, "verify"); 1128 DEFSYM (QCgnutls_bootprop_callbacks_verify, "verify");
1129 DEFSYM (Qgnutls_bootprop_min_prime_bits, ":min-prime-bits"); 1129 DEFSYM (QCgnutls_bootprop_min_prime_bits, ":min-prime-bits");
1130 DEFSYM (Qgnutls_bootprop_loglevel, ":loglevel"); 1130 DEFSYM (QCgnutls_bootprop_loglevel, ":loglevel");
1131 DEFSYM (Qgnutls_bootprop_verify_flags, ":verify-flags"); 1131 DEFSYM (QCgnutls_bootprop_verify_flags, ":verify-flags");
1132 DEFSYM (Qgnutls_bootprop_verify_hostname_error, ":verify-hostname-error"); 1132 DEFSYM (QCgnutls_bootprop_verify_hostname_error, ":verify-hostname-error");
1133 1133
1134 DEFSYM (Qgnutls_e_interrupted, "gnutls-e-interrupted"); 1134 DEFSYM (Qgnutls_e_interrupted, "gnutls-e-interrupted");
1135 Fput (Qgnutls_e_interrupted, Qgnutls_code, 1135 Fput (Qgnutls_e_interrupted, Qgnutls_code,
1136 make_number (GNUTLS_E_INTERRUPTED)); 1136 make_number (GNUTLS_E_INTERRUPTED));
1137 1137
1138 DEFSYM (Qgnutls_e_again, "gnutls-e-again"); 1138 DEFSYM (Qgnutls_e_again, "gnutls-e-again");
1139 Fput (Qgnutls_e_again, Qgnutls_code, 1139 Fput (Qgnutls_e_again, Qgnutls_code,
1140 make_number (GNUTLS_E_AGAIN)); 1140 make_number (GNUTLS_E_AGAIN));
1141 1141
1142 DEFSYM (Qgnutls_e_invalid_session, "gnutls-e-invalid-session"); 1142 DEFSYM (Qgnutls_e_invalid_session, "gnutls-e-invalid-session");
1143 Fput (Qgnutls_e_invalid_session, Qgnutls_code, 1143 Fput (Qgnutls_e_invalid_session, Qgnutls_code,
1144 make_number (GNUTLS_E_INVALID_SESSION)); 1144 make_number (GNUTLS_E_INVALID_SESSION));
1145 1145
1146 DEFSYM (Qgnutls_e_not_ready_for_handshake, "gnutls-e-not-ready-for-handshake"); 1146 DEFSYM (Qgnutls_e_not_ready_for_handshake, "gnutls-e-not-ready-for-handshake");
1147 Fput (Qgnutls_e_not_ready_for_handshake, Qgnutls_code, 1147 Fput (Qgnutls_e_not_ready_for_handshake, Qgnutls_code,
1148 make_number (GNUTLS_E_APPLICATION_ERROR_MIN)); 1148 make_number (GNUTLS_E_APPLICATION_ERROR_MIN));
1149 1149
1150 defsubr (&Sgnutls_get_initstage); 1150 defsubr (&Sgnutls_get_initstage);
1151 defsubr (&Sgnutls_errorp); 1151 defsubr (&Sgnutls_errorp);
diff --git a/src/nsfns.m b/src/nsfns.m
index 85246a4c25f..a09011d8461 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -97,6 +97,9 @@ Lisp_Object Fx_open_connection (Lisp_Object, Lisp_Object, Lisp_Object);
97 97
98extern BOOL ns_in_resize; 98extern BOOL ns_in_resize;
99 99
100/* Static variables to handle applescript execution. */
101static Lisp_Object as_script, *as_result;
102static int as_status;
100 103
101/* ========================================================================== 104/* ==========================================================================
102 105
@@ -2052,6 +2055,15 @@ ns_do_applescript (Lisp_Object script, Lisp_Object *result)
2052 return 0; 2055 return 0;
2053} 2056}
2054 2057
2058/* Helper function called from sendEvent to run applescript
2059 from within the main event loop. */
2060
2061void
2062ns_run_ascript (void)
2063{
2064 as_status = ns_do_applescript (as_script, as_result);
2065}
2066
2055DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0, 2067DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0,
2056 doc: /* Execute AppleScript SCRIPT and return the result. 2068 doc: /* Execute AppleScript SCRIPT and return the result.
2057If compilation and execution are successful, the resulting script value 2069If compilation and execution are successful, the resulting script value
@@ -2061,12 +2073,37 @@ In case the execution fails, an error is signaled. */)
2061{ 2073{
2062 Lisp_Object result; 2074 Lisp_Object result;
2063 int status; 2075 int status;
2076 NSEvent *nxev;
2064 2077
2065 CHECK_STRING (script); 2078 CHECK_STRING (script);
2066 check_ns (); 2079 check_ns ();
2067 2080
2068 BLOCK_INPUT; 2081 BLOCK_INPUT;
2069 status = ns_do_applescript (script, &result); 2082
2083 as_script = script;
2084 as_result = &result;
2085
2086 /* executing apple script requires the event loop to run, otherwise
2087 errors aren't returned and executeAndReturnError hangs forever.
2088 Post an event that runs applescript and then start the event loop.
2089 The event loop is exited when the script is done. */
2090 nxev = [NSEvent otherEventWithType: NSApplicationDefined
2091 location: NSMakePoint (0, 0)
2092 modifierFlags: 0
2093 timestamp: 0
2094 windowNumber: [[NSApp mainWindow] windowNumber]
2095 context: [NSApp context]
2096 subtype: 0
2097 data1: 0
2098 data2: NSAPP_DATA2_RUNASSCRIPT];
2099
2100 [NSApp postEvent: nxev atStart: NO];
2101 [NSApp run];
2102
2103 status = as_status;
2104 as_status = 0;
2105 as_script = Qnil;
2106 as_result = 0;
2070 UNBLOCK_INPUT; 2107 UNBLOCK_INPUT;
2071 if (status == 0) 2108 if (status == 0)
2072 return result; 2109 return result;
@@ -2670,4 +2707,7 @@ be used as the image of the icon representing the frame. */);
2670 /* used only in fontset.c */ 2707 /* used only in fontset.c */
2671 check_window_system_func = check_ns; 2708 check_window_system_func = check_ns;
2672 2709
2710 as_status = 0;
2711 as_script = Qnil;
2712 as_result = 0;
2673} 2713}
diff --git a/src/nsterm.h b/src/nsterm.h
index 5bbc5329aa2..188ec732e82 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -795,6 +795,9 @@ extern void x_set_tool_bar_lines (struct frame *f,
795extern void x_activate_menubar (struct frame *); 795extern void x_activate_menubar (struct frame *);
796extern void free_frame_menubar (struct frame *); 796extern void free_frame_menubar (struct frame *);
797 797
798#define NSAPP_DATA2_RUNASSCRIPT 10
799extern void ns_run_ascript (void);
800
798extern void ns_init_paths (void); 801extern void ns_init_paths (void);
799extern void syms_of_nsterm (void); 802extern void syms_of_nsterm (void);
800extern void syms_of_nsfns (void); 803extern void syms_of_nsfns (void);
diff --git a/src/nsterm.m b/src/nsterm.m
index 484e8847dc9..4c9574c35ba 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -4254,6 +4254,16 @@ ns_term_shutdown (int sig)
4254/* NSTRACE (sendEvent); */ 4254/* NSTRACE (sendEvent); */
4255/*fprintf (stderr, "received event of type %d\t%d\n", type);*/ 4255/*fprintf (stderr, "received event of type %d\t%d\n", type);*/
4256 4256
4257#ifdef NS_IMPL_COCOA
4258 if (type == NSApplicationDefined
4259 && [theEvent data2] == NSAPP_DATA2_RUNASSCRIPT)
4260 {
4261 ns_run_ascript ();
4262 [self stop: self];
4263 return;
4264 }
4265#endif
4266
4257 if (type == NSCursorUpdate && window == nil) 4267 if (type == NSCursorUpdate && window == nil)
4258 { 4268 {
4259 fprintf (stderr, "Dropping external cursor update event.\n"); 4269 fprintf (stderr, "Dropping external cursor update event.\n");
diff --git a/src/process.c b/src/process.c
index 887090df26c..9f3bb0e5803 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1643,7 +1643,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1643 1643
1644 XPROCESS (process)->pty_flag = pty_flag; 1644 XPROCESS (process)->pty_flag = pty_flag;
1645 XPROCESS (process)->status = Qrun; 1645 XPROCESS (process)->status = Qrun;
1646 setup_process_coding_systems (process);
1647 1646
1648 /* Delay interrupts until we have a chance to store 1647 /* Delay interrupts until we have a chance to store
1649 the new fork's pid in its process structure */ 1648 the new fork's pid in its process structure */
@@ -1678,6 +1677,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1678 processes to get their return values scrambled. */ 1677 processes to get their return values scrambled. */
1679 XPROCESS (process)->pid = -1; 1678 XPROCESS (process)->pid = -1;
1680 1679
1680 /* This must be called after the above line because it may signal an
1681 error. */
1682 setup_process_coding_systems (process);
1683
1681 BLOCK_INPUT; 1684 BLOCK_INPUT;
1682 1685
1683 { 1686 {
diff --git a/src/xdisp.c b/src/xdisp.c
index 98bd25d1e4f..124c3179a18 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8034,8 +8034,12 @@ move_it_in_display_line_to (struct it *it,
8034 if (!saw_smaller_pos && IT_CHARPOS (*it) > to_charpos) 8034 if (!saw_smaller_pos && IT_CHARPOS (*it) > to_charpos)
8035 { 8035 {
8036 if (IT_CHARPOS (ppos_it) < ZV) 8036 if (IT_CHARPOS (ppos_it) < ZV)
8037 RESTORE_IT (it, &ppos_it, ppos_data); 8037 {
8038 goto buffer_pos_reached; 8038 RESTORE_IT (it, &ppos_it, ppos_data);
8039 result = MOVE_POS_MATCH_OR_ZV;
8040 }
8041 else
8042 goto buffer_pos_reached;
8039 } 8043 }
8040 else if (it->line_wrap == WORD_WRAP && atpos_it.sp >= 0 8044 else if (it->line_wrap == WORD_WRAP && atpos_it.sp >= 0
8041 && IT_CHARPOS (*it) > to_charpos) 8045 && IT_CHARPOS (*it) > to_charpos)
diff --git a/src/xfaces.c b/src/xfaces.c
index df40a6999f7..fee4a6f9d6a 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -293,7 +293,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
293 293
294/* Non-zero if face attribute ATTR is `ignore-defface'. */ 294/* Non-zero if face attribute ATTR is `ignore-defface'. */
295 295
296#define IGNORE_DEFFACE_P(ATTR) EQ ((ATTR), Qignore_defface) 296#define IGNORE_DEFFACE_P(ATTR) EQ ((ATTR), QCignore_defface)
297 297
298/* Value is the number of elements of VECTOR. */ 298/* Value is the number of elements of VECTOR. */
299 299
@@ -332,7 +332,7 @@ static Lisp_Object Qultra_expanded;
332static Lisp_Object Qreleased_button, Qpressed_button; 332static Lisp_Object Qreleased_button, Qpressed_button;
333static Lisp_Object QCstyle, QCcolor, QCline_width; 333static Lisp_Object QCstyle, QCcolor, QCline_width;
334Lisp_Object Qunspecified; /* used in dosfns.c */ 334Lisp_Object Qunspecified; /* used in dosfns.c */
335static Lisp_Object Qignore_defface; 335static Lisp_Object QCignore_defface;
336 336
337char unspecified_fg[] = "unspecified-fg", unspecified_bg[] = "unspecified-bg"; 337char unspecified_fg[] = "unspecified-fg", unspecified_bg[] = "unspecified-bg";
338 338
@@ -458,11 +458,11 @@ struct table_entry;
458struct named_merge_point; 458struct named_merge_point;
459 459
460static void map_tty_color (struct frame *, struct face *, 460static void map_tty_color (struct frame *, struct face *,
461 enum lface_attribute_index, int *); 461 enum lface_attribute_index, int *);
462static Lisp_Object resolve_face_name (Lisp_Object, int); 462static Lisp_Object resolve_face_name (Lisp_Object, int);
463static void set_font_frame_param (Lisp_Object, Lisp_Object); 463static void set_font_frame_param (Lisp_Object, Lisp_Object);
464static int get_lface_attributes (struct frame *, Lisp_Object, Lisp_Object *, 464static int get_lface_attributes (struct frame *, Lisp_Object, Lisp_Object *,
465 int, struct named_merge_point *); 465 int, struct named_merge_point *);
466static ptrdiff_t load_pixmap (struct frame *, Lisp_Object, 466static ptrdiff_t load_pixmap (struct frame *, Lisp_Object,
467 unsigned *, unsigned *); 467 unsigned *, unsigned *);
468static struct frame *frame_or_selected_frame (Lisp_Object, int); 468static struct frame *frame_or_selected_frame (Lisp_Object, int);
@@ -470,9 +470,9 @@ static void load_face_colors (struct frame *, struct face *, Lisp_Object *);
470static void free_face_colors (struct frame *, struct face *); 470static void free_face_colors (struct frame *, struct face *);
471static int face_color_gray_p (struct frame *, const char *); 471static int face_color_gray_p (struct frame *, const char *);
472static struct face *realize_face (struct face_cache *, Lisp_Object *, 472static struct face *realize_face (struct face_cache *, Lisp_Object *,
473 int); 473 int);
474static struct face *realize_non_ascii_face (struct frame *, Lisp_Object, 474static struct face *realize_non_ascii_face (struct frame *, Lisp_Object,
475 struct face *); 475 struct face *);
476static struct face *realize_x_face (struct face_cache *, Lisp_Object *); 476static struct face *realize_x_face (struct face_cache *, Lisp_Object *);
477static struct face *realize_tty_face (struct face_cache *, Lisp_Object *); 477static struct face *realize_tty_face (struct face_cache *, Lisp_Object *);
478static int realize_basic_faces (struct frame *); 478static int realize_basic_faces (struct frame *);
@@ -488,11 +488,11 @@ static void clear_face_gcs (struct face_cache *);
488static void free_face_cache (struct face_cache *); 488static void free_face_cache (struct face_cache *);
489static int face_fontset (Lisp_Object *); 489static int face_fontset (Lisp_Object *);
490static void merge_face_vectors (struct frame *, Lisp_Object *, Lisp_Object*, 490static void merge_face_vectors (struct frame *, Lisp_Object *, Lisp_Object*,
491 struct named_merge_point *); 491 struct named_merge_point *);
492static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *, 492static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *,
493 int, struct named_merge_point *); 493 int, struct named_merge_point *);
494static int set_lface_from_font (struct frame *, Lisp_Object, Lisp_Object, 494static int set_lface_from_font (struct frame *, Lisp_Object, Lisp_Object,
495 int); 495 int);
496static Lisp_Object lface_from_face_name (struct frame *, Lisp_Object, int); 496static Lisp_Object lface_from_face_name (struct frame *, Lisp_Object, int);
497static struct face *make_realized_face (Lisp_Object *); 497static struct face *make_realized_face (Lisp_Object *);
498static void cache_face (struct face_cache *, struct face *, unsigned); 498static void cache_face (struct face_cache *, struct face *, unsigned);
@@ -623,7 +623,8 @@ x_free_colors (struct frame *f, long unsigned int *pixels, int npixels)
623 is called. */ 623 is called. */
624 624
625void 625void
626x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap, long unsigned int *pixels, int npixels) 626x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap,
627 long unsigned int *pixels, int npixels)
627{ 628{
628 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 629 struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
629 int class = dpyinfo->visual->class; 630 int class = dpyinfo->visual->class;
@@ -698,8 +699,8 @@ x_free_gc (struct frame *f, GC gc)
698 699
699static inline GC 700static inline GC
700x_create_gc (struct frame *f, 701x_create_gc (struct frame *f,
701 unsigned long mask, 702 unsigned long mask,
702 XGCValues *xgcv) 703 XGCValues *xgcv)
703{ 704{
704 GC gc = xmalloc (sizeof (*gc)); 705 GC gc = xmalloc (sizeof (*gc));
705 if (gc) 706 if (gc)
@@ -792,7 +793,7 @@ init_frame_faces (struct frame *f)
792 if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f)) 793 if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f))
793#endif 794#endif
794 if (!realize_basic_faces (f)) 795 if (!realize_basic_faces (f))
795 abort (); 796 abort ();
796} 797}
797 798
798 799
@@ -963,7 +964,8 @@ the pixmap. Bits are stored row by row, each row occupies
963 if these pointers are not null. */ 964 if these pointers are not null. */
964 965
965static ptrdiff_t 966static ptrdiff_t
966load_pixmap (FRAME_PTR f, Lisp_Object name, unsigned int *w_ptr, unsigned int *h_ptr) 967load_pixmap (FRAME_PTR f, Lisp_Object name, unsigned int *w_ptr,
968 unsigned int *h_ptr)
967{ 969{
968 ptrdiff_t bitmap_id; 970 ptrdiff_t bitmap_id;
969 971
@@ -1057,7 +1059,8 @@ parse_rgb_list (Lisp_Object rgb_list, XColor *color)
1057 returned in it. */ 1059 returned in it. */
1058 1060
1059static int 1061static int
1060tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, XColor *std_color) 1062tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color,
1063 XColor *std_color)
1061{ 1064{
1062 Lisp_Object frame, color_desc; 1065 Lisp_Object frame, color_desc;
1063 1066
@@ -1153,7 +1156,8 @@ tty_defined_color (struct frame *f, const char *color_name,
1153 This does the right thing for any type of frame. */ 1156 This does the right thing for any type of frame. */
1154 1157
1155static int 1158static int
1156defined_color (struct frame *f, const char *color_name, XColor *color_def, int alloc) 1159defined_color (struct frame *f, const char *color_name, XColor *color_def,
1160 int alloc)
1157{ 1161{
1158 if (!FRAME_WINDOW_P (f)) 1162 if (!FRAME_WINDOW_P (f))
1159 return tty_defined_color (f, color_name, color_def, alloc); 1163 return tty_defined_color (f, color_name, color_def, alloc);
@@ -1240,7 +1244,8 @@ face_color_gray_p (struct frame *f, const char *color_name)
1240 color. */ 1244 color. */
1241 1245
1242static int 1246static int
1243face_color_supported_p (struct frame *f, const char *color_name, int background_p) 1247face_color_supported_p (struct frame *f, const char *color_name,
1248 int background_p)
1244{ 1249{
1245 Lisp_Object frame; 1250 Lisp_Object frame;
1246 XColor not_used; 1251 XColor not_used;
@@ -1313,7 +1318,8 @@ COLOR must be a valid color name. */)
1313 these colors. */ 1318 these colors. */
1314 1319
1315unsigned long 1320unsigned long
1316load_color (struct frame *f, struct face *face, Lisp_Object name, enum lface_attribute_index target_index) 1321load_color (struct frame *f, struct face *face, Lisp_Object name,
1322 enum lface_attribute_index target_index)
1317{ 1323{
1318 XColor color; 1324 XColor color;
1319 1325
@@ -1721,7 +1727,8 @@ fonts to match. The first MAXIMUM fonts are reported.
1721The optional fifth argument WIDTH, if specified, is a number of columns 1727The optional fifth argument WIDTH, if specified, is a number of columns
1722occupied by a character of a font. In that case, return only fonts 1728occupied by a character of a font. In that case, return only fonts
1723the WIDTH times as wide as FACE on FRAME. */) 1729the WIDTH times as wide as FACE on FRAME. */)
1724 (Lisp_Object pattern, Lisp_Object face, Lisp_Object frame, Lisp_Object maximum, Lisp_Object width) 1730 (Lisp_Object pattern, Lisp_Object face, Lisp_Object frame,
1731 Lisp_Object maximum, Lisp_Object width)
1725{ 1732{
1726 struct frame *f; 1733 struct frame *f;
1727 int size, avgwidth IF_LINT (= 0); 1734 int size, avgwidth IF_LINT (= 0);
@@ -2059,7 +2066,8 @@ resolve_face_name (Lisp_Object face_name, int signal_p)
2059 signal an error if FACE_NAME is not a valid face name. If SIGNAL_P 2066 signal an error if FACE_NAME is not a valid face name. If SIGNAL_P
2060 is zero, value is nil if FACE_NAME is not a valid face name. */ 2067 is zero, value is nil if FACE_NAME is not a valid face name. */
2061static inline Lisp_Object 2068static inline Lisp_Object
2062lface_from_face_name_no_resolve (struct frame *f, Lisp_Object face_name, int signal_p) 2069lface_from_face_name_no_resolve (struct frame *f, Lisp_Object face_name,
2070 int signal_p)
2063{ 2071{
2064 Lisp_Object lface; 2072 Lisp_Object lface;
2065 2073
@@ -2101,7 +2109,8 @@ lface_from_face_name (struct frame *f, Lisp_Object face_name, int signal_p)
2101 Otherwise, value is zero if FACE_NAME is not a face. */ 2109 Otherwise, value is zero if FACE_NAME is not a face. */
2102 2110
2103static inline int 2111static inline int
2104get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name, Lisp_Object *attrs, int signal_p) 2112get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name,
2113 Lisp_Object *attrs, int signal_p)
2105{ 2114{
2106 Lisp_Object lface; 2115 Lisp_Object lface;
2107 2116
@@ -2122,7 +2131,9 @@ get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name, Lisp_Obje
2122 Otherwise, value is zero if FACE_NAME is not a face. */ 2131 Otherwise, value is zero if FACE_NAME is not a face. */
2123 2132
2124static inline int 2133static inline int
2125get_lface_attributes (struct frame *f, Lisp_Object face_name, Lisp_Object *attrs, int signal_p, struct named_merge_point *named_merge_points) 2134get_lface_attributes (struct frame *f, Lisp_Object face_name,
2135 Lisp_Object *attrs, int signal_p,
2136 struct named_merge_point *named_merge_points)
2126{ 2137{
2127 Lisp_Object face_remapping; 2138 Lisp_Object face_remapping;
2128 2139
@@ -2165,7 +2176,7 @@ lface_fully_specified_p (Lisp_Object *attrs)
2165 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) 2176 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
2166 if (i != LFACE_FONT_INDEX && i != LFACE_INHERIT_INDEX) 2177 if (i != LFACE_FONT_INDEX && i != LFACE_INHERIT_INDEX)
2167 if ((UNSPECIFIEDP (attrs[i]) || IGNORE_DEFFACE_P (attrs[i]))) 2178 if ((UNSPECIFIEDP (attrs[i]) || IGNORE_DEFFACE_P (attrs[i])))
2168 break; 2179 break;
2169 2180
2170 return i == LFACE_VECTOR_SIZE; 2181 return i == LFACE_VECTOR_SIZE;
2171} 2182}
@@ -2178,7 +2189,8 @@ lface_fully_specified_p (Lisp_Object *attrs)
2178 of FORCE_P. */ 2189 of FORCE_P. */
2179 2190
2180static int 2191static int
2181set_lface_from_font (struct frame *f, Lisp_Object lface, Lisp_Object font_object, int force_p) 2192set_lface_from_font (struct frame *f, Lisp_Object lface,
2193 Lisp_Object font_object, int force_p)
2182{ 2194{
2183 Lisp_Object val; 2195 Lisp_Object val;
2184 struct font *font = XFONT_OBJECT (font_object); 2196 struct font *font = XFONT_OBJECT (font_object);
@@ -2288,7 +2300,8 @@ merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid)
2288 other places. */ 2300 other places. */
2289 2301
2290static inline void 2302static inline void
2291merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, struct named_merge_point *named_merge_points) 2303merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to,
2304 struct named_merge_point *named_merge_points)
2292{ 2305{
2293 int i; 2306 int i;
2294 2307
@@ -2355,7 +2368,8 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, struct
2355 merging succeeded. */ 2368 merging succeeded. */
2356 2369
2357static int 2370static int
2358merge_named_face (struct frame *f, Lisp_Object face_name, Lisp_Object *to, struct named_merge_point *named_merge_points) 2371merge_named_face (struct frame *f, Lisp_Object face_name, Lisp_Object *to,
2372 struct named_merge_point *named_merge_points)
2359{ 2373{
2360 struct named_merge_point named_merge_point; 2374 struct named_merge_point named_merge_point;
2361 2375
@@ -2405,7 +2419,8 @@ merge_named_face (struct frame *f, Lisp_Object face_name, Lisp_Object *to, struc
2405 specifications. */ 2419 specifications. */
2406 2420
2407static int 2421static int
2408merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to, int err_msgs, struct named_merge_point *named_merge_points) 2422merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to,
2423 int err_msgs, struct named_merge_point *named_merge_points)
2409{ 2424{
2410 int ok = 1; /* Succeed without an error? */ 2425 int ok = 1; /* Succeed without an error? */
2411 2426
@@ -2836,7 +2851,7 @@ FRAME 0 means change the face on all frames, and change the default
2836 The value of that attribute will be inherited from some other 2851 The value of that attribute will be inherited from some other
2837 face during face merging. See internal_merge_in_global_face. */ 2852 face during face merging. See internal_merge_in_global_face. */
2838 if (UNSPECIFIEDP (value)) 2853 if (UNSPECIFIEDP (value))
2839 value = Qignore_defface; 2854 value = QCignore_defface;
2840 } 2855 }
2841 else 2856 else
2842 { 2857 {
@@ -2883,7 +2898,8 @@ FRAME 0 means change the face on all frames, and change the default
2883 { 2898 {
2884 /* The default face must have an absolute size. */ 2899 /* The default face must have an absolute size. */
2885 if (!INTEGERP (value) || XINT (value) <= 0) 2900 if (!INTEGERP (value) || XINT (value) <= 0)
2886 signal_error ("Default face height not absolute and positive", value); 2901 signal_error ("Default face height not absolute and positive",
2902 value);
2887 } 2903 }
2888 else 2904 else
2889 { 2905 {
@@ -2893,7 +2909,8 @@ FRAME 0 means change the face on all frames, and change the default
2893 make_number (10), 2909 make_number (10),
2894 Qnil); 2910 Qnil);
2895 if (!INTEGERP (test) || XINT (test) <= 0) 2911 if (!INTEGERP (test) || XINT (test) <= 0)
2896 signal_error ("Face height does not produce a positive integer", value); 2912 signal_error ("Face height does not produce a positive integer",
2913 value);
2897 } 2914 }
2898 } 2915 }
2899 2916
@@ -2972,7 +2989,7 @@ FRAME 0 means change the face on all frames, and change the default
2972 int valid_p; 2989 int valid_p;
2973 2990
2974 /* Allow t meaning a simple box of width 1 in foreground color 2991 /* Allow t meaning a simple box of width 1 in foreground color
2975 of the face. */ 2992 of the face. */
2976 if (EQ (value, Qt)) 2993 if (EQ (value, Qt))
2977 value = make_number (1); 2994 value = make_number (1);
2978 2995
@@ -3317,7 +3334,8 @@ FRAME 0 means change the face on all frames, and change the default
3317 has been assigned the value NEW_VALUE. */ 3334 has been assigned the value NEW_VALUE. */
3318 3335
3319void 3336void
3320update_face_from_frame_parameter (struct frame *f, Lisp_Object param, Lisp_Object new_value) 3337update_face_from_frame_parameter (struct frame *f, Lisp_Object param,
3338 Lisp_Object new_value)
3321{ 3339{
3322 Lisp_Object face = Qnil; 3340 Lisp_Object face = Qnil;
3323 Lisp_Object lface; 3341 Lisp_Object lface;
@@ -3631,7 +3649,7 @@ the only relative value that users see is `unspecified'.
3631However, for :height, floating point values are also relative. */) 3649However, for :height, floating point values are also relative. */)
3632 (Lisp_Object attribute, Lisp_Object value) 3650 (Lisp_Object attribute, Lisp_Object value)
3633{ 3651{
3634 if (EQ (value, Qunspecified) || (EQ (value, Qignore_defface))) 3652 if (EQ (value, Qunspecified) || (EQ (value, QCignore_defface)))
3635 return Qt; 3653 return Qt;
3636 else if (EQ (attribute, QCheight)) 3654 else if (EQ (attribute, QCheight))
3637 return INTEGERP (value) ? Qnil : Qt; 3655 return INTEGERP (value) ? Qnil : Qt;
@@ -3646,7 +3664,7 @@ If VALUE1 or VALUE2 are absolute (see `face-attribute-relative-p'), then
3646the result will be absolute, otherwise it will be relative. */) 3664the result will be absolute, otherwise it will be relative. */)
3647 (Lisp_Object attribute, Lisp_Object value1, Lisp_Object value2) 3665 (Lisp_Object attribute, Lisp_Object value1, Lisp_Object value2)
3648{ 3666{
3649 if (EQ (value1, Qunspecified) || EQ (value1, Qignore_defface)) 3667 if (EQ (value1, Qunspecified) || EQ (value1, QCignore_defface))
3650 return value2; 3668 return value2;
3651 else if (EQ (attribute, QCheight)) 3669 else if (EQ (attribute, QCheight))
3652 return merge_face_heights (value1, value2, value1); 3670 return merge_face_heights (value1, value2, value1);
@@ -4050,7 +4068,7 @@ lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2)
4050 xassert (lface_fully_specified_p (lface1) 4068 xassert (lface_fully_specified_p (lface1)
4051 && lface_fully_specified_p (lface2)); 4069 && lface_fully_specified_p (lface2));
4052 return (xstrcasecmp (SSDATA (lface1[LFACE_FAMILY_INDEX]), 4070 return (xstrcasecmp (SSDATA (lface1[LFACE_FAMILY_INDEX]),
4053 SSDATA (lface2[LFACE_FAMILY_INDEX])) == 0 4071 SSDATA (lface2[LFACE_FAMILY_INDEX])) == 0
4054 && xstrcasecmp (SSDATA (lface1[LFACE_FOUNDRY_INDEX]), 4072 && xstrcasecmp (SSDATA (lface1[LFACE_FOUNDRY_INDEX]),
4055 SSDATA (lface2[LFACE_FOUNDRY_INDEX])) == 0 4073 SSDATA (lface2[LFACE_FOUNDRY_INDEX])) == 0
4056 && EQ (lface1[LFACE_HEIGHT_INDEX], lface2[LFACE_HEIGHT_INDEX]) 4074 && EQ (lface1[LFACE_HEIGHT_INDEX], lface2[LFACE_HEIGHT_INDEX])
@@ -4062,7 +4080,7 @@ lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2)
4062 || (STRINGP (lface1[LFACE_FONTSET_INDEX]) 4080 || (STRINGP (lface1[LFACE_FONTSET_INDEX])
4063 && STRINGP (lface2[LFACE_FONTSET_INDEX]) 4081 && STRINGP (lface2[LFACE_FONTSET_INDEX])
4064 && ! xstrcasecmp (SSDATA (lface1[LFACE_FONTSET_INDEX]), 4082 && ! xstrcasecmp (SSDATA (lface1[LFACE_FONTSET_INDEX]),
4065 SSDATA (lface2[LFACE_FONTSET_INDEX])))) 4083 SSDATA (lface2[LFACE_FONTSET_INDEX]))))
4066 ); 4084 );
4067} 4085}
4068 4086
@@ -4167,10 +4185,10 @@ color_distance (XColor *x, XColor *y)
4167 /* This formula is from a paper title `Colour metric' by Thiadmer Riemersma. 4185 /* This formula is from a paper title `Colour metric' by Thiadmer Riemersma.
4168 Quoting from that paper: 4186 Quoting from that paper:
4169 4187
4170 This formula has results that are very close to L*u*v* (with the 4188 This formula has results that are very close to L*u*v* (with the
4171 modified lightness curve) and, more importantly, it is a more even 4189 modified lightness curve) and, more importantly, it is a more even
4172 algorithm: it does not have a range of colours where it suddenly 4190 algorithm: it does not have a range of colours where it suddenly
4173 gives far from optimal results. 4191 gives far from optimal results.
4174 4192
4175 See <http://www.compuphase.com/cmetric.htm> for more info. */ 4193 See <http://www.compuphase.com/cmetric.htm> for more info. */
4176 4194
@@ -4693,7 +4711,8 @@ face_with_height (struct frame *f, int face_id, int height)
4693 default face. FACE_ID is assumed to be already realized. */ 4711 default face. FACE_ID is assumed to be already realized. */
4694 4712
4695int 4713int
4696lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id, int signal_p) 4714lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id,
4715 int signal_p)
4697{ 4716{
4698 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 4717 Lisp_Object attrs[LFACE_VECTOR_SIZE];
4699 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; 4718 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
@@ -4749,7 +4768,8 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector,
4749 \(2) `close in spirit' to what the attributes specify, if not exact. */ 4768 \(2) `close in spirit' to what the attributes specify, if not exact. */
4750 4769
4751static int 4770static int
4752x_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face *def_face) 4771x_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs,
4772 struct face *def_face)
4753{ 4773{
4754 Lisp_Object *def_attrs = def_face->lface; 4774 Lisp_Object *def_attrs = def_face->lface;
4755 4775
@@ -4850,7 +4870,8 @@ x_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face *
4850 substitution of a `dim' face for italic. */ 4870 substitution of a `dim' face for italic. */
4851 4871
4852static int 4872static int
4853tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face *def_face) 4873tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs,
4874 struct face *def_face)
4854{ 4875{
4855 int weight; 4876 int weight;
4856 Lisp_Object val, fg, bg; 4877 Lisp_Object val, fg, bg;
@@ -5002,7 +5023,8 @@ tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face
5002 /* See if the capabilities we selected above are supported, with the 5023 /* See if the capabilities we selected above are supported, with the
5003 given colors. */ 5024 given colors. */
5004 if (test_caps != 0 && 5025 if (test_caps != 0 &&
5005 ! tty_capable_p (FRAME_TTY (f), test_caps, fg_tty_color.pixel, bg_tty_color.pixel)) 5026 ! tty_capable_p (FRAME_TTY (f), test_caps, fg_tty_color.pixel,
5027 bg_tty_color.pixel))
5006 return 0; 5028 return 0;
5007 5029
5008 5030
@@ -5274,8 +5296,8 @@ realize_basic_faces (struct frame *f)
5274 { 5296 {
5275 FRAME_FACE_CACHE (f)->menu_face_changed_p = 0; 5297 FRAME_FACE_CACHE (f)->menu_face_changed_p = 0;
5276#ifdef USE_X_TOOLKIT 5298#ifdef USE_X_TOOLKIT
5277 if (FRAME_WINDOW_P (f)) 5299 if (FRAME_WINDOW_P (f))
5278 x_update_menu_appearance (f); 5300 x_update_menu_appearance (f);
5279#endif 5301#endif
5280 } 5302 }
5281 5303
@@ -5395,14 +5417,14 @@ realize_default_face (struct frame *f)
5395 if (FRAME_X_P (f) && face->font != FRAME_FONT (f)) 5417 if (FRAME_X_P (f) && face->font != FRAME_FONT (f))
5396 { 5418 {
5397 /* This can happen when making a frame on a display that does 5419 /* This can happen when making a frame on a display that does
5398 not support the default font. */ 5420 not support the default font. */
5399 if (!face->font) 5421 if (!face->font)
5400 return 0; 5422 return 0;
5401 5423
5402 /* Otherwise, the font specified for the frame was not 5424 /* Otherwise, the font specified for the frame was not
5403 acceptable as a font for the default face (perhaps because 5425 acceptable as a font for the default face (perhaps because
5404 auto-scaled fonts are rejected), so we must adjust the frame 5426 auto-scaled fonts are rejected), so we must adjust the frame
5405 font. */ 5427 font. */
5406 x_set_font (f, LFACE_FONT (lface), Qnil); 5428 x_set_font (f, LFACE_FONT (lface), Qnil);
5407 } 5429 }
5408#endif /* HAVE_X_WINDOWS */ 5430#endif /* HAVE_X_WINDOWS */
@@ -5493,7 +5515,8 @@ realize_face (struct face_cache *cache, Lisp_Object *attrs, int former_face_id)
5493 no-font. */ 5515 no-font. */
5494 5516
5495static struct face * 5517static struct face *
5496realize_non_ascii_face (struct frame *f, Lisp_Object font_object, struct face *base_face) 5518realize_non_ascii_face (struct frame *f, Lisp_Object font_object,
5519 struct face *base_face)
5497{ 5520{
5498 struct face_cache *cache = FRAME_FACE_CACHE (f); 5521 struct face_cache *cache = FRAME_FACE_CACHE (f);
5499 struct face *face; 5522 struct face *face;
@@ -5612,7 +5635,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs)
5612 else if (INTEGERP (box)) 5635 else if (INTEGERP (box))
5613 { 5636 {
5614 /* Simple box of specified line width in foreground color of the 5637 /* Simple box of specified line width in foreground color of the
5615 face. */ 5638 face. */
5616 xassert (XINT (box) != 0); 5639 xassert (XINT (box) != 0);
5617 face->box = FACE_SIMPLE_BOX; 5640 face->box = FACE_SIMPLE_BOX;
5618 face->box_line_width = XINT (box); 5641 face->box_line_width = XINT (box);
@@ -5734,7 +5757,8 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs)
5734 default foreground/background colors. */ 5757 default foreground/background colors. */
5735 5758
5736static void 5759static void
5737map_tty_color (struct frame *f, struct face *face, enum lface_attribute_index idx, int *defaulted) 5760map_tty_color (struct frame *f, struct face *face,
5761 enum lface_attribute_index idx, int *defaulted)
5738{ 5762{
5739 Lisp_Object frame, color, def; 5763 Lisp_Object frame, color, def;
5740 int foreground_p = idx == LFACE_FOREGROUND_INDEX; 5764 int foreground_p = idx == LFACE_FOREGROUND_INDEX;
@@ -5790,7 +5814,7 @@ map_tty_color (struct frame *f, struct face *face, enum lface_attribute_index id
5790 face->lface[idx] = tty_color_name (f, pixel); 5814 face->lface[idx] = tty_color_name (f, pixel);
5791 *defaulted = 1; 5815 *defaulted = 1;
5792 } 5816 }
5793 } 5817 }
5794#endif /* MSDOS */ 5818#endif /* MSDOS */
5795 } 5819 }
5796 5820
@@ -6451,7 +6475,7 @@ syms_of_xfaces (void)
6451 DEFSYM (Qbackground_color, "background-color"); 6475 DEFSYM (Qbackground_color, "background-color");
6452 DEFSYM (Qforeground_color, "foreground-color"); 6476 DEFSYM (Qforeground_color, "foreground-color");
6453 DEFSYM (Qunspecified, "unspecified"); 6477 DEFSYM (Qunspecified, "unspecified");
6454 DEFSYM (Qignore_defface, ":ignore-defface"); 6478 DEFSYM (QCignore_defface, ":ignore-defface");
6455 6479
6456 DEFSYM (Qface_alias, "face-alias"); 6480 DEFSYM (Qface_alias, "face-alias");
6457 DEFSYM (Qdefault, "default"); 6481 DEFSYM (Qdefault, "default");
@@ -6589,7 +6613,7 @@ face definitions. For instance, the mode my-mode could define a face
6589`my-mode-default', and then in the mode setup function, do: 6613`my-mode-default', and then in the mode setup function, do:
6590 6614
6591 (set (make-local-variable 'face-remapping-alist) 6615 (set (make-local-variable 'face-remapping-alist)
6592 '((default my-mode-default)))). 6616 '((default my-mode-default)))).
6593 6617
6594Because Emacs normally only redraws screen areas when the underlying 6618Because Emacs normally only redraws screen areas when the underlying
6595buffer contents change, you may need to call `redraw-display' after 6619buffer contents change, you may need to call `redraw-display' after