Skip to content

Commit

Permalink
Tidy up config.h management (task from README)
Browse files Browse the repository at this point in the history
This fortuitously fixes the 16/32-bit 'unity' build.

Also tidy up the ckd_smul macros, for the sake of the Unity build.
  • Loading branch information
NWilson committed Jan 8, 2025
1 parent d50aa58 commit 82ee714
Show file tree
Hide file tree
Showing 49 changed files with 116 additions and 3,247 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,6 @@ if(PCRE2_BUILD_PCRE2_16)
set_target_properties(
pcre2-16-static
PROPERTIES
UNITY_BUILD OFF
COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=16
MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}"
MACHO_CURRENT_VERSION "${LIBPCRE2_32_MACHO_CURRENT_VERSION}"
Expand Down Expand Up @@ -918,7 +917,6 @@ if(PCRE2_BUILD_PCRE2_16)
set_target_properties(
pcre2-16-shared
PROPERTIES
UNITY_BUILD OFF
COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=16
MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}"
MACHO_CURRENT_VERSION "${LIBPCRE2_32_MACHO_CURRENT_VERSION}"
Expand Down Expand Up @@ -959,7 +957,6 @@ if(PCRE2_BUILD_PCRE2_32)
set_target_properties(
pcre2-32-static
PROPERTIES
UNITY_BUILD OFF
COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=32
MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}"
MACHO_CURRENT_VERSION "${LIBPCRE2_32_MACHO_CURRENT_VERSION}"
Expand Down Expand Up @@ -988,7 +985,6 @@ if(PCRE2_BUILD_PCRE2_32)
set_target_properties(
pcre2-32-shared
PROPERTIES
UNITY_BUILD OFF
COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=32
MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}"
MACHO_CURRENT_VERSION "${LIBPCRE2_32_MACHO_CURRENT_VERSION}"
Expand Down
3 changes: 0 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,7 @@ EXTRA_DIST += \
testdata/testoutput6 \
testdata/testoutput7 \
testdata/testoutput8-16-2 \
testdata/testoutput8-16-3 \
testdata/testoutput8-16-4 \
testdata/testoutput8-32-2 \
testdata/testoutput8-32-3 \
testdata/testoutput8-32-4 \
testdata/testoutput8-8-2 \
testdata/testoutput8-8-3 \
Expand Down
8 changes: 7 additions & 1 deletion RunTest
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,17 @@ for bmode in "$test8" "$test16" "$test32"; do

if [ $do8 = yes ] ; then
echo $title8
bits_link_size=$link_size
if [ $bits = "16" -a $link_size = "3" ] ; then
bits_link_size=4
elif [ $bits = "32" ] ; then
bits_link_size=4
fi
if [ $utf -eq 0 ] ; then
echo " Skipped because UTF-$bits support is not available"
else
$sim $valgrind $pcre2test -q $setstack $bmode $testdata/testinput8 testtry
checkresult $? 8-$bits-$link_size ""
checkresult $? 8-$bits-$bits_link_size ""
fi
fi

Expand Down
5 changes: 4 additions & 1 deletion RunTest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ if [%3] == [] (
)

if %1 == 8 (
set outnum=%1-%bits%-%link_size%
set bits_link_size=%link_size%
if %bits% EQU 16 if %link_size% EQU 3 set bits_link_size=4
if %bits% EQU 32 set bits_link_size=4
set outnum=%1-%bits%-!bits_link_size!
) else if %1 == 11 (
set outnum=%1-%bits%
) else if %1 == 12 (
Expand Down
3 changes: 0 additions & 3 deletions maint/GenerateUcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,6 @@ def write_bitsets(list, item_size):
headers are needed. */
#ifndef PCRE2_PCRE2TEST
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
#endif /* PCRE2_PCRE2TEST */
Expand Down
3 changes: 0 additions & 3 deletions maint/README
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,6 @@ years.
perhaps be used as a way round this problem. However, note that Perl does not
distinguish: like PCRE2, a name is just an alias for a number in Perl.

. Instead of having #ifdef HAVE_CONFIG_H in each module, put #include
"something" and the the #ifdef appears only in one place, in "something".

. Implement something like (?(R2+)... to check outer recursions.

. If Perl ever supports the POSIX notation [[.something.]] PCRE2 should try
Expand Down
3 changes: 0 additions & 3 deletions maint/manifest-tarball
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,7 @@ drwxr-xr-x tarball-dir/pcre2-SNAPSHOT/testdata
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput6
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput7
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput8-16-2
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput8-16-3
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput8-16-4
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput8-32-2
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput8-32-3
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput8-32-4
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput8-8-2
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput8-8-3
Expand Down
4 changes: 0 additions & 4 deletions maint/pcre2_chartables.c.non-standard
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "pcre2_internal.h"

const uint8_t PRIV(default_tables)[] = {
Expand Down
5 changes: 0 additions & 5 deletions maint/ucptest.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ characters, the list ends with ...
The command "list" must be followed by one of property names script, bool,
type, gbreak or bidi. The defined values for that property are listed. */


#ifdef HAVE_CONFIG_H
#include "../src/config.h"
#endif

#ifndef SUPPORT_UNICODE
#error "Unicode support not enabled"
#endif
Expand Down
6 changes: 2 additions & 4 deletions src/pcre2_auto_possess.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/


/* This module contains functions that scan a compiled pattern and change
repeats into possessive repeats where possible. */


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"


#include "pcre2_internal.h"

/* This macro represents the max size of list[] and that is used to keep
track of UCD info in several places, it should be kept on sync with the
Expand Down
4 changes: 0 additions & 4 deletions src/pcre2_chartables.c.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ PCRE2 is configured with --enable-rebuild-chartables. However, you can run
pcre2_dftables manually with the -L option to build tables using the LC_ALL
locale. */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "pcre2_internal.h"

const uint8_t PRIV(default_tables)[] = {
Expand Down
8 changes: 4 additions & 4 deletions src/pcre2_chkdint.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/


/* This file contains functions to implement checked integer operation */

#ifndef PCRE2_PCRE2TEST
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifndef PCRE2_PCRE2TEST
#include "pcre2_internal.h"
#endif



/*************************************************
* Checked Integer Multiplication *
*************************************************/
Expand Down
8 changes: 3 additions & 5 deletions src/pcre2_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ POSSIBILITY OF SUCH DAMAGE.
*/


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_compile.h"



#define NLBLOCK cb /* Block containing newline information */
#define PSSTART start_pattern /* Field containing processed string start */
#define PSEND end_pattern /* Field containing processed string end */

#include "pcre2_compile.h"

/* In rare error cases debugging might require calling pcre2_printint(). */

#if 0
Expand Down
5 changes: 2 additions & 3 deletions src/pcre2_compile_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "pcre2_compile.h"



typedef struct {
/* Option bits for eclass. */
uint32_t options;
Expand Down
11 changes: 2 additions & 9 deletions src/pcre2_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,10 @@ POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

/* Save the configured link size, which is in bytes. In 16-bit and 32-bit modes
its value gets changed by pcre2_intmodedep.h (included by pcre2_internal.h) to
be in code units. */
#include "pcre2_internal.h"

static int configured_link_size = LINK_SIZE;

#include "pcre2_internal.h"

/* These macros are the standard way of turning unquoted text into C strings.
They allow macros like PCRE2_MAJOR to be defined without quotes, which is
Expand Down Expand Up @@ -163,7 +156,7 @@ switch (what)
#endif

case PCRE2_CONFIG_LINKSIZE:
*((uint32_t *)where) = (uint32_t)configured_link_size;
*((uint32_t *)where) = (uint32_t)CONFIGURED_LINK_SIZE;
break;

case PCRE2_CONFIG_MATCHLIMIT:
Expand Down
4 changes: 0 additions & 4 deletions src/pcre2_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ POSSIBILITY OF SUCH DAMAGE.
*/


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "pcre2_internal.h"


Expand Down
6 changes: 2 additions & 4 deletions src/pcre2_convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ POSSIBILITY OF SUCH DAMAGE.
*/


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "pcre2_internal.h"



#define TYPE_OPTIONS (PCRE2_CONVERT_GLOB| \
PCRE2_CONVERT_POSIX_BASIC|PCRE2_CONVERT_POSIX_EXTENDED)

Expand Down
8 changes: 3 additions & 5 deletions src/pcre2_dfa_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,14 @@ Overall, I concluded that the gains in some cases did not outweigh the losses
in others, so I abandoned this code. */


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"



#define NLBLOCK mb /* Block containing newline information */
#define PSSTART start_subject /* Field containing processed string start */
#define PSEND end_subject /* Field containing processed string end */

#include "pcre2_internal.h"

#define PUBLIC_DFA_MATCH_OPTIONS \
(PCRE2_ANCHORED|PCRE2_ENDANCHORED|PCRE2_NOTBOL|PCRE2_NOTEOL|PCRE2_NOTEMPTY| \
PCRE2_NOTEMPTY_ATSTART|PCRE2_NO_UTF_CHECK|PCRE2_PARTIAL_HARD| \
Expand Down
17 changes: 1 addition & 16 deletions src/pcre2_dftables.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ option can be used to select the current locale from the LC_ALL environment
variable. By default, the tables are written in source form, but if -b is
given, they are written in binary. */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


#include <ctype.h>
#include <stdio.h>
Expand Down Expand Up @@ -197,20 +195,7 @@ the very long string otherwise. */
"pcre2_dftables manually with the -L option to build tables using the LC_ALL\n"
"locale. */\n\n");

/* Force config.h in z/OS */

#if defined NATIVE_ZOS
(void)fprintf(f,
"/* For z/OS, config.h is forced */\n"
"#ifndef HAVE_CONFIG_H\n"
"#define HAVE_CONFIG_H 1\n"
"#endif\n\n");
#endif

(void)fprintf(f,
"#ifdef HAVE_CONFIG_H\n"
"#include \"config.h\"\n"
"#endif\n\n"
"#include \"pcre2_internal.h\"\n\n");

(void)fprintf(f,
Expand Down
6 changes: 2 additions & 4 deletions src/pcre2_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ POSSIBILITY OF SUCH DAMAGE.
*/


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "pcre2_internal.h"



#define STRING(a) # a
#define XSTRING(s) STRING(s)

Expand Down
7 changes: 2 additions & 5 deletions src/pcre2_extuni.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,18 @@ POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/


/* This module contains an internal function that is used to match a Unicode
extended grapheme sequence. It is used by both pcre2_match() and
pcre2_dfa_match(). However, it is called only when Unicode support is being
compiled. Nevertheless, we provide a dummy function when there is no Unicode
support, because some compilers do not like functionless source files. */


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


#include "pcre2_internal.h"



/* Dummy function */

#ifndef SUPPORT_UNICODE
Expand Down
5 changes: 1 addition & 4 deletions src/pcre2_find_bracket.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,10 @@ function is called from pcre2_compile.c and also from pcre2_study.c when
finding the minimum matching length. */


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "pcre2_internal.h"



/*************************************************
* Scan compiled regex for specific bracket *
*************************************************/
Expand Down
2 changes: 0 additions & 2 deletions src/pcre2_fuzzsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ Further updates March/April/May 2024 by PH
#define PCRE2_CODE_UNIT_WIDTH 8
#endif

#include "config.h"
#include "pcre2.h"
#include "pcre2_internal.h"

#define MAX_MATCH_SIZE 1000
Expand Down
Loading

0 comments on commit 82ee714

Please sign in to comment.