@@ -43,6 +43,8 @@ POSSIBILITY OF SUCH DAMAGE.
43
43
#include "config.h"
44
44
#endif
45
45
46
+ #include "pcre2_internal.h"
47
+
46
48
/* These defines enable debugging code */
47
49
48
50
/* #define DEBUG_FRAMES_DISPLAY */
@@ -53,15 +55,17 @@ POSSIBILITY OF SUCH DAMAGE.
53
55
#include <stdarg.h>
54
56
#endif
55
57
58
+ #ifdef DEBUG_SHOW_OPS
59
+ static const char * OP_names [] = { OP_NAME_LIST };
60
+ #endif
61
+
56
62
/* These defines identify the name of the block containing "static"
57
63
information, and fields within it. */
58
64
59
65
#define NLBLOCK mb /* Block containing newline information */
60
66
#define PSSTART start_subject /* Field containing processed string start */
61
67
#define PSEND end_subject /* Field containing processed string end */
62
68
63
- #include "pcre2_internal.h"
64
-
65
69
#define RECURSE_UNSET 0xffffffffu /* Bigger than max group number */
66
70
67
71
/* Masks for identifying the public options that are permitted at match time. */
@@ -707,7 +711,7 @@ if ((heapframe *)((char *)N + frame_size) >= frames_top)
707
711
}
708
712
709
713
#ifdef DEBUG_SHOW_RMATCH
710
- fprintf (stderr , "++ RMATCH %2d frame=%d" , Freturn_id , Frdepth + 1 );
714
+ fprintf (stderr , "++ RMATCH %d frame=%d" , Freturn_id , Frdepth + 1 );
711
715
if (group_frame_type != 0 )
712
716
{
713
717
fprintf (stderr , " type=%x " , group_frame_type );
@@ -777,10 +781,16 @@ opcodes. */
777
781
if (mb -> match_call_count ++ >= mb -> match_limit ) return PCRE2_ERROR_MATCHLIMIT ;
778
782
if (Frdepth >= mb -> match_limit_depth ) return PCRE2_ERROR_DEPTHLIMIT ;
779
783
784
+ #ifdef DEBUG_SHOW_OPS
785
+ fprintf (stderr , "\n++ New frame: type=0x%x subject offset %ld\n" ,
786
+ GF_IDMASK (Fgroup_frame_type ), Feptr - mb -> start_subject );
787
+ #endif
788
+
780
789
for (;;)
781
790
{
782
791
#ifdef DEBUG_SHOW_OPS
783
- fprintf (stderr , "++ op=%d\n" , * Fecode );
792
+ fprintf (stderr , "++ %2ld op=%3d %s\n" , Fecode - mb -> start_code , * Fecode ,
793
+ OP_names [* Fecode ]);
784
794
#endif
785
795
786
796
Fop = (uint8_t )(* Fecode ); /* Cast needed for 16-bit and 32-bit modes */
@@ -837,13 +847,17 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
837
847
838
848
if (Fcurrent_recurse != RECURSE_UNSET )
839
849
{
850
+ #ifdef DEBUG_SHOW_OPS
851
+ fprintf (stderr , "++ End within recursion\n" );
852
+ #endif
840
853
offset = Flast_group_offset ;
841
854
for (;;)
842
855
{
843
856
if (offset == PCRE2_UNSET ) return PCRE2_ERROR_INTERNAL ;
844
857
N = (heapframe * )((char * )match_data -> heapframes + offset );
845
858
P = (heapframe * )((char * )N - frame_size );
846
859
if (GF_IDMASK (N -> group_frame_type ) == GF_RECURSE ) break ;
860
+
847
861
offset = P -> last_group_offset ;
848
862
}
849
863
@@ -869,7 +883,12 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
869
883
((mb -> moptions & PCRE2_NOTEMPTY ) != 0 ||
870
884
((mb -> moptions & PCRE2_NOTEMPTY_ATSTART ) != 0 &&
871
885
Fstart_match == mb -> start_subject + mb -> start_offset )))
886
+ {
887
+ #ifdef DEBUG_SHOW_OPS
888
+ fprintf (stderr , "++ Backtrack because empty string\n" );
889
+ #endif
872
890
RRETURN (MATCH_NOMATCH );
891
+ }
873
892
874
893
/* Fail if PCRE2_ENDANCHORED is set and the end of the match is not
875
894
the end of the subject. After (*ACCEPT) we fail the entire match (at this
@@ -879,7 +898,17 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
879
898
if (Feptr < mb -> end_subject &&
880
899
((mb -> moptions | mb -> poptions ) & PCRE2_ENDANCHORED ) != 0 )
881
900
{
882
- if (Fop == OP_END ) RRETURN (MATCH_NOMATCH );
901
+ if (Fop == OP_END )
902
+ {
903
+ #ifdef DEBUG_SHOW_OPS
904
+ fprintf (stderr , "++ Backtrack because not at end (endanchored set)\n" );
905
+ #endif
906
+ RRETURN (MATCH_NOMATCH );
907
+ }
908
+
909
+ #ifdef DEBUG_SHOW_OPS
910
+ fprintf (stderr , "++ Failed ACCEPT not at end (endanchnored set)\n" );
911
+ #endif
883
912
return MATCH_NOMATCH ; /* (*ACCEPT) */
884
913
}
885
914
@@ -5842,7 +5871,6 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
5842
5871
branch_start += GET (branch_start , 1 );
5843
5872
branch_end = NULL ;
5844
5873
5845
-
5846
5874
/* Point N to the frame at the start of the most recent group, and P to its
5847
5875
predecessor. Remember the subject pointer at the start of the group. */
5848
5876
@@ -6372,7 +6400,7 @@ F = (heapframe *)((char *)F - Fback_frame); /* Backtrack */
6372
6400
mb -> cb -> callout_flags |= PCRE2_CALLOUT_BACKTRACK ; /* Note for callouts */
6373
6401
6374
6402
#ifdef DEBUG_SHOW_RMATCH
6375
- fprintf (stderr , "++ RETURN %d to %d\n" , rrc , Freturn_id );
6403
+ fprintf (stderr , "++ RETURN %d to RM %d\n" , rrc , Freturn_id );
6376
6404
#endif
6377
6405
6378
6406
switch (Freturn_id )
@@ -7404,9 +7432,18 @@ for(;;)
7404
7432
mb -> match_call_count = 0 ;
7405
7433
mb -> end_offset_top = 0 ;
7406
7434
mb -> skip_arg_count = 0 ;
7435
+
7436
+ #ifdef DEBUG_SHOW_OPS
7437
+ fprintf (stderr , "++ Calling match()\n" );
7438
+ #endif
7439
+
7407
7440
rc = match (start_match , mb -> start_code , re -> top_bracket , frame_size ,
7408
7441
match_data , mb );
7409
7442
7443
+ #ifdef DEBUG_SHOW_OPS
7444
+ fprintf (stderr , "++ match() returned %d\n\n" , rc );
7445
+ #endif
7446
+
7410
7447
if (mb -> hitend && start_partial == NULL )
7411
7448
{
7412
7449
start_partial = mb -> start_used_ptr ;
0 commit comments