Refactor window-system configuration
[bpt/emacs.git] / src / image.c
index 8a318c2..c444c98 100644 (file)
@@ -20,7 +20,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include <stdio.h>
 #include <math.h>
-#include <ctype.h>
 #include <unistd.h>
 
 #ifdef HAVE_PNG
@@ -33,6 +32,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <setjmp.h>
 
+#include <c-ctype.h>
+
 /* This makes the fields of a Display accessible, in Xlib header files.  */
 
 #define XLIB_ILLEGAL_ACCESS
@@ -49,11 +50,19 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "termhooks.h"
 #include "font.h"
 
-#ifdef HAVE_X_WINDOWS
-#include "xterm.h"
-#include <sys/types.h>
+#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#endif /* HAVE_SYS_STAT_H */
 
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif /* HAVE_SYS_TYPES_H */
+
+#ifdef HAVE_WINDOW_SYSTEM
+#include TERM_HEADER
+#endif /* HAVE_WINDOW_SYSTEM */
+
+#ifdef HAVE_X_WINDOWS
 #define COLOR_TABLE_SUPPORT 1
 
 typedef struct x_bitmap_record Bitmap_Record;
@@ -66,11 +75,7 @@ typedef struct x_bitmap_record Bitmap_Record;
 #define PIX_MASK_DRAW  1
 #endif /* HAVE_X_WINDOWS */
 
-
 #ifdef HAVE_NTGUI
-#include "w32.h"
-#include "w32term.h"
-
 /* W32_TODO : Color tables on W32.  */
 #undef COLOR_TABLE_SUPPORT
 
@@ -83,15 +88,9 @@ typedef struct w32_bitmap_record Bitmap_Record;
 #define PIX_MASK_RETAIN        0
 #define PIX_MASK_DRAW  1
 
-#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
 #define x_defined_color w32_defined_color
 #define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
 
-/* Functions from w32term.c that depend on XColor (so can't go in w32term.h
-   without modifying lots of files).  */
-extern void x_query_colors (struct frame *f, XColor *colors, int ncolors);
-extern void x_query_color (struct frame *f, XColor *color);
-
 /* Version of libpng that we were compiled with, or -1 if no PNG
    support was compiled in.  This is tested by w32-win.el to correctly
    set up the alist used to search for PNG libraries.  */
@@ -99,10 +98,6 @@ Lisp_Object Qlibpng_version;
 #endif /* HAVE_NTGUI */
 
 #ifdef HAVE_NS
-#include "nsterm.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-
 #undef COLOR_TABLE_SUPPORT
 
 typedef struct ns_bitmap_record Bitmap_Record;
@@ -116,10 +111,8 @@ typedef struct ns_bitmap_record Bitmap_Record;
 #define PIX_MASK_RETAIN        0
 #define PIX_MASK_DRAW  1
 
-#define FRAME_X_VISUAL FRAME_NS_DISPLAY_INFO (f)->visual
 #define x_defined_color(f, name, color_def, alloc) \
   ns_defined_color (f, name, color_def, alloc, 0)
-#define FRAME_X_SCREEN(f) 0
 #define DefaultDepthOfScreen(screen) x_display_list->n_planes
 #endif /* HAVE_NS */
 
@@ -576,6 +569,7 @@ static void x_emboss (struct frame *, struct image *);
 static int x_build_heuristic_mask (struct frame *, struct image *,
                                    Lisp_Object);
 #ifdef HAVE_NTGUI
+extern Lisp_Object Vlibrary_cache, QCloaded_from;
 #define CACHE_IMAGE_TYPE(type, status) \
   do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0)
 #else
@@ -2405,12 +2399,12 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
  loop:
 
   /* Skip white space.  */
-  while (*s < end && (c = *(*s)++, isspace (c)))
+  while (*s < end && (c = *(*s)++, c_isspace (c)))
     ;
 
   if (*s >= end)
     c = 0;
-  else if (isdigit (c))
+  else if (c_isdigit (c))
     {
       int value = 0, digit;
 
@@ -2422,7 +2416,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
              while (*s < end)
                {
                  c = *(*s)++;
-                 if (isdigit (c))
+                 if (c_isdigit (c))
                    digit = c - '0';
                  else if (c >= 'a' && c <= 'f')
                    digit = c - 'a' + 10;
@@ -2433,11 +2427,11 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
                  value = 16 * value + digit;
                }
            }
-         else if (isdigit (c))
+         else if (c_isdigit (c))
            {
              value = c - '0';
              while (*s < end
-                    && (c = *(*s)++, isdigit (c)))
+                    && (c = *(*s)++, c_isdigit (c)))
                value = 8 * value + c - '0';
            }
        }
@@ -2445,7 +2439,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
        {
          value = c - '0';
          while (*s < end
-                && (c = *(*s)++, isdigit (c)))
+                && (c = *(*s)++, c_isdigit (c)))
            value = 10 * value + c - '0';
        }
 
@@ -2454,11 +2448,11 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
       *ival = value;
       c = XBM_TK_NUMBER;
     }
-  else if (isalpha (c) || c == '_')
+  else if (c_isalpha (c) || c == '_')
     {
       *sval++ = c;
       while (*s < end
-            && (c = *(*s)++, (isalnum (c) || c == '_')))
+            && (c = *(*s)++, (c_isalnum (c) || c == '_')))
        *sval++ = c;
       *sval = 0;
       if (*s < end)
@@ -3661,16 +3655,17 @@ xpm_scan (const unsigned char **s,
   while (*s < end)
     {
       /* Skip white-space.  */
-      while (*s < end && (c = *(*s)++, isspace (c)))
+      while (*s < end && (c = *(*s)++, c_isspace (c)))
        ;
 
       /* gnus-pointer.xpm uses '-' in its identifier.
         sb-dir-plus.xpm uses '+' in its identifier.  */
-      if (isalpha (c) || c == '_' || c == '-' || c == '+')
+      if (c_isalpha (c) || c == '_' || c == '-' || c == '+')
        {
          *beg = *s - 1;
          while (*s < end
-                && (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+'))
+                && (c = **s, c_isalnum (c)
+                    || c == '_' || c == '-' || c == '+'))
              ++*s;
          *len = *s - *beg;
          return XPM_TK_IDENT;
@@ -5014,7 +5009,7 @@ pbm_scan_number (unsigned char **s, unsigned char *end)
   while (*s < end)
     {
       /* Skip white-space.  */
-      while (*s < end && (c = *(*s)++, isspace (c)))
+      while (*s < end && (c = *(*s)++, c_isspace (c)))
        ;
 
       if (c == '#')
@@ -5023,11 +5018,11 @@ pbm_scan_number (unsigned char **s, unsigned char *end)
          while (*s < end && (c = *(*s)++, c != '\n'))
            ;
        }
-      else if (isdigit (c))
+      else if (c_isdigit (c))
        {
          /* Read decimal number.  */
          val = c - '0';
-         while (*s < end && (c = *(*s)++, isdigit (c)))
+         while (*s < end && (c = *(*s)++, c_isdigit (c)))
            val = 10 * val + c - '0';
          break;
        }
@@ -8554,7 +8549,7 @@ gs_load (struct frame *f, struct image *img)
      don't either.  Let the Lisp loader use `unwind-protect' instead.  */
   printnum1 = FRAME_X_WINDOW (f);
   printnum2 = img->pixmap;
-  window_and_pixmap_id 
+  window_and_pixmap_id
     = make_formatted_string (buffer, "%"pMu" %"pMu, printnum1, printnum2);
 
   printnum1 = FRAME_FOREGROUND_PIXEL (f);