/[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 340 by ph10, Fri Apr 18 20:00:21 2008 UTC revision 341 by ph10, Sat Apr 19 16:41:04 2008 UTC
# Line 976  be terminated by '>' because that is che Line 976  be terminated by '>' because that is che
976    
977  Arguments:  Arguments:
978    ptr          current position in the pattern    ptr          current position in the pattern
979    count        current count of capturing parens so far encountered    cd           compile background data
980    name         name to seek, or NULL if seeking a numbered subpattern    name         name to seek, or NULL if seeking a numbered subpattern
981    lorn         name length, or subpattern number if name is NULL    lorn         name length, or subpattern number if name is NULL
982    xmode        TRUE if we are in /x mode    xmode        TRUE if we are in /x mode
# Line 985  Returns: the number of the named s Line 985  Returns: the number of the named s
985  */  */
986    
987  static int  static int
988  find_parens(const uschar *ptr, int count, const uschar *name, int lorn,  find_parens(const uschar *ptr, compile_data *cd, const uschar *name, int lorn,
989    BOOL xmode)    BOOL xmode)
990  {  {
991  const uschar *thisname;  const uschar *thisname;
992    int count = cd->bracount;
993    
994  for (; *ptr != 0; ptr++)  for (; *ptr != 0; ptr++)
995    {    {
# Line 1031  for (; *ptr != 0; ptr++) Line 1032  for (; *ptr != 0; ptr++)
1032        }        }
1033    
1034      /* If the next character is ']', it is a data character that must be      /* If the next character is ']', it is a data character that must be
1035      skipped. */      skipped, except in JavaScript compatibility mode. */
1036    
1037      if (ptr[1] == ']') ptr++;      if (ptr[1] == ']' && (cd->external_options & PCRE_JAVASCRIPT_COMPAT) == 0)
1038          ptr++;
1039    
1040      while (*(++ptr) != ']')      while (*(++ptr) != ']')
1041        {        {
# Line 2721  for (;; ptr++) Line 2723  for (;; ptr++)
2723          negate_class = TRUE;          negate_class = TRUE;
2724        else break;        else break;
2725        }        }
2726    
2727        /* Empty classes are allowed in JavaScript compatibility mode. Otherwise,
2728        an initial ']' is taken as a data character -- the code below handles
2729        that. In JS mode, [] must always fail, so generate OP_FAIL, whereas
2730        [^] must match any character, so generate OP_ALLANY. */
2731    
2732        if (c ==']' && (cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
2733          {
2734          *code++ = negate_class? OP_ALLANY : OP_FAIL;
2735          if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
2736          zerofirstbyte = firstbyte;
2737          break;
2738          }
2739    
2740      /* If a class contains a negative special such as \S, we need to flip the      /* If a class contains a negative special such as \S, we need to flip the
2741      negation flag at the end, so that support for characters > 255 works      negation flag at the end, so that support for characters > 255 works
# Line 4102  we set the flag only if there is a liter Line 4117  we set the flag only if there is a liter
4117            }            }
4118          }          }
4119        }        }
4120    
4121        /* If previous is OP_FAIL, it was generated by an empty class [] in
4122        JavaScript mode. The other ways in which OP_FAIL can be generated, that is
4123        by (*FAIL) or (?!) set previous to NULL, which gives a "nothing to repeat"
4124        error above. We can just ignore the repeat in JS case. */
4125    
4126        else if (*previous == OP_FAIL) goto END_REPEAT;
4127    
4128      /* Else there's some kind of shambles */      /* Else there's some kind of shambles */
4129    
# Line 4389  we set the flag only if there is a liter Line 4411  we set the flag only if there is a liter
4411    
4412          /* Search the pattern for a forward reference */          /* Search the pattern for a forward reference */
4413    
4414          else if ((i = find_parens(ptr, cd->bracount, name, namelen,          else if ((i = find_parens(ptr, cd, name, namelen,
4415                          (options & PCRE_EXTENDED) != 0)) > 0)                          (options & PCRE_EXTENDED) != 0)) > 0)
4416            {            {
4417            PUT2(code, 2+LINK_SIZE, i);            PUT2(code, 2+LINK_SIZE, i);
# Line 4686  we set the flag only if there is a liter Line 4708  we set the flag only if there is a liter
4708              recno = GET2(slot, 0);              recno = GET2(slot, 0);
4709              }              }
4710            else if ((recno =                /* Forward back reference */            else if ((recno =                /* Forward back reference */
4711                      find_parens(ptr, cd->bracount, name, namelen,                      find_parens(ptr, cd, name, namelen,
4712                        (options & PCRE_EXTENDED) != 0)) <= 0)                        (options & PCRE_EXTENDED) != 0)) <= 0)
4713              {              {
4714              *errorcodeptr = ERR15;              *errorcodeptr = ERR15;
# Line 4796  we set the flag only if there is a liter Line 4818  we set the flag only if there is a liter
4818    
4819              if (called == NULL)              if (called == NULL)
4820                {                {
4821                if (find_parens(ptr, cd->bracount, NULL, recno,                if (find_parens(ptr, cd, NULL, recno,
4822                     (options & PCRE_EXTENDED) != 0) < 0)                      (options & PCRE_EXTENDED) != 0) < 0)
4823                  {                  {
4824                  *errorcodeptr = ERR15;                  *errorcodeptr = ERR15;
4825                  goto FAILED;                  goto FAILED;

Legend:
Removed from v.340  
changed lines
  Added in v.341

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12