comparison src/objects-xlike-inc.c @ 3676:3ef0aaf3dc34

[xemacs-hg @ 2006-11-12 13:40:04 by aidan] Prevent a crash if the ASCII charset registries match nothing.
author aidan
date Sun, 12 Nov 2006 13:40:09 +0000
parents 98af8a976fc3
children efca49973324
comparison
equal deleted inserted replaced
3675:0492077a2e85 3676:3ef0aaf3dc34
762 eidata(ei_xlfd)); 762 eidata(ei_xlfd));
763 result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd), 763 result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd),
764 charset, stage); 764 charset, stage);
765 } 765 }
766 766
767 /* In the event that the charset is ASCII and we haven't matched
768 anything up to now, even with a pattern of "*", add "iso8859-1"
769 to the charset's registry and try again. Not returning a result
770 for ASCII means our frame geometry calculations are
771 inconsistent, and that we may crash. */
772
773 if (1 == xlfd_length && EQ(charset, Vcharset_ascii) && NILP(result)
774 && ('*' == eigetch(ei_xlfd_without_registry, 0)))
775
776 {
777 int have_latin1 = 0;
778
779 /* Set this to, for example, is08859-1 if you want to see the
780 error behaviour. */
781
782 #define FALLBACK_ASCII_REGISTRY "iso8859-1"
783
784 for (j = 0; j < registries_len; ++j)
785 {
786 if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[j]),
787 FALLBACK_ASCII_REGISTRY))
788 {
789 have_latin1 = 1;
790 break;
791 }
792 }
793
794 if (!have_latin1)
795 {
796 Lisp_Object new_registries = make_vector(registries_len + 1, Qnil);
797
798 warn_when_safe (Qface, Qwarning,
799 "Your ASCII charset registries contain nothing "
800 "sensible. Adding `" FALLBACK_ASCII_REGISTRY "'.");
801
802 XVECTOR_DATA(new_registries)[0]
803 = build_string(FALLBACK_ASCII_REGISTRY);
804
805 memcpy(XVECTOR_DATA(new_registries) + 1,
806 XVECTOR_DATA(registries),
807 sizeof XVECTOR_DATA(registries)[0] *
808 XVECTOR_LENGTH(registries));
809
810 /* Calling set_charset_registries instead of overwriting the
811 value directly, to allow the charset font caches to be
812 invalidated and a change to the default face to be
813 noted. */
814 set_charset_registries(charset, new_registries);
815
816 /* And recurse. */
817 result =
818 DEVMETH_OR_GIVEN (XDEVICE (device), find_charset_font,
819 (device, font, charset, stage),
820 result);
821 }
822 else
823 {
824 DECLARE_EISTRING (ei_connection_name);
825
826 /* We preserve a copy of the connection name for the error message
827 after the device is deleted. */
828 eicpy_lstr (ei_connection_name,
829 DEVICE_CONNECTION (XDEVICE(device)));
830
831 stderr_out ("Cannot find a font for ASCII, deleting device on %s\n",
832 eidata (ei_connection_name));
833
834 io_error_delete_device (device);
835
836 /* Do a normal warning in the event that we have other, non-X
837 frames available. (If we don't, io_error_delete_device will
838 have exited.) */
839 warn_when_safe
840 (Qface, Qerror,
841 "Cannot find a font for ASCII, deleting device on %s.\n"
842 "\n"
843 "Your X server fonts appear to be inconsistent; fix them, or\n"
844 "the next frame you create on that DISPLAY will crash this\n"
845 "XEmacs. At a minimum, provide one font with an XLFD ending\n"
846 "in `" FALLBACK_ASCII_REGISTRY "', so we can work out what size\n"
847 "a frame should be. ",
848 eidata (ei_connection_name));
849 }
850
851 }
852
767 /* This function used to return the font spec, in the case where a font 853 /* This function used to return the font spec, in the case where a font
768 didn't exist on the X server but it did match the charset. We're not 854 didn't exist on the X server but it did match the charset. We're not
769 doing that any more, because none of the other platform code does, and 855 doing that any more, because none of the other platform code does, and
770 the old behaviour was badly-judged in other respects, so I don't trust 856 the old behaviour was badly-judged in other respects, so I don't trust
771 the original author to have had a good reason for it. */ 857 the original author to have had a good reason for it. */