unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#17519: [PATCH] take into account QuantumScale when reading imagemagick images
@ 2014-05-17 13:25 Nicolas Léveillé
  2014-05-19 20:04 ` Paul Eggert
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Léveillé @ 2014-05-17 13:25 UTC (permalink / raw)
  To: 17519

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

Symptom:
On Macs with a freshly compiled "nexstep" emacs and no rsvg library, the splash screen displays a corrupted picture.

This patch is here corrects the "pixel pushing" (default) method for loading images from ImageMagick to properly interpret pixels from images loaded with ImageMagick compiled with any pixel quantum value. (Q32 for instance)

--

[-- Attachment #2: 0001-whitespace-cleanup-removed-tabs.patch --]
[-- Type: application/octet-stream, Size: 186692 bytes --]

From f67f342d1ed1ed36d9b10072e1e1ae3800bf1ed7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolas=20L=C3=A9veill=C3=A9?= <nicolas@uucidl.com>
Date: Sat, 17 May 2014 13:38:56 +0200
Subject: [PATCH 1/3] whitespace-cleanup (removed tabs)

---
 src/image.c | 3436 +++++++++++++++++++++++++++++------------------------------
 1 file changed, 1718 insertions(+), 1718 deletions(-)

diff --git a/src/image.c b/src/image.c
index 047f751..7ae417c 100644
--- a/src/image.c
+++ b/src/image.c
@@ -206,7 +206,7 @@ x_allocate_bitmap_record (struct frame *f)
 
   dpyinfo->bitmaps =
     xpalloc (dpyinfo->bitmaps, &dpyinfo->bitmaps_size,
-	     10, -1, sizeof *dpyinfo->bitmaps);
+             10, -1, sizeof *dpyinfo->bitmaps);
   return ++dpyinfo->bitmaps_last;
 }
 
@@ -229,7 +229,7 @@ x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsi
 #ifdef HAVE_X_WINDOWS
   Pixmap bitmap;
   bitmap = XCreateBitmapFromData (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-				  bits, width, height);
+                                  bits, width, height);
   if (! bitmap)
     return -1;
 #endif /* HAVE_X_WINDOWS */
@@ -237,9 +237,9 @@ x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsi
 #ifdef HAVE_NTGUI
   Pixmap bitmap;
   bitmap = CreateBitmap (width, height,
-			 FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes,
-			 FRAME_DISPLAY_INFO (XFRAME (frame))->n_cbits,
-			 bits);
+                         FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes,
+                         FRAME_DISPLAY_INFO (XFRAME (frame))->n_cbits,
+                         bits);
   if (! bitmap)
     return -1;
 #endif /* HAVE_NTGUI */
@@ -318,24 +318,24 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
   for (id = 0; id < dpyinfo->bitmaps_last; ++id)
     {
       if (dpyinfo->bitmaps[id].refcount
-	  && dpyinfo->bitmaps[id].file
-	  && !strcmp (dpyinfo->bitmaps[id].file, SSDATA (file)))
-	{
-	  ++dpyinfo->bitmaps[id].refcount;
-	  return id + 1;
-	}
+          && dpyinfo->bitmaps[id].file
+          && !strcmp (dpyinfo->bitmaps[id].file, SSDATA (file)))
+        {
+          ++dpyinfo->bitmaps[id].refcount;
+          return id + 1;
+        }
     }
 
   /* Search bitmap-file-path for the file, if appropriate.  */
   if (openp (Vx_bitmap_file_path, file, Qnil, &found,
-	     make_number (R_OK), false)
+             make_number (R_OK), false)
       < 0)
     return -1;
 
   filename = SSDATA (found);
 
   result = XReadBitmapFile (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-			    filename, &width, &height, &bitmap, &xhot, &yhot);
+                            filename, &width, &height, &bitmap, &xhot, &yhot);
   if (result != BitmapSuccess)
     return -1;
 
@@ -390,11 +390,11 @@ x_destroy_bitmap (struct frame *f, ptrdiff_t id)
       Bitmap_Record *bm = &dpyinfo->bitmaps[id - 1];
 
       if (--bm->refcount == 0)
-	{
-	  block_input ();
-	  free_bitmap_record (dpyinfo, bm);
-	  unblock_input ();
-	}
+        {
+          block_input ();
+          free_bitmap_record (dpyinfo, bm);
+          unblock_input ();
+        }
     }
 }
 
@@ -414,14 +414,14 @@ x_destroy_all_bitmaps (Display_Info *dpyinfo)
 }
 
 static bool x_create_x_image_and_pixmap (struct frame *, int, int, int,
-					 XImagePtr *, Pixmap *);
+                                         XImagePtr *, Pixmap *);
 static void x_destroy_x_image (XImagePtr ximg);
 
 #ifdef HAVE_NTGUI
 static XImagePtr_or_DC image_get_x_image_or_dc (struct frame *, struct image *,
-						bool, HGDIOBJ *);
+                                                bool, HGDIOBJ *);
 static void image_unget_x_image_or_dc (struct image *, bool, XImagePtr_or_DC,
-				       HGDIOBJ);
+                                       HGDIOBJ);
 #else
 static XImagePtr image_get_x_image (struct frame *, struct image *, bool);
 static void image_unget_x_image (struct image *, bool, XImagePtr);
@@ -469,7 +469,7 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
 
   block_input ();
   ximg = XGetImage (FRAME_X_DISPLAY (f), pixmap, 0, 0, width, height,
-		    ~0, ZPixmap);
+                    ~0, ZPixmap);
 
   if (!ximg)
     {
@@ -491,30 +491,30 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
   for (y = 0; y < ximg->height; ++y)
     {
       for (x = 0; x < ximg->width; ++x)
-	{
-	  xp = x != ximg->width - 1 ? x + 1 : 0;
-	  xm = x != 0 ? x - 1 : ximg->width - 1;
-	  yp = y != ximg->height - 1 ? y + 1 : 0;
-	  ym = y != 0 ? y - 1 : ximg->height - 1;
-	  if (XGetPixel (ximg, x, y) == bg
-	      && XGetPixel (ximg, x, yp) == bg
-	      && XGetPixel (ximg, x, ym) == bg
-	      && XGetPixel (ximg, xp, y) == bg
-	      && XGetPixel (ximg, xp, yp) == bg
-	      && XGetPixel (ximg, xp, ym) == bg
-	      && XGetPixel (ximg, xm, y) == bg
-	      && XGetPixel (ximg, xm, yp) == bg
-	      && XGetPixel (ximg, xm, ym) == bg)
-	    XPutPixel (mask_img, x, y, 0);
-	  else
-	    XPutPixel (mask_img, x, y, 1);
-	}
+        {
+          xp = x != ximg->width - 1 ? x + 1 : 0;
+          xm = x != 0 ? x - 1 : ximg->width - 1;
+          yp = y != ximg->height - 1 ? y + 1 : 0;
+          ym = y != 0 ? y - 1 : ximg->height - 1;
+          if (XGetPixel (ximg, x, y) == bg
+              && XGetPixel (ximg, x, yp) == bg
+              && XGetPixel (ximg, x, ym) == bg
+              && XGetPixel (ximg, xp, y) == bg
+              && XGetPixel (ximg, xp, yp) == bg
+              && XGetPixel (ximg, xp, ym) == bg
+              && XGetPixel (ximg, xm, y) == bg
+              && XGetPixel (ximg, xm, yp) == bg
+              && XGetPixel (ximg, xm, ym) == bg)
+            XPutPixel (mask_img, x, y, 0);
+          else
+            XPutPixel (mask_img, x, y, 1);
+        }
     }
 
   eassert (input_blocked_p ());
   gc = XCreateGC (FRAME_X_DISPLAY (f), mask, 0, NULL);
   XPutImage (FRAME_X_DISPLAY (f), mask, gc, mask_img, 0, 0, 0, 0,
-	     width, height);
+             width, height);
   XFreeGC (FRAME_X_DISPLAY (f), gc);
 
   dpyinfo->bitmaps[id - 1].have_mask = true;
@@ -528,7 +528,7 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
 
 
 /***********************************************************************
-			    Image types
+                            Image types
  ***********************************************************************/
 
 /* List of supported image types.  Use define_image_type to add new
@@ -593,13 +593,13 @@ define_image_type (struct image_type *type)
       /* If we failed to load the library before, don't try again.  */
       Lisp_Object tested = Fassq (target_type, Vlibrary_cache);
       if (CONSP (tested) && NILP (XCDR (tested)))
-	type_valid = 0;
+        type_valid = 0;
       else
 #endif
-	{
-	  type_valid = type->init ();
-	  CACHE_IMAGE_TYPE (target_type, type_valid ? Qt : Qnil);
-	}
+        {
+          type_valid = type->init ();
+          CACHE_IMAGE_TYPE (target_type, type_valid ? Qt : Qnil);
+        }
     }
 
   if (type_valid)
@@ -635,19 +635,19 @@ valid_image_p (Lisp_Object object)
       Lisp_Object tem;
 
       for (tem = XCDR (object); CONSP (tem); tem = XCDR (tem))
-	if (EQ (XCAR (tem), QCtype))
-	  {
-	    tem = XCDR (tem);
-	    if (CONSP (tem) && SYMBOLP (XCAR (tem)))
-	      {
-		struct image_type *type;
-		type = lookup_image_type (XCAR (tem));
-		if (type)
-		  valid_p = type->valid_p (object);
-	      }
+        if (EQ (XCAR (tem), QCtype))
+          {
+            tem = XCDR (tem);
+            if (CONSP (tem) && SYMBOLP (XCAR (tem)))
+              {
+                struct image_type *type;
+                type = lookup_image_type (XCAR (tem));
+                if (type)
+                  valid_p = type->valid_p (object);
+              }
 
-	    break;
-	  }
+            break;
+          }
     }
 
   return valid_p;
@@ -669,7 +669,7 @@ image_error (const char *format, Lisp_Object arg1, Lisp_Object arg2)
 
 \f
 /***********************************************************************
-			 Image specifications
+                         Image specifications
  ***********************************************************************/
 
 enum image_value_type
@@ -717,7 +717,7 @@ struct image_keyword
 
 static bool
 parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
-		  int nkeywords, Lisp_Object type)
+                  int nkeywords, Lisp_Object type)
 {
   int i;
   Lisp_Object plist;
@@ -734,107 +734,107 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
       key = XCAR (plist);
       plist = XCDR (plist);
       if (!SYMBOLP (key))
-	return 0;
+        return 0;
 
       /* There must follow a value.  */
       if (!CONSP (plist))
-	return 0;
+        return 0;
       value = XCAR (plist);
       plist = XCDR (plist);
 
       /* Find key in KEYWORDS.  Error if not found.  */
       for (i = 0; i < nkeywords; ++i)
-	if (strcmp (keywords[i].name, SSDATA (SYMBOL_NAME (key))) == 0)
-	  break;
+        if (strcmp (keywords[i].name, SSDATA (SYMBOL_NAME (key))) == 0)
+          break;
 
       if (i == nkeywords)
-	continue;
+        continue;
 
       /* Record that we recognized the keyword.  If a keywords
-	 was found more than once, it's an error.  */
+         was found more than once, it's an error.  */
       keywords[i].value = value;
       if (keywords[i].count > 1)
-	return 0;
+        return 0;
       ++keywords[i].count;
 
       /* Check type of value against allowed type.  */
       switch (keywords[i].type)
-	{
-	case IMAGE_STRING_VALUE:
-	  if (!STRINGP (value))
-	    return 0;
-	  break;
-
-	case IMAGE_STRING_OR_NIL_VALUE:
-	  if (!STRINGP (value) && !NILP (value))
-	    return 0;
-	  break;
-
-	case IMAGE_SYMBOL_VALUE:
-	  if (!SYMBOLP (value))
-	    return 0;
-	  break;
-
-	case IMAGE_POSITIVE_INTEGER_VALUE:
-	  if (! RANGED_INTEGERP (1, value, INT_MAX))
-	    return 0;
-	  break;
-
-	case IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR:
-	  if (RANGED_INTEGERP (0, value, INT_MAX))
-	    break;
-	  if (CONSP (value)
-	      && RANGED_INTEGERP (0, XCAR (value), INT_MAX)
-	      && RANGED_INTEGERP (0, XCDR (value), INT_MAX))
-	    break;
-	  return 0;
-
-	case IMAGE_ASCENT_VALUE:
-	  if (SYMBOLP (value) && EQ (value, Qcenter))
-	    break;
-	  else if (RANGED_INTEGERP (0, value, 100))
-	    break;
-	  return 0;
-
-	case IMAGE_NON_NEGATIVE_INTEGER_VALUE:
-	  /* Unlike the other integer-related cases, this one does not
-	     verify that VALUE fits in 'int'.  This is because callers
-	     want EMACS_INT.  */
-	  if (!INTEGERP (value) || XINT (value) < 0)
-	    return 0;
-	  break;
-
-	case IMAGE_DONT_CHECK_VALUE_TYPE:
-	  break;
-
-	case IMAGE_FUNCTION_VALUE:
-	  value = indirect_function (value);
-	  if (!NILP (Ffunctionp (value)))
-	    break;
-	  return 0;
-
-	case IMAGE_NUMBER_VALUE:
-	  if (!INTEGERP (value) && !FLOATP (value))
-	    return 0;
-	  break;
-
-	case IMAGE_INTEGER_VALUE:
-	  if (! TYPE_RANGED_INTEGERP (int, value))
-	    return 0;
-	  break;
-
-	case IMAGE_BOOL_VALUE:
-	  if (!NILP (value) && !EQ (value, Qt))
-	    return 0;
-	  break;
-
-	default:
-	  emacs_abort ();
-	  break;
-	}
+        {
+        case IMAGE_STRING_VALUE:
+          if (!STRINGP (value))
+            return 0;
+          break;
+
+        case IMAGE_STRING_OR_NIL_VALUE:
+          if (!STRINGP (value) && !NILP (value))
+            return 0;
+          break;
+
+        case IMAGE_SYMBOL_VALUE:
+          if (!SYMBOLP (value))
+            return 0;
+          break;
+
+        case IMAGE_POSITIVE_INTEGER_VALUE:
+          if (! RANGED_INTEGERP (1, value, INT_MAX))
+            return 0;
+          break;
+
+        case IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR:
+          if (RANGED_INTEGERP (0, value, INT_MAX))
+            break;
+          if (CONSP (value)
+              && RANGED_INTEGERP (0, XCAR (value), INT_MAX)
+              && RANGED_INTEGERP (0, XCDR (value), INT_MAX))
+            break;
+          return 0;
+
+        case IMAGE_ASCENT_VALUE:
+          if (SYMBOLP (value) && EQ (value, Qcenter))
+            break;
+          else if (RANGED_INTEGERP (0, value, 100))
+            break;
+          return 0;
+
+        case IMAGE_NON_NEGATIVE_INTEGER_VALUE:
+          /* Unlike the other integer-related cases, this one does not
+             verify that VALUE fits in 'int'.  This is because callers
+             want EMACS_INT.  */
+          if (!INTEGERP (value) || XINT (value) < 0)
+            return 0;
+          break;
+
+        case IMAGE_DONT_CHECK_VALUE_TYPE:
+          break;
+
+        case IMAGE_FUNCTION_VALUE:
+          value = indirect_function (value);
+          if (!NILP (Ffunctionp (value)))
+            break;
+          return 0;
+
+        case IMAGE_NUMBER_VALUE:
+          if (!INTEGERP (value) && !FLOATP (value))
+            return 0;
+          break;
+
+        case IMAGE_INTEGER_VALUE:
+          if (! TYPE_RANGED_INTEGERP (int, value))
+            return 0;
+          break;
+
+        case IMAGE_BOOL_VALUE:
+          if (!NILP (value) && !EQ (value, Qt))
+            return 0;
+          break;
+
+        default:
+          emacs_abort ();
+          break;
+        }
 
       if (EQ (key, QCtype) && !EQ (type, value))
-	return 0;
+        return 0;
     }
 
   /* Check that all mandatory fields are present.  */
@@ -862,11 +862,11 @@ image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
        tail = XCDR (XCDR (tail)))
     {
       if (EQ (XCAR (tail), key))
-	{
-	  if (found)
-	    *found = 1;
-	  return XCAR (XCDR (tail));
-	}
+        {
+          if (found)
+            *found = 1;
+          return XCAR (XCDR (tail));
+        }
     }
 
   if (found)
@@ -895,10 +895,10 @@ or omitted means use the selected frame.  */)
       int height = img->height + 2 * img->vmargin;
 
       if (NILP (pixels))
-	size = Fcons (make_float ((double) width / FRAME_COLUMN_WIDTH (f)),
-		      make_float ((double) height / FRAME_LINE_HEIGHT (f)));
+        size = Fcons (make_float ((double) width / FRAME_COLUMN_WIDTH (f)),
+                      make_float ((double) height / FRAME_LINE_HEIGHT (f)));
       else
-	size = Fcons (make_number (width), make_number (height));
+        size = Fcons (make_number (width), make_number (height));
     }
   else
     error ("Invalid image specification");
@@ -922,7 +922,7 @@ or omitted means use the selected frame.  */)
       ptrdiff_t id = lookup_image (f, spec);
       struct image *img = IMAGE_FROM_ID (f, id);
       if (img->mask)
-	mask = Qt;
+        mask = Qt;
     }
   else
     error ("Invalid image specification");
@@ -952,7 +952,7 @@ or omitted means use the selected frame.  */)
 
 \f
 /***********************************************************************
-		 Image type independent image structures
+                 Image type independent image structures
  ***********************************************************************/
 
 #define MAX_IMAGE_SIZE 10.0
@@ -989,12 +989,12 @@ free_image (struct frame *f, struct image *img)
 
       /* Remove IMG from the hash table of its cache.  */
       if (img->prev)
-	img->prev->next = img->next;
+        img->prev->next = img->next;
       else
-	c->buckets[img->hash % IMAGE_CACHE_BUCKETS_SIZE] = img->next;
+        c->buckets[img->hash % IMAGE_CACHE_BUCKETS_SIZE] = img->next;
 
       if (img->next)
-	img->next->prev = img->prev;
+        img->next->prev = img->prev;
 
       c->images[img->id] = NULL;
 
@@ -1016,18 +1016,18 @@ check_image_size (struct frame *f, int width, int height)
 
   if (INTEGERP (Vmax_image_size))
     return (width <= XINT (Vmax_image_size)
-	    && height <= XINT (Vmax_image_size));
+            && height <= XINT (Vmax_image_size));
   else if (FLOATP (Vmax_image_size))
     {
       if (f != NULL)
-	{
-	  w = FRAME_PIXEL_WIDTH (f);
-	  h = FRAME_PIXEL_HEIGHT (f);
-	}
+        {
+          w = FRAME_PIXEL_WIDTH (f);
+          h = FRAME_PIXEL_HEIGHT (f);
+        }
       else
-	w = h = 1024;  /* Arbitrary size for unknown frame. */
+        w = h = 1024;  /* Arbitrary size for unknown frame. */
       return (width <= XFLOAT_DATA (Vmax_image_size) * w
-	      && height <= XFLOAT_DATA (Vmax_image_size) * h);
+              && height <= XFLOAT_DATA (Vmax_image_size) * h);
     }
   else
     return 1;
@@ -1077,23 +1077,23 @@ image_ascent (struct image *img, struct face *face, struct glyph_slice *slice)
   if (img->ascent == CENTERED_IMAGE_ASCENT)
     {
       if (face->font)
-	{
+        {
 #ifdef HAVE_NTGUI
-	  /* W32 specific version.  Why?. ++kfs  */
-	  ascent = height / 2 - (FONT_DESCENT (face->font)
-				 - FONT_BASE (face->font)) / 2;
+          /* W32 specific version.  Why?. ++kfs  */
+          ascent = height / 2 - (FONT_DESCENT (face->font)
+                                 - FONT_BASE (face->font)) / 2;
 #else
-	  /* This expression is arranged so that if the image can't be
-	     exactly centered, it will be moved slightly up.  This is
-	     because a typical font is `top-heavy' (due to the presence
-	     uppercase letters), so the image placement should err towards
-	     being top-heavy too.  It also just generally looks better.  */
-	  ascent = (height + FONT_BASE (face->font)
+          /* This expression is arranged so that if the image can't be
+             exactly centered, it will be moved slightly up.  This is
+             because a typical font is `top-heavy' (due to the presence
+             uppercase letters), so the image placement should err towards
+             being top-heavy too.  It also just generally looks better.  */
+          ascent = (height + FONT_BASE (face->font)
                     - FONT_DESCENT (face->font) + 1) / 2;
 #endif /* HAVE_NTGUI */
-	}
+        }
       else
-	ascent = height / 2;
+        ascent = height / 2;
     }
   else
     ascent = height * (img->ascent / 100.0);
@@ -1109,7 +1109,7 @@ image_ascent (struct image *img, struct face *face, struct glyph_slice *slice)
 
 static RGB_PIXEL_COLOR
 four_corners_best (XImagePtr_or_DC ximg, int *corners,
-		   unsigned long width, unsigned long height)
+                   unsigned long width, unsigned long height)
 {
   RGB_PIXEL_COLOR corner_pixels[4], best IF_LINT (= 0);
   int i, best_count;
@@ -1136,11 +1136,11 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners,
       int j, n;
 
       for (j = n = 0; j < 4; ++j)
-	if (corner_pixels[i] == corner_pixels[j])
-	  ++n;
+        if (corner_pixels[i] == corner_pixels[j])
+          ++n;
 
       if (n > best_count)
-	best = corner_pixels[i], best_count = n;
+        best = corner_pixels[i], best_count = n;
     }
 
   return best;
@@ -1183,12 +1183,12 @@ image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg)
 #endif /* HAVE_NTGUI */
 
       if (free_ximg)
-	ximg = image_get_x_image_or_dc (f, img, 0, &prev);
+        ximg = image_get_x_image_or_dc (f, img, 0, &prev);
 
       img->background = four_corners_best (ximg, img->corners, img->width, img->height);
 
       if (free_ximg)
-	image_unget_x_image_or_dc (img, 0, ximg, prev);
+        image_unget_x_image_or_dc (img, 0, ximg, prev);
 
       img->background_valid = 1;
     }
@@ -1207,23 +1207,23 @@ image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_D
     /* IMG doesn't have a background yet, try to guess a reasonable value.  */
     {
       if (img->mask)
-	{
-	  bool free_mask = !mask;
+        {
+          bool free_mask = !mask;
 #ifdef HAVE_NTGUI
-	  HGDIOBJ prev;
+          HGDIOBJ prev;
 #endif /* HAVE_NTGUI */
 
-	  if (free_mask)
-	    mask = image_get_x_image_or_dc (f, img, 1, &prev);
+          if (free_mask)
+            mask = image_get_x_image_or_dc (f, img, 1, &prev);
 
-	  img->background_transparent
-	    = (four_corners_best (mask, img->corners, img->width, img->height) == PIX_MASK_RETAIN);
+          img->background_transparent
+            = (four_corners_best (mask, img->corners, img->width, img->height) == PIX_MASK_RETAIN);
 
-	  if (free_mask)
-	    image_unget_x_image_or_dc (img, 1, mask, prev);
-	}
+          if (free_mask)
+            image_unget_x_image_or_dc (img, 1, mask, prev);
+        }
       else
-	img->background_transparent = 0;
+        img->background_transparent = 0;
 
       img->background_transparent_valid = 1;
     }
@@ -1245,7 +1245,7 @@ x_query_frame_background_color (struct frame *f, XColor *bgcolor)
 
 \f
 /***********************************************************************
-		  Helper functions for X image types
+                  Helper functions for X image types
  ***********************************************************************/
 
 /* Clear X resources of image IMG on frame F according to FLAGS.
@@ -1265,37 +1265,37 @@ x_clear_image_1 (struct frame *f, struct image *img, int flags)
   if (flags & CLEAR_IMAGE_PIXMAP)
     {
       if (img->pixmap)
-	{
-	  Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap);
-	  img->pixmap = NO_PIXMAP;
-	  /* NOTE (HAVE_NS): background color is NOT an indexed color! */
-	  img->background_valid = 0;
-	}
+        {
+          Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap);
+          img->pixmap = NO_PIXMAP;
+          /* NOTE (HAVE_NS): background color is NOT an indexed color! */
+          img->background_valid = 0;
+        }
 #ifdef HAVE_X_WINDOWS
       if (img->ximg)
-	{
-	  x_destroy_x_image (img->ximg);
-	  img->ximg = NULL;
-	  img->background_valid = 0;
-	}
+        {
+          x_destroy_x_image (img->ximg);
+          img->ximg = NULL;
+          img->background_valid = 0;
+        }
 #endif
     }
 
   if (flags & CLEAR_IMAGE_MASK)
     {
       if (img->mask)
-	{
-	  Free_Pixmap (FRAME_X_DISPLAY (f), img->mask);
-	  img->mask = NO_PIXMAP;
-	  img->background_transparent_valid = 0;
-	}
+        {
+          Free_Pixmap (FRAME_X_DISPLAY (f), img->mask);
+          img->mask = NO_PIXMAP;
+          img->background_transparent_valid = 0;
+        }
 #ifdef HAVE_X_WINDOWS
       if (img->mask_img)
-	{
-	  x_destroy_x_image (img->mask_img);
-	  img->mask_img = NULL;
-	  img->background_transparent_valid = 0;
-	}
+        {
+          x_destroy_x_image (img->mask_img);
+          img->mask_img = NULL;
+          img->background_transparent_valid = 0;
+        }
 #endif
     }
 
@@ -1319,7 +1319,7 @@ x_clear_image (struct frame *f, struct image *img)
 {
   block_input ();
   x_clear_image_1 (f, img,
-		   CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_MASK | CLEAR_IMAGE_COLORS);
+                   CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_MASK | CLEAR_IMAGE_COLORS);
   unblock_input ();
 }
 
@@ -1331,7 +1331,7 @@ x_clear_image (struct frame *f, struct image *img)
 
 static unsigned long
 x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object color_name,
-		     unsigned long dflt)
+                     unsigned long dflt)
 {
   XColor color;
   unsigned long result;
@@ -1340,10 +1340,10 @@ x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object color_name,
 
   if (x_defined_color (f, SSDATA (color_name), &color, 1)
       && img->ncolors < min (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *img->colors,
-			     INT_MAX))
+                             INT_MAX))
     {
       /* This isn't called frequently so we get away with simply
-	 reallocating the color vector to the needed size, here.  */
+         reallocating the color vector to the needed size, here.  */
       ptrdiff_t ncolors = img->ncolors + 1;
       img->colors = xrealloc (img->colors, ncolors * sizeof *img->colors);
       img->colors[ncolors - 1] = color.pixel;
@@ -1359,7 +1359,7 @@ x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object color_name,
 
 \f
 /***********************************************************************
-			     Image Cache
+                             Image Cache
  ***********************************************************************/
 
 static void cache_image (struct frame *f, struct image *img);
@@ -1405,9 +1405,9 @@ search_image_cache (struct frame *f, Lisp_Object spec, EMACS_UINT hash)
 
   for (img = c->buckets[i]; img; img = img->next)
     if (img->hash == hash
-	&& !NILP (Fequal (img->spec, spec))
-	&& img->frame_foreground == FRAME_FOREGROUND_PIXEL (f)
-	&& img->frame_background == FRAME_BACKGROUND_PIXEL (f))
+        && !NILP (Fequal (img->spec, spec))
+        && img->frame_foreground == FRAME_FOREGROUND_PIXEL (f)
+        && img->frame_background == FRAME_BACKGROUND_PIXEL (f))
       break;
   return img;
 }
@@ -1423,7 +1423,7 @@ uncache_image (struct frame *f, Lisp_Object spec)
     {
       free_image (f, img);
       /* As display glyphs may still be referring to the image ID, we
-	 must garbage the frame (Bug#6426).  */
+         must garbage the frame (Bug#6426).  */
       SET_FRAME_GARBAGED (f);
     }
 }
@@ -1444,7 +1444,7 @@ free_image_cache (struct frame *f)
       eassert (c->refcount == 0);
 
       for (i = 0; i < c->used; ++i)
-	free_image (f, c->images[i]);
+        free_image (f, c->images[i]);
       xfree (c->images);
       xfree (c->buckets);
       xfree (c);
@@ -1471,72 +1471,72 @@ clear_image_cache (struct frame *f, Lisp_Object filter)
       ptrdiff_t i, nfreed = 0;
 
       /* Block input so that we won't be interrupted by a SIGIO
-	 while being in an inconsistent state.  */
+         while being in an inconsistent state.  */
       block_input ();
 
       if (!NILP (filter))
-	{
-	  /* Filter image cache.  */
-	  for (i = 0; i < c->used; ++i)
-	    {
-	      struct image *img = c->images[i];
-	      if (img && (EQ (Qt, filter)
-			  || !NILP (Fmember (filter, img->dependencies))))
-		{
-		  free_image (f, img);
-		  ++nfreed;
-		}
-	    }
-	}
+        {
+          /* Filter image cache.  */
+          for (i = 0; i < c->used; ++i)
+            {
+              struct image *img = c->images[i];
+              if (img && (EQ (Qt, filter)
+                          || !NILP (Fmember (filter, img->dependencies))))
+                {
+                  free_image (f, img);
+                  ++nfreed;
+                }
+            }
+        }
       else if (INTEGERP (Vimage_cache_eviction_delay))
-	{
-	  /* Free cache based on timestamp.  */
-	  struct timespec old, t;
-	  double delay;
-	  ptrdiff_t nimages = 0;
-
-	  for (i = 0; i < c->used; ++i)
-	    if (c->images[i])
-	      nimages++;
-
-	  /* If the number of cached images has grown unusually large,
-	     decrease the cache eviction delay (Bug#6230).  */
-	  delay = XINT (Vimage_cache_eviction_delay);
-	  if (nimages > 40)
-	    delay = 1600 * delay / nimages / nimages;
-	  delay = max (delay, 1);
-
-	  t = current_timespec ();
-	  old = timespec_sub (t, dtotimespec (delay));
-
-	  for (i = 0; i < c->used; ++i)
-	    {
-	      struct image *img = c->images[i];
-	      if (img && timespec_cmp (img->timestamp, old) < 0)
-		{
-		  free_image (f, img);
-		  ++nfreed;
-		}
-	    }
-	}
+        {
+          /* Free cache based on timestamp.  */
+          struct timespec old, t;
+          double delay;
+          ptrdiff_t nimages = 0;
+
+          for (i = 0; i < c->used; ++i)
+            if (c->images[i])
+              nimages++;
+
+          /* If the number of cached images has grown unusually large,
+             decrease the cache eviction delay (Bug#6230).  */
+          delay = XINT (Vimage_cache_eviction_delay);
+          if (nimages > 40)
+            delay = 1600 * delay / nimages / nimages;
+          delay = max (delay, 1);
+
+          t = current_timespec ();
+          old = timespec_sub (t, dtotimespec (delay));
+
+          for (i = 0; i < c->used; ++i)
+            {
+              struct image *img = c->images[i];
+              if (img && timespec_cmp (img->timestamp, old) < 0)
+                {
+                  free_image (f, img);
+                  ++nfreed;
+                }
+            }
+        }
 
       /* We may be clearing the image cache because, for example,
-	 Emacs was iconified for a longer period of time.  In that
-	 case, current matrices may still contain references to
-	 images freed above.  So, clear these matrices.  */
+         Emacs was iconified for a longer period of time.  In that
+         case, current matrices may still contain references to
+         images freed above.  So, clear these matrices.  */
       if (nfreed)
-	{
-	  Lisp_Object tail, frame;
+        {
+          Lisp_Object tail, frame;
 
-	  FOR_EACH_FRAME (tail, frame)
-	    {
-	      struct frame *fr = XFRAME (frame);
-	      if (FRAME_IMAGE_CACHE (fr) == c)
-		clear_current_matrices (fr);
-	    }
+          FOR_EACH_FRAME (tail, frame)
+            {
+              struct frame *fr = XFRAME (frame);
+              if (FRAME_IMAGE_CACHE (fr) == c)
+                clear_current_matrices (fr);
+            }
 
-	  windows_or_buffers_changed = 19;
-	}
+          windows_or_buffers_changed = 19;
+        }
 
       unblock_input ();
     }
@@ -1591,11 +1591,11 @@ FRAME t means refresh the image on all frames.  */)
     {
       Lisp_Object tail;
       FOR_EACH_FRAME (tail, frame)
-	{
-	  struct frame *f = XFRAME (frame);
-	  if (FRAME_WINDOW_P (f))
-	    uncache_image (f, spec);
-	}
+        {
+          struct frame *f = XFRAME (frame);
+          if (FRAME_WINDOW_P (f))
+            uncache_image (f, spec);
+        }
     }
   else
     uncache_image (decode_window_system_frame (frame), spec);
@@ -1619,57 +1619,57 @@ postprocess_image (struct frame *f, struct image *img)
       spec = img->spec;
 
       /* `:heuristic-mask t'
-	 `:mask heuristic'
-	 means build a mask heuristically.
-	 `:heuristic-mask (R G B)'
-	 `:mask (heuristic (R G B))'
-	 means build a mask from color (R G B) in the
-	 image.
-	 `:mask nil'
-	 means remove a mask, if any.  */
+         `:mask heuristic'
+         means build a mask heuristically.
+         `:heuristic-mask (R G B)'
+         `:mask (heuristic (R G B))'
+         means build a mask from color (R G B) in the
+         image.
+         `:mask nil'
+         means remove a mask, if any.  */
 
       mask = image_spec_value (spec, QCheuristic_mask, NULL);
       if (!NILP (mask))
-	x_build_heuristic_mask (f, img, mask);
+        x_build_heuristic_mask (f, img, mask);
       else
-	{
-	  bool found_p;
-
-	  mask = image_spec_value (spec, QCmask, &found_p);
-
-	  if (EQ (mask, Qheuristic))
-	    x_build_heuristic_mask (f, img, Qt);
-	  else if (CONSP (mask)
-		   && EQ (XCAR (mask), Qheuristic))
-	    {
-	      if (CONSP (XCDR (mask)))
-		x_build_heuristic_mask (f, img, XCAR (XCDR (mask)));
-	      else
-		x_build_heuristic_mask (f, img, XCDR (mask));
-	    }
-	  else if (NILP (mask) && found_p && img->mask)
-	    x_clear_image_1 (f, img, CLEAR_IMAGE_MASK);
-	}
+        {
+          bool found_p;
+
+          mask = image_spec_value (spec, QCmask, &found_p);
+
+          if (EQ (mask, Qheuristic))
+            x_build_heuristic_mask (f, img, Qt);
+          else if (CONSP (mask)
+                   && EQ (XCAR (mask), Qheuristic))
+            {
+              if (CONSP (XCDR (mask)))
+                x_build_heuristic_mask (f, img, XCAR (XCDR (mask)));
+              else
+                x_build_heuristic_mask (f, img, XCDR (mask));
+            }
+          else if (NILP (mask) && found_p && img->mask)
+            x_clear_image_1 (f, img, CLEAR_IMAGE_MASK);
+        }
 
 
       /* Should we apply an image transformation algorithm?  */
       conversion = image_spec_value (spec, QCconversion, NULL);
       if (EQ (conversion, Qdisabled))
-	x_disable_image (f, img);
+        x_disable_image (f, img);
       else if (EQ (conversion, Qlaplace))
-	x_laplace (f, img);
+        x_laplace (f, img);
       else if (EQ (conversion, Qemboss))
-	x_emboss (f, img);
+        x_emboss (f, img);
       else if (CONSP (conversion)
-	       && EQ (XCAR (conversion), Qedge_detection))
-	{
-	  Lisp_Object tem;
-	  tem = XCDR (conversion);
-	  if (CONSP (tem))
-	    x_edge_detection (f, img,
-			      Fplist_get (tem, QCmatrix),
-			      Fplist_get (tem, QCcolor_adjustment));
-	}
+               && EQ (XCAR (conversion), Qedge_detection))
+        {
+          Lisp_Object tem;
+          tem = XCDR (conversion);
+          if (CONSP (tem))
+            x_edge_detection (f, img,
+                              Fplist_get (tem, QCmatrix),
+                              Fplist_get (tem, QCcolor_adjustment));
+        }
     }
 }
 
@@ -1708,68 +1708,68 @@ lookup_image (struct frame *f, Lisp_Object spec)
       img->frame_background = FRAME_BACKGROUND_PIXEL (f);
 
       /* If we can't load the image, and we don't have a width and
-	 height, use some arbitrary width and height so that we can
-	 draw a rectangle for it.  */
+         height, use some arbitrary width and height so that we can
+         draw a rectangle for it.  */
       if (img->load_failed_p)
-	{
-	  Lisp_Object value;
-
-	  value = image_spec_value (spec, QCwidth, NULL);
-	  img->width = (INTEGERP (value)
-			? XFASTINT (value) : DEFAULT_IMAGE_WIDTH);
-	  value = image_spec_value (spec, QCheight, NULL);
-	  img->height = (INTEGERP (value)
-			 ? XFASTINT (value) : DEFAULT_IMAGE_HEIGHT);
-	}
+        {
+          Lisp_Object value;
+
+          value = image_spec_value (spec, QCwidth, NULL);
+          img->width = (INTEGERP (value)
+                        ? XFASTINT (value) : DEFAULT_IMAGE_WIDTH);
+          value = image_spec_value (spec, QCheight, NULL);
+          img->height = (INTEGERP (value)
+                         ? XFASTINT (value) : DEFAULT_IMAGE_HEIGHT);
+        }
       else
-	{
-	  /* Handle image type independent image attributes
-	     `:ascent ASCENT', `:margin MARGIN', `:relief RELIEF',
-	     `:background COLOR'.  */
-	  Lisp_Object ascent, margin, relief, bg;
-	  int relief_bound;
-
-	  ascent = image_spec_value (spec, QCascent, NULL);
-	  if (INTEGERP (ascent))
-	    img->ascent = XFASTINT (ascent);
-	  else if (EQ (ascent, Qcenter))
-	    img->ascent = CENTERED_IMAGE_ASCENT;
-
-	  margin = image_spec_value (spec, QCmargin, NULL);
-	  if (INTEGERP (margin))
-	    img->vmargin = img->hmargin = XFASTINT (margin);
-	  else if (CONSP (margin))
-	    {
-	      img->hmargin = XFASTINT (XCAR (margin));
-	      img->vmargin = XFASTINT (XCDR (margin));
-	    }
-
-	  relief = image_spec_value (spec, QCrelief, NULL);
-	  relief_bound = INT_MAX - max (img->hmargin, img->vmargin);
-	  if (RANGED_INTEGERP (- relief_bound, relief, relief_bound))
-	    {
-	      img->relief = XINT (relief);
-	      img->hmargin += eabs (img->relief);
-	      img->vmargin += eabs (img->relief);
-	    }
-
-	  if (! img->background_valid)
-	    {
-	      bg = image_spec_value (img->spec, QCbackground, NULL);
-	      if (!NILP (bg))
-		{
-		  img->background
-		    = x_alloc_image_color (f, img, bg,
-					   FRAME_BACKGROUND_PIXEL (f));
-		  img->background_valid = 1;
-		}
-	    }
-
-	  /* Do image transformations and compute masks, unless we
-	     don't have the image yet.  */
-	  if (!EQ (*img->type->type, Qpostscript))
-	    postprocess_image (f, img);
-	}
+        {
+          /* Handle image type independent image attributes
+             `:ascent ASCENT', `:margin MARGIN', `:relief RELIEF',
+             `:background COLOR'.  */
+          Lisp_Object ascent, margin, relief, bg;
+          int relief_bound;
+
+          ascent = image_spec_value (spec, QCascent, NULL);
+          if (INTEGERP (ascent))
+            img->ascent = XFASTINT (ascent);
+          else if (EQ (ascent, Qcenter))
+            img->ascent = CENTERED_IMAGE_ASCENT;
+
+          margin = image_spec_value (spec, QCmargin, NULL);
+          if (INTEGERP (margin))
+            img->vmargin = img->hmargin = XFASTINT (margin);
+          else if (CONSP (margin))
+            {
+              img->hmargin = XFASTINT (XCAR (margin));
+              img->vmargin = XFASTINT (XCDR (margin));
+            }
+
+          relief = image_spec_value (spec, QCrelief, NULL);
+          relief_bound = INT_MAX - max (img->hmargin, img->vmargin);
+          if (RANGED_INTEGERP (- relief_bound, relief, relief_bound))
+            {
+              img->relief = XINT (relief);
+              img->hmargin += eabs (img->relief);
+              img->vmargin += eabs (img->relief);
+            }
+
+          if (! img->background_valid)
+            {
+              bg = image_spec_value (img->spec, QCbackground, NULL);
+              if (!NILP (bg))
+                {
+                  img->background
+                    = x_alloc_image_color (f, img, bg,
+                                           FRAME_BACKGROUND_PIXEL (f));
+                  img->background_valid = 1;
+                }
+            }
+
+          /* Do image transformations and compute masks, unless we
+             don't have the image yet.  */
+          if (!EQ (*img->type->type, Qpostscript))
+            postprocess_image (f, img);
+        }
 
       unblock_input ();
     }
@@ -1838,15 +1838,15 @@ mark_image_cache (struct image_cache *c)
     {
       ptrdiff_t i;
       for (i = 0; i < c->used; ++i)
-	if (c->images[i])
-	  mark_image (c->images[i]);
+        if (c->images[i])
+          mark_image (c->images[i]);
     }
 }
 
 
 \f
 /***********************************************************************
-			  X / NS / W32 support code
+                          X / NS / W32 support code
  ***********************************************************************/
 
 #ifdef WINDOWSNT
@@ -1893,7 +1893,7 @@ x_check_image_size (XImagePtr ximg, int width, int height)
       bytes_per_line = (width >> 3) + ((width & 7) != 0);
     }
   return (width <= (INT_MAX - (bitmap_pad - 1)) / depth
-	  && height <= X_IMAGE_BYTES_MAX / bytes_per_line);
+          && height <= X_IMAGE_BYTES_MAX / bytes_per_line);
 #else
   /* FIXME: Implement this check for the HAVE_NS and HAVE_NTGUI cases.
      For now, assume that every image size is allowed on these systems.  */
@@ -1912,7 +1912,7 @@ x_check_image_size (XImagePtr ximg, int width, int height)
 
 static bool
 x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
-			     XImagePtr *ximg, Pixmap *pixmap)
+                             XImagePtr *ximg, Pixmap *pixmap)
 {
 #ifdef HAVE_X_WINDOWS
   Display *display = FRAME_X_DISPLAY (f);
@@ -1924,8 +1924,8 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
   if (depth <= 0)
     depth = DefaultDepthOfScreen (screen);
   *ximg = XCreateImage (display, DefaultVisualOfScreen (screen),
-			depth, ZPixmap, 0, NULL, width, height,
-			depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);
+                        depth, ZPixmap, 0, NULL, width, height,
+                        depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);
   if (*ximg == NULL)
     {
       image_error ("Unable to allocate X image", Qnil, Qnil);
@@ -1937,7 +1937,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
       x_destroy_x_image (*ximg);
       *ximg = NULL;
       image_error ("Image too large (%dx%d)",
-		   make_number (width), make_number (height));
+                   make_number (width), make_number (height));
       return 0;
     }
 
@@ -2016,9 +2016,9 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
   /* Create a DIBSection and raster array for the bitmap,
      and store its handle in *pixmap.  */
   *pixmap = CreateDIBSection (hdc, &((*ximg)->info),
-			      (depth < 16) ? DIB_PAL_COLORS : DIB_RGB_COLORS,
-			      /* casting avoids a GCC warning */
-			      (void **)&((*ximg)->data), NULL, 0);
+                              (depth < 16) ? DIB_PAL_COLORS : DIB_RGB_COLORS,
+                              /* casting avoids a GCC warning */
+                              (void **)&((*ximg)->data), NULL, 0);
 
   /* Realize display palette and garbage all frames. */
   release_frame_dc (f, hdc);
@@ -2112,13 +2112,13 @@ x_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap, int width, int he
 
 static bool
 image_create_x_image_and_pixmap (struct frame *f, struct image *img,
-				 int width, int height, int depth,
-				 XImagePtr *ximg, bool mask_p)
+                                 int width, int height, int depth,
+                                 XImagePtr *ximg, bool mask_p)
 {
   eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP);
 
   return x_create_x_image_and_pixmap (f, width, height, depth, ximg,
-				      !mask_p ? &img->pixmap : &img->mask);
+                                      !mask_p ? &img->pixmap : &img->mask);
 }
 
 /* Put X image XIMG into image IMG on frame F, as a mask if and only
@@ -2129,7 +2129,7 @@ image_create_x_image_and_pixmap (struct frame *f, struct image *img,
 
 static void
 image_put_x_image (struct frame *f, struct image *img, XImagePtr ximg,
-		   bool mask_p)
+                   bool mask_p)
 {
 #ifdef HAVE_X_WINDOWS
   if (!mask_p)
@@ -2144,7 +2144,7 @@ image_put_x_image (struct frame *f, struct image *img, XImagePtr ximg,
     }
 #else
   x_put_x_image (f, ximg, !mask_p ? img->pixmap : img->mask,
-		 img->width, img->height);
+                 img->width, img->height);
   x_destroy_x_image (ximg);
 #endif
 }
@@ -2178,7 +2178,7 @@ image_sync_to_pixmaps (struct frame *f, struct image *img)
 
 static XImagePtr_or_DC
 image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p,
-			 HGDIOBJ *prev)
+                         HGDIOBJ *prev)
 {
   HDC frame_dc = get_frame_dc (f);
   XImagePtr_or_DC ximg = CreateCompatibleDC (frame_dc);
@@ -2191,7 +2191,7 @@ image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p,
 
 static void
 image_unget_x_image_or_dc (struct image *img, bool mask_p,
-			   XImagePtr_or_DC ximg, HGDIOBJ prev)
+                           XImagePtr_or_DC ximg, HGDIOBJ prev)
 {
   SelectObject (ximg, prev);
   DeleteDC (ximg);
@@ -2210,7 +2210,7 @@ image_get_x_image (struct frame *f, struct image *img, bool mask_p)
     return ximg_in_img;
   else
     return XGetImage (FRAME_X_DISPLAY (f), !mask_p ? img->pixmap : img->mask,
-		      0, 0, img->width, img->height, ~0, ZPixmap);
+                      0, 0, img->width, img->height, ~0, ZPixmap);
 #elif defined (HAVE_NS)
   XImagePtr pixmap = !mask_p ? img->pixmap : img->mask;
 
@@ -2237,7 +2237,7 @@ image_unget_x_image (struct image *img, bool mask_p, XImagePtr ximg)
 
 \f
 /***********************************************************************
-			      File Handling
+                              File Handling
  ***********************************************************************/
 
 /* Find image file FILE.  Look in data-directory/images, then
@@ -2253,8 +2253,8 @@ x_find_image_file (Lisp_Object file)
   /* TODO I think this should use something like image-load-path
      instead.  Unfortunately, that can contain non-string elements.  */
   search_path = Fcons (Fexpand_file_name (build_string ("images"),
-					  Vdata_directory),
-		       Vx_bitmap_file_path);
+                                          Vdata_directory),
+                       Vx_bitmap_file_path);
 
   /* Try to find FILE in data-directory/images, then x-bitmap-file-path.  */
   fd = openp (search_path, file, Qnil, &file_found, Qnil, false);
@@ -2265,7 +2265,7 @@ x_find_image_file (Lisp_Object file)
     {
       file_found = ENCODE_FILE (file_found);
       if (fd != -2)
-	emacs_close (fd);
+        emacs_close (fd);
     }
 
   return file_found;
@@ -2289,20 +2289,20 @@ slurp_file (char *file, ptrdiff_t *size)
       record_unwind_protect_ptr (fclose_unwind, fp);
 
       if (fstat (fileno (fp), &st) == 0
-	  && 0 <= st.st_size && st.st_size < min (PTRDIFF_MAX, SIZE_MAX))
-	{
-	  /* Report an error if we read past the purported EOF.
-	     This can happen if the file grows as we read it.  */
-	  ptrdiff_t buflen = st.st_size;
-	  buf = xmalloc (buflen + 1);
-	  if (fread (buf, 1, buflen + 1, fp) == buflen)
-	    *size = buflen;
-	  else
-	    {
-	      xfree (buf);
-	      buf = NULL;
-	    }
-	}
+          && 0 <= st.st_size && st.st_size < min (PTRDIFF_MAX, SIZE_MAX))
+        {
+          /* Report an error if we read past the purported EOF.
+             This can happen if the file grows as we read it.  */
+          ptrdiff_t buflen = st.st_size;
+          buf = xmalloc (buflen + 1);
+          if (fread (buf, 1, buflen + 1, fp) == buflen)
+            *size = buflen;
+          else
+            {
+              xfree (buf);
+              buf = NULL;
+            }
+        }
 
       unbind_to (count, Qnil);
     }
@@ -2313,7 +2313,7 @@ slurp_file (char *file, ptrdiff_t *size)
 
 \f
 /***********************************************************************
-			      XBM images
+                              XBM images
  ***********************************************************************/
 
 static bool xbm_load (struct frame *f, struct image *img);
@@ -2425,13 +2425,13 @@ xbm_image_p (Lisp_Object object)
   if (kw[XBM_FILE].count)
     {
       if (kw[XBM_WIDTH].count || kw[XBM_HEIGHT].count || kw[XBM_DATA].count)
-	return 0;
+        return 0;
     }
   else if (kw[XBM_DATA].count && xbm_file_p (kw[XBM_DATA].value))
     {
       /* In-memory XBM file.  */
       if (kw[XBM_WIDTH].count || kw[XBM_HEIGHT].count || kw[XBM_FILE].count)
-	return 0;
+        return 0;
     }
   else
     {
@@ -2440,58 +2440,58 @@ xbm_image_p (Lisp_Object object)
 
       /* Entries for `:width', `:height' and `:data' must be present.  */
       if (!kw[XBM_WIDTH].count
-	  || !kw[XBM_HEIGHT].count
-	  || !kw[XBM_DATA].count)
-	return 0;
+          || !kw[XBM_HEIGHT].count
+          || !kw[XBM_DATA].count)
+        return 0;
 
       data = kw[XBM_DATA].value;
       width = XFASTINT (kw[XBM_WIDTH].value);
       height = XFASTINT (kw[XBM_HEIGHT].value);
 
       /* Check type of data, and width and height against contents of
-	 data.  */
+         data.  */
       if (VECTORP (data))
-	{
-	  EMACS_INT i;
-
-	  /* Number of elements of the vector must be >= height.  */
-	  if (ASIZE (data) < height)
-	    return 0;
-
-	  /* Each string or bool-vector in data must be large enough
-	     for one line of the image.  */
-	  for (i = 0; i < height; ++i)
-	    {
-	      Lisp_Object elt = AREF (data, i);
-
-	      if (STRINGP (elt))
-		{
-		  if (SCHARS (elt)
-		      < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR)
-		    return 0;
-		}
-	      else if (BOOL_VECTOR_P (elt))
-		{
-		  if (bool_vector_size (elt) < width)
-		    return 0;
-		}
-	      else
-		return 0;
-	    }
-	}
+        {
+          EMACS_INT i;
+
+          /* Number of elements of the vector must be >= height.  */
+          if (ASIZE (data) < height)
+            return 0;
+
+          /* Each string or bool-vector in data must be large enough
+             for one line of the image.  */
+          for (i = 0; i < height; ++i)
+            {
+              Lisp_Object elt = AREF (data, i);
+
+              if (STRINGP (elt))
+                {
+                  if (SCHARS (elt)
+                      < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR)
+                    return 0;
+                }
+              else if (BOOL_VECTOR_P (elt))
+                {
+                  if (bool_vector_size (elt) < width)
+                    return 0;
+                }
+              else
+                return 0;
+            }
+        }
       else if (STRINGP (data))
-	{
-	  if (SCHARS (data)
-	      < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height)
-	    return 0;
-	}
+        {
+          if (SCHARS (data)
+              < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height)
+            return 0;
+        }
       else if (BOOL_VECTOR_P (data))
-	{
-	  if (bool_vector_size (data) / height < width)
-	    return 0;
-	}
+        {
+          if (bool_vector_size (data) / height < width)
+            return 0;
+        }
       else
-	return 0;
+        return 0;
     }
 
   return 1;
@@ -2522,42 +2522,42 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
       int value = 0, digit;
 
       if (c == '0' && *s < end)
-	{
-	  c = *(*s)++;
-	  if (c == 'x' || c == 'X')
-	    {
-	      while (*s < end)
-		{
-		  c = *(*s)++;
-		  if (c_isdigit (c))
-		    digit = c - '0';
-		  else if (c >= 'a' && c <= 'f')
-		    digit = c - 'a' + 10;
-		  else if (c >= 'A' && c <= 'F')
-		    digit = c - 'A' + 10;
-		  else
-		    break;
-		  value = 16 * value + digit;
-		}
-	    }
-	  else if (c_isdigit (c))
-	    {
-	      value = c - '0';
-	      while (*s < end
-		     && (c = *(*s)++, c_isdigit (c)))
-		value = 8 * value + c - '0';
-	    }
-	}
+        {
+          c = *(*s)++;
+          if (c == 'x' || c == 'X')
+            {
+              while (*s < end)
+                {
+                  c = *(*s)++;
+                  if (c_isdigit (c))
+                    digit = c - '0';
+                  else if (c >= 'a' && c <= 'f')
+                    digit = c - 'a' + 10;
+                  else if (c >= 'A' && c <= 'F')
+                    digit = c - 'A' + 10;
+                  else
+                    break;
+                  value = 16 * value + digit;
+                }
+            }
+          else if (c_isdigit (c))
+            {
+              value = c - '0';
+              while (*s < end
+                     && (c = *(*s)++, c_isdigit (c)))
+                value = 8 * value + c - '0';
+            }
+        }
       else
-	{
-	  value = c - '0';
-	  while (*s < end
-		 && (c = *(*s)++, c_isdigit (c)))
-	    value = 10 * value + c - '0';
-	}
+        {
+          value = c - '0';
+          while (*s < end
+                 && (c = *(*s)++, c_isdigit (c)))
+            value = 10 * value + c - '0';
+        }
 
       if (*s < end)
-	*s = *s - 1;
+        *s = *s - 1;
       *ival = value;
       c = XBM_TK_NUMBER;
     }
@@ -2565,11 +2565,11 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
     {
       *sval++ = c;
       while (*s < end
-	     && (c = *(*s)++, (c_isalnum (c) || c == '_')))
-	*sval++ = c;
+             && (c = *(*s)++, (c_isalnum (c) || c == '_')))
+        *sval++ = c;
       *sval = 0;
       if (*s < end)
-	*s = *s - 1;
+        *s = *s - 1;
       c = XBM_TK_IDENT;
     }
   else if (c == '/' && **s == '*')
@@ -2577,12 +2577,12 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
       /* C-style comment.  */
       ++*s;
       while (**s && (**s != '*' || *(*s + 1) != '/'))
-	++*s;
+        ++*s;
       if (**s)
-	{
-	  *s += 2;
-	  goto loop;
-	}
+        {
+          *s += 2;
+          goto loop;
+        }
     }
 
   return c;
@@ -2596,9 +2596,9 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data)
 {
   static unsigned char swap_nibble[16]
     = { 0x0, 0x8, 0x4, 0xc,    /* 0000 1000 0100 1100 */
-	0x2, 0xa, 0x6, 0xe,    /* 0010 1010 0110 1110 */
-	0x1, 0x9, 0x5, 0xd,    /* 0001 1001 0101 1101 */
-	0x3, 0xb, 0x7, 0xf };  /* 0011 1011 0111 1111 */
+        0x2, 0xa, 0x6, 0xe,    /* 0010 1010 0110 1110 */
+        0x1, 0x9, 0x5, 0xd,    /* 0001 1001 0101 1101 */
+        0x3, 0xb, 0x7, 0xf };  /* 0011 1011 0111 1111 */
   int i, j, w1, w2;
   unsigned char *bits, *p;
   HBITMAP bmp;
@@ -2611,12 +2611,12 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data)
     {
       p = bits + i*w2;
       for (j = 0; j < w1; j++)
-	{
-	  /* Bitswap XBM bytes to match how Windows does things.  */
-	  unsigned char c = *data++;
-	  *p++ = (unsigned char)((swap_nibble[c & 0xf] << 4)
-				 | (swap_nibble[(c>>4) & 0xf]));
-	}
+        {
+          /* Bitswap XBM bytes to match how Windows does things.  */
+          unsigned char c = *data++;
+          *p++ = (unsigned char)((swap_nibble[c & 0xf] << 4)
+                                 | (swap_nibble[(c>>4) & 0xf]));
+        }
     }
   bmp = CreateBitmap (width, height, 1, 1, (char *) bits);
 
@@ -2625,7 +2625,7 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data)
 
 static void
 convert_mono_to_color_image (struct frame *f, struct image *img,
-			     COLORREF foreground, COLORREF background)
+                             COLORREF foreground, COLORREF background)
 {
   HDC hdc, old_img_dc, new_img_dc;
   HGDIOBJ old_prev, new_prev;
@@ -2644,7 +2644,7 @@ convert_mono_to_color_image (struct frame *f, struct image *img,
   SetBkColor (new_img_dc, foreground);
 
   BitBlt (new_img_dc, 0, 0, img->width, img->height, old_img_dc,
-	  0, 0, SRCCOPY);
+          0, 0, SRCCOPY);
 
   SelectObject (old_img_dc, old_prev);
   SelectObject (new_img_dc, new_prev);
@@ -2668,8 +2668,8 @@ convert_mono_to_color_image (struct frame *f, struct image *img,
 
 static void
 Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data,
-				RGB_PIXEL_COLOR fg, RGB_PIXEL_COLOR bg,
-				bool non_default_colors)
+                                RGB_PIXEL_COLOR fg, RGB_PIXEL_COLOR bg,
+                                bool non_default_colors)
 {
 #ifdef HAVE_NTGUI
   img->pixmap
@@ -2686,11 +2686,11 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data,
   img->pixmap =
    (x_check_image_size (0, img->width, img->height)
     ? XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),
-				   FRAME_X_WINDOW (f),
-				   data,
-				   img->width, img->height,
-				   fg, bg,
-				   DefaultDepthOfScreen (FRAME_X_SCREEN (f)))
+                                   FRAME_X_WINDOW (f),
+                                   data,
+                                   img->width, img->height,
+                                   fg, bg,
+                                   DefaultDepthOfScreen (FRAME_X_SCREEN (f)))
     : NO_PIXMAP);
 #endif /* !HAVE_NTGUI && !HAVE_NS */
 }
@@ -2708,8 +2708,8 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data,
 
 static bool
 xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *end,
-		      int *width, int *height, char **data,
-		      bool inhibit_image_error)
+                      int *width, int *height, char **data,
+                      bool inhibit_image_error)
 {
   unsigned char *s = contents;
   char buffer[BUFSIZ];
@@ -2726,8 +2726,8 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
 #define expect(TOKEN)		\
   do				\
     {				\
-      if (LA1 != (TOKEN)) 	\
-	goto failure;		\
+      if (LA1 != (TOKEN))       \
+        goto failure;		\
       match ();			\
     }				\
   while (0)
@@ -2751,21 +2751,21 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
       expect (XBM_TK_IDENT);
 
       if (LA1 == XBM_TK_NUMBER)
-	{
-	  char *q = strrchr (buffer, '_');
-	  q = q ? q + 1 : buffer;
-	  if (strcmp (q, "width") == 0)
-	    *width = value;
-	  else if (strcmp (q, "height") == 0)
-	    *height = value;
-	}
+        {
+          char *q = strrchr (buffer, '_');
+          q = q ? q + 1 : buffer;
+          if (strcmp (q, "width") == 0)
+            *width = value;
+          else if (strcmp (q, "height") == 0)
+            *height = value;
+        }
       expect (XBM_TK_NUMBER);
     }
 
   if (!check_image_size (f, *width, *height))
     {
       if (!inhibit_image_error)
-	image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
+        image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
       goto failure;
     }
   else if (data == NULL)
@@ -2776,21 +2776,21 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
   if (LA1 == XBM_TK_IDENT)
     {
       if (strcmp (buffer, "unsigned") == 0)
-	{
-	  match ();
-	  expect_ident ("char");
-	}
+        {
+          match ();
+          expect_ident ("char");
+        }
       else if (strcmp (buffer, "short") == 0)
-	{
-	  match ();
-	  v10 = 1;
-	  if (*width % 16 && *width % 16 < 9)
-	    padding_p = 1;
-	}
+        {
+          match ();
+          v10 = 1;
+          if (*width % 16 && *width % 16 < 9)
+            padding_p = 1;
+        }
       else if (strcmp (buffer, "char") == 0)
-	match ();
+        match ();
       else
-	goto failure;
+        goto failure;
     }
   else
     goto failure;
@@ -2804,8 +2804,8 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
   if (! x_check_image_size (0, *width, *height))
     {
       if (!inhibit_image_error)
-	image_error ("Image too large (%dx%d)",
-		     make_number (*width), make_number (*height));
+        image_error ("Image too large (%dx%d)",
+                     make_number (*width), make_number (*height));
       goto failure;
     }
   bytes_per_line = (*width + 7) / 8 + padding_p;
@@ -2815,34 +2815,34 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
   if (v10)
     {
       for (i = 0; i < nbytes; i += 2)
-	{
-	  int val = value;
-	  expect (XBM_TK_NUMBER);
+        {
+          int val = value;
+          expect (XBM_TK_NUMBER);
 
-	  *p++ = XBM_BIT_SHUFFLE (val);
-	  if (!padding_p || ((i + 2) % bytes_per_line))
-	    *p++ = XBM_BIT_SHUFFLE (value >> 8);
+          *p++ = XBM_BIT_SHUFFLE (val);
+          if (!padding_p || ((i + 2) % bytes_per_line))
+            *p++ = XBM_BIT_SHUFFLE (value >> 8);
 
-	  if (LA1 == ',' || LA1 == '}')
-	    match ();
-	  else
-	    goto failure;
-	}
+          if (LA1 == ',' || LA1 == '}')
+            match ();
+          else
+            goto failure;
+        }
     }
   else
     {
       for (i = 0; i < nbytes; ++i)
-	{
-	  int val = value;
-	  expect (XBM_TK_NUMBER);
+        {
+          int val = value;
+          expect (XBM_TK_NUMBER);
 
-	  *p++ = XBM_BIT_SHUFFLE (val);
+          *p++ = XBM_BIT_SHUFFLE (val);
 
-	  if (LA1 == ',' || LA1 == '}')
-	    match ();
-	  else
-	    goto failure;
-	}
+          if (LA1 == ',' || LA1 == '}')
+            match ();
+          else
+            goto failure;
+        }
     }
 
  success:
@@ -2869,14 +2869,14 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
 
 static bool
 xbm_load_image (struct frame *f, struct image *img, unsigned char *contents,
-		unsigned char *end)
+                unsigned char *end)
 {
   bool rc;
   char *data;
   bool success_p = 0;
 
   rc = xbm_read_bitmap_data (f, contents, end, &img->width, &img->height,
-			     &data, 0);
+                             &data, 0);
   if (rc)
     {
       unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
@@ -2889,31 +2889,31 @@ xbm_load_image (struct frame *f, struct image *img, unsigned char *contents,
       /* Get foreground and background colors, maybe allocate colors.  */
       value = image_spec_value (img->spec, QCforeground, NULL);
       if (!NILP (value))
-	{
-	  foreground = x_alloc_image_color (f, img, value, foreground);
-	  non_default_colors = 1;
-	}
+        {
+          foreground = x_alloc_image_color (f, img, value, foreground);
+          non_default_colors = 1;
+        }
       value = image_spec_value (img->spec, QCbackground, NULL);
       if (!NILP (value))
-	{
-	  background = x_alloc_image_color (f, img, value, background);
-	  img->background = background;
-	  img->background_valid = 1;
-	  non_default_colors = 1;
-	}
+        {
+          background = x_alloc_image_color (f, img, value, background);
+          img->background = background;
+          img->background_valid = 1;
+          non_default_colors = 1;
+        }
 
       Create_Pixmap_From_Bitmap_Data (f, img, data,
-				      foreground, background,
-				      non_default_colors);
+                                      foreground, background,
+                                      non_default_colors);
       xfree (data);
 
       if (img->pixmap == NO_PIXMAP)
-	{
-	  x_clear_image (f, img);
-	  image_error ("Unable to create X pixmap for `%s'", img->spec, Qnil);
-	}
+        {
+          x_clear_image (f, img);
+          image_error ("Unable to create X pixmap for `%s'", img->spec, Qnil);
+        }
       else
-	success_p = 1;
+        success_p = 1;
     }
   else
     image_error ("Error loading XBM image `%s'", img->spec, Qnil);
@@ -2929,9 +2929,9 @@ xbm_file_p (Lisp_Object data)
 {
   int w, h;
   return (STRINGP (data)
-	  && xbm_read_bitmap_data (NULL, SDATA (data),
-				   (SDATA (data) + SBYTES (data)),
-				   &w, &h, NULL, 1));
+          && xbm_read_bitmap_data (NULL, SDATA (data),
+                                   (SDATA (data) + SBYTES (data)),
+                                   &w, &h, NULL, 1));
 }
 
 
@@ -2956,17 +2956,17 @@ xbm_load (struct frame *f, struct image *img)
 
       file = x_find_image_file (file_name);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", file_name, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot find image file `%s'", file_name, Qnil);
+          return 0;
+        }
 
       contents = slurp_file (SSDATA (file), &size);
       if (contents == NULL)
-	{
-	  image_error ("Error loading XBM image `%s'", img->spec, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Error loading XBM image `%s'", img->spec, Qnil);
+          return 0;
+        }
 
       success_p = xbm_load_image (f, img, contents, contents + size);
       xfree (contents);
@@ -2993,61 +2993,61 @@ xbm_load (struct frame *f, struct image *img)
 
       /* Get specified width, and height.  */
       if (!in_memory_file_p)
-	{
-	  img->width = XFASTINT (fmt[XBM_WIDTH].value);
-	  img->height = XFASTINT (fmt[XBM_HEIGHT].value);
-	  eassert (img->width > 0 && img->height > 0);
-	  if (!check_image_size (f, img->width, img->height))
-	    {
-	      image_error ("Invalid image size (see `max-image-size')",
-			   Qnil, Qnil);
-	      return 0;
-	    }
-	}
+        {
+          img->width = XFASTINT (fmt[XBM_WIDTH].value);
+          img->height = XFASTINT (fmt[XBM_HEIGHT].value);
+          eassert (img->width > 0 && img->height > 0);
+          if (!check_image_size (f, img->width, img->height))
+            {
+              image_error ("Invalid image size (see `max-image-size')",
+                           Qnil, Qnil);
+              return 0;
+            }
+        }
 
       /* Get foreground and background colors, maybe allocate colors.  */
       if (fmt[XBM_FOREGROUND].count
-	  && STRINGP (fmt[XBM_FOREGROUND].value))
-	{
-	  foreground = x_alloc_image_color (f, img, fmt[XBM_FOREGROUND].value,
-					    foreground);
-	  non_default_colors = 1;
-	}
+          && STRINGP (fmt[XBM_FOREGROUND].value))
+        {
+          foreground = x_alloc_image_color (f, img, fmt[XBM_FOREGROUND].value,
+                                            foreground);
+          non_default_colors = 1;
+        }
 
       if (fmt[XBM_BACKGROUND].count
-	  && STRINGP (fmt[XBM_BACKGROUND].value))
-	{
-	  background = x_alloc_image_color (f, img, fmt[XBM_BACKGROUND].value,
-					    background);
-	  non_default_colors = 1;
-	}
+          && STRINGP (fmt[XBM_BACKGROUND].value))
+        {
+          background = x_alloc_image_color (f, img, fmt[XBM_BACKGROUND].value,
+                                            background);
+          non_default_colors = 1;
+        }
 
       if (in_memory_file_p)
-	success_p = xbm_load_image (f, img, SDATA (data),
-				    (SDATA (data)
-				     + SBYTES (data)));
+        success_p = xbm_load_image (f, img, SDATA (data),
+                                    (SDATA (data)
+                                     + SBYTES (data)));
       else
-	{
-	  if (VECTORP (data))
-	    {
-	      int i;
-	      char *p;
-	      int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
-
-	      p = bits = alloca (nbytes * img->height);
-	      for (i = 0; i < img->height; ++i, p += nbytes)
-		{
-		  Lisp_Object line = AREF (data, i);
-		  if (STRINGP (line))
-		    memcpy (p, SDATA (line), nbytes);
-		  else
-		    memcpy (p, bool_vector_data (line), nbytes);
-		}
-	    }
-	  else if (STRINGP (data))
-	    bits = SSDATA (data);
-	  else
-	    bits = (char *) bool_vector_data (data);
+        {
+          if (VECTORP (data))
+            {
+              int i;
+              char *p;
+              int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
+
+              p = bits = alloca (nbytes * img->height);
+              for (i = 0; i < img->height; ++i, p += nbytes)
+                {
+                  Lisp_Object line = AREF (data, i);
+                  if (STRINGP (line))
+                    memcpy (p, SDATA (line), nbytes);
+                  else
+                    memcpy (p, bool_vector_data (line), nbytes);
+                }
+            }
+          else if (STRINGP (data))
+            bits = SSDATA (data);
+          else
+            bits = (char *) bool_vector_data (data);
 
 #ifdef HAVE_NTGUI
           {
@@ -3062,24 +3062,24 @@ xbm_load (struct frame *f, struct image *img)
               bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]);
           }
 #endif
-	  /* Create the pixmap.  */
-
-	  if (x_check_image_size (0, img->width, img->height))
-	    Create_Pixmap_From_Bitmap_Data (f, img, bits,
-					    foreground, background,
-					    non_default_colors);
-	  else
-	    img->pixmap = NO_PIXMAP;
-
-	  if (img->pixmap)
-	    success_p = 1;
-	  else
-	    {
-	      image_error ("Unable to create pixmap for XBM image `%s'",
-			   img->spec, Qnil);
-	      x_clear_image (f, img);
-	    }
-	}
+          /* Create the pixmap.  */
+
+          if (x_check_image_size (0, img->width, img->height))
+            Create_Pixmap_From_Bitmap_Data (f, img, bits,
+                                            foreground, background,
+                                            non_default_colors);
+          else
+            img->pixmap = NO_PIXMAP;
+
+          if (img->pixmap)
+            success_p = 1;
+          else
+            {
+              image_error ("Unable to create pixmap for XBM image `%s'",
+                           img->spec, Qnil);
+              x_clear_image (f, img);
+            }
+        }
     }
 
   return success_p;
@@ -3088,7 +3088,7 @@ xbm_load (struct frame *f, struct image *img)
 
 \f
 /***********************************************************************
-			      XPM images
+                              XPM images
  ***********************************************************************/
 
 #if defined (HAVE_XPM) || defined (HAVE_NS)
@@ -3233,13 +3233,13 @@ xpm_init_color_cache (struct frame *f, XpmAttributes *attrs)
       XColor color;
 
       for (i = 0; i < attrs->numsymbols; ++i)
-	if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
-			 attrs->colorsymbols[i].value, &color))
-	  {
-	    color.pixel = lookup_rgb_color (f, color.red, color.green,
-					    color.blue);
-	    xpm_cache_color (f, attrs->colorsymbols[i].name, &color, -1);
-	  }
+        if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
+                         attrs->colorsymbols[i].value, &color))
+          {
+            color.pixel = lookup_rgb_color (f, color.red, color.green,
+                                            color.blue);
+            xpm_cache_color (f, attrs->colorsymbols[i].name, &color, -1);
+          }
     }
 }
 
@@ -3254,8 +3254,8 @@ xpm_free_color_cache (void)
   for (i = 0; i < XPM_COLOR_CACHE_BUCKETS; ++i)
     for (p = xpm_color_cache[i]; p; p = next)
       {
-	next = p->next;
-	xfree (p);
+        next = p->next;
+        xfree (p);
       }
 
   xfree (xpm_color_cache);
@@ -3314,10 +3314,10 @@ xpm_lookup_color (struct frame *f, char *color_name, XColor *color)
   if (p != NULL)
     *color = p->color;
   else if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
-			color_name, color))
+                        color_name, color))
     {
       color->pixel = lookup_rgb_color (f, color->red, color->green,
-				       color->blue);
+                                       color->blue);
       p = xpm_cache_color (f, color_name, color, h);
     }
   /* You get `opaque' at least from ImageMagick converting pbm to xpm
@@ -3340,7 +3340,7 @@ xpm_lookup_color (struct frame *f, char *color_name, XColor *color)
 
 static int
 xpm_alloc_color (Display *dpy, Colormap cmap, char *color_name, XColor *color,
-		 void *closure)
+                 void *closure)
 {
   return xpm_lookup_color (closure, color_name, color);
 }
@@ -3365,9 +3365,9 @@ xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void *
 
 DEF_IMGLIB_FN (void, XpmFreeAttributes, (XpmAttributes *));
 DEF_IMGLIB_FN (int, XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **,
-					  xpm_XImage **, XpmAttributes *));
+                                          xpm_XImage **, XpmAttributes *));
 DEF_IMGLIB_FN (int, XpmReadFileToImage, (Display *, char *, xpm_XImage **,
-				    xpm_XImage **, XpmAttributes *));
+                                    xpm_XImage **, XpmAttributes *));
 DEF_IMGLIB_FN (void, XImageFree, (xpm_XImage *));
 
 static bool
@@ -3406,9 +3406,9 @@ xpm_valid_color_symbols_p (Lisp_Object color_symbols)
     {
       Lisp_Object sym = XCAR (color_symbols);
       if (!CONSP (sym)
-	  || !STRINGP (XCAR (sym))
-	  || !STRINGP (XCDR (sym)))
-	break;
+          || !STRINGP (XCAR (sym))
+          || !STRINGP (XCDR (sym)))
+        break;
       color_symbols = XCDR (color_symbols);
     }
 
@@ -3424,12 +3424,12 @@ xpm_image_p (Lisp_Object object)
   struct image_keyword fmt[XPM_LAST];
   memcpy (fmt, xpm_format, sizeof fmt);
   return (parse_image_spec (object, fmt, XPM_LAST, Qxpm)
-	  /* Either `:file' or `:data' must be present.  */
-	  && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1
-	  /* Either no `:color-symbols' or it's a list of conses
-	     whose car and cdr are strings.  */
-	  && (fmt[XPM_COLOR_SYMBOLS].count == 0
-	      || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value)));
+          /* Either `:file' or `:data' must be present.  */
+          && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1
+          /* Either no `:color-symbols' or it's a list of conses
+             whose car and cdr are strings.  */
+          && (fmt[XPM_COLOR_SYMBOLS].count == 0
+              || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value)));
 }
 
 #endif /* HAVE_XPM || HAVE_NS */
@@ -3452,7 +3452,7 @@ x_create_bitmap_from_xpm_data (struct frame *f, const char **bits)
   attrs.valuemask |= XpmColormap;
 
   rc = XpmCreatePixmapFromData (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-				(char **) bits, &bitmap, &mask, &attrs);
+                                (char **) bits, &bitmap, &mask, &attrs);
   if (rc != XpmSuccess)
     {
       XpmFreeAttributes (&attrs);
@@ -3534,7 +3534,7 @@ xpm_load (struct frame *f, struct image *img)
       /* Count number of symbols.  */
       attrs.numsymbols = 0;
       for (tail = color_symbols; CONSP (tail); tail = XCDR (tail))
-	++attrs.numsymbols;
+        ++attrs.numsymbols;
 
       /* Allocate an XpmColorSymbol array.  */
       size = attrs.numsymbols * sizeof *xpm_syms;
@@ -3544,36 +3544,36 @@ xpm_load (struct frame *f, struct image *img)
 
       /* Fill the color symbol array.  */
       for (tail = color_symbols, i = 0;
-	   CONSP (tail);
-	   ++i, tail = XCDR (tail))
-	{
-	  Lisp_Object name;
-	  Lisp_Object color;
-	  char *empty_string = (char *) "";
-
-	  if (!CONSP (XCAR (tail)))
-	    {
-	      xpm_syms[i].name = empty_string;
-	      xpm_syms[i].value = empty_string;
-	      continue;
-	    }
-	  name = XCAR (XCAR (tail));
-	  color = XCDR (XCAR (tail));
-	  if (STRINGP (name))
-	    {
-	      xpm_syms[i].name = alloca (SCHARS (name) + 1);
-	      strcpy (xpm_syms[i].name, SSDATA (name));
-	    }
-	  else
-	    xpm_syms[i].name = empty_string;
-	  if (STRINGP (color))
-	    {
-	      xpm_syms[i].value = alloca (SCHARS (color) + 1);
-	      strcpy (xpm_syms[i].value, SSDATA (color));
-	    }
-	  else
-	    xpm_syms[i].value = empty_string;
-	}
+           CONSP (tail);
+           ++i, tail = XCDR (tail))
+        {
+          Lisp_Object name;
+          Lisp_Object color;
+          char *empty_string = (char *) "";
+
+          if (!CONSP (XCAR (tail)))
+            {
+              xpm_syms[i].name = empty_string;
+              xpm_syms[i].value = empty_string;
+              continue;
+            }
+          name = XCAR (XCAR (tail));
+          color = XCDR (XCAR (tail));
+          if (STRINGP (name))
+            {
+              xpm_syms[i].name = alloca (SCHARS (name) + 1);
+              strcpy (xpm_syms[i].name, SSDATA (name));
+            }
+          else
+            xpm_syms[i].name = empty_string;
+          if (STRINGP (color))
+            {
+              xpm_syms[i].value = alloca (SCHARS (color) + 1);
+              strcpy (xpm_syms[i].value, SSDATA (color));
+            }
+          else
+            xpm_syms[i].value = empty_string;
+        }
     }
 
   /* Create a pixmap for the image, either from a file, or from a
@@ -3596,53 +3596,53 @@ xpm_load (struct frame *f, struct image *img)
     {
       Lisp_Object file = x_find_image_file (specified_file);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", specified_file, Qnil);
+        {
+          image_error ("Cannot find image file `%s'", specified_file, Qnil);
 #ifdef ALLOC_XPM_COLORS
-	  xpm_free_color_cache ();
+          xpm_free_color_cache ();
 #endif
-	  return 0;
-	}
+          return 0;
+        }
 
 #ifdef HAVE_NTGUI
 #ifdef WINDOWSNT
       /* FILE is encoded in UTF-8, but image libraries on Windows
-	 support neither UTF-8 nor UTF-16 encoded file names.  So we
-	 need to re-encode it in ANSI.  */
+         support neither UTF-8 nor UTF-16 encoded file names.  So we
+         need to re-encode it in ANSI.  */
       file = ansi_encode_filename (file);
 #endif
       /* XpmReadFileToPixmap is not available in the Windows port of
-	 libxpm.  But XpmReadFileToImage almost does what we want.  */
+         libxpm.  But XpmReadFileToImage almost does what we want.  */
       rc = fn_XpmReadFileToImage (&hdc, SDATA (file),
-				  &xpm_image, &xpm_mask,
-				  &attrs);
+                                  &xpm_image, &xpm_mask,
+                                  &attrs);
 #else
       rc = XpmReadFileToImage (FRAME_X_DISPLAY (f), SSDATA (file),
-			       &img->ximg, &img->mask_img,
-			       &attrs);
+                               &img->ximg, &img->mask_img,
+                               &attrs);
 #endif /* HAVE_NTGUI */
     }
   else
     {
       Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL);
       if (!STRINGP (buffer))
-	{
-	  image_error ("Invalid image data `%s'", buffer, Qnil);
+        {
+          image_error ("Invalid image data `%s'", buffer, Qnil);
 #ifdef ALLOC_XPM_COLORS
-	  xpm_free_color_cache ();
+          xpm_free_color_cache ();
 #endif
-	  return 0;
-	}
+          return 0;
+        }
 #ifdef HAVE_NTGUI
       /* XpmCreatePixmapFromBuffer is not available in the Windows port
-	 of libxpm.  But XpmCreateImageFromBuffer almost does what we want.  */
+         of libxpm.  But XpmCreateImageFromBuffer almost does what we want.  */
       rc = fn_XpmCreateImageFromBuffer (&hdc, SDATA (buffer),
-					&xpm_image, &xpm_mask,
-					&attrs);
+                                        &xpm_image, &xpm_mask,
+                                        &attrs);
 #else
       rc = XpmCreateImageFromBuffer (FRAME_X_DISPLAY (f), SSDATA (buffer),
-				     &img->ximg, &img->mask_img,
-				     &attrs);
+                                     &img->ximg, &img->mask_img,
+                                     &attrs);
 #endif /* HAVE_NTGUI */
     }
 
@@ -3650,25 +3650,25 @@ xpm_load (struct frame *f, struct image *img)
   if (rc == XpmSuccess)
     {
       img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-				   img->ximg->width, img->ximg->height,
-				   img->ximg->depth);
+                                   img->ximg->width, img->ximg->height,
+                                   img->ximg->depth);
       if (img->pixmap == NO_PIXMAP)
-	{
-	  x_clear_image (f, img);
-	  rc = XpmNoMemory;
-	}
+        {
+          x_clear_image (f, img);
+          rc = XpmNoMemory;
+        }
       else if (img->mask_img)
-	{
-	  img->mask = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-				     img->mask_img->width,
-				     img->mask_img->height,
-				     img->mask_img->depth);
-	  if (img->mask == NO_PIXMAP)
-	    {
-	      x_clear_image (f, img);
-	      rc = XpmNoMemory;
-	    }
-	}
+        {
+          img->mask = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                                     img->mask_img->width,
+                                     img->mask_img->height,
+                                     img->mask_img->depth);
+          if (img->mask == NO_PIXMAP)
+            {
+              x_clear_image (f, img);
+              rc = XpmNoMemory;
+            }
+        }
     }
 #endif
 
@@ -3681,29 +3681,29 @@ xpm_load (struct frame *f, struct image *img)
 
 #ifdef HAVE_NTGUI
       /* W32 XPM uses XImage to wrap what W32 Emacs calls a Pixmap,
-	 plus some duplicate attributes.  */
+         plus some duplicate attributes.  */
       if (xpm_image && xpm_image->bitmap)
-	{
-	  img->pixmap = xpm_image->bitmap;
-	  /* XImageFree in libXpm frees XImage struct without destroying
-	     the bitmap, which is what we want.  */
-	  fn_XImageFree (xpm_image);
-	}
+        {
+          img->pixmap = xpm_image->bitmap;
+          /* XImageFree in libXpm frees XImage struct without destroying
+             the bitmap, which is what we want.  */
+          fn_XImageFree (xpm_image);
+        }
       if (xpm_mask && xpm_mask->bitmap)
-	{
-	  /* The mask appears to be inverted compared with what we expect.
-	     TODO: invert our expectations.  See other places where we
-	     have to invert bits because our idea of masks is backwards.  */
-	  HGDIOBJ old_obj;
-	  old_obj = SelectObject (hdc, xpm_mask->bitmap);
-
-	  PatBlt (hdc, 0, 0, xpm_mask->width, xpm_mask->height, DSTINVERT);
-	  SelectObject (hdc, old_obj);
-
-	  img->mask = xpm_mask->bitmap;
-	  fn_XImageFree (xpm_mask);
-	  DeleteDC (hdc);
-	}
+        {
+          /* The mask appears to be inverted compared with what we expect.
+             TODO: invert our expectations.  See other places where we
+             have to invert bits because our idea of masks is backwards.  */
+          HGDIOBJ old_obj;
+          old_obj = SelectObject (hdc, xpm_mask->bitmap);
+
+          PatBlt (hdc, 0, 0, xpm_mask->width, xpm_mask->height, DSTINVERT);
+          SelectObject (hdc, old_obj);
+
+          img->mask = xpm_mask->bitmap;
+          fn_XImageFree (xpm_mask);
+          DeleteDC (hdc);
+        }
 
       DeleteDC (hdc);
 #endif /* HAVE_NTGUI */
@@ -3712,12 +3712,12 @@ xpm_load (struct frame *f, struct image *img)
       img->colors = xnmalloc (attrs.nalloc_pixels, sizeof *img->colors);
       img->ncolors = attrs.nalloc_pixels;
       for (i = 0; i < attrs.nalloc_pixels; ++i)
-	{
-	  img->colors[i] = attrs.alloc_pixels[i];
+        {
+          img->colors[i] = attrs.alloc_pixels[i];
 #ifdef DEBUG_X_COLORS
-	  register_color (img->colors[i]);
+          register_color (img->colors[i]);
 #endif
-	}
+        }
 #endif /* not ALLOC_XPM_COLORS */
 
       img->width = attrs.width;
@@ -3735,9 +3735,9 @@ xpm_load (struct frame *f, struct image *img)
       /* Maybe fill in the background field while we have ximg handy.  */
       IMAGE_BACKGROUND (img, f, img->ximg);
       if (img->mask_img)
-	/* Fill in the background_transparent field while we have the
-	   mask handy.  */
-	image_background_transparent (img, f, img->mask_img);
+        /* Fill in the background_transparent field while we have the
+           mask handy.  */
+        image_background_transparent (img, f, img->mask_img);
 #endif
     }
   else
@@ -3747,27 +3747,27 @@ xpm_load (struct frame *f, struct image *img)
 #endif /* HAVE_NTGUI */
 
       switch (rc)
-	{
-	case XpmOpenFailed:
-	  image_error ("Error opening XPM file (%s)", img->spec, Qnil);
-	  break;
+        {
+        case XpmOpenFailed:
+          image_error ("Error opening XPM file (%s)", img->spec, Qnil);
+          break;
 
-	case XpmFileInvalid:
-	  image_error ("Invalid XPM file (%s)", img->spec, Qnil);
-	  break;
+        case XpmFileInvalid:
+          image_error ("Invalid XPM file (%s)", img->spec, Qnil);
+          break;
 
-	case XpmNoMemory:
-	  image_error ("Out of memory (%s)", img->spec, Qnil);
-	  break;
+        case XpmNoMemory:
+          image_error ("Out of memory (%s)", img->spec, Qnil);
+          break;
 
-	case XpmColorFailed:
-	  image_error ("Color allocation error (%s)", img->spec, Qnil);
-	  break;
+        case XpmColorFailed:
+          image_error ("Color allocation error (%s)", img->spec, Qnil);
+          break;
 
-	default:
-	  image_error ("Unknown error (%s)", img->spec, Qnil);
-	  break;
-	}
+        default:
+          image_error ("Unknown error (%s)", img->spec, Qnil);
+          break;
+        }
     }
 
 #ifdef ALLOC_XPM_COLORS
@@ -3820,50 +3820,50 @@ xpm_scan (const unsigned char **s,
     {
       /* Skip white-space.  */
       while (*s < end && (c = *(*s)++, c_isspace (c)))
-	;
+        ;
 
       /* gnus-pointer.xpm uses '-' in its identifier.
-	 sb-dir-plus.xpm uses '+' in its identifier.  */
+         sb-dir-plus.xpm uses '+' in its identifier.  */
       if (c_isalpha (c) || c == '_' || c == '-' || c == '+')
-	{
-	  *beg = *s - 1;
-	  while (*s < end
-		 && (c = **s, c_isalnum (c)
-		     || c == '_' || c == '-' || c == '+'))
-	      ++*s;
-	  *len = *s - *beg;
-	  return XPM_TK_IDENT;
-	}
+        {
+          *beg = *s - 1;
+          while (*s < end
+                 && (c = **s, c_isalnum (c)
+                     || c == '_' || c == '-' || c == '+'))
+              ++*s;
+          *len = *s - *beg;
+          return XPM_TK_IDENT;
+        }
       else if (c == '"')
-	{
-	  *beg = *s;
-	  while (*s < end && **s != '"')
-	    ++*s;
-	  *len = *s - *beg;
-	  if (*s < end)
-	    ++*s;
-	  return XPM_TK_STRING;
-	}
+        {
+          *beg = *s;
+          while (*s < end && **s != '"')
+            ++*s;
+          *len = *s - *beg;
+          if (*s < end)
+            ++*s;
+          return XPM_TK_STRING;
+        }
       else if (c == '/')
-	{
-	  if (*s < end && **s == '*')
-	    {
-	      /* C-style comment.  */
-	      ++*s;
-	      do
-		{
-		  while (*s < end && *(*s)++ != '*')
-		    ;
-		}
-	      while (*s < end && **s != '/');
-	      if (*s < end)
-		++*s;
-	    }
-	  else
-	    return c;
-	}
+        {
+          if (*s < end && **s == '*')
+            {
+              /* C-style comment.  */
+              ++*s;
+              do
+                {
+                  while (*s < end && *(*s)++ != '*')
+                    ;
+                }
+              while (*s < end && **s != '/');
+              if (*s < end)
+                ++*s;
+            }
+          else
+            return c;
+        }
       else
-	return c;
+        return c;
     }
 
   return XPM_TK_EOF;
@@ -3919,9 +3919,9 @@ xpm_make_color_table_h (void (**put_func) (Lisp_Object,
   *put_func = xpm_put_color_table_h;
   *get_func = xpm_get_color_table_h;
   return make_hash_table (hashtest_equal, make_number (DEFAULT_HASH_SIZE),
-			  make_float (DEFAULT_REHASH_SIZE),
-			  make_float (DEFAULT_REHASH_THRESHOLD),
-			  Qnil);
+                          make_float (DEFAULT_REHASH_SIZE),
+                          make_float (DEFAULT_REHASH_THRESHOLD),
+                          Qnil);
 }
 
 static void
@@ -3996,8 +3996,8 @@ xpm_load_image (struct frame *f,
 #define expect(TOKEN)		\
   do				\
     {				\
-      if (LA1 != (TOKEN)) 	\
-	goto failure;		\
+      if (LA1 != (TOKEN))       \
+        goto failure;		\
       match ();			\
     }				\
   while (0)
@@ -4027,7 +4027,7 @@ xpm_load_image (struct frame *f,
   memcpy (buffer, beg, len);
   buffer[len] = '\0';
   if (sscanf (buffer, "%d %d %d %d", &width, &height,
-	      &num_colors, &chars_per_pixel) != 4
+              &num_colors, &chars_per_pixel) != 4
       || width <= 0 || height <= 0
       || num_colors <= 0 || chars_per_pixel <= 0)
     goto failure;
@@ -4041,7 +4041,7 @@ xpm_load_image (struct frame *f,
   if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)
 #ifndef HAVE_NS
       || !image_create_x_image_and_pixmap (f, img, width, height, 1,
-					   &mask_img, 1)
+                                           &mask_img, 1)
 #endif
       )
     {
@@ -4056,17 +4056,17 @@ xpm_load_image (struct frame *f,
     best_key = XPM_COLOR_KEY_C;
   else if (!NILP (Fx_display_grayscale_p (frame)))
     best_key = (XFASTINT (Fx_display_planes (frame)) > 2
-		? XPM_COLOR_KEY_G : XPM_COLOR_KEY_G4);
+                ? XPM_COLOR_KEY_G : XPM_COLOR_KEY_G4);
   else
     best_key = XPM_COLOR_KEY_M;
 
   color_symbols = image_spec_value (img->spec, QCcolor_symbols, NULL);
   if (chars_per_pixel == 1)
     color_table = xpm_make_color_table_v (&put_color_table,
-					  &get_color_table);
+                                          &get_color_table);
   else
     color_table = xpm_make_color_table_h (&put_color_table,
-					  &get_color_table);
+                                          &get_color_table);
 
   while (num_colors-- > 0)
     {
@@ -4077,67 +4077,67 @@ xpm_load_image (struct frame *f,
 
       expect (XPM_TK_STRING);
       if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel)
-	goto failure;
+        goto failure;
       memcpy (buffer, beg + chars_per_pixel, len - chars_per_pixel);
       buffer[len - chars_per_pixel] = '\0';
 
       str = strtok (buffer, " \t");
       if (str == NULL)
-	goto failure;
+        goto failure;
       key = xpm_str_to_color_key (str);
       if (key < 0)
-	goto failure;
+        goto failure;
       do
-	{
-	  color = strtok (NULL, " \t");
-	  if (color == NULL)
-	    goto failure;
-
-	  while ((str = strtok (NULL, " \t")) != NULL)
-	    {
-	      next_key = xpm_str_to_color_key (str);
-	      if (next_key >= 0)
-		break;
-	      color[strlen (color)] = ' ';
-	    }
-
-	  if (key == XPM_COLOR_KEY_S)
-	    {
-	      if (NILP (symbol_color))
-		symbol_color = build_string (color);
-	    }
-	  else if (max_key < key && key <= best_key)
-	    {
-	      max_key = key;
-	      max_color = color;
-	    }
-	  key = next_key;
-	}
+        {
+          color = strtok (NULL, " \t");
+          if (color == NULL)
+            goto failure;
+
+          while ((str = strtok (NULL, " \t")) != NULL)
+            {
+              next_key = xpm_str_to_color_key (str);
+              if (next_key >= 0)
+                break;
+              color[strlen (color)] = ' ';
+            }
+
+          if (key == XPM_COLOR_KEY_S)
+            {
+              if (NILP (symbol_color))
+                symbol_color = build_string (color);
+            }
+          else if (max_key < key && key <= best_key)
+            {
+              max_key = key;
+              max_color = color;
+            }
+          key = next_key;
+        }
       while (str);
 
       color_val = Qnil;
       if (!NILP (color_symbols) && !NILP (symbol_color))
-	{
-	  Lisp_Object specified_color = Fassoc (symbol_color, color_symbols);
-
-	  if (CONSP (specified_color) && STRINGP (XCDR (specified_color)))
-	    {
-	      if (xstrcasecmp (SSDATA (XCDR (specified_color)), "None") == 0)
-		color_val = Qt;
-	      else if (x_defined_color (f, SSDATA (XCDR (specified_color)),
-					&cdef, 0))
-		color_val = make_number (cdef.pixel);
-	    }
-	}
+        {
+          Lisp_Object specified_color = Fassoc (symbol_color, color_symbols);
+
+          if (CONSP (specified_color) && STRINGP (XCDR (specified_color)))
+            {
+              if (xstrcasecmp (SSDATA (XCDR (specified_color)), "None") == 0)
+                color_val = Qt;
+              else if (x_defined_color (f, SSDATA (XCDR (specified_color)),
+                                        &cdef, 0))
+                color_val = make_number (cdef.pixel);
+            }
+        }
       if (NILP (color_val) && max_key > 0)
-	{
-	  if (xstrcasecmp (max_color, "None") == 0)
-	    color_val = Qt;
-	  else if (x_defined_color (f, max_color, &cdef, 0))
-	    color_val = make_number (cdef.pixel);
-	}
+        {
+          if (xstrcasecmp (max_color, "None") == 0)
+            color_val = Qt;
+          else if (x_defined_color (f, max_color, &cdef, 0))
+            color_val = make_number (cdef.pixel);
+        }
       if (!NILP (color_val))
-	(*put_color_table) (color_table, beg, chars_per_pixel, color_val);
+        (*put_color_table) (color_table, beg, chars_per_pixel, color_val);
 
       expect (',');
     }
@@ -4147,26 +4147,26 @@ xpm_load_image (struct frame *f,
       expect (XPM_TK_STRING);
       str = beg;
       if (len < width * chars_per_pixel)
-	goto failure;
+        goto failure;
       for (x = 0; x < width; x++, str += chars_per_pixel)
-	{
-	  Lisp_Object color_val =
-	    (*get_color_table) (color_table, str, chars_per_pixel);
+        {
+          Lisp_Object color_val =
+            (*get_color_table) (color_table, str, chars_per_pixel);
 
-	  XPutPixel (ximg, x, y,
-		     (INTEGERP (color_val) ? XINT (color_val)
-		      : FRAME_FOREGROUND_PIXEL (f)));
+          XPutPixel (ximg, x, y,
+                     (INTEGERP (color_val) ? XINT (color_val)
+                      : FRAME_FOREGROUND_PIXEL (f)));
 #ifndef HAVE_NS
-	  XPutPixel (mask_img, x, y,
-		     (!EQ (color_val, Qt) ? PIX_MASK_DRAW
-		      : (have_mask = true, PIX_MASK_RETAIN)));
+          XPutPixel (mask_img, x, y,
+                     (!EQ (color_val, Qt) ? PIX_MASK_DRAW
+                      : (have_mask = true, PIX_MASK_RETAIN)));
 #else
           if (EQ (color_val, Qt))
             ns_set_alpha (ximg, x, y, 0);
 #endif
-	}
+        }
       if (y + 1 < height)
-	expect (',');
+        expect (',');
     }
 
   img->width = width;
@@ -4181,7 +4181,7 @@ xpm_load_image (struct frame *f,
   if (have_mask)
     {
       /* Fill in the background_transparent field while we have the
-	 mask handy.  */
+         mask handy.  */
       image_background_transparent (img, f, mask_img);
 
       image_put_x_image (f, img, mask_img, 1);
@@ -4223,17 +4223,17 @@ xpm_load (struct frame *f,
 
       file = x_find_image_file (file_name);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", file_name, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot find image file `%s'", file_name, Qnil);
+          return 0;
+        }
 
       contents = slurp_file (SSDATA (file), &size);
       if (contents == NULL)
-	{
-	  image_error ("Error loading XPM image `%s'", img->spec, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Error loading XPM image `%s'", img->spec, Qnil);
+          return 0;
+        }
 
       success_p = xpm_load_image (f, img, contents, contents + size);
       xfree (contents);
@@ -4244,12 +4244,12 @@ xpm_load (struct frame *f,
 
       data = image_spec_value (img->spec, QCdata, NULL);
       if (!STRINGP (data))
-	{
-	  image_error ("Invalid image data `%s'", data, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Invalid image data `%s'", data, Qnil);
+          return 0;
+        }
       success_p = xpm_load_image (f, img, SDATA (data),
-				  SDATA (data) + SBYTES (data));
+                                  SDATA (data) + SBYTES (data));
     }
 
   return success_p;
@@ -4260,7 +4260,7 @@ xpm_load (struct frame *f,
 
 \f
 /***********************************************************************
-			     Color table
+                             Color table
  ***********************************************************************/
 
 #ifdef COLOR_TABLE_SUPPORT
@@ -4295,7 +4295,7 @@ enum
 {
   ct_colors_allocated_max =
     min (INT_MAX,
-	 min (PTRDIFF_MAX, SIZE_MAX) / sizeof (unsigned long))
+         min (PTRDIFF_MAX, SIZE_MAX) / sizeof (unsigned long))
 };
 
 /* Initialize the color table.  */
@@ -4320,8 +4320,8 @@ free_color_table (void)
   for (i = 0; i < CT_SIZE; ++i)
     for (p = ct_table[i]; p; p = next)
       {
-	next = p->next;
-	xfree (p);
+        next = p->next;
+        xfree (p);
       }
 
   xfree (ct_table);
@@ -4353,16 +4353,16 @@ lookup_rgb_color (struct frame *f, int r, int g, int b)
 
       /* Apply gamma-correction like normal color allocation does.  */
       if (f->gamma)
-	{
-	  XColor color;
-	  color.red = r, color.green = g, color.blue = b;
-	  gamma_correct (f, &color);
-	  r = color.red, g = color.green, b = color.blue;
-	}
+        {
+          XColor color;
+          color.red = r, color.green = g, color.blue = b;
+          gamma_correct (f, &color);
+          r = color.red, g = color.green, b = color.blue;
+        }
 
       /* Scale down RGB values to the visual's bits per RGB, and shift
-	 them to the right position in the pixel color.  Note that the
-	 original RGB values are 16-bit values, as usual in X.  */
+         them to the right position in the pixel color.  Note that the
+         original RGB values are 16-bit values, as usual in X.  */
       pr = (r >> (16 - dpyinfo->red_bits))   << dpyinfo->red_offset;
       pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset;
       pb = (b >> (16 - dpyinfo->blue_bits))  << dpyinfo->blue_offset;
@@ -4387,7 +4387,7 @@ lookup_rgb_color (struct frame *f, int r, int g, int b)
 #endif
 
       if (ct_colors_allocated_max <= ct_colors_allocated)
-	return FRAME_FOREGROUND_PIXEL (f);
+        return FRAME_FOREGROUND_PIXEL (f);
 
 #ifdef HAVE_X_WINDOWS
       color.red = r;
@@ -4397,18 +4397,18 @@ lookup_rgb_color (struct frame *f, int r, int g, int b)
       cmap = FRAME_X_COLORMAP (f);
       rc = x_alloc_nearest_color (f, cmap, &color);
       if (rc)
-	{
-	  ++ct_colors_allocated;
-	  p = xmalloc (sizeof *p);
-	  p->r = r;
-	  p->g = g;
-	  p->b = b;
-	  p->pixel = color.pixel;
-	  p->next = ct_table[i];
-	  ct_table[i] = p;
-	}
+        {
+          ++ct_colors_allocated;
+          p = xmalloc (sizeof *p);
+          p->r = r;
+          p->g = g;
+          p->b = b;
+          p->pixel = color.pixel;
+          p->next = ct_table[i];
+          ct_table[i] = p;
+        }
       else
-	return FRAME_FOREGROUND_PIXEL (f);
+        return FRAME_FOREGROUND_PIXEL (f);
 
 #else
 #ifdef HAVE_NTGUI
@@ -4452,7 +4452,7 @@ lookup_pixel_color (struct frame *f, unsigned long pixel)
       bool rc;
 
       if (ct_colors_allocated_max <= ct_colors_allocated)
-	return FRAME_FOREGROUND_PIXEL (f);
+        return FRAME_FOREGROUND_PIXEL (f);
 
 #ifdef HAVE_X_WINDOWS
       cmap = FRAME_X_COLORMAP (f);
@@ -4469,19 +4469,19 @@ lookup_pixel_color (struct frame *f, unsigned long pixel)
 #endif /* HAVE_X_WINDOWS */
 
       if (rc)
-	{
-	  ++ct_colors_allocated;
-
-	  p = xmalloc (sizeof *p);
-	  p->r = color.red;
-	  p->g = color.green;
-	  p->b = color.blue;
-	  p->pixel = pixel;
-	  p->next = ct_table[i];
-	  ct_table[i] = p;
-	}
+        {
+          ++ct_colors_allocated;
+
+          p = xmalloc (sizeof *p);
+          p->r = color.red;
+          p->g = color.green;
+          p->b = color.blue;
+          p->pixel = pixel;
+          p->next = ct_table[i];
+          ct_table[i] = p;
+        }
       else
-	return FRAME_FOREGROUND_PIXEL (f);
+        return FRAME_FOREGROUND_PIXEL (f);
     }
   return p->pixel;
 }
@@ -4508,8 +4508,8 @@ colors_in_color_table (int *n)
       *n = ct_colors_allocated;
 
       for (i = j = 0; i < CT_SIZE; ++i)
-	for (p = ct_table[i]; p; p = p->next)
-	  colors[j++] = p->pixel;
+        for (p = ct_table[i]; p; p = p->next)
+          colors[j++] = p->pixel;
     }
 
   return colors;
@@ -4540,7 +4540,7 @@ init_color_table (void)
 
 \f
 /***********************************************************************
-			      Algorithms
+                              Algorithms
  ***********************************************************************/
 
 /* Edge detection matrices for different edge-detection
@@ -4548,14 +4548,14 @@ init_color_table (void)
 
 static int emboss_matrix[9] = {
    /* x - 1	x	x + 1  */
-        2,     -1,  	  0,		/* y - 1 */
+        2,     -1,        0,		/* y - 1 */
        -1,      0,        1,		/* y     */
         0,      1,       -2		/* y + 1 */
 };
 
 static int laplace_matrix[9] = {
    /* x - 1	x	x + 1  */
-        1,      0,  	  0,		/* y - 1 */
+        1,      0,        0,		/* y - 1 */
         0,      0,        0,		/* y     */
         0,      0,       -1		/* y + 1 */
 };
@@ -4597,23 +4597,23 @@ x_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
       XColor *row = p;
       for (x = 0; x < img->width; ++x, ++p)
-	p->pixel = GET_PIXEL (ximg, x, y);
+        p->pixel = GET_PIXEL (ximg, x, y);
       if (rgb_p)
-	x_query_colors (f, row, img->width);
+        x_query_colors (f, row, img->width);
 
 #else
 
       for (x = 0; x < img->width; ++x, ++p)
-	{
-	  /* W32_TODO: palette support needed here?  */
-	  p->pixel = GET_PIXEL (ximg, x, y);
-	  if (rgb_p)
-	    {
-	      p->red = RED16_FROM_ULONG (p->pixel);
-	      p->green = GREEN16_FROM_ULONG (p->pixel);
-	      p->blue = BLUE16_FROM_ULONG (p->pixel);
-	    }
-	}
+        {
+          /* W32_TODO: palette support needed here?  */
+          p->pixel = GET_PIXEL (ximg, x, y);
+          if (rgb_p)
+            {
+              p->red = RED16_FROM_ULONG (p->pixel);
+              p->green = GREEN16_FROM_ULONG (p->pixel);
+              p->blue = BLUE16_FROM_ULONG (p->pixel);
+            }
+        }
 #endif /* HAVE_X_WINDOWS */
     }
 
@@ -4640,7 +4640,7 @@ XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
       int rowbytes = width * 3;
       /* Ensure scanlines are aligned on 4 byte boundaries.  */
       if (rowbytes % 4)
-	rowbytes += 4 - (rowbytes % 4);
+        rowbytes += 4 - (rowbytes % 4);
 
       pixel = ximg->data + y * rowbytes + x * 3;
       /* Windows bitmaps are in BGR order.  */
@@ -4654,13 +4654,13 @@ XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
       int rowbytes = width / 8;
       /* Ensure scanlines are aligned on 4 byte boundaries.  */
       if (rowbytes % 4)
-	rowbytes += 4 - (rowbytes % 4);
+        rowbytes += 4 - (rowbytes % 4);
       pixel = ximg->data + y * rowbytes + x / 8;
       /* Filter out palette info.  */
       if (color & 0x00ffffff)
-	*pixel = *pixel | (1 << x % 8);
+        *pixel = *pixel | (1 << x % 8);
       else
-	*pixel = *pixel & ~(1 << x % 8);
+        *pixel = *pixel & ~(1 << x % 8);
     }
   else
     image_error ("XPutPixel: palette image not supported", Qnil, Qnil);
@@ -4683,14 +4683,14 @@ x_from_xcolors (struct frame *f, struct image *img, XColor *colors)
 
   x_clear_image_1 (f, img, CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_COLORS);
   image_create_x_image_and_pixmap (f, img, img->width, img->height, 0,
-				   &oimg, 0);
+                                   &oimg, 0);
   p = colors;
   for (y = 0; y < img->height; ++y)
     for (x = 0; x < img->width; ++x, ++p)
       {
-	unsigned long pixel;
-	pixel = lookup_rgb_color (f, p->red, p->green, p->blue);
-	XPutPixel (oimg, x, y, pixel);
+        unsigned long pixel;
+        pixel = lookup_rgb_color (f, p->red, p->green, p->blue);
+        XPutPixel (oimg, x, y, pixel);
       }
 
   xfree (colors);
@@ -4748,25 +4748,25 @@ x_detect_edges (struct frame *f, struct image *img, int *matrix, int color_adjus
       p = COLOR (new, 1, y);
 
       for (x = 1; x < img->width - 1; ++x, ++p)
-	{
-	  int r, g, b, yy, xx;
-
-	  r = g = b = i = 0;
-	  for (yy = y - 1; yy < y + 2; ++yy)
-	    for (xx = x - 1; xx < x + 2; ++xx, ++i)
-	      if (matrix[i])
-	        {
-	          XColor *t = COLOR (colors, xx, yy);
-		  r += matrix[i] * t->red;
-		  g += matrix[i] * t->green;
-		  b += matrix[i] * t->blue;
-		}
-
-	  r = (r / sum + color_adjust) & 0xffff;
-	  g = (g / sum + color_adjust) & 0xffff;
-	  b = (b / sum + color_adjust) & 0xffff;
-	  p->red = p->green = p->blue = COLOR_INTENSITY (r, g, b);
-	}
+        {
+          int r, g, b, yy, xx;
+
+          r = g = b = i = 0;
+          for (yy = y - 1; yy < y + 2; ++yy)
+            for (xx = x - 1; xx < x + 2; ++xx, ++i)
+              if (matrix[i])
+                {
+                  XColor *t = COLOR (colors, xx, yy);
+                  r += matrix[i] * t->red;
+                  g += matrix[i] * t->green;
+                  b += matrix[i] * t->blue;
+                }
+
+          r = (r / sum + color_adjust) & 0xffff;
+          g = (g / sum + color_adjust) & 0xffff;
+          b = (b / sum + color_adjust) & 0xffff;
+          p->red = p->green = p->blue = COLOR_INTENSITY (r, g, b);
+        }
     }
 
   xfree (colors);
@@ -4810,7 +4810,7 @@ x_laplace (struct frame *f, struct image *img)
 
 static void
 x_edge_detection (struct frame *f, struct image *img, Lisp_Object matrix,
-		  Lisp_Object color_adjust)
+                  Lisp_Object color_adjust)
 {
   int i = 0;
   int trans[9];
@@ -4818,14 +4818,14 @@ x_edge_detection (struct frame *f, struct image *img, Lisp_Object matrix,
   if (CONSP (matrix))
     {
       for (i = 0;
-	   i < 9 && CONSP (matrix) && NUMBERP (XCAR (matrix));
-	   ++i, matrix = XCDR (matrix))
-	trans[i] = XFLOATINT (XCAR (matrix));
+           i < 9 && CONSP (matrix) && NUMBERP (XCAR (matrix));
+           ++i, matrix = XCDR (matrix))
+        trans[i] = XFLOATINT (XCAR (matrix));
     }
   else if (VECTORP (matrix) && ASIZE (matrix) >= 9)
     {
       for (i = 0; i < 9 && NUMBERP (AREF (matrix, i)); ++i)
-	trans[i] = XFLOATINT (AREF (matrix, i));
+        trans[i] = XFLOATINT (AREF (matrix, i));
     }
 
   if (NILP (color_adjust))
@@ -4851,21 +4851,21 @@ x_disable_image (struct frame *f, struct image *img)
   if (n_planes >= 2)
     {
       /* Color (or grayscale).  Convert to gray, and equalize.  Just
-	 drawing such images with a stipple can look very odd, so
-	 we're using this method instead.  */
+         drawing such images with a stipple can look very odd, so
+         we're using this method instead.  */
       XColor *colors = x_to_xcolors (f, img, 1);
       XColor *p, *end;
       const int h = 15000;
       const int l = 30000;
 
       for (p = colors, end = colors + img->width * img->height;
-	   p < end;
-	   ++p)
-	{
-	  int i = COLOR_INTENSITY (p->red, p->green, p->blue);
-	  int i2 = (0xffff - h - l) * i / 0xffff + l;
-	  p->red = p->green = p->blue = i2;
-	}
+           p < end;
+           ++p)
+        {
+          int i = COLOR_INTENSITY (p->red, p->green, p->blue);
+          int i2 = (0xffff - h - l) * i / 0xffff + l;
+          p->red = p->green = p->blue = i2;
+        }
 
       x_from_xcolors (f, img, colors);
     }
@@ -4886,21 +4886,21 @@ x_disable_image (struct frame *f, struct image *img)
       gc = XCreateGC (dpy, img->pixmap, 0, NULL);
       XSetForeground (dpy, gc, BLACK_PIX_DEFAULT (f));
       XDrawLine (dpy, img->pixmap, gc, 0, 0,
-		 img->width - 1, img->height - 1);
+                 img->width - 1, img->height - 1);
       XDrawLine (dpy, img->pixmap, gc, 0, img->height - 1,
-		 img->width - 1, 0);
+                 img->width - 1, 0);
       XFreeGC (dpy, gc);
 
       if (img->mask)
-	{
-	  gc = XCreateGC (dpy, img->mask, 0, NULL);
-	  XSetForeground (dpy, gc, MaskForeground (f));
-	  XDrawLine (dpy, img->mask, gc, 0, 0,
-		     img->width - 1, img->height - 1);
-	  XDrawLine (dpy, img->mask, gc, 0, img->height - 1,
-		     img->width - 1, 0);
-	  XFreeGC (dpy, gc);
-	}
+        {
+          gc = XCreateGC (dpy, img->mask, 0, NULL);
+          XSetForeground (dpy, gc, MaskForeground (f));
+          XDrawLine (dpy, img->mask, gc, 0, 0,
+                     img->width - 1, img->height - 1);
+          XDrawLine (dpy, img->mask, gc, 0, img->height - 1,
+                     img->width - 1, 0);
+          XFreeGC (dpy, gc);
+        }
 #endif /* !HAVE_NS */
 #else
       HDC hdc, bmpdc;
@@ -4919,14 +4919,14 @@ x_disable_image (struct frame *f, struct image *img)
       LineTo (bmpdc, img->width - 1, 0);
 
       if (img->mask)
-	{
-	  SelectObject (bmpdc, img->mask);
-	  SetTextColor (bmpdc, WHITE_PIX_DEFAULT (f));
-	  MoveToEx (bmpdc, 0, 0, NULL);
-	  LineTo (bmpdc, img->width - 1, img->height - 1);
-	  MoveToEx (bmpdc, 0, img->height - 1, NULL);
-	  LineTo (bmpdc, img->width - 1, 0);
-	}
+        {
+          SelectObject (bmpdc, img->mask);
+          SetTextColor (bmpdc, WHITE_PIX_DEFAULT (f));
+          MoveToEx (bmpdc, 0, 0, NULL);
+          LineTo (bmpdc, img->width - 1, img->height - 1);
+          MoveToEx (bmpdc, 0, img->height - 1, NULL);
+          LineTo (bmpdc, img->width - 1, 0);
+        }
       SelectObject (bmpdc, prev);
       DeleteDC (bmpdc);
 #endif /* HAVE_NTGUI */
@@ -4963,7 +4963,7 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
 #ifndef HAVE_NS
   /* Create an image and pixmap serving as mask.  */
   if (! image_create_x_image_and_pixmap (f, img, img->width, img->height, 1,
-					 &mask_img, 1))
+                                         &mask_img, 1))
     return;
 #endif /* !HAVE_NS */
 #else
@@ -4984,22 +4984,22 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
       int rgb[3], i;
 
       for (i = 0; i < 3 && CONSP (how) && NATNUMP (XCAR (how)); ++i)
-	{
-	  rgb[i] = XFASTINT (XCAR (how)) & 0xffff;
-	  how = XCDR (how);
-	}
+        {
+          rgb[i] = XFASTINT (XCAR (how)) & 0xffff;
+          how = XCDR (how);
+        }
 
       if (i == 3 && NILP (how))
-	{
-	  char color_name[30];
-	  sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
-	  bg = (
+        {
+          char color_name[30];
+          sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
+          bg = (
 #ifdef HAVE_NTGUI
-		0x00ffffff & /* Filter out palette info.  */
+                0x00ffffff & /* Filter out palette info.  */
 #endif /* HAVE_NTGUI */
-		x_alloc_image_color (f, img, build_string (color_name), 0));
-	  use_img_background = 0;
-	}
+                x_alloc_image_color (f, img, build_string (color_name), 0));
+          use_img_background = 0;
+        }
     }
 
   if (use_img_background)
@@ -5012,7 +5012,7 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
     for (x = 0; x < img->width; ++x)
 #ifndef HAVE_NS
       XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg
-				  ? PIX_MASK_DRAW : PIX_MASK_RETAIN));
+                                  ? PIX_MASK_DRAW : PIX_MASK_RETAIN));
 #else
       if (XGetPixel (ximg, x, y) == bg)
         ns_set_alpha (ximg, x, y, 0);
@@ -5028,14 +5028,14 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
   for (y = 0; y < img->height; ++y)
     for (x = 0; x < img->width; ++x)
       {
-	COLORREF p = GetPixel (ximg, x, y);
-	if (p != bg)
-	  mask_img[y * row_width + x / 8] |= 1 << (x % 8);
+        COLORREF p = GetPixel (ximg, x, y);
+        if (p != bg)
+          mask_img[y * row_width + x / 8] |= 1 << (x % 8);
       }
 
   /* Create the mask image.  */
   img->mask = w32_create_pixmap_from_bitmap_data (img->width, img->height,
-						  mask_img);
+                                                  mask_img);
   /* Fill in the background_transparent field while we have the mask handy. */
   SelectObject (ximg, img->mask);
   image_background_transparent (img, f, ximg);
@@ -5049,7 +5049,7 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
 
 \f
 /***********************************************************************
-		       PBM (mono, gray, color)
+                       PBM (mono, gray, color)
  ***********************************************************************/
 
 static bool pbm_image_p (Lisp_Object object);
@@ -5192,17 +5192,17 @@ pbm_load (struct frame *f, struct image *img)
     {
       file = x_find_image_file (specified_file);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", specified_file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot find image file `%s'", specified_file, Qnil);
+          return 0;
+        }
 
       contents = slurp_file (SSDATA (file), &size);
       if (contents == NULL)
-	{
-	  image_error ("Error reading `%s'", file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Error reading `%s'", file, Qnil);
+          return 0;
+        }
 
       p = contents;
       end = contents + size;
@@ -5212,10 +5212,10 @@ pbm_load (struct frame *f, struct image *img)
       Lisp_Object data;
       data = image_spec_value (img->spec, QCdata, NULL);
       if (!STRINGP (data))
-	{
-	  image_error ("Invalid image data `%s'", data, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Invalid image data `%s'", data, Qnil);
+          return 0;
+        }
       p = SDATA (data);
       end = p + SBYTES (data);
     }
@@ -5270,10 +5270,10 @@ pbm_load (struct frame *f, struct image *img)
     {
       max_color_idx = pbm_scan_number (&p, end);
       if (max_color_idx > 65535 || max_color_idx < 0)
-	{
-	  image_error ("Unsupported maximum PBM color value", Qnil, Qnil);
-	  goto error;
-	}
+        {
+          image_error ("Unsupported maximum PBM color value", Qnil, Qnil);
+          goto error;
+        }
     }
 
   if (!check_image_size (f, width, height))
@@ -5301,106 +5301,106 @@ pbm_load (struct frame *f, struct image *img)
 
       /* Get foreground and background colors, maybe allocate colors.  */
       if (fmt[PBM_FOREGROUND].count
-	  && STRINGP (fmt[PBM_FOREGROUND].value))
-	fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg);
+          && STRINGP (fmt[PBM_FOREGROUND].value))
+        fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg);
       if (fmt[PBM_BACKGROUND].count
-	  && STRINGP (fmt[PBM_BACKGROUND].value))
-	{
-	  bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg);
-	  img->background = bg;
-	  img->background_valid = 1;
-	}
+          && STRINGP (fmt[PBM_BACKGROUND].value))
+        {
+          bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg);
+          img->background = bg;
+          img->background_valid = 1;
+        }
 
       for (y = 0; y < height; ++y)
-	for (x = 0; x < width; ++x)
-	  {
-	    if (raw_p)
-	      {
-		if ((x & 7) == 0)
-		  {
-		    if (p >= end)
-		      {
-			x_destroy_x_image (ximg);
-			x_clear_image (f, img);
-			image_error ("Invalid image size in image `%s'",
-				     img->spec, Qnil);
-			goto error;
-		      }
-		    c = *p++;
-		  }
-		g = c & 0x80;
-		c <<= 1;
-	      }
-	    else
-	      g = pbm_scan_number (&p, end);
-
-	    XPutPixel (ximg, x, y, g ? fg : bg);
-	  }
+        for (x = 0; x < width; ++x)
+          {
+            if (raw_p)
+              {
+                if ((x & 7) == 0)
+                  {
+                    if (p >= end)
+                      {
+                        x_destroy_x_image (ximg);
+                        x_clear_image (f, img);
+                        image_error ("Invalid image size in image `%s'",
+                                     img->spec, Qnil);
+                        goto error;
+                      }
+                    c = *p++;
+                  }
+                g = c & 0x80;
+                c <<= 1;
+              }
+            else
+              g = pbm_scan_number (&p, end);
+
+            XPutPixel (ximg, x, y, g ? fg : bg);
+          }
     }
   else
     {
       int expected_size = height * width;
       if (max_color_idx > 255)
-	expected_size *= 2;
+        expected_size *= 2;
       if (type == PBM_COLOR)
-	expected_size *= 3;
+        expected_size *= 3;
 
       if (raw_p && p + expected_size > end)
-	{
-	  x_destroy_x_image (ximg);
-	  x_clear_image (f, img);
-	  image_error ("Invalid image size in image `%s'",
-		       img->spec, Qnil);
-	  goto error;
-	}
+        {
+          x_destroy_x_image (ximg);
+          x_clear_image (f, img);
+          image_error ("Invalid image size in image `%s'",
+                       img->spec, Qnil);
+          goto error;
+        }
 
       for (y = 0; y < height; ++y)
-	for (x = 0; x < width; ++x)
-	  {
-	    int r, g, b;
-
-	    if (type == PBM_GRAY && raw_p)
-	      {
-		r = g = b = *p++;
-		if (max_color_idx > 255)
-		  r = g = b = r * 256 + *p++;
-	      }
-	    else if (type == PBM_GRAY)
-	      r = g = b = pbm_scan_number (&p, end);
-	    else if (raw_p)
-	      {
-		r = *p++;
-		if (max_color_idx > 255)
-		  r = r * 256 + *p++;
-		g = *p++;
-		if (max_color_idx > 255)
-		  g = g * 256 + *p++;
-		b = *p++;
-		if (max_color_idx > 255)
-		  b = b * 256 + *p++;
-	      }
-	    else
-	      {
-		r = pbm_scan_number (&p, end);
-		g = pbm_scan_number (&p, end);
-		b = pbm_scan_number (&p, end);
-	      }
-
-	    if (r < 0 || g < 0 || b < 0)
-	      {
-		x_destroy_x_image (ximg);
-		image_error ("Invalid pixel value in image `%s'",
-			     img->spec, Qnil);
-		goto error;
-	      }
-
-	    /* RGB values are now in the range 0..max_color_idx.
-	       Scale this to the range 0..0xffff supported by X.  */
-	    r = (double) r * 65535 / max_color_idx;
-	    g = (double) g * 65535 / max_color_idx;
-	    b = (double) b * 65535 / max_color_idx;
-	    XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
-	  }
+        for (x = 0; x < width; ++x)
+          {
+            int r, g, b;
+
+            if (type == PBM_GRAY && raw_p)
+              {
+                r = g = b = *p++;
+                if (max_color_idx > 255)
+                  r = g = b = r * 256 + *p++;
+              }
+            else if (type == PBM_GRAY)
+              r = g = b = pbm_scan_number (&p, end);
+            else if (raw_p)
+              {
+                r = *p++;
+                if (max_color_idx > 255)
+                  r = r * 256 + *p++;
+                g = *p++;
+                if (max_color_idx > 255)
+                  g = g * 256 + *p++;
+                b = *p++;
+                if (max_color_idx > 255)
+                  b = b * 256 + *p++;
+              }
+            else
+              {
+                r = pbm_scan_number (&p, end);
+                g = pbm_scan_number (&p, end);
+                b = pbm_scan_number (&p, end);
+              }
+
+            if (r < 0 || g < 0 || b < 0)
+              {
+                x_destroy_x_image (ximg);
+                image_error ("Invalid pixel value in image `%s'",
+                             img->spec, Qnil);
+                goto error;
+              }
+
+            /* RGB values are now in the range 0..max_color_idx.
+               Scale this to the range 0..0xffff supported by X.  */
+            r = (double) r * 65535 / max_color_idx;
+            g = (double) g * 65535 / max_color_idx;
+            b = (double) b * 65535 / max_color_idx;
+            XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
+          }
     }
 
 #ifdef COLOR_TABLE_SUPPORT
@@ -5432,7 +5432,7 @@ pbm_load (struct frame *f, struct image *img)
 
 \f
 /***********************************************************************
-				 PNG
+                                 PNG
  ***********************************************************************/
 
 #if defined (HAVE_PNG) || defined (HAVE_NS)
@@ -5524,21 +5524,21 @@ png_image_p (Lisp_Object object)
 DEF_IMGLIB_FN (png_voidp, png_get_io_ptr, (png_structp));
 DEF_IMGLIB_FN (int, png_sig_cmp, (png_bytep, png_size_t, png_size_t));
 DEF_IMGLIB_FN (png_structp, png_create_read_struct, (png_const_charp, png_voidp,
-						     png_error_ptr, png_error_ptr));
+                                                     png_error_ptr, png_error_ptr));
 DEF_IMGLIB_FN (png_infop, png_create_info_struct, (png_structp));
 DEF_IMGLIB_FN (void, png_destroy_read_struct, (png_structpp, png_infopp, png_infopp));
 DEF_IMGLIB_FN (void, png_set_read_fn, (png_structp, png_voidp, png_rw_ptr));
 DEF_IMGLIB_FN (void, png_set_sig_bytes, (png_structp, int));
 DEF_IMGLIB_FN (void, png_read_info, (png_structp, png_infop));
 DEF_IMGLIB_FN (png_uint_32, png_get_IHDR, (png_structp, png_infop,
-			      png_uint_32 *, png_uint_32 *,
-			      int *, int *, int *, int *, int *));
+                              png_uint_32 *, png_uint_32 *,
+                              int *, int *, int *, int *, int *));
 DEF_IMGLIB_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32));
 DEF_IMGLIB_FN (void, png_set_strip_16, (png_structp));
 DEF_IMGLIB_FN (void, png_set_expand, (png_structp));
 DEF_IMGLIB_FN (void, png_set_gray_to_rgb, (png_structp));
 DEF_IMGLIB_FN (void, png_set_background, (png_structp, png_color_16p,
-				    int, int, double));
+                                    int, int, double));
 DEF_IMGLIB_FN (png_uint_32, png_get_bKGD, (png_structp, png_infop, png_color_16p *));
 DEF_IMGLIB_FN (void, png_read_update_info, (png_structp, png_infop));
 DEF_IMGLIB_FN (png_byte, png_get_channels, (png_structp, png_infop));
@@ -5747,35 +5747,35 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
     {
       file = x_find_image_file (specified_file);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", specified_file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot find image file `%s'", specified_file, Qnil);
+          return 0;
+        }
 
       /* Open the image file.  */
       fp = emacs_fopen (SSDATA (file), "rb");
       if (!fp)
-	{
-	  image_error ("Cannot open image file `%s'", file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot open image file `%s'", file, Qnil);
+          return 0;
+        }
 
       /* Check PNG signature.  */
       if (fread (sig, 1, sizeof sig, fp) != sizeof sig
-	  || fn_png_sig_cmp (sig, 0, sizeof sig))
-	{
-	  fclose (fp);
-	  image_error ("Not a PNG file: `%s'", file, Qnil);
-	  return 0;
-	}
+          || fn_png_sig_cmp (sig, 0, sizeof sig))
+        {
+          fclose (fp);
+          image_error ("Not a PNG file: `%s'", file, Qnil);
+          return 0;
+        }
     }
   else
     {
       if (!STRINGP (specified_data))
-	{
-	  image_error ("Invalid image data `%s'", specified_data, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Invalid image data `%s'", specified_data, Qnil);
+          return 0;
+        }
 
       /* Read from memory.  */
       tbr.bytes = SDATA (specified_data);
@@ -5784,11 +5784,11 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
 
       /* Check PNG signature.  */
       if (tbr.len < sizeof sig
-	  || fn_png_sig_cmp (tbr.bytes, 0, sizeof sig))
-	{
-	  image_error ("Not a PNG image: `%s'", img->spec, Qnil);
-	  return 0;
-	}
+          || fn_png_sig_cmp (tbr.bytes, 0, sizeof sig))
+        {
+          image_error ("Not a PNG image: `%s'", img->spec, Qnil);
+          return 0;
+        }
 
       /* Need to skip past the signature.  */
       tbr.bytes += sizeof (sig);
@@ -5796,8 +5796,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
 
   /* Initialize read and info structs for PNG lib.  */
   png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING,
-				       NULL, my_png_error,
-				       my_png_warning);
+                                       NULL, my_png_error,
+                                       my_png_warning);
   if (png_ptr)
     {
       info_ptr = fn_png_create_info_struct (png_ptr);
@@ -5828,11 +5828,11 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
     {
     error:
       if (c->png_ptr)
-	fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
+        fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
       xfree (c->pixels);
       xfree (c->rows);
       if (c->fp)
-	fclose (c->fp);
+        fclose (c->fp);
       return 0;
     }
 
@@ -5848,10 +5848,10 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
   fn_png_set_sig_bytes (png_ptr, sizeof sig);
   fn_png_read_info (png_ptr, info_ptr);
   fn_png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
-		   &interlace_type, NULL, NULL);
+                   &interlace_type, NULL, NULL);
 
   if (! (width <= INT_MAX && height <= INT_MAX
-	 && check_image_size (f, width, height)))
+         && check_image_size (f, width, height)))
     {
       image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
       goto error;
@@ -5893,26 +5893,26 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
     {
       /* png_color_16 *image_bg; */
       Lisp_Object specified_bg
-	= image_spec_value (img->spec, QCbackground, NULL);
+        = image_spec_value (img->spec, QCbackground, NULL);
       XColor color;
 
       /* If the user specified a color, try to use it; if not, use the
-	 current frame background, ignoring any default background
-	 color set by the image.  */
+         current frame background, ignoring any default background
+         color set by the image.  */
       if (STRINGP (specified_bg)
-	  ? x_defined_color (f, SSDATA (specified_bg), &color, false)
-	  : (x_query_frame_background_color (f, &color), true))
-	/* The user specified `:background', use that.  */
-	{
-	  int shift = bit_depth == 16 ? 0 : 8;
-	  png_color_16 bg = { 0 };
-	  bg.red = color.red >> shift;
-	  bg.green = color.green >> shift;
-	  bg.blue = color.blue >> shift;
-
-	  fn_png_set_background (png_ptr, &bg,
-				 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
-	}
+          ? x_defined_color (f, SSDATA (specified_bg), &color, false)
+          : (x_query_frame_background_color (f, &color), true))
+        /* The user specified `:background', use that.  */
+        {
+          int shift = bit_depth == 16 ? 0 : 8;
+          png_color_16 bg = { 0 };
+          bg.red = color.red >> shift;
+          bg.green = color.green >> shift;
+          bg.blue = color.blue >> shift;
+
+          fn_png_set_background (png_ptr, &bg,
+                                 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+        }
     }
 
   /* Update info structure.  */
@@ -5952,7 +5952,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
   if (channels == 4
       && !transparent_p
       && !image_create_x_image_and_pixmap (f, img, width, height, 1,
-					   &mask_img, 1))
+                                           &mask_img, 1))
     {
       x_destroy_x_image (ximg);
       x_clear_image_1 (f, img, CLEAR_IMAGE_PIXMAP);
@@ -5967,36 +5967,36 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
       png_byte *p = rows[y];
 
       for (x = 0; x < width; ++x)
-	{
-	  int r, g, b;
-
-	  r = *p++ << 8;
-	  g = *p++ << 8;
-	  b = *p++ << 8;
-	  XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
-	  /* An alpha channel, aka mask channel, associates variable
-	     transparency with an image.  Where other image formats
-	     support binary transparency---fully transparent or fully
-	     opaque---PNG allows up to 254 levels of partial transparency.
-	     The PNG library implements partial transparency by combining
-	     the image with a specified background color.
-
-	     I'm not sure how to handle this here nicely: because the
-	     background on which the image is displayed may change, for
-	     real alpha channel support, it would be necessary to create
-	     a new image for each possible background.
-
-	     What I'm doing now is that a mask is created if we have
-	     boolean transparency information.  Otherwise I'm using
-	     the frame's background color to combine the image with.  */
-
-	  if (channels == 4)
-	    {
-	      if (mask_img)
-		XPutPixel (mask_img, x, y, *p > 0 ? PIX_MASK_DRAW : PIX_MASK_RETAIN);
-	      ++p;
-	    }
-	}
+        {
+          int r, g, b;
+
+          r = *p++ << 8;
+          g = *p++ << 8;
+          b = *p++ << 8;
+          XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
+          /* An alpha channel, aka mask channel, associates variable
+             transparency with an image.  Where other image formats
+             support binary transparency---fully transparent or fully
+             opaque---PNG allows up to 254 levels of partial transparency.
+             The PNG library implements partial transparency by combining
+             the image with a specified background color.
+
+             I'm not sure how to handle this here nicely: because the
+             background on which the image is displayed may change, for
+             real alpha channel support, it would be necessary to create
+             a new image for each possible background.
+
+             What I'm doing now is that a mask is created if we have
+             boolean transparency information.  Otherwise I'm using
+             the frame's background color to combine the image with.  */
+
+          if (channels == 4)
+            {
+              if (mask_img)
+                XPutPixel (mask_img, x, y, *p > 0 ? PIX_MASK_DRAW : PIX_MASK_RETAIN);
+              ++p;
+            }
+        }
     }
 
   if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
@@ -6005,10 +6005,10 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
     {
       png_color_16 *bg;
       if (fn_png_get_bKGD (png_ptr, info_ptr, &bg))
-	{
-	  img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue);
-	  img->background_valid = 1;
-	}
+        {
+          img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue);
+          img->background_valid = 1;
+        }
     }
 
 #ifdef COLOR_TABLE_SUPPORT
@@ -6036,7 +6036,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
   if (mask_img)
     {
       /* Fill in the background_transparent field while we have the
-	 mask handy.  Casting avoids a GCC warning.  */
+         mask handy.  Casting avoids a GCC warning.  */
       image_background_transparent (img, f, (XImagePtr_or_DC)mask_img);
 
       image_put_x_image (f, img, mask_img, 1);
@@ -6067,7 +6067,7 @@ png_load (struct frame *f, struct image *img)
 
 \f
 /***********************************************************************
-				 JPEG
+                                 JPEG
  ***********************************************************************/
 
 #if defined (HAVE_JPEG) || defined (HAVE_NS)
@@ -6312,7 +6312,7 @@ our_memory_skip_input_data (j_decompress_ptr cinfo, long int num_bytes)
   if (src)
     {
       if (num_bytes > src->bytes_in_buffer)
-	ERREXIT (cinfo, JERR_INPUT_EOF);
+        ERREXIT (cinfo, JERR_INPUT_EOF);
 
       src->bytes_in_buffer -= num_bytes;
       src->next_input_byte += num_bytes;
@@ -6333,7 +6333,7 @@ jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, ptrdiff_t len)
     {
       /* First time for this JPEG object?  */
       src = cinfo->mem->alloc_small ((j_common_ptr) cinfo,
-				     JPOOL_PERMANENT, sizeof *src);
+                                     JPOOL_PERMANENT, sizeof *src);
       cinfo->src = src;
       src->next_input_byte = data;
     }
@@ -6435,11 +6435,11 @@ jpeg_file_src (j_decompress_ptr cinfo, FILE *fp)
     {
       /* First time for this JPEG object?  */
       src = cinfo->mem->alloc_small ((j_common_ptr) cinfo,
-				     JPOOL_PERMANENT, sizeof *src);
+                                     JPOOL_PERMANENT, sizeof *src);
       cinfo->src = (struct jpeg_source_mgr *) src;
       src->buffer = cinfo->mem->alloc_small ((j_common_ptr) cinfo,
-					     JPOOL_PERMANENT,
-					     JPEG_STDIO_BUFFER_SIZE);
+                                             JPOOL_PERMANENT,
+                                             JPEG_STDIO_BUFFER_SIZE);
     }
 
   src->file = fp;
@@ -6459,7 +6459,7 @@ jpeg_file_src (j_decompress_ptr cinfo, FILE *fp)
 
 static bool
 jpeg_load_body (struct frame *f, struct image *img,
-		struct my_jpeg_error_mgr *mgr)
+                struct my_jpeg_error_mgr *mgr)
 {
   Lisp_Object file, specified_file;
   Lisp_Object specified_data;
@@ -6479,17 +6479,17 @@ jpeg_load_body (struct frame *f, struct image *img,
     {
       file = x_find_image_file (specified_file);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", specified_file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot find image file `%s'", specified_file, Qnil);
+          return 0;
+        }
 
       fp = emacs_fopen (SSDATA (file), "rb");
       if (fp == NULL)
-	{
-	  image_error ("Cannot open `%s'", file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot open `%s'", file, Qnil);
+          return 0;
+        }
     }
   else if (!STRINGP (specified_data))
     {
@@ -6504,27 +6504,27 @@ jpeg_load_body (struct frame *f, struct image *img,
   if (sys_setjmp (mgr->setjmp_buffer))
     {
       switch (mgr->failure_code)
-	{
-	case MY_JPEG_ERROR_EXIT:
-	  {
-	    char buf[JMSG_LENGTH_MAX];
-	    mgr->cinfo.err->format_message ((j_common_ptr) &mgr->cinfo, buf);
-	    image_error ("Error reading JPEG image `%s': %s", img->spec,
-			 build_string (buf));
-	    break;
-	  }
-
-	case MY_JPEG_INVALID_IMAGE_SIZE:
-	  image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
-	  break;
-
-	case MY_JPEG_CANNOT_CREATE_X:
-	  break;
-	}
+        {
+        case MY_JPEG_ERROR_EXIT:
+          {
+            char buf[JMSG_LENGTH_MAX];
+            mgr->cinfo.err->format_message ((j_common_ptr) &mgr->cinfo, buf);
+            image_error ("Error reading JPEG image `%s': %s", img->spec,
+                         build_string (buf));
+            break;
+          }
+
+        case MY_JPEG_INVALID_IMAGE_SIZE:
+          image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
+          break;
+
+        case MY_JPEG_CANNOT_CREATE_X:
+          break;
+        }
 
       /* Close the input file and destroy the JPEG object.  */
       if (fp)
-	fclose (fp);
+        fclose (fp);
       fn_jpeg_destroy_decompress (&mgr->cinfo);
 
       /* If we already have an XImage, free that.  */
@@ -6536,19 +6536,19 @@ jpeg_load_body (struct frame *f, struct image *img,
     }
 
   /* Create the JPEG decompression object.  Let it read from fp.
-	 Read the JPEG image header.  */
+         Read the JPEG image header.  */
   fn_jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo);
 
   if (NILP (specified_data))
     jpeg_file_src (&mgr->cinfo, fp);
   else
     jpeg_memory_src (&mgr->cinfo, SDATA (specified_data),
-		     SBYTES (specified_data));
+                     SBYTES (specified_data));
 
   fn_jpeg_read_header (&mgr->cinfo, 1);
 
   /* Customize decompression so that color quantization will be used.
-	 Start decompression.  */
+         Start decompression.  */
   mgr->cinfo.quantize_colors = 1;
   fn_jpeg_start_decompress (&mgr->cinfo);
   width = img->width = mgr->cinfo.output_width;
@@ -6591,12 +6591,12 @@ jpeg_load_body (struct frame *f, struct image *img,
 
     for (i = 0; i < mgr->cinfo.actual_number_of_colors; ++i)
       {
-	/* Multiply RGB values with 255 because X expects RGB values
-	   in the range 0..0xffff.  */
-	int r = mgr->cinfo.colormap[ir][i] << 8;
-	int g = mgr->cinfo.colormap[ig][i] << 8;
-	int b = mgr->cinfo.colormap[ib][i] << 8;
-	colors[i] = lookup_rgb_color (f, r, g, b);
+        /* Multiply RGB values with 255 because X expects RGB values
+           in the range 0..0xffff.  */
+        int r = mgr->cinfo.colormap[ir][i] << 8;
+        int g = mgr->cinfo.colormap[ig][i] << 8;
+        int b = mgr->cinfo.colormap[ib][i] << 8;
+        colors[i] = lookup_rgb_color (f, r, g, b);
       }
 
 #ifdef COLOR_TABLE_SUPPORT
@@ -6609,12 +6609,12 @@ jpeg_load_body (struct frame *f, struct image *img,
   /* Read pixels.  */
   row_stride = width * mgr->cinfo.output_components;
   buffer = mgr->cinfo.mem->alloc_sarray ((j_common_ptr) &mgr->cinfo,
-					 JPOOL_IMAGE, row_stride, 1);
+                                         JPOOL_IMAGE, row_stride, 1);
   for (y = 0; y < height; ++y)
     {
       fn_jpeg_read_scanlines (&mgr->cinfo, buffer, 1);
       for (x = 0; x < mgr->cinfo.output_width; ++x)
-	XPutPixel (ximg, x, y, colors[buffer[0][x]]);
+        XPutPixel (ximg, x, y, colors[buffer[0][x]]);
     }
 
   /* Clean up.  */
@@ -6647,8 +6647,8 @@ static bool
 jpeg_load (struct frame *f, struct image *img)
 {
   return ns_load_image (f, img,
-			image_spec_value (img->spec, QCfile, NULL),
-			image_spec_value (img->spec, QCdata, NULL));
+                        image_spec_value (img->spec, QCfile, NULL),
+                        image_spec_value (img->spec, QCdata, NULL));
 }
 #endif  /* HAVE_NS */
 
@@ -6657,7 +6657,7 @@ jpeg_load (struct frame *f, struct image *img)
 
 \f
 /***********************************************************************
-				 TIFF
+                                 TIFF
  ***********************************************************************/
 
 #if defined (HAVE_TIFF) || defined (HAVE_NS)
@@ -6751,9 +6751,9 @@ DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler));
 DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetWarningHandler, (TIFFErrorHandler));
 DEF_IMGLIB_FN (TIFF *, TIFFOpen, (const char *, const char *));
 DEF_IMGLIB_FN (TIFF *, TIFFClientOpen, (const char *, const char *, thandle_t,
-				TIFFReadWriteProc, TIFFReadWriteProc,
-				TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
-				TIFFMapFileProc, TIFFUnmapFileProc));
+                                TIFFReadWriteProc, TIFFReadWriteProc,
+                                TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
+                                TIFFMapFileProc, TIFFUnmapFileProc));
 DEF_IMGLIB_FN (int, TIFFGetField, (TIFF *, ttag_t, ...));
 DEF_IMGLIB_FN (int, TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int));
 DEF_IMGLIB_FN (void, TIFFClose, (TIFF *));
@@ -6897,7 +6897,7 @@ tiff_handler (const char *, const char *, const char *, va_list)
   ATTRIBUTE_FORMAT_PRINTF (3, 0);
 MINGW_STATIC void
 tiff_handler (const char *log_format, const char *title,
-	      const char *format, va_list ap)
+              const char *format, va_list ap)
 {
   /* doprnt is not suitable here, as TIFF handlers are called from
      libtiff and are passed arbitrary printf directives.  Instead, use
@@ -6907,7 +6907,7 @@ tiff_handler (const char *log_format, const char *title,
   char buf[4000];
   int len = vsnprintf (buf, sizeof buf, format, ap);
   add_to_log (log_format, build_string (title),
-	      make_string (buf, max (0, min (len, sizeof buf - 1))));
+              make_string (buf, max (0, min (len, sizeof buf - 1))));
 }
 #undef MINGW_STATIC
 
@@ -6956,10 +6956,10 @@ tiff_load (struct frame *f, struct image *img)
       /* Read from a file */
       file = x_find_image_file (specified_file);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", specified_file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot find image file `%s'", specified_file, Qnil);
+          return 0;
+        }
 #ifdef WINDOWSNT
       file = ansi_encode_filename (file);
 #endif
@@ -6967,18 +6967,18 @@ tiff_load (struct frame *f, struct image *img)
       /* Try to open the image file.  */
       tiff = fn_TIFFOpen (SSDATA (file), "r");
       if (tiff == NULL)
-	{
-	  image_error ("Cannot open `%s'", file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot open `%s'", file, Qnil);
+          return 0;
+        }
     }
   else
     {
       if (!STRINGP (specified_data))
-	{
-	  image_error ("Invalid image data `%s'", specified_data, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Invalid image data `%s'", specified_data, Qnil);
+          return 0;
+        }
 
       /* Memory source! */
       memsrc.bytes = SDATA (specified_data);
@@ -6986,19 +6986,19 @@ tiff_load (struct frame *f, struct image *img)
       memsrc.index = 0;
 
       tiff = fn_TIFFClientOpen ("memory_source", "r", (thandle_t)&memsrc,
-				tiff_read_from_memory,
-				tiff_write_from_memory,
-				tiff_seek_in_memory,
-				tiff_close_memory,
-				tiff_size_of_memory,
-				tiff_mmap_memory,
-				tiff_unmap_memory);
+                                tiff_read_from_memory,
+                                tiff_write_from_memory,
+                                tiff_seek_in_memory,
+                                tiff_close_memory,
+                                tiff_size_of_memory,
+                                tiff_mmap_memory,
+                                tiff_unmap_memory);
 
       if (!tiff)
-	{
-	  image_error ("Cannot open memory source for `%s'", img->spec, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot open memory source for `%s'", img->spec, Qnil);
+          return 0;
+        }
     }
 
   image = image_spec_value (img->spec, QCindex, NULL);
@@ -7006,13 +7006,13 @@ tiff_load (struct frame *f, struct image *img)
     {
       EMACS_INT ino = XFASTINT (image);
       if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t)
-	     && fn_TIFFSetDirectory (tiff, ino)))
-	{
-	  image_error ("Invalid image number `%s' in image `%s'",
-		       image, img->spec);
-	  fn_TIFFClose (tiff);
-	  return 0;
-	}
+             && fn_TIFFSetDirectory (tiff, ino)))
+        {
+          image_error ("Invalid image number `%s' in image `%s'",
+                       image, img->spec);
+          fn_TIFFClose (tiff);
+          return 0;
+        }
     }
 
   /* Get width and height of the image, and allocate a raster buffer
@@ -7029,8 +7029,8 @@ tiff_load (struct frame *f, struct image *img)
 
   /* Create the X image and pixmap.  */
   if (! (height <= min (PTRDIFF_MAX, SIZE_MAX) / sizeof *buf / width
-	 && image_create_x_image_and_pixmap (f, img, width, height, 0,
-					     &ximg, 0)))
+         && image_create_x_image_and_pixmap (f, img, width, height, 0,
+                                             &ximg, 0)))
     {
       fn_TIFFClose (tiff);
       return 0;
@@ -7046,8 +7046,8 @@ tiff_load (struct frame *f, struct image *img)
 
   if (count > 1)
     img->lisp_data = Fcons (Qcount,
-			    Fcons (make_number (count),
-				   img->lisp_data));
+                            Fcons (make_number (count),
+                                   img->lisp_data));
 
   fn_TIFFClose (tiff);
   if (!rc)
@@ -7066,13 +7066,13 @@ tiff_load (struct frame *f, struct image *img)
       uint32 *row = buf + y * width;
 
       for (x = 0; x < width; ++x)
-	{
-	  uint32 abgr = row[x];
-	  int r = TIFFGetR (abgr) << 8;
-	  int g = TIFFGetG (abgr) << 8;
-	  int b = TIFFGetB (abgr) << 8;
-	  XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));
-	}
+        {
+          uint32 abgr = row[x];
+          int r = TIFFGetR (abgr) << 8;
+          int g = TIFFGetG (abgr) << 8;
+          int b = TIFFGetB (abgr) << 8;
+          XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));
+        }
     }
 
 #ifdef COLOR_TABLE_SUPPORT
@@ -7113,7 +7113,7 @@ tiff_load (struct frame *f, struct image *img)
 
 \f
 /***********************************************************************
-				 GIF
+                                 GIF
  ***********************************************************************/
 
 #if defined (HAVE_GIF) || defined (HAVE_NS)
@@ -7344,10 +7344,10 @@ gif_load (struct frame *f, struct image *img)
     {
       file = x_find_image_file (specified_file);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", specified_file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot find image file `%s'", specified_file, Qnil);
+          return 0;
+        }
 #ifdef WINDOWSNT
       file = ansi_encode_filename (file);
 #endif
@@ -7356,27 +7356,27 @@ gif_load (struct frame *f, struct image *img)
 #if GIFLIB_MAJOR < 5
       gif = fn_DGifOpenFileName (SSDATA (file));
       if (gif == NULL)
-	{
-	  image_error ("Cannot open `%s'", file, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot open `%s'", file, Qnil);
+          return 0;
+        }
 #else
       gif = fn_DGifOpenFileName (SSDATA (file), &gif_err);
       if (gif == NULL)
-	{
-	  image_error ("Cannot open `%s': %s",
-		       file, build_string (fn_GifErrorString (gif_err)));
-	  return 0;
-	}
+        {
+          image_error ("Cannot open `%s': %s",
+                       file, build_string (fn_GifErrorString (gif_err)));
+          return 0;
+        }
 #endif
     }
   else
     {
       if (!STRINGP (specified_data))
-	{
-	  image_error ("Invalid image data `%s'", specified_data, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Invalid image data `%s'", specified_data, Qnil);
+          return 0;
+        }
 
       /* Read from memory! */
       current_gif_memory_src = &memsrc;
@@ -7387,18 +7387,18 @@ gif_load (struct frame *f, struct image *img)
 #if GIFLIB_MAJOR < 5
       gif = fn_DGifOpen (&memsrc, gif_read_from_memory);
       if (!gif)
-	{
-	  image_error ("Cannot open memory source `%s'", img->spec, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot open memory source `%s'", img->spec, Qnil);
+          return 0;
+        }
 #else
       gif = fn_DGifOpen (&memsrc, gif_read_from_memory, &gif_err);
       if (!gif)
-	{
-	  image_error ("Cannot open memory source `%s': %s",
-		       img->spec, build_string (fn_GifErrorString (gif_err)));
-	  return 0;
-	}
+        {
+          image_error ("Cannot open memory source `%s': %s",
+                       img->spec, build_string (fn_GifErrorString (gif_err)));
+          return 0;
+        }
 #endif
     }
 
@@ -7425,10 +7425,10 @@ gif_load (struct frame *f, struct image *img)
     idx = INTEGERP (image_number) ? XFASTINT (image_number) : 0;
     if (idx < 0 || idx >= gif->ImageCount)
       {
-	image_error ("Invalid image number `%s' in image `%s'",
-		     image_number, img->spec);
-	fn_DGifCloseFile (gif);
-	return 0;
+        image_error ("Invalid image number `%s' in image `%s'",
+                     image_number, img->spec);
+        fn_DGifCloseFile (gif);
+        return 0;
       }
   }
 
@@ -7459,13 +7459,13 @@ gif_load (struct frame *f, struct image *img)
       int subimg_top = subimage->ImageDesc.Top;
       int subimg_left = subimage->ImageDesc.Left;
       if (! (0 <= subimg_width && 0 <= subimg_height
-	     && 0 <= subimg_top && subimg_top <= height - subimg_height
-	     && 0 <= subimg_left && subimg_left <= width - subimg_width))
-	{
-	  image_error ("Subimage does not fit in image", Qnil, Qnil);
-	  fn_DGifCloseFile (gif);
-	  return 0;
-	}
+             && 0 <= subimg_top && subimg_top <= height - subimg_height
+             && 0 <= subimg_left && subimg_left <= width - subimg_width))
+        {
+          image_error ("Subimage does not fit in image", Qnil, Qnil);
+          fn_DGifCloseFile (gif);
+          return 0;
+        }
     }
 
   /* Create the X image and pixmap.  */
@@ -7490,9 +7490,9 @@ gif_load (struct frame *f, struct image *img)
   for (y = img->corners[TOP_CORNER]; y < img->corners[BOT_CORNER]; ++y)
     {
       for (x = 0; x < img->corners[LEFT_CORNER]; ++x)
-	XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
+        XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
       for (x = img->corners[RIGHT_CORNER]; x < width; ++x)
-	XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
+        XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
     }
 
   /* Read the GIF image into the X image.   */
@@ -7505,11 +7505,11 @@ gif_load (struct frame *f, struct image *img)
   init_color_table ();
   if (STRINGP (specified_bg))
     bgcolor = x_alloc_image_color (f, img, specified_bg,
-				   FRAME_BACKGROUND_PIXEL (f));
+                                   FRAME_BACKGROUND_PIXEL (f));
   for (j = 0; j <= idx; ++j)
     {
       /* We use a local variable `raster' here because RasterBits is a
-	 char *, which invites problems with bytes >= 0x80.  */
+         char *, which invites problems with bytes >= 0x80.  */
       struct SavedImage *subimage = gif->SavedImages + j;
       unsigned char *raster = (unsigned char *) subimage->RasterBits;
       int transparency_color_index = -1;
@@ -7520,87 +7520,87 @@ gif_load (struct frame *f, struct image *img)
       int subimg_left = subimage->ImageDesc.Left;
 
       /* Find the Graphic Control Extension block for this sub-image.
-	 Extract the disposal method and transparency color.  */
+         Extract the disposal method and transparency color.  */
       for (i = 0; i < subimage->ExtensionBlockCount; i++)
-	{
-	  ExtensionBlock *extblock = subimage->ExtensionBlocks + i;
-
-	  if ((extblock->Function == GIF_LOCAL_DESCRIPTOR_EXTENSION)
-	      && extblock->ByteCount == 4
-	      && extblock->Bytes[0] & 1)
-	    {
-	      /* From gif89a spec: 1 = "keep in place", 2 = "restore
-		 to background".  Treat any other value like 2.  */
-	      disposal = (extblock->Bytes[0] >> 2) & 7;
-	      transparency_color_index = (unsigned char) extblock->Bytes[3];
-	      break;
-	    }
-	}
+        {
+          ExtensionBlock *extblock = subimage->ExtensionBlocks + i;
+
+          if ((extblock->Function == GIF_LOCAL_DESCRIPTOR_EXTENSION)
+              && extblock->ByteCount == 4
+              && extblock->Bytes[0] & 1)
+            {
+              /* From gif89a spec: 1 = "keep in place", 2 = "restore
+                 to background".  Treat any other value like 2.  */
+              disposal = (extblock->Bytes[0] >> 2) & 7;
+              transparency_color_index = (unsigned char) extblock->Bytes[3];
+              break;
+            }
+        }
 
       /* We can't "keep in place" the first subimage.  */
       if (j == 0)
-	disposal = 2;
+        disposal = 2;
 
       /* For disposal == 0, the spec says "No disposal specified. The
-	 decoder is not required to take any action."  In practice, it
-	 seems we need to treat this like "keep in place", see e.g.
-	 http://upload.wikimedia.org/wikipedia/commons/3/37/Clock.gif */
+         decoder is not required to take any action."  In practice, it
+         seems we need to treat this like "keep in place", see e.g.
+         http://upload.wikimedia.org/wikipedia/commons/3/37/Clock.gif */
       if (disposal == 0)
-	disposal = 1;
+        disposal = 1;
 
       /* Allocate subimage colors.  */
       memset (pixel_colors, 0, sizeof pixel_colors);
       gif_color_map = subimage->ImageDesc.ColorMap;
       if (!gif_color_map)
-	gif_color_map = gif->SColorMap;
+        gif_color_map = gif->SColorMap;
 
       if (gif_color_map)
-	for (i = 0; i < gif_color_map->ColorCount; ++i)
-	  {
-	    if (transparency_color_index == i)
-	      pixel_colors[i] = STRINGP (specified_bg)
-		? bgcolor : FRAME_BACKGROUND_PIXEL (f);
-	    else
-	      {
-		int r = gif_color_map->Colors[i].Red << 8;
-		int g = gif_color_map->Colors[i].Green << 8;
-		int b = gif_color_map->Colors[i].Blue << 8;
-		pixel_colors[i] = lookup_rgb_color (f, r, g, b);
-	      }
-	  }
+        for (i = 0; i < gif_color_map->ColorCount; ++i)
+          {
+            if (transparency_color_index == i)
+              pixel_colors[i] = STRINGP (specified_bg)
+                ? bgcolor : FRAME_BACKGROUND_PIXEL (f);
+            else
+              {
+                int r = gif_color_map->Colors[i].Red << 8;
+                int g = gif_color_map->Colors[i].Green << 8;
+                int b = gif_color_map->Colors[i].Blue << 8;
+                pixel_colors[i] = lookup_rgb_color (f, r, g, b);
+              }
+          }
 
       /* Apply the pixel values.  */
       if (GIFLIB_MAJOR < 5 && gif->SavedImages[j].ImageDesc.Interlace)
-	{
-	  int row, pass;
-
-	  for (y = 0, row = interlace_start[0], pass = 0;
-	       y < subimg_height;
-	       y++, row += interlace_increment[pass])
-	    {
-	      while (subimg_height <= row)
-		row = interlace_start[++pass];
-
-	      for (x = 0; x < subimg_width; x++)
-		{
-		  int c = raster[y * subimg_width + x];
-		  if (transparency_color_index != c || disposal != 1)
-		    XPutPixel (ximg, x + subimg_left, row + subimg_top,
-			       pixel_colors[c]);
-		}
-	    }
-	}
+        {
+          int row, pass;
+
+          for (y = 0, row = interlace_start[0], pass = 0;
+               y < subimg_height;
+               y++, row += interlace_increment[pass])
+            {
+              while (subimg_height <= row)
+                row = interlace_start[++pass];
+
+              for (x = 0; x < subimg_width; x++)
+                {
+                  int c = raster[y * subimg_width + x];
+                  if (transparency_color_index != c || disposal != 1)
+                    XPutPixel (ximg, x + subimg_left, row + subimg_top,
+                               pixel_colors[c]);
+                }
+            }
+        }
       else
-	{
-	  for (y = 0; y < subimg_height; ++y)
-	    for (x = 0; x < subimg_width; ++x)
-	      {
-		int c = raster[y * subimg_width + x];
-		if (transparency_color_index != c || disposal != 1)
-		  XPutPixel (ximg, x + subimg_left, y + subimg_top,
-			     pixel_colors[c]);
-	      }
-	}
+        {
+          for (y = 0; y < subimg_height; ++y)
+            for (x = 0; x < subimg_width; ++x)
+              {
+                int c = raster[y * subimg_width + x];
+                if (transparency_color_index != c || disposal != 1)
+                  XPutPixel (ximg, x + subimg_left, y + subimg_top,
+                             pixel_colors[c]);
+              }
+        }
     }
 
 #ifdef COLOR_TABLE_SUPPORT
@@ -7616,31 +7616,31 @@ gif_load (struct frame *f, struct image *img)
       int delay = 0;
       ExtensionBlock *ext = gif->SavedImages[idx].ExtensionBlocks;
       for (i = 0; i < gif->SavedImages[idx].ExtensionBlockCount; i++, ext++)
-	/* Append (... FUNCTION "BYTES") */
-	{
-	  img->lisp_data
-	    = Fcons (make_number (ext->Function),
-		     Fcons (make_unibyte_string (ext->Bytes, ext->ByteCount),
-			    img->lisp_data));
-	  if (ext->Function == GIF_LOCAL_DESCRIPTOR_EXTENSION
-	      && ext->ByteCount == 4)
-	    {
-	      delay = ext->Bytes[2] << CHAR_BIT;
-	      delay |= ext->Bytes[1];
-	    }
-	}
+        /* Append (... FUNCTION "BYTES") */
+        {
+          img->lisp_data
+            = Fcons (make_number (ext->Function),
+                     Fcons (make_unibyte_string (ext->Bytes, ext->ByteCount),
+                            img->lisp_data));
+          if (ext->Function == GIF_LOCAL_DESCRIPTOR_EXTENSION
+              && ext->ByteCount == 4)
+            {
+              delay = ext->Bytes[2] << CHAR_BIT;
+              delay |= ext->Bytes[1];
+            }
+        }
       img->lisp_data = list2 (Qextension_data, img->lisp_data);
       if (delay)
-	img->lisp_data
-	  = Fcons (Qdelay,
-		   Fcons (make_float (delay / 100.0),
-			  img->lisp_data));
+        img->lisp_data
+          = Fcons (Qdelay,
+                   Fcons (make_float (delay / 100.0),
+                          img->lisp_data));
     }
 
   if (gif->ImageCount > 1)
     img->lisp_data = Fcons (Qcount,
-			    Fcons (make_number (gif->ImageCount),
-				   img->lisp_data));
+                            Fcons (make_number (gif->ImageCount),
+                                   img->lisp_data));
 
   fn_DGifCloseFile (gif);
 
@@ -7663,7 +7663,7 @@ gif_load (struct frame *f, struct image *img)
 {
   return ns_load_image (f, img,
                         image_spec_value (img->spec, QCfile, NULL),
-			image_spec_value (img->spec, QCdata, NULL));
+                        image_spec_value (img->spec, QCdata, NULL));
 }
 #endif /* HAVE_NS */
 
@@ -7673,7 +7673,7 @@ gif_load (struct frame *f, struct image *img)
 #ifdef HAVE_IMAGEMAGICK
 
 /***********************************************************************
-				 ImageMagick
+                                 ImageMagick
 ***********************************************************************/
 
 /* Scale an image size by returning SIZE / DIVISOR * MULTIPLIER,
@@ -7687,7 +7687,7 @@ scale_image_size (int size, size_t divisor, size_t multiplier)
       double s = size;
       double scaled = s * multiplier / divisor + 0.5;
       if (scaled < INT_MAX)
-	return scaled;
+        return scaled;
     }
   return INT_MAX;
 }
@@ -7697,8 +7697,8 @@ scale_image_size (int size, size_t divisor, size_t multiplier)
    *D_WIDTH x *D_HEIGHT.  Store -1 x -1 if the native size is OK.  */
 static void
 compute_image_size (size_t width, size_t height,
-		    Lisp_Object spec,
-		    int *d_width, int *d_height)
+                    Lisp_Object spec,
+                    int *d_width, int *d_height)
 {
   Lisp_Object value;
   int desired_width, desired_height;
@@ -7716,41 +7716,41 @@ compute_image_size (size_t width, size_t height,
     {
       value = image_spec_value (spec, QCmax_width, NULL);
       if (NATNUMP (value))
-	{
-	  int max_width = min (XFASTINT (value), INT_MAX);
-	  if (max_width < width)
-	    {
-	      /* The image is wider than :max-width. */
-	      desired_width = max_width;
-	      if (desired_height == -1)
-		{
-		  desired_height = scale_image_size (desired_width,
-						     width, height);
-		  value = image_spec_value (spec, QCmax_height, NULL);
-		  if (NATNUMP (value))
-		    {
-		      int max_height = min (XFASTINT (value), INT_MAX);
-		      if (max_height < desired_height)
-			{
-			  desired_height = max_height;
-			  desired_width = scale_image_size (desired_height,
-							    height, width);
-			}
-		    }
-		}
-	    }
-	}
+        {
+          int max_width = min (XFASTINT (value), INT_MAX);
+          if (max_width < width)
+            {
+              /* The image is wider than :max-width. */
+              desired_width = max_width;
+              if (desired_height == -1)
+                {
+                  desired_height = scale_image_size (desired_width,
+                                                     width, height);
+                  value = image_spec_value (spec, QCmax_height, NULL);
+                  if (NATNUMP (value))
+                    {
+                      int max_height = min (XFASTINT (value), INT_MAX);
+                      if (max_height < desired_height)
+                        {
+                          desired_height = max_height;
+                          desired_width = scale_image_size (desired_height,
+                                                            height, width);
+                        }
+                    }
+                }
+            }
+        }
     }
 
   if (desired_height == -1)
     {
       value = image_spec_value (spec, QCmax_height, NULL);
       if (NATNUMP (value))
-	{
-	  int max_height = min (XFASTINT (value), INT_MAX);
-	  if (max_height < height)
-	    desired_height = max_height;
-	}
+        {
+          int max_height = min (XFASTINT (value), INT_MAX);
+          if (max_height < height)
+            desired_height = max_height;
+        }
     }
 
   if (desired_width != -1 && desired_height == -1)
@@ -7815,7 +7815,7 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] =
     {":max-height",	IMAGE_INTEGER_VALUE,			0},
     {":max-width",	IMAGE_INTEGER_VALUE,			0},
     {":format",		IMAGE_SYMBOL_VALUE,			0},
-    {":rotation",	IMAGE_NUMBER_VALUE,     		0},
+    {":rotation",	IMAGE_NUMBER_VALUE,                     0},
     {":crop",		IMAGE_DONT_CHECK_VALUE_TYPE,		0}
   };
 
@@ -7874,7 +7874,7 @@ imagemagick_image_p (Lisp_Object object)
 #include <magick/version.h>
 #if 0x653 <= MagickLibVersion && MagickLibVersion <= 0x665
 extern WandExport void PixelGetMagickColor (const PixelWand *,
-					    MagickPixelPacket *);
+                                            MagickPixelPacket *);
 #endif
 
 /* Log ImageMagick error message.
@@ -7888,8 +7888,8 @@ imagemagick_error (MagickWand *wand)
 
   description = MagickGetException (wand, &severity);
   image_error ("ImageMagick error: %s",
-	       build_string (description),
-	       Qnil);
+               build_string (description),
+               Qnil);
   MagickRelinquishMemory (description);
 }
 
@@ -7945,7 +7945,7 @@ imagemagick_create_cache (char *signature)
 {
   struct animation_cache *cache
     = xmalloc (offsetof (struct animation_cache, signature)
-	       + strlen (signature) + 1);
+               + strlen (signature) + 1);
   cache->wand = 0;
   cache->index = 0;
   cache->next = 0;
@@ -7959,20 +7959,20 @@ imagemagick_prune_animation_cache (void)
 {
   struct animation_cache **pcache = &animation_cache;
   struct timespec old = timespec_sub (current_timespec (),
-				      make_timespec (60, 0));
+                                      make_timespec (60, 0));
 
   while (*pcache)
     {
       struct animation_cache *cache = *pcache;
       if (timespec_cmp (old, cache->update_time) <= 0)
-	pcache = &cache->next;
+        pcache = &cache->next;
       else
-	{
-	  if (cache->wand)
-	    DestroyMagickWand (cache->wand);
-	  *pcache = cache->next;
-	  xfree (cache);
-	}
+        {
+          if (cache->wand)
+            DestroyMagickWand (cache->wand);
+          *pcache = cache->next;
+          xfree (cache);
+        }
     }
 }
 
@@ -7989,12 +7989,12 @@ imagemagick_get_animation_cache (MagickWand *wand)
     {
       cache = *pcache;
       if (! cache)
-	{
+        {
           *pcache = cache = imagemagick_create_cache (signature);
           break;
         }
       if (strcmp (signature, cache->signature) == 0)
-	break;
+        break;
       pcache = &cache->next;
     }
 
@@ -8017,7 +8017,7 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
     {
       composite_wand = MagickGetImage (super_wand);
       if (cache->wand)
-	DestroyMagickWand (cache->wand);
+        DestroyMagickWand (cache->wand);
     }
   else
     composite_wand = cache->wand;
@@ -8040,71 +8040,71 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
       sub_wand = MagickGetImage (super_wand);
 
       MagickGetImagePage (sub_wand, &source_width, &source_height,
-			  &source_left, &source_top);
+                          &source_left, &source_top);
 
       /* This flag says how to handle transparent pixels.  */
       dispose = MagickGetImageDispose (sub_wand);
 
       source_iterator = NewPixelIterator (sub_wand);
       if (! source_iterator)
-	{
-	  DestroyMagickWand (composite_wand);
-	  DestroyMagickWand (sub_wand);
-	  cache->wand = NULL;
-	  image_error ("Imagemagick pixel iterator creation failed",
-		       Qnil, Qnil);
-	  return NULL;
-	}
+        {
+          DestroyMagickWand (composite_wand);
+          DestroyMagickWand (sub_wand);
+          cache->wand = NULL;
+          image_error ("Imagemagick pixel iterator creation failed",
+                       Qnil, Qnil);
+          return NULL;
+        }
 
       dest_iterator = NewPixelIterator (composite_wand);
       if (! dest_iterator)
-	{
-	  DestroyMagickWand (composite_wand);
-	  DestroyMagickWand (sub_wand);
-	  DestroyPixelIterator (source_iterator);
-	  cache->wand = NULL;
-	  image_error ("Imagemagick pixel iterator creation failed",
-		       Qnil, Qnil);
-	  return NULL;
-	}
+        {
+          DestroyMagickWand (composite_wand);
+          DestroyMagickWand (sub_wand);
+          DestroyPixelIterator (source_iterator);
+          cache->wand = NULL;
+          image_error ("Imagemagick pixel iterator creation failed",
+                       Qnil, Qnil);
+          return NULL;
+        }
 
       /* The sub-image may not start at origin, so move the destination
-	 iterator to where the sub-image should start. */
+         iterator to where the sub-image should start. */
       if (source_top > 0)
-	{
-	  PixelSetIteratorRow (dest_iterator, source_top);
-	  lines = source_top;
-	}
+        {
+          PixelSetIteratorRow (dest_iterator, source_top);
+          lines = source_top;
+        }
 
       while ((source = PixelGetNextIteratorRow (source_iterator, &source_width))
-	     != NULL)
-	{
-	  ptrdiff_t x;
-
-	  /* Sanity check.  This shouldn't happen, but apparently
-	     does in some pictures.  */
-	  if (++lines >= dest_height)
-	    break;
-
-	  dest = PixelGetNextIteratorRow (dest_iterator, &dest_width);
-	  for (x = 0; x < source_width; x++)
-	    {
-	      /* Sanity check.  This shouldn't happen, but apparently
-		 also does in some pictures.  */
-	      if (x + source_left > dest_width - 1)
-		break;
-	      /* Normally we only copy over non-transparent pixels,
-		 but if the disposal method is "Background", then we
-		 copy over all pixels.  */
-	      if (dispose == BackgroundDispose ||
-		  PixelGetAlpha (source[x]))
-		{
-		  PixelGetMagickColor (source[x], &pixel);
-		  PixelSetMagickColor (dest[x + source_left], &pixel);
-		}
-	    }
-	  PixelSyncIterator (dest_iterator);
-	}
+             != NULL)
+        {
+          ptrdiff_t x;
+
+          /* Sanity check.  This shouldn't happen, but apparently
+             does in some pictures.  */
+          if (++lines >= dest_height)
+            break;
+
+          dest = PixelGetNextIteratorRow (dest_iterator, &dest_width);
+          for (x = 0; x < source_width; x++)
+            {
+              /* Sanity check.  This shouldn't happen, but apparently
+                 also does in some pictures.  */
+              if (x + source_left > dest_width - 1)
+                break;
+              /* Normally we only copy over non-transparent pixels,
+                 but if the disposal method is "Background", then we
+                 copy over all pixels.  */
+              if (dispose == BackgroundDispose ||
+                  PixelGetAlpha (source[x]))
+                {
+                  PixelGetMagickColor (source[x], &pixel);
+                  PixelSetMagickColor (dest[x + source_left], &pixel);
+                }
+            }
+          PixelSyncIterator (dest_iterator);
+        }
 
       DestroyPixelIterator (source_iterator);
       DestroyPixelIterator (dest_iterator);
@@ -8134,8 +8134,8 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
 
 static bool
 imagemagick_load_image (struct frame *f, struct image *img,
-			unsigned char *contents, unsigned int size,
-			char *filename)
+                        unsigned char *contents, unsigned int size,
+                        char *filename)
 {
   size_t width, height;
   MagickBooleanType status;
@@ -8185,7 +8185,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
   if (ino < 0 || ino >= MagickGetNumberImages (image_wand))
     {
       image_error ("Invalid image number `%s' in image `%s'",
-		   image, img->spec);
+                   image, img->spec);
       DestroyMagickWand (image_wand);
       return 0;
     }
@@ -8203,9 +8203,9 @@ imagemagick_load_image (struct frame *f, struct image *img,
       MagickWand *super_wand = image_wand;
       image_wand = imagemagick_compute_animated_image (super_wand, ino);
       if (! image_wand)
-	image_wand = super_wand;
+        image_wand = super_wand;
       else
-	DestroyMagickWand (super_wand);
+        DestroyMagickWand (super_wand);
     }
 
   /* Retrieve the frame's background color, for use later.  */
@@ -8215,7 +8215,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
 
     specified_bg = image_spec_value (img->spec, QCbackground, NULL);
     if (!STRINGP (specified_bg)
-	|| !x_defined_color (f, SSDATA (specified_bg), &bgcolor, 0))
+        || !x_defined_color (f, SSDATA (specified_bg), &bgcolor, 0))
       x_query_frame_background_color (f, &bgcolor);
 
     bg_wand = NewPixelWand ();
@@ -8225,18 +8225,18 @@ imagemagick_load_image (struct frame *f, struct image *img,
   }
 
   compute_image_size (MagickGetImageWidth (image_wand),
-		      MagickGetImageHeight (image_wand),
-		      img->spec, &desired_width, &desired_height);
+                      MagickGetImageHeight (image_wand),
+                      img->spec, &desired_width, &desired_height);
 
   if (desired_width != -1 && desired_height != -1)
     {
       status = MagickScaleImage (image_wand, desired_width, desired_height);
       if (status == MagickFalse)
-	{
-	  image_error ("Imagemagick scale failed", Qnil, Qnil);
-	  imagemagick_error (image_wand);
-	  goto imagemagick_error;
-	}
+        {
+          image_error ("Imagemagick scale failed", Qnil, Qnil);
+          imagemagick_error (image_wand);
+          goto imagemagick_error;
+        }
     }
 
   /* crop behaves similar to image slicing in Emacs but is more memory
@@ -8253,21 +8253,21 @@ imagemagick_load_image (struct frame *f, struct image *img,
       size_t crop_width = XINT (XCAR (crop));
       crop = XCDR (crop);
       if (CONSP (crop) && TYPE_RANGED_INTEGERP (size_t, XCAR (crop)))
-	{
-	  size_t crop_height = XINT (XCAR (crop));
-	  crop = XCDR (crop);
-	  if (CONSP (crop) && TYPE_RANGED_INTEGERP (ssize_t, XCAR (crop)))
-	    {
-	      ssize_t crop_x = XINT (XCAR (crop));
-	      crop = XCDR (crop);
-	      if (CONSP (crop) && TYPE_RANGED_INTEGERP (ssize_t, XCAR (crop)))
-		{
-		  ssize_t crop_y = XINT (XCAR (crop));
-		  MagickCropImage (image_wand, crop_width, crop_height,
-				   crop_x, crop_y);
-		}
-	    }
-	}
+        {
+          size_t crop_height = XINT (XCAR (crop));
+          crop = XCDR (crop);
+          if (CONSP (crop) && TYPE_RANGED_INTEGERP (ssize_t, XCAR (crop)))
+            {
+              ssize_t crop_x = XINT (XCAR (crop));
+              crop = XCDR (crop);
+              if (CONSP (crop) && TYPE_RANGED_INTEGERP (ssize_t, XCAR (crop)))
+                {
+                  ssize_t crop_y = XINT (XCAR (crop));
+                  MagickCropImage (image_wand, crop_width, crop_height,
+                                   crop_x, crop_y);
+                }
+            }
+        }
     }
 
   /* Furthermore :rotation. we need background color and angle for
@@ -8284,7 +8284,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
       if (status == MagickFalse)
         {
           image_error ("Imagemagick image rotate failed", Qnil, Qnil);
-	  imagemagick_error (image_wand);
+          imagemagick_error (image_wand);
           goto imagemagick_error;
         }
     }
@@ -8311,7 +8311,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
   width = MagickGetImageWidth (image_wand);
 
   if (! (width <= INT_MAX && height <= INT_MAX
-	 && check_image_size (f, width, height)))
+         && check_image_size (f, width, height)))
     {
       image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
       goto imagemagick_error;
@@ -8332,14 +8332,14 @@ imagemagick_load_image (struct frame *f, struct image *img,
       const char *exportdepth = imagedepth <= 8 ? "I" : "BGRP"; /*"RGBP";*/
       /* Try to create a x pixmap to hold the imagemagick pixmap.  */
       if (!image_create_x_image_and_pixmap (f, img, width, height, imagedepth,
-					    &ximg, 0))
-	{
+                                            &ximg, 0))
+        {
 #ifdef COLOR_TABLE_SUPPORT
-	  free_color_table ();
+          free_color_table ();
 #endif
-	  image_error ("Imagemagick X bitmap allocation failure", Qnil, Qnil);
-	  goto imagemagick_error;
-	}
+          image_error ("Imagemagick X bitmap allocation failure", Qnil, Qnil);
+          goto imagemagick_error;
+        }
 
       /* Oddly, the below code doesn't seem to work:*/
       /* switch(ximg->bitmap_unit){ */
@@ -8362,7 +8362,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
       */
       pixelwidth = CharPixel; /*??? TODO figure out*/
       MagickExportImagePixels (image_wand, 0, 0, width, height,
-			       exportdepth, pixelwidth, ximg->data);
+                               exportdepth, pixelwidth, ximg->data);
     }
   else
 #endif /* HAVE_MAGICKEXPORTIMAGEPIXELS */
@@ -8371,10 +8371,10 @@ imagemagick_load_image (struct frame *f, struct image *img,
 
       /* Try to create a x pixmap to hold the imagemagick pixmap.  */
       if (!image_create_x_image_and_pixmap (f, img, width, height, 0,
-					    &ximg, 0))
+                                            &ximg, 0))
         {
 #ifdef COLOR_TABLE_SUPPORT
-	  free_color_table ();
+          free_color_table ();
 #endif
           image_error ("Imagemagick X bitmap allocation failure", Qnil, Qnil);
           goto imagemagick_error;
@@ -8389,9 +8389,9 @@ imagemagick_load_image (struct frame *f, struct image *img,
       if (! iterator)
         {
 #ifdef COLOR_TABLE_SUPPORT
-	  free_color_table ();
+          free_color_table ();
 #endif
-	  x_destroy_x_image (ximg);
+          x_destroy_x_image (ximg);
           image_error ("Imagemagick pixel iterator creation failed",
                        Qnil, Qnil);
           goto imagemagick_error;
@@ -8466,10 +8466,10 @@ imagemagick_load (struct frame *f, struct image *img)
 
       file = x_find_image_file (file_name);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", file_name, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot find image file `%s'", file_name, Qnil);
+          return 0;
+        }
 #ifdef WINDOWSNT
       file = ansi_encode_filename (file);
 #endif
@@ -8483,10 +8483,10 @@ imagemagick_load (struct frame *f, struct image *img)
 
       data = image_spec_value (img->spec, QCdata, NULL);
       if (!STRINGP (data))
-	{
-	  image_error ("Invalid image data `%s'", data, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Invalid image data `%s'", data, Qnil);
+          return 0;
+        }
       success_p = imagemagick_load_image (f, img, SDATA (data),
                                           SBYTES (data), NULL);
     }
@@ -8533,7 +8533,7 @@ and `imagemagick-types-inhibit'.  */)
 
 \f
 /***********************************************************************
-				 SVG
+                                 SVG
  ***********************************************************************/
 
 #if defined (HAVE_RSVG)
@@ -8544,7 +8544,7 @@ static bool svg_image_p (Lisp_Object object);
 static bool svg_load (struct frame *f, struct image *img);
 
 static bool svg_load_image (struct frame *, struct image *,
-			    unsigned char *, ptrdiff_t);
+                            unsigned char *, ptrdiff_t);
 
 /* The symbol `svg' identifying images of this type. */
 
@@ -8699,13 +8699,13 @@ init_svg_functions (void)
 #define fn_rsvg_handle_close		rsvg_handle_close
 #define fn_rsvg_handle_get_pixbuf	rsvg_handle_get_pixbuf
 
-#define fn_gdk_pixbuf_get_width		  gdk_pixbuf_get_width
-#define fn_gdk_pixbuf_get_height	  gdk_pixbuf_get_height
-#define fn_gdk_pixbuf_get_pixels	  gdk_pixbuf_get_pixels
-#define fn_gdk_pixbuf_get_rowstride	  gdk_pixbuf_get_rowstride
-#define fn_gdk_pixbuf_get_colorspace	  gdk_pixbuf_get_colorspace
-#define fn_gdk_pixbuf_get_n_channels	  gdk_pixbuf_get_n_channels
-#define fn_gdk_pixbuf_get_has_alpha	  gdk_pixbuf_get_has_alpha
+#define fn_gdk_pixbuf_get_width           gdk_pixbuf_get_width
+#define fn_gdk_pixbuf_get_height          gdk_pixbuf_get_height
+#define fn_gdk_pixbuf_get_pixels          gdk_pixbuf_get_pixels
+#define fn_gdk_pixbuf_get_rowstride       gdk_pixbuf_get_rowstride
+#define fn_gdk_pixbuf_get_colorspace      gdk_pixbuf_get_colorspace
+#define fn_gdk_pixbuf_get_n_channels      gdk_pixbuf_get_n_channels
+#define fn_gdk_pixbuf_get_has_alpha       gdk_pixbuf_get_has_alpha
 #define fn_gdk_pixbuf_get_bits_per_sample gdk_pixbuf_get_bits_per_sample
 
 #if ! GLIB_CHECK_VERSION (2, 36, 0)
@@ -8734,18 +8734,18 @@ svg_load (struct frame *f, struct image *img)
 
       file = x_find_image_file (file_name);
       if (!STRINGP (file))
-	{
-	  image_error ("Cannot find image file `%s'", file_name, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Cannot find image file `%s'", file_name, Qnil);
+          return 0;
+        }
 
       /* Read the entire file into memory.  */
       contents = slurp_file (SSDATA (file), &size);
       if (contents == NULL)
-	{
-	  image_error ("Error loading SVG image `%s'", img->spec, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Error loading SVG image `%s'", img->spec, Qnil);
+          return 0;
+        }
       /* If the file was slurped into memory properly, parse it.  */
       success_p = svg_load_image (f, img, contents, size);
       xfree (contents);
@@ -8758,10 +8758,10 @@ svg_load (struct frame *f, struct image *img)
 
       data = image_spec_value (img->spec, QCdata, NULL);
       if (!STRINGP (data))
-	{
-	  image_error ("Invalid image data `%s'", data, Qnil);
-	  return 0;
-	}
+        {
+          image_error ("Invalid image data `%s'", data, Qnil);
+          return 0;
+        }
       success_p = svg_load_image (f, img, SDATA (data), SBYTES (data));
     }
 
@@ -8777,9 +8777,9 @@ svg_load (struct frame *f, struct image *img)
    Returns true when successful.  */
 static bool
 svg_load_image (struct frame *f,         /* Pointer to emacs frame structure.  */
-		struct image *img,       /* Pointer to emacs image structure.  */
-		unsigned char *contents, /* String containing the SVG XML data to be parsed.  */
-		ptrdiff_t size)          /* Size of data in bytes.  */
+                struct image *img,       /* Pointer to emacs image structure.  */
+                unsigned char *contents, /* String containing the SVG XML data to be parsed.  */
+                ptrdiff_t size)          /* Size of data in bytes.  */
 {
   RsvgHandle *rsvg_handle;
   RsvgDimensionData dimension_data;
@@ -8868,26 +8868,26 @@ svg_load_image (struct frame *f,         /* Pointer to emacs frame structure.  *
   for (y = 0; y < height; ++y)
     {
       for (x = 0; x < width; ++x)
-	{
-	  int red;
-	  int green;
-	  int blue;
-	  int opacity;
-
-	  red     = *pixels++;
-	  green   = *pixels++;
-	  blue    = *pixels++;
-	  opacity = *pixels++;
-
-	  red   = ((red * opacity)
-		   + (background.red * ((1 << 8) - opacity)));
-	  green = ((green * opacity)
-		   + (background.green * ((1 << 8) - opacity)));
-	  blue  = ((blue * opacity)
-		   + (background.blue * ((1 << 8) - opacity)));
-
-	  XPutPixel (ximg, x, y, lookup_rgb_color (f, red, green, blue));
-	}
+        {
+          int red;
+          int green;
+          int blue;
+          int opacity;
+
+          red     = *pixels++;
+          green   = *pixels++;
+          blue    = *pixels++;
+          opacity = *pixels++;
+
+          red   = ((red * opacity)
+                   + (background.red * ((1 << 8) - opacity)));
+          green = ((green * opacity)
+                   + (background.green * ((1 << 8) - opacity)));
+          blue  = ((blue * opacity)
+                   + (background.blue * ((1 << 8) - opacity)));
+
+          XPutPixel (ximg, x, y, lookup_rgb_color (f, red, green, blue));
+        }
 
       pixels += rowstride - 4 * width;
     }
@@ -8927,7 +8927,7 @@ svg_load_image (struct frame *f,         /* Pointer to emacs frame structure.  *
 
 \f
 /***********************************************************************
-				Ghostscript
+                                Ghostscript
  ***********************************************************************/
 
 #ifdef HAVE_X_WINDOWS
@@ -9026,18 +9026,18 @@ gs_image_p (Lisp_Object object)
   if (CONSP (tem))
     {
       for (i = 0; i < 4; ++i, tem = XCDR (tem))
-	if (!CONSP (tem) || !INTEGERP (XCAR (tem)))
-	  return 0;
+        if (!CONSP (tem) || !INTEGERP (XCAR (tem)))
+          return 0;
       if (!NILP (tem))
-	return 0;
+        return 0;
     }
   else if (VECTORP (tem))
     {
       if (ASIZE (tem) != 4)
-	return 0;
+        return 0;
       for (i = 0; i < 4; ++i)
-	if (!INTEGERP (AREF (tem, i)))
-	  return 0;
+        if (!INTEGERP (AREF (tem, i)))
+          return 0;
     }
   else
     return 0;
@@ -9071,7 +9071,7 @@ gs_load (struct frame *f, struct image *img)
   in_height *= FRAME_RES_Y (f);
 
   if (! (in_width <= INT_MAX && in_height <= INT_MAX
-	 && check_image_size (f, in_width, in_height)))
+         && check_image_size (f, in_width, in_height)))
     {
       image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
       return 0;
@@ -9087,8 +9087,8 @@ gs_load (struct frame *f, struct image *img)
       /* Only W32 version did BLOCK_INPUT here.  ++kfs */
       block_input ();
       img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-				   img->width, img->height,
-				   DefaultDepthOfScreen (FRAME_X_SCREEN (f)));
+                                   img->width, img->height,
+                                   DefaultDepthOfScreen (FRAME_X_SCREEN (f)));
       unblock_input ();
     }
 
@@ -9118,10 +9118,10 @@ gs_load (struct frame *f, struct image *img)
     loader = intern ("gs-load-image");
 
   img->lisp_data = call6 (loader, frame, img->spec,
-			  make_number (img->width),
-			  make_number (img->height),
-			  window_and_pixmap_id,
-			  pixel_colors);
+                          make_number (img->width),
+                          make_number (img->height),
+                          window_and_pixmap_id,
+                          pixel_colors);
   return PROCESSP (img->lisp_data);
 }
 
@@ -9169,44 +9169,44 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
 
       /* Try to get an XImage for img->pixmep.  */
       ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap,
-			0, 0, img->width, img->height, ~0, ZPixmap);
+                        0, 0, img->width, img->height, ~0, ZPixmap);
       if (ximg)
-	{
-	  int x, y;
-
-	  /* Initialize the color table.  */
-	  init_color_table ();
-
-	  /* For each pixel of the image, look its color up in the
-	     color table.  After having done so, the color table will
-	     contain an entry for each color used by the image.  */
-	  for (y = 0; y < img->height; ++y)
-	    for (x = 0; x < img->width; ++x)
-	      {
-		unsigned long pixel = XGetPixel (ximg, x, y);
-		lookup_pixel_color (f, pixel);
-	      }
-
-	  /* Record colors in the image.  Free color table and XImage.  */
+        {
+          int x, y;
+
+          /* Initialize the color table.  */
+          init_color_table ();
+
+          /* For each pixel of the image, look its color up in the
+             color table.  After having done so, the color table will
+             contain an entry for each color used by the image.  */
+          for (y = 0; y < img->height; ++y)
+            for (x = 0; x < img->width; ++x)
+              {
+                unsigned long pixel = XGetPixel (ximg, x, y);
+                lookup_pixel_color (f, pixel);
+              }
+
+          /* Record colors in the image.  Free color table and XImage.  */
 #ifdef COLOR_TABLE_SUPPORT
-	  img->colors = colors_in_color_table (&img->ncolors);
-	  free_color_table ();
+          img->colors = colors_in_color_table (&img->ncolors);
+          free_color_table ();
 #endif
-	  XDestroyImage (ximg);
+          XDestroyImage (ximg);
 
 #if 0 /* This doesn't seem to be the case.  If we free the colors
-	 here, we get a BadAccess later in x_clear_image when
-	 freeing the colors.  */
-	  /* We have allocated colors once, but Ghostscript has also
-	     allocated colors on behalf of us.  So, to get the
-	     reference counts right, free them once.  */
-	  if (img->ncolors)
-	    x_free_colors (f, img->colors, img->ncolors);
+         here, we get a BadAccess later in x_clear_image when
+         freeing the colors.  */
+          /* We have allocated colors once, but Ghostscript has also
+             allocated colors on behalf of us.  So, to get the
+             reference counts right, free them once.  */
+          if (img->ncolors)
+            x_free_colors (f, img->colors, img->ncolors);
 #endif
-	}
+        }
       else
-	image_error ("Cannot get X image of `%s'; colors will not be freed",
-		     img->spec, Qnil);
+        image_error ("Cannot get X image of `%s'; colors will not be freed",
+                     img->spec, Qnil);
 
       unblock_input ();
     }
@@ -9223,7 +9223,7 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
 
 \f
 /***********************************************************************
-				Tests
+                                Tests
  ***********************************************************************/
 
 #ifdef GLYPH_DEBUG
@@ -9252,7 +9252,7 @@ DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "")
 
 
 /***********************************************************************
-			    Initialization
+                            Initialization
  ***********************************************************************/
 
 DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 1, 1, 0,
@@ -9401,29 +9401,29 @@ non-numeric, there is no explicit limit on the size of images.  */);
   DEFSYM (Qlibpng_version, "libpng-version");
   Fset (Qlibpng_version,
 #if HAVE_PNG
-	make_number (PNG_LIBPNG_VER)
+        make_number (PNG_LIBPNG_VER)
 #else
-	make_number (-1)
+        make_number (-1)
 #endif
-	);
+        );
   DEFSYM (Qlibgif_version, "libgif-version");
   Fset (Qlibgif_version,
 #ifdef HAVE_GIF
-	make_number (GIFLIB_MAJOR * 10000
-		     + GIFLIB_MINOR * 100
-		     + GIFLIB_RELEASE)
+        make_number (GIFLIB_MAJOR * 10000
+                     + GIFLIB_MINOR * 100
+                     + GIFLIB_RELEASE)
 #else
-	make_number (-1)
+        make_number (-1)
 #endif
         );
   DEFSYM (Qlibjpeg_version, "libjpeg-version");
   Fset (Qlibjpeg_version,
 #if HAVE_JPEG
-	make_number (JPEG_LIB_VERSION)
+        make_number (JPEG_LIB_VERSION)
 #else
-	make_number (-1)
+        make_number (-1)
 #endif
-	);
+        );
 #endif
 
   DEFSYM (Qpbm, "pbm");
-- 
1.9.0


[-- Attachment #3: 0002-remove-visibility-of-some-variables.patch --]
[-- Type: application/octet-stream, Size: 1404 bytes --]

From 23c8e58ebc66453b9bf5edc357028ce8b7cb15c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolas=20L=C3=A9veill=C3=A9?= <nicolas@uucidl.com>
Date: Sat, 17 May 2014 13:41:51 +0200
Subject: [PATCH 2/3] remove visibility of some variables

---
 src/image.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/image.c b/src/image.c
index 7ae417c..b2c74c9 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8143,8 +8143,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
   int x, y;
   MagickWand *image_wand;
   PixelIterator *iterator;
-  PixelWand **pixels, *bg_wand = NULL;
-  MagickPixelPacket  pixel;
+  PixelWand *bg_wand = NULL;
   Lisp_Object image;
   Lisp_Object value;
   Lisp_Object crop;
@@ -8400,11 +8399,12 @@ imagemagick_load_image (struct frame *f, struct image *img,
       image_height = MagickGetImageHeight (image_wand);
       for (y = 0; y < image_height; y++)
         {
-          pixels = PixelGetNextIteratorRow (iterator, &width);
+          PixelWand **pixels = PixelGetNextIteratorRow (iterator, &width);
           if (! pixels)
             break;
           for (x = 0; x < (long) width; x++)
             {
+              MagickPixelPacket pixel;
               PixelGetMagickColor (pixels[x], &pixel);
               XPutPixel (ximg, x, y,
                          lookup_rgb_color (f,
-- 
1.9.0


[-- Attachment #4: 0003-properly-scale-pixels-from-pixelmagick.patch --]
[-- Type: application/octet-stream, Size: 1153 bytes --]

From 4d4470c72fe509aac53cec681b4e90a7856c1273 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolas=20L=C3=A9veill=C3=A9?= <nicolas@uucidl.com>
Date: Sat, 17 May 2014 15:14:17 +0200
Subject: [PATCH 3/3] properly scale pixels from pixelmagick

---
 src/image.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/image.c b/src/image.c
index b2c74c9..b7be66c 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8408,9 +8408,9 @@ imagemagick_load_image (struct frame *f, struct image *img,
               PixelGetMagickColor (pixels[x], &pixel);
               XPutPixel (ximg, x, y,
                          lookup_rgb_color (f,
-                                           pixel.red,
-                                           pixel.green,
-                                           pixel.blue));
+                                           65535.0*QuantumScale*pixel.red,
+                                           65535.0*QuantumScale*pixel.green,
+                                           65535.0*QuantumScale*pixel.blue));
             }
         }
       DestroyPixelIterator (iterator);
-- 
1.9.0


[-- Attachment #5: Type: text/plain, Size: 4 bytes --]






^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#17519: [PATCH] take into account QuantumScale when reading imagemagick images
  2014-05-17 13:25 bug#17519: [PATCH] take into account QuantumScale when reading imagemagick images Nicolas Léveillé
@ 2014-05-19 20:04 ` Paul Eggert
  2014-05-20  7:37   ` Nicolas Léveillé
  2014-05-21 19:31   ` Nicolas Léveillé
  0 siblings, 2 replies; 6+ messages in thread
From: Paul Eggert @ 2014-05-19 20:04 UTC (permalink / raw)
  To: Nicolas Léveillé; +Cc: 17519

[-- Attachment #1: Type: text/plain, Size: 229 bytes --]

Thanks for reporting this. Does the attached simpler patch fix the 
problem for you?  Dividing by QuantumRange instead of multiplying by 
QuantumScale avoids potential double-rounding problems in future 
versions of ImageMagick.

[-- Attachment #2: imagemagick.patch --]
[-- Type: text/x-patch, Size: 919 bytes --]

=== modified file 'src/image.c'
--- src/image.c	2014-05-04 18:51:32 +0000
+++ src/image.c	2014-05-19 19:47:21 +0000
@@ -8388,6 +8388,7 @@
 #endif /* HAVE_MAGICKEXPORTIMAGEPIXELS */
     {
       size_t image_height;
+      double color_scale = 65535.0 / QuantumRange;
 
       /* Try to create a x pixmap to hold the imagemagick pixmap.  */
       if (!image_create_x_image_and_pixmap (f, img, width, height, 0,
@@ -8428,9 +8429,9 @@
               PixelGetMagickColor (pixels[x], &pixel);
               XPutPixel (ximg, x, y,
                          lookup_rgb_color (f,
-                                           pixel.red,
-                                           pixel.green,
-                                           pixel.blue));
+					   color_scale * pixel.red,
+					   color_scale * pixel.green,
+					   color_scale * pixel.blue));
             }
         }
       DestroyPixelIterator (iterator);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#17519: [PATCH] take into account QuantumScale when reading imagemagick images
  2014-05-19 20:04 ` Paul Eggert
@ 2014-05-20  7:37   ` Nicolas Léveillé
  2014-05-20  8:07     ` Paul Eggert
  2014-05-21 19:31   ` Nicolas Léveillé
  1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Léveillé @ 2014-05-20  7:37 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 17519

I'll come back to you once I'll have tested your patch.

Do you object with the other cleanups or is it poor form in this project to clean up code while fixing a bug? (Not sure what the philosophy in this project is, I tend to alway opportunistically do a little clean up (in separate commits/patches) when I fix bugs as a form of low intensity maintenance work)

Cheers,
Nicolas

On 2014-05-19, at 22:04 , Paul Eggert <eggert@cs.ucla.edu> wrote:

> Thanks for reporting this. Does the attached simpler patch fix the problem for you?  Dividing by QuantumRange instead of multiplying by QuantumScale avoids potential double-rounding problems in future versions of ImageMagick.
> <imagemagick.patch>






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#17519: [PATCH] take into account QuantumScale when reading imagemagick images
  2014-05-20  7:37   ` Nicolas Léveillé
@ 2014-05-20  8:07     ` Paul Eggert
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Eggert @ 2014-05-20  8:07 UTC (permalink / raw)
  To: Nicolas Léveillé; +Cc: 17519

Nicolas Léveillé wrote:
> Do you object with the other cleanups or is it poor form in this project to clean up code while fixing a bug?

Neither, but we're in a code freeze now (bug fixes only) and I looked 
only at the bug fix.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#17519: [PATCH] take into account QuantumScale when reading imagemagick images
  2014-05-19 20:04 ` Paul Eggert
  2014-05-20  7:37   ` Nicolas Léveillé
@ 2014-05-21 19:31   ` Nicolas Léveillé
  2014-05-21 19:54     ` Paul Eggert
  1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Léveillé @ 2014-05-21 19:31 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 17519

I tested this patch on OSX Mavericks, with ImageMagick compiled with a quantum of Q32, and it works

Nicolas

On 2014-05-19, at 22:04 , Paul Eggert <eggert@cs.ucla.edu> wrote:

> Thanks for reporting this. Does the attached simpler patch fix the problem for you?  Dividing by QuantumRange instead of multiplying by QuantumScale avoids potential double-rounding problems in future versions of ImageMagick.
> <imagemagick.patch>






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#17519: [PATCH] take into account QuantumScale when reading imagemagick images
  2014-05-21 19:31   ` Nicolas Léveillé
@ 2014-05-21 19:54     ` Paul Eggert
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Eggert @ 2014-05-21 19:54 UTC (permalink / raw)
  To: Nicolas Léveillé; +Cc: 17519-done

Thanks for testing it.  I installed the fix as trunk bzr 117134 and am 
marking the bug as fixed.

Unfortunately this is an old bug and currently the emacs-24 branch is 
accepting fixes only for regressions, so this bug fix is not scheduled 
for the very next release, but it should appear in the release after 
that.  If it's more urgent to fix it for some reason, please let us know.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-05-21 19:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-17 13:25 bug#17519: [PATCH] take into account QuantumScale when reading imagemagick images Nicolas Léveillé
2014-05-19 20:04 ` Paul Eggert
2014-05-20  7:37   ` Nicolas Léveillé
2014-05-20  8:07     ` Paul Eggert
2014-05-21 19:31   ` Nicolas Léveillé
2014-05-21 19:54     ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).