Rename files which are #included (#708)

We have four files which have .c extensions, but which are actually #included rather than treated as their own compilation unit.

This goes against conventions - Autotools, CMake, and Bazel all assume that the .h/.c distinction indicates which files are compilation units.

pcre2_jit_match.c -> _inc.h
pcre2_jit_misc.c -> _inc.h
pcre2_printint.c -> _inc.h
pcre2_ucptables.c -> _inc.h
This commit is contained in:
Nicholas Wilson
2025-02-27 06:57:44 +00:00
committed by GitHub
parent d9a49724de
commit b79ee1dea5
22 changed files with 55 additions and 83 deletions

View File

@@ -20,9 +20,6 @@ copy_file(
out = "src/pcre2_chartables.c",
)
# Removed src/pcre2_ucptables.c below because it is #included in
# src/pcre2_tables.c. Also fixed typo: ckdint should be chkdint.
# PH, 22-March-2023.
cc_library(
name = "pcre2",
srcs = [
@@ -39,12 +36,15 @@ cc_library(
"src/pcre2_extuni.c",
"src/pcre2_find_bracket.c",
"src/pcre2_jit_compile.c",
"src/pcre2_jit_match_inc.h",
"src/pcre2_jit_misc_inc.h",
"src/pcre2_maketables.c",
"src/pcre2_match.c",
"src/pcre2_match_data.c",
"src/pcre2_newline.c",
"src/pcre2_ord2utf.c",
"src/pcre2_pattern_info.c",
"src/pcre2_printint_inc.h",
"src/pcre2_script_run.c",
"src/pcre2_serialize.c",
"src/pcre2_string_utils.c",
@@ -60,13 +60,11 @@ cc_library(
"src/pcre2_internal.h",
"src/pcre2_intmodedep.h",
"src/pcre2_ucp.h",
"src/pcre2_ucptables_inc.h",
"src/pcre2_util.h",
":config_h_generic",
],
textual_hdrs = [
"src/pcre2_jit_match.c",
"src/pcre2_jit_misc.c",
"src/pcre2_ucptables.c",
],
hdrs = [
":pcre2_h_generic",
@@ -119,7 +117,6 @@ cc_library(
name = "pcre2test_dotc_headers",
hdrs = [
"src/pcre2_chkdint.c",
"src/pcre2_printint.c",
"src/pcre2_tables.c",
"src/pcre2_ucd.c",
"src/pcre2_valid_utf.c",

View File

@@ -404,6 +404,8 @@ COMMON_SOURCES = \
src/pcre2_intmodedep.h \
src/pcre2_jit_char_inc.h \
src/pcre2_jit_compile.c \
src/pcre2_jit_match_inc.h \
src/pcre2_jit_misc_inc.h \
src/pcre2_jit_neon_inc.h \
src/pcre2_jit_simd_inc.h \
src/pcre2_maketables.c \
@@ -412,6 +414,7 @@ COMMON_SOURCES = \
src/pcre2_newline.c \
src/pcre2_ord2utf.c \
src/pcre2_pattern_info.c \
src/pcre2_printint_inc.h \
src/pcre2_script_run.c \
src/pcre2_serialize.c \
src/pcre2_string_utils.c \
@@ -421,14 +424,11 @@ COMMON_SOURCES = \
src/pcre2_tables.c \
src/pcre2_ucd.c \
src/pcre2_ucp.h \
src/pcre2_ucptables_inc.h \
src/pcre2_util.h \
src/pcre2_valid_utf.c \
src/pcre2_xclass.c
# The pcre2_ucptables.c file is #included by pcre2_tables.c
EXTRA_DIST += src/pcre2_ucptables.c
if WITH_PCRE2_8
lib_LTLIBRARIES += libpcre2-8.la
libpcre2_8_la_SOURCES = \
@@ -520,12 +520,6 @@ EXTRA_DIST += \
deps/sljit/sljit_src/allocator_src/sljitWXExecAllocatorPosix.c \
deps/sljit/sljit_src/allocator_src/sljitWXExecAllocatorWindows.c
# Some of the JIT sources are also in separate files that are #included.
EXTRA_DIST += \
src/pcre2_jit_match.c \
src/pcre2_jit_misc.c
if WITH_PCRE2_8
libpcre2_8_la_LDFLAGS = $(EXTRA_LIBPCRE2_8_LDFLAGS)
endif # WITH_PCRE2_8
@@ -681,12 +675,9 @@ pcre2_jit_test_LDADD += $(GCOV_LIBS)
endif # WITH_GCOV
endif # WITH_JIT
# Build the general pcre2test program. The file src/pcre2_printint.c is
# #included by pcre2test as many times as needed, at different code unit
# widths.
# Build the general pcre2test program.
bin_PROGRAMS += pcre2test
EXTRA_DIST += src/pcre2_printint.c
pcre2test_SOURCES = src/pcre2test.c
pcre2test_CFLAGS = $(AM_CFLAGS)
pcre2test_LDADD = $(LIBREADLINE)

View File

@@ -143,9 +143,7 @@ example.
defined SUPPORT_JIT in src/config.h, because when JIT support is not
configured, dummy functions are compiled. When JIT support IS configured,
pcre2_jit_compile.c #includes other files from the sljit dependency,
all of whose names begin with "sljit". It also #includes
src/pcre2_jit_match.c and src/pcre2_jit_misc.c, so you should not compile
those yourself.
all of whose names begin with "sljit".
Note also that the pcre2_fuzzsupport.c file contains special code that is
useful to those who want to run fuzzing tests on the PCRE2 library. Unless

12
README
View File

@@ -860,10 +860,8 @@ The distribution should contain the files listed below.
src/pcre2_extuni.c )
src/pcre2_find_bracket.c )
src/pcre2_jit_compile.c )
src/pcre2_jit_match.c ) sources for the functions in the library,
src/pcre2_jit_misc.c ) and some internal functions that they use
src/pcre2_maketables.c )
src/pcre2_match.c )
src/pcre2_maketables.c ) sources for the functions in the library,
src/pcre2_match.c ) and some internal functions that they use
src/pcre2_match_data.c )
src/pcre2_newline.c )
src/pcre2_ord2utf.c )
@@ -876,11 +874,9 @@ The distribution should contain the files listed below.
src/pcre2_substring.c )
src/pcre2_tables.c )
src/pcre2_ucd.c )
src/pcre2_ucptables.c )
src/pcre2_valid_utf.c )
src/pcre2_xclass.c )
src/pcre2_printint.c debugging function that is used by pcre2test,
src/pcre2_fuzzsupport.c function for (optional) fuzzing support
src/config.h.in template for config.h, when built by "configure"
@@ -890,9 +886,13 @@ The distribution should contain the files listed below.
src/pcre2_internal.h header for internal use
src/pcre2_intmodedep.h a mode-specific internal header
src/pcre2_jit_char_inc.h header used by JIT
src/pcre2_jit_match_inc.h header used by JIT
src/pcre2_jit_misc_inc.h header used by JIT
src/pcre2_jit_neon_inc.h header used by JIT
src/pcre2_jit_simd_inc.h header used by JIT
src/pcre2_printint_inc.h debugging function that is used by pcre2test
src/pcre2_ucp.h header for Unicode property handling
src/pcre2_ucptables_inc.h header with Unicode data tables
src/pcre2_util.h header for internal utils
deps/sljit/sljit_src/* source files for the JIT compiler

View File

@@ -143,9 +143,7 @@ example.
defined SUPPORT_JIT in src/config.h, because when JIT support is not
configured, dummy functions are compiled. When JIT support IS configured,
pcre2_jit_compile.c #includes other files from the sljit dependency,
all of whose names begin with "sljit". It also #includes
src/pcre2_jit_match.c and src/pcre2_jit_misc.c, so you should not compile
those yourself.
all of whose names begin with "sljit".
Note also that the pcre2_fuzzsupport.c file contains special code that is
useful to those who want to run fuzzing tests on the PCRE2 library. Unless

View File

@@ -860,10 +860,8 @@ The distribution should contain the files listed below.
src/pcre2_extuni.c )
src/pcre2_find_bracket.c )
src/pcre2_jit_compile.c )
src/pcre2_jit_match.c ) sources for the functions in the library,
src/pcre2_jit_misc.c ) and some internal functions that they use
src/pcre2_maketables.c )
src/pcre2_match.c )
src/pcre2_maketables.c ) sources for the functions in the library,
src/pcre2_match.c ) and some internal functions that they use
src/pcre2_match_data.c )
src/pcre2_newline.c )
src/pcre2_ord2utf.c )
@@ -876,11 +874,9 @@ The distribution should contain the files listed below.
src/pcre2_substring.c )
src/pcre2_tables.c )
src/pcre2_ucd.c )
src/pcre2_ucptables.c )
src/pcre2_valid_utf.c )
src/pcre2_xclass.c )
src/pcre2_printint.c debugging function that is used by pcre2test,
src/pcre2_fuzzsupport.c function for (optional) fuzzing support
src/config.h.in template for config.h, when built by "configure"
@@ -890,9 +886,13 @@ The distribution should contain the files listed below.
src/pcre2_internal.h header for internal use
src/pcre2_intmodedep.h a mode-specific internal header
src/pcre2_jit_char_inc.h header used by JIT
src/pcre2_jit_match_inc.h header used by JIT
src/pcre2_jit_misc_inc.h header used by JIT
src/pcre2_jit_neon_inc.h header used by JIT
src/pcre2_jit_simd_inc.h header used by JIT
src/pcre2_printint_inc.h debugging function that is used by pcre2test
src/pcre2_ucp.h header for Unicode property handling
src/pcre2_ucptables_inc.h header with Unicode data tables
src/pcre2_util.h header for internal utils
deps/sljit/sljit_src/* source files for the JIT compiler

2
maint/.gitignore vendored
View File

@@ -2,7 +2,7 @@ ucptest
utf8
pcre2_ucp.h
pcre2_ucptables.c
pcre2_ucptables_inc.h
pcre2_ucd.c
testinput

View File

@@ -3,7 +3,7 @@
# PCRE2 UNICODE PROPERTY SUPPORT
# ------------------------------
# This script generates the pcre2_ucptables.c file, which contains tables for
# This script generates the pcre2_ucptables_inc.h file, which contains tables for
# recognizing Unicode property names. It is #included by pcre2_tables.c. In
# order to reduce the number of relocations when loading the PCRE2 library, the
# names are held as a single large string, with offsets in the table. This is
@@ -60,7 +60,7 @@ from GenerateCommon import \
# Open the output file (no return on failure). This call also writes standard
# header boilerplate.
f = open_output("pcre2_ucptables.c")
f = open_output("pcre2_ucptables_inc.h")
# The list in bidi_classes contains just the Unicode classes such as AN, LRE,
# etc., along with comments. We need to add "bidi" in front of each value, in
@@ -195,7 +195,7 @@ const size_t PRIV(utt_size) = sizeof(PRIV(utt)) / sizeof(ucp_type_table);
#endif /* SUPPORT_UNICODE */
/* End of pcre2_ucptables.c */
/* End of pcre2_ucptables_inc.h */
""")
f.close

View File

@@ -56,7 +56,7 @@ GenerateUcpHeader.py
Unicode property values.
GenerateUcpTables.py
A Python script that generates the file pcre2_ucptables.c from
A Python script that generates the file pcre2_ucptables_inc.h from
GenerateCommon.py and Unicode data files. The generated file contains tables
for looking up Unicode property names.
@@ -145,9 +145,9 @@ of supported scripts, and the command to do so is part of the documentation.
You can give an output file name as an argument to the following scripts, but
by default:
GenerateUcd.py creates pcre2_ucd.c )
GenerateUcpHeader.py creates pcre2_ucp.h ) in the current directory
GenerateUcpTables.py creates pcre2_ucptables.c )
GenerateUcd.py creates pcre2_ucd.c )
GenerateUcpHeader.py creates pcre2_ucp.h ) in the current directory
GenerateUcpTables.py creates pcre2_ucptables_inc.h )
These files can be compared against the existing versions in the src directory
to check on any changes before replacing the old files, but you can also
@@ -155,7 +155,7 @@ generate directly into the final location by running:
./GenerateUcd.py ../src/pcre2_ucd.c
./GenerateUcpHeader.py ../src/pcre2_ucp.h
./GenerateUcpTables.py ../src/pcre2_ucptables.c
./GenerateUcpTables.py ../src/pcre2_ucptables_inc.h
Once the .c and .h files are in the ../src directory, the ucptest program can
be compiled and used to check that the new tables work properly. The data files
@@ -176,7 +176,7 @@ In summary:
```
./GenerateUcd.py ../src/pcre2_ucd.c
./GenerateUcpHeader.py ../src/pcre2_ucp.h
./GenerateUcpTables.py ../src/pcre2_ucptables.c
./GenerateUcpTables.py ../src/pcre2_ucptables_inc.h
./GenerateTest.py
mv testinput ../testdata/testinput27
mv testoutput ../testdata/testoutput27

View File

@@ -282,8 +282,8 @@ c_files=(
src/pcre2_intmodedep.h
src/pcre2_jit_char_inc.h
src/pcre2_jit_compile.c
src/pcre2_jit_match.c
src/pcre2_jit_misc.c
src/pcre2_jit_match_inc.h
src/pcre2_jit_misc_inc.h
src/pcre2_jit_neon_inc.h
src/pcre2_jit_simd_inc.h
src/pcre2_jit_test.c
@@ -293,7 +293,7 @@ c_files=(
src/pcre2_newline.c
src/pcre2_ord2utf.c
src/pcre2_pattern_info.c
src/pcre2_printint.c
src/pcre2_printint_inc.h
src/pcre2_script_run.c
src/pcre2_serialize.c
src/pcre2_string_utils.c
@@ -303,7 +303,7 @@ c_files=(
src/pcre2_tables.c
src/pcre2_ucd.c
src/pcre2_ucp.h
src/pcre2_ucptables.c
src/pcre2_ucptables_inc.h
src/pcre2_util.h
src/pcre2_valid_utf.c
src/pcre2_xclass.c

View File

@@ -327,8 +327,8 @@ drwxr-xr-x tarball-dir/pcre2-SNAPSHOT/src
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_intmodedep.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_jit_char_inc.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_jit_compile.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_jit_match.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_jit_misc.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_jit_match_inc.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_jit_misc_inc.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_jit_neon_inc.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_jit_simd_inc.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_jit_test.c
@@ -338,7 +338,7 @@ drwxr-xr-x tarball-dir/pcre2-SNAPSHOT/src
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_newline.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_ord2utf.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_pattern_info.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_printint.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_printint_inc.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_script_run.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_serialize.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_string_utils.c
@@ -348,7 +348,7 @@ drwxr-xr-x tarball-dir/pcre2-SNAPSHOT/src
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_tables.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_ucd.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_ucp.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_ucptables.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_ucptables_inc.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_util.h
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_valid_utf.c
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/src/pcre2_xclass.c

View File

@@ -59,7 +59,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define CHAR_OUTPUT_HEX(c) (c)
#define CHAR_INPUT(c) (c)
#define CHAR_INPUT_HEX(c) (c)
#include "pcre2_printint.c"
#include "pcre2_printint_inc.h"
#undef PRINTABLE
#undef CHAR_OUTPUT
#undef CHAR_OUTPUT_HEX

View File

@@ -1949,7 +1949,7 @@ pcre2_dfa_match.c that must be updated. */
/* This macro defines textual names for all the opcodes. These are used only
for debugging, and some of them are only partial names. The macro is referenced
only in pcre2_printint.c, which fills out the full names in many cases (and in
only in pcre2_printint_inc.h, which fills out the full names in many cases (and in
some cases doesn't actually use these names at all). */
#define OP_NAME_LIST \

View File

@@ -47,7 +47,7 @@ to have access to the hidden structures at all supported widths.
Some of the mode-dependent macros are required at different widths for
different parts of the pcre2test code (in particular, the included
pcre2_printint.c file). We undefine them here so that they can be re-defined for
pcre2_printint_inc.h file). We undefine them here so that they can be re-defined for
multiple inclusions. Not all of these are used in pcre2test, but it's easier
just to undefine them all. */

View File

@@ -14235,7 +14235,7 @@ return 0;
#define INCLUDED_FROM_PCRE2_JIT_COMPILE
#include "pcre2_jit_match.c"
#include "pcre2_jit_misc.c"
#include "pcre2_jit_match_inc.h"
#include "pcre2_jit_misc_inc.h"
/* End of pcre2_jit_compile.c */

View File

@@ -197,4 +197,4 @@ return match_data->rc;
#endif /* SUPPORT_JIT */
}
/* End of pcre2_jit_match.c */
/* End of pcre2_jit_match_inc.h */

View File

@@ -231,4 +231,4 @@ return executable_sizes[0] + executable_sizes[1] + executable_sizes[2];
#endif
}
/* End of pcre2_jit_misc.c */
/* End of pcre2_jit_misc_inc.h */

View File

@@ -1125,4 +1125,4 @@ for(;;)
}
}
/* End of pcre2_printint.c */
/* End of pcre2_printint_inc.h */

View File

@@ -122,7 +122,7 @@ const uint8_t PRIV(utf8_table4)[] = {
#endif /* UTF-8 support needed */
/* Tables concerned with Unicode properties are relevant only when Unicode
support is enabled. See also the pcre2_ucptables.c file, which is generated by
support is enabled. See also the pcre2_ucptables_inc.h file, which is generated by
a Python script from Unicode data files. */
#if defined(SUPPORT_UNICODE) && !defined(PCRE2_DFTABLES)
@@ -229,7 +229,7 @@ const int PRIV(ucp_typerange)[] = {
/* Finally, include the tables that are auto-generated from the Unicode data
files. */
#include "pcre2_ucptables.c"
#include "pcre2_ucptables_inc.h"
#endif /* Unicode support needed */

View File

@@ -1593,4 +1593,4 @@ const size_t PRIV(utt_size) = sizeof(PRIV(utt)) / sizeof(ucp_type_table);
#endif /* SUPPORT_UNICODE */
/* End of pcre2_ucptables.c */
/* End of pcre2_ucptables_inc.h */

View File

@@ -365,7 +365,7 @@ these inclusions should not be changed. */
#define PCRE2_CODE_UNIT_WIDTH 8
#define PCRE2_SUFFIX(a) G(a,8)
#include "pcre2_intmodedep.h"
#include "pcre2_printint.c"
#include "pcre2_printint_inc.h"
#undef PCRE2_CODE_UNIT_WIDTH
#undef PCRE2_SUFFIX
#endif /* SUPPORT_PCRE2_8 */
@@ -374,7 +374,7 @@ these inclusions should not be changed. */
#define PCRE2_CODE_UNIT_WIDTH 16
#define PCRE2_SUFFIX(a) G(a,16)
#include "pcre2_intmodedep.h"
#include "pcre2_printint.c"
#include "pcre2_printint_inc.h"
#undef PCRE2_CODE_UNIT_WIDTH
#undef PCRE2_SUFFIX
#endif /* SUPPORT_PCRE2_16 */
@@ -383,7 +383,7 @@ these inclusions should not be changed. */
#define PCRE2_CODE_UNIT_WIDTH 32
#define PCRE2_SUFFIX(a) G(a,32)
#include "pcre2_intmodedep.h"
#include "pcre2_printint.c"
#include "pcre2_printint_inc.h"
#undef PCRE2_CODE_UNIT_WIDTH
#undef PCRE2_SUFFIX
#endif /* SUPPORT_PCRE2_32 */

View File

@@ -1073,12 +1073,6 @@ PCRE2_FUZZSUPPORT.OBJ : PCRE2_FUZZSUPPORT.C
PCRE2_JIT_COMPILE.OBJ : PCRE2_JIT_COMPILE.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
PCRE2_JIT_MATCH.OBJ : PCRE2_JIT_MATCH.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
PCRE2_JIT_MISC.OBJ : PCRE2_JIT_MISC.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
PCRE2_JIT_TEST.OBJ : PCRE2_JIT_TEST.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
@@ -1100,9 +1094,6 @@ PCRE2_ORD2UTF.OBJ : PCRE2_ORD2UTF.C
PCRE2_PATTERN_INFO.OBJ : PCRE2_PATTERN_INFO.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
PCRE2_PRINTINT.OBJ : PCRE2_PRINTINT.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
PCRE2_SCRIPT_RUN.OBJ : PCRE2_SCRIPT_RUN.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
@@ -1127,9 +1118,6 @@ PCRE2_TABLES.OBJ : PCRE2_TABLES.C
PCRE2_UCD.OBJ : PCRE2_UCD.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
PCRE2_UCPTABLES.OBJ : PCRE2_UCPTABLES.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
PCRE2_VALID_UTF.OBJ : PCRE2_VALID_UTF.C
$(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)