To: [email protected]
Subject: Patch 6.1b.016
Fcc: outbox
From: Bram Moolenaar <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 6.1b.016
Problem:    GTK: loading a fontset that works partly, Vim might hang or crash.
Solution:   Avoid that char_width becomes zero. (Yasuhiro Matsumoto)
Files:      src/gui_gtk_x11.c


*** ../vim61b.015/src/gui_gtk_x11.c     Fri Mar  8 20:01:49 2002
--- src/gui_gtk_x11.c   Wed Mar 13 21:19:58 2002
***************
*** 2686,2692 ****
     {
       gui.norm_font = NOFONT;
       gui.fontset = (GuiFontset)font;
!       gui.char_width = gdk_string_width(font, " ");
     }
     else
 #endif
--- 2686,2694 ----
     {
       gui.norm_font = NOFONT;
       gui.fontset = (GuiFontset)font;
!       /* Use two bytes, this works around the problem that the result would
!        * be zero if no 8-bit font was found. */
!       gui.char_width = gdk_string_width(font, "xW") / 2;
     }
     else
 #endif
***************
*** 2698,2703 ****
--- 2700,2709 ----
       gui.char_width = ((XFontStruct *)
                                     GDK_FONT_XFONT(font))->max_bounds.width;
     }
+
+     /* A zero width may cause a crash.  Happens for semi-invalid fontsets. */
+     if (gui.char_width <= 0)
+       gui.char_width = 8;

     gui.char_height = font->ascent + font->descent + p_linespace;
     gui.char_ascent = font->ascent + p_linespace / 2;
*** ../vim61b.015/src/version.c Fri Mar 15 21:59:22 2002
--- src/version.c       Fri Mar 15 22:20:18 2002
***************
*** 608,609 ****
--- 608,611 ----
 {   /* Add new patch number below this line */
+ /**/
+     16,
 /**/

--
ARTHUR:  Bloody peasant!
DENNIS:  Oh, what a give away.  Did you here that, did you here that, eh?
        That's what I'm on about -- did you see him repressing me, you saw it
        didn't you?
                                 The Quest for the Holy Grail (Monty Python)

///  Bram Moolenaar -- [email protected] -- http://www.moolenaar.net  \\\
///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
\\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
\\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///