On Fri, 2007 Jul 20 14:33:01 -0700, Craig Silverstein wrote:
> } I suppose we could put the PCRECPP_EXP_DEFN definitions in pcre.h,
> } if it's kosher for pcre_stringpiece.h et al. to pull in that header.
>
> Hmm, in theory pcre_stringpiece should be usable without pcre.h, but I
> don't mind having that dependency.
>
> It's nice to have all the dll-defn stuff in one file anyway, perhaps.
>
> I'm ok with either the pcre.h solution or the separate-header-file
> solution.
Okay, I've rejiggered the pcrecpp library a bit. The definitions of
PCRECPP_EXP_{DECL,DEFN} have been moved into pcre.h. Philip, if you'd
rather have these in a separate file, let me know and I'll make that
happen.
There is a new private header file here: pcrecpp_internal.h. I took a
similar approach as pcre_internal.h, where dllexport directives are found
only inside a private header. I think this works better than the
PCRE_DEFINITION switch (which is now gone).
A patch against SVN and the new header file are attached. The changelist is
the same as the first time around, modulo the above. Any questions
welcomed.
--Daniel
--
NAME = Daniel Richard G. ## Remember, skunks _\|/_ meef?
EMAIL1 = skunk@??? ## don't smell bad--- (/o|o\) /
EMAIL2 = skunk@??? ## it's the people who < (^),>
WWW = http://www.******.org/ ## annoy them that do! / \
--
(****** = site not yet online)
Index: pcrecpp.h
===================================================================
--- pcrecpp.h (revision 190)
+++ pcrecpp.h (working copy)
@@ -331,11 +331,12 @@
#include <string>
+
+#include <pcre.h>
#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 <pcre_stringpiece.h>
namespace pcrecpp {
@@ -348,7 +349,7 @@
(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 +357,7 @@
// 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_DEFN RE_Options {
public:
// constructor
RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {}
@@ -488,7 +489,7 @@
// 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_DEFN 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.
Index: pcre_scanner_unittest.cc
===================================================================
--- pcre_scanner_unittest.cc (revision 190)
+++ pcre_scanner_unittest.cc (working copy)
@@ -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>
Index: pcre_scanner.cc
===================================================================
--- pcre_scanner.cc (revision 190)
+++ pcre_scanner.cc (working copy)
@@ -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;
Index: pcre_ord2utf8.c
===================================================================
--- pcre_ord2utf8.c (revision 190)
+++ pcre_ord2utf8.c (working copy)
@@ -42,6 +42,10 @@
character value into a UTF8 string. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_fullinfo.c
===================================================================
--- pcre_fullinfo.c (revision 190)
+++ pcre_fullinfo.c (working copy)
@@ -42,6 +42,10 @@
information about a compiled pattern. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_version.c
===================================================================
--- pcre_version.c (revision 190)
+++ pcre_version.c (working copy)
@@ -42,6 +42,10 @@
string that identifies the PCRE version that is in use. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_refcount.c
===================================================================
--- pcre_refcount.c (revision 190)
+++ pcre_refcount.c (working copy)
@@ -43,6 +43,10 @@
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"
Index: pcrecpp.cc
===================================================================
--- pcrecpp.cc (revision 190)
+++ pcrecpp.cc (working copy)
@@ -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 kVecSize = (1 + kMaxArgs) * 3; // results + PCRE workspace
// Special object that stands-in for no argument
-Arg no_arg((void*)NULL);
+PCRECPP_EXP_DEFN 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 @@
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();
Index: pcrecpparg.h.in
===================================================================
--- pcrecpparg.h.in (revision 190)
+++ pcrecpparg.h.in (working copy)
@@ -35,6 +35,8 @@
#include <stdlib.h> // for NULL
#include <string>
+#include <pcre.h>
+
namespace pcrecpp {
class StringPiece;
@@ -51,7 +53,7 @@
}
};
-class Arg {
+class PCRECPP_EXP_DEFN Arg {
public:
// Empty constructor so we can declare arrays of Arg
Arg();
Index: pcre.h.in
===================================================================
--- pcre.h.in (revision 190)
+++ pcre.h.in (working copy)
@@ -51,10 +51,16 @@
export setting is defined in pcre_internal.h, which includes this file. So we
don't change an existing definition of PCRE_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 @@
#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
Index: pcre_info.c
===================================================================
--- pcre_info.c (revision 190)
+++ pcre_info.c (working copy)
@@ -43,6 +43,10 @@
deprecated, as it has been superseded by pcre_fullinfo(). */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_scanner.h
===================================================================
--- pcre_scanner.h (revision 190)
+++ pcre_scanner.h (working copy)
@@ -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);
Index: pcreposix.c
===================================================================
--- pcreposix.c (revision 190)
+++ pcreposix.c (working copy)
@@ -42,9 +42,20 @@
functions. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL)
+# define PCREPOSIX_EXP_DECL extern __declspec(dllexport)
+# define PCREPOSIX_EXP_DEFN __declspec(dllexport)
+#endif
+
+#include <pcre.h>
#include "pcre_internal.h"
#include "pcreposix.h"
-#include "stdlib.h"
Index: pcre_valid_utf8.c
===================================================================
--- pcre_valid_utf8.c (revision 190)
+++ pcre_valid_utf8.c (working copy)
@@ -42,6 +42,10 @@
strings. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcreposix.h
===================================================================
--- pcreposix.h (revision 190)
+++ pcreposix.h (working copy)
@@ -109,11 +109,9 @@
imported have to be identified as such. When building PCRE, the appropriate
export settings are needed. */
-#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. */
Index: pcre_study.c
===================================================================
--- pcre_study.c (revision 190)
+++ pcre_study.c (working copy)
@@ -42,6 +42,10 @@
supporting functions. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_tables.c
===================================================================
--- pcre_tables.c (revision 190)
+++ pcre_tables.c (working copy)
@@ -44,6 +44,10 @@
clashes with the library. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: dftables.c
===================================================================
--- dftables.c (revision 190)
+++ dftables.c (working copy)
@@ -43,6 +43,10 @@
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>
@@ -105,6 +109,9 @@
"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\n"
+ "# include <config.h>\n"
+ "#endif\n\n"
"#include \"pcre_internal.h\"\n\n");
fprintf(f,
"const unsigned char _pcre_default_tables[] = {\n\n"
Index: pcre_stringpiece_unittest.cc
===================================================================
--- pcre_stringpiece_unittest.cc (revision 190)
+++ pcre_stringpiece_unittest.cc (working copy)
@@ -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*
Index: pcre_internal.h
===================================================================
--- pcre_internal.h (revision 190)
+++ pcre_internal.h (working copy)
@@ -67,10 +67,6 @@
#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 @@
#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 @@
# define PCRE_EXP_DEFN
# define PCRE_EXP_DATA_DEFN
# endif
-#
# else
# ifdef __cplusplus
# define PCRE_EXP_DECL extern "C"
Index: pcre_exec.c
===================================================================
--- pcre_exec.c (revision 190)
+++ pcre_exec.c (working copy)
@@ -42,6 +42,10 @@
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 */
Index: pcre_stringpiece.h.in
===================================================================
--- pcre_stringpiece.h.in (revision 190)
+++ pcre_stringpiece.h.in (working copy)
@@ -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_;
Index: pcre_compile.c
===================================================================
--- pcre_compile.c (revision 190)
+++ pcre_compile.c (working copy)
@@ -42,6 +42,10 @@
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 */
@@ -701,7 +705,7 @@
*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;
Index: pcre_xclass.c
===================================================================
--- pcre_xclass.c (revision 190)
+++ pcre_xclass.c (working copy)
@@ -43,6 +43,10 @@
pcre_exec() and pcre_def_exec(). */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_newline.c
===================================================================
--- pcre_newline.c (revision 190)
+++ pcre_newline.c (working copy)
@@ -47,6 +47,10 @@
http://unicode.org/unicode/reports/tr18/. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_config.c
===================================================================
--- pcre_config.c (revision 190)
+++ pcre_config.c (working copy)
@@ -41,6 +41,10 @@
/* This module contains the external function pcre_config(). */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_maketables.c
===================================================================
--- pcre_maketables.c (revision 190)
+++ pcre_maketables.c (working copy)
@@ -45,7 +45,10 @@
#ifndef DFTABLES
-#include "pcre_internal.h"
+# ifdef HAVE_CONFIG_H
+# include <config.h>
+# endif
+# include "pcre_internal.h"
#endif
Index: pcre_ucp_searchfuncs.c
===================================================================
--- pcre_ucp_searchfuncs.c (revision 190)
+++ pcre_ucp_searchfuncs.c (working copy)
@@ -41,6 +41,10 @@
/* 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 */
Index: pcre_get.c
===================================================================
--- pcre_get.c (revision 190)
+++ pcre_get.c (working copy)
@@ -43,6 +43,10 @@
for these functions came from Scott Wimer. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_stringpiece.cc
===================================================================
--- pcre_stringpiece.cc (revision 190)
+++ pcre_stringpiece.cc (working copy)
@@ -30,8 +30,13 @@
// Author: wilsonh@??? (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) {
Index: pcretest.c
===================================================================
--- pcretest.c (revision 190)
+++ pcretest.c (working copy)
@@ -36,6 +36,10 @@
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <ctype.h>
#include <stdio.h>
#include <string.h>
Index: pcre_try_flipped.c
===================================================================
--- pcre_try_flipped.c (revision 190)
+++ pcre_try_flipped.c (working copy)
@@ -43,6 +43,10 @@
auxiliary local function to flip the appropriate bytes. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pcre_internal.h"
Index: pcre_globals.c
===================================================================
--- pcre_globals.c (revision 190)
+++ pcre_globals.c (working copy)
@@ -46,6 +46,10 @@
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
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 190)
+++ CMakeLists.txt (working copy)
@@ -58,7 +58,7 @@
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 @@
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
IF(WIN32)
- # What about -DDLL_EXPORT?
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF(WIN32)
@@ -317,7 +316,10 @@
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 @@
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
Index: pcrecpp_unittest.cc
===================================================================
--- pcrecpp_unittest.cc (revision 190)
+++ pcrecpp_unittest.cc (working copy)
@@ -33,10 +33,14 @@
//
// 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;
Index: pcre_dfa_exec.c
===================================================================
--- pcre_dfa_exec.c (revision 190)
+++ pcre_dfa_exec.c (working copy)
@@ -44,6 +44,10 @@
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 */
Index: pcregrep.c
===================================================================
--- pcregrep.c (revision 190)
+++ pcregrep.c (working copy)
@@ -855,7 +855,7 @@
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 +1625,7 @@
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;
Index: pcre_chartables.c.dist
===================================================================
--- pcre_chartables.c.dist (revision 190)
+++ pcre_chartables.c.dist (working copy)
@@ -20,6 +20,10 @@
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[] = {
Index: Makefile.am
===================================================================
--- Makefile.am (revision 190)
+++ Makefile.am (working copy)
@@ -210,6 +210,7 @@
lib_LTLIBRARIES += libpcrecpp.la
libpcrecpp_la_SOURCES = \
+ pcrecpp_internal.h \
pcrecpp.cc \
pcre_scanner.cc \
pcre_stringpiece.cc
/* pcrecpp_internal.h */
#ifndef PCRECPP_EXP_DECL
# if defined(_WIN32) && !defined(PCRE_STATIC)
# define PCRECPP_EXP_DECL extern __declspec(dllexport)
# define PCRECPP_EXP_DEFN __declspec(dllexport)
# else
# define PCRECPP_EXP_DECL extern
# define PCRECPP_EXP_DEFN
# endif
#endif
/* end pcrecpp_internal.h */