[Pcre-svn] [1235] code/trunk: Ensure boolean macros are #und…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1235] code/trunk: Ensure boolean macros are #undeffed in pcre.h.generic.
Revision: 1235
          http://vcs.pcre.org/viewvc?view=rev&revision=1235
Author:   ph10
Date:     2012-12-10 13:36:29 +0000 (Mon, 10 Dec 2012)


Log Message:
-----------
Ensure boolean macros are #undeffed in pcre.h.generic.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/Makefile.am
    code/trunk/configure.ac
    code/trunk/m4/pcre_visibility.m4


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2012-12-08 16:35:42 UTC (rev 1234)
+++ code/trunk/ChangeLog    2012-12-10 13:36:29 UTC (rev 1235)
@@ -11,6 +11,10 @@


 2.  Applied patch by Daniel Richard G for quashing MSVC warnings to the
     CMake config files.
+    
+3.  Revise the creation of config.h.generic so that all boolean macros are
+    #undefined, whereas non-boolean macros are #ifndef/#endif-ed. This makes
+    overriding via -D on the command line possible.  



Version 8.32 30-November-2012

Modified: code/trunk/Makefile.am
===================================================================
--- code/trunk/Makefile.am    2012-12-08 16:35:42 UTC (rev 1234)
+++ code/trunk/Makefile.am    2012-12-10 13:36:29 UTC (rev 1235)
@@ -138,14 +138,16 @@
     cp -p pcre.h $@


 # It is more complicated for config.h.generic. We need the version that results
-# from a default configuration. We can get this by doing a configure in a
-# temporary directory. However, some trickery is needed,
-# because the source directory may already be configured. If you
-# just try running configure in a new directory, it complains. For this reason,
-# we move config.status out of the way while doing the default configuration.
-# The resulting config.h is munged by perl to put #ifdefs round any #defines
-# and to get rid of any gcc-specific visibility settings. Make sure that
-# PCRE_EXP_DEFN is unset (in case it has visibility settings).
+# from a default configuration so as to get all the default values for PCRE
+# configuration macros such as MATCH_LIMIT and NEWLINE. We can get this by
+# doing a configure in a temporary directory. However, some trickery is needed,
+# because the source directory may already be configured. If you just try
+# running configure in a new directory, it complains. For this reason, we move
+# config.status out of the way while doing the default configuration. The
+# resulting config.h is munged by perl to put #ifdefs round any #defines for
+# macros with values, and to #undef all boolean macros such as HAVE_xxx and
+# SUPPORT_xxx. We also get rid of any gcc-specific visibility settings. Make
+# sure that PCRE_EXP_DEFN is unset (in case it has visibility settings).
 config.h.generic: configure.ac
     rm -rf $@ _generic
     mkdir _generic
@@ -158,8 +160,10 @@
       -e 'if(/PCRE_EXP_DEFN/){print"/* #undef PCRE_EXP_DEFN */\n";$$blank=0;next;}' \
       -e 'if(/to make a symbol visible/){next;}' \
       -e 'if(/__attribute__ \(\(visibility/){next;}' \
-      -e 'if(/^#define\s(?!PACKAGE)(\w+)/){print"#ifndef $$1\n$$_#endif\n";$$blank=0;}' \
-      -e 'else {if(/^\s*$$/){print unless $$blank; $$blank=1;} else{print;$$blank=0;}}' \
+      -e 'if(/LT_OBJDIR/){print"/* This is ignored unless you are using libtool. */\n";}' \
+      -e 'if(/^#define\s((?:HAVE|SUPPORT|STDC)_\w+)/){print"/* #undef $$1 */\n";$$blank=0;next;}' \
+      -e 'if(/^#define\s(?!PACKAGE|VERSION)(\w+)/){print"#ifndef $$1\n$$_#endif\n";$$blank=0;next;}' \
+      -e 'if(/^\s*$$/){print unless $$blank; $$blank=1;} else{print;$$blank=0;}' \
       _generic/config.h >$@
     rm -rf _generic



Modified: code/trunk/configure.ac
===================================================================
--- code/trunk/configure.ac    2012-12-08 16:35:42 UTC (rev 1234)
+++ code/trunk/configure.ac    2012-12-10 13:36:29 UTC (rev 1235)
@@ -427,21 +427,29 @@
 can cope with, allowing it to run on SunOS4 and other "close to standard"
 systems.


-In environments that support the facilities, config.h.in is converted by
-"configure", or config-cmake.h.in is converted by CMake, into config.h. If you
-are going to build PCRE "by hand" without using "configure" or CMake, you
-should copy the distributed config.h.generic to config.h, and then edit the
-macro definitions to be the way you need them. You must then add
--DHAVE_CONFIG_H to all of your compile commands, so that config.h is included
-at the start of every source.
+In environments that support the GNU autotools, config.h.in is converted into
+config.h by the "configure" script. In environments that use CMake,
+config-cmake.in is converted into config.h. If you are going to build PCRE "by
+hand" without using "configure" or CMake, you should copy the distributed
+config.h.generic to config.h, and edit the macro definitions to be the way you
+need them. You must then add -DHAVE_CONFIG_H to all of your compile commands,
+so that config.h is included at the start of every source.

Alternatively, you can avoid editing by using -D on the compiler command line
-to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H.
+to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H,
+but if you do, default values will be taken from config.h for non-boolean
+macros that are not defined on the command line.

-PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if
-HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set
-them both to 0; an emulation function will be used. */])
+Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE8 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.

+PCRE uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
+HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
+sure both macros are undefined; an emulation function will then be used. */])
+
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(limits.h sys/types.h sys/stat.h dirent.h windows.h)
@@ -838,7 +846,7 @@

 if test "$enable_valgrind" = "yes"; then
   AC_DEFINE_UNQUOTED([SUPPORT_VALGRIND], [], [
-     Valgrind support to find invalid memory reads.])
+     Define to any value for valgrind support to find invalid memory reads.])
 fi


# Platform specific issues

Modified: code/trunk/m4/pcre_visibility.m4
===================================================================
--- code/trunk/m4/pcre_visibility.m4    2012-12-08 16:35:42 UTC (rev 1234)
+++ code/trunk/m4/pcre_visibility.m4    2012-12-10 13:36:29 UTC (rev 1235)
@@ -85,5 +85,5 @@
   AC_SUBST([VISIBILITY_CXXFLAGS])
   AC_SUBST([HAVE_VISIBILITY])
   AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
-    [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
+    [Define to 1 if the compiler supports simple visibility declarations.])
 ])