]> granicus.if.org Git - php/commitdiff
made var_dump zend-aware....
authorThies C. Arntzen <thies@php.net>
Sat, 24 Apr 1999 18:39:41 +0000 (18:39 +0000)
committerThies C. Arntzen <thies@php.net>
Sat, 24 Apr 1999 18:39:41 +0000 (18:39 +0000)
<?
$ar = array("hallo" => "tubu");

var_dump($ar);
?>
works again!!!

zeev, andi -> please review what i've done!!!

(no i can start "debugging" other stuff, as i often use var_dump)

ext/standard/php3_var.h
ext/standard/var.c

index 238a0a3cb3b69f84358c12a4b1676c3758c991db..89ebb23bffcbfeaf259ac4e8efaff9f06115fd67 100644 (file)
@@ -35,7 +35,7 @@ PHP_FUNCTION(var_dump);
 PHP_FUNCTION(serialize);
 PHP_FUNCTION(unserialize);
 
-void php3api_var_dump(pval *struc, int level);
+void php3api_var_dump(pval **struc, int level);
 void php3api_var_serialize(pval *buf, pval *struc);
 int php3api_var_unserialize(pval *rval, char **p, char *max);
 
index 7bf00519f5e96f1454311f36a107e2ccca34ca52..8aaecedee7caf3235bb1fe79ad6d4b36a78523df 100644 (file)
 
 #include "php3_var.h"
 
-void php3api_var_dump(pval *struc, int level)
+void php3api_var_dump(pval **struc, int level)
 {
        ulong index;
        char *key;
        int i, c = 0;
-       pval *data;
+       pval **data;
        char buf[512];
 
-       switch (struc->type) {
+       switch ((*struc)->type) {
                case IS_LONG:
-                       i = sprintf(buf, "%*cint(%ld)\n", level, ' ', struc->value.lval);
+                       i = sprintf(buf, "%*cint(%ld)\n", level, ' ', (*struc)->value.lval);
                        PHPWRITE(&buf[1], i - 1);
                        break;
 
                case IS_DOUBLE:
-                       i = sprintf(buf, "%*cfloat(%g)\n", level, ' ', struc->value.dval);
+                       i = sprintf(buf, "%*cfloat(%g)\n", level, ' ', (*struc)->value.dval);
                        PHPWRITE(&buf[1], i - 1);
                        break;
 
                case IS_STRING:
-                       i = sprintf(buf, "%*cstring(%d) \"", level, ' ', struc->value.str.len);
+                       i = sprintf(buf, "%*cstring(%d) \"", level, ' ', (*struc)->value.str.len);
                        PHPWRITE(&buf[1], i - 1);
-                       PHPWRITE(struc->value.str.val, struc->value.str.len);
+                       PHPWRITE((*struc)->value.str.val, (*struc)->value.str.len);
                        strcpy(buf, "\"\n");
                        PHPWRITE(buf, strlen(buf));
                        break;
 
                case IS_ARRAY:
-                       i = sprintf(buf, "%*carray(%d) {\n", level, ' ', _php3_hash_num_elements(struc->value.ht));
+                       i = sprintf(buf, "%*carray(%d) {\n", level, ' ', _php3_hash_num_elements((*struc)->value.ht));
                        PHPWRITE(&buf[1], i - 1);
                        goto head_done;
 
                case IS_OBJECT:
-                       i = sprintf(buf, "%*cobject(%d) {\n", level, ' ', _php3_hash_num_elements(struc->value.ht));
+                       i = sprintf(buf, "%*cobject(%d) {\n", level, ' ', _php3_hash_num_elements((*struc)->value.ht));
                        PHPWRITE(&buf[1], i - 1);
                  head_done:
 
-                       _php3_hash_internal_pointer_reset(struc->value.ht);
-                       for (;; _php3_hash_move_forward(struc->value.ht)) {
-                               if ((i = _php3_hash_get_current_key(struc->value.ht, &key, &index)) == HASH_KEY_NON_EXISTANT)
+                       _php3_hash_internal_pointer_reset((*struc)->value.ht);
+                       for (;; _php3_hash_move_forward((*struc)->value.ht)) {
+                               if ((i = _php3_hash_get_current_key((*struc)->value.ht, &key, &index)) == HASH_KEY_NON_EXISTANT)
                                        break;
                                if (c > 0) {
                                        strcpy(buf, "\n");
                                        PHPWRITE(buf, strlen(buf));
                                }
                                c++;
-                               if (_php3_hash_get_current_data(struc->value.ht, (void **) (&data)) != SUCCESS || !data || (data == struc))
+                               if (_php3_hash_get_current_data((*struc)->value.ht, (void **) (&data)) != SUCCESS || !data || (data == struc))
                                        continue;
                                switch (i) {
                                        case HASH_KEY_IS_LONG:{
-                                                       pval d;
+                                                       pval *d = emalloc(sizeof(pval));
 
-                                                       d.type = IS_LONG;
-                                                       d.value.lval = index;
+                                                       d->type = IS_LONG;
+                                                       d->value.lval = index;
                                                        php3api_var_dump(&d, level + 2);
+                                                       efree(d);
                                                }
                                                break;
 
                                        case HASH_KEY_IS_STRING:{
-                                                       pval d;
+                                                       pval *d = emalloc(sizeof(pval));
 
-                                                       d.type = IS_STRING;
-                                                       d.value.str.val = key;
-                                                       d.value.str.len = strlen(key);
+                                                       d->type = IS_STRING;
+                                                       d->value.str.val = key;
+                                                       d->value.str.len = strlen(key);
                                                        php3api_var_dump(&d, level + 2);
                                                        efree(key);
+                                                       efree(d);
                                                }
                                                break;
                                }
@@ -130,7 +132,7 @@ PHP_FUNCTION(var_dump)
        if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &struc) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       php3api_var_dump(struc, 1);
+       php3api_var_dump(&struc, 1);
 }