diff --git a/.gitignore b/.gitignore index 7dacbcbce..9a8b947ae 100644 --- a/.gitignore +++ b/.gitignore @@ -40,15 +40,19 @@ missing pcre2-config pcre2_dftables pcre2_jit_test +pcre2_jit_test.exe pcre2_jit_test.log pcre2_jit_test.trs pcre2posix_test +pcre2posix_test.exe pcre2posix_test.log pcre2posix_test.trs pcre2demo pcre2fuzzcheck pcre2grep +pcre2grep.exe pcre2test +pcre2test.exe test-driver test-suite.log test3input diff --git a/CMakeLists.txt b/CMakeLists.txt index b2915f855..bd8fe374b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,13 +102,15 @@ # 2022-12-10 PH added support for pcre2posix_test # 2023-01-15 Carlo added C99 as the minimum required -# Increased minimum to 2.8.5 to support GNUInstallDirs. -# Increased minimum to 3.1 to support imported targets. -CMAKE_MINIMUM_REQUIRED(VERSION 3.1) +# Increased minimum to 3.3 to support visibility. +CMAKE_MINIMUM_REQUIRED(VERSION 3.3) PROJECT(PCRE2 C) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED TRUE) +set(CMAKE_C_VISIBILITY_PRESET hidden) +cmake_policy(SET CMP0063 NEW) + # Set policy CMP0026 to avoid warnings for the use of LOCATION in # GET_TARGET_PROPERTY. This should no longer be required. # CMAKE_POLICY(SET CMP0026 OLD) @@ -156,7 +158,7 @@ CHECK_SYMBOL_EXISTS(strerror "string.h" HAVE_STRERROR) CHECK_C_SOURCE_COMPILES( "#include #include - int main(int c, char *v[]) { char buf[PATH_MAX]; realpath(v[1], buf); return 0; }" + int main(int c, char *v[]) { char buf[PATH_MAX]; realpath(v[c], buf); return 0; }" HAVE_REALPATH ) @@ -165,14 +167,28 @@ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") CHECK_C_SOURCE_COMPILES( "#include - int main() { int a,b; size_t m; __builtin_mul_overflow(a,b,&m); return 0; }" + int main(void) { int a,b; size_t m; __builtin_mul_overflow(a,b,&m); return 0; }" HAVE_BUILTIN_MUL_OVERFLOW ) CHECK_C_SOURCE_COMPILES( - "int main() { char buf[128] __attribute__((uninitialized)); (void)buf; return 0; }" + "int main(void) { char buf[128] __attribute__((uninitialized)); (void)buf; return 0; }" HAVE_ATTRIBUTE_UNINITIALIZED ) + +CHECK_C_SOURCE_COMPILES([=[ + extern __attribute__ ((visibility ("default"))) int f(void); + int main(void) { return f(); } + int f(void) { return 42; } + ]=] HAVE_VISIBILITY +) + +if (HAVE_VISIBILITY) + set(PCRE2_EXPORT [=[__attribute__ ((visibility ("default")))]=]) +else() + set(PCRE2_EXPORT) +endif() + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) # Check whether Intel CET is enabled, and if so, adjust compiler flags. This @@ -191,8 +207,6 @@ IF (INTEL_CET_ENABLED) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mshstk") ENDIF(INTEL_CET_ENABLED) - - # User-configurable options # # Note: CMakeSetup displays these in alphabetical order, regardless of @@ -729,7 +743,6 @@ IF(PCRE2_BUILD_PCRE2_8) VERSION ${LIBPCRE2_POSIX_VERSION} SOVERSION ${LIBPCRE2_POSIX_SOVERSION}) TARGET_LINK_LIBRARIES(pcre2-posix-static pcre2-8-static) - TARGET_COMPILE_DEFINITIONS(pcre2-posix-static PUBLIC PCRE2_STATIC) TARGET_INCLUDE_DIRECTORIES(pcre2-posix-static PUBLIC ${PROJECT_BINARY_DIR}) SET(targets ${targets} pcre2-posix-static) @@ -759,6 +772,7 @@ IF(PCRE2_BUILD_PCRE2_8) TARGET_LINK_LIBRARIES(pcre2-8-shared Threads::Threads) ENDIF(REQUIRE_PTHREAD) SET(targets ${targets} pcre2-8-shared) + ADD_LIBRARY(pcre2-posix-shared SHARED ${PCRE2POSIX_HEADERS} ${PCRE2POSIX_SOURCES}) TARGET_INCLUDE_DIRECTORIES(pcre2-posix-shared PUBLIC ${PROJECT_BINARY_DIR}) SET_TARGET_PROPERTIES(pcre2-posix-shared PROPERTIES @@ -768,6 +782,7 @@ IF(PCRE2_BUILD_PCRE2_8) VERSION ${LIBPCRE2_POSIX_VERSION} SOVERSION ${LIBPCRE2_POSIX_SOVERSION} OUTPUT_NAME pcre2-posix) + TARGET_COMPILE_DEFINITIONS(pcre2-posix-shared PUBLIC PCRE2POSIX_SHARED) TARGET_LINK_LIBRARIES(pcre2-posix-shared pcre2-8-shared) SET(targets ${targets} pcre2-posix-shared) SET(dll_pdb_files ${PROJECT_BINARY_DIR}/pcre2-8.pdb ${dll_pdb_files}) diff --git a/Makefile.am b/Makefile.am index 00cef59a6..b5d6a7c2f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -292,8 +292,7 @@ src/pcre2.h.generic: src/pcre2.h.in configure.ac # 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 PCRE2_EXP_DEFN is unset (in case it has visibility settings). +# SUPPORT_xxx. We also get rid of any gcc-specific visibility settings. src/config.h.generic: configure.ac rm -rf $@ _generic @@ -304,9 +303,7 @@ src/config.h.generic: configure.ac test -f _generic/src/config.h perl -n \ -e 'BEGIN{$$blank=0;}' \ - -e 'if(/PCRE2_EXP_DEFN/){print"/* #undef PCRE2_EXP_DEFN */\n";$$blank=0;next;}' \ - -e 'if(/to make a symbol visible/){next;}' \ - -e 'if(/__attribute__ \(\(visibility/){next;}' \ + -e 'if(/(.+?)\s*__attribute__ \(\(visibility/){print"$$1\n";$$blank=0;next;}' \ -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;}' \ @@ -518,7 +515,7 @@ if WITH_PCRE2_8 lib_LTLIBRARIES += libpcre2-posix.la libpcre2_posix_la_SOURCES = src/pcre2posix.c libpcre2_posix_la_CFLAGS = \ - -DPCRE2_CODE_UNIT_WIDTH=8 \ + -DPCRE2_CODE_UNIT_WIDTH=8 @PCRE2POSIX_CFLAG@ \ $(VISIBILITY_CFLAGS) $(AM_CFLAGS) libpcre2_posix_la_LDFLAGS = $(EXTRA_LIBPCRE2_POSIX_LDFLAGS) libpcre2_posix_la_LIBADD = libpcre2-8.la @@ -570,7 +567,7 @@ if WITH_PCRE2_8 TESTS += pcre2posix_test noinst_PROGRAMS += pcre2posix_test pcre2posix_test_SOURCES = src/pcre2posix_test.c -pcre2posix_test_CFLAGS = $(AM_CFLAGS) +pcre2posix_test_CFLAGS = $(AM_CFLAGS) @PCRE2POSIX_CFLAG@ pcre2posix_test_LDADD = libpcre2-posix.la libpcre2-8.la endif # WITH_PCRE2_8 diff --git a/NON-AUTOTOOLS-BUILD b/NON-AUTOTOOLS-BUILD index 9864523fe..c0b9eed9b 100644 --- a/NON-AUTOTOOLS-BUILD +++ b/NON-AUTOTOOLS-BUILD @@ -159,7 +159,8 @@ example. (7) If you want to build the POSIX wrapper functions (which apply only to the 8-bit library), ensure that you have the src/pcre2posix.h file and then compile src/pcre2posix.c. Link the result (on its own) as the pcre2posix - library. + library. If targeting a DLL in Windows, make sure to include + -DPCRE2POSIX_SHARED with your compiler flags. (8) The pcre2test program can be linked with any combination of the 8-bit, 16-bit and 32-bit libraries (depending on what you specfied in diff --git a/config-cmake.h.in b/config-cmake.h.in index 8ef0e11eb..73032f65c 100644 --- a/config-cmake.h.in +++ b/config-cmake.h.in @@ -3,7 +3,6 @@ #cmakedefine HAVE_BUILTIN_MUL_OVERFLOW 1 #cmakedefine HAVE_ATTRIBUTE_UNINITIALIZED 1 #cmakedefine HAVE_DIRENT_H 1 -#cmakedefine HAVE_STRERROR 1 #cmakedefine HAVE_SYS_STAT_H 1 #cmakedefine HAVE_SYS_TYPES_H 1 #cmakedefine HAVE_UNISTD_H 1 @@ -40,6 +39,7 @@ #cmakedefine HEAP_MATCH_RECURSE 1 #cmakedefine NEVER_BACKSLASH_C 1 +#define PCRE2_EXPORT @PCRE2_EXPORT@ #define LINK_SIZE @PCRE2_LINK_SIZE@ #define HEAP_LIMIT @PCRE2_HEAP_LIMIT@ #define MATCH_LIMIT @PCRE2_MATCH_LIMIT@ diff --git a/configure.ac b/configure.ac index f488b8875..0cbd6df3f 100644 --- a/configure.ac +++ b/configure.ac @@ -640,6 +640,12 @@ if test "x$enable_shared" = "xno" ; then fi AC_SUBST(PCRE2_STATIC_CFLAG) +PCRE2POSIX_CFLAG="" +if test "x$enable_shared" = "xyes" ; then + PCRE2POSIX_CFLAG="-DPCRE2POSIX_SHARED" +fi +AC_SUBST(PCRE2POSIX_CFLAG) + # Here is where PCRE2-specific defines are handled if test "$enable_pcre2_8" = "yes"; then @@ -812,7 +818,7 @@ AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [ matching attempt. The value is also used to limit a loop counter in pcre2_dfa_match(). There is a runtime interface for setting a different limit. The limit exists in order to catch runaway regular expressions that - take for ever to determine that they do not match. The default is set very + take forever to determine that they do not match. The default is set very large so that it does not accidentally catch legitimate cases.]) # --with-match-limit-recursion is an obsolete synonym for --with-match-limit-depth @@ -862,8 +868,9 @@ AH_VERBATIM([PCRE2_EXP_DEFN], [ Win32, and it needs some magic to be inserted before the definition of a function that is exported by the library, define this macro to contain the relevant magic. If you do not define this macro, a suitable - __declspec value is used for Windows systems; in other environments - "extern" is used for a C compiler and "extern C" for a C++ compiler. + __declspec value is used for Windows systems; in other environments + a compiler relevant "extern" is used with any "visibility" related + attributes from PCRE2_EXPORT included. This macro apears at the start of every exported function that is part of the external API. It does not appear on functions that are "external" in the C sense, but which are internal to the library. */ diff --git a/doc/pcre2posix.3 b/doc/pcre2posix.3 index 6cfede7eb..e02f704c0 100644 --- a/doc/pcre2posix.3 +++ b/doc/pcre2posix.3 @@ -1,4 +1,4 @@ -.TH PCRE2POSIX 3 "26 April 2021" "PCRE2 10.37" +.TH PCRE2POSIX 3 "13 May 2023" "PCRE2 10.43" .SH NAME PCRE2 - Perl-compatible regular expressions (revised API) .SH "SYNOPSIS" @@ -44,7 +44,12 @@ can be accessed by adding \fB-lpcre2-posix\fP to the command for linking an application. Because the POSIX functions call the native ones, it is also necessary to add \fB-lpcre2-8\fP. .P -Although they were not defined as protypes in \fBpcre2posix.h\fP, releases +On Windows systems, if you are linking to a DLL version of the library, it is +recommended that \fBPCRE2POSIX_SHARED\fP is defined before including the +\fBpcre2posix.h\fP header, as it will allow for a more efficient way to +invoke the functions by adding the \fB__declspec(dllimport)\fP decorator. +.P +Although they were not defined as prototypes in \fBpcre2posix.h\fP, releases 10.33 to 10.36 of the library contained functions with the POSIX names \fBregcomp()\fP etc. These simply passed their arguments to the PCRE2 functions. These functions were provided for backwards compatibility with diff --git a/libpcre2-posix.pc.in b/libpcre2-posix.pc.in index 758c30688..2f1e8f102 100644 --- a/libpcre2-posix.pc.in +++ b/libpcre2-posix.pc.in @@ -9,5 +9,5 @@ Name: libpcre2-posix Description: Posix compatible interface to libpcre2-8 Version: @PACKAGE_VERSION@ Libs: -L${libdir} -lpcre2-posix@LIB_POSTFIX@ -Cflags: -I${includedir} @PCRE2_STATIC_CFLAG@ +Cflags: -I${includedir} @PCRE2POSIX_CFLAG@ Requires.private: libpcre2-8 diff --git a/m4/pcre2_visibility.m4 b/m4/pcre2_visibility.m4 index 480f2eefe..ae00de06e 100644 --- a/m4/pcre2_visibility.m4 +++ b/m4/pcre2_visibility.m4 @@ -73,10 +73,9 @@ AC_DEFUN([PCRE2_VISIBILITY], VISIBILITY_CFLAGS="-fvisibility=hidden" VISIBILITY_CXXFLAGS="-fvisibility=hidden -fvisibility-inlines-hidden" HAVE_VISIBILITY=1 - AC_DEFINE(PCRE2_EXP_DECL, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible]) - AC_DEFINE(PCRE2_EXP_DEFN, [__attribute__ ((visibility ("default")))], [to make a symbol visible]) - AC_DEFINE(PCRE2POSIX_EXP_DECL, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible]) - AC_DEFINE(PCRE2POSIX_EXP_DEFN, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible]) + AC_DEFINE(PCRE2_EXPORT, [__attribute__ ((visibility ("default")))], [to make a symbol visible]) + else + AC_DEFINE(PCRE2_EXPORT, [], [to make a symbol visible]) fi fi AC_SUBST([VISIBILITY_CFLAGS]) diff --git a/src/config.h.generic b/src/config.h.generic index 8c8c25e60..e140ae8f5 100644 --- a/src/config.h.generic +++ b/src/config.h.generic @@ -184,7 +184,7 @@ sure both macros are undefined; an emulation function will then be used. */ matching attempt. The value is also used to limit a loop counter in pcre2_dfa_match(). There is a runtime interface for setting a different limit. The limit exists in order to catch runaway regular expressions that - take for ever to determine that they do not match. The default is set very + take forever to determine that they do not match. The default is set very large so that it does not accidentally catch legitimate cases. */ #ifndef MATCH_LIMIT #define MATCH_LIMIT 10000000 @@ -239,7 +239,7 @@ sure both macros are undefined; an emulation function will then be used. */ #define PACKAGE_NAME "PCRE2" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "PCRE2 10.42" +#define PACKAGE_STRING "PCRE2 10.43-DEV" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "pcre2" @@ -248,7 +248,7 @@ sure both macros are undefined; an emulation function will then be used. */ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "10.42" +#define PACKAGE_VERSION "10.43-DEV" /* The value of PARENS_NEST_LIMIT specifies the maximum depth of nested parentheses (of any kind) in a pattern. This limits the amount of system @@ -278,12 +278,16 @@ sure both macros are undefined; an emulation function will then be used. */ /* Define to any value to include debugging code. */ /* #undef PCRE2_DEBUG */ +/* to make a symbol visible */ +#define PCRE2_EXPORT + /* If you are compiling for a system other than a Unix-like system or Win32, and it needs some magic to be inserted before the definition of a function that is exported by the library, define this macro to contain the relevant magic. If you do not define this macro, a suitable - __declspec value is used for Windows systems; in other environments - "extern" is used for a C compiler and "extern C" for a C++ compiler. + __declspec value is used for Windows systems; in other environments + a compiler relevant "extern" is used with any "visibility" related + attributes from PCRE2_EXPORT included. This macro apears at the start of every exported function that is part of the external API. It does not appear on functions that are "external" in the C sense, but which are internal to the library. */ @@ -441,7 +445,7 @@ sure both macros are undefined; an emulation function will then be used. */ #endif /* Version number of package */ -#define VERSION "10.42" +#define VERSION "10.43-DEV" /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _FILE_OFFSET_BITS */ diff --git a/src/config.h.in b/src/config.h.in index d9d7c6686..f53fb77a1 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -177,7 +177,7 @@ sure both macros are undefined; an emulation function will then be used. */ matching attempt. The value is also used to limit a loop counter in pcre2_dfa_match(). There is a runtime interface for setting a different limit. The limit exists in order to catch runaway regular expressions that - take for ever to determine that they do not match. The default is set very + take forever to determine that they do not match. The default is set very large so that it does not accidentally catch legitimate cases. */ #undef MATCH_LIMIT @@ -252,25 +252,20 @@ sure both macros are undefined; an emulation function will then be used. */ allows for the buffering of "before" and "after" lines. */ #undef PCRE2GREP_MAX_BUFSIZE -/* to make a symbol visible */ -#undef PCRE2POSIX_EXP_DECL - -/* to make a symbol visible */ -#undef PCRE2POSIX_EXP_DEFN - /* Define to any value to include debugging code. */ #undef PCRE2_DEBUG /* to make a symbol visible */ -#undef PCRE2_EXP_DECL +#undef PCRE2_EXPORT /* If you are compiling for a system other than a Unix-like system or Win32, and it needs some magic to be inserted before the definition of a function that is exported by the library, define this macro to contain the relevant magic. If you do not define this macro, a suitable - __declspec value is used for Windows systems; in other environments - "extern" is used for a C compiler and "extern C" for a C++ compiler. + __declspec value is used for Windows systems; in other environments + a compiler relevant "extern" is used with any "visibility" related + attributes from PCRE2_EXPORT included. This macro apears at the start of every exported function that is part of the external API. It does not appear on functions that are "external" in the C sense, but which are internal to the library. */ diff --git a/src/pcre2_internal.h b/src/pcre2_internal.h index 5e7796a9d..575eaa5b3 100644 --- a/src/pcre2_internal.h +++ b/src/pcre2_internal.h @@ -119,20 +119,20 @@ only if it is not already set. */ #ifndef PCRE2_EXP_DECL # ifdef _WIN32 # ifndef PCRE2_STATIC -# define PCRE2_EXP_DECL extern __declspec(dllexport) -# define PCRE2_EXP_DEFN __declspec(dllexport) +# define PCRE2_EXP_DECL extern __declspec(dllexport) +# define PCRE2_EXP_DEFN __declspec(dllexport) # else -# define PCRE2_EXP_DECL extern +# define PCRE2_EXP_DECL extern PCRE2_EXPORT # define PCRE2_EXP_DEFN # endif # else # ifdef __cplusplus -# define PCRE2_EXP_DECL extern "C" +# define PCRE2_EXP_DECL extern "C" PCRE2_EXPORT # else -# define PCRE2_EXP_DECL extern +# define PCRE2_EXP_DECL extern PCRE2_EXPORT # endif # ifndef PCRE2_EXP_DEFN -# define PCRE2_EXP_DEFN PCRE2_EXP_DECL +# define PCRE2_EXP_DEFN PCRE2_EXP_DECL # endif # endif #endif diff --git a/src/pcre2posix.c b/src/pcre2posix.c index a15174dca..b926951b1 100644 --- a/src/pcre2posix.c +++ b/src/pcre2posix.c @@ -40,25 +40,27 @@ POSSIBILITY OF SUCH DAMAGE. /* This module is a wrapper that provides a POSIX API to the underlying PCRE2 -functions. The operative functions are called pcre2_regcomp(), etc., with -wrappers that use the plain POSIX names. In addition, pcre2posix.h defines the -POSIX names as macros for the pcre2_xxx functions, so any program that includes -it and uses the POSIX names will call the base functions directly. This makes -it easier for an application to be sure it gets the PCRE2 versions in the -presence of other POSIX regex libraries. */ +functions. The functions are called pcre2_regcomp(), pcre2_regexec(), etc. +pcre2posix.h defines the POSIX names as macros for the corresonding pcre2_xxx +functions, so any program that includes it and uses the POSIX names will call +the PCRE2 implementations instead. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#ifdef PCRE2POSIX_SHARED +#undef PCRE2_STATIC +#endif + /* Ensure that the PCRE2POSIX_EXP_xxx macros are set appropriately for compiling these functions. This must come before including pcre2posix.h, where they are set for an application (using these functions) if they have not previously been set. */ -#if defined(_WIN32) && !defined(PCRE2_STATIC) +#if defined(_WIN32) && (defined(PCRE2POSIX_SHARED) || !defined(PCRE2_STATIC)) # define PCRE2POSIX_EXP_DECL extern __declspec(dllexport) # define PCRE2POSIX_EXP_DEFN __declspec(dllexport) #endif @@ -162,66 +164,6 @@ static const char *const pstring[] = { -#if 0 /* REMOVE THIS CODE */ - -The code below was created for 10.33 (see ChangeLog 10.33 #4) when the -POSIX functions were given pcre2_... names instead of the traditional POSIX -names. However, it has proved to be more troublesome than useful. There have -been at least two cases where a program links with two others, one of which -uses the POSIX library and the other uses the PCRE2 POSIX functions, thus -causing two instances of the POSIX runctions to exist, leading to trouble. For -10.37 this code is commented out. In due course it can be removed if there are -no issues. The only small worry is the comment below about languages that do -not include pcre2posix.h. If there are any such cases, they will have to use -the PCRE2 names. - - -/************************************************* -* Wrappers with traditional POSIX names * -*************************************************/ - -/* Keep defining them to preseve the ABI for applications linked to the pcre2 -POSIX library before these names were changed into macros in pcre2posix.h. -This also ensures that the POSIX names are callable from languages that do not -include pcre2posix.h. It is vital to #undef the macro definitions from -pcre2posix.h! */ - -#undef regerror -PCRE2POSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t); -PCRE2POSIX_EXP_DEFN size_t PCRE2_CALL_CONVENTION -regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) -{ -return pcre2_regerror(errcode, preg, errbuf, errbuf_size); -} - -#undef regfree -PCRE2POSIX_EXP_DECL void regfree(regex_t *); -PCRE2POSIX_EXP_DEFN void PCRE2_CALL_CONVENTION -regfree(regex_t *preg) -{ -pcre2_regfree(preg); -} - -#undef regcomp -PCRE2POSIX_EXP_DECL int regcomp(regex_t *, const char *, int); -PCRE2POSIX_EXP_DEFN int PCRE2_CALL_CONVENTION -regcomp(regex_t *preg, const char *pattern, int cflags) -{ -return pcre2_regcomp(preg, pattern, cflags); -} - -#undef regexec -PCRE2POSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t, - regmatch_t *, int); -PCRE2POSIX_EXP_DEFN int PCRE2_CALL_CONVENTION -regexec(const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags) -{ -return pcre2_regexec(preg, string, nmatch, pmatch, eflags); -} -#endif - - /************************************************* * Translate error code to string * *************************************************/ diff --git a/src/pcre2posix.h b/src/pcre2posix.h index 6e3b2cff9..2cb0fe87c 100644 --- a/src/pcre2posix.h +++ b/src/pcre2posix.h @@ -130,25 +130,25 @@ set, we ensure here that it has no effect. */ #define PCRE2_CALL_CONVENTION #endif + +#ifndef PCRE2_EXPORT +#define PCRE2_EXPORT +#endif + /* When an application links to a PCRE2 DLL in Windows, the symbols that are imported have to be identified as such. When building PCRE2, the appropriate export settings are needed, and are set in pcre2posix.c before including this file. */ -#if defined(_WIN32) && !defined(PCRE2_STATIC) && !defined(PCRE2POSIX_EXP_DECL) -# define PCRE2POSIX_EXP_DECL extern __declspec(dllimport) -# define PCRE2POSIX_EXP_DEFN __declspec(dllimport) -#endif - /* By default, we use the standard "extern" declarations. */ #ifndef PCRE2POSIX_EXP_DECL -# ifdef __cplusplus -# define PCRE2POSIX_EXP_DECL extern "C" -# define PCRE2POSIX_EXP_DEFN extern "C" +# if defined(_WIN32) && defined(PCRE2POSIX_SHARED) && !defined(PCRE2_STATIC) +# define PCRE2POSIX_EXP_DECL extern __declspec(dllimport) +# define PCRE2POSIX_EXP_DEFN __declspec(dllimport) # else -# define PCRE2POSIX_EXP_DECL extern -# define PCRE2POSIX_EXP_DEFN extern +# define PCRE2POSIX_EXP_DECL extern PCRE2_EXPORT +# define PCRE2POSIX_EXP_DEFN # endif #endif