/[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 265 by ph10, Wed Nov 14 11:35:48 2007 UTC revision 270 by ph10, Fri Nov 16 19:55:16 2007 UTC
# Line 241  static const char error_texts[] = Line 241  static const char error_texts[] =
241    /* 10 */    /* 10 */
242    "operand of unlimited repeat could match the empty string\0"  /** DEAD **/    "operand of unlimited repeat could match the empty string\0"  /** DEAD **/
243    "internal error: unexpected repeat\0"    "internal error: unexpected repeat\0"
244    "unrecognized character after (?\0"    "unrecognized character after (? or (?-\0"
245    "POSIX named classes are supported only within a class\0"    "POSIX named classes are supported only within a class\0"
246    "missing )\0"    "missing )\0"
247    /* 15 */    /* 15 */
# Line 300  static const char error_texts[] = Line 300  static const char error_texts[] =
300    "(*VERB) with an argument is not supported\0"    "(*VERB) with an argument is not supported\0"
301    /* 60 */    /* 60 */
302    "(*VERB) not recognized\0"    "(*VERB) not recognized\0"
303    "number is too big";    "number is too big\0"
304      "subpattern name expected after (?&\0"
305      "digit expected after (?+";
306    
307    
308  /* Table to identify digits and hex digits. This is used when compiling  /* Table to identify digits and hex digits. This is used when compiling
# Line 4246  we set the flag only if there is a liter Line 4248  we set the flag only if there is a liter
4248              *errorcodeptr = ERR58;              *errorcodeptr = ERR58;
4249              goto FAILED;              goto FAILED;
4250              }              }
4251            if (refsign == '-')            recno = (refsign == '-')?
4252                cd->bracount - recno + 1 : recno +cd->bracount;
4253              if (recno <= 0 || recno > cd->final_bracount)
4254              {              {
4255              recno = cd->bracount - recno + 1;              *errorcodeptr = ERR15;
4256              if (recno <= 0)              goto FAILED;
               {  
               *errorcodeptr = ERR15;  
               goto FAILED;  
               }  
4257              }              }
           else recno += cd->bracount;  
4258            PUT2(code, 2+LINK_SIZE, recno);            PUT2(code, 2+LINK_SIZE, recno);
4259            break;            break;
4260            }            }
# Line 4327  we set the flag only if there is a liter Line 4326  we set the flag only if there is a liter
4326            skipbytes = 1;            skipbytes = 1;
4327            }            }
4328    
4329          /* Check for the "name" actually being a subpattern number. */          /* Check for the "name" actually being a subpattern number. We are
4330            in the second pass here, so final_bracount is set. */
4331    
4332          else if (recno > 0)          else if (recno > 0 && recno <= cd->final_bracount)
4333            {            {
4334            PUT2(code, 2+LINK_SIZE, recno);            PUT2(code, 2+LINK_SIZE, recno);
4335            }            }
# Line 4535  we set the flag only if there is a liter Line 4535  we set the flag only if there is a liter
4535    
4536          if (lengthptr != NULL)          if (lengthptr != NULL)
4537            {            {
4538              if (namelen == 0)
4539                {
4540                *errorcodeptr = ERR62;
4541                goto FAILED;
4542                }
4543            if (*ptr != terminator)            if (*ptr != terminator)
4544              {              {
4545              *errorcodeptr = ERR42;              *errorcodeptr = ERR42;
# Line 4548  we set the flag only if there is a liter Line 4553  we set the flag only if there is a liter
4553            recno = 0;            recno = 0;
4554            }            }
4555    
4556          /* In the real compile, seek the name in the table */          /* In the real compile, seek the name in the table. We check the name
4557            first, and then check that we have reached the end of the name in the
4558            table. That way, if the name that is longer than any in the table,
4559            the comparison will fail without reading beyond the table entry. */
4560    
4561          else          else
4562            {            {
4563            slot = cd->name_table;            slot = cd->name_table;
4564            for (i = 0; i < cd->names_found; i++)            for (i = 0; i < cd->names_found; i++)
4565              {              {
4566              if (strncmp((char *)name, (char *)slot+2, namelen) == 0) break;              if (strncmp((char *)name, (char *)slot+2, namelen) == 0 &&
4567                    slot[2+namelen] == 0)
4568                  break;
4569              slot += cd->name_entry_size;              slot += cd->name_entry_size;
4570              }              }
4571    
# Line 4592  we set the flag only if there is a liter Line 4602  we set the flag only if there is a liter
4602            {            {
4603            const uschar *called;            const uschar *called;
4604    
4605            if ((refsign = *ptr) == '+') ptr++;            if ((refsign = *ptr) == '+')
4606                {
4607                ptr++;
4608                if ((digitab[*ptr] & ctype_digit) == 0)
4609                  {
4610                  *errorcodeptr = ERR63;
4611                  goto FAILED;
4612                  }
4613                }
4614            else if (refsign == '-')            else if (refsign == '-')
4615              {              {
4616              if ((digitab[ptr[1]] & ctype_digit) == 0)              if ((digitab[ptr[1]] & ctype_digit) == 0)
# Line 5919  to compile parts of the pattern into; th Line 5937  to compile parts of the pattern into; th
5937  no longer needed, so hopefully this workspace will never overflow, though there  no longer needed, so hopefully this workspace will never overflow, though there
5938  is a test for its doing so. */  is a test for its doing so. */
5939    
5940  cd->bracount = 0;  cd->bracount = cd->final_bracount = 0;
5941  cd->names_found = 0;  cd->names_found = 0;
5942  cd->name_entry_size = 0;  cd->name_entry_size = 0;
5943  cd->name_table = NULL;  cd->name_table = NULL;
# Line 5996  field. Reset the bracket count and the n Line 6014  field. Reset the bracket count and the n
6014  field; this time it's used for remembering forward references to subpatterns.  field; this time it's used for remembering forward references to subpatterns.
6015  */  */
6016    
6017    cd->final_bracount = cd->bracount;  /* Save for checking forward references */
6018  cd->bracount = 0;  cd->bracount = 0;
6019  cd->names_found = 0;  cd->names_found = 0;
6020  cd->name_table = (uschar *)re + re->name_table_offset;  cd->name_table = (uschar *)re + re->name_table_offset;

Legend:
Removed from v.265  
changed lines
  Added in v.270

  ViewVC Help
Powered by ViewVC 1.1.5