shithub: jbig2

Download patch

ref: 3cfcf8802109d753769a91d51f22a5f4353fb6d4
parent: c4921544fb9e703930007eab90e458dbf052c6ec
author: Tor Andersson <tor.andersson@artifex.com>
date: Thu Mar 29 08:41:37 EDT 2018

Clean up the stdint configuration mess.

Don't require HAVE_STDINT_H to be defined to assume the sane default of
including the C standard stdint.h header file.

Use the configuration defines to include non-standard header files.

VS 2012 and newer have stdint.h, so use it.

--- a/config_win32.h
+++ b/config_win32.h
@@ -23,29 +23,37 @@
 #define PACKAGE "jbig2dec"
 #define VERSION "0.14"
 
-#if defined(_MSC_VER) || (defined(__BORLANDC__) && defined(__WIN32__))
-/* Microsoft Visual C++ or Borland C++ */
+#ifdef _MSC_VER
+
+/* VS 2012 and later have stdint.h */
+# if _MSC_VER >= 1700
+#  include <stdint.h>
+# else
 typedef signed char int8_t;
 typedef short int int16_t;
 typedef int int32_t;
 typedef __int64 int64_t;
-
 typedef unsigned char uint8_t;
 typedef unsigned short int uint16_t;
 typedef unsigned int uint32_t;
+typedef unsigned __int64 uint64_t;
+# endif
 
-/* no uint64_t */
+/* VS 2008 and later have vsnprintf */
+# if _MSC_VER < 1500
+#  define vsnprintf _vsnprintf
+# endif
 
-#  if defined(_MSC_VER)
-#   if _MSC_VER < 1500          /* VS 2008 has vsnprintf */
-#    define vsnprintf _vsnprintf
-#   endif
-#  endif
+/* VS 2014 and later have (finally) snprintf */
+# if _MSC_VER >= 1900
+#  define STDC99
+# else
+#  define snprintf _snprintf
+# endif
 
-#  if defined(_MSC_VER) && _MSC_VER>=1900       /* VS 2014 and later have (finally) snprintf */
-#    define STDC99
-#  else
-#    define snprintf _snprintf
-#  endif
+#else /* _MSC_VER */
+
+/* Not VS -- it had best behave */
+# include <stdint.h>
 
 #endif /* _MSC_VER */
--- a/os_types.h
+++ b/os_types.h
@@ -28,21 +28,9 @@
 #ifndef _JBIG2_OS_TYPES_H
 #define _JBIG2_OS_TYPES_H
 
-#if defined(__CYGWIN__) && !defined(HAVE_STDINT_H)
-# include <sys/types.h>
-# if defined(OLD_CYGWIN_SYS_TYPES)
-/*
- * Old versions of Cygwin have no stdint.h but define "MS types". Some of
- * them conflict with a standard type emulation provided by config_types.h
- * so we do a fixup here.
- */
-typedef u_int8_t uint8_t;
-typedef u_int16_t uint16_t;
-typedef u_int32_t uint32_t;
-#endif
-#elif defined(HAVE_CONFIG_H)
+#if defined(HAVE_CONFIG_H)
 # include "config_types.h"
-#elif defined(_WIN32) || defined(__WIN32__)
+#elif defined(_WIN32)
 # include "config_win32.h"
 #elif defined (STD_INT_USE_SYS_TYPES_H)
 # include <sys/types.h>
@@ -52,23 +40,8 @@
 # include <sys/inttypes.h>
 #elif defined (STD_INT_USE_SYS_INT_TYPES_H)
 # include <sys/int_types.h>
-#elif !defined(HAVE_STDINT_H)
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef signed char int8_t;
-typedef signed short int16_t;
-typedef signed int int32_t;
-#endif
-
-#if defined(HAVE_STDINT_H) || defined(__MACOS__)
+#else
 # include <stdint.h>
-#elif defined(__VMS) || defined(__osf__)
-# include <inttypes.h>
-#endif
-
-#ifdef __hpux
-#include <sys/_inttypes.h>
 #endif
 
 #endif /* _JBIG2_OS_TYPES_H */