[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard browscap.c

2008-08-29 Thread Antony Dovgal
tony2001Fri Aug 29 14:14:09 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   browscap.c 
  Log:
  MFH: fix get_browser() (broken in the process of param API conversion)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/browscap.c?r1=1.85.2.2.2.3.2.8r2=1.85.2.2.2.3.2.9diff_format=u
Index: php-src/ext/standard/browscap.c
diff -u php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.8 
php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.9
--- php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.8Tue Aug 19 15:16:33 2008
+++ php-src/ext/standard/browscap.c Fri Aug 29 14:14:09 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: browscap.c,v 1.85.2.2.2.3.2.8 2008/08/19 15:16:33 tony2001 Exp $ */
+/* $Id: browscap.c,v 1.85.2.2.2.3.2.9 2008/08/29 14:14:09 tony2001 Exp $ */
 
 #include php.h
 #include php_browscap.h
@@ -328,7 +328,7 @@
char *agent_name = NULL;
int agent_name_len;
zend_bool return_array = 0;
-   zval **agent;
+   zval **agent, **z_agent_name;
zval *found_browser_entry, *tmp_copy;
char *lookup_browser_name;
char *browscap = INI_STR(browscap);
@@ -375,8 +375,8 @@
zend_hash_copy(Z_OBJPROP_P(return_value), Z_ARRVAL_PP(agent), 
(copy_ctor_func_t) zval_add_ref, (void *) tmp_copy, sizeof(zval *));
}
 
-   while (zend_hash_find(Z_ARRVAL_PP(agent), parent, sizeof(parent), 
(void **) agent_name) == SUCCESS) {
-   if (zend_hash_find(browser_hash, agent_name, agent_name_len + 
1, (void **)agent) == FAILURE) {
+   while (zend_hash_find(Z_ARRVAL_PP(agent), parent, sizeof(parent), 
(void **) z_agent_name) == SUCCESS) {
+   if (zend_hash_find(browser_hash, Z_STRVAL_PP(z_agent_name), 
Z_STRLEN_PP(z_agent_name) + 1, (void **)agent) == FAILURE) {
break;
}
 



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



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard browscap.c

2008-08-19 Thread Antony Dovgal
tony2001Tue Aug 19 15:16:33 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   browscap.c 
  Log:
  MFH: fix memleak in browscap code (noticed by Gopal)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/browscap.c?r1=1.85.2.2.2.3.2.7r2=1.85.2.2.2.3.2.8diff_format=u
Index: php-src/ext/standard/browscap.c
diff -u php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.7 
php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.8
--- php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.7Thu Aug  7 12:50:17 2008
+++ php-src/ext/standard/browscap.c Tue Aug 19 15:16:33 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: browscap.c,v 1.85.2.2.2.3.2.7 2008/08/07 12:50:17 nlopess Exp $ */
+/* $Id: browscap.c,v 1.85.2.2.2.3.2.8 2008/08/19 15:16:33 tony2001 Exp $ */
 
 #include php.h
 #include php_browscap.h
@@ -118,7 +118,8 @@
char *new_key;
 
/* parent entry can not be same as current 
section - causes infinite loop! */
-   if (!strcasecmp(Z_STRVAL_P(arg1), parent) 
+   if (!strcasecmp(Z_STRVAL_P(arg1), parent)  
+   current_section_name != NULL 
!strcasecmp(current_section_name, 
Z_STRVAL_P(arg2))
) {
zend_error(E_CORE_ERROR, Invalid 
browscap ini file: 'Parent' value can not be same as the section name: %s (in 
file %s), current_section_name, INI_STR(browscap));
@@ -171,6 +172,9 @@
zend_hash_init(section_properties, 0, NULL, 
(dtor_func_t) browscap_entry_dtor, 1);
Z_ARRVAL_P(current_section) = 
section_properties;
Z_TYPE_P(current_section) = IS_ARRAY;
+   if (current_section_name) {
+   free(current_section_name);
+   }
current_section_name = 
zend_strndup(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
 
zend_hash_update(browser_hash, 
Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, (void *) current_section, sizeof(zval 
*), NULL);
@@ -213,7 +217,12 @@
}
fh.filename = browscap;
Z_TYPE(fh) = ZEND_HANDLE_FP;
+   current_section_name = NULL;
zend_parse_ini_file(fh, 1, ZEND_INI_SCANNER_RAW, 
(zend_ini_parser_cb_t) php_browscap_parser_cb, browser_hash TSRMLS_CC);
+   if (current_section_name) {
+   free(current_section_name);
+   current_section_name = NULL;
+   }
}
 
return SUCCESS;



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



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard browscap.c

2008-08-07 Thread Nuno Lopes
nlopess Thu Aug  7 12:50:17 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   browscap.c 
  Log:
  upgrade to PCRE (i.e. get ride of ereg usage)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/browscap.c?r1=1.85.2.2.2.3.2.6r2=1.85.2.2.2.3.2.7diff_format=u
Index: php-src/ext/standard/browscap.c
diff -u php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.6 
php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.7
--- php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.6Thu Jul 24 19:52:24 2008
+++ php-src/ext/standard/browscap.c Thu Aug  7 12:50:17 2008
@@ -16,13 +16,13 @@
+--+
  */
 
-/* $Id: browscap.c,v 1.85.2.2.2.3.2.6 2008/07/24 19:52:24 felipe Exp $ */
+/* $Id: browscap.c,v 1.85.2.2.2.3.2.7 2008/08/07 12:50:17 nlopess Exp $ */
 
 #include php.h
 #include php_browscap.h
 #include php_ini.h
 #include php_string.h
-#include ext/ereg/php_regex.h
+#include ext/pcre/php_pcre.h
 
 #include zend_ini_scanner.h
 #include zend_globals.h
@@ -51,16 +51,17 @@
 
 static void convert_browscap_pattern(zval *pattern) /* {{{ */
 {
-   register int i, j;
+   int i, j=0;
char *t;
 
php_strtolower(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern));
 
-   t = (char *) safe_pemalloc(Z_STRLEN_P(pattern), 2, 3, 1);
+   t = (char *) safe_pemalloc(Z_STRLEN_P(pattern), 2, 5, 1);
 
-   t[0] = '^';
+   t[j++] = '§';
+   t[j++] = '^';
 
-   for (i=0, j=1; iZ_STRLEN_P(pattern); i++, j++) {
+   for (i=0; iZ_STRLEN_P(pattern); i++, j++) {
switch (Z_STRVAL_P(pattern)[i]) {
case '?':
t[j] = '.';
@@ -73,6 +74,22 @@
t[j++] = '\\';
t[j] = '.';
break;
+   case '\\':
+   t[j++] = '\\';
+   t[j] = '\\';
+   break;
+   case '(':
+   t[j++] = '\\';
+   t[j] = '(';
+   break;
+   case ')':
+   t[j++] = '\\';
+   t[j] = ')';
+   break;
+   case '§':
+   t[j++] = '\\';
+   t[j] = '§';
+   break;
default:
t[j] = Z_STRVAL_P(pattern)[i];
break;
@@ -80,6 +97,7 @@
}
 
t[j++] = '$';
+   t[j++] = '§';
 
t[j]=0;
Z_STRVAL_P(pattern) = t;
@@ -215,8 +233,11 @@
 static int browser_reg_compare(zval **browser TSRMLS_DC, int num_args, va_list 
args, zend_hash_key *key) /* {{{ */
 {
zval **browser_regex, **previous_match;
-   regex_t r;
+   pcre *re;
+   int re_options;
+   pcre_extra *re_extra;
char *lookup_browser_name = va_arg(args, char *);
+   int lookup_browser_length = va_arg(args, int);
zval **found_browser_entry = va_arg(args, zval **);
 
/* See if we have an exact match, if so, we're done... */
@@ -233,10 +254,12 @@
return 0;
}
 
-   if (regcomp(r, Z_STRVAL_PP(browser_regex), REG_NOSUB) != 0) {
+   re = pcre_get_compiled_regex(Z_STRVAL_PP(browser_regex), re_extra, 
re_options TSRMLS_CC);
+   if (re == NULL) {
return 0;
}
-   if (regexec(r, lookup_browser_name, 0, NULL, 0) == 0) {
+
+   if (pcre_exec(re, re_extra, lookup_browser_name, lookup_browser_length, 
0, re_options, NULL, 0) == 0) {
/* If we've found a possible browser, we need to do a 
comparison of the
   number of characters changed in the user agent being checked 
versus
   the previous match found and the current match. */
@@ -245,11 +268,10 @@
zval **current_match;
 
if (zend_hash_find(Z_ARRVAL_PP(browser), 
browser_name_pattern, sizeof(browser_name_pattern), (void**) 
current_match) == FAILURE) {
-   regfree(r);
return 0;
}
 
-   ua_len = strlen(lookup_browser_name);
+   ua_len = lookup_browser_length;
 
for (i = 0; i  Z_STRLEN_PP(previous_match); i++) {
switch (Z_STRVAL_PP(previous_match)[i]) {
@@ -286,10 +308,6 @@
}
}
 
-   if (r) {
-   regfree(r);
-   }
-
return 0;
 }
 /* }}} */
@@ -329,7 +347,7 @@
 
if (zend_hash_find(browser_hash, lookup_browser_name, agent_name_len + 
1, (void **) agent) == FAILURE) {
found_browser_entry = NULL;
-   

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard browscap.c exec.c filters.c formatted_print.c ftp_fopen_wrapper.c http.c http_fopen_wrapper.c image.c mail.c php_fopen_wrapper.c streamsfuncs.c uniqid.c u

2007-09-29 Thread Jani Taskinen
janiSun Sep 30 05:49:45 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   browscap.c exec.c filters.c formatted_print.c 
ftp_fopen_wrapper.c http.c 
http_fopen_wrapper.c image.c mail.c 
php_fopen_wrapper.c streamsfuncs.c uniqid.c 
url.c uuencode.c 
  Log:
  MFH: Nuked ending dots from error messages
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/browscap.c?r1=1.85.2.2.2.3.2.1r2=1.85.2.2.2.3.2.2diff_format=u
Index: php-src/ext/standard/browscap.c
diff -u php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.1 
php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.2
--- php-src/ext/standard/browscap.c:1.85.2.2.2.3.2.1Fri Sep 28 02:05:09 2007
+++ php-src/ext/standard/browscap.c Sun Sep 30 05:49:44 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: browscap.c,v 1.85.2.2.2.3.2.1 2007/09/28 02:05:09 jani Exp $ */
+/* $Id: browscap.c,v 1.85.2.2.2.3.2.2 2007/09/30 05:49:44 jani Exp $ */
 
 #include php.h
 #include php_regex.h
@@ -318,7 +318,7 @@
char *browscap = INI_STR(browscap);
 
if (!browscap || !browscap[0]) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, browscap ini 
directive not set.);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, browscap ini 
directive not set);
RETURN_FALSE;
}
 
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/exec.c?r1=1.113.2.3.2.1r2=1.113.2.3.2.1.2.1diff_format=u
Index: php-src/ext/standard/exec.c
diff -u php-src/ext/standard/exec.c:1.113.2.3.2.1 
php-src/ext/standard/exec.c:1.113.2.3.2.1.2.1
--- php-src/ext/standard/exec.c:1.113.2.3.2.1   Mon Jan  1 09:36:08 2007
+++ php-src/ext/standard/exec.c Sun Sep 30 05:49:44 2007
@@ -16,7 +16,7 @@
| Ilia Alshanetsky [EMAIL PROTECTED] |
+--+
  */
-/* $Id: exec.c,v 1.113.2.3.2.1 2007/01/01 09:36:08 sebastian Exp $ */
+/* $Id: exec.c,v 1.113.2.3.2.1.2.1 2007/09/30 05:49:44 jani Exp $ */
 
 #include stdio.h
 #include php.h
@@ -463,7 +463,7 @@
errno = 0;
nice(pri);
if (errno) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Only a super user 
may attempt to increase the priority of a process.);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Only a super user 
may attempt to increase the priority of a process);
RETURN_FALSE;
}

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/filters.c?r1=1.44.2.6.2.4r2=1.44.2.6.2.4.2.1diff_format=u
Index: php-src/ext/standard/filters.c
diff -u php-src/ext/standard/filters.c:1.44.2.6.2.4 
php-src/ext/standard/filters.c:1.44.2.6.2.4.2.1
--- php-src/ext/standard/filters.c:1.44.2.6.2.4 Mon Jan  1 09:36:08 2007
+++ php-src/ext/standard/filters.c  Sun Sep 30 05:49:44 2007
@@ -20,7 +20,7 @@
+--+
 */
 
-/* $Id: filters.c,v 1.44.2.6.2.4 2007/01/01 09:36:08 sebastian Exp $ */
+/* $Id: filters.c,v 1.44.2.6.2.4.2.1 2007/09/30 05:49:44 jani Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -1880,7 +1880,7 @@
/* Create this filter */
data = pecalloc(1, sizeof(php_consumed_filter_data), persistent);
if (!data) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed allocating 
%zd bytes., sizeof(php_consumed_filter_data));
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed allocating 
%zd bytes, sizeof(php_consumed_filter_data));
return NULL;
}
data-persistent = persistent;
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/formatted_print.c?r1=1.82.2.1.2.16r2=1.82.2.1.2.16.2.1diff_format=u
Index: php-src/ext/standard/formatted_print.c
diff -u php-src/ext/standard/formatted_print.c:1.82.2.1.2.16 
php-src/ext/standard/formatted_print.c:1.82.2.1.2.16.2.1
--- php-src/ext/standard/formatted_print.c:1.82.2.1.2.16Sun Jun  3 
09:12:04 2007
+++ php-src/ext/standard/formatted_print.c  Sun Sep 30 05:49:44 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: formatted_print.c,v 1.82.2.1.2.16 2007/06/03 09:12:04 shire Exp $ */
+/* $Id: formatted_print.c,v 1.82.2.1.2.16.2.1 2007/09/30 05:49:44 jani Exp $ */
 
 #include math.h  /* modf() */
 #include php.h
@@ -445,7 +445,7 @@
if (argnum = 0) {
efree(result);
efree(args);
-   php_error_docref(NULL 
TSRMLS_CC, E_WARNING, Argument number must be greater than zero.);
+   php_error_docref(NULL 
TSRMLS_CC,