Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43901 invoked from network); 18 Mar 2003 21:57:31 -0000 Received: from unknown (HELO hyperion.gravitonic.com) (65.198.110.5) by pb1.pair.com with SMTP; 18 Mar 2003 21:57:31 -0000 Received: (from andrei@localhost) by hyperion.gravitonic.com (8.11.6/8.11.6) id h2ILv2S08469 for internals@lists.php.net; Tue, 18 Mar 2003 16:57:02 -0500 X-Authentication-Warning: hyperion.gravitonic.com: andrei set sender to andrei@gravitonic.com using -f Date: Tue, 18 Mar 2003 16:57:02 -0500 To: PHP Internals Message-ID: <20030318215701.GA8449@hyperion.gravitonic.com> Mail-Followup-To: Andrei Zmievski , PHP Internals References: <20030318215420.GA8409@hyperion.gravitonic.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030318215420.GA8409@hyperion.gravitonic.com> User-Agent: Mutt/1.4i Subject: Re: [PHP-DEV] function registration patch From: andrei@gravitonic.com (Andrei Zmievski) Grr. Totally slipped my mind that with this patch, the original function names will be lost when doing get_class_methods() and similar stuff. Any other suggestions? On Tue, 18 Mar 2003, Andrei Zmievski wrote: > 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. * > 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 */ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php -Andrei http://www.gravitonic.com/ * "UNIX, isn't that some archaic form of DOS?" - our job applicant *