cvs: /php4/ext/apache apache.c /php4/ext/pcre php_pcre.c

From: Date: Sat, 17 Jul 1999 16:03:10 +0000
Subject: cvs: /php4/ext/apache apache.c /php4/ext/pcre php_pcre.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-2202@lists.php.net to get a copy of this message
andrey Sat Jul 17 16:03:10 1999 EDT Modified files: /php4/ext/apache apache.c /php4/ext/pcre php_pcre.c Log: -Kill compile warnings in apache.c -Make preg_grep() work with copies of array entries Index: php4/ext/apache/apache.c diff -u php4/ext/apache/apache.c:1.14 php4/ext/apache/apache.c:1.15 --- php4/ext/apache/apache.c:1.14 Fri Jul 16 09:12:42 1999 +++ php4/ext/apache/apache.c Sat Jul 17 16:03:10 1999 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apache.c,v 1.14 1999/07/16 13:12:42 zeev Exp $ */ +/* $Id: apache.c,v 1.15 1999/07/17 20:03:10 andrey Exp $ */ #include "php.h" #include "ext/standard/head.h" #include "php_globals.h" @@ -362,10 +362,10 @@ add_property_string(return_value,"the_request",rr->the_request,1); } if (rr->status_line) { - add_property_string(return_value,"status_line",rr->status_line,1); + add_property_string(return_value,"status_line",(char *)rr->status_line,1); } if (rr->method) { - add_property_string(return_value,"method",rr->method,1); + add_property_string(return_value,"method",(char *)rr->method,1); } if (rr->content_type) { add_property_string(return_value,"content_type",(char *)rr->content_type,1); Index: php4/ext/pcre/php_pcre.c diff -u php4/ext/pcre/php_pcre.c:1.7 php4/ext/pcre/php_pcre.c:1.8 --- php4/ext/pcre/php_pcre.c:1.7 Fri Jul 16 09:12:54 1999 +++ php4/ext/pcre/php_pcre.c Sat Jul 17 16:03:10 1999 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pcre.c,v 1.7 1999/07/16 13:12:54 zeev Exp $ */ +/* $Id: php_pcre.c,v 1.8 1999/07/17 20:03:10 andrey Exp $ */ #include "php.h" #include "php_globals.h" @@ -1010,7 +1010,8 @@ { zval *regex, /* Regular expression */ *input, /* Input array */ - **entry; /* An entry in the input array */ + *entry, /* A copy of the entry in the input array */ + **entry_ptr; /* An entry in the input array */ pcre *re = NULL; /* Compiled regular expression */ pcre_extra *extra = NULL; /* Holds results of studying */ int preg_options = 0; /* Custom preg options */ @@ -1045,48 +1046,56 @@ /* Initialize return array */ array_init(return_value); - + + /* Allocate entry storage */ + entry = (zval *)emalloc(sizeof(zval)); + /* Go through the input array */ zend_hash_internal_pointer_reset(input->value.ht); - while(zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) { + while(zend_hash_get_current_data(input->value.ht, (void **)&entry_ptr) == SUCCESS) { - /* Only match against strings */ - if ((*entry)->type == IS_STRING) { - /* Perform the match */ - count = pcre_exec(re, extra, (*entry)->value.str.val, - (*entry)->value.str.len, (*entry)->value.str.val, - 0, offsets, size_offsets, 0); - - /* Check for too many substrings condition. */ - if (count == 0) { - zend_error(E_NOTICE, "Matched, but too many substrings\n"); - count = size_offsets/3; - } + /* Copy entry and convert to string */ + *entry = **entry_ptr; + zval_copy_ctor(entry); + convert_to_string(entry); + + /* Perform the match */ + count = pcre_exec(re, extra, entry->value.str.val, + entry->value.str.len, entry->value.str.val, + 0, offsets, size_offsets, 0); - /* If something matched */ - if (count > 0) { - (*entry)->refcount++; - - /* Add to return array */ - switch(zend_hash_get_current_key(input->value.ht, &string_key, &num_key)) - { - case HASH_KEY_IS_STRING: - zend_hash_update(return_value->value.ht, string_key, - strlen(string_key)+1, entry, sizeof(zval *), NULL); - efree(string_key); - break; - - case HASH_KEY_IS_LONG: - zend_hash_next_index_insert(return_value->value.ht, entry, - sizeof(zval *), NULL); - break; - } + /* Check for too many substrings condition. */ + if (count == 0) { + zend_error(E_NOTICE, "Matched, but too many substrings\n"); + count = size_offsets/3; + } + + /* If something matched */ + if (count > 0) { + (*entry_ptr)->refcount++; + + /* Add to return array */ + switch(zend_hash_get_current_key(input->value.ht, &string_key, &num_key)) + { + case HASH_KEY_IS_STRING: + zend_hash_update(return_value->value.ht, string_key, + strlen(string_key)+1, entry_ptr, sizeof(zval *), NULL); + efree(string_key); + break; + + case HASH_KEY_IS_LONG: + zend_hash_next_index_insert(return_value->value.ht, entry_ptr, + sizeof(zval *), NULL); + break; } } + zval_dtor(entry); zend_hash_move_forward(input->value.ht); } + /* Clean up */ + efree(entry); efree(offsets); } /* }}} */

« previous php.version4 (#2202) next »