Skip to content

Commit 8613839

Browse files
committed
Last-ish round of fixes
1 parent ec9fdc8 commit 8613839

30 files changed

+569
-392
lines changed

.github/workflows/dev.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -439,28 +439,6 @@ jobs:
439439
- name: Test
440440
run: bazelisk test //... --enable_runfiles --incompatible_strict_action_env --test_output=all
441441

442-
# XXX Maybe this should just go in the ManyConfig tests, actually??
443-
# XXX JIT IS TURNED OFF - apparently it needs some fixes (not surprising)
444-
ebcdic:
445-
# Tests the full support for EBCDIC on a non-EBCDIC platform, using a
446-
# hardcoded EBCDIC-1047 codepage.
447-
name: EBCDIC
448-
runs-on: ubuntu-24.04
449-
steps:
450-
- name: Checkout
451-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
452-
with:
453-
submodules: true
454-
455-
- name: Configure
456-
run: cmake -DPCRE2_SUPPORT_JIT=OFF -DPCRE2_SUPPORT_UNICODE=OFF -DPCRE2_EBCDIC=ON -DPCRE2_EBCDIC_IGNORING_COMPILER=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
457-
458-
- name: Build
459-
run: cd build && make -j3
460-
461-
- name: Test
462-
run: cd build && ../RunTest
463-
464442
heron:
465443
# Job to verify that the tasks performed by PrepareRelease have been done. It is
466444
# the committer's responsibility (currently) to run PrepareRelease themselves when

Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ EXTRA_DIST += \
782782
testdata/testinput26 \
783783
testdata/testinput27 \
784784
testdata/testinput28 \
785+
testdata/testinput29 \
785786
testdata/testinputheap \
786787
testdata/testoutput1 \
787788
testdata/testoutput2 \
@@ -824,6 +825,7 @@ EXTRA_DIST += \
824825
testdata/testoutput26 \
825826
testdata/testoutput27 \
826827
testdata/testoutput28 \
828+
testdata/testoutput29 \
827829
testdata/testoutputheap-16 \
828830
testdata/testoutputheap-32 \
829831
testdata/testoutputheap-8 \

RunTest

Lines changed: 45 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ title25="Test 25: UTF pattern conversion tests"
8585
title26="Test 26: Unicode property tests (compatible with Perl >= 5.38)"
8686
title27="Test 27: Auto-generated unicode property tests"
8787
title28="Test 28: EBCDIC-specific tests"
88-
maxtest=28
88+
title29="Test 29: EBCDIC-specific tests (for NL=0x25)"
89+
maxtest=29
8990
titleheap="Test 'heap': Environment-specific heap tests"
9091

9192
if [ $# -eq 1 -a "$1" = "list" ]; then
@@ -118,6 +119,7 @@ if [ $# -eq 1 -a "$1" = "list" ]; then
118119
echo $title26
119120
echo $title27
120121
echo $title28
122+
echo $title29
121123
echo ""
122124
echo $titleheap
123125
echo ""
@@ -169,7 +171,10 @@ checkresult()
169171
esac
170172
cf_out="$testdata/testoutput$2"
171173
if [ $ebcdic -eq 1 ] ; then
172-
sed '/^# if !EBCDIC/,/^# endif/d' "$cf_out" >testtry2
174+
# We currently only use the #if ... #endif support in pcre2test for EBCDIC
175+
# testing. Run in "preprocess-only" mode (-E) on the testoutput file to trim
176+
# the output lines matching the input lines which are discarded.
177+
$sim $pcre2test -q -E "$cf_out" >testtry2
173178
cf_out=testtry2
174179
fi
175180
$cf "$cf_out" testtry
@@ -249,6 +254,7 @@ do25=no
249254
do26=no
250255
do27=no
251256
do28=no
257+
do29=no
252258
doheap=no
253259

254260
while [ $# -gt 0 ] ; do
@@ -282,6 +288,7 @@ while [ $# -gt 0 ] ; do
282288
26) do26=yes;;
283289
27) do27=yes;;
284290
28) do28=yes;;
291+
29) do29=yes;;
285292
heap) doheap=yes;;
286293
-8) arg8=yes;;
287294
-16) arg16=yes;;
@@ -358,53 +365,25 @@ support32=$?
358365
$sim $pcre2test -C backslash-C >/dev/null
359366
supportBSC=$?
360367

361-
# Check if compiled in EBCDIC mode, and whether we have EBCDIC I/O
368+
# Check if compiled in EBCDIC mode, and whether we have EBCDIC I/O and NL=0x25
362369
$sim $pcre2test -C ebcdic >/dev/null
363370
ebcdic=$?
364371
$sim $pcre2test -C ebcdic-io >/dev/null
365372
ebcdic_io=$?
373+
$sim $pcre2test -C ebcdic-nl25 >/dev/null
374+
ebcdic_nl25=$?
375+
366376
if [ $ebcdic -eq 1 ]; then
367-
# XXX This is a bit unholy. How about I just bite the bullet and implement
368-
# the "#if" stuff directly inside pcre2test? It wouldn't be totally crazy.
369-
# This does seem to work fine here though.
370-
#
371-
# Purpose of code: sneakily parse the pcre2test commandline, to find the
372-
# filename of the input file. Run that through sed, to strip out the chunks
373-
# blocked out by "# if !EBCDIC...#endif", and then invoke pcre2test with the
374-
# modified input file. That's it.
375-
filterebcdic()
376-
{
377-
filter_args=
378-
while [ "$1" != "$pcre2test" ] ; do
379-
# Shift off any Valgrind args
380-
filter_args="$filter_args $1"
381-
shift
382-
done
383-
# Shift off the $pcre2test arg
384-
filter_args="$filter_args $1"
385-
shift
386-
while [ $# -gt 0 ] ; do
387-
case "$1" in
388-
-C|-error|-pattern|-S|-subject|-t|-tm|-T|-TM)
389-
if [ $# -gt 1 ] ; then
390-
filter_args="$filter_args $1 $2"; shift; shift
391-
else
392-
filter_args="$filter_args $1"; shift
393-
fi
394-
;;
395-
-*) filter_args="$filter_args $1"; shift;;
396-
*) break;;
397-
esac
398-
done
399-
if [ $# -gt 0 ] ; then
400-
input="$1"
401-
shift
402-
sed '/^# if !EBCDIC/,/^# endif/d' "$input" | $filter_args "/dev/stdin" "$@"
403-
else
404-
$filter_args "$@"
405-
fi
406-
}
407-
sim="filterebcdic $sim"
377+
if [ $ebcdic_io -eq 0 ]; then
378+
echo "Running tests in EBCDIC mode, and expecting ASCII test data"
379+
else
380+
echo "Running tests in EBCDIC mode, and expecting EBCDIC test data"
381+
echo "If you are on an EBCDIC machine, you will need to convert the PCRE2"
382+
echo "testdata/ directory from ISO8859-1, so the data match the EBCDIC"
383+
echo "codepage that your C compiler is using for C character literals."
384+
echo "For example:"
385+
echo " iconv -f ISO8859-1 -t IBM-1047 ..."
386+
fi
408387
fi
409388

410389
# Initialize all bitsizes skipped
@@ -483,7 +462,7 @@ if [ $do0 = no -a $do1 = no -a $do2 = no -a $do3 = no -a \
483462
$do16 = no -a $do17 = no -a $do18 = no -a $do19 = no -a \
484463
$do20 = no -a $do21 = no -a $do22 = no -a $do23 = no -a \
485464
$do24 = no -a $do25 = no -a $do26 = no -a $do27 = no -a \
486-
$do28 = no -a $doheap = no \
465+
$do28 = no -a $do29 = no -a $doheap = no \
487466
]; then
488467
do0=yes
489468
do1=yes
@@ -514,6 +493,7 @@ if [ $do0 = no -a $do1 = no -a $do2 = no -a $do3 = no -a \
514493
do26=yes
515494
do27=yes
516495
do28=yes
496+
do29=yes
517497
fi
518498

519499
# Handle any explicit skips at this stage, so that an argument list may consist
@@ -980,33 +960,26 @@ for bmode in "$test8" "$test16" "$test32"; do
980960
if [ $ebcdic -eq 0 ] ; then
981961
echo " Skipped when not targetting EBCDIC"
982962
else
983-
if [ $ebcdic_io -eq 0 ] ; then
984-
# Our testdata files are in ASCII, and the pcre2test program is using
985-
# ASCII input: all easy.
986-
for opt in "" "-dfa"; do
987-
$sim $valgrind $pcre2test -q $setstack $bmode $opt $testdata/testinput28 testtry
988-
checkresult $? 28 "$opt"
989-
done
990-
else
991-
echo "Cannot run EBCDIC tests:"
992-
echo " Ironically this particular test script does not automatically"
993-
echo " run the tests on an actual EBCDIC system. The testdata files"
994-
echo " shipped with PCRE2 are in ASCII."
995-
echo " You may be able to run the tests manually if you know which"
996-
echo " EBCDIC codepage you used when compiling PCRE2, and then convert"
997-
echo " the testdata to match. For example, if the C compiler used to build"
998-
echo " PCRE2 was using IBM-1047:"
999-
echo ""
1000-
echo " iconv -f ISO8859-1 -t IBM-1047 <testdata/testinputEBC >testinputEBC-native"
1001-
echo " pcre2test -q -$bmode testinputEBC-native >testoutputEBC-native"
1002-
echo " [ $? -eq 0 ] || echo 'pcre2test failed'"
1003-
echo " iconv -f IBM-1047 -t ISO8859-1 <testoutputEBC-native >testoutputEBC-ascii"
1004-
echo " $cf testdata/testoutputEBC testoutputEBC-ascii"
1005-
echo ""
1006-
echo "This is speculative. The PCRE2 maintainers do not have access to an"
1007-
echo "EBCDIC system to test this. Please report back if you try it."
1008-
exit 1
1009-
fi
963+
for opt in "" $jitopt "-dfa"; do
964+
$sim $valgrind ${opt:+$vjs} $pcre2test -q $setstack $bmode $opt $testdata/testinput28 testtry
965+
checkresult $? 28 "$opt"
966+
done
967+
fi
968+
fi
969+
970+
# EBCDIC tests (for NL=0x25)
971+
972+
if [ $do29 = yes ] ; then
973+
echo $title29
974+
if [ $ebcdic -eq 0 ] ; then
975+
echo " Skipped when not targetting EBCDIC"
976+
elif [ $ebcdic_nl25 -eq 0 ] ; then
977+
echo " Skipped because EBCDIC newline is not 0x25"
978+
else
979+
for opt in "" $jitopt "-dfa"; do
980+
$sim $valgrind ${opt:+$vjs} $pcre2test -q $setstack $bmode $opt $testdata/testinput29 testtry
981+
checkresult $? 29 "$opt"
982+
done
1010983
fi
1011984
fi
1012985

RunTest.bat

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ set unicode=%ERRORLEVEL%
7171
set jit=%ERRORLEVEL%
7272
%pcre2test% -C backslash-C >NUL
7373
set supportBSC=%ERRORLEVEL%
74+
%pcre2test% -C ebcdic >NUL
75+
set ebcdic=%ERRORLEVEL%
76+
%pcre2test% -C ebcdic-nl25 >NUL
77+
set ebcdic_nl25=%ERRORLEVEL%
7478

7579
if %support8% EQU 1 (
7680
if not exist testout8 md testout8
@@ -114,19 +118,20 @@ set do24=no
114118
set do25=no
115119
set do26=no
116120
set do27=no
117-
@rem XXX ADD TEST 28
121+
set do28=no
122+
set do29=no
118123
set all=yes
119124

120125
for %%a in (%*) do (
121126
set valid=no
122-
for %%v in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27) do if %%v == %%a set valid=yes
127+
for %%v in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29) do if %%v == %%a set valid=yes
123128
if "!valid!" == "yes" (
124129
set do%%a=yes
125130
set all=no
126131
) else (
127132
echo Invalid test number - %%a!
128133
echo Usage %0 [ test_number ] ...
129-
echo Where test_number is one or more optional test numbers 1 through 27, default is all tests.
134+
echo Where test_number is one or more optional test numbers 1 through 29, default is all tests.
130135
exit /b 1
131136
)
132137
)
@@ -160,6 +165,8 @@ if "%all%" == "yes" (
160165
set do25=yes
161166
set do26=yes
162167
set do27=yes
168+
set do28=yes
169+
set do29=yes
163170
)
164171

165172
@echo RunTest.bat's pcre2test output is written to newly created subfolders
@@ -215,6 +222,8 @@ if "%do24%" == "yes" call :do24
215222
if "%do25%" == "yes" call :do25
216223
if "%do26%" == "yes" call :do26
217224
if "%do27%" == "yes" call :do27
225+
if "%do28%" == "yes" call :do28
226+
if "%do29%" == "yes" call :do29
218227
:modeSkip
219228
if "%mode%" == "" (
220229
set mode=-16
@@ -293,18 +302,28 @@ if errorlevel 1 (
293302
%pcre2test% %mode% %4 %5 %6 %7 %8 %9 -error -80,-62,-2,-1,0,100,101,191,300 >>%2%bits%\%testoutput%
294303
)
295304

296-
fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput% >NUL
305+
set testexpected=%srcdir%\testdata\%testoutput%
306+
307+
if %ebcdic% EQU 1 (
308+
@rem We currently only use the #if ... #endif support in pcre2test for EBCDIC
309+
@rem testing. Run in "preprocess-only" mode (-E) on the testoutput file to trim
310+
@rem the output lines matching the input lines which are discarded.
311+
%pcre2test% -q -E %testexpected% >%2%bits%\%testoutput%-trimmed
312+
set testexpected=%2%bits%\%testoutput%-trimmed
313+
)
314+
315+
fc /n %testexpected% %2%bits%\%testoutput% >NUL
297316

298317
if errorlevel 1 (
299-
echo. failed comparison: fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput%
318+
echo. failed comparison: fc /n %testexpected% %2%bits%\%testoutput%
300319
if [%1]==[3] (
301320
echo.
302321
echo ** Test 3 failure usually means french locale is not
303322
echo ** available on the system, rather than a bug or problem with PCRE2.
304323
echo.
305324
goto :eof
306325
)
307-
fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput%
326+
fc /n %testexpected% %2%bits%\%testoutput%
308327

309328
set failed="yes"
310329
goto :eof
@@ -544,6 +563,30 @@ if %unicode% EQU 0 (
544563
if %jit% EQU 1 call :runsub 27 testoutjit "Test with JIT Override" -q -jit
545564
goto :eof
546565

566+
:do28
567+
if %ebcdic% EQU 0 (
568+
echo Test 28 Skipped when not targetting EBCDIC.
569+
goto :eof
570+
)
571+
call :runsub 28 testout "EBCDIC-specific tests" -q
572+
call :runsub 28 testout "EBCDIC-specific tests (DFA)" -q -dfa
573+
if %jit% EQU 1 call :runsub 28 testoutjit "Test with JIT Override" -q -jit
574+
goto :eof
575+
576+
:do29
577+
if %ebcdic% EQU 0 (
578+
echo Test 29 Skipped when not targetting EBCDIC.
579+
goto :eof
580+
)
581+
if %ebcdic_nl25% EQU 0 (
582+
echo Test 29 Skipped because EBCDIC newline is not 0x25.
583+
goto :eof
584+
)
585+
call :runsub 29 testout "EBCDIC-specific tests for NL=0x25" -q
586+
call :runsub 29 testout "EBCDIC-specific tests for NL=0x25 (DFA)" -q -dfa
587+
if %jit% EQU 1 call :runsub 29 testoutjit "Test with JIT Override" -q -jit
588+
goto :eof
589+
547590
:conferror
548591
@echo.
549592
@echo Either your build is incomplete or you have a configuration error.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre2-config])
11691169

11701170
# Make sure that pcre2_chartables.c is removed in case the method for
11711171
# creating it was changed by reconfiguration.
1172-
AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre2_chartables.c])
1172+
AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f src/pcre2_chartables.c])
11731173

11741174
# Handle --enable-Werror/errwarn. This must come last, so that we don't mess
11751175
# with any of the library-detection tests (or similar).

0 commit comments

Comments
 (0)