#endif /* HAVE_X_WINDOWS */
#ifdef HAVE_NTGUI
-# ifdef WINDOWSNT
-/* We only need (or want) w32.h when we're _not_
- * compiling for Cygwin */
+
+/* We need (or want) w32.h only when we're _not_ compiling for Cygwin. */
+#ifdef WINDOWSNT
# include "w32.h"
-# endif /* WINDOWSNT */
+#endif
+
/* W32_TODO : Color tables on W32. */
#undef COLOR_TABLE_SUPPORT
do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0)
#else
#define CACHE_IMAGE_TYPE(type, status)
-#endif /* WINDOWSNT */
+#endif
#define ADD_IMAGE_TYPE(type) \
do { Vimage_types = Fcons (type, Vimage_types); } while (0)
if (type->init)
{
-#if defined (HAVE_NTGUI) && defined (WINDOWSNT)
+#if defined HAVE_NTGUI && defined WINDOWSNT
/* 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)))
static unsigned char *
slurp_file (char *file, ptrdiff_t *size)
{
- FILE *fp = NULL;
+ FILE *fp = fopen (file, "rb");
unsigned char *buf = NULL;
struct stat st;
- if (stat (file, &st) == 0
- && (fp = fopen (file, "rb")) != NULL
+ if (fp && fstat (fileno (fp), &st) == 0
&& 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX)
&& (buf = xmalloc (st.st_size),
fread (buf, 1, st.st_size, fp) == st.st_size))
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
-#if defined(HAVE_NTGUI) && defined(WINDOWSNT)
+#if defined HAVE_NTGUI && defined WINDOWSNT
static bool init_xpm_functions (void);
#else
#define init_xpm_functions NULL
#endif /* WINDOWSNT */
-#if defined (HAVE_NTGUI) && !defined (WINDOWSNT)
+#if defined HAVE_NTGUI && !defined WINDOWSNT
/* Glue for code below */
#define fn_XpmReadFileToImage XpmReadFileToImage
#define fn_XpmCreateImageFromBuffer XpmCreateImageFromBuffer
{
*put_func = xpm_put_color_table_h;
*get_func = xpm_get_color_table_h;
- return make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
+ return make_hash_table (hashtest_equal, make_number (DEFAULT_HASH_SIZE),
make_float (DEFAULT_REHASH_SIZE),
make_float (DEFAULT_REHASH_THRESHOLD),
- Qnil, Qnil, Qnil);
+ Qnil);
}
static void
}
-#ifdef HAVE_NTGUI
-#if 0 /* Unused. ++kfs */
-
-/* Read FILE into memory. Value is a pointer to a buffer allocated
- with xmalloc holding FILE's contents. Value is null if an error
- occurred. *SIZE is set to the size of the file. */
-
-static char *
-pbm_read_file (Lisp_Object file, int *size)
-{
- FILE *fp = NULL;
- char *buf = NULL;
- struct stat st;
-
- if (stat (SDATA (file), &st) == 0
- && (fp = fopen (SDATA (file), "rb")) != NULL
- && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX)
- && (buf = xmalloc (st.st_size),
- fread (buf, 1, st.st_size, fp) == st.st_size))
- {
- *size = st.st_size;
- fclose (fp);
- }
- else
- {
- if (fp)
- fclose (fp);
- if (buf)
- {
- xfree (buf);
- buf = NULL;
- }
- }
-
- return buf;
-}
-#endif
-#endif /* HAVE_NTGUI */
-
/* Load PBM image IMG for use on frame F. */
static bool
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
-#if defined(HAVE_NTGUI) && defined (WINDOWSNT)
+#if defined HAVE_NTGUI && defined WINDOWSNT
static bool init_png_functions (void);
#else
#define init_png_functions NULL
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
-#if defined(HAVE_NTGUI) && defined(WINDOWSNT)
+#if defined HAVE_NTGUI && defined WINDOWSNT
static bool init_jpeg_functions (void);
#else
#define init_jpeg_functions NULL
#define __WIN32__ 1
#endif
-#if 0 /* FIXME */
-/* Work around conflict between jpeg boolean and rpcndr.h
- under Windows. */
+/* rpcndr.h (via windows.h) and jpeglib.h both define boolean types.
+ Some versions of jpeglib try to detect whether rpcndr.h is loaded,
+ using the Windows boolean type instead of the jpeglib boolean type
+ if so. Cygwin jpeglib, however, doesn't try to detect whether its
+ headers are included along with windows.h, so under Cygwin, jpeglib
+ attempts to define a conflicting boolean type. Worse, forcing
+ Cygwin jpeglib headers to use the Windows boolean type doesn't work
+ because it created an ABI incompatibility between the
+ already-compiled jpeg library and the header interface definition.
+
+ The best we can do is to define jpeglib's boolean type to a
+ different name. This name, jpeg_boolean, remains in effect through
+ the rest of image.c.
+*/
+#if defined CYGWIN && defined HAVE_NTGUI
#define boolean jpeg_boolean
#endif
#include <jpeglib.h>
#include <jerror.h>
-/* Don't undefine boolean --- use the JPEG boolean
- through the rest of the file. */
-
-#ifdef HAVE_STLIB_H_1
-#define HAVE_STDLIB_H 1
-#endif
-
#ifdef WINDOWSNT
/* JPEG library details. */
{":index", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}
};
-#ifdef HAVE_NTGUI
+#if defined HAVE_NTGUI && defined WINDOWSNT
static bool init_tiff_functions (void);
#else
#define init_tiff_functions NULL
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
-#if defined(HAVE_NTGUI) && defined(WINDOWSNT)
+#if defined HAVE_NTGUI && defined WINDOWSNT
static bool init_gif_functions (void);
#else
#define init_gif_functions NULL
{":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
};
-#ifdef HAVE_NTGUI
+#if defined HAVE_NTGUI && defined WINDOWSNT
static bool init_imagemagick_functions (void);
#else
#define init_imagemagick_functions NULL
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
-#ifdef HAVE_NTGUI
+#if defined HAVE_NTGUI && defined WINDOWSNT
static bool init_svg_functions (void);
#else
#define init_svg_functions NULL
Initialization
***********************************************************************/
-#ifdef WINDOWSNT
-/* Image types that rely on external libraries are loaded dynamically
- if the library is available. */
-#define CHECK_LIB_AVAILABLE(image_type, init_lib_fn, libraries) \
- define_image_type (image_type, init_lib_fn (libraries))
-#else
-#define CHECK_LIB_AVAILABLE(image_type, init_lib_fn, libraries) \
- define_image_type (image_type, 1)
-#endif /* WINDOWSNT */
-
DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 1, 1, 0,
doc: /* Initialize image library implementing image type TYPE.
Return non-nil if TYPE is a supported image type.