/[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 117 by ph10, Fri Mar 9 15:59:06 2007 UTC revision 166 by ph10, Wed May 9 14:48:28 2007 UTC
# Line 208  static const char *error_texts[] = { Line 208  static const char *error_texts[] = {
208    "malformed number or name after (?(",    "malformed number or name after (?(",
209    "conditional group contains more than two branches",    "conditional group contains more than two branches",
210    "assertion expected after (?(",    "assertion expected after (?(",
211    "(?R or (?digits must be followed by )",    "(?R or (?[+-]digits must be followed by )",
212    /* 30 */    /* 30 */
213    "unknown POSIX class name",    "unknown POSIX class name",
214    "POSIX collating elements are not supported",    "POSIX collating elements are not supported",
# Line 242  static const char *error_texts[] = { Line 242  static const char *error_texts[] = {
242    /* 55 */    /* 55 */
243    "repeating a DEFINE group is not allowed",    "repeating a DEFINE group is not allowed",
244    "inconsistent NEWLINE options",    "inconsistent NEWLINE options",
245    "\\g is not followed by an (optionally braced) non-zero number"    "\\g is not followed by an (optionally braced) non-zero number",
246      "(?+ or (?- must be followed by a non-zero number"
247  };  };
248    
249    
# Line 3999  for (;; ptr++) Line 4000  for (;; ptr++)
4000    
4001    
4002          /* ------------------------------------------------------------ */          /* ------------------------------------------------------------ */
4003            case '-': case '+':
4004          case '0': case '1': case '2': case '3': case '4':   /* Recursion or */          case '0': case '1': case '2': case '3': case '4':   /* Recursion or */
4005          case '5': case '6': case '7': case '8': case '9':   /* subroutine */          case '5': case '6': case '7': case '8': case '9':   /* subroutine */
4006            {            {
4007            const uschar *called;            const uschar *called;
4008              int sign = *ptr;
4009    
4010              if (sign == '+') ptr++;
4011              else if (sign == '-')
4012                {
4013                if ((digitab[ptr[1]] & ctype_digit) == 0)
4014                  goto OTHER_CHAR_AFTER_QUERY;
4015                ptr++;
4016                }
4017    
4018            recno = 0;            recno = 0;
4019            while((digitab[*ptr] & ctype_digit) != 0)            while((digitab[*ptr] & ctype_digit) != 0)
4020              recno = recno * 10 + *ptr++ - '0';              recno = recno * 10 + *ptr++ - '0';
4021    
4022            if (*ptr != ')')            if (*ptr != ')')
4023              {              {
4024              *errorcodeptr = ERR29;              *errorcodeptr = ERR29;
4025              goto FAILED;              goto FAILED;
4026              }              }
4027    
4028              if (sign == '-')
4029                {
4030                if (recno == 0)
4031                  {
4032                  *errorcodeptr = ERR58;
4033                  goto FAILED;
4034                  }
4035                recno = cd->bracount - recno + 1;
4036                if (recno <= 0)
4037                  {
4038                  *errorcodeptr = ERR15;
4039                  goto FAILED;
4040                  }
4041                }
4042              else if (sign == '+')
4043                {
4044                if (recno == 0)
4045                  {
4046                  *errorcodeptr = ERR58;
4047                  goto FAILED;
4048                  }
4049                recno += cd->bracount;
4050                }
4051    
4052            /* Come here from code above that handles a named recursion */            /* Come here from code above that handles a named recursion */
4053    
# Line 4084  for (;; ptr++) Line 4121  for (;; ptr++)
4121    
4122          /* ------------------------------------------------------------ */          /* ------------------------------------------------------------ */
4123          default:              /* Other characters: check option setting */          default:              /* Other characters: check option setting */
4124            OTHER_CHAR_AFTER_QUERY:
4125          set = unset = 0;          set = unset = 0;
4126          optset = &set;          optset = &set;
4127    
# Line 5043  Returns: pointer to compiled data Line 5081  Returns: pointer to compiled data
5081                  with errorptr and erroroffset set                  with errorptr and erroroffset set
5082  */  */
5083    
5084  PCRE_DATA_SCOPE pcre *  PCRE_EXP_DEFN pcre *
5085  pcre_compile(const char *pattern, int options, const char **errorptr,  pcre_compile(const char *pattern, int options, const char **errorptr,
5086    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
5087  {  {
# Line 5051  return pcre_compile2(pattern, options, N Line 5089  return pcre_compile2(pattern, options, N
5089  }  }
5090    
5091    
5092  PCRE_DATA_SCOPE pcre *  PCRE_EXP_DEFN pcre *
5093  pcre_compile2(const char *pattern, int options, int *errorcodeptr,  pcre_compile2(const char *pattern, int options, int *errorcodeptr,
5094    const char **errorptr, int *erroroffset, const unsigned char *tables)    const char **errorptr, int *erroroffset, const unsigned char *tables)
5095  {  {
# Line 5100  if (errorcodeptr != NULL) *errorcodeptr Line 5138  if (errorcodeptr != NULL) *errorcodeptr
5138  if (erroroffset == NULL)  if (erroroffset == NULL)
5139    {    {
5140    errorcode = ERR16;    errorcode = ERR16;
5141    goto PCRE_EARLY_ERROR_RETURN;    goto PCRE_EARLY_ERROR_RETURN2;
5142    }    }
5143    
5144  *erroroffset = 0;  *erroroffset = 0;
# Line 5113  if (utf8 && (options & PCRE_NO_UTF8_CHEC Line 5151  if (utf8 && (options & PCRE_NO_UTF8_CHEC
5151       (*erroroffset = _pcre_valid_utf8((uschar *)pattern, -1)) >= 0)       (*erroroffset = _pcre_valid_utf8((uschar *)pattern, -1)) >= 0)
5152    {    {
5153    errorcode = ERR44;    errorcode = ERR44;
5154    goto PCRE_UTF8_ERROR_RETURN;    goto PCRE_EARLY_ERROR_RETURN2;
5155    }    }
5156  #else  #else
5157  if ((options & PCRE_UTF8) != 0)  if ((options & PCRE_UTF8) != 0)
# Line 5138  cd->cbits = tables + cbits_offset; Line 5176  cd->cbits = tables + cbits_offset;
5176  cd->ctypes = tables + ctypes_offset;  cd->ctypes = tables + ctypes_offset;
5177    
5178  /* Handle different types of newline. The three bits give seven cases. The  /* Handle different types of newline. The three bits give seven cases. The
5179  current code allows for fixed one- or two-byte sequences, plus "any". */  current code allows for fixed one- or two-byte sequences, plus "any" and
5180    "anycrlf". */
5181    
5182  switch (options & (PCRE_NEWLINE_CRLF | PCRE_NEWLINE_ANY))  switch (options & (PCRE_NEWLINE_CRLF | PCRE_NEWLINE_ANY))
5183    {    {
# Line 5148  switch (options & (PCRE_NEWLINE_CRLF | P Line 5187  switch (options & (PCRE_NEWLINE_CRLF | P
5187    case PCRE_NEWLINE_CR+    case PCRE_NEWLINE_CR+
5188         PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;         PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
5189    case PCRE_NEWLINE_ANY: newline = -1; break;    case PCRE_NEWLINE_ANY: newline = -1; break;
5190      case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
5191    default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;    default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;
5192    }    }
5193    
5194  if (newline < 0)  if (newline == -2)
5195      {
5196      cd->nltype = NLTYPE_ANYCRLF;
5197      }
5198    else if (newline < 0)
5199    {    {
5200    cd->nltype = NLTYPE_ANY;    cd->nltype = NLTYPE_ANY;
5201    }    }
# Line 5325  if (errorcode != 0) Line 5369  if (errorcode != 0)
5369    (pcre_free)(re);    (pcre_free)(re);
5370    PCRE_EARLY_ERROR_RETURN:    PCRE_EARLY_ERROR_RETURN:
5371    *erroroffset = ptr - (const uschar *)pattern;    *erroroffset = ptr - (const uschar *)pattern;
5372  #ifdef SUPPORT_UTF8    PCRE_EARLY_ERROR_RETURN2:
   PCRE_UTF8_ERROR_RETURN:  
 #endif  
5373    *errorptr = error_texts[errorcode];    *errorptr = error_texts[errorcode];
5374    if (errorcodeptr != NULL) *errorcodeptr = errorcode;    if (errorcodeptr != NULL) *errorcodeptr = errorcode;
5375    return NULL;    return NULL;

Legend:
Removed from v.117  
changed lines
  Added in v.166

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12