Hello,

While developing software in PHP that supports i18n I've come across several 
problems that affect defines made in PHP.
The first problem is that when a define is declared and its name contains 
upper case characters such as I, the define becomes unusable if a locale, 
which does not support those chracters is exported, such as tr_TR or ru_IU.
Bug Report at: http://bugs.php.net/bug.php?id=16865

There is a problem with case sensetivity of defines, for example, if you 
create a case sensetive define 'TEST' and then a case sensetive define 
'test', the latter define's value will be lost.
Bug Report at: http://bugs.php.net/?id=17658

The problem occurs because zend internally (zend_constants.c) seems to always 
lowecase the define before it is fetched/added to the hash table of defines. 
This causes problem for i18n because the define is lowercased using c's 
tolower function, which is affected by locale settings. Because it is stored 
as lower case, having 2 defines with the same name but in different case also 
becomes impossible to do.

Attached is a patch against zend_constants.c CVS revision 1.38 that fixes both 
of these bugs, I hope the developers would consider adding this patch to the 
CVS.

Ilia
--- zend_constants.c_old	Sat Jun 15 13:02:40 2002
+++ zend_constants.c	Sat Jun 15 12:59:11 2002
@@ -226,8 +226,6 @@
 	lookup_name = do_alloca(name_len+1);
 	memcpy(lookup_name, name, name_len+1);
 
-	zend_str_tolower(lookup_name, name_len);
-
 	if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) {
 		if ((c->flags & CONST_CS) && memcmp(c->name, name, name_len)!=0) {
 			retval=0;
@@ -255,7 +253,6 @@
 	printf("Registering constant for module %d\n", c->module_number);
 #endif
 
-	zend_str_tolower(lowercase_name, c->name_len);
 	if (zend_hash_add(EG(zend_constants), lowercase_name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
 		free(c->name);
 		if (!(c->flags & CONST_PERSISTENT)

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to