Hi again,

I have it working here now, but whether that's just because the test suite script's set to ISO-8859-1/UTF-8 I don't know...

Patch attached in case anyone wants to mess about with it (nb 'ware DOS). It's nothing like commit-able, I was just fiddling, since having a third of our tests failing in HEAD poses a major problem when trying to maintain cross-version compatibility.

I found a problem with running zend_hash_find() on the env vars resulting from this patch. I think this is probably because the returned keys are unicode but the data is binary?

Outside of that issue, which *might* not be related anyway, 'it works on my box'.

- Steph
Index: ext/standard/proc_open.c
===================================================================
RCS file: /repository/php-src/ext/standard/proc_open.c,v
retrieving revision 1.63
diff -u -r1.63 proc_open.c
--- ext/standard/proc_open.c    23 Jul 2008 11:24:35 -0000      1.63
+++ ext/standard/proc_open.c    30 Jul 2008 19:02:53 -0000
@@ -75,13 +75,12 @@
{
        zval **element;
        php_process_env_t env;
-       zstr string_key;
-       char *data;
+       zstr zstr_key;
+       char *string_key, *data, *p;
#ifndef PHP_WIN32
        char **ep;
#endif
-       char *p;
-       uint string_length, cnt, l, sizeenv=0, el_len;
+       uint zstr_length, cnt, l, sizeenv=0, el_len;
        ulong num_key;
        HashTable *target_hash;
        HashPosition pos;
@@ -120,12 +119,20 @@
                
                sizeenv += el_len+1;
                
-               switch (zend_hash_get_current_key_ex(target_hash, &string_key, 
&string_length, &num_key, 0, &pos)) {
+               switch (zend_hash_get_current_key_ex(target_hash, &zstr_key, 
&zstr_length, &num_key, 0, &pos)) {
+                       case HASH_KEY_IS_UNICODE:
+                               if (zstr_length == 0) {
+                                       continue;
+                               }
+                               spprintf(&string_key, 0, "%v", zstr_key);
+                               sizeenv += strlen(string_key)+1;
+                               break;
                        case HASH_KEY_IS_STRING:
-                               if (string_length == 0) {
+                               if (zstr_length == 0) {
                                        continue;
                                }
-                               sizeenv += string_length+1;
+                               string_key = zstr_key.s;
+                               sizeenv += strlen(string_key)+1;
                                break;
                }
        }
@@ -138,8 +145,13 @@
        for (zend_hash_internal_pointer_reset_ex(target_hash, &pos);
                        zend_hash_get_current_data_ex(target_hash, (void **) 
&element, &pos) == SUCCESS;
                        zend_hash_move_forward_ex(target_hash, &pos)) {
-               
-               convert_to_string_ex(element);
+
+               if (Z_TYPE_PP(element) == IS_UNICODE) {
+                       zval_unicode_to_string(*(element) TSRMLS_CC);
+               } else {
+                       convert_to_string_ex(element);
+               }
+
                el_len = Z_STRLEN_PP(element);
                
                if (el_len == 0) {
@@ -147,16 +159,31 @@
                }
                
                data = Z_STRVAL_PP(element);
-               switch (zend_hash_get_current_key_ex(target_hash, &string_key, 
&string_length, &num_key, 0, &pos)) {
+
+               switch (zend_hash_get_current_key_ex(target_hash, &zstr_key, 
&zstr_length, &num_key, 0, &pos)) {
+                       case HASH_KEY_IS_UNICODE:
+                               if (zstr_length == 0) {
+                                       continue;
+                               }
+                               spprintf(&string_key, 0, "%v", zstr_key);
+                               l = zstr_length + el_len + 1;
+                               memcpy(p, string_key, zstr_length + 1);
+                               strcat(p, "=");
+                               strcat(p, data);
+#ifndef PHP_WIN32
+                               *ep = p;
+                               ++ep;
+#endif
+                               p += l;
+                               break;
                        case HASH_KEY_IS_STRING:
-                               if (string_length == 0) {
+                               if (zstr_length == 0) {
                                        continue;
                                }
-                               l = string_length + el_len + 1;
-                               memcpy(p, string_key.s, string_length);
+                               l = zstr_length + el_len + 1;
+                               memcpy(p, zstr_key.s, zstr_length);
                                strcat(p, "=");
                                strcat(p, data);
-                               
#ifndef PHP_WIN32
                                *ep = p;
                                ++ep;
@@ -174,10 +201,9 @@
                        case HASH_KEY_NON_EXISTANT:
                                break;
                }
-       }       
+       }

        assert(p - env.envp <= sizeenv);
-       
        zend_hash_internal_pointer_reset_ex(target_hash, &pos);

        return env;

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

Reply via email to