Skip to content

Commit 46367fc

Browse files
committed
A few more fixes, after further testing
1 parent f611deb commit 46367fc

File tree

9 files changed

+163
-31
lines changed

9 files changed

+163
-31
lines changed

.github/workflows/build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,55 @@ jobs:
281281
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-solaris
282282
../maint/RunSymbolTest install-dir/lib/ ../maint/
283283
284+
zos:
285+
name: z/OS
286+
runs-on: ubuntu-latest
287+
if: github.event_name != 'pull_request'
288+
concurrency:
289+
group: zos-ssh-build
290+
steps:
291+
- name: Checkout
292+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
293+
with:
294+
submodules: true
295+
296+
- name: Prepare
297+
run: ./autogen.sh
298+
299+
- name: Build & test
300+
env:
301+
ZOS_HOST: ${{ secrets.ZOS_HOST }}
302+
ZOS_PORT: ${{ secrets.ZOS_PORT }}
303+
ZOS_PRIVATE_KEY: ${{ secrets.ZOS_PRIVATE_KEY }}
304+
ZOS_KNOWN_HOSTS: ${{ secrets.ZOS_KNOWN_HOSTS }}
305+
run: |
306+
(umask 0077 && printenv ZOS_PRIVATE_KEY > id_rsa_zos)
307+
mkdir -p ~/.ssh
308+
printenv ZOS_KNOWN_HOSTS > ~/.ssh/known_hosts
309+
310+
tar czf ../pcre2-build.tar.gz --exclude=.git .
311+
mv ../pcre2-build.tar.gz .
312+
313+
scp -i id_rsa_zos -P "$ZOS_PORT" pcre2-build.tar.gz "$ZOS_HOST:/data/"
314+
ssh -i id_rsa_zos -p "$ZOS_PORT" "$ZOS_HOST" /data/zopen/usr/local/bin/bash -c \
315+
'export _BPXK_AUTOCVT=ON;
316+
export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)";
317+
export _TAG_REDIR_ERR=txt;
318+
export _TAG_REDIR_IN=txt;
319+
export _TAG_REDIR_OUT=txt;
320+
. /data/zopen/etc/zopen-config;
321+
set -e;
322+
set -x;
323+
cd /data;
324+
rm -rf pcre2-build;
325+
mkdir pcre2-build;
326+
gtar xzf pcre2-build.tar.gz -C pcre2-build;
327+
cd pcre2-build;
328+
chtag -R -tc ISO8859-1 .;
329+
MAKE=gmake CC=xlc ./configure --enable-ebcdic --disable-unicode;
330+
gmake;
331+
gmake check'
332+
284333
distcheck:
285334
name: Build & verify distribution
286335
runs-on: ubuntu-latest

Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ lib_LTLIBRARIES =
235235
# TESTS is for binary unit tests, check_SCRIPTS for script-based tests
236236

237237
TESTS =
238+
XFAIL_TESTS =
238239
check_SCRIPTS =
239240
dist_noinst_SCRIPTS =
240241

@@ -724,6 +725,9 @@ if WITH_PCRE2_8
724725
TESTS += RunGrepTest
725726
EXTRA_DIST += RunGrepTest.bat
726727
dist_noinst_SCRIPTS += RunGrepTest
728+
if WITH_EBCDIC
729+
XFAIL_TESTS += RunGrepTest
730+
endif # WITH_EBCDIC
727731
endif # WITH_PCRE2_8
728732

729733
## Distribute all the test data files

RunTest

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ fi
130130

131131
# Set up a suitable "diff" command for comparison. Some systems
132132
# have a diff that lacks a -u option. Try to deal with this.
133+
# Use gdiff if available.
133134

134135
cf="diff"
135-
diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u"
136+
gdiff /dev/null /dev/null 2>/dev/null && cf="gdiff"
137+
$cf -u /dev/null /dev/null 2>/dev/null && cf="$cf -u"
136138

137139
# Find the test data
138140

src/pcre2_compile.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,14 @@ POSSIBILITY OF SUCH DAMAGE.
5555
#else
5656
#define PRINTABLE(c) ((c) >= 32 && (c) < 127)
5757
#endif
58-
#define CHAR_OUTPUT(c) (c)
59-
#define CHAR_INPUT(c) (c)
58+
#define CHAR_OUTPUT(c) (c)
59+
#define CHAR_OUTPUT_HEX(c) (c)
60+
#define CHAR_INPUT(c) (c)
61+
#define CHAR_INPUT_HEX(c) (c)
6062
#include "pcre2_printint.c"
6163
#undef PRINTABLE
6264
#undef CHAR_OUTPUT
65+
#undef CHAR_OUTPUT_HEX
6366
#undef CHAR_INPUT
6467
#define DEBUG_CALL_PRINTINT
6568
#endif

src/pcre2_compile_class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ while (TRUE)
12851285
uint8_t posix_vertical[4] = { CHAR_LF, CHAR_VT, CHAR_FF, CHAR_CR };
12861286
uint8_t posix_underscore = CHAR_UNDERSCORE;
12871287
uint8_t *chars = NULL;
1288-
uint n = 0;
1288+
int n = 0;
12891289

12901290
if (tabopt == 1) { chars = posix_vertical; n = 4; }
12911291
else if (tabopt == 2) { chars = &posix_underscore; n = 1; }

src/pcre2_printint.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ if (utf)
120120
if (one_code_unit)
121121
{
122122
if (PRINTABLE(c))
123-
fprintf(f, "%c", (char)CHAR_OUTPUT(c));
123+
fprintf(f, "%c", CHAR_OUTPUT(c));
124124
else
125125
{
126-
c = CHAR_OUTPUT(c);
126+
c = CHAR_OUTPUT_HEX(c);
127127
if (c < 0x80) fprintf(f, "\\x%02x", c);
128128
else fprintf(f, "\\x{%02x}", c);
129129
}
@@ -219,7 +219,7 @@ while (*ptr != '\0')
219219
{
220220
uint32_t c = *ptr++;
221221
if (PRINTABLE(c)) fprintf(f, "%c", CHAR_OUTPUT(c));
222-
else fprintf(f, "\\x{%x}", CHAR_OUTPUT(c));
222+
else fprintf(f, "\\x{%x}", CHAR_OUTPUT_HEX(c));
223223
}
224224
}
225225

@@ -230,7 +230,7 @@ for (; len > 0; len--)
230230
{
231231
uint32_t c = *ptr++;
232232
if (PRINTABLE(c)) fprintf(f, "%c", CHAR_OUTPUT(c));
233-
else fprintf(f, "\\x{%x}", CHAR_OUTPUT(c));
233+
else fprintf(f, "\\x{%x}", CHAR_OUTPUT_HEX(c));
234234
}
235235
}
236236

@@ -481,22 +481,22 @@ if (negated)
481481

482482
for (input = 0; input < 256; input++)
483483
{
484-
i = CHAR_INPUT(input);
484+
i = CHAR_INPUT_HEX(input);
485485
if ((map[i/8] & (1u << (i&7))) != 0)
486486
{
487487
int j, jinput;
488488
for (jinput = input; jinput+1 < 256; jinput++)
489489
{
490-
j = CHAR_INPUT(jinput+1);
490+
j = CHAR_INPUT_HEX(jinput+1);
491491
if ((map[j/8] & (1u << (j&7))) == 0) break;
492492
}
493-
j = CHAR_INPUT(jinput);
493+
j = CHAR_INPUT_HEX(jinput);
494494
if (i == CHAR_MINUS || i == CHAR_BACKSLASH ||
495495
i == CHAR_RIGHT_SQUARE_BRACKET ||
496496
(first && i == CHAR_CIRCUMFLEX_ACCENT))
497497
fprintf(f, "\\");
498498
if (PRINTABLE(i)) fprintf(f, "%c", CHAR_OUTPUT(i));
499-
else fprintf(f, "\\x%02x", CHAR_OUTPUT(i));
499+
else fprintf(f, "\\x%02x", CHAR_OUTPUT_HEX(i));
500500
first = FALSE;
501501
if (jinput > input)
502502
{
@@ -505,7 +505,7 @@ for (input = 0; input < 256; input++)
505505
j == CHAR_RIGHT_SQUARE_BRACKET)
506506
fprintf(f, "\\");
507507
if (PRINTABLE(j)) fprintf(f, "%c", CHAR_OUTPUT(j));
508-
else fprintf(f, "\\x%02x", CHAR_OUTPUT(j));
508+
else fprintf(f, "\\x%02x", CHAR_OUTPUT_HEX(j));
509509
}
510510
input = jinput;
511511
}

src/pcre2test.c

Lines changed: 88 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,8 @@ as a hex value when showing compiled patterns. We use it in cases when the
262262
locale has not been explicitly changed, so as to get consistent output from
263263
systems that differ in their output from isprint() even in the "C" locale. */
264264

265-
#if defined(EBCDIC) && !EBCDIC_IO
266-
#define PRINTABLE(c) (ebcdic_to_ascii(c) >= 32 && ebcdic_to_ascii(c) < 127)
267-
#elif defined(EBCDIC)
268-
#define PRINTABLE(c) ((c) >= 64 && (c) < 255)
265+
#if defined(EBCDIC)
266+
#define PRINTABLE(c) printable(c)
269267
#else
270268
#define PRINTABLE(c) ((c) >= 32 && (c) < 127)
271269
#endif
@@ -275,11 +273,20 @@ format. The input character is encoded in PCRE2's native codepage (EBCDIC, if
275273
enabled), but the output may differ in the case where pcre2test uses ASCII input
276274
and output. */
277275
#if defined(EBCDIC) && !EBCDIC_IO
278-
#define CHAR_OUTPUT(c) ebcdic_to_ascii(c)
279-
#define CHAR_INPUT(c) ascii_to_ebcdic(c)
276+
#define CHAR_OUTPUT(c) ebcdic_to_ascii(c)
277+
#define CHAR_OUTPUT_HEX(c) CHAR_OUTPUT(c)
278+
#define CHAR_INPUT(c) ascii_to_ebcdic(c)
279+
#define CHAR_INPUT_HEX(c) CHAR_INPUT(c)
280+
#elif defined(EBCDIC)
281+
#define CHAR_OUTPUT(c) (c)
282+
#define CHAR_OUTPUT_HEX(c) ebcdic_to_ascii(c)
283+
#define CHAR_INPUT(c) (c)
284+
#define CHAR_INPUT_HEX(c) ascii_to_ebcdic(c)
280285
#else
281-
#define CHAR_OUTPUT(c) (c)
282-
#define CHAR_INPUT(c) (c)
286+
#define CHAR_OUTPUT(c) (c)
287+
#define CHAR_OUTPUT_HEX(c) CHAR_OUTPUT(c)
288+
#define CHAR_INPUT(c) (c)
289+
#define CHAR_INPUT_HEX(c) CHAR_INPUT(c)
283290
#endif
284291

285292
/* We have to include some of the library source files because we need
@@ -313,10 +320,15 @@ previous definition of PRIV avoids name clashes. */
313320
#include "pcre2_tables.c"
314321
#include "pcre2_ucd.c"
315322

316-
/* Forward-declarations for PRINTABLE(). */
323+
/* Forward-declarations for PRINTABLE(), etc. */
317324

325+
#if defined(EBCDIC)
326+
static BOOL printable(uint32_t c);
327+
#endif
318328
#if defined(EBCDIC) && !EBCDIC_IO
319329
static void ascii_to_ebcdic_str(uint8_t *buf, size_t len);
330+
#endif
331+
#if defined(EBCDIC)
320332
static uint32_t ascii_to_ebcdic(uint32_t c);
321333
static uint32_t ebcdic_to_ascii(uint32_t c);
322334
#endif
@@ -3045,14 +3057,71 @@ return (PCRE2_JIT_STACK *)arg;
30453057
* EBCDIC support functions *
30463058
*************************************************/
30473059

3060+
#if defined(EBCDIC)
3061+
static BOOL
3062+
printable(uint32_t c)
3063+
{
3064+
if ((c >= CHAR_a && c <= CHAR_i) ||
3065+
(c >= CHAR_j && c <= CHAR_r) ||
3066+
(c >= CHAR_s && c <= CHAR_z) ||
3067+
(c >= CHAR_A && c <= CHAR_I) ||
3068+
(c >= CHAR_J && c <= CHAR_R) ||
3069+
(c >= CHAR_S && c <= CHAR_Z) ||
3070+
(c >= CHAR_0 && c <= CHAR_9))
3071+
return TRUE;
3072+
3073+
switch (c)
3074+
{
3075+
case CHAR_SPACE:
3076+
case CHAR_EXCLAMATION_MARK:
3077+
case CHAR_QUOTATION_MARK:
3078+
case CHAR_NUMBER_SIGN:
3079+
case CHAR_DOLLAR_SIGN:
3080+
case CHAR_PERCENT_SIGN:
3081+
case CHAR_AMPERSAND:
3082+
case CHAR_APOSTROPHE:
3083+
case CHAR_LEFT_PARENTHESIS:
3084+
case CHAR_RIGHT_PARENTHESIS:
3085+
case CHAR_ASTERISK:
3086+
case CHAR_PLUS:
3087+
case CHAR_COMMA:
3088+
case CHAR_MINUS:
3089+
case CHAR_DOT:
3090+
case CHAR_SLASH:
3091+
case CHAR_COLON:
3092+
case CHAR_SEMICOLON:
3093+
case CHAR_LESS_THAN_SIGN:
3094+
case CHAR_EQUALS_SIGN:
3095+
case CHAR_GREATER_THAN_SIGN:
3096+
case CHAR_QUESTION_MARK:
3097+
case CHAR_COMMERCIAL_AT:
3098+
case CHAR_LEFT_SQUARE_BRACKET:
3099+
case CHAR_BACKSLASH:
3100+
case CHAR_RIGHT_SQUARE_BRACKET:
3101+
case CHAR_CIRCUMFLEX_ACCENT:
3102+
case CHAR_UNDERSCORE:
3103+
case CHAR_GRAVE_ACCENT:
3104+
case CHAR_LEFT_CURLY_BRACKET:
3105+
case CHAR_VERTICAL_LINE:
3106+
case CHAR_RIGHT_CURLY_BRACKET:
3107+
case CHAR_TILDE:
3108+
return TRUE;
3109+
}
3110+
3111+
return FALSE;
3112+
}
3113+
#endif
3114+
30483115
#if defined(EBCDIC) && !EBCDIC_IO
30493116
static void
30503117
ascii_to_ebcdic_str(uint8_t *buf, size_t len)
30513118
{
30523119
for (size_t i = 0; i < len; ++i)
30533120
buf[i] = ascii_to_ebcdic_1047[buf[i]];
30543121
}
3122+
#endif
30553123

3124+
#if defined(EBCDIC)
30563125
static uint32_t
30573126
ascii_to_ebcdic(uint32_t c)
30583127
{
@@ -3161,7 +3230,7 @@ if (PRINTABLE(c))
31613230
return 1;
31623231
}
31633232

3164-
c = CHAR_OUTPUT(c);
3233+
c = CHAR_OUTPUT_HEX(c);
31653234

31663235
if (c < 0x100)
31673236
{
@@ -4983,7 +5052,7 @@ if ((pat_patctl.control & CTL_INFO) != 0)
49835052
fprintf(outfile, "Starting code units:");
49845053
for (input = 0; input < 256; input++)
49855054
{
4986-
int i = CHAR_INPUT(input);
5055+
int i = CHAR_INPUT_HEX(input);
49875056
if ((start_bits[i/8] & (1u << (i&7))) != 0)
49885057
{
49895058
if (c > 75)
@@ -4998,7 +5067,7 @@ if ((pat_patctl.control & CTL_INFO) != 0)
49985067
}
49995068
else
50005069
{
5001-
fprintf(outfile, " \\x%02x", CHAR_OUTPUT(i));
5070+
fprintf(outfile, " \\x%02x", CHAR_OUTPUT_HEX(i));
50025071
c += 5;
50035072
}
50045073
}
@@ -5645,8 +5714,9 @@ if ((pat_patctl.control & CTL_HEXPAT) != 0)
56455714
}
56465715
c = toupper(c);
56475716
d = toupper(d);
5648-
*pt++ = ((isdigit(c)? (c - '0') : (c - 'A' + 10)) << 4) +
5649-
(isdigit(d)? (d - '0') : (d - 'A' + 10));
5717+
c = isdigit(c)? (c - '0') : (c - 'A' + 10);
5718+
d = isdigit(d)? (d - '0') : (d - 'A' + 10);
5719+
*pt++ = CHAR_OUTPUT(CHAR_INPUT_HEX((c << 4) + d));
56505720
}
56515721
}
56525722
*pt = 0;
@@ -7554,6 +7624,7 @@ while ((c = *p++) != 0)
75547624
c -= '0';
75557625
while (i++ < 2 && isdigit(*p) && *p < '8')
75567626
c = c * 8 + (*p++ - '0');
7627+
c = CHAR_OUTPUT(CHAR_INPUT_HEX(c));
75577628

75587629
encoding = (utf && c > 255)? FORCE_UTF : FORCE_RAW;
75597630
break;
@@ -7572,6 +7643,7 @@ while ((c = *p++) != 0)
75727643
}
75737644
else c = c * 8 + (*pt - '0');
75747645
}
7646+
c = CHAR_OUTPUT(CHAR_INPUT_HEX(c));
75757647
if (i == 0 || *pt != '}')
75767648
{
75777649
fprintf(outfile, "** Malformed \\o{ escape\n");
@@ -7603,6 +7675,7 @@ while ((c = *p++) != 0)
76037675
}
76047676
else c = c * 16 + (tolower(*pt) - (isdigit(*pt)? '0' : 'a' - 10));
76057677
}
7678+
c = CHAR_OUTPUT(CHAR_INPUT_HEX(c));
76067679
if (i == 0 || *pt != '}')
76077680
{
76087681
fprintf(outfile, "** Malformed \\x{ escape\n");
@@ -7622,6 +7695,7 @@ while ((c = *p++) != 0)
76227695
c = c * 16 + (tolower(*p) - (isdigit(*p)? '0' : 'a' - 10));
76237696
p++;
76247697
}
7698+
c = CHAR_OUTPUT(CHAR_INPUT_HEX(c));
76257699
#if defined SUPPORT_PCRE2_8
76267700
if (utf && (test_mode == PCRE8_MODE)) encoding = FORCE_RAW;
76277701
#endif

testdata/testinput2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6202,8 +6202,6 @@ a)"xI
62026202
/\sxxx\s/tables=2
62036203
AB\x{85}xxx\x{a0}XYZ
62046204

6205-
#endif
6206-
62076205
/^\w+/tables=2
62086206
École
62096207

@@ -6215,6 +6213,8 @@ a)"xI
62156213
/^\w+/tables=3
62166214
École
62176215

6216+
#endif
6217+
62186218
/"(*MARK:>" 00 "<).."/hex,mark,no_start_optimize
62196219
AB
62206220
A\=ph

0 commit comments

Comments
 (0)