Hello Andi,

Wednesday, September 17, 2003, 6:07:40 AM, you wrote:

> At 10:10 PM 9/16/2003 +0200, Marcus Börger wrote:
>>Hello Andi,
>>
>>Tuesday, September 16, 2003, 9:37:40 PM, you wrote:
>>
>> > I think this patch is fine.
>> > I think (1) can be fixed quite easily. What do you mean when you say that
>> > (2) would result in a performance decrease? Would this only be in an error
>> > situation or also during regular runtime?
>>
>> >>2) Errors for non existing functions are still shown lowercased. This could
>> >>be changed too. But the performance decrease is higher so i wouldn't
>> >>recommend that.
>> >>
>>
>>My soulution to (2) required an additional estrndup() for all functions which
>>are called by name. Maybe i should apply the parts done so far and send you
>>the patch for (2), how about doing so?

> Good idea. We can then see if it's worth it or not.

> Andi

Here you go :-)

As you can see i need one additional emalloc in compile which should be ok
but also one additional emalloc/lowercase operation for dynamic function
calls with static function names. That is you are going to use a function
prior to declaring it.


Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]
Index: Zend/zend_execute.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute.c,v
retrieving revision 1.539
diff -u -p -d -r1.539 zend_execute.c
--- Zend/zend_execute.c 15 Sep 2003 21:00:38 -0000      1.539
+++ Zend/zend_execute.c 17 Sep 2003 10:49:39 -0000
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute.c,v 1.539 2003/09/15 21:00:38 helly Exp $ */
+/* $Id: zend_execute.c,v 1.537 2003/09/07 23:09:30 helly Exp $ */
 
 #define ZEND_INTENSIVE_DEBUGGING 0
 
@@ -2454,7 +2454,7 @@ int zend_init_fcall_by_name_handler(ZEND
        zval *function_name;
        zend_function *function;
        zend_bool is_const;
-       char *function_name_strval;
+       char *function_name_strval, *lcname;
        int function_name_strlen;
 
        zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), 
EX(calling_scope));
@@ -2470,16 +2470,18 @@ int zend_init_fcall_by_name_handler(ZEND
                if (Z_TYPE_P(function_name) != IS_STRING) {
                        zend_error(E_ERROR, "Function name must be a string");
                }
-               function_name_strval = 
zend_str_tolower_dup(function_name->value.str.val, function_name->value.str.len);
+               function_name_strval = function_name->value.str.val;
                function_name_strlen = function_name->value.str.len;
        }
 
-       if (zend_hash_find(EG(function_table), function_name_strval, 
function_name_strlen+1, (void **) &function)==FAILURE) {
+       lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen);
+       if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void 
**) &function)==FAILURE) {
+               efree(lcname);
                zend_error(E_ERROR, "Call to undefined function %s()", 
function_name_strval);
        }
 
+       efree(lcname);
        if (!is_const) {
-               efree(function_name_strval);
                FREE_OP(EX(Ts), &EX(opline)->op2, EG(free_op2));
        } 
 
Index: Zend/zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.483
diff -u -p -d -r1.483 zend_compile.c
--- Zend/zend_compile.c 17 Sep 2003 10:14:12 -0000      1.483
+++ Zend/zend_compile.c 17 Sep 2003 10:49:40 -0000
@@ -1140,12 +1140,16 @@ void zend_do_receive_arg(zend_uchar op, 
 int zend_do_begin_function_call(znode *function_name TSRMLS_DC)
 {
        zend_function *function;
+       char *lcname;
        
-       zend_str_tolower(function_name->u.constant.value.str.val, 
function_name->u.constant.value.str.len);
-       if (zend_hash_find(CG(function_table), 
function_name->u.constant.value.str.val, function_name->u.constant.value.str.len+1, 
(void **) &function)==FAILURE) {
+       lcname = zend_str_tolower_dup(function_name->u.constant.value.str.val, 
function_name->u.constant.value.str.len);
+       if (zend_hash_find(CG(function_table), lcname, 
function_name->u.constant.value.str.len+1, (void **) &function)==FAILURE) {
                zend_do_begin_dynamic_function_call(function_name TSRMLS_CC);
+               efree(lcname);
                return 1; /* Dynamic */
        }
+       efree(function_name->u.constant.value.str.val);
+       function_name->u.constant.value.str.val = lcname;
        
        switch (function->type) {
                case ZEND_USER_FUNCTION:        {
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to