/[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 504 by ph10, Mon Mar 8 08:57:04 2010 UTC revision 507 by ph10, Wed Mar 10 16:08:01 2010 UTC
# Line 92  is 4 there is plenty of room. */ Line 92  is 4 there is plenty of room. */
92    
93  #define COMPILE_WORK_SIZE (4096)  #define COMPILE_WORK_SIZE (4096)
94    
95    /* The overrun tests check for a slightly smaller size so that they detect the
96    overrun before it actually does run off the end of the data block. */
97    
98    #define WORK_SIZE_CHECK (COMPILE_WORK_SIZE - 100)
99    
100    
101  /* Table for handling escaped characters in the range '0'-'z'. Positive returns  /* Table for handling escaped characters in the range '0'-'z'. Positive returns
102  are simple data values; negative values are for special things like \d and so  are simple data values; negative values are for special things like \d and so
# Line 263  the number of relocations needed when a Line 268  the number of relocations needed when a
268  it is now one long string. We cannot use a table of offsets, because the  it is now one long string. We cannot use a table of offsets, because the
269  lengths of inserts such as XSTRING(MAX_NAME_SIZE) are not known. Instead, we  lengths of inserts such as XSTRING(MAX_NAME_SIZE) are not known. Instead, we
270  simply count through to the one we want - this isn't a performance issue  simply count through to the one we want - this isn't a performance issue
271  because these strings are used only when there is a compilation error.  because these strings are used only when there is a compilation error.
272    
273  Each substring ends with \0 to insert a null character. This includes the final  Each substring ends with \0 to insert a null character. This includes the final
274  substring, so that the whole string ends with \0\0, which can be detected when  substring, so that the whole string ends with \0\0, which can be detected when
275  counting through. */  counting through. */
276    
277  static const char error_texts[] =  static const char error_texts[] =
# Line 506  static const char * Line 511  static const char *
511  find_error_text(int n)  find_error_text(int n)
512  {  {
513  const char *s = error_texts;  const char *s = error_texts;
514  for (; n > 0; n--)  for (; n > 0; n--)
515    {    {
516    while (*s++ != 0) {};    while (*s++ != 0) {};
517    if (*s == 0) return "Error text not found (please report)";    if (*s == 0) return "Error text not found (please report)";
518    }    }
519  return s;  return s;
520  }  }
521    
# Line 1802  for (code = first_significant_code(code Line 1807  for (code = first_significant_code(code
1807    const uschar *ccode;    const uschar *ccode;
1808    
1809    c = *code;    c = *code;
1810    
1811    /* Skip over forward assertions; the other assertions are skipped by    /* Skip over forward assertions; the other assertions are skipped by
1812    first_significant_code() with a TRUE final argument. */    first_significant_code() with a TRUE final argument. */
1813    
# Line 1822  for (code = first_significant_code(code Line 1827  for (code = first_significant_code(code
1827      c = *code;      c = *code;
1828      continue;      continue;
1829      }      }
1830    
1831    /* For a recursion/subroutine call, if its end has been reached, which    /* For a recursion/subroutine call, if its end has been reached, which
1832    implies a subroutine call, we can scan it. */    implies a subroutine call, we can scan it. */
1833    
1834    if (c == OP_RECURSE)    if (c == OP_RECURSE)
1835      {      {
1836      BOOL empty_branch = FALSE;      BOOL empty_branch = FALSE;
1837      const uschar *scode = cd->start_code + GET(code, 1);      const uschar *scode = cd->start_code + GET(code, 1);
1838      if (GET(scode, 1) == 0) return TRUE;    /* Unclosed */      if (GET(scode, 1) == 0) return TRUE;    /* Unclosed */
1839      do      do
# Line 1836  for (code = first_significant_code(code Line 1841  for (code = first_significant_code(code
1841        if (could_be_empty_branch(scode, endcode, utf8, cd))        if (could_be_empty_branch(scode, endcode, utf8, cd))
1842          {          {
1843          empty_branch = TRUE;          empty_branch = TRUE;
1844          break;          break;
1845          }          }
1846        scode += GET(scode, 1);        scode += GET(scode, 1);
1847        }        }
1848      while (*scode == OP_ALT);      while (*scode == OP_ALT);
1849      if (!empty_branch) return FALSE;  /* All branches are non-empty */      if (!empty_branch) return FALSE;  /* All branches are non-empty */
1850      continue;      continue;
1851      }      }
1852    
1853    /* For other groups, scan the branches. */    /* For other groups, scan the branches. */
1854    
# Line 1999  for (code = first_significant_code(code Line 2004  for (code = first_significant_code(code
2004  #endif  #endif
2005    
2006      /* None of the remaining opcodes are required to match a character. */      /* None of the remaining opcodes are required to match a character. */
2007    
2008      default:      default:
2009      break;      break;
2010      }      }
2011    }    }
2012    
# Line 2024  Arguments: Line 2029  Arguments:
2029    endcode     points to where to stop (current RECURSE item)    endcode     points to where to stop (current RECURSE item)
2030    bcptr       points to the chain of current (unclosed) branch starts    bcptr       points to the chain of current (unclosed) branch starts
2031    utf8        TRUE if in UTF-8 mode    utf8        TRUE if in UTF-8 mode
2032    cd          pointers to tables etc    cd          pointers to tables etc
2033    
2034  Returns:      TRUE if what is matched could be empty  Returns:      TRUE if what is matched could be empty
2035  */  */
# Line 2760  for (;; ptr++) Line 2765  for (;; ptr++)
2765  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
2766      if (code > cd->hwm) cd->hwm = code;                 /* High water info */      if (code > cd->hwm) cd->hwm = code;                 /* High water info */
2767  #endif  #endif
2768      if (code > cd->start_workspace + COMPILE_WORK_SIZE) /* Check for overrun */      if (code > cd->start_workspace + WORK_SIZE_CHECK)   /* Check for overrun */
2769        {        {
2770        *errorcodeptr = ERR52;        *errorcodeptr = ERR52;
2771        goto FAILED;        goto FAILED;
# Line 2809  for (;; ptr++) Line 2814  for (;; ptr++)
2814    /* In the real compile phase, just check the workspace used by the forward    /* In the real compile phase, just check the workspace used by the forward
2815    reference list. */    reference list. */
2816    
2817    else if (cd->hwm > cd->start_workspace + COMPILE_WORK_SIZE)    else if (cd->hwm > cd->start_workspace + WORK_SIZE_CHECK)
2818      {      {
2819      *errorcodeptr = ERR52;      *errorcodeptr = ERR52;
2820      goto FAILED;      goto FAILED;
# Line 4470  we set the flag only if there is a liter Line 4475  we set the flag only if there is a liter
4475    
4476          /* Because we are moving code along, we must ensure that any          /* Because we are moving code along, we must ensure that any
4477          pending recursive references are updated. */          pending recursive references are updated. */
4478    
4479          default:          default:
4480          *code = OP_END;          *code = OP_END;
4481          adjust_recurse(tempcode, 1 + LINK_SIZE, utf8, cd, save_hwm);          adjust_recurse(tempcode, 1 + LINK_SIZE, utf8, cd, save_hwm);
# Line 5192  we set the flag only if there is a liter Line 5197  we set the flag only if there is a liter
5197                  *errorcodeptr = ERR15;                  *errorcodeptr = ERR15;
5198                  goto FAILED;                  goto FAILED;
5199                  }                  }
5200    
5201                /* Fudge the value of "called" so that when it is inserted as an                /* Fudge the value of "called" so that when it is inserted as an
5202                offset below, what it actually inserted is the reference number                offset below, what it actually inserted is the reference number
5203                of the group. */                of the group. */
5204    
5205                called = cd->start_code + recno;                called = cd->start_code + recno;
5206                PUTINC(cd->hwm, 0, code + 2 + LINK_SIZE - cd->start_code);                PUTINC(cd->hwm, 0, code + 2 + LINK_SIZE - cd->start_code);
5207                }                }

Legend:
Removed from v.504  
changed lines
  Added in v.507

  ViewVC Help
Powered by ViewVC 1.1.5