[PHP-CVS] cvs: php-src /ext/pcre TODO php_pcre.c

2006-04-07 Thread Andrei Zmievski
andrei  Fri Apr  7 21:20:10 2006 UTC

  Modified files:  
/php-src/ext/pcre   TODO php_pcre.c 
  Log:
  Disallowed numeric named captures.
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/TODO?r1=1.5r2=1.6diff_format=u
Index: php-src/ext/pcre/TODO
diff -u php-src/ext/pcre/TODO:1.5 php-src/ext/pcre/TODO:1.6
--- php-src/ext/pcre/TODO:1.5   Thu Apr  6 22:37:42 2006
+++ php-src/ext/pcre/TODO   Fri Apr  7 21:20:10 2006
@@ -32,6 +32,4 @@
   of a grep function in PHP would be that the default is PREG_GREP_REKEY_NUMS
   or PREG_GREP_REKEY_ALL
 
-- Disallow numeric named captures.
-
 
http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/php_pcre.c?r1=1.179r2=1.180diff_format=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.179 php-src/ext/pcre/php_pcre.c:1.180
--- php-src/ext/pcre/php_pcre.c:1.179   Thu Apr  6 21:16:28 2006
+++ php-src/ext/pcre/php_pcre.c Fri Apr  7 21:20:10 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_pcre.c,v 1.179 2006/04/06 21:16:28 andrei Exp $ */
+/* $Id: php_pcre.c,v 1.180 2006/04/07 21:20:10 andrei Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -464,7 +464,7 @@
 
/*
 * Build a mapping from subpattern numbers to their names. We will 
always
-* allocate the table, even though they may be no named subpatterns. 
This
+* allocate the table, even though there may be no named subpatterns. 
This
 * avoids somewhat more complicated logic in the inner loops.
 */
subpat_names = (char **)safe_emalloc(num_subpats, sizeof(char *), 0);
@@ -478,22 +478,34 @@
if (rc  0) {
php_error(E_WARNING, %s: internal pcre_fullinfo() 
error %d,
  get_active_function_name(TSRMLS_C), 
rc);
+   efree(offsets);
+   efree(subpat_names);
RETURN_FALSE;
}
if (name_cnt  0) {
int rc1, rc2;
+   long dummy_l;
+   double dummy_d;
rc1 = pcre_fullinfo(re, extra, PCRE_INFO_NAMETABLE, 
name_table);
rc2 = pcre_fullinfo(re, extra, PCRE_INFO_NAMEENTRYSIZE, 
name_size);
rc = rc2 ? rc2 : rc1;
if (rc  0) {
php_error(E_WARNING, %s: internal 
pcre_fullinfo() error %d,
  
get_active_function_name(TSRMLS_C), rc);
+   efree(offsets);
+   efree(subpat_names);
RETURN_FALSE;
}
 
while (ni++  name_cnt) {
name_idx = 0xff * name_table[0] + name_table[1];
subpat_names[name_idx] = name_table + 2;
+   if (is_numeric_string(subpat_names[name_idx], 
strlen(subpat_names[name_idx]), dummy_l, dummy_d, 0)  0) {
+   php_error(E_WARNING, %s: numeric named 
subpatterns are not allowed, get_active_function_name(TSRMLS_C));
+   efree(offsets);
+   efree(subpat_names);
+   RETURN_FALSE;
+   }
name_table += name_size;
}
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/pcre TODO php_pcre.c ZendEngine2 zend_arg_defs.c zend_modules.h

2006-04-06 Thread Andrei Zmievski
andrei  Thu Apr  6 21:16:28 2006 UTC

  Modified files:  
/ZendEngine2zend_arg_defs.c zend_modules.h 
/php-src/ext/pcre   TODO php_pcre.c 
  Log:
  MFB
  
  
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_arg_defs.c?r1=1.4r2=1.5diff_format=u
Index: ZendEngine2/zend_arg_defs.c
diff -u ZendEngine2/zend_arg_defs.c:1.4 ZendEngine2/zend_arg_defs.c:1.5
--- ZendEngine2/zend_arg_defs.c:1.4 Tue Feb 21 08:00:38 2006
+++ ZendEngine2/zend_arg_defs.c Thu Apr  6 21:16:28 2006
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: zend_arg_defs.c,v 1.4 2006/02/21 08:00:38 dmitry Exp $ */
+/* $Id: zend_arg_defs.c,v 1.5 2006/04/06 21:16:28 andrei Exp $ */
 
 ZEND_BEGIN_ARG_INFO(first_arg_force_ref, 0)
ZEND_ARG_PASS_INFO(1)
@@ -40,5 +40,13 @@
ZEND_ARG_PASS_INFO(1)
 ZEND_END_ARG_INFO();
 
+ZEND_BEGIN_ARG_INFO(fifth_arg_force_ref, 0)
+   ZEND_ARG_PASS_INFO(0)
+   ZEND_ARG_PASS_INFO(0)
+   ZEND_ARG_PASS_INFO(0)
+   ZEND_ARG_PASS_INFO(0)
+   ZEND_ARG_PASS_INFO(1)
+ZEND_END_ARG_INFO();
+
 ZEND_BEGIN_ARG_INFO(all_args_by_ref, 1)
 ZEND_END_ARG_INFO();
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_modules.h?r1=1.71r2=1.72diff_format=u
Index: ZendEngine2/zend_modules.h
diff -u ZendEngine2/zend_modules.h:1.71 ZendEngine2/zend_modules.h:1.72
--- ZendEngine2/zend_modules.h:1.71 Tue Feb 21 08:00:39 2006
+++ ZendEngine2/zend_modules.h  Thu Apr  6 21:16:28 2006
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: zend_modules.h,v 1.71 2006/02/21 08:00:39 dmitry Exp $ */
+/* $Id: zend_modules.h,v 1.72 2006/04/06 21:16:28 andrei Exp $ */
 
 #ifndef MODULES_H
 #define MODULES_H
@@ -36,6 +36,7 @@
 extern struct _zend_arg_info second_arg_force_ref[3];
 extern struct _zend_arg_info third_arg_force_ref[4];
 extern struct _zend_arg_info fourth_arg_force_ref[5];
+extern struct _zend_arg_info fifth_arg_force_ref[6];
 extern struct _zend_arg_info all_args_by_ref[1];
 
 #define ZEND_MODULE_API_NO 20050922
http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/TODO?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/pcre/TODO
diff -u /dev/null php-src/ext/pcre/TODO:1.2
--- /dev/null   Thu Apr  6 21:16:28 2006
+++ php-src/ext/pcre/TODO   Thu Apr  6 21:16:28 2006
@@ -0,0 +1,21 @@
+- Allow NULL for $matches argument (helps when using preg_match only for
+  match condition) - might not be possible
+
+- http://bugs.php.net/bug.php?id=36975
+
+- I'd love to see a pattern modifer which says don't fill $matches except
+  for the overall match and any specific named captures. This would allow
+  (?: ...) to be avoided in a lot of cases.
+  
+  This could make for non-trivial speed enhancements with regexes that have
+  a lot of parens when working on long strings, since you'd not have to  
+  copy them multiple times to the $matches array.
+  
+  Also, it makes $matches much cleaner after a match where you've named the
+  captures you're interested in.
+  
+  (Note that this would not involve the use of PCRE_NO_AUTO_CAPTURE, as
+  that would change the semantics of backreferences)
+
+
+
http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/php_pcre.c?r1=1.178r2=1.179diff_format=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.178 php-src/ext/pcre/php_pcre.c:1.179
--- php-src/ext/pcre/php_pcre.c:1.178   Tue Feb 21 20:12:42 2006
+++ php-src/ext/pcre/php_pcre.c Thu Apr  6 21:16:28 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_pcre.c,v 1.178 2006/02/21 20:12:42 dmitry Exp $ */
+/* $Id: php_pcre.c,v 1.179 2006/04/06 21:16:28 andrei Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1626,8 +1626,8 @@
 zend_function_entry pcre_functions[] = {
PHP_FE(preg_match,  third_arg_force_ref)
PHP_FE(preg_match_all,  third_arg_force_ref)
-   PHP_FE(preg_replace,NULL)
-   PHP_FE(preg_replace_callback,   NULL)
+   PHP_FE(preg_replace,fifth_arg_force_ref)
+   PHP_FE(preg_replace_callback,   fifth_arg_force_ref)
PHP_FE(preg_split,  NULL)
PHP_FE(preg_quote,  NULL)
PHP_FE(preg_grep,   NULL)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php