[Pcre-svn] [940] code/trunk: Make stdint.h an optional inclu…

Page principale
Supprimer ce message
Auteur: Subversion repository
Date:  
À: pcre-svn
Sujet: [Pcre-svn] [940] code/trunk: Make stdint.h an optional inclusion, in case it' s not present in some systems.
Revision: 940
          http://www.exim.org/viewvc/pcre2?view=rev&revision=940
Author:   ph10
Date:     2018-06-19 18:41:01 +0100 (Tue, 19 Jun 2018)
Log Message:
-----------
Make stdint.h an optional inclusion, in case it's not present in some systems. 
Use inttypes.h instead if it exists.


Modified Paths:
--------------
    code/trunk/CMakeLists.txt
    code/trunk/ChangeLog
    code/trunk/configure.ac
    code/trunk/src/config.h.generic
    code/trunk/src/config.h.in
    code/trunk/src/pcre2.h
    code/trunk/src/pcre2.h.generic
    code/trunk/src/pcre2.h.in


Modified: code/trunk/CMakeLists.txt
===================================================================
--- code/trunk/CMakeLists.txt    2018-06-19 16:27:42 UTC (rev 939)
+++ code/trunk/CMakeLists.txt    2018-06-19 17:41:01 UTC (rev 940)
@@ -80,6 +80,7 @@
 # 2017-03-11 PH turned HEAP_MATCH_RECURSE into a NO-OP for 10.30
 # 2017-04-08 PH added HEAP_LIMIT
 # 2017-06-15 ZH added SUPPORT_JIT_SEALLOC support
+# 2018-06-19 PH added checks for stdint.h and inttypes.h


PROJECT(PCRE2 C)

@@ -113,6 +114,18 @@
 CHECK_INCLUDE_FILE(unistd.h     HAVE_UNISTD_H)
 CHECK_INCLUDE_FILE(windows.h    HAVE_WINDOWS_H)


+IF(HAVE_INTTYPES_H)
+  SET(PCRE2_HAVE_INTTYPES_H 1)
+ELSE(HAVE_INTTYPES_H)  
+  SET(PCRE2_HAVE_INTTYPES_H 0)
+ENDIF(HAVE_INTTYPES_H)
+
+IF(HAVE_STDINT_H)
+  SET(PCRE2_HAVE_STDINT_H 1)
+ELSE(HAVE_STDINT_H)
+  SET(PCRE2_HAVE_STDINT_H 0)
+ENDIF(HAVE_STDINT_H)
+
 CHECK_FUNCTION_EXISTS(bcopy     HAVE_BCOPY)
 CHECK_FUNCTION_EXISTS(memmove   HAVE_MEMMOVE)
 CHECK_FUNCTION_EXISTS(strerror  HAVE_STRERROR)


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2018-06-19 16:27:42 UTC (rev 939)
+++ code/trunk/ChangeLog    2018-06-19 17:41:01 UTC (rev 940)
@@ -70,7 +70,11 @@
 16. Another Windows related patch for pcregrep to ensure that WIN32 is 
 undefiined under Cygwin.


+17. Test for the presence of stdint.h and inttypes.h in configure and CMake and
+include whichever exists (stdint preferred) instead of unconditionally
+including stdint. This makes life easier for old and non-standard systems.

+
Version 10.31 12-February-2018
------------------------------


Modified: code/trunk/configure.ac
===================================================================
--- code/trunk/configure.ac    2018-06-19 16:27:42 UTC (rev 939)
+++ code/trunk/configure.ac    2018-06-19 17:41:01 UTC (rev 940)
@@ -435,10 +435,10 @@
 but if you do, default values will be taken from config.h for non-boolean
 macros that are not defined on the command line.


-Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be defined
-(conventionally to 1) for TRUE, and not defined at all for FALSE. All such
-macros are listed as a commented #undef in config.h.generic. Macros such as
-MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
+Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be
+defined (conventionally to 1) for TRUE, and not defined at all for FALSE. All
+such macros are listed as a commented #undef in config.h.generic. Macros such
+as MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
surrounded by #ifndef/#endif lines so that the value can be overridden by -D.

PCRE2 uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
@@ -451,6 +451,11 @@
AC_CHECK_HEADERS([windows.h], [HAVE_WINDOWS_H=1])
AC_CHECK_HEADERS([sys/wait.h], [HAVE_SYS_WAIT_H=1])

+AC_CHECK_HEADERS([stdint.h], [PCRE2_HAVE_STDINT_H=1])
+AC_CHECK_HEADERS([inttypes.h], [PCRE2_HAVE_INTTYPES_H=1])
+AC_SUBST([PCRE2_HAVE_STDINT_H])
+AC_SUBST([PCRE2_HAVE_INTTYPES_H])
+
# Conditional compilation
AM_CONDITIONAL(WITH_PCRE2_8, test "x$enable_pcre2_8" = "xyes")
AM_CONDITIONAL(WITH_PCRE2_16, test "x$enable_pcre2_16" = "xyes")

Modified: code/trunk/src/config.h.generic
===================================================================
--- code/trunk/src/config.h.generic    2018-06-19 16:27:42 UTC (rev 939)
+++ code/trunk/src/config.h.generic    2018-06-19 17:41:01 UTC (rev 940)
@@ -18,10 +18,10 @@
 but if you do, default values will be taken from config.h for non-boolean
 macros that are not defined on the command line.


-Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be defined
-(conventionally to 1) for TRUE, and not defined at all for FALSE. All such
-macros are listed as a commented #undef in config.h.generic. Macros such as
-MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
+Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be
+defined (conventionally to 1) for TRUE, and not defined at all for FALSE. All
+such macros are listed as a commented #undef in config.h.generic. Macros such
+as MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
surrounded by #ifndef/#endif lines so that the value can be overridden by -D.

PCRE2 uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if

Modified: code/trunk/src/config.h.in
===================================================================
--- code/trunk/src/config.h.in    2018-06-19 16:27:42 UTC (rev 939)
+++ code/trunk/src/config.h.in    2018-06-19 17:41:01 UTC (rev 940)
@@ -18,10 +18,10 @@
 but if you do, default values will be taken from config.h for non-boolean
 macros that are not defined on the command line.


-Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be defined
-(conventionally to 1) for TRUE, and not defined at all for FALSE. All such
-macros are listed as a commented #undef in config.h.generic. Macros such as
-MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
+Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be
+defined (conventionally to 1) for TRUE, and not defined at all for FALSE. All
+such macros are listed as a commented #undef in config.h.generic. Macros such
+as MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
surrounded by #ifndef/#endif lines so that the value can be overridden by -D.

PCRE2 uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if

Modified: code/trunk/src/pcre2.h
===================================================================
--- code/trunk/src/pcre2.h    2018-06-19 16:27:42 UTC (rev 939)
+++ code/trunk/src/pcre2.h    2018-06-19 17:41:01 UTC (rev 940)
@@ -41,11 +41,17 @@


/* The current PCRE version information. */

-#define PCRE2_MAJOR          10
-#define PCRE2_MINOR          32
-#define PCRE2_PRERELEASE     -RC1
-#define PCRE2_DATE           2018-02-19
+#define PCRE2_MAJOR           10
+#define PCRE2_MINOR           32
+#define PCRE2_PRERELEASE      -RC1
+#define PCRE2_DATE            2018-02-19


+/* For the benefit of systems without stdint.h, an alternative is to use
+inttypes.h. The existence of these headers is checked by configure or CMake. */
+
+#define PCRE2_HAVE_STDINT_H 1
+#define PCRE2_HAVE_INTTYPES_H 1
+
/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE2, the appropriate
export setting is defined in pcre2_internal.h, which includes this file. So we
@@ -81,12 +87,18 @@
#define PCRE2_CALL_CONVENTION
#endif

-/* Have to include limits.h, stdlib.h and stdint.h to ensure that size_t and
-uint8_t, UCHAR_MAX, etc are defined. */
+/* Have to include limits.h, stdlib.h and stdint.h (or inttypes.h) to ensure
+that size_t and uint8_t, UCHAR_MAX, etc are defined. If the system has neither
+header, the relevant values must be provided by some other means. */

#include <limits.h>
#include <stdlib.h>
+
+#if PCRE2_HAVE_STDINT_H
#include <stdint.h>
+#elif PCRE2_HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif

/* Allow for C++ users compiling this directly. */


Modified: code/trunk/src/pcre2.h.generic
===================================================================
--- code/trunk/src/pcre2.h.generic    2018-06-19 16:27:42 UTC (rev 939)
+++ code/trunk/src/pcre2.h.generic    2018-06-19 17:41:01 UTC (rev 940)
@@ -41,11 +41,17 @@


/* The current PCRE version information. */

-#define PCRE2_MAJOR          10
-#define PCRE2_MINOR          32
-#define PCRE2_PRERELEASE     -RC1
-#define PCRE2_DATE           2018-02-19
+#define PCRE2_MAJOR           10
+#define PCRE2_MINOR           32
+#define PCRE2_PRERELEASE      -RC1
+#define PCRE2_DATE            2018-02-19


+/* For the benefit of systems without stdint.h, an alternative is to use
+inttypes.h. The existence of these headers is checked by configure or CMake. */
+
+#define PCRE2_HAVE_STDINT_H 1
+#define PCRE2_HAVE_INTTYPES_H 1
+
/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE2, the appropriate
export setting is defined in pcre2_internal.h, which includes this file. So we
@@ -81,12 +87,18 @@
#define PCRE2_CALL_CONVENTION
#endif

-/* Have to include limits.h, stdlib.h and stdint.h to ensure that size_t and
-uint8_t, UCHAR_MAX, etc are defined. */
+/* Have to include limits.h, stdlib.h and stdint.h (or inttypes.h) to ensure
+that size_t and uint8_t, UCHAR_MAX, etc are defined. If the system has neither
+header, the relevant values must be provided by some other means. */

#include <limits.h>
#include <stdlib.h>
+
+#if PCRE2_HAVE_STDINT_H
#include <stdint.h>
+#elif PCRE2_HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif

/* Allow for C++ users compiling this directly. */


Modified: code/trunk/src/pcre2.h.in
===================================================================
--- code/trunk/src/pcre2.h.in    2018-06-19 16:27:42 UTC (rev 939)
+++ code/trunk/src/pcre2.h.in    2018-06-19 17:41:01 UTC (rev 940)
@@ -41,11 +41,17 @@


/* The current PCRE version information. */

-#define PCRE2_MAJOR          @PCRE2_MAJOR@
-#define PCRE2_MINOR          @PCRE2_MINOR@
-#define PCRE2_PRERELEASE     @PCRE2_PRERELEASE@
-#define PCRE2_DATE           @PCRE2_DATE@
+#define PCRE2_MAJOR           @PCRE2_MAJOR@
+#define PCRE2_MINOR           @PCRE2_MINOR@
+#define PCRE2_PRERELEASE      @PCRE2_PRERELEASE@
+#define PCRE2_DATE            @PCRE2_DATE@


+/* For the benefit of systems without stdint.h, an alternative is to use
+inttypes.h. The existence of these headers is checked by configure or CMake. */
+
+#define PCRE2_HAVE_STDINT_H @PCRE2_HAVE_STDINT_H@
+#define PCRE2_HAVE_INTTYPES_H @PCRE2_HAVE_INTTYPES_H@
+
/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE2, the appropriate
export setting is defined in pcre2_internal.h, which includes this file. So we
@@ -81,12 +87,18 @@
#define PCRE2_CALL_CONVENTION
#endif

-/* Have to include limits.h, stdlib.h and stdint.h to ensure that size_t and
-uint8_t, UCHAR_MAX, etc are defined. */
+/* Have to include limits.h, stdlib.h and stdint.h (or inttypes.h) to ensure
+that size_t and uint8_t, UCHAR_MAX, etc are defined. If the system has neither
+header, the relevant values must be provided by some other means. */

#include <limits.h>
#include <stdlib.h>
+
+#if PCRE2_HAVE_STDINT_H
#include <stdint.h>
+#elif PCRE2_HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif

/* Allow for C++ users compiling this directly. */