summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-07-31 14:39:09 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-07-31 14:39:09 +0000
commite188596ef3e912f62e3ae85c8da905a54fc41d8b (patch)
treeebd384645bf62c640a04fe0308bcbac05e8087e0
parent235d0eb42c6281f0d8a1863f866c4d2722f0cdcf (diff)
downloadpcre-e188596ef3e912f62e3ae85c8da905a54fc41d8b.tar.gz
Daniel's patch for config.h and Windows DLL declarations (not fully working).
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@199 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--CMakeLists.txt12
-rw-r--r--Makefile.am1
-rw-r--r--dftables.c9
-rw-r--r--pcre.h.in29
-rw-r--r--pcre_chartables.c.dist6
-rw-r--r--pcre_compile.c7
-rw-r--r--pcre_config.c4
-rw-r--r--pcre_dfa_exec.c4
-rw-r--r--pcre_exec.c4
-rw-r--r--pcre_fullinfo.c4
-rw-r--r--pcre_get.c4
-rw-r--r--pcre_globals.c4
-rw-r--r--pcre_info.c4
-rw-r--r--pcre_internal.h7
-rw-r--r--pcre_maketables.c5
-rw-r--r--pcre_newline.c4
-rw-r--r--pcre_ord2utf8.c5
-rw-r--r--pcre_refcount.c5
-rw-r--r--pcre_scanner.cc7
-rw-r--r--pcre_scanner.h3
-rw-r--r--pcre_scanner_unittest.cc6
-rw-r--r--pcre_stringpiece.cc6
-rw-r--r--pcre_stringpiece.h.in4
-rw-r--r--pcre_stringpiece_unittest.cc6
-rw-r--r--pcre_study.c4
-rw-r--r--pcre_tables.c4
-rw-r--r--pcre_try_flipped.c4
-rw-r--r--pcre_ucp_searchfuncs.c4
-rw-r--r--pcre_valid_utf8.c4
-rw-r--r--pcre_version.c4
-rw-r--r--pcre_xclass.c4
-rw-r--r--pcrecpp.cc13
-rw-r--r--pcrecpp.h13
-rw-r--r--pcrecpp_internal.h50
-rw-r--r--pcrecpp_unittest.cc5
-rw-r--r--pcrecpparg.h.in4
-rw-r--r--pcredemo.c7
-rw-r--r--pcregrep.c9
-rw-r--r--pcreposix.c16
-rw-r--r--pcreposix.h11
-rw-r--r--pcretest.c4
41 files changed, 250 insertions, 60 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a683995..29c7578 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,7 +58,7 @@ SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING
SET(PCRE_NEWLINE "LF" CACHE STRING
"What to recognize as a newline (one of CR, LF, CRLF, ANY).")
-SET(PCRE_NO_RECURSE ON CACHE BOOL
+SET(PCRE_NO_RECURSE OFF CACHE BOOL
"If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.")
SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING
@@ -218,7 +218,6 @@ SET(PCRECPP_SOURCES
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
IF(WIN32)
- # What about -DDLL_EXPORT?
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF(WIN32)
@@ -278,7 +277,7 @@ SET(ENV{pcretest} ${PCRETEST_EXE})
")
IF(UNIX)
- ADD_TEST(pcre_test ${CMAKE_SOURCE_DIR}/RunTest)
+ ADD_TEST(pcre_test ${CMAKE_SOURCE_DIR}/RunTest)
ADD_TEST(pcre_grep_test ${CMAKE_SOURCE_DIR}/RunGrepTest)
ENDIF(UNIX)
IF(WIN32)
@@ -317,7 +316,10 @@ FILE(GLOB man1 ${CMAKE_SOURCE_DIR}/doc/*.1)
FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3)
IF(PCRE_BUILD_PCRECPP)
- INSTALL(TARGETS pcrecpp DESTINATION lib)
+ INSTALL(TARGETS pcrecpp
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
ELSE(PCRE_BUILD_PCRECPP)
# Remove pcrecpp.3
@@ -332,6 +334,6 @@ ENDIF(PCRE_BUILD_PCRECPP)
INSTALL(FILES ${man1} DESTINATION man/man1)
INSTALL(FILES ${man3} DESTINATION man/man3)
-INSTALL(FILES ${html} DESTINATION doc/html)
+INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
# end CMakeLists.txt
diff --git a/Makefile.am b/Makefile.am
index 4fe1655..6703575 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -210,6 +210,7 @@ if WITH_PCRE_CPP
lib_LTLIBRARIES += libpcrecpp.la
libpcrecpp_la_SOURCES = \
+ pcrecpp_internal.h \
pcrecpp.cc \
pcre_scanner.cc \
pcre_stringpiece.cc
diff --git a/dftables.c b/dftables.c
index baa56a1..39e525e 100644
--- a/dftables.c
+++ b/dftables.c
@@ -43,6 +43,10 @@ character tables for PCRE. The tables are built according to the current
locale. Now that pcre_maketables is a function visible to the outside world, we
make use of its code from here in order to be consistent. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <ctype.h>
#include <stdio.h>
#include <string.h>
@@ -99,12 +103,15 @@ fprintf(f,
"tables are passed to PCRE by the application that calls it. The tables\n"
"are used only for characters whose code values are less than 256.\n\n");
fprintf(f,
- "The following #include is present because without it gcc 4.x may remove\n"
+ "The following #includes are present because without them gcc 4.x may remove\n"
"the array definition from the final binary if PCRE is built into a static\n"
"library and dead code stripping is activated. This leads to link errors.\n"
"Pulling in the header ensures that the array gets flagged as \"someone\n"
"outside this compilation unit might reference this\" and so it will always\n"
"be supplied to the linker. */\n\n"
+ "#ifdef HAVE_CONFIG_H"
+ "#include <config.h>"
+ "#endif"
"#include \"pcre_internal.h\"\n\n");
fprintf(f,
"const unsigned char _pcre_default_tables[] = {\n\n"
diff --git a/pcre.h.in b/pcre.h.in
index f6ec1b0..5e7a08e 100644
--- a/pcre.h.in
+++ b/pcre.h.in
@@ -49,12 +49,18 @@ POSSIBILITY OF SUCH DAMAGE.
/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE, the appropriate
export setting is defined in pcre_internal.h, which includes this file. So we
-don't change an existing definition of PCRE_EXP_DECL. */
+don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
-#ifndef PCRE_EXP_DECL
-# ifdef _WIN32
-# ifndef PCRE_STATIC
-# define PCRE_EXP_DECL extern __declspec(dllimport)
+#if defined(_WIN32) && !defined(PCRE_STATIC)
+# ifndef PCRE_EXP_DECL
+# define PCRE_EXP_DECL extern __declspec(dllimport)
+# endif
+# ifdef __cplusplus
+# ifndef PCRECPP_EXP_DECL
+# define PCRECPP_EXP_DECL extern __declspec(dllimport)
+# endif
+# ifndef PCRECPP_EXP_DEFN
+# define PCRECPP_EXP_DEFN __declspec(dllimport)
# endif
# endif
#endif
@@ -63,9 +69,18 @@ don't change an existing definition of PCRE_EXP_DECL. */
#ifndef PCRE_EXP_DECL
# ifdef __cplusplus
-# define PCRE_EXP_DECL extern "C"
+# define PCRE_EXP_DECL extern "C"
# else
-# define PCRE_EXP_DECL extern
+# define PCRE_EXP_DECL extern
+# endif
+#endif
+
+#ifdef __cplusplus
+# ifndef PCRECPP_EXP_DECL
+# define PCRECPP_EXP_DECL extern
+# endif
+# ifndef PCRECPP_EXP_DEFN
+# define PCRECPP_EXP_DEFN
# endif
#endif
diff --git a/pcre_chartables.c.dist b/pcre_chartables.c.dist
index 6494d8e..7769bd6 100644
--- a/pcre_chartables.c.dist
+++ b/pcre_chartables.c.dist
@@ -14,12 +14,16 @@ example ISO-8859-1. When dftables is run, it creates these tables in the
current locale. If PCRE is configured with --enable-rebuild-chartables, this
happens automatically.
-The following #include is present because without it gcc 4.x may remove the
+The following #includes are present because without the gcc 4.x may remove the
array definition from the final binary if PCRE is built into a static library
and dead code stripping is activated. This leads to link errors. Pulling in the
header ensures that the array gets flagged as "someone outside this compilation
unit might reference this" and so it will always be supplied to the linker. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
const unsigned char _pcre_default_tables[] = {
diff --git a/pcre_compile.c b/pcre_compile.c
index f5e46f5..f066714 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -42,11 +42,14 @@ POSSIBILITY OF SUCH DAMAGE.
supporting internal functions that are not used by other modules. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#define NLBLOCK cd /* Block containing newline information */
#define PSSTART start_pattern /* Field containing processed string start */
#define PSEND end_pattern /* Field containing processed string end */
-
#include "pcre_internal.h"
@@ -701,7 +704,7 @@ if (c == '{')
*negptr = TRUE;
ptr++;
}
- for (i = 0; i < sizeof(name) - 1; i++)
+ for (i = 0; i < (int)sizeof(name) - 1; i++)
{
c = *(++ptr);
if (c == 0) goto ERROR_RETURN;
diff --git a/pcre_config.c b/pcre_config.c
index 52d2594..d148f35 100644
--- a/pcre_config.c
+++ b/pcre_config.c
@@ -41,6 +41,10 @@ POSSIBILITY OF SUCH DAMAGE.
/* This module contains the external function pcre_config(). */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_dfa_exec.c b/pcre_dfa_exec.c
index 87f9746..f00b57f 100644
--- a/pcre_dfa_exec.c
+++ b/pcre_dfa_exec.c
@@ -44,6 +44,10 @@ FSM). This is NOT Perl- compatible, but it has advantages in certain
applications. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#define NLBLOCK md /* Block containing newline information */
#define PSSTART start_subject /* Field containing processed string start */
#define PSEND end_subject /* Field containing processed string end */
diff --git a/pcre_exec.c b/pcre_exec.c
index 8044815..1c7f39c 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -42,6 +42,10 @@ POSSIBILITY OF SUCH DAMAGE.
pattern matching using an NFA algorithm, trying to mimic Perl as closely as
possible. There are also some static supporting functions. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#define NLBLOCK md /* Block containing newline information */
#define PSSTART start_subject /* Field containing processed string start */
#define PSEND end_subject /* Field containing processed string end */
diff --git a/pcre_fullinfo.c b/pcre_fullinfo.c
index 797edde..031aad6 100644
--- a/pcre_fullinfo.c
+++ b/pcre_fullinfo.c
@@ -42,6 +42,10 @@ POSSIBILITY OF SUCH DAMAGE.
information about a compiled pattern. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_get.c b/pcre_get.c
index ba0c8cb..f9baee6 100644
--- a/pcre_get.c
+++ b/pcre_get.c
@@ -43,6 +43,10 @@ from the subject string after a regex match has succeeded. The original idea
for these functions came from Scott Wimer. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_globals.c b/pcre_globals.c
index dbde57e..4b62d11 100644
--- a/pcre_globals.c
+++ b/pcre_globals.c
@@ -46,6 +46,10 @@ indirection. These values can be changed by the caller, but are shared between
all threads. However, when compiling for Virtual Pascal, things are done
differently, and global variables are not used (see pcre.in). */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
#ifndef VPCOMPAT
diff --git a/pcre_info.c b/pcre_info.c
index 52ac23f..7b31894 100644
--- a/pcre_info.c
+++ b/pcre_info.c
@@ -43,6 +43,10 @@ information about a compiled pattern. However, use of this function is now
deprecated, as it has been superseded by pcre_fullinfo(). */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_internal.h b/pcre_internal.h
index 9b0c48b..eae91d8 100644
--- a/pcre_internal.h
+++ b/pcre_internal.h
@@ -67,10 +67,6 @@ be absolutely sure we get our version. */
#endif
-/* Get the definitions provided by running "configure" */
-
-#include "config.h"
-
/* Standard C headers plus the external interface definition. The only time
setjmp and stdarg are used is when NO_RECURSE is set. */
@@ -112,7 +108,7 @@ PCRE_EXP_DATA_DEFN only if they are not already set. */
#ifndef PCRE_EXP_DECL
# ifdef _WIN32
-# ifdef DLL_EXPORT
+# ifndef PCRE_STATIC
# define PCRE_EXP_DECL extern __declspec(dllexport)
# define PCRE_EXP_DEFN __declspec(dllexport)
# define PCRE_EXP_DATA_DEFN __declspec(dllexport)
@@ -121,7 +117,6 @@ PCRE_EXP_DATA_DEFN only if they are not already set. */
# define PCRE_EXP_DEFN
# define PCRE_EXP_DATA_DEFN
# endif
-#
# else
# ifdef __cplusplus
# define PCRE_EXP_DECL extern "C"
diff --git a/pcre_maketables.c b/pcre_maketables.c
index 9963e13..b8a6682 100644
--- a/pcre_maketables.c
+++ b/pcre_maketables.c
@@ -45,7 +45,10 @@ compilation of dftables.c, in which case the macro DFTABLES is defined. */
#ifndef DFTABLES
-#include "pcre_internal.h"
+ #ifdef HAVE_CONFIG_H
+ #include <config.h>
+ #endif
+ #include "pcre_internal.h"
#endif
diff --git a/pcre_newline.c b/pcre_newline.c
index ae66c73..053df61 100644
--- a/pcre_newline.c
+++ b/pcre_newline.c
@@ -47,6 +47,10 @@ and NLTYPE_ANY. The full list of Unicode newline characters is taken from
http://unicode.org/unicode/reports/tr18/. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_ord2utf8.c b/pcre_ord2utf8.c
index a727612..6378cce 100644
--- a/pcre_ord2utf8.c
+++ b/pcre_ord2utf8.c
@@ -41,7 +41,10 @@ POSSIBILITY OF SUCH DAMAGE.
/* This file contains a private PCRE function that converts an ordinal
character value into a UTF8 string. */
-
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_refcount.c b/pcre_refcount.c
index 8339019..658e627 100644
--- a/pcre_refcount.c
+++ b/pcre_refcount.c
@@ -43,6 +43,11 @@ auxiliary function that can be used to maintain a reference count in a compiled
pattern data block. This might be helpful in applications where the block is
shared by different users. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_scanner.cc b/pcre_scanner.cc
index bdc8d4d..f23716d 100644
--- a/pcre_scanner.cc
+++ b/pcre_scanner.cc
@@ -29,9 +29,14 @@
//
// Author: Sanjay Ghemawat
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <vector>
#include <assert.h>
-#include "config.h"
+
+#include "pcrecpp_internal.h"
#include "pcre_scanner.h"
using std::vector;
diff --git a/pcre_scanner.h b/pcre_scanner.h
index ab4583e..99a6832 100644
--- a/pcre_scanner.h
+++ b/pcre_scanner.h
@@ -47,12 +47,13 @@
#include <assert.h>
#include <string>
#include <vector>
+
#include <pcrecpp.h>
#include <pcre_stringpiece.h>
namespace pcrecpp {
-class Scanner {
+class PCRECPP_EXP_DEFN Scanner {
public:
Scanner();
explicit Scanner(const std::string& input);
diff --git a/pcre_scanner_unittest.cc b/pcre_scanner_unittest.cc
index 8e1a598..92d8a55 100644
--- a/pcre_scanner_unittest.cc
+++ b/pcre_scanner_unittest.cc
@@ -32,9 +32,15 @@
// Unittest for scanner, especially GetNextComments and GetComments()
// functionality.
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <stdio.h>
#include <string>
#include <vector>
+
+#include <pcrecpp.h>
#include <pcre_stringpiece.h>
#include <pcre_scanner.h>
diff --git a/pcre_stringpiece.cc b/pcre_stringpiece.cc
index dbdb509..a8e1e2c 100644
--- a/pcre_stringpiece.cc
+++ b/pcre_stringpiece.cc
@@ -30,8 +30,12 @@
// Author: wilsonh@google.com (Wilson Hsieh)
//
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <iostream>
-#include "config.h"
+#include "pcrecpp_internal.h"
#include "pcre_stringpiece.h"
std::ostream& operator<<(std::ostream& o, const pcrecpp::StringPiece& piece) {
diff --git a/pcre_stringpiece.h.in b/pcre_stringpiece.h.in
index 7cc074d..708fd0f 100644
--- a/pcre_stringpiece.h.in
+++ b/pcre_stringpiece.h.in
@@ -50,11 +50,13 @@
#include <bits/type_traits.h>
#endif
+#include <pcre.h>
+
using std::string;
namespace pcrecpp {
-class StringPiece {
+class PCRECPP_EXP_DEFN StringPiece {
private:
const char* ptr_;
int length_;
diff --git a/pcre_stringpiece_unittest.cc b/pcre_stringpiece_unittest.cc
index d6a89e8..90cad7c 100644
--- a/pcre_stringpiece_unittest.cc
+++ b/pcre_stringpiece_unittest.cc
@@ -1,9 +1,15 @@
// Copyright 2003 and onwards Google Inc.
// Author: Sanjay Ghemawat
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <stdio.h>
#include <map>
#include <algorithm> // for make_pair
+
+#include <pcrecpp.h>
#include <pcre_stringpiece.h>
// CHECK dies with a fatal error if condition is not true. It is *not*
diff --git a/pcre_study.c b/pcre_study.c
index 3cf5b59..a9b7599 100644
--- a/pcre_study.c
+++ b/pcre_study.c
@@ -42,6 +42,10 @@ POSSIBILITY OF SUCH DAMAGE.
supporting functions. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_tables.c b/pcre_tables.c
index 3e36c93..f37bf4a 100644
--- a/pcre_tables.c
+++ b/pcre_tables.c
@@ -44,6 +44,10 @@ uses macros to change their names from _pcre_xxx to xxxx, thereby avoiding name
clashes with the library. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_try_flipped.c b/pcre_try_flipped.c
index cd45968..a461ced 100644
--- a/pcre_try_flipped.c
+++ b/pcre_try_flipped.c
@@ -43,6 +43,10 @@ see if it was compiled with the opposite endianness. If so, it uses an
auxiliary local function to flip the appropriate bytes. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_ucp_searchfuncs.c b/pcre_ucp_searchfuncs.c
index 5ecba6b..06de257 100644
--- a/pcre_ucp_searchfuncs.c
+++ b/pcre_ucp_searchfuncs.c
@@ -41,6 +41,10 @@ POSSIBILITY OF SUCH DAMAGE.
/* This module contains code for searching the table of Unicode character
properties. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
#include "ucp.h" /* Category definitions */
diff --git a/pcre_valid_utf8.c b/pcre_valid_utf8.c
index 9a35a20..7decf52 100644
--- a/pcre_valid_utf8.c
+++ b/pcre_valid_utf8.c
@@ -42,6 +42,10 @@ POSSIBILITY OF SUCH DAMAGE.
strings. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_version.c b/pcre_version.c
index 1a9ecb2..0c7c1a0 100644
--- a/pcre_version.c
+++ b/pcre_version.c
@@ -42,6 +42,10 @@ POSSIBILITY OF SUCH DAMAGE.
string that identifies the PCRE version that is in use. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcre_xclass.c b/pcre_xclass.c
index 0b33351..fe74c6d 100644
--- a/pcre_xclass.c
+++ b/pcre_xclass.c
@@ -43,6 +43,10 @@ class (one that contains characters whose values are > 255). It is used by both
pcre_exec() and pcre_def_exec(). */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pcre_internal.h"
diff --git a/pcrecpp.cc b/pcrecpp.cc
index ffb873f..73f6b75 100644
--- a/pcrecpp.cc
+++ b/pcrecpp.cc
@@ -30,7 +30,7 @@
// Author: Sanjay Ghemawat
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -41,12 +41,11 @@
#include <errno.h>
#include <string>
#include <algorithm>
-// We need this to compile the proper dll on windows/msys. This is copied
-// from pcre_internal.h. It would probably be better just to include that.
-#define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
+
+#include "pcrecpp_internal.h"
#include <pcre.h>
-#include "pcre_stringpiece.h"
#include "pcrecpp.h"
+#include "pcre_stringpiece.h"
namespace pcrecpp {
@@ -56,7 +55,7 @@ static const int kMaxArgs = 16;
static const int kVecSize = (1 + kMaxArgs) * 3; // results + PCRE workspace
// Special object that stands-in for no argument
-Arg no_arg((void*)NULL);
+PCRECPP_EXP_DECL Arg no_arg((void*)NULL);
// If a regular expression has no error, its error_ field points here
static const string empty_string;
@@ -463,7 +462,7 @@ int RE::TryMatch(const StringPiece& text,
return 0;
}
- pcre_extra extra = { 0 };
+ pcre_extra extra = { 0, 0, 0, 0, 0, 0 };
if (options_.match_limit() > 0) {
extra.flags |= PCRE_EXTRA_MATCH_LIMIT;
extra.match_limit = options_.match_limit();
diff --git a/pcrecpp.h b/pcrecpp.h
index e3f1b71..cb30552 100644
--- a/pcrecpp.h
+++ b/pcrecpp.h
@@ -331,11 +331,10 @@
#include <string>
-#include <pcrecpparg.h> // defines the Arg class
-// These aren't technically needed here, but we include them
-// anyway so folks who include pcrecpp.h don't have to include
-// all these other header files as well.
#include <pcre.h>
+#include <pcrecpparg.h> // defines the Arg class
+// This isn't technically needed here, but we include it
+// anyway so folks who include pcrecpp.h don't have to.
#include <pcre_stringpiece.h>
namespace pcrecpp {
@@ -348,7 +347,7 @@ namespace pcrecpp {
(all_options_ & o) == o
// We convert user-passed pointers into special Arg objects
-extern Arg no_arg;
+PCRECPP_EXP_DECL Arg no_arg;
/***** Compiling regular expressions: the RE class *****/
@@ -356,7 +355,7 @@ extern Arg no_arg;
// along with other options we put on top of pcre.
// Only 9 modifiers, plus match_limit and match_limit_recursion,
// are supported now.
-class RE_Options {
+class PCRECPP_EXP_DECL RE_Options {
public:
// constructor
RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {}
@@ -488,7 +487,7 @@ static inline RE_Options EXTENDED() {
// Interface for regular expression matching. Also corresponds to a
// pre-compiled regular expression. An "RE" object is safe for
// concurrent use by multiple threads.
-class RE {
+class PCRECPP_EXP_DECL RE {
public:
// We provide implicit conversions from strings so that users can
// pass in a string or a "const char*" wherever an "RE" is expected.
diff --git a/pcrecpp_internal.h b/pcrecpp_internal.h
new file mode 100644
index 0000000..f4a7fd5
--- /dev/null
+++ b/pcrecpp_internal.h
@@ -0,0 +1,50 @@
+#ifndef PCRECPP_INTERNAL_H
+#define PCRECPP_INTERNAL_H
+
+/* When compiling a DLL for Windows, the exported symbols have to be declared
+using some MS magic. I found some useful information on this web page:
+http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
+information there, using __declspec(dllexport) without "extern" we have a
+definition; with "extern" we have a declaration. The settings here override the
+setting in pcrecpp.h; it defines only PCRECPP_EXP_DECL, which is all that is
+needed for applications (they just import the symbols). We use:
+
+ PCRECPP_EXP_DECL for declarations
+ PCRECPP_EXP_DEFN for definitions of exported functions
+ PCRECPP_EXP_DATA_DEFN for definitions of exported variables
+
+The reason for the two DEFN macros is that in non-Windows environments, one
+does not want to have "extern" before variable definitions because it leads to
+compiler warnings. So we distinguish between functions and variables. In
+Windows, the two should always be the same.
+
+The reason for wrapping this in #ifndef PCRECPP_EXP_DECL is so that pcretest,
+which is an application, but needs to import this file in order to "peek" at
+internals, can #include pcre.h first to get an application's-eye view.
+
+In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,
+special-purpose environments) might want to stick other stuff in front of
+exported symbols. That's why, in the non-Windows case, we set PCRECPP_EXP_DEFN and
+PCRECPP_EXP_DATA_DEFN only if they are not already set. */
+
+#ifndef PCRECPP_EXP_DECL
+# ifdef _WIN32
+# ifndef PCRECPP_STATIC
+# define PCRECPP_EXP_DECL extern __declspec(dllexport)
+# define PCRECPP_EXP_DEFN __declspec(dllexport)
+# define PCRECPP_EXP_DATA_DEFN __declspec(dllexport)
+# else
+# define PCRECPP_EXP_DECL extern
+# define PCRECPP_EXP_DEFN
+# define PCRECPP_EXP_DATA_DEFN
+# endif
+# else
+# define PCRECPP_EXP_DECL
+# define PCRECPP_EXP_DEFN
+# define PCRECPP_EXP_DATA_DEFN
+# endif
+#endif
+
+#endif
+
+/* End of pcrecpp_internal.h */
diff --git a/pcrecpp_unittest.cc b/pcrecpp_unittest.cc
index 25be7d8..901ed33 100644
--- a/pcrecpp_unittest.cc
+++ b/pcrecpp_unittest.cc
@@ -33,10 +33,13 @@
//
// TODO: Test extractions for PartialMatch/Consume
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <stdio.h>
#include <cassert>
#include <vector>
-#include "config.h"
#include "pcrecpp.h"
using pcrecpp::StringPiece;
diff --git a/pcrecpparg.h.in b/pcrecpparg.h.in
index 3e866cf..83cc44b 100644
--- a/pcrecpparg.h.in
+++ b/pcrecpparg.h.in
@@ -35,6 +35,8 @@
#include <stdlib.h> // for NULL
#include <string>
+#include <pcre.h>
+
namespace pcrecpp {
class StringPiece;
@@ -51,7 +53,7 @@ class _RE_MatchObject {
}
};
-class Arg {
+class PCRECPP_EXP_DEFN Arg {
public:
// Empty constructor so we can declare arrays of Arg
Arg();
diff --git a/pcredemo.c b/pcredemo.c
index 80aba0e..5be0899 100644
--- a/pcredemo.c
+++ b/pcredemo.c
@@ -11,15 +11,12 @@ Compile thuswise:
-R/usr/local/lib -lpcre
Replace "/usr/local/include" and "/usr/local/lib" with wherever the include and
-library files for PCRE are installed on your system. Only some operating
+library files for PCRE are installed on your system. You don't need -I and -L
+if PCRE is installed in the standard system libraries. Only some operating
systems (e.g. Solaris) use the -R option.
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#include <stdio.h>
#include <string.h>
#include <pcre.h>
diff --git a/pcregrep.c b/pcregrep.c
index f14c973..6dc3cc2 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <ctype.h>
@@ -50,8 +50,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <sys/types.h>
#include <sys/stat.h>
+
#ifdef HAVE_UNISTD_H
-# include <unistd.h>
+#include <unistd.h>
#endif
#include <pcre.h>
@@ -855,7 +856,7 @@ while (ptr < endptr)
t = end_of_line(t, endptr, &endlinelength);
linelength = t - ptr - endlinelength;
- length = multiline? endptr - ptr : linelength;
+ length = multiline? (size_t)(endptr - ptr) : linelength;
/* Extra processing for Jeffrey Friedl's debugging. */
@@ -1625,7 +1626,7 @@ for (i = 1; i < argc; i++)
else /* Special case xxx=data */
{
int oplen = equals - op->long_name;
- int arglen = (argequals == NULL)? strlen(arg) : argequals - arg;
+ int arglen = (argequals == NULL)? (int)strlen(arg) : argequals - arg;
if (oplen == arglen && strncmp(arg, op->long_name, oplen) == 0)
{
option_data = arg + arglen;
diff --git a/pcreposix.c b/pcreposix.c
index 8582fba..543b605 100644
--- a/pcreposix.c
+++ b/pcreposix.c
@@ -42,9 +42,23 @@ POSSIBILITY OF SUCH DAMAGE.
functions. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+/* Ensure that the PCREPOSIX_EXP_xxx macros are set appropriately for
+compiling these functions. This must come before including pcreposix.h, where
+they are set for an application (using these functions) if they have not
+previously been set. */
+
+#if defined(_WIN32) && !defined(PCRE_STATIC)
+# define PCREPOSIX_EXP_DECL extern __declspec(dllexport)
+# define PCREPOSIX_EXP_DEFN __declspec(dllexport)
+#endif
+
#include "pcre_internal.h"
#include "pcreposix.h"
-#include "stdlib.h"
diff --git a/pcreposix.h b/pcreposix.h
index cca559b..40ed406 100644
--- a/pcreposix.h
+++ b/pcreposix.h
@@ -107,13 +107,12 @@ typedef struct {
/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE, the appropriate
-export settings are needed. */
+export settings are needed, and are set in pcreposix.c before including this
+file. */
-#ifdef _WIN32
-# ifndef PCREPOSIX_STATIC
-# define PCREPOSIX_EXP_DECL extern __declspec(dllimport)
-# define PCREPOSIX_EXP_DEFN __declspec(dllimport)
-# endif
+#if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL)
+# define PCREPOSIX_EXP_DECL extern __declspec(dllimport)
+# define PCREPOSIX_EXP_DEFN __declspec(dllimport)
#endif
/* By default, we use the standard "extern" declarations. */
diff --git a/pcretest.c b/pcretest.c
index 9cd07ee..afa1de8 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -36,6 +36,10 @@ POSSIBILITY OF SUCH DAMAGE.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <ctype.h>
#include <stdio.h>
#include <string.h>