CVS update: php3/functions

From: Date: Sun, 04 Oct 1998 14:19:17 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-1651@lists.php.net to get a copy of this message
Date: Sunday October 4, 1998 @ 10:19 Author: zeev Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv1128/functions Modified Files: basic_functions.c php3_var.h var.c Log Message: - Fix the warnings in the serialization code - Change all new serialization stuff to the way PHP code should look like, as far as naming convention and macros are concerned (please try to use these rules in new code) - Add more beta testers Index: php3/functions/basic_functions.c diff -c php3/functions/basic_functions.c:1.225 php3/functions/basic_functions.c:1.226 *** php3/functions/basic_functions.c:1.225 Sat Oct 3 20:50:21 1998 --- php3/functions/basic_functions.c Sun Oct 4 10:19:16 1998 *************** *** 280,290 **** {"call_user_func", php3_call_user_func, NULL}, {"call_user_method", php3_call_user_method, NULL}, ! {"var_dump", php3_var_dump, NULL}, ! {"serialize", php3_serialize, first_arg_allow_ref}, ! {"unserialize", php3_unserialize, first_arg_allow_ref}, ! PHP_FE(register_shutdown_function, NULL) {NULL, NULL, NULL} }; --- 280,290 ---- {"call_user_func", php3_call_user_func, NULL}, {"call_user_method", php3_call_user_method, NULL}, ! PHP_FE(var_dump, NULL) ! PHP_FE(serialize, first_arg_allow_ref) ! PHP_FE(unserialize, first_arg_allow_ref) ! PHP_FE(register_shutdown_function, NULL) {NULL, NULL, NULL} }; Index: php3/functions/php3_var.h diff -c php3/functions/php3_var.h:1.1 php3/functions/php3_var.h:1.2 *** php3/functions/php3_var.h:1.1 Tue Sep 29 03:14:39 1998 --- php3/functions/php3_var.h Sun Oct 4 10:19:17 1998 *************** *** 31,38 **** #ifndef _PHPVAR_H #define _PHPVAR_H ! extern void php3_var_dump(INTERNAL_FUNCTION_PARAMETERS); ! extern void php3_serialize(INTERNAL_FUNCTION_PARAMETERS); ! extern void php3_unserialize(INTERNAL_FUNCTION_PARAMETERS); #endif /* _PHPVAR_H */ --- 31,38 ---- #ifndef _PHPVAR_H #define _PHPVAR_H ! PHP_FUNCTION(var_dump); ! PHP_FUNCTION(serialize); ! PHP_FUNCTION(unserialize); #endif /* _PHPVAR_H */ Index: php3/functions/var.c diff -c php3/functions/var.c:1.3 php3/functions/var.c:1.4 *** php3/functions/var.c:1.3 Tue Sep 29 19:47:21 1998 --- php3/functions/var.c Sun Oct 4 10:19:17 1998 *************** *** 44,50 **** #endif ! void _php3_var_dump(pval * struc, int level) { ulong index; char * key; --- 44,50 ---- #endif ! void php3api_var_dump(pval *struc, int level) { ulong index; char * key; *************** *** 54,70 **** switch(struc->type) { case IS_LONG: ! i = sprintf(buf, "% *cint(%d)\n", level, ' ', struc->value.lval); PHPWRITE(&buf[1], i-1); break; case IS_DOUBLE: ! 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); PHPWRITE(&buf[1], i-1); PHPWRITE(struc->value.str.val, struc->value.str.len); strcpy(buf, "\"\n"); --- 54,70 ---- switch(struc->type) { case IS_LONG: ! 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); PHPWRITE(&buf[1], i-1); break; case IS_STRING: ! i = sprintf(buf, "%*cstring(%d) \"", level, ' ', struc->value.str.len); PHPWRITE(&buf[1], i-1); PHPWRITE(struc->value.str.val, struc->value.str.len); strcpy(buf, "\"\n"); *************** *** 72,83 **** break; case IS_ARRAY: ! 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)); PHPWRITE(&buf[1], i-1); head_done: --- 72,83 ---- break; case IS_ARRAY: ! 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)); PHPWRITE(&buf[1], i-1); head_done: *************** *** 95,101 **** pval d; d.type = IS_LONG; d.value.lval = index; ! _php3_var_dump(&d, level+2); } break; --- 95,101 ---- pval d; d.type = IS_LONG; d.value.lval = index; ! php3api_var_dump(&d, level+2); } break; *************** *** 104,140 **** d.type = IS_STRING; d.value.str.val = key; d.value.str.len = strlen(key); ! _php3_var_dump(&d, level+2); } break; } ! _php3_var_dump(data, level+2); } ! i = sprintf(buf, "% *c}\n", level, ' '); PHPWRITE(&buf[1], i-1); break; default: ! i = sprintf(buf, "% *ci:0\n", level, ' '); PHPWRITE(&buf[1], i-1); } } ! void php3_var_dump(INTERNAL_FUNCTION_PARAMETERS) { ! pval * struc; if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &struc) == FAILURE) { WRONG_PARAM_COUNT; } ! _php3_var_dump(struc, 1); } #define STR_CAT(P,S,I) {\ ! pval * __p = (P);\ ulong __i = __p->value.str.len;\ __p->value.str.len += (I);\ if (__p->value.str.val) {\ --- 104,140 ---- d.type = IS_STRING; d.value.str.val = key; d.value.str.len = strlen(key); ! php3api_var_dump(&d, level+2); } break; } ! php3api_var_dump(data, level+2); } ! i = sprintf(buf, "%*c}\n", level, ' '); PHPWRITE(&buf[1], i-1); break; default: ! i = sprintf(buf, "%*ci:0\n", level, ' '); PHPWRITE(&buf[1], i-1); } } ! PHP_FUNCTION(var_dump) { ! pval *struc; if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &struc) == FAILURE) { WRONG_PARAM_COUNT; } ! php3api_var_dump(struc, 1); } #define STR_CAT(P,S,I) {\ ! pval *__p = (P);\ ulong __i = __p->value.str.len;\ __p->value.str.len += (I);\ if (__p->value.str.val) {\ *************** *** 145,152 **** }\ strcat(__p->value.str.val + __i, (S));\ } ! void _php3_var_serialize(pval * buf, pval * struc) { char s[256]; ulong slen; --- 145,153 ---- }\ strcat(__p->value.str.val + __i, (S));\ } + ! void php3api_var_serialize(pval *buf, pval *struc) { char s[256]; ulong slen; *************** *** 154,160 **** switch(struc->type) { case IS_LONG: ! slen = sprintf(s, "i:%d;", struc->value.lval); STR_CAT(buf, s, slen); return; --- 155,161 ---- switch(struc->type) { case IS_LONG: ! slen = sprintf(s, "i:%ld;", struc->value.lval); STR_CAT(buf, s, slen); return; *************** *** 192,198 **** STR_CAT(buf, s, slen); if (i > 0) { char * key; ! pval * data; pval d; ulong index; _php3_hash_internal_pointer_reset(struc->value.ht); --- 193,199 ---- STR_CAT(buf, s, slen); if (i > 0) { char * key; ! pval *data; pval d; ulong index; _php3_hash_internal_pointer_reset(struc->value.ht); *************** *** 207,222 **** case HASH_KEY_IS_LONG: d.type = IS_LONG; d.value.lval = index; ! _php3_var_serialize(buf, &d); break; case HASH_KEY_IS_STRING: d.type = IS_STRING; d.value.str.val = key; d.value.str.len = strlen(key); ! _php3_var_serialize(buf, &d); break; } ! _php3_var_serialize(buf, data); } } STR_CAT(buf, "}", 1); --- 208,223 ---- case HASH_KEY_IS_LONG: d.type = IS_LONG; d.value.lval = index; ! php3api_var_serialize(buf, &d); break; case HASH_KEY_IS_STRING: d.type = IS_STRING; d.value.str.val = key; d.value.str.len = strlen(key); ! php3api_var_serialize(buf, &d); break; } ! php3api_var_serialize(buf, data); } } STR_CAT(buf, "}", 1); *************** *** 229,235 **** } ! int _php3_var_unserialize(pval *rval, char **p, char *max) { char * q; char * str; --- 230,236 ---- } ! int php3api_var_unserialize(pval *rval, char **p, char *max) { char * q; char * str; *************** *** 318,327 **** for((*p)+=2; **p && **p != '}' && i>0; i--) { pval key; pval data; ! if (!_php3_var_unserialize(&key, p, max)) { return 0; } ! if (!_php3_var_unserialize(&data, p, max)) { return 0; } switch(key.type) { --- 319,328 ---- for((*p)+=2; **p && **p != '}' && i>0; i--) { pval key; pval data; ! if (!php3api_var_unserialize(&key, p, max)) { return 0; } ! if (!php3api_var_unserialize(&data, p, max)) { return 0; } switch(key.type) { *************** *** 341,347 **** } ! void php3_serialize(INTERNAL_FUNCTION_PARAMETERS) { pval *struc; --- 342,348 ---- } ! PHP_FUNCTION(serialize) { pval *struc; *************** *** 352,370 **** return_value->type = IS_STRING; return_value->value.str.val = NULL; return_value->value.str.len = 0; ! _php3_var_serialize(return_value, struc); } ! void php3_unserialize(INTERNAL_FUNCTION_PARAMETERS) { ! pval * buf; if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &buf) == FAILURE) { WRONG_PARAM_COUNT; } if (buf->type == IS_STRING) { char * p = buf->value.str.val; ! if (!_php3_var_unserialize(return_value, &p, p + buf->value.str.len)) { RETURN_FALSE; } } else { --- 353,371 ---- return_value->type = IS_STRING; return_value->value.str.val = NULL; return_value->value.str.len = 0; ! php3api_var_serialize(return_value, struc); } ! PHP_FUNCTION(unserialize) { ! pval *buf; if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &buf) == FAILURE) { WRONG_PARAM_COUNT; } if (buf->type == IS_STRING) { char * p = buf->value.str.val; ! if (!php3api_var_unserialize(return_value, &p, p + buf->value.str.len)) { RETURN_FALSE; } } else { -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1651) next »