[patch][gtk-960606] gdkfont sign-extension bug fix



Here is a small fix for a sign-extension bug in gdkfont.  On
Linux/Alpha it had the effect that gimp would crash if ~/.gimp did not
exist.

The patch below fixes the immediate problem, but looking at the code,
I do wonder whether the proper fix wouldn't be to make gchar an
unsigned type.

	--david

--- gtk+/gdk/gdkfont.c~	Wed Feb 26 05:00:43 1997
+++ gtk+/gdk/gdkfont.c	Sun Jun  8 11:46:40 1997
@@ -142,6 +142,7 @@
 {
   GdkFontPrivate *private;
   XCharStruct *chars;
+  guint ch = character & 0xff;	/* get rid of sign-extension */
   gint width;
 
   g_return_val_if_fail (font != NULL, -1);
@@ -150,12 +151,12 @@
 
   if ((private->xfont->min_byte1 == 0) &&
       (private->xfont->max_byte1 == 0) &&
-      (character >= private->xfont->min_char_or_byte2) &&
-      (character <= private->xfont->max_char_or_byte2))
+      (ch >= private->xfont->min_char_or_byte2) &&
+      (ch <= private->xfont->max_char_or_byte2))
     {
       chars = private->xfont->per_char;
       if (chars)
-	width = chars[character - private->xfont->min_char_or_byte2].width;
+	width = chars[ch - private->xfont->min_char_or_byte2].width;
       else
 	width = private->xfont->min_bounds.width;
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]