@@ -123,8 +123,10 @@ static void describe_failure(
123
123
uint32_t compile_options ,
124
124
uint32_t match_options ,
125
125
int errorcode ,
126
- pcre2_match_data * match_data ,
127
126
int errorcode_jit ,
127
+ int matches ,
128
+ int matches_jit ,
129
+ pcre2_match_data * match_data ,
128
130
pcre2_match_data * match_data_jit ,
129
131
pcre2_match_context * match_context
130
132
) {
@@ -145,31 +147,31 @@ print_match_options(stderr, match_options);
145
147
if (errorcode < 0 )
146
148
{
147
149
pcre2_get_error_message (errorcode , buffer , 256 );
148
- fprintf (stderr , "Non-JIT'd operation emitted an error: %s\n" , buffer );
150
+ fprintf (stderr , "Non-JIT'd operation emitted an error: %s (%d) \n" , buffer , errorcode );
149
151
}
150
- else
152
+ if ( matches >= 0 )
151
153
{
152
154
fprintf (stderr , "Non-JIT'd operation did not emit an error.\n" );
153
155
if (match_data != NULL )
154
156
{
155
- fprintf (stderr , "%d matches discovered by non-JIT'd regex:\n" , errorcode );
156
- dump_matches (stderr , errorcode , match_data , match_context );
157
+ fprintf (stderr , "%d matches discovered by non-JIT'd regex:\n" , matches );
158
+ dump_matches (stderr , matches , match_data , match_context );
157
159
fprintf (stderr , "\n" );
158
160
}
159
161
}
160
162
161
163
if (errorcode_jit < 0 )
162
164
{
163
165
pcre2_get_error_message (errorcode_jit , buffer , 256 );
164
- fprintf (stderr , "JIT'd operation emitted an error: %s\n" , buffer );
166
+ fprintf (stderr , "JIT'd operation emitted an error: %s (%d) \n" , buffer , errorcode_jit );
165
167
}
166
- else
168
+ if ( matches_jit >= 0 )
167
169
{
168
170
fprintf (stderr , "JIT'd operation did not emit an error.\n" );
169
171
if (match_data_jit != NULL )
170
172
{
171
- fprintf (stderr , "%d matches discovered by JIT'd regex:\n" , errorcode_jit );
172
- dump_matches (stderr , errorcode_jit , match_data_jit , match_context );
173
+ fprintf (stderr , "%d matches discovered by JIT'd regex:\n" , matches_jit );
174
+ dump_matches (stderr , matches_jit , match_data_jit , match_context );
173
175
fprintf (stderr , "\n" );
174
176
}
175
177
}
@@ -246,6 +248,8 @@ for (i = 0; i < 2; i++)
246
248
int errorcode ;
247
249
#ifdef SUPPORT_JIT
248
250
int errorcode_jit ;
251
+ int matches = 0 ;
252
+ int matches_jit = 0 ;
249
253
#endif
250
254
PCRE2_SIZE erroroffset ;
251
255
pcre2_code * code ;
@@ -332,42 +336,52 @@ for (i = 0; i < 2; i++)
332
336
errorcode_jit = pcre2_match (code , (PCRE2_SPTR )data , (PCRE2_SIZE )match_size , 0 ,
333
337
match_options & ~PCRE2_NO_JIT , match_data_jit , match_context );
334
338
339
+ matches = errorcode ;
340
+ matches_jit = errorcode_jit ;
341
+
335
342
if (errorcode_jit != errorcode )
336
343
{
337
- describe_failure ("match errorcode comparison" , data , size , compile_options , match_options , errorcode , match_data , errorcode_jit , match_data_jit , match_context );
344
+ if (!(errorcode < 0 && errorcode_jit < 0 ) &&
345
+ errorcode != PCRE2_ERROR_MATCHLIMIT &&
346
+ errorcode_jit != PCRE2_ERROR_MATCHLIMIT && errorcode_jit != PCRE2_ERROR_JIT_STACKLIMIT )
347
+ {
348
+ describe_failure ("match errorcode comparison" , data , size , compile_options , match_options , errorcode , errorcode_jit , matches , matches_jit , match_data , match_data_jit , match_context );
349
+ }
338
350
}
339
-
340
- for (int index = 0 ; index < errorcode ; index ++ )
351
+ else
341
352
{
342
- PCRE2_UCHAR * bufferptr , * bufferptr_jit ;
343
- PCRE2_SIZE bufflen , bufflen_jit ;
344
-
345
- bufferptr = bufferptr_jit = NULL ;
346
- bufflen = bufflen_jit = 0 ;
353
+ for (int index = 0 ; index < errorcode ; index ++ )
354
+ {
355
+ PCRE2_UCHAR * bufferptr , * bufferptr_jit ;
356
+ PCRE2_SIZE bufflen , bufflen_jit ;
347
357
348
- errorcode = pcre2_substring_get_bynumber ( match_data , ( uint32_t ) index , & bufferptr , & bufflen ) ;
349
- errorcode_jit = pcre2_substring_get_bynumber ( match_data_jit , ( uint32_t ) index , & bufferptr_jit , & bufflen_jit ) ;
358
+ bufferptr = bufferptr_jit = NULL ;
359
+ bufflen = bufflen_jit = 0 ;
350
360
351
- if (errorcode != errorcode_jit )
352
- {
353
- describe_failure ("ovector entry errorcode comparison" , data , size , compile_options , match_options , errorcode , match_data , errorcode_jit , match_data_jit , match_context );
354
- }
361
+ errorcode = pcre2_substring_get_bynumber (match_data , (uint32_t ) index , & bufferptr , & bufflen );
362
+ errorcode_jit = pcre2_substring_get_bynumber (match_data_jit , (uint32_t ) index , & bufferptr_jit , & bufflen_jit );
355
363
356
- if (errorcode >= 0 )
357
- {
358
- if (bufflen != bufflen_jit )
364
+ if (errorcode != errorcode_jit )
359
365
{
360
- describe_failure ("ovector entry length comparison" , data , size , compile_options , match_options , errorcode , match_data , errorcode_jit , match_data_jit , match_context );
366
+ describe_failure ("match entry errorcode comparison" , data , size , compile_options , match_options , errorcode , errorcode_jit , matches , matches_jit , match_data , match_data_jit , match_context );
361
367
}
362
368
363
- if (memcmp ( bufferptr , bufferptr_jit , bufflen ) ! = 0 )
369
+ if (errorcode > = 0 )
364
370
{
365
- describe_failure ("ovector entry content comparison" , data , size , compile_options , match_options , errorcode , match_data , errorcode_jit , match_data_jit , match_context );
371
+ if (bufflen != bufflen_jit )
372
+ {
373
+ describe_failure ("match entry length comparison" , data , size , compile_options , match_options , errorcode , errorcode_jit , matches , matches_jit , match_data , match_data_jit , match_context );
374
+ }
375
+
376
+ if (memcmp (bufferptr , bufferptr_jit , bufflen ) != 0 )
377
+ {
378
+ describe_failure ("match entry content comparison" , data , size , compile_options , match_options , errorcode , errorcode_jit , matches , matches_jit , match_data , match_data_jit , match_context );
379
+ }
366
380
}
367
- }
368
381
369
- pcre2_substring_free (bufferptr );
370
- pcre2_substring_free (bufferptr_jit );
382
+ pcre2_substring_free (bufferptr );
383
+ pcre2_substring_free (bufferptr_jit );
384
+ }
371
385
}
372
386
}
373
387
#endif
0 commit comments