@@ -85,7 +85,8 @@ title25="Test 25: UTF pattern conversion tests"
8585title26=" Test 26: Unicode property tests (compatible with Perl >= 5.38)"
8686title27=" Test 27: Auto-generated unicode property tests"
8787title28=" Test 28: EBCDIC-specific tests"
88- maxtest=28
88+ title29=" Test 29: EBCDIC-specific tests (for NL=0x25)"
89+ maxtest=29
8990titleheap=" Test 'heap': Environment-specific heap tests"
9091
9192if [ $# -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
249254do26=no
250255do27=no
251256do28=no
257+ do29=no
252258doheap=no
253259
254260while [ $# -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
359366supportBSC=$?
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
363370ebcdic=$?
364371$sim $pcre2test -C ebcdic-io > /dev/null
365372ebcdic_io=$?
373+ $sim $pcre2test -C ebcdic-nl25 > /dev/null
374+ ebcdic_nl25=$?
375+
366376if [ $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
408387fi
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
517497fi
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
0 commit comments