aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mackenzie2011-10-28 14:35:39 +0000
committerAlan Mackenzie2011-10-28 14:35:39 +0000
commit93b5b3bdc8b734132c530acd6ffae1196c0865bc (patch)
treeda8ed72a56bfbf65d6f3cd9bdc3fa5d123dc4873 /src
parent020716e178cdae443a3630c4307023cb3fc4c350 (diff)
parentbc97a826f8ea89a269f6043be3148930f023e2b2 (diff)
downloademacs-93b5b3bdc8b734132c530acd6ffae1196c0865bc.tar.gz
emacs-93b5b3bdc8b734132c530acd6ffae1196c0865bc.zip
Boring merge from savannah.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog83
-rw-r--r--src/dispextern.h1
-rw-r--r--src/emacs.c1
-rw-r--r--src/gnutls.c325
-rw-r--r--src/gnutls.h5
-rw-r--r--src/image.c2
-rw-r--r--src/intervals.c2
-rw-r--r--src/keyboard.c140
-rw-r--r--src/lisp.h20
-rw-r--r--src/process.c8
-rw-r--r--src/sysdep.c5
-rw-r--r--src/w32.c6
-rw-r--r--src/w32.h1
-rw-r--r--src/w32fns.c15
-rw-r--r--src/w32font.c153
-rw-r--r--src/w32reg.c7
-rw-r--r--src/window.c40
17 files changed, 506 insertions, 308 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3f9b5beeab6..50fc953024a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,86 @@
12011-10-28 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * lisp.h (struct Lisp_Symbol): Update comments.
4
52011-10-28 Juanma Barranquero <lekktu@gmail.com>
6
7 * w32font.c (w32_load_unicows_or_gdi32): Add missing return.
8
92011-10-28 Eli Zaretskii <eliz@gnu.org>
10
11 Fix Emacs on Windows 9X (bug#8562). Thanks to oslsachem
12 <oslsachem@gmail.com> for helping to debug this.
13
14 * w32font.c (g_b_init_is_w9x, g_b_init_get_outline_metrics_w)
15 (g_b_init_get_text_metrics_w, g_b_init_get_glyph_outline_w)
16 (g_b_init_get_glyph_outline_w): New static variables.
17 (GetOutlineTextMetricsW_Proc, GetTextMetricsW_Proc)
18 (GetGlyphOutlineW_Proc): New typedefs.
19 (w32_load_unicows_or_gdi32, get_outline_metrics_w)
20 (get_text_metrics_w, get_glyph_outline_w, globals_of_w32font):
21 New functions.
22 (w32font_open_internal, compute_metrics):
23 Call get_outline_metrics_w, get_text_metrics_w, and get_glyph_outline_w
24 instead of calling the "wide" APIs directly.
25
26 * emacs.c (main) [HAVE_NTGUI]: Call globals_of_w32font.
27
28 * w32.h (syms_of_w32font): Add prototype.
29
302011-10-27 Juanma Barranquero <lekktu@gmail.com>
31
32 * window.c (Fframe_root_window, Fframe_first_window, Fwindow_end)
33 (Fframe_selected_window, Ftemp_output_buffer_show, Fnext_window)
34 (Fdelete_window_internal, Fwindow_parameters): Fix typos in docstrings.
35 (Fmove_to_window_line): Doc fix.
36
372011-10-27 Chong Yidong <cyd@gnu.org>
38
39 * process.c (make_process): Set gnutls_state to NULL.
40
41 * gnutls.c (emacs_gnutls_deinit): Deinit the gnutls_state if it is
42 non-NULL, regardless of GNUTLS_INITSTAGE.
43 (Fgnutls_boot): Cleanups. Call emacs_gnutls_deinit if we signal
44 an error. Set process slots as soon as we allocate them.
45
46 * gnutls.h (GNUTLS_LOG, GNUTLS_LOG2): Fix macros.
47
482011-10-27 Chong Yidong <cyd@gnu.org>
49
50 * gnutls.c (emacs_gnutls_deinit): New function.
51 Deallocate credentials structures as well as calling gnutls_deinit.
52 (Fgnutls_deinit, Fgnutls_boot): Use it.
53
54 * process.c (make_process): Initialize GnuTLS credentials to NULL.
55 (deactivate_process): Call emacs_gnutls_deinit.
56
572011-10-27 Juanma Barranquero <lekktu@gmail.com>
58
59 * image.c (x_create_x_image_and_pixmap):
60 * w32.c (sys_rename, w32_delayed_load):
61 * w32font.c (fill_in_logfont):
62 * w32reg.c (x_get_string_resource): Silence compiler warnings.
63
642011-10-26 Juanma Barranquero <lekktu@gmail.com>
65
66 * w32fns.c (w32_default_color_map): New function,
67 extracted from Fw32_default_color_map.
68 (Fw32_default_color_map, Fx_open_connection): Use it. (Bug#9785)
69
702011-10-25 Paul Eggert <eggert@cs.ucla.edu>
71
72 * dispextern.h (Fcontrolling_tty_p): New decl (Bug#6649 part 2).
73
742011-10-25 Stefan Monnier <monnier@iro.umontreal.ca>
75
76 * keyboard.c (test_undefined): New function (bug#9751).
77 (read_key_sequence): Use it to detect when a key is bound to `undefined'.
78
792011-10-25 Enami Tsugutomo <tsugutomo.enami@jp.sony.com>
80
81 * sysdep.c (init_sys_modes): Fix the check for the controlling
82 terminal (Bug#6649).
83
12011-10-20 Eli Zaretskii <eliz@gnu.org> 842011-10-20 Eli Zaretskii <eliz@gnu.org>
2 85
3 * dispextern.h (struct bidi_it): New member next_en_type. 86 * dispextern.h (struct bidi_it): New member next_en_type.
diff --git a/src/dispextern.h b/src/dispextern.h
index dd5f67d2d10..5c60a5499da 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3346,6 +3346,7 @@ extern int tty_capable_p (struct tty_display_info *, unsigned, unsigned long, un
3346extern void set_tty_color_mode (struct tty_display_info *, struct frame *); 3346extern void set_tty_color_mode (struct tty_display_info *, struct frame *);
3347extern struct terminal *get_named_tty (const char *); 3347extern struct terminal *get_named_tty (const char *);
3348EXFUN (Ftty_type, 1); 3348EXFUN (Ftty_type, 1);
3349EXFUN (Fcontrolling_tty_p, 1);
3349extern void create_tty_output (struct frame *); 3350extern void create_tty_output (struct frame *);
3350extern struct terminal *init_tty (const char *, const char *, int); 3351extern struct terminal *init_tty (const char *, const char *, int);
3351extern void tty_append_glyph (struct it *); 3352extern void tty_append_glyph (struct it *);
diff --git a/src/emacs.c b/src/emacs.c
index 073156bb0c9..12be7bc0808 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1591,6 +1591,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1591 /* Initialization that must be done even if the global variable 1591 /* Initialization that must be done even if the global variable
1592 initialized is non zero. */ 1592 initialized is non zero. */
1593#ifdef HAVE_NTGUI 1593#ifdef HAVE_NTGUI
1594 globals_of_w32font ();
1594 globals_of_w32fns (); 1595 globals_of_w32fns ();
1595 globals_of_w32menu (); 1596 globals_of_w32menu ();
1596 globals_of_w32select (); 1597 globals_of_w32select ();
diff --git a/src/gnutls.c b/src/gnutls.c
index 0743ef3f4ee..500f09432b1 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -464,6 +464,44 @@ gnutls_make_error (int err)
464 return make_number (err); 464 return make_number (err);
465} 465}
466 466
467Lisp_Object
468emacs_gnutls_deinit (Lisp_Object proc)
469{
470 int log_level;
471
472 CHECK_PROCESS (proc);
473
474 if (XPROCESS (proc)->gnutls_p == 0)
475 return Qnil;
476
477 log_level = XPROCESS (proc)->gnutls_log_level;
478
479 if (XPROCESS (proc)->gnutls_x509_cred)
480 {
481 GNUTLS_LOG (2, log_level, "Deallocating x509 credentials");
482 fn_gnutls_certificate_free_credentials (XPROCESS (proc)->gnutls_x509_cred);
483 XPROCESS (proc)->gnutls_x509_cred = NULL;
484 }
485
486 if (XPROCESS (proc)->gnutls_anon_cred)
487 {
488 GNUTLS_LOG (2, log_level, "Deallocating anon credentials");
489 fn_gnutls_anon_free_client_credentials (XPROCESS (proc)->gnutls_anon_cred);
490 XPROCESS (proc)->gnutls_anon_cred = NULL;
491 }
492
493 if (XPROCESS (proc)->gnutls_state)
494 {
495 fn_gnutls_deinit (XPROCESS (proc)->gnutls_state);
496 XPROCESS (proc)->gnutls_state = NULL;
497 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT)
498 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1;
499 }
500
501 XPROCESS (proc)->gnutls_p = 0;
502 return Qt;
503}
504
467DEFUN ("gnutls-get-initstage", Fgnutls_get_initstage, Sgnutls_get_initstage, 1, 1, 0, 505DEFUN ("gnutls-get-initstage", Fgnutls_get_initstage, Sgnutls_get_initstage, 1, 1, 0,
468 doc: /* Return the GnuTLS init stage of process PROC. 506 doc: /* Return the GnuTLS init stage of process PROC.
469See also `gnutls-boot'. */) 507See also `gnutls-boot'. */)
@@ -551,18 +589,7 @@ DEFUN ("gnutls-deinit", Fgnutls_deinit, Sgnutls_deinit, 1, 1, 0,
551See also `gnutls-init'. */) 589See also `gnutls-init'. */)
552 (Lisp_Object proc) 590 (Lisp_Object proc)
553{ 591{
554 gnutls_session_t state; 592 return emacs_gnutls_deinit (proc);
555
556 CHECK_PROCESS (proc);
557 state = XPROCESS (proc)->gnutls_state;
558
559 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT)
560 {
561 fn_gnutls_deinit (state);
562 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1;
563 }
564
565 return Qt;
566} 593}
567 594
568DEFUN ("gnutls-available-p", Fgnutls_available_p, Sgnutls_available_p, 0, 0, 0, 595DEFUN ("gnutls-available-p", Fgnutls_available_p, Sgnutls_available_p, 0, 0, 0,
@@ -622,7 +649,7 @@ emacs_gnutls_global_deinit (void)
622 649
623DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, 650DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0,
624 doc: /* Initialize GnuTLS client for process PROC with TYPE+PROPLIST. 651 doc: /* Initialize GnuTLS client for process PROC with TYPE+PROPLIST.
625Currently only client mode is supported. Returns a success/failure 652Currently only client mode is supported. Return a success/failure
626value you can check with `gnutls-errorp'. 653value you can check with `gnutls-errorp'.
627 654
628TYPE is a symbol, either `gnutls-anon' or `gnutls-x509pki'. 655TYPE is a symbol, either `gnutls-anon' or `gnutls-x509pki'.
@@ -673,23 +700,13 @@ one trustfile (usually a CA bundle). */)
673 (Lisp_Object proc, Lisp_Object type, Lisp_Object proplist) 700 (Lisp_Object proc, Lisp_Object type, Lisp_Object proplist)
674{ 701{
675 int ret = GNUTLS_E_SUCCESS; 702 int ret = GNUTLS_E_SUCCESS;
676
677 int max_log_level = 0; 703 int max_log_level = 0;
678 704
679 /* TODO: GNUTLS_X509_FMT_DER is also an option. */
680 int file_format = GNUTLS_X509_FMT_PEM;
681
682 unsigned int gnutls_verify_flags = GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT;
683 gnutls_x509_crt_t gnutls_verify_cert;
684 unsigned int gnutls_verify_cert_list_size;
685 const gnutls_datum_t *gnutls_verify_cert_list;
686
687 gnutls_session_t state; 705 gnutls_session_t state;
688 gnutls_certificate_credentials_t x509_cred; 706 gnutls_certificate_credentials_t x509_cred = NULL;
689 gnutls_anon_client_credentials_t anon_cred; 707 gnutls_anon_client_credentials_t anon_cred = NULL;
690 Lisp_Object global_init; 708 Lisp_Object global_init;
691 char const *priority_string_ptr = "NORMAL"; /* default priority string. */ 709 char const *priority_string_ptr = "NORMAL"; /* default priority string. */
692 Lisp_Object tail;
693 unsigned int peer_verification; 710 unsigned int peer_verification;
694 char* c_hostname; 711 char* c_hostname;
695 712
@@ -701,7 +718,6 @@ one trustfile (usually a CA bundle). */)
701 /* Lisp_Object callbacks; */ 718 /* Lisp_Object callbacks; */
702 Lisp_Object loglevel; 719 Lisp_Object loglevel;
703 Lisp_Object hostname; 720 Lisp_Object hostname;
704 Lisp_Object verify_flags;
705 /* Lisp_Object verify_error; */ 721 /* Lisp_Object verify_error; */
706 Lisp_Object verify_hostname_error; 722 Lisp_Object verify_hostname_error;
707 Lisp_Object prime_bits; 723 Lisp_Object prime_bits;
@@ -716,26 +732,25 @@ one trustfile (usually a CA bundle). */)
716 return gnutls_make_error (GNUTLS_EMACS_ERROR_NOT_LOADED); 732 return gnutls_make_error (GNUTLS_EMACS_ERROR_NOT_LOADED);
717 } 733 }
718 734
735 if (!EQ (type, Qgnutls_x509pki) && !EQ (type, Qgnutls_anon))
736 {
737 error ("Invalid GnuTLS credential type");
738 return gnutls_make_error (GNUTLS_EMACS_ERROR_INVALID_TYPE);
739 }
740
719 hostname = Fplist_get (proplist, QCgnutls_bootprop_hostname); 741 hostname = Fplist_get (proplist, QCgnutls_bootprop_hostname);
720 priority_string = Fplist_get (proplist, QCgnutls_bootprop_priority); 742 priority_string = Fplist_get (proplist, QCgnutls_bootprop_priority);
721 trustfiles = Fplist_get (proplist, QCgnutls_bootprop_trustfiles); 743 trustfiles = Fplist_get (proplist, QCgnutls_bootprop_trustfiles);
722 keylist = Fplist_get (proplist, QCgnutls_bootprop_keylist); 744 keylist = Fplist_get (proplist, QCgnutls_bootprop_keylist);
723 crlfiles = Fplist_get (proplist, QCgnutls_bootprop_crlfiles); 745 crlfiles = Fplist_get (proplist, QCgnutls_bootprop_crlfiles);
724 /* callbacks = Fplist_get (proplist, QCgnutls_bootprop_callbacks); */
725 loglevel = Fplist_get (proplist, QCgnutls_bootprop_loglevel); 746 loglevel = Fplist_get (proplist, QCgnutls_bootprop_loglevel);
726 verify_flags = Fplist_get (proplist, QCgnutls_bootprop_verify_flags);
727 /* verify_error = Fplist_get (proplist, QCgnutls_bootprop_verify_error); */
728 verify_hostname_error = Fplist_get (proplist, QCgnutls_bootprop_verify_hostname_error); 747 verify_hostname_error = Fplist_get (proplist, QCgnutls_bootprop_verify_hostname_error);
729 prime_bits = Fplist_get (proplist, QCgnutls_bootprop_min_prime_bits); 748 prime_bits = Fplist_get (proplist, QCgnutls_bootprop_min_prime_bits);
730 749
731 if (!STRINGP (hostname)) 750 if (!STRINGP (hostname))
732 error ("gnutls-boot: invalid :hostname parameter"); 751 error ("gnutls-boot: invalid :hostname parameter");
733
734 c_hostname = SSDATA (hostname); 752 c_hostname = SSDATA (hostname);
735 753
736 state = XPROCESS (proc)->gnutls_state;
737 XPROCESS (proc)->gnutls_p = 1;
738
739 if (NUMBERP (loglevel)) 754 if (NUMBERP (loglevel))
740 { 755 {
741 fn_gnutls_global_set_log_function (gnutls_log_function); 756 fn_gnutls_global_set_log_function (gnutls_log_function);
@@ -749,82 +764,56 @@ one trustfile (usually a CA bundle). */)
749 if (! NILP (Fgnutls_errorp (global_init))) 764 if (! NILP (Fgnutls_errorp (global_init)))
750 return global_init; 765 return global_init;
751 766
752 /* deinit and free resources. */ 767 /* Before allocating new credentials, deallocate any credentials
753 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_CRED_ALLOC) 768 that PROC might already have. */
754 { 769 emacs_gnutls_deinit (proc);
755 GNUTLS_LOG (1, max_log_level, "deallocating credentials");
756
757 if (EQ (type, Qgnutls_x509pki))
758 {
759 GNUTLS_LOG (2, max_log_level, "deallocating x509 credentials");
760 x509_cred = XPROCESS (proc)->gnutls_x509_cred;
761 fn_gnutls_certificate_free_credentials (x509_cred);
762 }
763 else if (EQ (type, Qgnutls_anon))
764 {
765 GNUTLS_LOG (2, max_log_level, "deallocating anon credentials");
766 anon_cred = XPROCESS (proc)->gnutls_anon_cred;
767 fn_gnutls_anon_free_client_credentials (anon_cred);
768 }
769 else
770 {
771 error ("unknown credential type");
772 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
773 }
774
775 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT)
776 {
777 GNUTLS_LOG (1, max_log_level, "deallocating x509 credentials");
778 Fgnutls_deinit (proc);
779 }
780 }
781 770
771 /* Mark PROC as a GnuTLS process. */
772 XPROCESS (proc)->gnutls_p = 1;
773 XPROCESS (proc)->gnutls_state = NULL;
774 XPROCESS (proc)->gnutls_x509_cred = NULL;
775 XPROCESS (proc)->gnutls_anon_cred = NULL;
776 XPROCESS (proc)->gnutls_cred_type = type;
782 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY; 777 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY;
783 778
784 GNUTLS_LOG (1, max_log_level, "allocating credentials"); 779 GNUTLS_LOG (1, max_log_level, "allocating credentials");
785
786 if (EQ (type, Qgnutls_x509pki)) 780 if (EQ (type, Qgnutls_x509pki))
787 { 781 {
782 Lisp_Object verify_flags;
783 unsigned int gnutls_verify_flags = GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT;
784
788 GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); 785 GNUTLS_LOG (2, max_log_level, "allocating x509 credentials");
789 x509_cred = XPROCESS (proc)->gnutls_x509_cred;
790 fn_gnutls_certificate_allocate_credentials (&x509_cred); 786 fn_gnutls_certificate_allocate_credentials (&x509_cred);
787 XPROCESS (proc)->gnutls_x509_cred = x509_cred;
791 788
789 verify_flags = Fplist_get (proplist, QCgnutls_bootprop_verify_flags);
792 if (NUMBERP (verify_flags)) 790 if (NUMBERP (verify_flags))
793 { 791 {
794 gnutls_verify_flags = XINT (verify_flags); 792 gnutls_verify_flags = XINT (verify_flags);
795 GNUTLS_LOG (2, max_log_level, "setting verification flags"); 793 GNUTLS_LOG (2, max_log_level, "setting verification flags");
796 } 794 }
797 else if (NILP (verify_flags)) 795 else if (NILP (verify_flags))
798 { 796 GNUTLS_LOG (2, max_log_level, "using default verification flags");
799 /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */
800 GNUTLS_LOG (2, max_log_level, "using default verification flags");
801 }
802 else 797 else
803 { 798 GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags");
804 /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */ 799
805 GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags");
806 }
807 fn_gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags); 800 fn_gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags);
808 } 801 }
809 else if (EQ (type, Qgnutls_anon)) 802 else /* Qgnutls_anon: */
810 { 803 {
811 GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); 804 GNUTLS_LOG (2, max_log_level, "allocating anon credentials");
812 anon_cred = XPROCESS (proc)->gnutls_anon_cred;
813 fn_gnutls_anon_allocate_client_credentials (&anon_cred); 805 fn_gnutls_anon_allocate_client_credentials (&anon_cred);
814 } 806 XPROCESS (proc)->gnutls_anon_cred = anon_cred;
815 else
816 {
817 error ("unknown credential type");
818 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
819 } 807 }
820 808
821 if (ret < GNUTLS_E_SUCCESS)
822 return gnutls_make_error (ret);
823
824 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_ALLOC; 809 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_ALLOC;
825 810
826 if (EQ (type, Qgnutls_x509pki)) 811 if (EQ (type, Qgnutls_x509pki))
827 { 812 {
813 /* TODO: GNUTLS_X509_FMT_DER is also an option. */
814 int file_format = GNUTLS_X509_FMT_PEM;
815 Lisp_Object tail;
816
828 for (tail = trustfiles; !NILP (tail); tail = Fcdr (tail)) 817 for (tail = trustfiles; !NILP (tail); tail = Fcdr (tail))
829 { 818 {
830 Lisp_Object trustfile = Fcar (tail); 819 Lisp_Object trustfile = Fcar (tail);
@@ -842,8 +831,8 @@ one trustfile (usually a CA bundle). */)
842 } 831 }
843 else 832 else
844 { 833 {
845 error ("Sorry, GnuTLS can't use non-string trustfile %s", 834 emacs_gnutls_deinit (proc);
846 SDATA (trustfile)); 835 error ("Invalid trustfile");
847 } 836 }
848 } 837 }
849 838
@@ -855,17 +844,15 @@ one trustfile (usually a CA bundle). */)
855 GNUTLS_LOG2 (1, max_log_level, "setting the CRL file: ", 844 GNUTLS_LOG2 (1, max_log_level, "setting the CRL file: ",
856 SSDATA (crlfile)); 845 SSDATA (crlfile));
857 ret = fn_gnutls_certificate_set_x509_crl_file 846 ret = fn_gnutls_certificate_set_x509_crl_file
858 (x509_cred, 847 (x509_cred, SSDATA (crlfile), file_format);
859 SSDATA (crlfile),
860 file_format);
861 848
862 if (ret < GNUTLS_E_SUCCESS) 849 if (ret < GNUTLS_E_SUCCESS)
863 return gnutls_make_error (ret); 850 return gnutls_make_error (ret);
864 } 851 }
865 else 852 else
866 { 853 {
867 error ("Sorry, GnuTLS can't use non-string CRL file %s", 854 emacs_gnutls_deinit (proc);
868 SDATA (crlfile)); 855 error ("Invalid CRL file");
869 } 856 }
870 } 857 }
871 858
@@ -880,45 +867,31 @@ one trustfile (usually a CA bundle). */)
880 GNUTLS_LOG2 (1, max_log_level, "setting the client cert file: ", 867 GNUTLS_LOG2 (1, max_log_level, "setting the client cert file: ",
881 SSDATA (certfile)); 868 SSDATA (certfile));
882 ret = fn_gnutls_certificate_set_x509_key_file 869 ret = fn_gnutls_certificate_set_x509_key_file
883 (x509_cred, 870 (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_format);
884 SSDATA (certfile),
885 SSDATA (keyfile),
886 file_format);
887 871
888 if (ret < GNUTLS_E_SUCCESS) 872 if (ret < GNUTLS_E_SUCCESS)
889 return gnutls_make_error (ret); 873 return gnutls_make_error (ret);
890 } 874 }
891 else 875 else
892 { 876 {
893 if (STRINGP (keyfile)) 877 emacs_gnutls_deinit (proc);
894 error ("Sorry, GnuTLS can't use non-string client cert file %s", 878 error (STRINGP (keyfile) ? "Invalid client cert file"
895 SDATA (certfile)); 879 : "Invalid client key file");
896 else
897 error ("Sorry, GnuTLS can't use non-string client key file %s",
898 SDATA (keyfile));
899 } 880 }
900 } 881 }
901 } 882 }
902 883
903 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES; 884 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES;
904
905 GNUTLS_LOG (1, max_log_level, "gnutls callbacks"); 885 GNUTLS_LOG (1, max_log_level, "gnutls callbacks");
906
907 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CALLBACKS; 886 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CALLBACKS;
908 887
909#ifdef HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY 888 /* Call gnutls_init here: */
910#else
911#endif
912 889
913 GNUTLS_LOG (1, max_log_level, "gnutls_init"); 890 GNUTLS_LOG (1, max_log_level, "gnutls_init");
914
915 ret = fn_gnutls_init (&state, GNUTLS_CLIENT); 891 ret = fn_gnutls_init (&state, GNUTLS_CLIENT);
916 892 XPROCESS (proc)->gnutls_state = state;
917 if (ret < GNUTLS_E_SUCCESS) 893 if (ret < GNUTLS_E_SUCCESS)
918 return gnutls_make_error (ret); 894 return gnutls_make_error (ret);
919
920 XPROCESS (proc)->gnutls_state = state;
921
922 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT; 895 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT;
923 896
924 if (STRINGP (priority_string)) 897 if (STRINGP (priority_string))
@@ -934,46 +907,25 @@ one trustfile (usually a CA bundle). */)
934 } 907 }
935 908
936 GNUTLS_LOG (1, max_log_level, "setting the priority string"); 909 GNUTLS_LOG (1, max_log_level, "setting the priority string");
937
938 ret = fn_gnutls_priority_set_direct (state, 910 ret = fn_gnutls_priority_set_direct (state,
939 priority_string_ptr, 911 priority_string_ptr,
940 NULL); 912 NULL);
941
942 if (ret < GNUTLS_E_SUCCESS) 913 if (ret < GNUTLS_E_SUCCESS)
943 return gnutls_make_error (ret); 914 return gnutls_make_error (ret);
944 915
945 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_PRIORITY; 916 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_PRIORITY;
946 917
947 if (!EQ (prime_bits, Qnil)) 918 if (INTEGERP (prime_bits))
948 { 919 fn_gnutls_dh_set_prime_bits (state, XUINT (prime_bits));
949 fn_gnutls_dh_set_prime_bits (state, XUINT (prime_bits));
950 }
951
952 if (EQ (type, Qgnutls_x509pki))
953 {
954 ret = fn_gnutls_credentials_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred);
955 }
956 else if (EQ (type, Qgnutls_anon))
957 {
958 ret = fn_gnutls_credentials_set (state, GNUTLS_CRD_ANON, anon_cred);
959 }
960 else
961 {
962 error ("unknown credential type");
963 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
964 }
965 920
921 ret = EQ (type, Qgnutls_x509pki)
922 ? fn_gnutls_credentials_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred)
923 : fn_gnutls_credentials_set (state, GNUTLS_CRD_ANON, anon_cred);
966 if (ret < GNUTLS_E_SUCCESS) 924 if (ret < GNUTLS_E_SUCCESS)
967 return gnutls_make_error (ret); 925 return gnutls_make_error (ret);
968 926
969 XPROCESS (proc)->gnutls_anon_cred = anon_cred;
970 XPROCESS (proc)->gnutls_x509_cred = x509_cred;
971 XPROCESS (proc)->gnutls_cred_type = type;
972
973 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET; 927 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET;
974
975 ret = emacs_gnutls_handshake (XPROCESS (proc)); 928 ret = emacs_gnutls_handshake (XPROCESS (proc));
976
977 if (ret < GNUTLS_E_SUCCESS) 929 if (ret < GNUTLS_E_SUCCESS)
978 return gnutls_make_error (ret); 930 return gnutls_make_error (ret);
979 931
@@ -984,69 +936,71 @@ one trustfile (usually a CA bundle). */)
984 gnutls_x509_crt_check_hostname() against :hostname. */ 936 gnutls_x509_crt_check_hostname() against :hostname. */
985 937
986 ret = fn_gnutls_certificate_verify_peers2 (state, &peer_verification); 938 ret = fn_gnutls_certificate_verify_peers2 (state, &peer_verification);
987
988 if (ret < GNUTLS_E_SUCCESS) 939 if (ret < GNUTLS_E_SUCCESS)
989 return gnutls_make_error (ret); 940 return gnutls_make_error (ret);
990 941
991 if (XINT (loglevel) > 0 && peer_verification & GNUTLS_CERT_INVALID) 942 if (XINT (loglevel) > 0 && peer_verification & GNUTLS_CERT_INVALID)
992 message ("%s certificate could not be verified.", 943 message ("%s certificate could not be verified.", c_hostname);
993 c_hostname); 944
994 945 if (peer_verification & GNUTLS_CERT_REVOKED)
995 if (peer_verification & GNUTLS_CERT_REVOKED) 946 GNUTLS_LOG2 (1, max_log_level, "certificate was revoked (CRL):",
996 GNUTLS_LOG2 (1, max_log_level, "certificate was revoked (CRL):", 947 c_hostname);
997 c_hostname); 948
998 949 if (peer_verification & GNUTLS_CERT_SIGNER_NOT_FOUND)
999 if (peer_verification & GNUTLS_CERT_SIGNER_NOT_FOUND) 950 GNUTLS_LOG2 (1, max_log_level, "certificate signer was not found:",
1000 GNUTLS_LOG2 (1, max_log_level, "certificate signer was not found:", 951 c_hostname);
1001 c_hostname); 952
1002 953 if (peer_verification & GNUTLS_CERT_SIGNER_NOT_CA)
1003 if (peer_verification & GNUTLS_CERT_SIGNER_NOT_CA) 954 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:", 955 c_hostname);
1005 c_hostname); 956
1006 957 if (peer_verification & GNUTLS_CERT_INSECURE_ALGORITHM)
1007 if (peer_verification & GNUTLS_CERT_INSECURE_ALGORITHM) 958 GNUTLS_LOG2 (1, max_log_level,
1008 GNUTLS_LOG2 (1, max_log_level, 959 "certificate was signed with an insecure algorithm:",
1009 "certificate was signed with an insecure algorithm:", 960 c_hostname);
1010 c_hostname); 961
1011 962 if (peer_verification & GNUTLS_CERT_NOT_ACTIVATED)
1012 if (peer_verification & GNUTLS_CERT_NOT_ACTIVATED) 963 GNUTLS_LOG2 (1, max_log_level, "certificate is not yet activated:",
1013 GNUTLS_LOG2 (1, max_log_level, "certificate is not yet activated:", 964 c_hostname);
1014 c_hostname); 965
1015 966 if (peer_verification & GNUTLS_CERT_EXPIRED)
1016 if (peer_verification & GNUTLS_CERT_EXPIRED) 967 GNUTLS_LOG2 (1, max_log_level, "certificate has expired:",
1017 GNUTLS_LOG2 (1, max_log_level, "certificate has expired:", 968 c_hostname);
1018 c_hostname); 969
1019 970 if (peer_verification != 0)
1020 if (peer_verification != 0) 971 {
1021 { 972 if (NILP (verify_hostname_error))
1022 if (NILP (verify_hostname_error)) 973 GNUTLS_LOG2 (1, max_log_level, "certificate validation failed:",
1023 { 974 c_hostname);
1024 GNUTLS_LOG2 (1, max_log_level, "certificate validation failed:", 975 else
1025 c_hostname); 976 {
1026 } 977 emacs_gnutls_deinit (proc);
1027 else 978 error ("Certificate validation failed %s, verification code %d",
1028 { 979 c_hostname, peer_verification);
1029 error ("Certificate validation failed %s, verification code %d", 980 }
1030 c_hostname, peer_verification); 981 }
1031 }
1032 }
1033 982
1034 /* Up to here the process is the same for X.509 certificates and 983 /* Up to here the process is the same for X.509 certificates and
1035 OpenPGP keys. From now on X.509 certificates are assumed. This 984 OpenPGP keys. From now on X.509 certificates are assumed. This
1036 can be easily extended to work with openpgp keys as well. */ 985 can be easily extended to work with openpgp keys as well. */
1037 if (fn_gnutls_certificate_type_get (state) == GNUTLS_CRT_X509) 986 if (fn_gnutls_certificate_type_get (state) == GNUTLS_CRT_X509)
1038 { 987 {
1039 ret = fn_gnutls_x509_crt_init (&gnutls_verify_cert); 988 gnutls_x509_crt_t gnutls_verify_cert;
989 const gnutls_datum_t *gnutls_verify_cert_list;
990 unsigned int gnutls_verify_cert_list_size;
1040 991
992 ret = fn_gnutls_x509_crt_init (&gnutls_verify_cert);
1041 if (ret < GNUTLS_E_SUCCESS) 993 if (ret < GNUTLS_E_SUCCESS)
1042 return gnutls_make_error (ret); 994 return gnutls_make_error (ret);
1043 995
1044 gnutls_verify_cert_list = 996 gnutls_verify_cert_list =
1045 fn_gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); 997 fn_gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size);
1046 998
1047 if (NULL == gnutls_verify_cert_list) 999 if (gnutls_verify_cert_list == NULL)
1048 { 1000 {
1049 error ("No x509 certificate was found!\n"); 1001 fn_gnutls_x509_crt_deinit (gnutls_verify_cert);
1002 emacs_gnutls_deinit (proc);
1003 error ("No x509 certificate was found\n");
1050 } 1004 }
1051 1005
1052 /* We only check the first certificate in the given chain. */ 1006 /* We only check the first certificate in the given chain. */
@@ -1063,18 +1017,15 @@ one trustfile (usually a CA bundle). */)
1063 if (!fn_gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname)) 1017 if (!fn_gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname))
1064 { 1018 {
1065 if (NILP (verify_hostname_error)) 1019 if (NILP (verify_hostname_error))
1066 { 1020 GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:",
1067 GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:", 1021 c_hostname);
1068 c_hostname);
1069 }
1070 else 1022 else
1071 { 1023 {
1072 fn_gnutls_x509_crt_deinit (gnutls_verify_cert); 1024 fn_gnutls_x509_crt_deinit (gnutls_verify_cert);
1073 error ("The x509 certificate does not match \"%s\"", 1025 emacs_gnutls_deinit (proc);
1074 c_hostname); 1026 error ("The x509 certificate does not match \"%s\"", c_hostname);
1075 } 1027 }
1076 } 1028 }
1077
1078 fn_gnutls_x509_crt_deinit (gnutls_verify_cert); 1029 fn_gnutls_x509_crt_deinit (gnutls_verify_cert);
1079 } 1030 }
1080 1031
diff --git a/src/gnutls.h b/src/gnutls.h
index e2a9bc9eaea..076e9fdba9c 100644
--- a/src/gnutls.h
+++ b/src/gnutls.h
@@ -49,9 +49,9 @@ typedef enum
49 49
50#define GNUTLS_PROCESS_USABLE(proc) (GNUTLS_INITSTAGE(proc) >= GNUTLS_STAGE_READY) 50#define GNUTLS_PROCESS_USABLE(proc) (GNUTLS_INITSTAGE(proc) >= GNUTLS_STAGE_READY)
51 51
52#define GNUTLS_LOG(level, max, string) if (level <= max) { gnutls_log_function (level, "(Emacs) " string); } 52#define GNUTLS_LOG(level, max, string) do { if (level <= max) { gnutls_log_function (level, "(Emacs) " string); } } while (0)
53 53
54#define GNUTLS_LOG2(level, max, string, extra) if (level <= max) { gnutls_log_function2 (level, "(Emacs) " string, extra); } 54#define GNUTLS_LOG2(level, max, string, extra) do { if (level <= max) { gnutls_log_function2 (level, "(Emacs) " string, extra); } } while (0)
55 55
56extern EMACS_INT 56extern EMACS_INT
57emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, EMACS_INT nbyte); 57emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, EMACS_INT nbyte);
@@ -60,6 +60,7 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, EMACS_INT nbyte);
60 60
61extern int emacs_gnutls_record_check_pending (gnutls_session_t state); 61extern int emacs_gnutls_record_check_pending (gnutls_session_t state);
62extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err); 62extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err);
63extern Lisp_Object emacs_gnutls_deinit (Lisp_Object);
63 64
64extern void syms_of_gnutls (void); 65extern void syms_of_gnutls (void);
65 66
diff --git a/src/image.c b/src/image.c
index ef72745a72f..14c74f10607 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2015,7 +2015,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
2015 /* Bitmaps with a depth less than 16 need a palette. */ 2015 /* Bitmaps with a depth less than 16 need a palette. */
2016 /* BITMAPINFO structure already contains the first RGBQUAD. */ 2016 /* BITMAPINFO structure already contains the first RGBQUAD. */
2017 if (depth < 16) 2017 if (depth < 16)
2018 palette_colors = 1 << depth - 1; 2018 palette_colors = 1 << (depth - 1);
2019 2019
2020 *ximg = xmalloc (sizeof (XImage) + palette_colors * sizeof (RGBQUAD)); 2020 *ximg = xmalloc (sizeof (XImage) + palette_colors * sizeof (RGBQUAD));
2021 2021
diff --git a/src/intervals.c b/src/intervals.c
index 2063655cdb9..1f3f8cf793e 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -1723,8 +1723,6 @@ graft_intervals_into_buffer (INTERVAL source, EMACS_INT position,
1723 BUF_INTERVALS (buffer)->position = BEG; 1723 BUF_INTERVALS (buffer)->position = BEG;
1724 BUF_INTERVALS (buffer)->up_obj = 1; 1724 BUF_INTERVALS (buffer)->up_obj = 1;
1725 1725
1726 /* Explicitly free the old tree here? */
1727
1728 return; 1726 return;
1729 } 1727 }
1730 1728
diff --git a/src/keyboard.c b/src/keyboard.c
index 6f3bfd8c1e7..95604550c80 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -73,7 +73,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
73#include "nsterm.h" 73#include "nsterm.h"
74#endif 74#endif
75 75
76/* Variables for blockinput.h: */ 76/* Variables for blockinput.h: */
77 77
78/* Non-zero if interrupt input is blocked right now. */ 78/* Non-zero if interrupt input is blocked right now. */
79volatile int interrupt_input_blocked; 79volatile int interrupt_input_blocked;
@@ -338,7 +338,7 @@ static Lisp_Object Qconfig_changed_event;
338Lisp_Object Qevent_kind; 338Lisp_Object Qevent_kind;
339static Lisp_Object Qevent_symbol_elements; 339static Lisp_Object Qevent_symbol_elements;
340 340
341/* menu and tool bar item parts */ 341/* Menu and tool bar item parts. */
342static Lisp_Object Qmenu_enable; 342static Lisp_Object Qmenu_enable;
343static Lisp_Object QCenable, QCvisible, QChelp, QCkeys, QCkey_sequence; 343static Lisp_Object QCenable, QCvisible, QChelp, QCkeys, QCkey_sequence;
344Lisp_Object QCfilter; 344Lisp_Object QCfilter;
@@ -835,7 +835,7 @@ recursive_edit_unwind (Lisp_Object buffer)
835 835
836 836
837#if 0 /* These two functions are now replaced with 837#if 0 /* These two functions are now replaced with
838 temporarily_switch_to_single_kboard. */ 838 temporarily_switch_to_single_kboard. */
839static void 839static void
840any_kboard_state () 840any_kboard_state ()
841{ 841{
@@ -1038,7 +1038,7 @@ cmd_error (Lisp_Object data)
1038 Vquit_flag = Qnil; 1038 Vquit_flag = Qnil;
1039 1039
1040 Vinhibit_quit = Qnil; 1040 Vinhibit_quit = Qnil;
1041#if 0 /* This shouldn't be necessary anymore. --lorentey */ 1041#if 0 /* This shouldn't be necessary anymore. --lorentey */
1042 if (command_loop_level == 0 && minibuf_level == 0) 1042 if (command_loop_level == 0 && minibuf_level == 0)
1043 any_kboard_state (); 1043 any_kboard_state ();
1044#endif 1044#endif
@@ -1131,7 +1131,7 @@ command_loop (void)
1131#if 0 /* This shouldn't be necessary anymore. --lorentey */ 1131#if 0 /* This shouldn't be necessary anymore. --lorentey */
1132 /* Reset single_kboard in case top-level set it while 1132 /* Reset single_kboard in case top-level set it while
1133 evaluating an -f option, or we are stuck there for some 1133 evaluating an -f option, or we are stuck there for some
1134 other reason. */ 1134 other reason. */
1135 any_kboard_state (); 1135 any_kboard_state ();
1136#endif 1136#endif
1137 internal_catch (Qtop_level, command_loop_2, Qnil); 1137 internal_catch (Qtop_level, command_loop_2, Qnil);
@@ -1492,8 +1492,8 @@ command_loop_1 (void)
1492 if (!NILP (Vquit_flag)) 1492 if (!NILP (Vquit_flag))
1493 { 1493 {
1494 Vexecuting_kbd_macro = Qt; 1494 Vexecuting_kbd_macro = Qt;
1495 QUIT; /* Make some noise. */ 1495 QUIT; /* Make some noise. */
1496 /* Will return since macro now empty. */ 1496 /* Will return since macro now empty. */
1497 } 1497 }
1498 } 1498 }
1499 1499
@@ -1512,7 +1512,7 @@ command_loop_1 (void)
1512 Vdisable_point_adjustment = Qnil; 1512 Vdisable_point_adjustment = Qnil;
1513 1513
1514 /* Process filters and timers may have messed with deactivate-mark. 1514 /* Process filters and timers may have messed with deactivate-mark.
1515 reset it before we execute the command. */ 1515 reset it before we execute the command. */
1516 Vdeactivate_mark = Qnil; 1516 Vdeactivate_mark = Qnil;
1517 1517
1518 /* Remap command through active keymaps. */ 1518 /* Remap command through active keymaps. */
@@ -1552,7 +1552,7 @@ command_loop_1 (void)
1552 } 1552 }
1553 else 1553 else
1554 { 1554 {
1555 /* Here for a command that isn't executed directly */ 1555 /* Here for a command that isn't executed directly. */
1556 1556
1557#ifdef HAVE_WINDOW_SYSTEM 1557#ifdef HAVE_WINDOW_SYSTEM
1558 int scount = SPECPDL_INDEX (); 1558 int scount = SPECPDL_INDEX ();
@@ -1960,7 +1960,7 @@ void
1960poll_for_input_1 (void) 1960poll_for_input_1 (void)
1961{ 1961{
1962/* Tell ns_read_socket() it is being called asynchronously so it can avoid 1962/* Tell ns_read_socket() it is being called asynchronously so it can avoid
1963 doing anything dangerous. */ 1963 doing anything dangerous. */
1964#ifdef HAVE_NS 1964#ifdef HAVE_NS
1965 ++handling_signal; 1965 ++handling_signal;
1966#endif 1966#endif
@@ -2000,7 +2000,7 @@ start_polling (void)
2000#ifdef POLL_FOR_INPUT 2000#ifdef POLL_FOR_INPUT
2001 /* XXX This condition was (read_socket_hook && !interrupt_input), 2001 /* XXX This condition was (read_socket_hook && !interrupt_input),
2002 but read_socket_hook is not global anymore. Let's pretend that 2002 but read_socket_hook is not global anymore. Let's pretend that
2003 it's always set. */ 2003 it's always set. */
2004 if (!interrupt_input) 2004 if (!interrupt_input)
2005 { 2005 {
2006 /* Turn alarm handling on unconditionally. It might have 2006 /* Turn alarm handling on unconditionally. It might have
@@ -2037,7 +2037,7 @@ input_polling_used (void)
2037#ifdef POLL_FOR_INPUT 2037#ifdef POLL_FOR_INPUT
2038 /* XXX This condition was (read_socket_hook && !interrupt_input), 2038 /* XXX This condition was (read_socket_hook && !interrupt_input),
2039 but read_socket_hook is not global anymore. Let's pretend that 2039 but read_socket_hook is not global anymore. Let's pretend that
2040 it's always set. */ 2040 it's always set. */
2041 return !interrupt_input; 2041 return !interrupt_input;
2042#else 2042#else
2043 return 0; 2043 return 0;
@@ -2052,7 +2052,7 @@ stop_polling (void)
2052#ifdef POLL_FOR_INPUT 2052#ifdef POLL_FOR_INPUT
2053 /* XXX This condition was (read_socket_hook && !interrupt_input), 2053 /* XXX This condition was (read_socket_hook && !interrupt_input),
2054 but read_socket_hook is not global anymore. Let's pretend that 2054 but read_socket_hook is not global anymore. Let's pretend that
2055 it's always set. */ 2055 it's always set. */
2056 if (!interrupt_input) 2056 if (!interrupt_input)
2057 ++poll_suppress_count; 2057 ++poll_suppress_count;
2058#endif 2058#endif
@@ -2390,7 +2390,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2390 real event came from. Normally, a switch-frame event selects 2390 real event came from. Normally, a switch-frame event selects
2391 internal_last_event_frame after each command is read, but 2391 internal_last_event_frame after each command is read, but
2392 events read from a macro should never cause a new frame to be 2392 events read from a macro should never cause a new frame to be
2393 selected. */ 2393 selected. */
2394 Vlast_event_frame = internal_last_event_frame = Qmacro; 2394 Vlast_event_frame = internal_last_event_frame = Qmacro;
2395 2395
2396 /* Exit the macro if we are at the end. 2396 /* Exit the macro if we are at the end.
@@ -2500,7 +2500,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2500 Try this before the sit-for, because the sit-for 2500 Try this before the sit-for, because the sit-for
2501 would do the wrong thing if we are supposed to do 2501 would do the wrong thing if we are supposed to do
2502 menu prompting. If EVENT_HAS_PARAMETERS then we are reading 2502 menu prompting. If EVENT_HAS_PARAMETERS then we are reading
2503 after a mouse event so don't try a minibuf menu. */ 2503 after a mouse event so don't try a minibuf menu. */
2504 c = Qnil; 2504 c = Qnil;
2505 if (nmaps > 0 && INTERACTIVE 2505 if (nmaps > 0 && INTERACTIVE
2506 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) 2506 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event)
@@ -4980,8 +4980,8 @@ static const char *const lispy_function_keys[] =
4980 "break", /* 0xff6b */ 4980 "break", /* 0xff6b */
4981 4981
4982 0, 0, 0, 0, 4982 0, 0, 0, 0,
4983 0, 0, 0, 0, "backtab", 0, 0, 0, /* 0xff70... */ 4983 0, 0, 0, 0, "backtab", 0, 0, 0, /* 0xff70... */
4984 0, 0, 0, 0, 0, 0, 0, "kp-numlock", /* 0xff78... */ 4984 0, 0, 0, 0, 0, 0, 0, "kp-numlock", /* 0xff78... */
4985 "kp-space", /* 0xff80 */ /* IsKeypadKey */ 4985 "kp-space", /* 0xff80 */ /* IsKeypadKey */
4986 0, 0, 0, 0, 0, 0, 0, 0, 4986 0, 0, 0, 0, 0, 0, 0, 0,
4987 "kp-tab", /* 0xff89 */ 4987 "kp-tab", /* 0xff89 */
@@ -5093,14 +5093,14 @@ static Lisp_Object *const scroll_bar_parts[] = {
5093static Lisp_Object button_down_location; 5093static Lisp_Object button_down_location;
5094 5094
5095/* Information about the most recent up-going button event: Which 5095/* Information about the most recent up-going button event: Which
5096 button, what location, and what time. */ 5096 button, what location, and what time. */
5097 5097
5098static int last_mouse_button; 5098static int last_mouse_button;
5099static int last_mouse_x; 5099static int last_mouse_x;
5100static int last_mouse_y; 5100static int last_mouse_y;
5101static Time button_down_time; 5101static Time button_down_time;
5102 5102
5103/* The number of clicks in this multiple-click. */ 5103/* The number of clicks in this multiple-click. */
5104 5104
5105static int double_click_count; 5105static int double_click_count;
5106 5106
@@ -5344,7 +5344,7 @@ make_lispy_event (struct input_event *event)
5344 5344
5345#ifdef HAVE_NS 5345#ifdef HAVE_NS
5346 /* NS_NONKEY_EVENTs are just like NON_ASCII_KEYSTROKE_EVENTs, 5346 /* NS_NONKEY_EVENTs are just like NON_ASCII_KEYSTROKE_EVENTs,
5347 except that they are non-key events (last-nonmenu-event is nil). */ 5347 except that they are non-key events (last-nonmenu-event is nil). */
5348 case NS_NONKEY_EVENT: 5348 case NS_NONKEY_EVENT:
5349#endif 5349#endif
5350 5350
@@ -5830,7 +5830,7 @@ make_lispy_event (struct input_event *event)
5830 Fcons (make_number (event->timestamp), 5830 Fcons (make_number (event->timestamp),
5831 Fcons (part, Qnil))))); 5831 Fcons (part, Qnil)))));
5832 5832
5833 /* Always treat scroll bar events as clicks. */ 5833 /* Always treat scroll bar events as clicks. */
5834 event->modifiers |= click_modifier; 5834 event->modifiers |= click_modifier;
5835 event->modifiers &= ~up_modifier; 5835 event->modifiers &= ~up_modifier;
5836 5836
@@ -6694,7 +6694,7 @@ lucid_event_type_list_p (Lisp_Object object)
6694 If READABLE_EVENTS_FILTER_EVENTS is set in FLAGS, ignore internal 6694 If READABLE_EVENTS_FILTER_EVENTS is set in FLAGS, ignore internal
6695 events (FOCUS_IN_EVENT). 6695 events (FOCUS_IN_EVENT).
6696 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse 6696 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse
6697 movements and toolkit scroll bar thumb drags. */ 6697 movements and toolkit scroll bar thumb drags. */
6698 6698
6699static void 6699static void
6700get_input_pending (int *addr, int flags) 6700get_input_pending (int *addr, int flags)
@@ -6728,7 +6728,7 @@ gobble_input (int expected)
6728#ifdef POLL_FOR_INPUT 6728#ifdef POLL_FOR_INPUT
6729 /* XXX This condition was (read_socket_hook && !interrupt_input), 6729 /* XXX This condition was (read_socket_hook && !interrupt_input),
6730 but read_socket_hook is not global anymore. Let's pretend that 6730 but read_socket_hook is not global anymore. Let's pretend that
6731 it's always set. */ 6731 it's always set. */
6732 if (!interrupt_input && poll_suppress_count == 0) 6732 if (!interrupt_input && poll_suppress_count == 0)
6733 { 6733 {
6734 SIGMASKTYPE mask; 6734 SIGMASKTYPE mask;
@@ -6803,7 +6803,7 @@ read_avail_input (int expected)
6803 if (store_user_signal_events ()) 6803 if (store_user_signal_events ())
6804 expected = 0; 6804 expected = 0;
6805 6805
6806 /* Loop through the available terminals, and call their input hooks. */ 6806 /* Loop through the available terminals, and call their input hooks. */
6807 t = terminal_list; 6807 t = terminal_list;
6808 while (t) 6808 while (t)
6809 { 6809 {
@@ -6824,15 +6824,15 @@ read_avail_input (int expected)
6824 expected = 0; 6824 expected = 0;
6825 } 6825 }
6826 6826
6827 if (nr == -1) /* Not OK to read input now. */ 6827 if (nr == -1) /* Not OK to read input now. */
6828 { 6828 {
6829 err = 1; 6829 err = 1;
6830 } 6830 }
6831 else if (nr == -2) /* Non-transient error. */ 6831 else if (nr == -2) /* Non-transient error. */
6832 { 6832 {
6833 /* The terminal device terminated; it should be closed. */ 6833 /* The terminal device terminated; it should be closed. */
6834 6834
6835 /* Kill Emacs if this was our last terminal. */ 6835 /* Kill Emacs if this was our last terminal. */
6836 if (!terminal_list->next_terminal) 6836 if (!terminal_list->next_terminal)
6837 /* Formerly simply reported no input, but that 6837 /* Formerly simply reported no input, but that
6838 sometimes led to a failure of Emacs to terminate. 6838 sometimes led to a failure of Emacs to terminate.
@@ -6844,7 +6844,7 @@ read_avail_input (int expected)
6844 alone in its group. */ 6844 alone in its group. */
6845 kill (getpid (), SIGHUP); 6845 kill (getpid (), SIGHUP);
6846 6846
6847 /* XXX Is calling delete_terminal safe here? It calls delete_frame. */ 6847 /* XXX Is calling delete_terminal safe here? It calls delete_frame. */
6848 { 6848 {
6849 Lisp_Object tmp; 6849 Lisp_Object tmp;
6850 XSETTERMINAL (tmp, t); 6850 XSETTERMINAL (tmp, t);
@@ -6934,7 +6934,7 @@ tty_read_avail_input (struct terminal *terminal,
6934 return 0; 6934 return 0;
6935#endif /* subprocesses */ 6935#endif /* subprocesses */
6936 6936
6937 if (!terminal->name) /* Don't read from a dead terminal. */ 6937 if (!terminal->name) /* Don't read from a dead terminal. */
6938 return 0; 6938 return 0;
6939 6939
6940 if (terminal->type != output_termcap 6940 if (terminal->type != output_termcap
@@ -6942,15 +6942,15 @@ tty_read_avail_input (struct terminal *terminal,
6942 abort (); 6942 abort ();
6943 6943
6944 /* XXX I think the following code should be moved to separate hook 6944 /* XXX I think the following code should be moved to separate hook
6945 functions in system-dependent files. */ 6945 functions in system-dependent files. */
6946#ifdef WINDOWSNT 6946#ifdef WINDOWSNT
6947 return 0; 6947 return 0;
6948#else /* not WINDOWSNT */ 6948#else /* not WINDOWSNT */
6949 if (! tty->term_initted) /* In case we get called during bootstrap. */ 6949 if (! tty->term_initted) /* In case we get called during bootstrap. */
6950 return 0; 6950 return 0;
6951 6951
6952 if (! tty->input) 6952 if (! tty->input)
6953 return 0; /* The terminal is suspended. */ 6953 return 0; /* The terminal is suspended. */
6954 6954
6955#ifdef MSDOS 6955#ifdef MSDOS
6956 n_to_read = dos_keysns (); 6956 n_to_read = dos_keysns ();
@@ -6976,7 +6976,7 @@ tty_read_avail_input (struct terminal *terminal,
6976 Gpm_GetEvent closes gpm_fd and clears it to -1, which is why 6976 Gpm_GetEvent closes gpm_fd and clears it to -1, which is why
6977 we save it in `fd' so close_gpm can remove it from the 6977 we save it in `fd' so close_gpm can remove it from the
6978 select masks. 6978 select masks.
6979 gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */ 6979 gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */
6980 while (gpm = Gpm_GetEvent (&event), gpm == 1) { 6980 while (gpm = Gpm_GetEvent (&event), gpm == 1) {
6981 nread += handle_one_term_event (tty, &event, &gpm_hold_quit); 6981 nread += handle_one_term_event (tty, &event, &gpm_hold_quit);
6982 } 6982 }
@@ -6996,7 +6996,7 @@ tty_read_avail_input (struct terminal *terminal,
6996 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) 6996 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
6997 { 6997 {
6998 if (! noninteractive) 6998 if (! noninteractive)
6999 return -2; /* Close this terminal. */ 6999 return -2; /* Close this terminal. */
7000 else 7000 else
7001 n_to_read = 0; 7001 n_to_read = 0;
7002 } 7002 }
@@ -7029,16 +7029,16 @@ tty_read_avail_input (struct terminal *terminal,
7029 process group won't get SIGHUP's at logout time. BSDI adheres to 7029 process group won't get SIGHUP's at logout time. BSDI adheres to
7030 this part standard and returns -1 from read (0) with errno==EIO 7030 this part standard and returns -1 from read (0) with errno==EIO
7031 when the control tty is taken away. 7031 when the control tty is taken away.
7032 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ 7032 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */
7033 if (nread == -1 && errno == EIO) 7033 if (nread == -1 && errno == EIO)
7034 return -2; /* Close this terminal. */ 7034 return -2; /* Close this terminal. */
7035#if defined (AIX) && defined (_BSD) 7035#if defined (AIX) && defined (_BSD)
7036 /* The kernel sometimes fails to deliver SIGHUP for ptys. 7036 /* The kernel sometimes fails to deliver SIGHUP for ptys.
7037 This looks incorrect, but it isn't, because _BSD causes 7037 This looks incorrect, but it isn't, because _BSD causes
7038 O_NDELAY to be defined in fcntl.h as O_NONBLOCK, 7038 O_NDELAY to be defined in fcntl.h as O_NONBLOCK,
7039 and that causes a value other than 0 when there is no input. */ 7039 and that causes a value other than 0 when there is no input. */
7040 if (nread == 0) 7040 if (nread == 0)
7041 return -2; /* Close this terminal. */ 7041 return -2; /* Close this terminal. */
7042#endif 7042#endif
7043 } 7043 }
7044 while ( 7044 while (
@@ -7116,7 +7116,7 @@ tty_read_avail_input (struct terminal *terminal,
7116 buf.code = cbuf[i]; 7116 buf.code = cbuf[i];
7117 /* Set the frame corresponding to the active tty. Note that the 7117 /* Set the frame corresponding to the active tty. Note that the
7118 value of selected_frame is not reliable here, redisplay tends 7118 value of selected_frame is not reliable here, redisplay tends
7119 to temporarily change it. */ 7119 to temporarily change it. */
7120 buf.frame_or_window = tty->top_frame; 7120 buf.frame_or_window = tty->top_frame;
7121 buf.arg = Qnil; 7121 buf.arg = Qnil;
7122 7122
@@ -7139,7 +7139,7 @@ handle_async_input (void)
7139 pending_signals = pending_atimers; 7139 pending_signals = pending_atimers;
7140#endif 7140#endif
7141/* Tell ns_read_socket() it is being called asynchronously so it can avoid 7141/* Tell ns_read_socket() it is being called asynchronously so it can avoid
7142 doing anything dangerous. */ 7142 doing anything dangerous. */
7143#ifdef HAVE_NS 7143#ifdef HAVE_NS
7144 ++handling_signal; 7144 ++handling_signal;
7145#endif 7145#endif
@@ -7197,7 +7197,7 @@ input_available_signal (int signo)
7197 This function exists so that the UNBLOCK_INPUT macro in 7197 This function exists so that the UNBLOCK_INPUT macro in
7198 blockinput.h can have some way to take care of input we put off 7198 blockinput.h can have some way to take care of input we put off
7199 dealing with, without assuming that every file which uses 7199 dealing with, without assuming that every file which uses
7200 UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */ 7200 UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */
7201void 7201void
7202reinvoke_input_signal (void) 7202reinvoke_input_signal (void)
7203{ 7203{
@@ -7224,7 +7224,7 @@ struct user_signal_info
7224 struct user_signal_info *next; 7224 struct user_signal_info *next;
7225}; 7225};
7226 7226
7227/* List of user signals. */ 7227/* List of user signals. */
7228static struct user_signal_info *user_signals = NULL; 7228static struct user_signal_info *user_signals = NULL;
7229 7229
7230void 7230void
@@ -7761,7 +7761,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
7761 { 7761 {
7762 tem = XCAR (item); 7762 tem = XCAR (item);
7763 if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem)) 7763 if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem))
7764 /* Be GC protected. Set keyhint to item instead of tem. */ 7764 /* Be GC protected. Set keyhint to item instead of tem. */
7765 keyhint = item; 7765 keyhint = item;
7766 } 7766 }
7767 else if (EQ (tem, QCkeys)) 7767 else if (EQ (tem, QCkeys))
@@ -7844,7 +7844,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
7844 if (inmenubar > 0) 7844 if (inmenubar > 0)
7845 return 1; 7845 return 1;
7846 7846
7847 { /* This is a command. See if there is an equivalent key binding. */ 7847 { /* This is a command. See if there is an equivalent key binding. */
7848 Lisp_Object keyeq = AREF (item_properties, ITEM_PROPERTY_KEYEQ); 7848 Lisp_Object keyeq = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
7849 7849
7850 /* The previous code preferred :key-sequence to :keys, so we 7850 /* The previous code preferred :key-sequence to :keys, so we
@@ -8400,7 +8400,7 @@ append_tool_bar_item (void)
8400 These are done in different ways, depending on how the input will be read. 8400 These are done in different ways, depending on how the input will be read.
8401 Menus using X are done after auto-saving in read-char, getting the input 8401 Menus using X are done after auto-saving in read-char, getting the input
8402 event from Fx_popup_menu; menus using the minibuf use read_char recursively 8402 event from Fx_popup_menu; menus using the minibuf use read_char recursively
8403 and do auto-saving in the inner call of read_char. */ 8403 and do auto-saving in the inner call of read_char. */
8404 8404
8405static Lisp_Object 8405static Lisp_Object
8406read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, 8406read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps,
@@ -8620,14 +8620,14 @@ read_char_minibuf_menu_prompt (int commandflag,
8620 tem 8620 tem
8621 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ]; 8621 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ];
8622 if (!NILP (tem)) 8622 if (!NILP (tem))
8623 /* Insert equivalent keybinding. */ 8623 /* Insert equivalent keybinding. */
8624 s = concat2 (s, tem); 8624 s = concat2 (s, tem);
8625#endif 8625#endif
8626 tem 8626 tem
8627 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE]; 8627 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE];
8628 if (EQ (tem, QCradio) || EQ (tem, QCtoggle)) 8628 if (EQ (tem, QCradio) || EQ (tem, QCtoggle))
8629 { 8629 {
8630 /* Insert button prefix. */ 8630 /* Insert button prefix. */
8631 Lisp_Object selected 8631 Lisp_Object selected
8632 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED]; 8632 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED];
8633 if (EQ (tem, QCradio)) 8633 if (EQ (tem, QCradio))
@@ -8861,7 +8861,7 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8861 8861
8862 /* If keybuf[fkey->start..fkey->end] is bound in the 8862 /* If keybuf[fkey->start..fkey->end] is bound in the
8863 map and we're in a position to do the key remapping, replace it with 8863 map and we're in a position to do the key remapping, replace it with
8864 the binding and restart with fkey->start at the end. */ 8864 the binding and restart with fkey->start at the end. */
8865 if ((VECTORP (next) || STRINGP (next)) && doit) 8865 if ((VECTORP (next) || STRINGP (next)) && doit)
8866 { 8866 {
8867 int len = XFASTINT (Flength (next)); 8867 int len = XFASTINT (Flength (next));
@@ -8902,6 +8902,14 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8902 return 0; 8902 return 0;
8903} 8903}
8904 8904
8905static int
8906test_undefined (Lisp_Object binding)
8907{
8908 return (EQ (binding, Qundefined)
8909 || (!NILP (binding) && SYMBOLP (binding)
8910 && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined)));
8911}
8912
8905/* Read a sequence of keys that ends with a non prefix character, 8913/* Read a sequence of keys that ends with a non prefix character,
8906 storing it in KEYBUF, a buffer of size BUFSIZE. 8914 storing it in KEYBUF, a buffer of size BUFSIZE.
8907 Prompt with PROMPT. 8915 Prompt with PROMPT.
@@ -9017,7 +9025,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9017 9025
9018 /* Non-zero if we are trying to map a key by changing an upper-case 9026 /* Non-zero if we are trying to map a key by changing an upper-case
9019 letter to lower case, or a shifted function key to an unshifted 9027 letter to lower case, or a shifted function key to an unshifted
9020 one. */ 9028 one. */
9021 int shift_translated = 0; 9029 int shift_translated = 0;
9022 9030
9023 /* If we receive a `switch-frame' or `select-window' event in the middle of 9031 /* If we receive a `switch-frame' or `select-window' event in the middle of
@@ -9025,7 +9033,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9025 While we're reading, we keep the event here. */ 9033 While we're reading, we keep the event here. */
9026 Lisp_Object delayed_switch_frame; 9034 Lisp_Object delayed_switch_frame;
9027 9035
9028 /* See the comment below... */ 9036 /* See the comment below... */
9029#if defined (GOBBLE_FIRST_EVENT) 9037#if defined (GOBBLE_FIRST_EVENT)
9030 Lisp_Object first_event; 9038 Lisp_Object first_event;
9031#endif 9039#endif
@@ -9300,7 +9308,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9300 if (!found) 9308 if (!found)
9301 { 9309 {
9302 /* Don't touch interrupted_kboard when it's been 9310 /* Don't touch interrupted_kboard when it's been
9303 deleted. */ 9311 deleted. */
9304 delayed_switch_frame = Qnil; 9312 delayed_switch_frame = Qnil;
9305 goto replay_entire_sequence; 9313 goto replay_entire_sequence;
9306 } 9314 }
@@ -9408,7 +9416,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9408 { 9416 {
9409 /* If we're at the beginning of a key sequence, and the caller 9417 /* If we're at the beginning of a key sequence, and the caller
9410 says it's okay, go ahead and return this event. If we're 9418 says it's okay, go ahead and return this event. If we're
9411 in the midst of a key sequence, delay it until the end. */ 9419 in the midst of a key sequence, delay it until the end. */
9412 if (t > 0 || !can_return_switch_frame) 9420 if (t > 0 || !can_return_switch_frame)
9413 { 9421 {
9414 delayed_switch_frame = key; 9422 delayed_switch_frame = key;
@@ -9705,7 +9713,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9705 Down-clicks are eliminated. 9713 Down-clicks are eliminated.
9706 Double-downs reduce to downs, then are eliminated. 9714 Double-downs reduce to downs, then are eliminated.
9707 Triple-downs reduce to double-downs, then to downs, 9715 Triple-downs reduce to double-downs, then to downs,
9708 then are eliminated. */ 9716 then are eliminated. */
9709 if (modifiers & (down_modifier | drag_modifier 9717 if (modifiers & (down_modifier | drag_modifier
9710 | double_modifier | triple_modifier)) 9718 | double_modifier | triple_modifier))
9711 { 9719 {
@@ -9852,7 +9860,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9852 } 9860 }
9853 } 9861 }
9854 9862
9855 if (first_binding < nmaps && NILP (submaps[first_binding]) 9863 if (first_binding < nmaps
9864 && NILP (submaps[first_binding])
9865 && !test_undefined (defs[first_binding])
9856 && indec.start >= t) 9866 && indec.start >= t)
9857 /* There is a binding and it's not a prefix. 9867 /* There is a binding and it's not a prefix.
9858 (and it doesn't have any input-decode-map translation pending). 9868 (and it doesn't have any input-decode-map translation pending).
@@ -9879,7 +9889,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9879 /* If there's a binding (i.e. 9889 /* If there's a binding (i.e.
9880 first_binding >= nmaps) we don't want 9890 first_binding >= nmaps) we don't want
9881 to apply this function-key-mapping. */ 9891 to apply this function-key-mapping. */
9882 fkey.end + 1 == t && first_binding >= nmaps, 9892 fkey.end + 1 == t
9893 && (first_binding >= nmaps
9894 || test_undefined (defs[first_binding])),
9883 &diff, prompt); 9895 &diff, prompt);
9884 UNGCPRO; 9896 UNGCPRO;
9885 if (done) 9897 if (done)
@@ -10810,7 +10822,7 @@ set_waiting_for_input (struct timeval *time_to_clear)
10810 waiting_for_input = 1; 10822 waiting_for_input = 1;
10811 10823
10812 /* If handle_interrupt was called before and buffered a C-g, 10824 /* If handle_interrupt was called before and buffered a C-g,
10813 make it run again now, to avoid timing error. */ 10825 make it run again now, to avoid timing error. */
10814 if (!NILP (Vquit_flag)) 10826 if (!NILP (Vquit_flag))
10815 quit_throw_to_read_char (); 10827 quit_throw_to_read_char ();
10816} 10828}
@@ -10831,7 +10843,7 @@ clear_waiting_for_input (void)
10831 10843
10832static void 10844static void
10833interrupt_signal (int signalnum) /* If we don't have an argument, some */ 10845interrupt_signal (int signalnum) /* If we don't have an argument, some */
10834 /* compilers complain in signal calls. */ 10846 /* compilers complain in signal calls. */
10835{ 10847{
10836 /* Must preserve main program's value of errno. */ 10848 /* Must preserve main program's value of errno. */
10837 int old_errno = errno; 10849 int old_errno = errno;
@@ -10839,12 +10851,12 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */
10839 10851
10840 SIGNAL_THREAD_CHECK (signalnum); 10852 SIGNAL_THREAD_CHECK (signalnum);
10841 10853
10842 /* See if we have an active terminal on our controlling tty. */ 10854 /* See if we have an active terminal on our controlling tty. */
10843 terminal = get_named_tty ("/dev/tty"); 10855 terminal = get_named_tty ("/dev/tty");
10844 if (!terminal) 10856 if (!terminal)
10845 { 10857 {
10846 /* If there are no frames there, let's pretend that we are a 10858 /* If there are no frames there, let's pretend that we are a
10847 well-behaving UN*X program and quit. */ 10859 well-behaving UN*X program and quit. */
10848 Fkill_emacs (Qnil); 10860 Fkill_emacs (Qnil);
10849 } 10861 }
10850 else 10862 else
@@ -10872,7 +10884,7 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */
10872 10884
10873 Otherwise it sets the Lisp variable quit-flag not-nil. This causes 10885 Otherwise it sets the Lisp variable quit-flag not-nil. This causes
10874 eval to throw, when it gets a chance. If quit-flag is already 10886 eval to throw, when it gets a chance. If quit-flag is already
10875 non-nil, it stops the job right away. */ 10887 non-nil, it stops the job right away. */
10876 10888
10877static void 10889static void
10878handle_interrupt (void) 10890handle_interrupt (void)
@@ -10881,7 +10893,7 @@ handle_interrupt (void)
10881 10893
10882 cancel_echoing (); 10894 cancel_echoing ();
10883 10895
10884 /* XXX This code needs to be revised for multi-tty support. */ 10896 /* XXX This code needs to be revised for multi-tty support. */
10885 if (!NILP (Vquit_flag) && get_named_tty ("/dev/tty")) 10897 if (!NILP (Vquit_flag) && get_named_tty ("/dev/tty"))
10886 { 10898 {
10887 /* If SIGINT isn't blocked, don't let us be interrupted by 10899 /* If SIGINT isn't blocked, don't let us be interrupted by
@@ -10991,7 +11003,7 @@ handle_interrupt (void)
10991 wait_reading_process_output() under HAVE_NS because of the call 11003 wait_reading_process_output() under HAVE_NS because of the call
10992 to ns_select there (needed because otherwise events aren't picked up 11004 to ns_select there (needed because otherwise events aren't picked up
10993 outside of polling since we don't get SIGIO like X and we don't have a 11005 outside of polling since we don't get SIGIO like X and we don't have a
10994 separate event loop thread like W32. */ 11006 separate event loop thread like W32. */
10995#ifndef HAVE_NS 11007#ifndef HAVE_NS
10996 if (waiting_for_input && !echoing) 11008 if (waiting_for_input && !echoing)
10997 quit_throw_to_read_char (); 11009 quit_throw_to_read_char ();
@@ -11440,7 +11452,7 @@ init_keyboard (void)
11440 session may have multiple display types, so we always handle 11452 session may have multiple display types, so we always handle
11441 SIGINT. There is special code in interrupt_signal to exit 11453 SIGINT. There is special code in interrupt_signal to exit
11442 Emacs on SIGINT when there are no termcap frames on the 11454 Emacs on SIGINT when there are no termcap frames on the
11443 controlling terminal. */ 11455 controlling terminal. */
11444 signal (SIGINT, interrupt_signal); 11456 signal (SIGINT, interrupt_signal);
11445#ifndef DOS_NT 11457#ifndef DOS_NT
11446 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and 11458 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and
@@ -12237,7 +12249,7 @@ Currently, the only supported values for this
12237variable are `sigusr1' and `sigusr2'. */); 12249variable are `sigusr1' and `sigusr2'. */);
12238 Vdebug_on_event = intern_c_string ("sigusr2"); 12250 Vdebug_on_event = intern_c_string ("sigusr2");
12239 12251
12240 /* Create the initial keyboard. */ 12252 /* Create the initial keyboard. */
12241 initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); 12253 initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
12242 init_kboard (initial_kboard); 12254 init_kboard (initial_kboard);
12243 /* Vwindow_system is left at t for now. */ 12255 /* Vwindow_system is left at t for now. */
diff --git a/src/lisp.h b/src/lisp.h
index 1bbb5633fe5..df8812f73b7 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -162,7 +162,7 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
162 162
163/* First, try and define DECL_ALIGN(type,var) which declares a static 163/* First, try and define DECL_ALIGN(type,var) which declares a static
164 variable VAR of type TYPE with the added requirement that it be 164 variable VAR of type TYPE with the added requirement that it be
165 TYPEBITS-aligned. */ 165 TYPEBITS-aligned. */
166#ifndef NO_DECL_ALIGN 166#ifndef NO_DECL_ALIGN
167# ifndef DECL_ALIGN 167# ifndef DECL_ALIGN
168# if HAVE_ATTRIBUTE_ALIGNED 168# if HAVE_ATTRIBUTE_ALIGNED
@@ -1084,11 +1084,9 @@ enum symbol_redirect
1084 SYMBOL_PLAINVAL = 4, 1084 SYMBOL_PLAINVAL = 4,
1085 SYMBOL_VARALIAS = 1, 1085 SYMBOL_VARALIAS = 1,
1086 SYMBOL_LOCALIZED = 2, 1086 SYMBOL_LOCALIZED = 2,
1087 SYMBOL_FORWARDED = 3 1087 SYMBOL_FORWARDED = 3
1088}; 1088};
1089 1089
1090/* In a symbol, the markbit of the plist is used as the gc mark bit */
1091
1092struct Lisp_Symbol 1090struct Lisp_Symbol
1093{ 1091{
1094 unsigned gcmarkbit : 1; 1092 unsigned gcmarkbit : 1;
@@ -1097,8 +1095,7 @@ struct Lisp_Symbol
1097 0 : it's a plain var, the value is in the `value' field. 1095 0 : it's a plain var, the value is in the `value' field.
1098 1 : it's a varalias, the value is really in the `alias' symbol. 1096 1 : it's a varalias, the value is really in the `alias' symbol.
1099 2 : it's a localized var, the value is in the `blv' object. 1097 2 : it's a localized var, the value is in the `blv' object.
1100 3 : it's a forwarding variable, the value is in `forward'. 1098 3 : it's a forwarding variable, the value is in `forward'. */
1101 */
1102 enum symbol_redirect redirect : 3; 1099 enum symbol_redirect redirect : 3;
1103 1100
1104 /* Non-zero means symbol is constant, i.e. changing its value 1101 /* Non-zero means symbol is constant, i.e. changing its value
@@ -1115,15 +1112,12 @@ struct Lisp_Symbol
1115 unsigned declared_special : 1; 1112 unsigned declared_special : 1;
1116 1113
1117 /* The symbol's name, as a Lisp string. 1114 /* The symbol's name, as a Lisp string.
1118
1119 The name "xname" is used to intentionally break code referring to 1115 The name "xname" is used to intentionally break code referring to
1120 the old field "name" of type pointer to struct Lisp_String. */ 1116 the old field "name" of type pointer to struct Lisp_String. */
1121 Lisp_Object xname; 1117 Lisp_Object xname;
1122 1118
1123 /* Value of the symbol or Qunbound if unbound. If this symbol is a 1119 /* Value of the symbol or Qunbound if unbound. Which alternative of the
1124 defvaralias, `alias' contains the symbol for which it is an 1120 union is used depends on the `redirect' field above. */
1125 alias. Use the SYMBOL_VALUE and SET_SYMBOL_VALUE macros to get
1126 and set a symbol's value, to take defvaralias into account. */
1127 union { 1121 union {
1128 Lisp_Object value; 1122 Lisp_Object value;
1129 struct Lisp_Symbol *alias; 1123 struct Lisp_Symbol *alias;
@@ -1318,7 +1312,7 @@ struct Lisp_Misc_Any /* Supertype of all Misc types. */
1318 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_??? */ 1312 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_??? */
1319 unsigned gcmarkbit : 1; 1313 unsigned gcmarkbit : 1;
1320 int spacer : 15; 1314 int spacer : 15;
1321 /* Make it as long as "Lisp_Free without padding". */ 1315 /* Make it as long as "Lisp_Free without padding". */
1322 void *fill; 1316 void *fill;
1323}; 1317};
1324 1318
@@ -3603,7 +3597,7 @@ extern void init_system_name (void);
3603 3597
3604#define SWITCH_ENUM_CAST(x) (x) 3598#define SWITCH_ENUM_CAST(x) (x)
3605 3599
3606/* Use this to suppress gcc's warnings. */ 3600/* Use this to suppress gcc's warnings. */
3607#ifdef lint 3601#ifdef lint
3608 3602
3609/* Use CODE only if lint checking is in effect. */ 3603/* Use CODE only if lint checking is in effect. */
diff --git a/src/process.c b/src/process.c
index 90ad9c21681..dc37ec5f961 100644
--- a/src/process.c
+++ b/src/process.c
@@ -642,6 +642,9 @@ make_process (Lisp_Object name)
642 p->gnutls_initstage = GNUTLS_STAGE_EMPTY; 642 p->gnutls_initstage = GNUTLS_STAGE_EMPTY;
643 p->gnutls_log_level = 0; 643 p->gnutls_log_level = 0;
644 p->gnutls_p = 0; 644 p->gnutls_p = 0;
645 p->gnutls_state = NULL;
646 p->gnutls_x509_cred = NULL;
647 p->gnutls_anon_cred = NULL;
645#endif 648#endif
646 649
647 /* If name is already in use, modify it until it is unused. */ 650 /* If name is already in use, modify it until it is unused. */
@@ -3867,6 +3870,11 @@ deactivate_process (Lisp_Object proc)
3867 register int inchannel, outchannel; 3870 register int inchannel, outchannel;
3868 register struct Lisp_Process *p = XPROCESS (proc); 3871 register struct Lisp_Process *p = XPROCESS (proc);
3869 3872
3873#ifdef HAVE_GNUTLS
3874 /* Delete GnuTLS structures in PROC, if any. */
3875 emacs_gnutls_deinit (proc);
3876#endif /* HAVE_GNUTLS */
3877
3870 inchannel = p->infd; 3878 inchannel = p->infd;
3871 outchannel = p->outfd; 3879 outchannel = p->outfd;
3872 3880
diff --git a/src/sysdep.c b/src/sysdep.c
index b0d5a1abbe3..d666f8dbb79 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -854,6 +854,7 @@ void
854init_sys_modes (struct tty_display_info *tty_out) 854init_sys_modes (struct tty_display_info *tty_out)
855{ 855{
856 struct emacs_tty tty; 856 struct emacs_tty tty;
857 Lisp_Object terminal;
857 858
858 Vtty_erase_char = Qnil; 859 Vtty_erase_char = Qnil;
859 860
@@ -907,7 +908,9 @@ init_sys_modes (struct tty_display_info *tty_out)
907 tty.main.c_cflag &= ~PARENB;/* Don't check parity */ 908 tty.main.c_cflag &= ~PARENB;/* Don't check parity */
908 } 909 }
909#endif 910#endif
910 if (tty_out->input == stdin) 911
912 XSETTERMINAL(terminal, tty_out->terminal);
913 if (!NILP (Fcontrolling_tty_p (terminal)))
911 { 914 {
912 tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */ 915 tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */
913 /* Set up C-g for both SIGQUIT and SIGINT. 916 /* Set up C-g for both SIGQUIT and SIGINT.
diff --git a/src/w32.c b/src/w32.c
index 91893ddfc61..42546fc8d49 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2892,12 +2892,12 @@ sys_rename (const char * oldname, const char * newname)
2892 int i = 0; 2892 int i = 0;
2893 2893
2894 oldname = map_w32_filename (oldname, NULL); 2894 oldname = map_w32_filename (oldname, NULL);
2895 if (o = strrchr (oldname, '\\')) 2895 if ((o = strrchr (oldname, '\\')))
2896 o++; 2896 o++;
2897 else 2897 else
2898 o = (char *) oldname; 2898 o = (char *) oldname;
2899 2899
2900 if (p = strrchr (temp, '\\')) 2900 if ((p = strrchr (temp, '\\')))
2901 p++; 2901 p++;
2902 else 2902 else
2903 p = temp; 2903 p = temp;
@@ -5756,7 +5756,7 @@ w32_delayed_load (Lisp_Object libraries, Lisp_Object library_id)
5756 for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls)) 5756 for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls))
5757 { 5757 {
5758 CHECK_STRING_CAR (dlls); 5758 CHECK_STRING_CAR (dlls);
5759 if (library_dll = LoadLibrary (SDATA (XCAR (dlls)))) 5759 if ((library_dll = LoadLibrary (SDATA (XCAR (dlls)))))
5760 { 5760 {
5761 found = XCAR (dlls); 5761 found = XCAR (dlls);
5762 break; 5762 break;
diff --git a/src/w32.h b/src/w32.h
index f1915125c90..a3ca1130ce6 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -139,6 +139,7 @@ extern void term_w32select (void);
139extern void syms_of_w32menu (void); 139extern void syms_of_w32menu (void);
140extern void globals_of_w32menu (void); 140extern void globals_of_w32menu (void);
141extern void syms_of_fontset (void); 141extern void syms_of_fontset (void);
142extern void syms_of_w32font (void);
142 143
143extern int _sys_read_ahead (int fd); 144extern int _sys_read_ahead (int fd);
144extern int _sys_wait_accept (int fd); 145extern int _sys_wait_accept (int fd);
diff --git a/src/w32fns.c b/src/w32fns.c
index f48e5764b4c..2ecd6e91533 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -635,9 +635,8 @@ colormap_t w32_color_map[] =
635 {"LightGreen" , PALETTERGB (144,238,144)}, 635 {"LightGreen" , PALETTERGB (144,238,144)},
636}; 636};
637 637
638DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map, 638static Lisp_Object
639 0, 0, 0, doc: /* Return the default color map. */) 639w32_default_color_map (void)
640 (void)
641{ 640{
642 int i; 641 int i;
643 colormap_t *pc = w32_color_map; 642 colormap_t *pc = w32_color_map;
@@ -658,6 +657,13 @@ DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map,
658 return (cmap); 657 return (cmap);
659} 658}
660 659
660DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map,
661 0, 0, 0, doc: /* Return the default color map. */)
662 (void)
663{
664 return w32_default_color_map ();
665}
666
661static Lisp_Object 667static Lisp_Object
662w32_color_map_lookup (char *colorname) 668w32_color_map_lookup (char *colorname)
663{ 669{
@@ -683,7 +689,6 @@ w32_color_map_lookup (char *colorname)
683 QUIT; 689 QUIT;
684 } 690 }
685 691
686
687 UNBLOCK_INPUT; 692 UNBLOCK_INPUT;
688 693
689 return ret; 694 return ret;
@@ -4768,7 +4773,7 @@ terminate Emacs if we can't open the connection.
4768 UNGCPRO; 4773 UNGCPRO;
4769 } 4774 }
4770 if (NILP (Vw32_color_map)) 4775 if (NILP (Vw32_color_map))
4771 Vw32_color_map = Fw32_default_color_map (); 4776 Vw32_color_map = w32_default_color_map ();
4772 4777
4773 /* Merge in system logical colors. */ 4778 /* Merge in system logical colors. */
4774 add_system_logical_colors_to_map (&Vw32_color_map); 4779 add_system_logical_colors_to_map (&Vw32_color_map);
diff --git a/src/w32font.c b/src/w32font.c
index 985370c15c1..6c1b4d0bc20 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -145,6 +145,138 @@ struct font_callback_data
145 style variations if the font name is not specified. */ 145 style variations if the font name is not specified. */
146static void list_all_matching_fonts (struct font_callback_data *); 146static void list_all_matching_fonts (struct font_callback_data *);
147 147
148static BOOL g_b_init_is_w9x;
149static BOOL g_b_init_get_outline_metrics_w;
150static BOOL g_b_init_get_text_metrics_w;
151static BOOL g_b_init_get_glyph_outline_w;
152static BOOL g_b_init_get_glyph_outline_w;
153
154typedef UINT (WINAPI * GetOutlineTextMetricsW_Proc) (
155 HDC hdc,
156 UINT cbData,
157 LPOUTLINETEXTMETRICW lpotmw);
158typedef BOOL (WINAPI * GetTextMetricsW_Proc) (
159 HDC hdc,
160 LPTEXTMETRICW lptmw);
161typedef DWORD (WINAPI * GetGlyphOutlineW_Proc) (
162 HDC hdc,
163 UINT uChar,
164 UINT uFormat,
165 LPGLYPHMETRICS lpgm,
166 DWORD cbBuffer,
167 LPVOID lpvBuffer,
168 const MAT2 *lpmat2);
169
170/* Several "wide" functions we use to support the font backends are
171 unavailable on Windows 9X, unless UNICOWS.DLL is installed (their
172 versions in the default libraries are non-functional stubs). On NT
173 and later systems, these functions are in GDI32.DLL. The following
174 helper function attempts to load UNICOWS.DLL on Windows 9X, and
175 refuses to let Emacs start up if that library is not found. On NT
176 and later versions, it simply loads GDI32.DLL, which should always
177 be available. */
178static HMODULE
179w32_load_unicows_or_gdi32 (void)
180{
181 static BOOL is_9x = 0;
182 OSVERSIONINFO os_ver;
183 HMODULE ret;
184 if (g_b_init_is_w9x == 0)
185 {
186 g_b_init_is_w9x = 1;
187 ZeroMemory (&os_ver, sizeof (OSVERSIONINFO));
188 os_ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
189 if (GetVersionEx (&os_ver))
190 is_9x = (os_ver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
191 }
192 if (is_9x)
193 {
194 ret = LoadLibrary ("Unicows.dll");
195 if (!ret)
196 {
197 int button;
198
199 button = MessageBox (NULL,
200 "Emacs cannot load the UNICOWS.DLL library.\n"
201 "This library is essential for using Emacs\n"
202 "on this system. You need to install it.\n\n"
203 "However, you can still use Emacs by invoking\n"
204 "it with the '-nw' command-line option.\n\n"
205 "Emacs will exit when you click OK.",
206 "Emacs cannot load UNICOWS.DLL",
207 MB_ICONERROR | MB_TASKMODAL
208 | MB_SETFOREGROUND | MB_OK);
209 switch (button)
210 {
211 case IDOK:
212 default:
213 exit (1);
214 }
215 }
216 }
217 else
218 ret = LoadLibrary ("Gdi32.dll");
219 return ret;
220}
221
222/* The following 3 functions call the problematic "wide" APIs via
223 function pointers, to avoid linking against the non-standard
224 libunicows on W9X. */
225static UINT WINAPI
226get_outline_metrics_w(HDC hdc, UINT cbData, LPOUTLINETEXTMETRICW lpotmw)
227{
228 static GetOutlineTextMetricsW_Proc s_pfn_Get_Outline_Text_MetricsW = NULL;
229 HMODULE hm_unicows = NULL;
230 if (g_b_init_get_outline_metrics_w == 0)
231 {
232 g_b_init_get_outline_metrics_w = 1;
233 hm_unicows = w32_load_unicows_or_gdi32 ();
234 if (hm_unicows)
235 s_pfn_Get_Outline_Text_MetricsW = (GetOutlineTextMetricsW_Proc)
236 GetProcAddress (hm_unicows, "GetOutlineTextMetricsW");
237 }
238 if (s_pfn_Get_Outline_Text_MetricsW == NULL)
239 abort (); /* cannot happen */
240 return s_pfn_Get_Outline_Text_MetricsW (hdc, cbData, lpotmw);
241}
242
243static BOOL WINAPI
244get_text_metrics_w(HDC hdc, LPTEXTMETRICW lptmw)
245{
246 static GetTextMetricsW_Proc s_pfn_Get_Text_MetricsW = NULL;
247 HMODULE hm_unicows = NULL;
248 if (g_b_init_get_text_metrics_w == 0)
249 {
250 g_b_init_get_text_metrics_w = 1;
251 hm_unicows = w32_load_unicows_or_gdi32 ();
252 if (hm_unicows)
253 s_pfn_Get_Text_MetricsW = (GetTextMetricsW_Proc)
254 GetProcAddress (hm_unicows, "GetTextMetricsW");
255 }
256 if (s_pfn_Get_Text_MetricsW == NULL)
257 abort (); /* cannot happen */
258 return s_pfn_Get_Text_MetricsW (hdc, lptmw);
259}
260
261static DWORD WINAPI
262get_glyph_outline_w (HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm,
263 DWORD cbBuffer, LPVOID lpvBuffer, const MAT2 *lpmat2)
264{
265 static GetGlyphOutlineW_Proc s_pfn_Get_Glyph_OutlineW = NULL;
266 HMODULE hm_unicows = NULL;
267 if (g_b_init_get_glyph_outline_w == 0)
268 {
269 g_b_init_get_glyph_outline_w = 1;
270 hm_unicows = w32_load_unicows_or_gdi32 ();
271 if (hm_unicows)
272 s_pfn_Get_Glyph_OutlineW = (GetGlyphOutlineW_Proc)
273 GetProcAddress (hm_unicows, "GetGlyphOutlineW");
274 }
275 if (s_pfn_Get_Glyph_OutlineW == NULL)
276 abort (); /* cannot happen */
277 return s_pfn_Get_Glyph_OutlineW (hdc, uChar, uFormat, lpgm, cbBuffer,
278 lpvBuffer, lpmat2);
279}
148 280
149static int 281static int
150memq_no_quit (Lisp_Object elt, Lisp_Object list) 282memq_no_quit (Lisp_Object elt, Lisp_Object list)
@@ -816,11 +948,11 @@ w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity,
816 old_font = SelectObject (dc, hfont); 948 old_font = SelectObject (dc, hfont);
817 949
818 /* Try getting the outline metrics (only works for truetype fonts). */ 950 /* Try getting the outline metrics (only works for truetype fonts). */
819 len = GetOutlineTextMetricsW (dc, 0, NULL); 951 len = get_outline_metrics_w (dc, 0, NULL);
820 if (len) 952 if (len)
821 { 953 {
822 metrics = (OUTLINETEXTMETRICW *) alloca (len); 954 metrics = (OUTLINETEXTMETRICW *) alloca (len);
823 if (GetOutlineTextMetricsW (dc, len, metrics)) 955 if (get_outline_metrics_w (dc, len, metrics))
824 memcpy (&w32_font->metrics, &metrics->otmTextMetrics, 956 memcpy (&w32_font->metrics, &metrics->otmTextMetrics,
825 sizeof (TEXTMETRICW)); 957 sizeof (TEXTMETRICW));
826 else 958 else
@@ -828,7 +960,7 @@ w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity,
828 } 960 }
829 961
830 if (!metrics) 962 if (!metrics)
831 GetTextMetricsW (dc, &w32_font->metrics); 963 get_text_metrics_w (dc, &w32_font->metrics);
832 964
833 w32_font->cached_metrics = NULL; 965 w32_font->cached_metrics = NULL;
834 w32_font->n_cache_blocks = 0; 966 w32_font->n_cache_blocks = 0;
@@ -1916,10 +2048,10 @@ fill_in_logfont (FRAME_PTR f, LOGFONT *logfont, Lisp_Object font_spec)
1916 int spacing = XINT (tmp); 2048 int spacing = XINT (tmp);
1917 if (spacing < FONT_SPACING_MONO) 2049 if (spacing < FONT_SPACING_MONO)
1918 logfont->lfPitchAndFamily 2050 logfont->lfPitchAndFamily
1919 = logfont->lfPitchAndFamily & 0xF0 | VARIABLE_PITCH; 2051 = (logfont->lfPitchAndFamily & 0xF0) | VARIABLE_PITCH;
1920 else 2052 else
1921 logfont->lfPitchAndFamily 2053 logfont->lfPitchAndFamily
1922 = logfont->lfPitchAndFamily & 0xF0 | FIXED_PITCH; 2054 = (logfont->lfPitchAndFamily & 0xF0) | FIXED_PITCH;
1923 } 2055 }
1924 2056
1925 /* Process EXTRA info. */ 2057 /* Process EXTRA info. */
@@ -2306,7 +2438,7 @@ compute_metrics (HDC dc, struct w32font_info *w32_font, unsigned int code,
2306 transform.eM11.value = 1; 2438 transform.eM11.value = 1;
2307 transform.eM22.value = 1; 2439 transform.eM22.value = 1;
2308 2440
2309 if (GetGlyphOutlineW (dc, code, options, &gm, 0, NULL, &transform) 2441 if (get_glyph_outline_w (dc, code, options, &gm, 0, NULL, &transform)
2310 != GDI_ERROR) 2442 != GDI_ERROR)
2311 { 2443 {
2312 metrics->lbearing = gm.gmptGlyphOrigin.x; 2444 metrics->lbearing = gm.gmptGlyphOrigin.x;
@@ -2581,3 +2713,12 @@ versions of Windows) characters. */);
2581 w32font_driver.type = Qgdi; 2713 w32font_driver.type = Qgdi;
2582 register_font_driver (&w32font_driver, NULL); 2714 register_font_driver (&w32font_driver, NULL);
2583} 2715}
2716
2717void
2718globals_of_w32font (void)
2719{
2720 g_b_init_is_w9x = 0;
2721 g_b_init_get_outline_metrics_w = 0;
2722 g_b_init_get_text_metrics_w = 0;
2723 g_b_init_get_glyph_outline_w = 0;
2724}
diff --git a/src/w32reg.c b/src/w32reg.c
index e1465be9e44..18374431062 100644
--- a/src/w32reg.c
+++ b/src/w32reg.c
@@ -147,9 +147,9 @@ x_get_string_resource (XrmDatabase rdb, char *name, char *class)
147 { 147 {
148 char *resource; 148 char *resource;
149 149
150 if (resource = w32_get_rdb_resource (rdb, name)) 150 if ((resource = w32_get_rdb_resource (rdb, name)))
151 return resource; 151 return resource;
152 if (resource = w32_get_rdb_resource (rdb, class)) 152 if ((resource = w32_get_rdb_resource (rdb, class)))
153 return resource; 153 return resource;
154 } 154 }
155 155
@@ -157,6 +157,5 @@ x_get_string_resource (XrmDatabase rdb, char *name, char *class)
157 /* --quick was passed, so this is a no-op. */ 157 /* --quick was passed, so this is a no-op. */
158 return NULL; 158 return NULL;
159 159
160 return (w32_get_string_resource (name, class, REG_SZ)); 160 return w32_get_string_resource (name, class, REG_SZ);
161} 161}
162
diff --git a/src/window.c b/src/window.c
index c3b4384137d..0c35b913789 100644
--- a/src/window.c
+++ b/src/window.c
@@ -175,10 +175,10 @@ WINDOW can be any window and defaults to the selected one. */)
175} 175}
176 176
177DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, 177DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
178 doc: /* Return the root window of FRAME_OR_WINDOW. 178 doc: /* Return the root window of FRAME-OR-WINDOW.
179If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. 179If omitted, FRAME-OR-WINDOW defaults to the currently selected frame.
180Else if FRAME_OR_WINDOW denotes any window, return the root window of 180Else if FRAME-OR-WINDOW denotes any window, return the root window of
181that window's frame. If FRAME_OR_WINDOW denotes a live frame, return 181that window's frame. If FRAME-OR-WINDOW denotes a live frame, return
182the root window of that frame. */) 182the root window of that frame. */)
183 (Lisp_Object frame_or_window) 183 (Lisp_Object frame_or_window)
184{ 184{
@@ -220,10 +220,10 @@ WINDOW can be any window and defaults to the selected one. */)
220 220
221/* Don't move this to window.el - this must be a safe routine. */ 221/* Don't move this to window.el - this must be a safe routine. */
222DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, 222DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
223 doc: /* Return the topmost, leftmost live window on FRAME_OR_WINDOW. 223 doc: /* Return the topmost, leftmost live window on FRAME-OR-WINDOW.
224If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. 224If omitted, FRAME-OR-WINDOW defaults to the currently selected frame.
225Else if FRAME_OR_WINDOW denotes any window, return the first window of 225Else if FRAME-OR-WINDOW denotes any window, return the first window of
226that window's frame. If FRAME_OR_WINDOW denotes a live frame, return 226that window's frame. If FRAME-OR-WINDOW denotes a live frame, return
227the first window of that frame. */) 227the first window of that frame. */)
228 (Lisp_Object frame_or_window) 228 (Lisp_Object frame_or_window)
229{ 229{
@@ -254,10 +254,10 @@ the first window of that frame. */)
254 254
255DEFUN ("frame-selected-window", Fframe_selected_window, 255DEFUN ("frame-selected-window", Fframe_selected_window,
256 Sframe_selected_window, 0, 1, 0, 256 Sframe_selected_window, 0, 1, 0,
257 doc: /* Return the selected window of FRAME_OR_WINDOW. 257 doc: /* Return the selected window of FRAME-OR-WINDOW.
258If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. 258If omitted, FRAME-OR-WINDOW defaults to the currently selected frame.
259Else if FRAME_OR_WINDOW denotes any window, return the selected window 259Else if FRAME-OR-WINDOW denotes any window, return the selected window
260of that window's frame. If FRAME_OR_WINDOW denotes a live frame, return 260of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return
261the selected window of that frame. */) 261the selected window of that frame. */)
262 (Lisp_Object frame_or_window) 262 (Lisp_Object frame_or_window)
263{ 263{
@@ -1297,7 +1297,7 @@ WINDOW must be a live window and defaults to the selected one.
1297This is updated by redisplay, when it runs to completion. 1297This is updated by redisplay, when it runs to completion.
1298Simply changing the buffer text or setting `window-start' 1298Simply changing the buffer text or setting `window-start'
1299does not update this value. 1299does not update this value.
1300Return nil if there is no recorded value. \(This can happen if the 1300Return nil if there is no recorded value. (This can happen if the
1301last redisplay of WINDOW was preempted, and did not finish.) 1301last redisplay of WINDOW was preempted, and did not finish.)
1302If UPDATE is non-nil, compute the up-to-date position 1302If UPDATE is non-nil, compute the up-to-date position
1303if it isn't already recorded. */) 1303if it isn't already recorded. */)
@@ -1688,7 +1688,7 @@ DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters,
1688 0, 1, 0, 1688 0, 1, 0,
1689 doc: /* Return the parameters of WINDOW and their values. 1689 doc: /* Return the parameters of WINDOW and their values.
1690WINDOW defaults to the selected window. The return value is a list of 1690WINDOW defaults to the selected window. The return value is a list of
1691elements of the form (PARAMETER . VALUE). */) 1691elements of the form (PARAMETER . VALUE). */)
1692 (Lisp_Object window) 1692 (Lisp_Object window)
1693{ 1693{
1694 return Fcopy_alist (decode_any_window (window)->window_parameters); 1694 return Fcopy_alist (decode_any_window (window)->window_parameters);
@@ -2193,7 +2193,7 @@ next_window (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames, in
2193 2193
2194DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0, 2194DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0,
2195 doc: /* Return window following WINDOW in cyclic ordering of windows. 2195 doc: /* Return window following WINDOW in cyclic ordering of windows.
2196WINDOW must be a live window and defaults to the selected one. The 2196WINDOW must be a live window and defaults to the selected one. The
2197optional arguments MINIBUF and ALL-FRAMES specify the set of windows to 2197optional arguments MINIBUF and ALL-FRAMES specify the set of windows to
2198consider. 2198consider.
2199 2199
@@ -3224,7 +3224,7 @@ temp_output_buffer_show (register Lisp_Object buf)
3224DEFUN ("internal-temp-output-buffer-show", 3224DEFUN ("internal-temp-output-buffer-show",
3225 Ftemp_output_buffer_show, Stemp_output_buffer_show, 3225 Ftemp_output_buffer_show, Stemp_output_buffer_show,
3226 1, 1, 0, 3226 1, 1, 0,
3227 doc: /* Internal function for `with-output-to-temp-buffer''. */) 3227 doc: /* Internal function for `with-output-to-temp-buffer'. */)
3228 (Lisp_Object buf) 3228 (Lisp_Object buf)
3229{ 3229{
3230 temp_output_buffer_show (buf); 3230 temp_output_buffer_show (buf);
@@ -3845,8 +3845,8 @@ set correctly. See the code of `split-window' for how this is done. */)
3845 3845
3846DEFUN ("delete-window-internal", Fdelete_window_internal, Sdelete_window_internal, 1, 1, 0, 3846DEFUN ("delete-window-internal", Fdelete_window_internal, Sdelete_window_internal, 1, 1, 0,
3847 doc: /* Remove WINDOW from its frame. 3847 doc: /* Remove WINDOW from its frame.
3848WINDOW defaults to the selected window. Return nil. Signal an error 3848WINDOW defaults to the selected window. Return nil.
3849when WINDOW is the only window on its frame. */) 3849Signal an error when WINDOW is the only window on its frame. */)
3850 (register Lisp_Object window) 3850 (register Lisp_Object window)
3851{ 3851{
3852 register Lisp_Object parent, sibling, frame, root; 3852 register Lisp_Object parent, sibling, frame, root;
@@ -5225,8 +5225,8 @@ any partial-height lines in the text display area. */)
5225DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line, 5225DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line,
5226 1, 1, "P", 5226 1, 1, "P",
5227 doc: /* Position point relative to window. 5227 doc: /* Position point relative to window.
5228With no argument, position point at center of window. 5228ARG nil means position point at center of window.
5229An argument specifies vertical position within the window; 5229Else, ARG specifies vertical position within the window;
5230zero means top of window, negative means relative to bottom of window. */) 5230zero means top of window, negative means relative to bottom of window. */)
5231 (Lisp_Object arg) 5231 (Lisp_Object arg)
5232{ 5232{