Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41554 invoked from network); 18 Mar 2003 21:54:51 -0000 Received: from unknown (HELO hyperion.gravitonic.com) (65.198.110.5) by pb1.pair.com with SMTP; 18 Mar 2003 21:54:51 -0000 Received: (from andrei@localhost) by hyperion.gravitonic.com (8.11.6/8.11.6) id h2ILsL208435 for internals@lists.php.net; Tue, 18 Mar 2003 16:54:21 -0500 X-Authentication-Warning: hyperion.gravitonic.com: andrei set sender to andrei@gravitonic.com using -f Date: Tue, 18 Mar 2003 16:54:21 -0500 To: PHP Internals Message-ID: <20030318215420.GA8409@hyperion.gravitonic.com> Mail-Followup-To: Andrei Zmievski , PHP Internals Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="qMm9M+Fa2AknHoGS" Content-Disposition: inline User-Agent: Mutt/1.4i Subject: function registration patch From: andrei@gravitonic.com (Andrei Zmievski) --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Currently when registering functions, the unmodified function name is used as the key for the function table. This leads to problems when an extension class has a constructor that is not all lowercased. For example: function_entry php_gtk_button_functions[] = { PHP_FE("GtkButton", NULL), ... }; Then when using something like: ... parent::GtkButton(); ... It fails because it uses 'gtkbutton' as the key to search the function table. The attached patch fixes that by lowercasing the key (function name) when registering functions. I know that some may say, "just use lowercase class name for the constructor in the function entry list", but that messes with nice class/function names again. -Andrei http://www.gravitonic.com/ * It said 'Winmodem' on the box, but I still feel like I lost. * --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="zend_API.diff" Index: zend_API.c =================================================================== RCS file: /repository/ZendEngine2/zend_API.c,v retrieving revision 1.158 diff -u -2 -b -w -B -r1.158 zend_API.c --- zend_API.c 13 Mar 2003 20:41:58 -0000 1.158 +++ zend_API.c 18 Mar 2003 21:49:31 -0000 @@ -1147,4 +1147,6 @@ int error_type; zend_function *ctor = NULL, *dtor = NULL, *clone = NULL; + char *lowercase_name; + int fname_len; if (type==MODULE_PERSISTENT) { @@ -1171,6 +1174,10 @@ return FAILURE; } - if (zend_hash_add(target_function_table, ptr->fname, strlen(ptr->fname)+1, &function, sizeof(zend_function), (void**)®_function) == FAILURE) { + fname_len = strlen(ptr->fname); + lowercase_name = zend_strndup(ptr->fname, fname_len); + zend_str_tolower(lowercase_name, fname_len); + if (zend_hash_add(target_function_table, lowercase_name, fname_len+1, &function, sizeof(zend_function), (void**)®_function) == FAILURE) { unload=1; + free(lowercase_name); break; } @@ -1192,4 +1199,5 @@ ptr++; count++; + free(lowercase_name); } if (unload) { /* before unloading, display all remaining bad function in the module */ --qMm9M+Fa2AknHoGS--