Diff for /embedaddon/php/ext/mbstring/php_mbregex.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2012/05/29 12:34:40 version 1.1.1.3, 2013/07/22 01:31:53
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 648  _php_mb_regex_init_options(const char *parg, int narg, Line 648  _php_mb_regex_init_options(const char *parg, int narg,
 /* }}} */  /* }}} */
   
 /*  /*
 * php funcions * php functions
  */   */
   
 /* {{{ proto string mb_regex_encoding([string encoding])  /* {{{ proto string mb_regex_encoding([string encoding])
Line 1055  PHP_FUNCTION(mb_split) Line 1055  PHP_FUNCTION(mb_split)
         php_mb_regex_t *re;          php_mb_regex_t *re;
         OnigRegion *regs = NULL;          OnigRegion *regs = NULL;
         char *string;          char *string;
        OnigUChar *pos;        OnigUChar *pos, *chunk_pos;
         int string_len;          int string_len;
   
         int n, err;          int n, err;
Line 1065  PHP_FUNCTION(mb_split) Line 1065  PHP_FUNCTION(mb_split)
                 RETURN_FALSE;                  RETURN_FALSE;
         }           } 
   
        if (count == 0) {        if (count > 0) {
                count = 1;                count--;
         }          }
   
         /* create regex pattern buffer */          /* create regex pattern buffer */
Line 1076  PHP_FUNCTION(mb_split) Line 1076  PHP_FUNCTION(mb_split)
   
         array_init(return_value);          array_init(return_value);
   
        pos = (OnigUChar *)string;        chunk_pos = pos = (OnigUChar *)string;
         err = 0;          err = 0;
         regs = onig_region_new();          regs = onig_region_new();
         /* churn through str, generating array entries as we go */          /* churn through str, generating array entries as we go */
        while ((--count != 0) &&        while (count != 0 && (pos - (OnigUChar *)string) < string_len) {
                   (err = onig_search(re, (OnigUChar *)string, (OnigUChar *)(string + string_len), pos, (OnigUChar *)(string + string_len), regs, 0)) >= 0) {                int beg, end;
                if (regs->beg[0] == regs->end[0]) {                err = onig_search(re, (OnigUChar *)string, (OnigUChar *)(string + string_len), pos, (OnigUChar *)(string + string_len), regs, 0);
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty regular expression");                if (err < 0) {
                         break;                          break;
                 }                  }
                beg = regs->beg[0], end = regs->end[0];
                 /* add it to the array */                  /* add it to the array */
                if (regs->beg[0] < string_len && regs->beg[0] >= (pos - (OnigUChar *)string)) {                if ((pos - (OnigUChar *)string) < end) {
                        add_next_index_stringl(return_value, (char *)pos, ((OnigUChar *)(string + regs->beg[0]) - pos), 1);                        if (beg < string_len && beg >= (chunk_pos - (OnigUChar *)string)) {
                                 add_next_index_stringl(return_value, (char *)chunk_pos, ((OnigUChar *)(string + beg) - chunk_pos), 1);
                                 --count;
                         } else {
                                 err = -2;
                                 break;
                         }
                         /* point at our new starting point */
                         chunk_pos = pos = (OnigUChar *)string + end;
                 } else {                  } else {
                        err = -2;                        pos++;
                        break; 
                 }                  }
                 /* point at our new starting point */  
                 n = regs->end[0];  
                 if ((pos - (OnigUChar *)string) < n) {  
                         pos = (OnigUChar *)string + n;  
                 }  
                 if (count < 0) {  
                         count = 0;  
                 }  
                 onig_region_free(regs, 0);                  onig_region_free(regs, 0);
         }          }
   
Line 1117  PHP_FUNCTION(mb_split) Line 1116  PHP_FUNCTION(mb_split)
         }          }
   
         /* otherwise we just have one last element to add to the array */          /* otherwise we just have one last element to add to the array */
        n = ((OnigUChar *)(string + string_len) - pos);        n = ((OnigUChar *)(string + string_len) - chunk_pos);
         if (n > 0) {          if (n > 0) {
                add_next_index_stringl(return_value, (char *)pos, n, 1);                add_next_index_stringl(return_value, (char *)chunk_pos, n, 1);
         } else {          } else {
                 add_next_index_stringl(return_value, "", 0, 1);                  add_next_index_stringl(return_value, "", 0, 1);
         }          }

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


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