You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sc...@apache.org on 2017/07/06 17:33:13 UTC

svn commit: r1801083 - in /xerces/c/trunk: cmake/XercesIntTypes.cmake configure.ac src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in src/xercesc/util/Xerces_autoconf_config.hpp.in

Author: scantor
Date: Thu Jul  6 17:33:12 2017
New Revision: 1801083

URL: http://svn.apache.org/viewvc?rev=1801083&view=rev
Log:
Add portable bounds checking for XMLSize_t

Modified:
    xerces/c/trunk/cmake/XercesIntTypes.cmake
    xerces/c/trunk/configure.ac
    xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in
    xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.in

Modified: xerces/c/trunk/cmake/XercesIntTypes.cmake
URL: http://svn.apache.org/viewvc/xerces/c/trunk/cmake/XercesIntTypes.cmake?rev=1801083&r1=1801082&r2=1801083&view=diff
==============================================================================
--- xerces/c/trunk/cmake/XercesIntTypes.cmake (original)
+++ xerces/c/trunk/cmake/XercesIntTypes.cmake Thu Jul  6 17:33:12 2017
@@ -60,13 +60,17 @@ set(HAVE_SSIZE_T ${SSIZEOF_SSIZE_T})
 set(HAVE_WCHAR_T ${WCHAROF_WCHAR_T})
 if(SIZEOF_SIZE_T)
   set(XERCES_SIZE_T size_t)
+  set(XERCES_SIZE_MAX SIZE_MAX)
 else()
   set(XERCES_SIZE_T unsigned long)
+  set(XERCES_SIZE_MAX ULONG_MAX)
 endif()
 if(SIZEOF_SSIZE_T)
   set(XERCES_SSIZE_T ssize_t)
+  set(XERCES_SSIZE_MAX SSIZE_MAX)
 else()
   set(XERCES_SSIZE_T long)
+  set(XERCES_SSIZE_MAX LONG_MAX)
 endif()
 
 # Check type sizes

Modified: xerces/c/trunk/configure.ac
URL: http://svn.apache.org/viewvc/xerces/c/trunk/configure.ac?rev=1801083&r1=1801082&r2=1801083&view=diff
==============================================================================
--- xerces/c/trunk/configure.ac (original)
+++ xerces/c/trunk/configure.ac Thu Jul  6 17:33:12 2017
@@ -154,6 +154,24 @@ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#i
                     ]
                  )
 
+# Check for functional cstdint header
+AC_MSG_CHECKING([for cstdint])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <cstdint>]],
+[[
+  uint32_t v1 = 342;
+  int64_t v2 = -23;
+  return 0;
+]])],
+                    [
+                      AC_MSG_RESULT([yes])
+                      AC_DEFINE_UNQUOTED([XERCES_HAVE_CSTDINT], 1, [Define to 1 if cstdint is functional.])
+                    ],
+                    [
+                      AC_MSG_RESULT([no])
+                      AC_DEFINE_UNQUOTED([XERCES_HAVE_CSTDINT], 0, [Define to 1 if cstdint is functional.])
+                    ]
+                 )
+
 # The check for mbrlen, wcsrtombs and mbsrtowcs gives a false
 # positive on HP-UX, so we use a different snippet to set the
 # corresponding macro
@@ -286,6 +304,8 @@ AC_ARG_ENABLE(sse2,
 
 AC_DEFINE([XERCES_AUTOCONF], 1, [Define to true if autoconf is used in this configuration])
 
+AS_IF([test x$ac_cv_header_stdint_h = xyes],
+	AC_DEFINE([XERCES_HAVE_STDINT_H], 1, [Define to 1 if we have stdint.h]))
 AS_IF([test x$ac_cv_header_sys_types_h = xyes],
 	AC_DEFINE([XERCES_HAVE_SYS_TYPES_H], 1, [Define to 1 if we have sys/types.h]))
 AS_IF([test x$ac_cv_header_inttypes_h = xyes],
@@ -474,12 +494,16 @@ if test "$have_sse2" = "yes"; then
 fi
 
 AS_IF([test x$ac_cv_type_size_t = xyes],
-	AC_DEFINE([XERCES_SIZE_T], [size_t], [Define as the appropriate size_t type]),
-	AC_DEFINE([XERCES_SIZE_T], [unsigned long], [Define as the appropriate size_t type]))
+	AC_DEFINE([XERCES_SIZE_T], [size_t], [Define as the appropriate size_t type])
+	AC_DEFINE([XERCES_SIZE_MAX], [SIZE_MAX], [Define as the appropriate SIZE_MAX macro]),
+	AC_DEFINE([XERCES_SIZE_T], [unsigned long], [Define as the appropriate size_t type])
+	AC_DEFINE([XERCES_SIZE_MAX], [ULONG_MAX], [Define as the appropriate SIZE_MAX macro]))
 
 AS_IF([test x$ac_cv_type_ssize_t = xyes],
-	AC_DEFINE([XERCES_SSIZE_T], [ssize_t], [Define as the appropriate ssize_t type]),
-	AC_DEFINE([XERCES_SSIZE_T], [long], [Define as the appropriate ssize_t type]))
+	AC_DEFINE([XERCES_SSIZE_T], [ssize_t], [Define as the appropriate ssize_t type])
+	AC_DEFINE([XERCES_SSIZE_MAX], [SSIZE_MAX], [Define as the appropriate SSIZE_MAX macro]),
+	AC_DEFINE([XERCES_SSIZE_T], [long], [Define as the appropriate ssize_t type])
+	AC_DEFINE([XERCES_SSIZE_MAX], [LONG_MAX], [Define as the appropriate SSIZE_MAX macro]))
 
 AS_IF([test x$ac_cv_cxx_have_namespaces = xyes],
 	AC_DEFINE([XERCES_HAS_CPP_NAMESPACE], 1, [Define if namespaces is supported by the compiler]))

Modified: xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in?rev=1801083&r1=1801082&r2=1801083&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in (original)
+++ xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in Thu Jul  6 17:33:12 2017
@@ -65,7 +65,9 @@
 #define XERCES_U64BIT_INT @XERCES_U64BIT_INT@
 #define XERCES_XMLCH_T @XERCES_XMLCH_T@
 #define XERCES_SIZE_T @XERCES_SIZE_T@
+#define XERCES_SIZE_MAX @XERCES_SIZE_MAX@
 #define XERCES_SSIZE_T @XERCES_SSIZE_T@
+#define XERCES_SSIZE_MAX @XERCES_SSIZE_MAX@
 
 #cmakedefine XERCES_HAS_CPP_NAMESPACE 1
 #cmakedefine XERCES_STD_NAMESPACE 1

Modified: xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.in
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.in?rev=1801083&r1=1801082&r2=1801083&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.in (original)
+++ xerces/c/trunk/src/xercesc/util/Xerces_autoconf_config.hpp.in Thu Jul  6 17:33:12 2017
@@ -49,6 +49,8 @@
 //  These defines are set by configure as appropriate for the platform.
 // ---------------------------------------------------------------------------
 #undef XERCES_AUTOCONF
+#undef XERCES_HAVE_CSTDINT
+#undef XERCES_HAVE_STDINT_H
 #undef XERCES_HAVE_SYS_TYPES_H
 #undef XERCES_HAVE_INTTYPES_H
 #undef XERCES_HAVE_INTRIN_H
@@ -83,6 +85,14 @@
 // ---------------------------------------------------------------------------
 //  Include standard headers, if available, that we may rely on below.
 // ---------------------------------------------------------------------------
+#if defined(__cplusplus) && XERCES_HAVE_CSTDINT
+#	include <cstdint>
+#elif XERCES_HAVE_STDINT_H
+#		if defined(__cplusplus)
+#			define __STDC_LIMIT_MACROS
+#		endif
+#		include <stdint.h>
+#endif
 #if XERCES_HAVE_INTTYPES_H
 #	include <inttypes.h>
 #endif
@@ -98,6 +108,8 @@
 // ---------------------------------------------------------------------------
 typedef XERCES_SIZE_T				XMLSize_t;
 typedef XERCES_SSIZE_T				XMLSSize_t;
+#undef XERCES_SIZE_MAX
+#undef XERCES_SSIZE_MAX
 
 // ---------------------------------------------------------------------------
 //  Define our version of the XML character



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org