Diff for /embedaddon/php/ext/pcre/php_pcre.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2012/05/29 12:34:45 version 1.1.1.3, 2013/07/22 01:31:57
Line 2 Line 2
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | PHP Version 5                                                        |     | PHP Version 5                                                        |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
   | Copyright (c) 1997-2012 The PHP Group                                |   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |     | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |     | that is bundled with this package in the file LICENSE, and is        |
Line 244  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache Line 244  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache
         int                             count = 0;          int                             count = 0;
         unsigned const char *tables = NULL;          unsigned const char *tables = NULL;
 #if HAVE_SETLOCALE  #if HAVE_SETLOCALE
        char                            *locale = setlocale(LC_CTYPE, NULL);        char                            *locale;
 #endif  #endif
         pcre_cache_entry        *pce;          pcre_cache_entry        *pce;
         pcre_cache_entry         new_entry;          pcre_cache_entry         new_entry;
           char                *tmp = NULL;
   
   #if HAVE_SETLOCALE
   # if defined(PHP_WIN32) && defined(ZTS)
           _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
   # endif
           locale = setlocale(LC_CTYPE, NULL);
   #endif
   
         /* Try to lookup the cached regex entry, and if successful, just pass          /* Try to lookup the cached regex entry, and if successful, just pass
            back the compiled pattern, otherwise go on and compile it. */             back the compiled pattern, otherwise go on and compile it. */
         if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {          if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {
Line 275  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache Line 283  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache
            get to the end without encountering a delimiter. */             get to the end without encountering a delimiter. */
         while (isspace((int)*(unsigned char *)p)) p++;          while (isspace((int)*(unsigned char *)p)) p++;
         if (*p == 0) {          if (*p == 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty regular expression");                php_error_docref(NULL TSRMLS_CC, E_WARNING, 
                                                  p < regex + regex_len ? "Null byte in regex" : "Empty regular expression");
                 return NULL;                  return NULL;
         }          }
                   
Line 292  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache Line 301  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache
                 delimiter = pp[5];                  delimiter = pp[5];
         end_delimiter = delimiter;          end_delimiter = delimiter;
   
           pp = p;
   
         if (start_delimiter == end_delimiter) {          if (start_delimiter == end_delimiter) {
                 /* We need to iterate through the pattern, searching for the ending delimiter,                  /* We need to iterate through the pattern, searching for the ending delimiter,
                    but skipping the backslashed delimiters.  If the ending delimiter is not                     but skipping the backslashed delimiters.  If the ending delimiter is not
                    found, display a warning. */                     found, display a warning. */
                 pp = p;  
                 while (*pp != 0) {                  while (*pp != 0) {
                         if (*pp == '\\' && pp[1] != 0) pp++;                          if (*pp == '\\' && pp[1] != 0) pp++;
                         else if (*pp == delimiter)                          else if (*pp == delimiter)
                                 break;                                  break;
                         pp++;                          pp++;
                 }                  }
                 if (*pp == 0) {  
                         php_error_docref(NULL TSRMLS_CC,E_WARNING, "No ending delimiter '%c' found", delimiter);  
                         return NULL;  
                 }  
         } else {          } else {
                 /* We iterate through the pattern, searching for the matching ending                  /* We iterate through the pattern, searching for the matching ending
                  * delimiter. For each matching starting delimiter, we increment nesting                   * delimiter. For each matching starting delimiter, we increment nesting
Line 314  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache Line 320  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache
                  * reach the end of the pattern without matching, display a warning.                   * reach the end of the pattern without matching, display a warning.
                  */                   */
                 int brackets = 1;       /* brackets nesting level */                  int brackets = 1;       /* brackets nesting level */
                 pp = p;  
                 while (*pp != 0) {                  while (*pp != 0) {
                         if (*pp == '\\' && pp[1] != 0) pp++;                          if (*pp == '\\' && pp[1] != 0) pp++;
                         else if (*pp == end_delimiter && --brackets <= 0)                          else if (*pp == end_delimiter && --brackets <= 0)
Line 323  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache Line 328  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache
                                 brackets++;                                  brackets++;
                         pp++;                          pp++;
                 }                  }
                if (*pp == 0) {        }
                        php_error_docref(NULL TSRMLS_CC,E_WARNING, "No ending matching delimiter '%c' found", end_delimiter);
                        return NULL;        if (*pp == 0) {
                 if (pp < regex + regex_len) {
                         php_error_docref(NULL TSRMLS_CC,E_WARNING, "Null byte in regex");
                 } else if (start_delimiter == end_delimiter) {
                         php_error_docref(NULL TSRMLS_CC,E_WARNING, "No ending delimiter '%c' found", delimiter);
                 } else {
                         php_error_docref(NULL TSRMLS_CC,E_WARNING, "No ending matching delimiter '%c' found", delimiter);
                 }                  }
                   return NULL;
         }          }
                   
         /* Make a copy of the actual pattern. */          /* Make a copy of the actual pattern. */
Line 337  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache Line 349  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache
   
         /* Parse through the options, setting appropriate flags.  Display          /* Parse through the options, setting appropriate flags.  Display
            a warning if we encounter an unknown modifier. */                 a warning if we encounter an unknown modifier. */    
        while (*pp != 0) {        while (pp < regex + regex_len) {
                 switch (*pp++) {                  switch (*pp++) {
                         /* Perl compatible options */                          /* Perl compatible options */
                         case 'i':       coptions |= PCRE_CASELESS;              break;                          case 'i':       coptions |= PCRE_CASELESS;              break;
Line 368  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache Line 380  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache
                                 break;                                  break;
   
                         default:                          default:
                                php_error_docref(NULL TSRMLS_CC,E_WARNING, "Unknown modifier '%c'", pp[-1]);                                if (pp[-1]) {
                                         php_error_docref(NULL TSRMLS_CC,E_WARNING, "Unknown modifier '%c'", pp[-1]);
                                 } else {
                                         php_error_docref(NULL TSRMLS_CC,E_WARNING, "Null byte in regex");
                                 }
                                 efree(pattern);                                  efree(pattern);
                                 return NULL;                                  return NULL;
                 }                  }
Line 430  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache Line 446  PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache
         new_entry.locale = pestrdup(locale, 1);          new_entry.locale = pestrdup(locale, 1);
         new_entry.tables = tables;          new_entry.tables = tables;
 #endif  #endif
   
           /*
            * Interned strings are not duplicated when stored in HashTable,
            * but all the interned strings created during HTTP request are removed
            * at end of request. However PCRE_G(pcre_cache) must be consistent
            * on the next request as well. So we disable usage of interned strings
            * as hash keys especually for this table.
            * See bug #63180 
            */
           if (IS_INTERNED(regex)) {
                   regex = tmp = estrndup(regex, regex_len);
           }
   
         zend_hash_update(&PCRE_G(pcre_cache), regex, regex_len+1, (void *)&new_entry,          zend_hash_update(&PCRE_G(pcre_cache), regex, regex_len+1, (void *)&new_entry,
                                                 sizeof(pcre_cache_entry), (void**)&pce);                                                  sizeof(pcre_cache_entry), (void**)&pce);
   
           if (tmp) {
                   efree(tmp);
           }
   
         return pce;          return pce;
 }  }
 /* }}} */  /* }}} */
Line 1840  ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_match, 0, 0, 2) Line 1873  ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_match, 0, 0, 2)
     ZEND_ARG_INFO(0, offset)      ZEND_ARG_INFO(0, offset)
 ZEND_END_ARG_INFO()  ZEND_END_ARG_INFO()
   
ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_match_all, 0, 0, 3)ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_match_all, 0, 0, 2)
     ZEND_ARG_INFO(0, pattern)      ZEND_ARG_INFO(0, pattern)
     ZEND_ARG_INFO(0, subject)      ZEND_ARG_INFO(0, subject)
     ZEND_ARG_INFO(1, subpatterns) /* array */      ZEND_ARG_INFO(1, subpatterns) /* array */

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>