]> code.delx.au - gnu-emacs/blobdiff - src/macfns.c
(syms_of_macfns) <Vx_bitmap_file_path>: Doc fix.
[gnu-emacs] / src / macfns.c
index a4235d7c6531e4d977f960dfabbb9c17401b09c1..38afebe0c91ca5185296a593cb87928e091197f6 100644 (file)
@@ -72,6 +72,7 @@ static unsigned char gray_bits[] = {
    precompiled header Carbon.h.  */
 #undef max
 #undef min
+#undef init_process
 #include <Carbon/Carbon.h>
 #undef Z
 #define Z (current_buffer->text->z)
@@ -85,7 +86,9 @@ static unsigned char gray_bits[] = {
 #define min(a, b) ((a) < (b) ? (a) : (b))
 #undef max
 #define max(a, b) ((a) > (b) ? (a) : (b))
-#else /* not MAC_OSX */ 
+#undef init_process
+#define init_process emacs_init_process
+#else /* not MAC_OSX */
 #include <Windows.h>
 #include <Gestalt.h>
 #include <TextUtils.h>
@@ -96,16 +99,6 @@ extern double atof ();
 extern int w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state);
 extern int quit_char;*/
 
-/* A definition of XColor for non-X frames.  */
-#ifndef HAVE_X_WINDOWS
-typedef struct {
-  unsigned long pixel;
-  unsigned short red, green, blue;
-  char flags;
-  char pad;
-} XColor;
-#endif
-
 extern char *lispy_function_keys[];
 
 /* The gray bitmap `bitmaps/gray'.  This is done because macterm.c uses
@@ -191,15 +184,13 @@ Lisp_Object Vx_pixel_size_width_font_regexp;
       (insert (format "\");\n  staticpro (&%s);\n" (car symbol-list)))
       (setq symbol-list (cdr symbol-list)))))
 
-  */        
+  */
 
 /*&&& symbols declared here &&&*/
 Lisp_Object Qauto_raise;
 Lisp_Object Qauto_lower;
-Lisp_Object Qbar;
 Lisp_Object Qborder_color;
 Lisp_Object Qborder_width;
-Lisp_Object Qbox;
 Lisp_Object Qcursor_color;
 Lisp_Object Qcursor_type;
 Lisp_Object Qgeometry;
@@ -247,6 +238,8 @@ extern Lisp_Object Qtool_bar_lines;
 
 extern Lisp_Object Vwindow_system_version;
 
+extern Lisp_Object Qbox;
+
 Lisp_Object Qface_set_after_frame_default;
 
 extern int mac_initialized;
@@ -298,7 +291,7 @@ check_mac ()
 
 /* Nonzero if we can use mouse menus.
    You should not call this unless HAVE_MENUS is defined.  */
-  
+
 int
 have_menus_p ()
 {
@@ -323,7 +316,7 @@ check_x_frame (frame)
   return f;
 }
 
-/* Let the user specify an display with a frame.
+/* Let the user specify a display with a frame.
    nil stands for the selected frame--or, if that is not a mac frame,
    the first display on the list.  */
 
@@ -340,7 +333,7 @@ check_x_display_info (frame)
   if (NILP (frame))
     {
       struct frame *sf = XFRAME (selected_frame);
-      
+
       if (FRAME_MAC_P (sf) && FRAME_LIVE_P (sf))
        return FRAME_MAC_DISPLAY_INFO (sf);
       else
@@ -360,7 +353,7 @@ check_x_display_info (frame)
     }
 }
 \f
-/* Return the Emacs frame-object corresponding to an mac window.
+/* Return the Emacs frame-object corresponding to a mac window.
    It could be the frame's main window or an icon window.  */
 
 /* This function can be called during GC, so use GC_xxx type test macros.  */
@@ -491,7 +484,7 @@ x_create_bitmap_from_data (f, bits, width, height)
   /* MAC_TODO: for now fail if width is not mod 16 (toolbox requires it) */
 
   id = x_allocate_bitmap_record (f);
-  
+
   if (width % 16 != 0)
     return -1;
 
@@ -531,7 +524,7 @@ x_create_bitmap_from_file (f, file)
     {
       if (dpyinfo->bitmaps[id].refcount
          && dpyinfo->bitmaps[id].file
-         && !strcmp (dpyinfo->bitmaps[id].file, (char *) XSTRING (file)->data))
+         && !strcmp (dpyinfo->bitmaps[id].file, (char *) SDATA (file)))
        {
          ++dpyinfo->bitmaps[id].refcount;
          return id + 1;
@@ -539,7 +532,7 @@ x_create_bitmap_from_file (f, file)
     }
 
   /* Search bitmap-file-path for the file, if appropriate.  */
-  fd = openp (Vx_bitmap_file_path, file, "", &found, 0);
+  fd = openp (Vx_bitmap_file_path, file, "", &found, Qnil);
   if (fd < 0)
     return -1;
   /* LoadLibraryEx won't handle special files handled by Emacs handler.  */
@@ -547,14 +540,14 @@ x_create_bitmap_from_file (f, file)
     return -1;
   emacs_close (fd);
 
-  filename = (char *) XSTRING (found)->data;
+  filename = (char *) SDATA (found);
 
   hinst = LoadLibraryEx (filename, NULL, LOAD_LIBRARY_AS_DATAFILE);
 
   if (hinst == NULL)
       return -1;
 
-  
+
   result = XReadBitmapFile (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
                            filename, &width, &height, &bitmap, &xhot, &yhot);
   if (result != BitmapSuccess)
@@ -563,11 +556,11 @@ x_create_bitmap_from_file (f, file)
   id = x_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
   dpyinfo->bitmaps[id - 1].refcount = 1;
-  dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (XSTRING (file)->size + 1);
+  dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SCHARS (file) + 1);
   dpyinfo->bitmaps[id - 1].depth = 1;
   dpyinfo->bitmaps[id - 1].height = height;
   dpyinfo->bitmaps[id - 1].width = width;
-  strcpy (dpyinfo->bitmaps[id - 1].file, XSTRING (file)->data);
+  strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file));
 
   return id;
 #endif  /* MAC_TODO */
@@ -777,7 +770,7 @@ x_set_frame_parameters (f, alist)
   /* Process foreground_color and background_color before anything else.
      They are independent of other properties, but other properties (e.g.,
      cursor_color) are dependent upon them.  */
-  for (p = 0; p < i; p++) 
+  for (p = 0; p < i; p++)
     {
       Lisp_Object prop, val;
 
@@ -979,7 +972,7 @@ x_real_positions (f, xptr, yptr)
 #ifdef TARGET_API_MAC_CARBON
   {
     Rect r;
-    
+
     GetWindowPortBounds (f->output_data.mac->mWP, &r);
     SetPt (&pt, r.left, r.top);
   }
@@ -991,7 +984,7 @@ x_real_positions (f, xptr, yptr)
   GetPort (&oldport);
   LocalToGlobal (&pt);
   SetPort (oldport);
-  
+
   *xptr = pt.h;
   *yptr = pt.v;
 }
@@ -1041,13 +1034,13 @@ x_report_frame_params (f, alistptr)
 }
 \f
 /* The default colors for the Mac color map */
-typedef struct colormap_t 
+typedef struct colormap_t
 {
   unsigned long color;
   char *name;
 } colormap_t;
 
-colormap_t mac_color_map[] = 
+colormap_t mac_color_map[] =
 {
   { RGB_TO_ULONG(255, 250, 250), "snow" },
   { RGB_TO_ULONG(248, 248, 255), "ghost white" },
@@ -1402,7 +1395,7 @@ colormap_t mac_color_map[] =
   { RGB_TO_ULONG(155, 205, 155), "DarkSeaGreen3" },
   { RGB_TO_ULONG(105, 139, 105), "DarkSeaGreen4" },
   { RGB_TO_ULONG(84 , 255, 159), "SeaGreen1" },
-  { RGB_TO_ULONG(78 , 238, 148), "SeaGreen2" },   
+  { RGB_TO_ULONG(78 , 238, 148), "SeaGreen2" },
   { RGB_TO_ULONG(67 , 205, 128), "SeaGreen3" },
   { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen4" },
   { RGB_TO_ULONG(154, 255, 154), "PaleGreen1" },
@@ -1811,7 +1804,7 @@ mac_color_map_lookup (colorname)
   int i;
 
   BLOCK_INPUT;
-  
+
   for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++)
     if (stricmp (colorname, mac_color_map[i].name) == 0)
       {
@@ -1824,12 +1817,12 @@ mac_color_map_lookup (colorname)
   return ret;
 }
 
-Lisp_Object 
+Lisp_Object
 x_to_mac_color (colorname)
      char * colorname;
 {
   register Lisp_Object tail, ret = Qnil;
-  
+
   BLOCK_INPUT;
 
   if (colorname[0] == '#')
@@ -1838,7 +1831,7 @@ x_to_mac_color (colorname)
       char *color;
       int size;
       color = colorname + 1;
-      
+
       size = strlen(color);
       if (size == 3 || size == 6 || size == 9 || size == 12)
        {
@@ -1847,7 +1840,7 @@ x_to_mac_color (colorname)
          pos = 0;
          size /= 3;
          colorval = 0;
-         
+
          for (i = 0; i < 3; i++)
            {
              char *end;
@@ -1903,7 +1896,7 @@ x_to_mac_color (colorname)
        {
          char *end;
          unsigned long value;
-         
+
          /* The check for 'x' in the following conditional takes into
             account the fact that strtol allows a "0x" in front of
             our numbers, and we don't.  */
@@ -1966,7 +1959,7 @@ x_to_mac_color (colorname)
          if (value < 0.0 || value > 1.0)
            break;
          val = (unsigned long)(0x100 * value);
-         /* We used 0x100 instead of 0xFF to give an continuous
+         /* We used 0x100 instead of 0xFF to give a continuous
              range between 0.0 and 1.0 inclusive.  The next statement
              fixes the 1.0 case.  */
          if (val == 0x100)
@@ -1987,7 +1980,7 @@ x_to_mac_color (colorname)
     }
 
   ret = mac_color_map_lookup (colorname);
-  
+
   UNBLOCK_INPUT;
   return ret;
 }
@@ -2026,7 +2019,7 @@ mac_defined_color (f, color, color_def, alloc)
 
   tem = x_to_mac_color (color);
 
-  if (!NILP (tem)) 
+  if (!NILP (tem))
     {
       if (f)
         {
@@ -2043,7 +2036,7 @@ mac_defined_color (f, color, color_def, alloc)
 
       return 1;
     }
-  else 
+  else
     {
       return 0;
     }
@@ -2064,9 +2057,9 @@ x_decode_color (f, arg, def)
 
   CHECK_STRING (arg);
 
-  if (strcmp (XSTRING (arg)->data, "black") == 0)
+  if (strcmp (SDATA (arg), "black") == 0)
     return BLACK_PIX_DEFAULT (f);
-  else if (strcmp (XSTRING (arg)->data, "white") == 0)
+  else if (strcmp (SDATA (arg), "white") == 0)
     return WHITE_PIX_DEFAULT (f);
 
 #if 0
@@ -2075,7 +2068,7 @@ x_decode_color (f, arg, def)
     return def;
 #endif
 
-  if (mac_defined_color (f, XSTRING (arg)->data, &cdef, 1))
+  if (mac_defined_color (f, SDATA (arg), &cdef, 1))
     return cdef.pixel;
 
   /* defined_color failed; return an ultimate default.  */
@@ -2217,7 +2210,7 @@ x_set_mouse_color (f, arg, oldval)
   else
     hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch);
   x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s");
-  
+
   x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s");
   if (!EQ (Qnil, Vx_mode_pointer_shape))
     {
@@ -2300,7 +2293,7 @@ x_set_mouse_color (f, arg, oldval)
       && f->output_data.w32->modeline_cursor != 0)
     XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor);
   f->output_data.w32->modeline_cursor = mode_cursor;
-  
+
   if (cross_cursor != f->output_data.w32->cross_cursor
       && f->output_data.w32->cross_cursor != 0)
     XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->cross_cursor);
@@ -2326,7 +2319,7 @@ x_set_cursor_color (f, arg, oldval)
   else
     fore_pixel = FRAME_BACKGROUND_PIXEL (f);
   f->output_data.mac->cursor_pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
-  
+
   /* Make sure that the cursor color differs from the background color.  */
   if (f->output_data.mac->cursor_pixel == FRAME_BACKGROUND_PIXEL (f))
     {
@@ -2352,7 +2345,7 @@ x_set_cursor_color (f, arg, oldval)
 
 /* Set the border-color of frame F to pixel value PIX.
    Note that this does not fully take effect if done before
-   F has an window.  */
+   F has a window.  */
 void
 x_set_border_pixel (f, pix)
      struct frame *f;
@@ -2386,50 +2379,12 @@ x_set_border_color (f, arg, oldval)
   update_face_from_frame_parameter (f, Qborder_color, arg);
 }
 
-/* Value is the internal representation of the specified cursor type
-   ARG.  If type is BAR_CURSOR, return in *WIDTH the specified width
-   of the bar cursor.  */
-
-enum text_cursor_kinds
-x_specified_cursor_type (arg, width)
-     Lisp_Object arg;
-     int *width;
-{
-  enum text_cursor_kinds type;
-  
-  if (EQ (arg, Qbar))
-    {
-      type = BAR_CURSOR;
-      *width = 2;
-    }
-  else if (CONSP (arg)
-          && EQ (XCAR (arg), Qbar)
-          && INTEGERP (XCDR (arg))
-          && XINT (XCDR (arg)) >= 0)
-    {
-      type = BAR_CURSOR;
-      *width = XINT (XCDR (arg));
-    }
-  else if (NILP (arg))
-    type = NO_CURSOR;
-  else
-    /* Treat anything unknown as "box cursor".
-       It was bad to signal an error; people have trouble fixing
-       .Xdefaults with Emacs, when it has something bad in it.  */
-    type = FILLED_BOX_CURSOR;
-
-  return type;
-}
-
 void
 x_set_cursor_type (f, arg, oldval)
      FRAME_PTR f;
      Lisp_Object arg, oldval;
 {
-  int width;
-  
-  FRAME_DESIRED_CURSOR (f) = x_specified_cursor_type (arg, &width);
-  f->output_data.mac->cursor_width = width;
+  set_frame_cursor_types (f, arg);
 
   /* Make sure the cursor gets redrawn.  This is overkill, but how
      often do people change cursor types?  */
@@ -2447,7 +2402,7 @@ x_set_icon_type (f, arg, oldval)
   if (NILP (arg) && NILP (oldval))
     return;
 
-  if (STRINGP (arg) && STRINGP (oldval) 
+  if (STRINGP (arg) && STRINGP (oldval)
       && EQ (Fstring_equal (oldval, arg), Qt))
     return;
 
@@ -2506,11 +2461,11 @@ x_set_icon_name (f, arg, oldval)
   BLOCK_INPUT;
 
   result = x_text_icon (f,
-                       (char *) XSTRING ((!NILP (f->icon_name)
-                                          ? f->icon_name
-                                          : !NILP (f->title)
-                                          ? f->title
-                                          : f->name))->data);
+                       (char *) SDATA ((!NILP (f->icon_name)
+                                        ? f->icon_name
+                                        : !NILP (f->title)
+                                        ? f->title
+                                        : f->name)));
 
   if (result)
     {
@@ -2552,12 +2507,12 @@ x_set_font (f, arg, oldval)
 
   BLOCK_INPUT;
   result = (STRINGP (fontset_name)
-            ? x_new_fontset (f, XSTRING (fontset_name)->data)
-            : x_new_font (f, XSTRING (arg)->data));
+            ? x_new_fontset (f, SDATA (fontset_name))
+            : x_new_font (f, SDATA (arg)));
   UNBLOCK_INPUT;
-  
+
   if (EQ (result, Qnil))
-    error ("Font `%s' is not defined", XSTRING (arg)->data);
+    error ("Font `%s' is not defined", SDATA (arg));
   else if (EQ (result, Qt))
     error ("The characters of the given font have varying widths");
   else if (STRINGP (result))
@@ -2813,7 +2768,7 @@ x_set_name (f, name, explicit)
      Lisp_Object name;
      int explicit;
 {
-  /* Make sure that requests from lisp code override requests from 
+  /* Make sure that requests from lisp code override requests from
      Emacs redisplay code.  */
   if (explicit)
     {
@@ -2833,7 +2788,7 @@ x_set_name (f, name, explicit)
       /* Check for no change needed in this very common case
         before we do any consing.  */
       if (!strcmp (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name,
-                  XSTRING (f->name)->data))
+                  SDATA (f->name)))
        return;
       name = build_string (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name);
     }
@@ -2861,12 +2816,12 @@ x_set_name (f, name, explicit)
 #endif
 
       BLOCK_INPUT;
-      
+
       {
        Str255 windowTitle;
-       if (strlen (XSTRING (name)->data) < 255)
+       if (strlen (SDATA (name)) < 255)
          {
-           strcpy (windowTitle, XSTRING (name)->data);
+           strcpy (windowTitle, SDATA (name));
            c2pstr (windowTitle);
            SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
          }
@@ -2938,9 +2893,9 @@ x_set_title (f, name, old_name)
 
       {
        Str255 windowTitle;
-       if (strlen (XSTRING (name)->data) < 255)
+       if (strlen (SDATA (name)) < 255)
          {
-           strcpy (windowTitle, XSTRING (name)->data);
+           strcpy (windowTitle, SDATA (name));
            c2pstr (windowTitle);
            SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
          }
@@ -2988,7 +2943,7 @@ x_set_vertical_scroll_bars (f, arg, oldval)
        = (NILP (arg)
           ? vertical_scroll_bar_none
           : EQ (Qright, arg)
-            ? vertical_scroll_bar_right 
+            ? vertical_scroll_bar_right
             : vertical_scroll_bar_left);
 
       /* We set this parameter before creating the window for the
@@ -3020,7 +2975,7 @@ x_set_scroll_bar_width (f, arg, oldval)
       /* Make the actual width at least 14 pixels and a multiple of a
         character width.  */
       FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
-      
+
       /* Use all of that space (aside from required margins) for the
         scroll bar.  */
       FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
@@ -3043,10 +2998,10 @@ x_set_scroll_bar_width (f, arg, oldval)
     }
   change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);
   XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
-  XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0; 
+  XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
 }
 \f
-/* Subroutines of creating an frame.  */
+/* Subroutines of creating a frame.  */
 
 /* Make sure that Vx_resource_name is set to a reasonable value.
    Fix it up, or set it to `emacs' if it is too hopeless.  */
@@ -3064,10 +3019,10 @@ validate_x_resource_name ()
 
   if (STRINGP (Vx_resource_name))
     {
-      unsigned char *p = XSTRING (Vx_resource_name)->data;
+      unsigned char *p = SDATA (Vx_resource_name);
       int i;
 
-      len = STRING_BYTES (XSTRING (Vx_resource_name));
+      len = SBYTES (Vx_resource_name);
 
       /* Only letters, digits, - and _ are valid in resource names.
         Count the valid characters and count the invalid ones.  */
@@ -3106,12 +3061,12 @@ validate_x_resource_name ()
 
   for (i = 0; i < len; i++)
     {
-      int c = XSTRING (new)->data[i];
+      int c = SREF (new, i);
       if (! ((c >= 'a' && c <= 'z')
             || (c >= 'A' && c <= 'Z')
             || (c >= '0' && c <= '9')
             || c == '-' || c == '_'))
-       XSTRING (new)->data[i] = '_';
+       SSET (new, i, '_');
     }
 }
 
@@ -3150,37 +3105,37 @@ and the class is `Emacs.CLASS.SUBCLASS'.  */)
 
   /* Allocate space for the components, the dots which separate them,
      and the final '\0'.  Make them big enough for the worst case.  */
-  name_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_name))
+  name_key = (char *) alloca (SBYTES (Vx_resource_name)
                              + (STRINGP (component)
-                                ? STRING_BYTES (XSTRING (component)) : 0)
-                             + STRING_BYTES (XSTRING (attribute))
+                                ? SBYTES (component) : 0)
+                             + SBYTES (attribute)
                              + 3);
 
   class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
-                              + STRING_BYTES (XSTRING (class))
+                              + SBYTES (class)
                               + (STRINGP (subclass)
-                                 ? STRING_BYTES (XSTRING (subclass)) : 0)
+                                 ? SBYTES (subclass) : 0)
                               + 3);
 
   /* Start with emacs.FRAMENAME for the name (the specific one)
      and with `Emacs' for the class key (the general one).  */
-  strcpy (name_key, XSTRING (Vx_resource_name)->data);
+  strcpy (name_key, SDATA (Vx_resource_name));
   strcpy (class_key, EMACS_CLASS);
 
   strcat (class_key, ".");
-  strcat (class_key, XSTRING (class)->data);
+  strcat (class_key, SDATA (class));
 
   if (!NILP (component))
     {
       strcat (class_key, ".");
-      strcat (class_key, XSTRING (subclass)->data);
+      strcat (class_key, SDATA (subclass));
 
       strcat (name_key, ".");
-      strcat (name_key, XSTRING (component)->data);
+      strcat (name_key, SDATA (component));
     }
 
   strcat (name_key, ".");
-  strcat (name_key, XSTRING (attribute)->data);
+  strcat (name_key, SDATA (attribute));
 
   value = x_get_string_resource (Qnil,
                                 name_key, class_key);
@@ -3203,13 +3158,13 @@ x_get_resource_string (attribute, class)
 
   /* Allocate space for the components, the dots which separate them,
      and the final '\0'.  */
-  name_key = (char *) alloca (STRING_BYTES (XSTRING (Vinvocation_name))
+  name_key = (char *) alloca (SBYTES (Vinvocation_name)
                              + strlen (attribute) + 2);
   class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
                               + strlen (class) + 2);
 
   sprintf (name_key, "%s.%s",
-          XSTRING (Vinvocation_name)->data,
+          SDATA (Vinvocation_name),
           attribute);
   sprintf (class_key, "%s.%s", EMACS_CLASS, class);
 
@@ -3266,17 +3221,17 @@ mac_get_arg (alist, param, attribute, class, type)
          switch (type)
            {
            case RES_TYPE_NUMBER:
-             return make_number (atoi (XSTRING (tem)->data));
+             return make_number (atoi (SDATA (tem)));
 
            case RES_TYPE_FLOAT:
-             return make_float (atof (XSTRING (tem)->data));
+             return make_float (atof (SDATA (tem)));
 
            case RES_TYPE_BOOLEAN:
              tem = Fdowncase (tem);
-             if (!strcmp (XSTRING (tem)->data, "on")
-                 || !strcmp (XSTRING (tem)->data, "true"))
+             if (!strcmp (SDATA (tem), "on")
+                 || !strcmp (SDATA (tem), "true"))
                return Qt;
-             else 
+             else
                return Qnil;
 
            case RES_TYPE_STRING:
@@ -3288,11 +3243,11 @@ mac_get_arg (alist, param, attribute, class, type)
              {
                Lisp_Object lower;
                lower = Fdowncase (tem);
-               if (!strcmp (XSTRING (lower)->data, "on")
-                   || !strcmp (XSTRING (lower)->data, "true"))
+               if (!strcmp (SDATA (lower), "on")
+                   || !strcmp (SDATA (lower), "true"))
                  return Qt;
-               else if (!strcmp (XSTRING (lower)->data, "off")
-                     || !strcmp (XSTRING (lower)->data, "false"))
+               else if (!strcmp (SDATA (lower), "off")
+                     || !strcmp (SDATA (lower), "false"))
                  return Qnil;
                else
                  return Fintern (tem, Qnil);
@@ -3345,7 +3300,7 @@ x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
  *   It returns a bitmask that indicates which of the four values
  *   were actually found in the string.  For each value found,
  *   the corresponding argument is updated;  for each value
- *   not found, the corresponding argument is left unchanged. 
+ *   not found, the corresponding argument is left unchanged.
  */
 
 static int
@@ -3355,7 +3310,7 @@ read_integer (string, NextString)
 {
   register int Result = 0;
   int Sign = 1;
-  
+
   if (*string == '+')
     string++;
   else if (*string == '-')
@@ -3374,7 +3329,7 @@ read_integer (string, NextString)
     return (-Result);
 }
 
-int 
+int
 XParseGeometry (string, x, y, width, height)
      char *string;
      int *x, *y;
@@ -3385,23 +3340,23 @@ XParseGeometry (string, x, y, width, height)
   unsigned int tempWidth, tempHeight;
   int tempX, tempY;
   char *nextCharacter;
-  
+
   if ((string == NULL) || (*string == '\0')) return (mask);
   if (*string == '=')
     string++;  /* ignore possible '=' at beg of geometry spec */
-  
+
   strind = (char *)string;
-  if (*strind != '+' && *strind != '-' && *strind != 'x') 
+  if (*strind != '+' && *strind != '-' && *strind != 'x')
     {
       tempWidth = read_integer (strind, &nextCharacter);
-      if (strind == nextCharacter) 
+      if (strind == nextCharacter)
        return (0);
       strind = nextCharacter;
       mask |= WidthValue;
     }
-  
-  if (*strind == 'x' || *strind == 'X') 
-    {  
+
+  if (*strind == 'x' || *strind == 'X')
+    {
       strind++;
       tempHeight = read_integer (strind, &nextCharacter);
       if (strind == nextCharacter)
@@ -3409,10 +3364,10 @@ XParseGeometry (string, x, y, width, height)
       strind = nextCharacter;
       mask |= HeightValue;
     }
-  
-  if ((*strind == '+') || (*strind == '-')) 
+
+  if ((*strind == '+') || (*strind == '-'))
     {
-      if (*strind == '-') 
+      if (*strind == '-')
        {
          strind++;
          tempX = -read_integer (strind, &nextCharacter);
@@ -3423,7 +3378,7 @@ XParseGeometry (string, x, y, width, height)
 
        }
       else
-       {       
+       {
          strind++;
          tempX = read_integer (strind, &nextCharacter);
          if (strind == nextCharacter)
@@ -3431,9 +3386,9 @@ XParseGeometry (string, x, y, width, height)
          strind = nextCharacter;
        }
       mask |= XValue;
-      if ((*strind == '+') || (*strind == '-')) 
+      if ((*strind == '+') || (*strind == '-'))
        {
-         if (*strind == '-') 
+         if (*strind == '-')
            {
              strind++;
              tempY = -read_integer (strind, &nextCharacter);
@@ -3454,12 +3409,12 @@ XParseGeometry (string, x, y, width, height)
          mask |= YValue;
        }
     }
-  
+
   /* If strind isn't at the end of the string the it's an invalid
      geometry specification. */
-  
+
   if (*strind != '\0') return (0);
-  
+
   if (mask & XValue)
     *x = tempX;
   if (mask & YValue)
@@ -3487,7 +3442,7 @@ or a list (- N) meaning -N pixels relative to bottom/right corner.  */)
 
   CHECK_STRING (string);
 
-  geometry = XParseGeometry ((char *) XSTRING (string)->data,
+  geometry = XParseGeometry ((char *) SDATA (string),
                             &x, &y, &width, &height);
 
   result = Qnil;
@@ -3673,9 +3628,9 @@ mac_window (f, window_prompting, minibuffer_only)
      for the window manager, so GC relocation won't bother it.
 
      Elsewhere we specify the window name for the window manager.  */
-     
+
   {
-    char *str = (char *) XSTRING (Vx_resource_name)->data;
+    char *str = (char *) SDATA (Vx_resource_name);
     f->namebuf = (char *) xmalloc (strlen (str) + 1);
     strcpy (f->namebuf, str);
   }
@@ -3749,9 +3704,9 @@ x_icon (f, parms)
         ? IconicState
         : NormalState));
 
-  x_text_icon (f, (char *) XSTRING ((!NILP (f->icon_name)
+  x_text_icon (f, (char *) SDATA ((!NILP (f->icon_name)
                                     ? f->icon_name
-                                    : f->name))->data);
+                                    : f->name)));
 #endif
 
   UNBLOCK_INPUT;
@@ -3822,7 +3777,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
   int minibuffer_only = 0;
   long window_prompting = 0;
   int width, height;
-  int count = BINDING_STACK_SIZE ();
+  int count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   Lisp_Object display;
   struct mac_display_info *dpyinfo = NULL;
@@ -3961,9 +3916,9 @@ This function is an internal primitive--use `make-frame' instead.  */)
       {
         tem = Fquery_fontset (font, Qnil);
         if (STRINGP (tem))
-          font = x_new_fontset (f, XSTRING (tem)->data);
+          font = x_new_fontset (f, SDATA (tem));
         else
-          font = x_new_font (f, XSTRING (font)->data);
+          font = x_new_font (f, SDATA (font));
       }
     /* Try out a font which we hope has bold and italic variations.  */
     if (! STRINGP (font))
@@ -3977,7 +3932,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
       error ("Cannot find any usable font");
     UNBLOCK_INPUT;
 
-    x_default_parameter (f, parms, Qfont, font, 
+    x_default_parameter (f, parms, Qfont, font,
                         "font", "Font", RES_TYPE_STRING);
   }
 
@@ -4030,7 +3985,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
      end up in init_iterator with a null face cache, which should not
      happen.  */
   init_frame_faces (f);
-  
+
   x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
                       "menuBar", "MenuBar", RES_TYPE_NUMBER);
   x_default_parameter (f, parms, Qtool_bar_lines, make_number (0),
@@ -4141,11 +4096,11 @@ This function is an internal primitive--use `make-frame' instead.  */)
        ;
     }
   UNGCPRO;
-  
+
   /* Make sure windows on this frame appear in calls to next-window
      and similar functions.  */
   Vwindow_list = Qnil;
-  
+
   return unbind_to (count, frame);
 }
 
@@ -4175,7 +4130,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
 
   CHECK_STRING (color);
 
-  if (mac_defined_color (f, XSTRING (color)->data, &foo, 0))
+  if (mac_defined_color (f, SDATA (color), &foo, 0))
     return Qt;
   else
     return Qnil;
@@ -4191,7 +4146,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
 
   CHECK_STRING (color);
 
-  if (mac_defined_color (f, XSTRING (color)->data, &foo, 0))
+  if (mac_defined_color (f, SDATA (color), &foo, 0))
     {
       Lisp_Object rgb[3];
 
@@ -4290,7 +4245,7 @@ If omitted or nil, that stands for the selected frame's display.  */)
      Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
-  
+
   /* MAC_TODO: check whether this is right */
   return make_number ((unsigned long) (pow (2, dpyinfo->n_cbits)));
 }
@@ -4301,7 +4256,7 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
        doc: /* Returns the maximum request size of the server of display DISPLAY.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display.   */)
+If omitted or nil, that stands for the selected frame's display.  */)
   (display)
      Lisp_Object display;
 {
@@ -4338,7 +4293,7 @@ If omitted or nil, that stands for the selected frame's display.  */)
 
   if (Gestalt (gestaltSystemVersion, &response) != noErr)
     error ("Cannot get Mac OS version");
-  
+
   mac_major_version = (response >> 8) & 0xf;
   mac_minor_version = (response >> 4) & 0xf;
 
@@ -4365,13 +4320,13 @@ If omitted or nil, that stands for the selected frame's display.  */)
   (display)
      Lisp_Object display;
 {
-  /* MAC_TODO: this is an approximation, and only of the main display */  
+  /* MAC_TODO: this is an approximation, and only of the main display */
 
   struct mac_display_info *dpyinfo = check_x_display_info (display);
   short h, v;
-  
+
   ScreenRes (&h, &v);
-  
+
   return make_number ((int) (v / 72.0 * 25.4));
 }
 
@@ -4383,13 +4338,13 @@ If omitted or nil, that stands for the selected frame's display.  */)
   (display)
      Lisp_Object display;
 {
-  /* MAC_TODO: this is an approximation, and only of the main display */  
+  /* MAC_TODO: this is an approximation, and only of the main display */
 
   struct mac_display_info *dpyinfo = check_x_display_info (display);
   short h, v;
-  
+
   ScreenRes (&h, &v);
-  
+
   return make_number ((int) (h / 72.0 * 25.4));
 }
 
@@ -4434,7 +4389,7 @@ If omitted or nil, that stands for the selected frame's display.  */)
     }
 #endif /* 0 */
 
-  error ("Display has an unknown visual class");
+  return (intern ("true-color"));
 }
 
 DEFUN ("x-display-save-under", Fx_display_save_under,
@@ -4512,10 +4467,10 @@ x_display_info_for_name (name)
   validate_x_resource_name ();
 
   dpyinfo = mac_term_init (name, (unsigned char *) 0,
-                          (char *) XSTRING (Vx_resource_name)->data);
+                          (char *) SDATA (Vx_resource_name));
 
   if (dpyinfo == 0)
-    error ("Cannot connect to server %s", XSTRING (name)->data);
+    error ("Cannot connect to server %s", SDATA (name));
 
   mac_in_use = 1;
   XSETFASTINT (Vwindow_system_version, 3);
@@ -4545,7 +4500,7 @@ terminate Emacs if we can't open the connection.  */)
     error ("Not using Mac OS");
 
   if (! NILP (xrm_string))
-    xrm_option = (unsigned char *) XSTRING (xrm_string)->data;
+    xrm_option = (unsigned char *) SDATA (xrm_string);
   else
     xrm_option = (unsigned char *) 0;
 
@@ -4554,15 +4509,15 @@ terminate Emacs if we can't open the connection.  */)
   /* This is what opens the connection and sets x_current_display.
      This also initializes many symbols, such as those used for input.  */
   dpyinfo = mac_term_init (display, xrm_option,
-                            (char *) XSTRING (Vx_resource_name)->data);
+                            (char *) SDATA (Vx_resource_name));
 
   if (dpyinfo == 0)
     {
       if (!NILP (must_succeed))
        fatal ("Cannot connect to server %s.\n",
-              XSTRING (display)->data);
+              SDATA (display));
       else
-       error ("Cannot connect to server %s", XSTRING (display)->data);
+       error ("Cannot connect to server %s", SDATA (display));
     }
 
   mac_in_use = 1;
@@ -4726,12 +4681,12 @@ valid_image_p (object)
      Lisp_Object object;
 {
   int valid_p = 0;
-  
+
   if (CONSP (object) && EQ (XCAR (object), Qimage))
     {
       Lisp_Object symbol = Fplist_get (XCDR (object), QCtype);
       struct image_type *type = lookup_image_type (symbol);
-      
+
       if (type)
        valid_p = type->valid_p (object);
     }
@@ -4839,7 +4794,7 @@ parse_image_spec (spec, keywords, nkeywords, type)
 
       /* Find key in KEYWORDS.  Error if not found.  */
       for (i = 0; i < nkeywords; ++i)
-       if (strcmp (keywords[i].name, XSYMBOL (key)->name->data) == 0)
+       if (strcmp (keywords[i].name, SDATA (SYMBOL_NAME (key))) == 0)
          break;
 
       if (i == nkeywords)
@@ -4849,7 +4804,7 @@ parse_image_spec (spec, keywords, nkeywords, type)
         was found more than once, it's an error.  */
       keywords[i].value = value;
       ++keywords[i].count;
-      
+
       if (keywords[i].count > 1)
        return 0;
 
@@ -4899,7 +4854,7 @@ parse_image_spec (spec, keywords, nkeywords, type)
 
        case IMAGE_FUNCTION_VALUE:
          value = indirect_function (value);
-         if (SUBRP (value) 
+         if (SUBRP (value)
              || COMPILEDP (value)
              || (CONSP (value) && EQ (XCAR (value), Qlambda)))
            break;
@@ -4948,7 +4903,7 @@ image_spec_value (spec, key, found)
      int *found;
 {
   Lisp_Object tail;
-  
+
   xassert (valid_image_p (spec));
 
   for (tail = XCDR (spec);
@@ -4962,12 +4917,12 @@ image_spec_value (spec, key, found)
          return XCAR (XCDR (tail));
        }
     }
-  
+
   if (found)
     *found = 0;
   return Qnil;
 }
-     
+
 
 
 \f
@@ -4988,7 +4943,7 @@ make_image (spec, hash)
      unsigned hash;
 {
   struct image *img = (struct image *) xmalloc (sizeof *img);
-  
+
   xassert (valid_image_p (spec));
   bzero (img, sizeof *img);
   img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
@@ -5049,7 +5004,7 @@ prepare_image_for_display (f, img)
   if (img->pixmap == 0 && !img->load_failed_p)
     img->load_failed_p = img->type->load (f, img) == 0;
 }
-     
+
 
 /* Value is the number of pixels for the ascent of image IMG when
    drawn in face FACE.  */
@@ -5108,7 +5063,7 @@ x_clear_image (f, img)
   if (img->ncolors)
     {
       int class = FRAME_W32_DISPLAY_INFO (f)->visual->class;
-      
+
       /* If display has an immutable color map, freeing colors is not
         necessary and some servers don't allow it.  So don't do it.  */
       if (class != StaticColor
@@ -5122,7 +5077,7 @@ x_clear_image (f, img)
                       img->ncolors, 0);
          UNBLOCK_INPUT;
        }
-      
+
       xfree (img->colors);
       img->colors = NULL;
       img->ncolors = 0;
@@ -5149,7 +5104,7 @@ x_alloc_image_color (f, img, color_name, dflt)
 
   xassert (STRINGP (color_name));
 
-  if (w32_defined_color (f, XSTRING (color_name)->data, &color, 1))
+  if (w32_defined_color (f, SDATA (color_name), &color, 1))
     {
       /* This isn't called frequently so we get away with simply
         reallocating the color vector to the needed size, here.  */
@@ -5184,7 +5139,7 @@ make_image_cache ()
 {
   struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
   int size;
-  
+
   bzero (c, sizeof *c);
   c->size = 50;
   c->images = (struct image **) xmalloc (c->size * sizeof *c->images);
@@ -5209,7 +5164,7 @@ free_image_cache (f)
 
       /* Cache should not be referenced by any frame when freed.  */
       xassert (c->refcount == 0);
-      
+
       for (i = 0; i < c->used; ++i)
        free_image (f, c->images[i]);
       xfree (c->images);
@@ -5242,7 +5197,7 @@ clear_image_cache (f, force_p)
 
       EMACS_GET_TIME (t);
       old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);
-      
+
       for (i = 0; i < c->used; ++i)
        {
          struct image *img = c->images[i];
@@ -5279,7 +5234,7 @@ FRAME t means clear the image caches of all frames.  */)
   if (EQ (frame, Qt))
     {
       Lisp_Object tail;
-      
+
       FOR_EACH_FRAME (tail, frame)
        if (FRAME_MAC_P (XFRAME (frame)))
          clear_image_cache (XFRAME (frame), 1);
@@ -5310,7 +5265,7 @@ lookup_image (f, spec)
      specification.  */
   xassert (FRAME_WINDOW_P (f));
   xassert (valid_image_p (spec));
-  
+
   GCPRO1 (spec);
 
   /* Look up SPEC in the hash table of the image cache.  */
@@ -5367,7 +5322,7 @@ lookup_image (f, spec)
              if (XINT (XCDR (margin)) > 0)
                img->vmargin = XFASTINT (XCDR (margin));
            }
-         
+
          relief = image_spec_value (spec, QCrelief, NULL);
          if (INTEGERP (relief))
            {
@@ -5381,9 +5336,9 @@ lookup_image (f, spec)
   /* We're using IMG, so set its timestamp to `now'.  */
   EMACS_GET_TIME (now);
   img->timestamp = EMACS_SECS (now);
-  
+
   UNGCPRO;
-  
+
   /* Value is the image id.  */
   return img->id;
 }
@@ -5537,7 +5492,7 @@ x_put_x_image (f, ximg, pixmap, width, height)
      Pixmap pixmap;
 {
   GC gc;
-  
+
   xassert (interrupt_input_blocked);
   gc = XCreateGC (NULL, pixmap, 0, NULL);
   XPutImage (NULL, pixmap, gc, ximg, 0, 0, 0, 0, width, height);
@@ -5570,8 +5525,8 @@ x_find_image_file (file)
   GCPRO2 (file_found, search_path);
 
   /* Try to find FILE in data-directory, then x-bitmap-file-path.  */
-  fd = openp (search_path, file, Qnil, &file_found, 0);
-  
+  fd = openp (search_path, file, Qnil, &file_found, Qnil);
+
   if (fd < 0)
     file_found = Qnil;
   else
@@ -5651,7 +5606,7 @@ enum xbm_token
   XBM_TK_NUMBER
 };
 
-  
+
 /* Return non-zero if OBJECT is a valid XBM-type image specification.
    A valid specification is a list starting with the symbol `image'
    The rest of the list is a property list which must contain an
@@ -5682,7 +5637,7 @@ xbm_image_p (object)
      Lisp_Object object;
 {
   struct image_keyword kw[XBM_LAST];
-  
+
   bcopy (xbm_format, kw, sizeof kw);
   if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))
     return 0;
@@ -5708,13 +5663,13 @@ xbm_image_p (object)
       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.  */
       if (VECTORP (data))
        {
          int i;
-         
+
          /* Number of elements of the vector must be >= height.  */
          if (XVECTOR (data)->size < height)
            return 0;
@@ -5727,7 +5682,7 @@ xbm_image_p (object)
 
              if (STRINGP (elt))
                {
-                 if (XSTRING (elt)->size
+                 if (SCHARS (elt)
                      < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR)
                    return 0;
                }
@@ -5742,7 +5697,7 @@ xbm_image_p (object)
        }
       else if (STRINGP (data))
        {
-         if (XSTRING (data)->size
+         if (SCHARS (data)
              < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height)
            return 0;
        }
@@ -5759,7 +5714,7 @@ xbm_image_p (object)
   if (kw[XBM_ASCENT].count
       && XFASTINT (kw[XBM_ASCENT].value) > 100)
     return 0;
-  
+
   return 1;
 }
 
@@ -5777,7 +5732,7 @@ xbm_scan (fp, sval, ival)
      int *ival;
 {
   int c;
-  
+
   /* Skip white space.  */
   while ((c = fgetc (fp)) != EOF && isspace (c))
     ;
@@ -5787,7 +5742,7 @@ xbm_scan (fp, sval, ival)
   else if (isdigit (c))
     {
       int value = 0, digit;
-      
+
       if (c == '0')
        {
          c = fgetc (fp);
@@ -5871,7 +5826,7 @@ xbm_read_bitmap_file_data (file, width, height, data)
      if (LA1 != (TOKEN))       \
        goto failure;           \
      else                      \
-       match ()        
+       match ()
 
 #define expect_ident(IDENT)                                    \
      if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0) \
@@ -5915,7 +5870,7 @@ xbm_read_bitmap_file_data (file, width, height, data)
     {
       if (strcmp (buffer, "unsigned") == 0)
        {
-         match (); 
+         match ();
          expect_ident ("char");
        }
       else if (strcmp (buffer, "short") == 0)
@@ -5930,7 +5885,7 @@ xbm_read_bitmap_file_data (file, width, height, data)
       else
        goto failure;
     }
-  else 
+  else
     goto failure;
 
   expect (XBM_TK_IDENT);
@@ -5945,7 +5900,7 @@ xbm_read_bitmap_file_data (file, width, height, data)
 
   if (v10)
     {
-      
+
       for (i = 0; i < nbytes; i += 2)
        {
          int val = value;
@@ -5954,7 +5909,7 @@ xbm_read_bitmap_file_data (file, width, height, data)
          *p++ = val;
          if (!padding_p || ((i + 2) % bytes_per_line))
            *p++ = value >> 8;
-         
+
          if (LA1 == ',' || LA1 == '}')
            match ();
          else
@@ -5967,9 +5922,9 @@ xbm_read_bitmap_file_data (file, width, height, data)
        {
          int val = value;
          expect (XBM_TK_NUMBER);
-         
+
          *p++ = val;
-         
+
          if (LA1 == ',' || LA1 == '}')
            match ();
          else
@@ -5981,7 +5936,7 @@ xbm_read_bitmap_file_data (file, width, height, data)
   return 1;
 
  failure:
-  
+
   fclose (fp);
   if (*data)
     {
@@ -6010,7 +5965,7 @@ xbm_load_image_from_file (f, img, specified_file)
   int success_p = 0;
   Lisp_Object file;
   struct gcpro gcpro1;
-  
+
   xassert (STRINGP (specified_file));
   file = Qnil;
   GCPRO1 (file);
@@ -6022,8 +5977,8 @@ xbm_load_image_from_file (f, img, specified_file)
       UNGCPRO;
       return 0;
     }
-         
-  rc = xbm_read_bitmap_file_data (XSTRING (file)->data, &img->width,
+
+  rc = xbm_read_bitmap_file_data (SDATA (file), &img->width,
                                  &img->height, &data);
   if (rc)
     {
@@ -6031,14 +5986,14 @@ xbm_load_image_from_file (f, img, specified_file)
       unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
       unsigned long background = FRAME_BACKGROUND_PIXEL (f);
       Lisp_Object value;
-      
+
       xassert (img->width > 0 && img->height > 0);
 
       /* 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);
-      
+
       value = image_spec_value (img->spec, QCbackground, NULL);
       if (!NILP (value))
        background = x_alloc_image_color (f, img, value, background);
@@ -6061,7 +6016,7 @@ xbm_load_image_from_file (f, img, specified_file)
        }
       else
        success_p = 1;
-      
+
       UNBLOCK_INPUT;
 #endif /* MAC_TODO */
     }
@@ -6111,7 +6066,7 @@ xbm_load (f, img)
       xassert (img->width > 0 && img->height > 0);
 
       BLOCK_INPUT;
-      
+
       if (fmt[XBM_ASCENT].count)
        img->ascent = XFASTINT (fmt[XBM_ASCENT].value);
 
@@ -6130,19 +6085,19 @@ xbm_load (f, img)
          int i;
          char *p;
          int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
-         
+
          p = bits = (char *) alloca (nbytes * img->height);
          for (i = 0; i < img->height; ++i, p += nbytes)
            {
              Lisp_Object line = XVECTOR (data)->contents[i];
              if (STRINGP (line))
-               bcopy (XSTRING (line)->data, p, nbytes);
+               bcopy (SDATA (line), p, nbytes);
              else
                bcopy (XBOOL_VECTOR (line)->data, p, nbytes);
            }
        }
       else if (STRINGP (data))
-       bits = XSTRING (data)->data;
+       bits = SDATA (data);
       else
        bits = XBOOL_VECTOR (data)->data;
 
@@ -6172,14 +6127,14 @@ xbm_load (f, img)
 
   return success_p;
 }
-  
+
 
 \f
 /***********************************************************************
                              XPM images
  ***********************************************************************/
 
-#if HAVE_XPM 
+#if HAVE_XPM
 
 static int xpm_image_p P_ ((Lisp_Object object));
 static int xpm_load P_ ((struct frame *f, struct image *img));
@@ -6313,7 +6268,7 @@ xpm_load (f, img)
       Lisp_Object tail;
       XpmColorSymbol *xpm_syms;
       int i, size;
-      
+
       attrs.valuemask |= XpmColorSymbols;
 
       /* Count number of symbols.  */
@@ -6334,10 +6289,10 @@ xpm_load (f, img)
        {
          Lisp_Object name = XCAR (XCAR (tail));
          Lisp_Object color = XCDR (XCAR (tail));
-         xpm_syms[i].name = (char *) alloca (XSTRING (name)->size + 1);
-         strcpy (xpm_syms[i].name, XSTRING (name)->data);
-         xpm_syms[i].value = (char *) alloca (XSTRING (color)->size + 1);
-         strcpy (xpm_syms[i].value, XSTRING (color)->data);
+         xpm_syms[i].name = (char *) alloca (SCHARS (name) + 1);
+         strcpy (xpm_syms[i].name, SDATA (name));
+         xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1);
+         strcpy (xpm_syms[i].value, SDATA (color));
        }
     }
 
@@ -6354,16 +6309,16 @@ xpm_load (f, img)
           UNBLOCK_INPUT;
          return 0;
        }
-      
+
       rc = XpmReadFileToPixmap (NULL, FRAME_W32_WINDOW (f),
-                               XSTRING (file)->data, &img->pixmap, &img->mask,
+                               SDATA (file), &img->pixmap, &img->mask,
                                &attrs);
     }
   else
     {
       Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL);
       rc = XpmCreatePixmapFromBuffer (NULL, FRAME_W32_WINDOW (f),
-                                     XSTRING (buffer)->data,
+                                     SDATA (buffer),
                                      &img->pixmap, &img->mask,
                                      &attrs);
     }
@@ -6394,19 +6349,19 @@ xpm_load (f, img)
        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 XpmNoMemory:
          image_error ("Out of memory (%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;
@@ -6555,7 +6510,7 @@ lookup_pixel_color (f, pixel)
       int rc;
 
       BLOCK_INPUT;
-      
+
       cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
       color.pixel = pixel;
       XQueryColor (NULL, cmap, &color);
@@ -6565,7 +6520,7 @@ lookup_pixel_color (f, pixel)
       if (rc)
        {
          ++ct_colors_allocated;
-      
+
          p = (struct ct_color *) xmalloc (sizeof *p);
          p->r = color.red;
          p->g = color.green;
@@ -6602,7 +6557,7 @@ colors_in_color_table (n)
       colors = (unsigned long *) xmalloc (ct_colors_allocated
                                          * sizeof *colors);
       *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;
@@ -6660,7 +6615,7 @@ x_laplace_write_row (f, pixels, width, ximg, y)
      int y;
 {
   int x;
-  
+
   for (x = 0; x < width; ++x)
     XPutPixel (ximg, x, y, pixels[x]);
 }
@@ -6726,7 +6681,7 @@ x_laplace (f, img)
          int r = in[rowa][x].red + mv2 - in[rowb][x + 2].red;
          int g = in[rowa][x].green + mv2 - in[rowb][x + 2].green;
          int b = in[rowa][x].blue + mv2 - in[rowb][x + 2].blue;
-         
+
          out[x + 1] = lookup_rgb_color (f, r & 0xffff, g & 0xffff,
                                         b & 0xffff);
        }
@@ -6742,7 +6697,7 @@ x_laplace (f, img)
   /* Free the input image, and free resources of IMG.  */
   XDestroyImage (ximg);
   x_clear_image (f, img);
-  
+
   /* Put the output image into pixmap, and destroy it.  */
   x_put_x_image (f, oimg, pixmap, img->width, img->height);
   x_destroy_x_image (oimg);
@@ -6777,7 +6732,7 @@ x_build_heuristic_mask (f, img, how)
   unsigned long bg;
 
   BLOCK_INPUT;
-  
+
   /* Create an image and pixmap serving as mask.  */
   rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1,
                                    &mask_img, &img->mask);
@@ -6795,7 +6750,7 @@ x_build_heuristic_mask (f, img, how)
      take that as color.  Otherwise, try to determine the color
      heuristically. */
   look_at_corners_p = 1;
-  
+
   if (CONSP (how))
     {
       int rgb[3], i = 0;
@@ -6815,7 +6770,7 @@ x_build_heuristic_mask (f, img, how)
          Colormap cmap;
 
          sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
-         
+
          cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
          if (XLookupColor (dpy, cmap, color_name, &exact, &color))
            {
@@ -6824,7 +6779,7 @@ x_build_heuristic_mask (f, img, how)
            }
        }
     }
-  
+
   if (look_at_corners_p)
     {
       unsigned long corners[4];
@@ -6840,7 +6795,7 @@ x_build_heuristic_mask (f, img, how)
       for (i = best_count = 0; i < 4; ++i)
        {
          int j, n;
-         
+
          for (j = n = 0; j < 4; ++j)
            if (corners[i] == corners[j])
              ++n;
@@ -6860,7 +6815,7 @@ x_build_heuristic_mask (f, img, how)
   x_put_x_image (f, mask_img, img->mask, img->width, img->height);
   x_destroy_x_image (mask_img);
   XDestroyImage (ximg);
-  
+
   UNBLOCK_INPUT;
 #endif /* MAC_TODO */
 
@@ -6931,11 +6886,11 @@ pbm_image_p (object)
      Lisp_Object object;
 {
   struct image_keyword fmt[PBM_LAST];
-  
+
   bcopy (pbm_format, fmt, sizeof fmt);
-  
+
   if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)
-      || (fmt[PBM_ASCENT].count 
+      || (fmt[PBM_ASCENT].count
          && XFASTINT (fmt[PBM_ASCENT].value) > 100))
     return 0;
 
@@ -6984,7 +6939,7 @@ pbm_scan_number (s, end)
 
 /* Read FILE into memory.  Value is a pointer to a buffer allocated
    with xmalloc holding FILE's contents.  Value is null if an error
-   occured.  *SIZE is set to the size of the file.  */
+   occurred.  *SIZE is set to the size of the file.  */
 
 static char *
 pbm_read_file (file, size)
@@ -6995,8 +6950,8 @@ pbm_read_file (file, size)
   char *buf = NULL;
   struct stat st;
 
-  if (stat (XSTRING (file)->data, &st) == 0
-      && (fp = fopen (XSTRING (file)->data, "r")) != NULL
+  if (stat (SDATA (file), &st) == 0
+      && (fp = fopen (SDATA (file), "r")) != NULL
       && (buf = (char *) xmalloc (st.st_size),
          fread (buf, 1, st.st_size, fp) == st.st_size))
     {
@@ -7013,14 +6968,14 @@ pbm_read_file (file, size)
          buf = NULL;
        }
     }
-  
+
   return buf;
 }
 
 
 /* Load PBM image IMG for use on frame F.  */
 
-static int 
+static int
 pbm_load (f, img)
      struct frame *f;
      struct image *img;
@@ -7064,8 +7019,8 @@ pbm_load (f, img)
     {
       Lisp_Object data;
       data = image_spec_value (img->spec, QCdata, NULL);
-      p = XSTRING (data)->data;
-      end = p + STRING_BYTES (XSTRING (data));
+      p = SDATA (data);
+      end = p + SBYTES (data);
     }
 
   /* Check magic number.  */
@@ -7083,7 +7038,7 @@ pbm_load (f, img)
     case '1':
       raw_p = 0, type = PBM_MONO;
       break;
-      
+
     case '2':
       raw_p = 0, type = PBM_GRAY;
       break;
@@ -7095,11 +7050,11 @@ pbm_load (f, img)
     case '4':
       raw_p = 1, type = PBM_MONO;
       break;
-      
+
     case '5':
       raw_p = 1, type = PBM_GRAY;
       break;
-      
+
     case '6':
       raw_p = 1, type = PBM_COLOR;
       break;
@@ -7120,7 +7075,7 @@ pbm_load (f, img)
       if (raw_p && max_color_idx > 255)
        max_color_idx = 255;
     }
-  
+
   if (width < 0
       || height < 0
       || (type != PBM_MONO && max_color_idx < 0))
@@ -7133,14 +7088,14 @@ pbm_load (f, img)
       UNBLOCK_INPUT;
       goto error;
     }
-  
+
   /* Initialize the color hash table.  */
   init_color_table ();
 
   if (type == PBM_MONO)
     {
       int c = 0, g;
-      
+
       for (y = 0; y < height; ++y)
        for (x = 0; x < width; ++x)
          {
@@ -7165,7 +7120,7 @@ pbm_load (f, img)
        for (x = 0; x < width; ++x)
          {
            int r, g, b;
-           
+
            if (type == PBM_GRAY)
              r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);
            else if (raw_p)
@@ -7180,7 +7135,7 @@ pbm_load (f, img)
                g = pbm_scan_number (&p, end);
                b = pbm_scan_number (&p, end);
              }
-           
+
            if (r < 0 || g < 0 || b < 0)
              {
                xfree (ximg->data);
@@ -7191,7 +7146,7 @@ pbm_load (f, img)
                             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;
@@ -7200,17 +7155,17 @@ pbm_load (f, img)
            XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
          }
     }
-  
+
   /* Store in IMG->colors the colors allocated for the image, and
      free the color table.  */
   img->colors = colors_in_color_table (&img->ncolors);
   free_color_table ();
-  
+
   /* Put the image into a pixmap.  */
   x_put_x_image (f, ximg, img->pixmap, width, height);
   x_destroy_x_image (ximg);
   UNBLOCK_INPUT;
-      
+
   img->width = width;
   img->height = height;
 
@@ -7288,9 +7243,9 @@ png_image_p (object)
 {
   struct image_keyword fmt[PNG_LAST];
   bcopy (png_format, fmt, sizeof fmt);
-  
+
   if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)
-      || (fmt[PNG_ASCENT].count 
+      || (fmt[PNG_ASCENT].count
          && XFASTINT (fmt[PNG_ASCENT].value) > 100))
     return 0;
 
@@ -7347,7 +7302,7 @@ png_read_from_memory (png_ptr, data, length)
 
   if (length > tbr->len - tbr->index)
     png_error (png_ptr, "Read error");
-  
+
   bcopy (tbr->bytes + tbr->index, data, length);
   tbr->index = tbr->index + length;
 }
@@ -7398,7 +7353,7 @@ png_load (f, img)
         }
 
       /* Open the image file.  */
-      fp = fopen (XSTRING (file)->data, "rb");
+      fp = fopen (SDATA (file), "rb");
       if (!fp)
         {
           image_error ("Cannot open image file `%s'", file, Qnil);
@@ -7420,8 +7375,8 @@ png_load (f, img)
   else
     {
       /* Read from memory.  */
-      tbr.bytes = XSTRING (specified_data)->data;
-      tbr.len = STRING_BYTES (XSTRING (specified_data));
+      tbr.bytes = SDATA (specified_data);
+      tbr.len = SBYTES (specified_data);
       tbr.index = 0;
 
       /* Check PNG signature.  */
@@ -7490,14 +7445,14 @@ png_load (f, img)
   png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
                &interlace_type, NULL, NULL);
 
-  /* If image contains simply transparency data, we prefer to 
+  /* If image contains simply transparency data, we prefer to
      construct a clipping mask.  */
   if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
     transparent_p = 1;
   else
     transparent_p = 0;
 
-  /* This function is easier to write if we only have to handle 
+  /* This function is easier to write if we only have to handle
      one data format: RGB or RGBA with 8 bits per channel.  Let's
      transform other formats into that format.  */
 
@@ -7510,7 +7465,7 @@ png_load (f, img)
   png_set_expand (png_ptr);
 
   /* Convert grayscale images to RGB.  */
-  if (color_type == PNG_COLOR_TYPE_GRAY 
+  if (color_type == PNG_COLOR_TYPE_GRAY
       || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
     png_set_gray_to_rgb (png_ptr);
 
@@ -7541,14 +7496,14 @@ png_load (f, img)
       png_color_16 *image_background;
 
       if (png_get_bKGD (png_ptr, info_ptr, &image_background))
-       /* Image contains a background color with which to 
+       /* Image contains a background color with which to
           combine the image.  */
        png_set_background (png_ptr, image_background,
                            PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
       else
        {
          /* Image does not contain a background color with which
-            to combine the image data via an alpha channel.  Use 
+            to combine the image data via an alpha channel.  Use
             the frame's background instead.  */
          XColor color;
          Colormap cmap;
@@ -7608,7 +7563,7 @@ png_load (f, img)
       UNBLOCK_INPUT;
       goto error;
     }
-  
+
   /* Create an image and pixmap serving as mask if the PNG image
      contains an alpha channel.  */
   if (channels == 4
@@ -7640,16 +7595,16 @@ png_load (f, img)
          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 
+            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.  
+            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
@@ -7773,11 +7728,11 @@ jpeg_image_p (object)
      Lisp_Object object;
 {
   struct image_keyword fmt[JPEG_LAST];
-  
+
   bcopy (jpeg_format, fmt, sizeof fmt);
-  
+
   if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)
-      || (fmt[JPEG_ASCENT].count 
+      || (fmt[JPEG_ASCENT].count
          && XFASTINT (fmt[JPEG_ASCENT].value) > 100))
     return 0;
 
@@ -7846,7 +7801,7 @@ our_skip_input_data (cinfo, num_bytes)
     {
       if (num_bytes > src->bytes_in_buffer)
        ERREXIT (cinfo, JERR_INPUT_EOF);
-      
+
       src->bytes_in_buffer -= num_bytes;
       src->next_input_byte += num_bytes;
     }
@@ -7884,7 +7839,7 @@ jpeg_memory_src (cinfo, data, len)
       src = (struct jpeg_source_mgr *) cinfo->src;
       src->next_input_byte = data;
     }
-  
+
   src = (struct jpeg_source_mgr *) cinfo->src;
   src->init_source = our_init_source;
   src->fill_input_buffer = our_fill_input_buffer;
@@ -7899,7 +7854,7 @@ jpeg_memory_src (cinfo, data, len)
 /* Load image IMG for use on frame F.  Patterned after example.c
    from the JPEG lib.  */
 
-static int 
+static int
 jpeg_load (f, img)
      struct frame *f;
      struct image *img;
@@ -7932,8 +7887,8 @@ jpeg_load (f, img)
           UNGCPRO;
           return 0;
         }
-  
-      fp = fopen (XSTRING (file)->data, "r");
+
+      fp = fopen (SDATA (file), "r");
       if (fp == NULL)
         {
           image_error ("Cannot open `%s'", file, Qnil);
@@ -7941,12 +7896,12 @@ jpeg_load (f, img)
           return 0;
         }
     }
-  
+
   /* Customize libjpeg's error handling to call my_error_exit when an
      error is detected. This function will perform a longjmp. */
   mgr.pub.error_exit = my_error_exit;
   cinfo.err = jpeg_std_error (&mgr.pub);
-  
+
   if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
     {
       if (rc == 1)
@@ -7957,20 +7912,20 @@ jpeg_load (f, img)
          image_error ("Error reading JPEG image `%s': %s", img->spec,
                       build_string (buffer));
        }
-         
+
       /* Close the input file and destroy the JPEG object.  */
       if (fp)
         fclose (fp);
       jpeg_destroy_decompress (&cinfo);
 
       BLOCK_INPUT;
-      
+
       /* If we already have an XImage, free that.  */
       x_destroy_x_image (ximg);
 
       /* Free pixmap and colors.  */
       x_clear_image (f, img);
-      
+
       UNBLOCK_INPUT;
       UNGCPRO;
       return 0;
@@ -7983,8 +7938,8 @@ jpeg_load (f, img)
   if (NILP (specified_data))
     jpeg_stdio_src (&cinfo, fp);
   else
-    jpeg_memory_src (&cinfo, XSTRING (specified_data)->data,
-                    STRING_BYTES (XSTRING (specified_data)));
+    jpeg_memory_src (&cinfo, SDATA (specified_data),
+                    SBYTES (specified_data));
 
   jpeg_read_header (&cinfo, TRUE);
 
@@ -8027,7 +7982,7 @@ jpeg_load (f, img)
     init_color_table ();
     colors = (unsigned long *) alloca (cinfo.actual_number_of_colors
                                       * sizeof *colors);
-  
+
     for (i = 0; i < cinfo.actual_number_of_colors; ++i)
       {
        /* Multiply RGB values with 255 because X expects RGB values
@@ -8059,7 +8014,7 @@ jpeg_load (f, img)
   jpeg_destroy_decompress (&cinfo);
   if (fp)
     fclose (fp);
-  
+
   /* Put the image into the pixmap.  */
   x_put_x_image (f, ximg, img->pixmap, width, height);
   x_destroy_x_image (ximg);
@@ -8137,12 +8092,12 @@ tiff_image_p (object)
 {
   struct image_keyword fmt[TIFF_LAST];
   bcopy (tiff_format, fmt, sizeof fmt);
-  
+
   if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)
-      || (fmt[TIFF_ASCENT].count 
+      || (fmt[TIFF_ASCENT].count
          && XFASTINT (fmt[TIFF_ASCENT].value) > 100))
     return 0;
-  
+
   /* Must specify either the :data or :file keyword.  */
   return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;
 }
@@ -8203,22 +8158,22 @@ tiff_seek_in_memory (data, off, whence)
     case SEEK_SET:             /* Go from beginning of source.  */
       idx = off;
       break;
-      
+
     case SEEK_END:             /* Go from end of source.  */
       idx = src->len + off;
       break;
-      
+
     case SEEK_CUR:             /* Go from current position.  */
       idx = src->index + off;
       break;
-      
-    default:                   /* Invalid `whence'.   */
+
+    default:                   /* Invalid `whence'.  */
       return -1;
     }
-  
+
   if (idx > src->len || idx < 0)
     return -1;
-  
+
   src->index = idx;
   return src->index;
 }
@@ -8290,9 +8245,9 @@ tiff_load (f, img)
           UNGCPRO;
           return 0;
         }
-  
+
       /* Try to open the image file.  */
-      tiff = TIFFOpen (XSTRING (file)->data, "r");
+      tiff = TIFFOpen (SDATA (file), "r");
       if (tiff == NULL)
         {
           image_error ("Cannot open `%s'", file, Qnil);
@@ -8303,8 +8258,8 @@ tiff_load (f, img)
   else
     {
       /* Memory source! */
-      memsrc.bytes = XSTRING (specified_data)->data;
-      memsrc.len = STRING_BYTES (XSTRING (specified_data));
+      memsrc.bytes = SDATA (specified_data);
+      memsrc.len = SBYTES (specified_data);
       memsrc.index = 0;
 
       tiff = TIFFClientOpen ("memory_source", "r", &memsrc,
@@ -8329,7 +8284,7 @@ tiff_load (f, img)
   TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
   TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
   buf = (uint32 *) xmalloc (width * height * sizeof *buf);
-  
+
   rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);
   TIFFClose (tiff);
   if (!rc)
@@ -8358,14 +8313,14 @@ tiff_load (f, img)
   for (y = 0; y < height; ++y)
     {
       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)); 
+         XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));
        }
     }
 
@@ -8378,7 +8333,7 @@ tiff_load (f, img)
   x_destroy_x_image (ximg);
   xfree (buf);
   UNBLOCK_INPUT;
-      
+
   img->width = width;
   img->height = height;
 
@@ -8456,12 +8411,12 @@ gif_image_p (object)
 {
   struct image_keyword fmt[GIF_LAST];
   bcopy (gif_format, fmt, sizeof fmt);
-  
+
   if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)
-      || (fmt[GIF_ASCENT].count 
+      || (fmt[GIF_ASCENT].count
          && XFASTINT (fmt[GIF_ASCENT].value) > 100))
     return 0;
-  
+
   /* Must specify either the :data or :file keyword.  */
   return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;
 }
@@ -8534,9 +8489,9 @@ gif_load (f, img)
           UNGCPRO;
           return 0;
         }
-  
+
       /* Open the GIF file.  */
-      gif = DGifOpenFileName (XSTRING (file)->data);
+      gif = DGifOpenFileName (SDATA (file));
       if (gif == NULL)
         {
           image_error ("Cannot open `%s'", file, Qnil);
@@ -8548,8 +8503,8 @@ gif_load (f, img)
     {
       /* Read from memory! */
       current_gif_memory_src = &memsrc;
-      memsrc.bytes = XSTRING (specified_data)->data;
-      memsrc.len = STRING_BYTES (XSTRING (specified_data));
+      memsrc.bytes = SDATA (specified_data);
+      memsrc.len = SBYTES (specified_data);
       memsrc.index = 0;
 
       gif = DGifOpen(&memsrc, gif_read_from_memory);
@@ -8595,14 +8550,14 @@ gif_load (f, img)
       UNGCPRO;
       return 0;
     }
-  
+
   /* Allocate colors.  */
   gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;
   if (!gif_color_map)
     gif_color_map = gif->SColorMap;
   init_color_table ();
   bzero (pixel_colors, sizeof pixel_colors);
-  
+
   for (i = 0; i < gif_color_map->ColorCount; ++i)
     {
       int r = gif_color_map->Colors[i].Red << 8;
@@ -8615,7 +8570,7 @@ gif_load (f, img)
   free_color_table ();
 
   /* Clear the part of the screen image that are not covered by
-     the image from the GIF file.  Full animated GIF support 
+     the image from the GIF file.  Full animated GIF support
      requires more than can be done here (see the gif89 spec,
      disposal methods).  Let's simply assume that the part
      not covered by a sub-image is in the frame's background color.  */
@@ -8662,14 +8617,14 @@ gif_load (f, img)
              while (row >= image_height)
                row = interlace_start[++pass];
            }
-         
+
          for (x = 0; x < image_width; x++)
            {
              int i = raster[(y * image_width) + x];
              XPutPixel (ximg, x + image_left, row + image_top,
                         pixel_colors[i]);
            }
-         
+
          row += interlace_increment[pass];
        }
     }
@@ -8682,14 +8637,14 @@ gif_load (f, img)
            XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);
          }
     }
-  
+
   DGifCloseFile (gif);
-  
+
   /* Put the image into the pixmap, then free the X image and its buffer.  */
   x_put_x_image (f, ximg, img->pixmap, width, height);
   x_destroy_x_image (ximg);
   UNBLOCK_INPUT;
-      
+
   UNGCPRO;
   return 1;
 }
@@ -8786,11 +8741,11 @@ gs_image_p (object)
   struct image_keyword fmt[GS_LAST];
   Lisp_Object tem;
   int i;
-  
+
   bcopy (gs_format, fmt, sizeof fmt);
-  
+
   if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)
-      || (fmt[GS_ASCENT].count 
+      || (fmt[GS_ASCENT].count
          && XFASTINT (fmt[GS_ASCENT].value) > 100))
     return 0;
 
@@ -8858,7 +8813,7 @@ gs_load (f, img)
       image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);
       return 0;
     }
-    
+
   /* Call the loader to fill the pixmap.  It returns a process object
      if successful.  We do not record_unwind_protect here because
      other places in redisplay like calling window scroll functions
@@ -8869,12 +8824,12 @@ gs_load (f, img)
           (unsigned long) FRAME_W32_WINDOW (f),
           (unsigned long) img->pixmap);
   window_and_pixmap_id = build_string (buffer);
-  
+
   sprintf (buffer, "%lu %lu",
           FRAME_FOREGROUND_PIXEL (f),
           FRAME_BACKGROUND_PIXEL (f));
   pixel_colors = build_string (buffer);
-  
+
   XSETFRAME (frame, f);
   loader = image_spec_value (img->spec, QCloader, NULL);
   if (NILP (loader))
@@ -8932,10 +8887,10 @@ x_kill_gs_process (pixmap, f)
       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.  */
@@ -8968,7 +8923,7 @@ x_kill_gs_process (pixmap, f)
       else
        image_error ("Cannot get X image of `%s'; colors will not be freed",
                     img->spec, Qnil);
-      
+
       UNBLOCK_INPUT;
     }
 }
@@ -8996,10 +8951,10 @@ selected frame.  Value is VALUE.  */)
   CHECK_STRING (value);
 
   BLOCK_INPUT;
-  prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), XSTRING (prop)->data, False);
+  prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
   XChangeProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
                   prop_atom, XA_STRING, 8, PropModeReplace,
-                  XSTRING (value)->data, XSTRING (value)->size);
+                  SDATA (value), SCHARS (value));
 
   /* Make sure the property is set when we return.  */
   XFlush (FRAME_W32_DISPLAY (f));
@@ -9025,7 +8980,7 @@ FRAME nil or omitted means use the selected frame.  Value is PROP.  */)
 
   CHECK_STRING (prop);
   BLOCK_INPUT;
-  prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), XSTRING (prop)->data, False);
+  prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
   XDeleteProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), prop_atom);
 
   /* Make sure the property is removed when we return.  */
@@ -9059,7 +9014,7 @@ value.  */)
 
   CHECK_STRING (prop);
   BLOCK_INPUT;
-  prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), XSTRING (prop)->data, False);
+  prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
   rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
                           prop_atom, 0, 0, False, XA_STRING,
                           &actual_type, &actual_format, &actual_size,
@@ -9074,8 +9029,8 @@ value.  */)
       rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
                               prop_atom, 0, bytes_remaining,
                               False, XA_STRING,
-                              &actual_type, &actual_format, 
-                              &actual_size, &bytes_remaining, 
+                              &actual_type, &actual_format,
+                              &actual_size, &bytes_remaining,
                               (unsigned char **) &tmp_data);
       if (rc == Success)
        prop_value = make_string (tmp_data, size);
@@ -9129,7 +9084,7 @@ start_hourglass ()
 #if 0 /* MAC_TODO: cursor shape changes.  */
   EMACS_TIME delay;
   int secs, usecs = 0;
-  
+
   cancel_hourglass ();
 
   if (INTEGERP (Vhourglass_delay)
@@ -9145,7 +9100,7 @@ start_hourglass ()
     }
   else
     secs = DEFAULT_HOURGLASS_DELAY;
-  
+
   EMACS_SET_SECS_USECS (delay, secs, usecs);
   hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
                                     show_hourglass, NULL);
@@ -9164,7 +9119,7 @@ cancel_hourglass ()
       cancel_atimer (hourglass_atimer);
       hourglass_atimer = NULL;
     }
-  
+
   if (hourglass_shown_p)
     hide_hourglass ();
 }
@@ -9191,23 +9146,23 @@ show_hourglass (timer)
   if (!hourglass_shown_p)
     {
       Lisp_Object rest, frame;
-  
+
       BLOCK_INPUT;
-  
+
       FOR_EACH_FRAME (rest, frame)
        if (FRAME_W32_P (XFRAME (frame)))
          {
            struct frame *f = XFRAME (frame);
-       
+
            f->output_data.w32->hourglass_p = 1;
-       
+
            if (!f->output_data.w32->hourglass_window)
              {
                unsigned long mask = CWCursor;
                XSetWindowAttributes attrs;
-           
+
                attrs.cursor = f->output_data.w32->hourglass_cursor;
-           
+
                f->output_data.w32->hourglass_window
                  = XCreateWindow (FRAME_X_DISPLAY (f),
                                   FRAME_OUTER_WINDOW (f),
@@ -9216,7 +9171,7 @@ show_hourglass (timer)
                                   CopyFromParent,
                                   mask, &attrs);
              }
-       
+
            XMapRaised (FRAME_X_DISPLAY (f),
                        f->output_data.w32->hourglass_window);
            XFlush (FRAME_X_DISPLAY (f));
@@ -9243,7 +9198,7 @@ hide_hourglass ()
       FOR_EACH_FRAME (rest, frame)
        {
          struct frame *f = XFRAME (frame);
-      
+
          if (FRAME_W32_P (f)
              /* Watch out for newly created frames.  */
              && f->output_data.x->hourglass_window)
@@ -9271,7 +9226,7 @@ hide_hourglass ()
 
 static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *,
                                           Lisp_Object));
-     
+
 /* The frame of a currently visible tooltip, or null.  */
 
 Lisp_Object tip_frame;
@@ -9301,7 +9256,7 @@ x_create_tip_frame (dpyinfo, parms)
   Lisp_Object name;
   long window_prompting = 0;
   int width, height;
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3;
   struct kboard *kb;
 
@@ -9375,11 +9330,11 @@ x_create_tip_frame (dpyinfo, parms)
       {
        tem = Fquery_fontset (font, Qnil);
        if (STRINGP (tem))
-         font = x_new_fontset (f, XSTRING (tem)->data);
+         font = x_new_fontset (f, SDATA (tem));
        else
-         font = x_new_font (f, XSTRING (font)->data);
+         font = x_new_font (f, SDATA (font));
       }
-    
+
     /* Try out a font which we hope has bold and italic variations.  */
     if (!STRINGP (font))
       font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
@@ -9404,7 +9359,7 @@ x_create_tip_frame (dpyinfo, parms)
 
   x_default_parameter (f, parms, Qborder_width, make_number (2),
                       "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
-  
+
   /* This defaults to 2 in order to match xterm.  We recognize either
      internalBorderWidth or internalBorder (which is what xterm calls
      it).  */
@@ -9442,7 +9397,7 @@ x_create_tip_frame (dpyinfo, parms)
      end up in init_iterator with a null face cache, which should not
      happen.  */
   init_frame_faces (f);
-  
+
   f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;
   window_prompting = x_figure_window_size (f, parms);
 
@@ -9465,7 +9420,7 @@ x_create_tip_frame (dpyinfo, parms)
   {
     XSetWindowAttributes attrs;
     unsigned long mask;
-    
+
     BLOCK_INPUT;
     mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;
     /* Window managers looks at the override-redirect flag to
@@ -9507,6 +9462,11 @@ x_create_tip_frame (dpyinfo, parms)
   SET_FRAME_WIDTH (f, 0);
   change_frame_size (f, height, width, 1, 0, 0);
 
+  /* Add `tooltip' frame parameter's default value. */
+  if (NILP (Fframe_parameter (frame, intern ("tooltip"))))
+    Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
+                                           Qnil));
+
   f->no_split = 1;
 
   UNGCPRO;
@@ -9559,8 +9519,8 @@ DY added (default is 10).  */)
   unsigned pmask;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   int old_windows_or_buffers_changed = windows_or_buffers_changed;
-  int count = specpdl_ptr - specpdl;
-  
+  int count = SPECPDL_INDEX ();
+
   specbind (Qinhibit_redisplay, Qt);
 
   GCPRO4 (string, parms, frame, timeout);
@@ -9576,7 +9536,7 @@ DY added (default is 10).  */)
     dx = make_number (5);
   else
     CHECK_NUMBER (dx);
-  
+
   if (NILP (dy))
     dy = make_number (-10);
   else
@@ -9596,7 +9556,7 @@ DY added (default is 10).  */)
          && !NILP (Fequal (last_parms, parms)))
        {
          struct frame *f = XFRAME (tip_frame);
-         
+
          /* Only DX and DY have changed.  */
          if (!NILP (tip_timer))
            {
@@ -9687,7 +9647,7 @@ DY added (default is 10).  */)
        }
       else
        row_width = row->pixel_width;
-      
+
       height += row->height;
       width = max (width, row_width);
     }
@@ -9741,16 +9701,16 @@ Value is t is tooltip was open, nil otherwise.  */)
   /* Return quickly if nothing to do.  */
   if (NILP (tip_timer) && NILP (tip_frame))
     return Qnil;
-  
+
   frame = tip_frame;
   timer = tip_timer;
   GCPRO2 (frame, timer);
   tip_frame = tip_timer = deleted = Qnil;
-  
-  count = BINDING_STACK_SIZE ();
+
+  count = SPECPDL_INDEX ();
   specbind (Qinhibit_redisplay, Qt);
   specbind (Qinhibit_quit, Qt);
-  
+
   if (!NILP (timer))
     call1 (Qcancel_timer, timer);
 
@@ -9784,7 +9744,7 @@ selection dialog's entry field, if MUSTMATCH is non-nil.  */)
 {
   struct frame *f = SELECTED_FRAME ();
   Lisp_Object file = Qnil;
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   char filename[MAX_PATH + 1];
   char init_dir[MAX_PATH + 1];
@@ -9797,14 +9757,14 @@ selection dialog's entry field, if MUSTMATCH is non-nil.  */)
   /* Create the dialog with PROMPT as title, using DIR as initial
      directory and using "*" as pattern.  */
   dir = Fexpand_file_name (dir, Qnil);
-  strncpy (init_dir, XSTRING (dir)->data, MAX_PATH);
+  strncpy (init_dir, SDATA (dir), MAX_PATH);
   init_dir[MAX_PATH] = '\0';
   unixtodos_filename (init_dir);
 
   if (STRINGP (default_filename))
     {
       char *file_name_only;
-      char *full_path_name = XSTRING (default_filename)->data;
+      char *full_path_name = SDATA (default_filename);
 
       unixtodos_filename (full_path_name);
 
@@ -9843,7 +9803,7 @@ selection dialog's entry field, if MUSTMATCH is non-nil.  */)
       file_details.lpstrFile = filename;
       file_details.nMaxFile = sizeof (filename);
       file_details.lpstrInitialDir = init_dir;
-      file_details.lpstrTitle = XSTRING (prompt)->data;
+      file_details.lpstrTitle = SDATA (prompt);
       file_details.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
 
       if (!NILP (mustmatch))
@@ -9899,7 +9859,7 @@ DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "")
      Lisp_Object spec;
 {
   int id = -1;
-  
+
   if (valid_image_p (spec))
     id = lookup_image (SELECTED_FRAME (), spec);
 
@@ -9924,14 +9884,10 @@ syms_of_macfns ()
   staticpro (&Qauto_raise);
   Qauto_lower = intern ("auto-lower");
   staticpro (&Qauto_lower);
-  Qbar = intern ("bar");
-  staticpro (&Qbar);
   Qborder_color = intern ("border-color");
   staticpro (&Qborder_color);
   Qborder_width = intern ("border-width");
   staticpro (&Qborder_width);
-  Qbox = intern ("box");
-  staticpro (&Qbox);
   Qcursor_color = intern ("cursor-color");
   staticpro (&Qcursor_color);
   Qcursor_type = intern ("cursor-type");
@@ -10020,7 +9976,7 @@ syms_of_macfns ()
   init_x_parm_symbols ();
 
   DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,
-              doc: /* List of directories to search for bitmap files for w32.  */);
+              doc: /* List of directories to search for window system bitmap files.  */);
   Vx_bitmap_file_path = decode_env_path ((char *) 0, "PATH");
 
   DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
@@ -10051,7 +10007,7 @@ or when you set the mouse color.  */);
   DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
               doc: /* Non-zero means Emacs displays an hourglass pointer on window systems.  */);
   display_hourglass_p = 1;
-  
+
   DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
               doc: /* *Seconds to wait before displaying an hourglass pointer.
 Value must be an integer or float.  */);
@@ -10178,16 +10134,16 @@ meaning don't clear the cache.  */);
   Qxpm = intern ("xpm");
   staticpro (&Qxpm);
 #endif
-  
+
 #if HAVE_JPEG
   Qjpeg = intern ("jpeg");
   staticpro (&Qjpeg);
-#endif 
+#endif
 
 #if HAVE_TIFF
   Qtiff = intern ("tiff");
   staticpro (&Qtiff);
-#endif 
+#endif
 
 #if HAVE_GIF
   Qgif = intern ("gif");
@@ -10231,23 +10187,23 @@ init_xfns ()
 #if 0 /* NTEMACS_TODO : Image support for W32 */
   define_image_type (&gs_type);
   define_image_type (&pbm_type);
-  
+
 #if HAVE_XPM
   define_image_type (&xpm_type);
 #endif
-  
+
 #if HAVE_JPEG
   define_image_type (&jpeg_type);
 #endif
-  
+
 #if HAVE_TIFF
   define_image_type (&tiff_type);
 #endif
-  
+
 #if HAVE_GIF
   define_image_type (&gif_type);
 #endif
-  
+
 #if HAVE_PNG
   define_image_type (&png_type);
 #endif