Skip to content

Commit 7db647d

Browse files
mvorisekiluuu1994
authored andcommitted
Verify bundled PCRE2 in CI
Closes GH-20354
1 parent b9562ad commit 7db647d

File tree

5 files changed

+92
-11
lines changed

5 files changed

+92
-11
lines changed

.github/actions/verify-generated-files/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ runs:
1313
ext/tokenizer/tokenizer_data_gen.php
1414
build/gen_stub.php -f --generate-optimizer-info --verify
1515
ext/phar/makestub.php
16-
# Use the -a flag for a bug in git 2.46.0, which doesn't consider changed -diff files.
17-
git add . -N && git diff -a --exit-code
16+
.github/scripts/test-directory-unchanged.sh .
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
set -ex
3+
cd "$(dirname "$0")/../../.."
4+
5+
revision=refs/tags/pcre2-10.44
6+
7+
git clone --depth 1 --recurse-submodules --revision="$revision" https://github.com/PCRE2Project/pcre2.git /tmp/php-src-bundled/pcre2
8+
9+
rm -rf ext/pcre/pcre2lib
10+
cp -R /tmp/php-src-bundled/pcre2/src ext/pcre/pcre2lib
11+
12+
cd ext/pcre/pcre2lib
13+
14+
# remove unneeded files
15+
rm config.h.generic
16+
rm pcre2.h.in
17+
rm pcre2_dftables.c
18+
rm pcre2_fuzzsupport.c
19+
rm pcre2_jit_test.c
20+
rm pcre2demo.c
21+
rm pcre2grep.c
22+
rm pcre2posix.c
23+
rm pcre2posix.h
24+
rm pcre2posix_test.c
25+
rm pcre2test.c
26+
27+
# move renamed files
28+
mv pcre2.h.generic pcre2.h
29+
mv pcre2_chartables.c.dist pcre2_chartables.c
30+
31+
# add extra files
32+
git restore config.h # based on config.h.generic but with many changes
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
cd "$(dirname "$0")/../../$1"
5+
6+
# notify git about untracked (except ignored) files
7+
git add -N .
8+
9+
# display overview of changed files
10+
git status .
11+
12+
# display diff of working directory vs HEAD commit and set exit code
13+
git diff -a --exit-code HEAD .
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Verify Bundled Files
2+
3+
on:
4+
push:
5+
paths: &paths
6+
- '.github/scripts/download-bundled/pcre2.sh'
7+
- 'ext/pcre/pcre2lib/**'
8+
pull_request:
9+
paths: *paths
10+
schedule:
11+
- cron: "0 1 * * *"
12+
workflow_dispatch: ~
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
VERIFY_BUNDLED_FILES:
19+
name: Verify Bundled Files
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- name: git checkout
23+
uses: actions/checkout@v5
24+
25+
- name: Detect changed files
26+
uses: dorny/paths-filter@v3
27+
id: changes
28+
with:
29+
base: master
30+
filters: |
31+
pcre2:
32+
- '.github/scripts/download-bundled/pcre2.sh'
33+
- 'ext/pcre/pcre2lib/**'
34+
35+
- name: PCRE2
36+
if: ${{ !cancelled() && (steps.changes.outputs.pcre2 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
37+
run: |
38+
echo "::group::Download"
39+
.github/scripts/download-bundled/pcre2.sh
40+
echo "::endgroup::"
41+
echo "::group::Verify files"
42+
.github/scripts/test-directory-unchanged.sh ext/pcre/pcre2lib
43+
echo "::endgroup::"

ext/pcre/pcre2lib/pcre2_chartables.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
/* This file was automatically written by the pcre2_dftables auxiliary
66
program. It contains character tables that are used when no external
77
tables are passed to PCRE2 by the application that calls it. The tables
8-
are used only for characters whose code values are less than 256. */
8+
are used only for characters whose code values are less than 256, and
9+
only relevant if not in UCP mode. */
910

1011
/* This set of tables was written in the C locale. */
1112

@@ -18,13 +19,6 @@ PCRE2 is configured with --enable-rebuild-chartables. However, you can run
1819
pcre2_dftables manually with the -L option to build tables using the LC_ALL
1920
locale. */
2021

21-
/* The following #include is present because without it gcc 4.x may remove
22-
the array definition from the final binary if PCRE2 is built into a static
23-
library and dead code stripping is activated. This leads to link errors.
24-
Pulling in the header ensures that the array gets flagged as "someone
25-
outside this compilation unit might reference this" and so it will always
26-
be supplied to the linker. */
27-
2822
#ifdef HAVE_CONFIG_H
2923
#include "config.h"
3024
#endif
@@ -163,7 +157,7 @@ graph, print, punct, and cntrl. Other classes are built from combinations. */
163157
0x02 letter
164158
0x04 lower case letter
165159
0x08 decimal digit
166-
0x10 alphanumeric or '_'
160+
0x10 word (alphanumeric or '_')
167161
*/
168162

169163
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */

0 commit comments

Comments
 (0)