/[pcre]/code/trunk/pcre_compile.c
ViewVC logotype

Diff of /code/trunk/pcre_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1495 by ph10, Sat Jul 12 18:22:54 2014 UTC revision 1498 by ph10, Fri Aug 8 15:22:51 2014 UTC
# Line 2374  for (code = first_significant_code(code Line 2374  for (code = first_significant_code(code
2374    if (c == OP_RECURSE)    if (c == OP_RECURSE)
2375      {      {
2376      const pcre_uchar *scode = cd->start_code + GET(code, 1);      const pcre_uchar *scode = cd->start_code + GET(code, 1);
2377        const pcre_uchar *endgroup = scode;
2378      BOOL empty_branch;      BOOL empty_branch;
2379    
2380      /* Test for forward reference or uncompleted reference. This is disabled      /* Test for forward reference or uncompleted reference. This is disabled
# Line 2388  for (code = first_significant_code(code Line 2389  for (code = first_significant_code(code
2389        if (GET(scode, 1) == 0) return TRUE;    /* Unclosed */        if (GET(scode, 1) == 0) return TRUE;    /* Unclosed */
2390        }        }
2391    
2392      /* If we are scanning a completed pattern, there are no forward references      /* If the reference is to a completed group, we need to detect whether this
2393      and all groups are complete. We need to detect whether this is a recursive      is a recursive call, as otherwise there will be an infinite loop. If it is
2394      call, as otherwise there will be an infinite loop. If it is a recursion,      a recursion, just skip over it. Simple recursions are easily detected. For
2395      just skip over it. Simple recursions are easily detected. For mutual      mutual recursions we keep a chain on the stack. */
     recursions we keep a chain on the stack. */  
2396    
2397        do endgroup += GET(endgroup, 1); while (*endgroup == OP_ALT);
2398        if (code >= scode && code <= endgroup) continue;  /* Simple recursion */
2399      else      else
2400        {        {
2401        recurse_check *r = recurses;        recurse_check *r = recurses;
       const pcre_uchar *endgroup = scode;  
   
       do endgroup += GET(endgroup, 1); while (*endgroup == OP_ALT);  
       if (code >= scode && code <= endgroup) continue;  /* Simple recursion */  
   
2402        for (r = recurses; r != NULL; r = r->prev)        for (r = recurses; r != NULL; r = r->prev)
2403          if (r->group == scode) break;          if (r->group == scode) break;
2404        if (r != NULL) continue;   /* Mutual recursion */        if (r != NULL) continue;   /* Mutual recursion */
2405        }        }
2406    
2407      /* Completed reference; scan the referenced group, remembering it on the      /* Completed reference; scan the referenced group, remembering it on the
2408      stack chain to detect mutual recursions. */      stack chain to detect mutual recursions. */

Legend:
Removed from v.1495  
changed lines
  Added in v.1498

  ViewVC Help
Powered by ViewVC 1.1.5