CVS update: php3

From: Date: Thu, 10 Sep 1998 23:57:01 +0000
Subject: CVS update: php3
Groups: php.dev 
Request: Send a blank email to php-dev+get-948@lists.php.net to get a copy of this message
Date: Thursday September 10, 1998 @ 19:57 Author: zeev Update of /repository/php3 In directory asf:/u2/tmp/cvs-serv29994 Modified Files: Makefile.in apidoc.txt configuration-parser.y constants.c control_structures_inline.h internal_functions.c language-parser.y language-scanner.lex main.c operators.c operators.h php.h token_cache.c variables.c variables.h Log Message: Clean all remaining leftovers from yystype, convert to pval and fix capitalization on macros Index: php3/Makefile.in diff -c php3/Makefile.in:1.254 php3/Makefile.in:1.255 *** php3/Makefile.in:1.254 Wed Sep 9 08:38:04 1998 --- php3/Makefile.in Thu Sep 10 19:56:52 1998 *************** *** 24,30 **** # +----------------------------------------------------------------------+ # ! # $Id: Makefile.in,v 1.254 1998/09/09 12:38:04 ssb Exp $ # prefix = @prefix@ --- 24,30 ---- # +----------------------------------------------------------------------+ # ! # $Id: Makefile.in,v 1.255 1998/09/10 23:56:52 zeev Exp $ # prefix = @prefix@ *************** *** 199,205 **** -T pval -T HashTable -T Bucket -T Token -T TokenCache -T TokenCacheManager \ -T switch_expr -T internal_function -T control_structure_data \ -T MemoryHashTable -T MemoryBucket \ ! -T yystype_value -T Stack *.c *.h functions/*.c functions/*.h rm -f *~ functions/*~ .c.o: --- 199,205 ---- -T pval -T HashTable -T Bucket -T Token -T TokenCache -T TokenCacheManager \ -T switch_expr -T internal_function -T control_structure_data \ -T MemoryHashTable -T MemoryBucket \ ! -T pvalue_value -T Stack *.c *.h functions/*.c functions/*.h rm -f *~ functions/*~ .c.o: Index: php3/apidoc.txt diff -c php3/apidoc.txt:1.39 php3/apidoc.txt:1.40 *** php3/apidoc.txt:1.39 Fri May 15 06:56:16 1998 --- php3/apidoc.txt Thu Sep 10 19:56:52 1998 *************** *** 48,61 **** When you change any of the passed parameters, whether they are sent by reference or by value, you can either start over with the parameter by ! calling yystype_destructor on it, or if it's an ARRAY you want to add to, you can use functions similar to the ones in internal_functions.h which manipulate return_value as an ARRAY. Also if you change a parameter to IS_STRING make sure you first assign the new estrdup'ed string and the string length, and only later change the type to IS_STRING. If you change the string of a parameter which already ! IS_STRING or IS_ARRAY you should run yystype_destructor on it first. ----------------- --- 48,61 ---- When you change any of the passed parameters, whether they are sent by reference or by value, you can either start over with the parameter by ! calling pval_destructor on it, or if it's an ARRAY you want to add to, you can use functions similar to the ones in internal_functions.h which manipulate return_value as an ARRAY. Also if you change a parameter to IS_STRING make sure you first assign the new estrdup'ed string and the string length, and only later change the type to IS_STRING. If you change the string of a parameter which already ! IS_STRING or IS_ARRAY you should run pval_destructor on it first. ----------------- *************** *** 175,182 **** else { doesn't exist } * If you also need to get the type of the variable, you can use: ! hash_find(active_symbol_table,"foo",sizeof("foo"),&yystype); ! check(yystype.type); Arrays in PHP 3.0 are implemented using the same hashtables as symbol tables. This means the two above functions can also be used to check variables --- 175,182 ---- else { doesn't exist } * If you also need to get the type of the variable, you can use: ! hash_find(active_symbol_table,"foo",sizeof("foo"),&pvalue); ! check(pvalue.type); Arrays in PHP 3.0 are implemented using the same hashtables as symbol tables. This means the two above functions can also be used to check variables Index: php3/configuration-parser.y diff -c php3/configuration-parser.y:1.74 php3/configuration-parser.y:1.75 *** php3/configuration-parser.y:1.74 Mon Jun 22 16:28:02 1998 --- php3/configuration-parser.y Thu Sep 10 19:56:53 1998 *************** *** 30,36 **** ! /* $Id: configuration-parser.y,v 1.74 1998/06/22 20:28:02 zeev Exp $ */ #define DEBUG_CFG_PARSER 1 #ifdef THREAD_SAFE --- 30,36 ---- ! /* $Id: configuration-parser.y,v 1.75 1998/09/10 23:56:53 zeev Exp $ */ #define DEBUG_CFG_PARSER 1 #ifdef THREAD_SAFE *************** *** 78,84 **** return FAILURE; } var = *tmp; ! yystype_copy_constructor(&var); convert_to_long(&var); *result = var.value.lval; return SUCCESS; --- 78,84 ---- return FAILURE; } var = *tmp; ! pval_copy_constructor(&var); convert_to_long(&var); *result = var.value.lval; return SUCCESS; *************** *** 94,100 **** return FAILURE; } var = *tmp; ! yystype_copy_constructor(&var); convert_to_double(&var); *result = var.value.dval; return SUCCESS; --- 94,100 ---- return FAILURE; } var = *tmp; ! pval_copy_constructor(&var); convert_to_double(&var); *result = var.value.dval; return SUCCESS; *************** *** 120,138 **** } ! static void yystype_config_destructor(pval *yystype) { ! if (yystype->type == IS_STRING && yystype->value.str.val != empty_string) { ! free(yystype->value.str.val); } } ! static void yystype_browscap_destructor(pval *yystype) { ! if (yystype->type == IS_OBJECT || yystype->type == IS_ARRAY) { ! _php3_hash_destroy(yystype->value.ht); ! free(yystype->value.ht); } } --- 120,138 ---- } ! static void pvalue_config_destructor(pval *pvalue) { ! if (pvalue->type == IS_STRING && pvalue->value.str.val != empty_string) { ! free(pvalue->value.str.val); } } ! static void pvalue_browscap_destructor(pval *pvalue) { ! if (pvalue->type == IS_OBJECT || pvalue->type == IS_ARRAY) { ! _php3_hash_destroy(pvalue->value.ht); ! free(pvalue->value.ht); } } *************** *** 141,147 **** { TLS_VARS; ! if (_php3_hash_init(&configuration_hash, 0, NULL, (void (*)(void *))yystype_config_destructor, 1)==FAILURE) { return FAILURE; } --- 141,147 ---- { TLS_VARS; ! if (_php3_hash_init(&configuration_hash, 0, NULL, (void (*)(void *))pvalue_config_destructor, 1)==FAILURE) { return FAILURE; } *************** *** 232,238 **** TLS_VARS; if (php3_ini.browscap) { ! if (_php3_hash_init(&GLOBAL(browser_hash), 0, NULL, (void (*)(void *))yystype_browscap_destructor, 1)==FAILURE) { return FAILURE; } --- 232,238 ---- TLS_VARS; if (php3_ini.browscap) { ! if (_php3_hash_init(&GLOBAL(browser_hash), 0, NULL, (void (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) { return FAILURE; } *************** *** 359,365 **** /*printf("'%s' (%d)\n",$1.value.str.val,$1.value.str.len+1);*/ tmp.value.ht = (HashTable *) malloc(sizeof(HashTable)); ! _php3_hash_init(tmp.value.ht, 0, NULL, (void (*)(void *))yystype_config_destructor, 1); tmp.type = IS_OBJECT; _php3_hash_update(active__php3_hash_table, $1.value.str.val, $1.value.str.len+1, (void *) &tmp, sizeof(pval), (void **) &current_section); tmp.value.str.val = php3_strndup($1.value.str.val,$1.value.str.len); --- 359,365 ---- /*printf("'%s' (%d)\n",$1.value.str.val,$1.value.str.len+1);*/ tmp.value.ht = (HashTable *) malloc(sizeof(HashTable)); ! _php3_hash_init(tmp.value.ht, 0, NULL, (void (*)(void *))pvalue_config_destructor, 1); tmp.type = IS_OBJECT; _php3_hash_update(active__php3_hash_table, $1.value.str.val, $1.value.str.len+1, (void *) &tmp, sizeof(pval), (void **) &current_section); tmp.value.str.val = php3_strndup($1.value.str.val,$1.value.str.len); Index: php3/constants.c diff -c php3/constants.c:1.17 php3/constants.c:1.18 *** php3/constants.c:1.17 Tue Jul 28 17:59:57 1998 --- php3/constants.c Thu Sep 10 19:56:53 1998 *************** *** 48,54 **** { TLS_VARS; if (!(c->flags & CONST_PERSISTENT)) { ! yystype_destructor(&c->value _INLINE_TLS); } free(c->name); } --- 48,54 ---- { TLS_VARS; if (!(c->flags & CONST_PERSISTENT)) { ! pval_destructor(&c->value _INLINE_TLS); } free(c->name); } *************** *** 198,204 **** } else { retval=1; *result = c->value; ! yystype_copy_constructor(result); } } else { retval=0; --- 198,204 ---- } else { retval=1; *result = c->value; ! pval_copy_constructor(result); } } else { retval=0; *************** *** 265,271 **** convert_to_string(var); c.value = *val; ! yystype_copy_constructor(&c.value); c.flags = case_sensitive | ~CONST_PERSISTENT; /* non persistent */ c.name = php3_strndup(var->value.str.val, var->value.str.len); c.name_len = var->value.str.len+1; --- 265,271 ---- convert_to_string(var); c.value = *val; ! pval_copy_constructor(&c.value); c.flags = case_sensitive | ~CONST_PERSISTENT; /* non persistent */ c.name = php3_strndup(var->value.str.val, var->value.str.len); c.name_len = var->value.str.len+1; Index: php3/control_structures_inline.h diff -c php3/control_structures_inline.h:1.185 php3/control_structures_inline.h:1.186 *** php3/control_structures_inline.h:1.185 Tue Aug 25 14:48:55 1998 --- php3/control_structures_inline.h Thu Sep 10 19:56:53 1998 *************** *** 29,35 **** */ ! /* $Id: control_structures_inline.h,v 1.185 1998/08/25 18:48:55 rasmus Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: control_structures_inline.h,v 1.186 1998/09/10 23:56:53 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 115,121 **** return FAILURE; } if ((varname->type != IS_STRING)) { ! yystype_destructor(varname _INLINE_TLS); php3_error(E_WARNING, "Incorrect variable type or name in global in function %s()", GLOBAL(function_state).function_name); return FAILURE; } --- 115,121 ---- return FAILURE; } if ((varname->type != IS_STRING)) { ! pval_destructor(varname _INLINE_TLS); php3_error(E_WARNING, "Incorrect variable type or name in global in function %s()", GLOBAL(function_state).function_name); return FAILURE; } *************** *** 156,181 **** php3_error(E_WARNING, "STATIC variable decleration meaningless in main() scope"); STR_FREE(varname->value.str.val); if (value) { ! yystype_destructor(value _INLINE_TLS); } return FAILURE; } if ((varname->type != IS_STRING)) { ! yystype_destructor(varname _INLINE_TLS); ! yystype_destructor(value _INLINE_TLS); php3_error(E_WARNING, "Incorrect variable type or name in static in function %s()", GLOBAL(function_state).function_name); return FAILURE; } if (_php3_hash_find(GLOBAL(function_state).hosting_function_table, GLOBAL(function_state).function_name, strlen(GLOBAL(function_state).function_name)+1, (void **) &func_ent) == FAILURE) { STR_FREE(varname->value.str.val); if (value) { ! yystype_destructor(value _INLINE_TLS); } return FAILURE; } if (!func_ent->value.func.addr.statics) { func_ent->value.func.addr.statics = (HashTable *) emalloc(sizeof(HashTable)); ! _php3_hash_init(func_ent->value.func.addr.statics, 0, NULL, pval_DESTRUCTOR, 0); } if (_php3_hash_find(func_ent->value.func.addr.statics, varname->value.str.val, varname->value.str.len+1, (void **) &variable_entry) == FAILURE) { if (value) { --- 156,181 ---- php3_error(E_WARNING, "STATIC variable decleration meaningless in main() scope"); STR_FREE(varname->value.str.val); if (value) { ! pval_destructor(value _INLINE_TLS); } return FAILURE; } if ((varname->type != IS_STRING)) { ! pval_destructor(varname _INLINE_TLS); ! pval_destructor(value _INLINE_TLS); php3_error(E_WARNING, "Incorrect variable type or name in static in function %s()", GLOBAL(function_state).function_name); return FAILURE; } if (_php3_hash_find(GLOBAL(function_state).hosting_function_table, GLOBAL(function_state).function_name, strlen(GLOBAL(function_state).function_name)+1, (void **) &func_ent) == FAILURE) { STR_FREE(varname->value.str.val); if (value) { ! pval_destructor(value _INLINE_TLS); } return FAILURE; } if (!func_ent->value.func.addr.statics) { func_ent->value.func.addr.statics = (HashTable *) emalloc(sizeof(HashTable)); ! _php3_hash_init(func_ent->value.func.addr.statics, 0, NULL, PVAL_DESTRUCTOR, 0); } if (_php3_hash_find(func_ent->value.func.addr.statics, varname->value.str.val, varname->value.str.len+1, (void **) &variable_entry) == FAILURE) { if (value) { *************** *** 189,195 **** php3_error(E_ERROR, "Inserted static variable got lost"); STR_FREE(varname->value.str.val); if (value) { ! yystype_destructor(value); } return FAILURE; } --- 189,195 ---- php3_error(E_ERROR, "Inserted static variable got lost"); STR_FREE(varname->value.str.val); if (value) { ! pval_destructor(value); } return FAILURE; } *************** *** 199,205 **** php3_error(E_ERROR, "Unable to initialize static variable"); STR_FREE(varname->value.str.val); if (value) { ! yystype_destructor(value _INLINE_TLS); } return FAILURE; } else { --- 199,205 ---- php3_error(E_ERROR, "Unable to initialize static variable"); STR_FREE(varname->value.str.val); if (value) { ! pval_destructor(value _INLINE_TLS); } return FAILURE; } else { *************** *** 217,230 **** if (GLOBAL(Execute)) { tc_set_token(&GLOBAL(token_cache_manager), while_token->offset, WHILE); ! if (yystype_true(expr)) { GLOBAL(ExecuteFlag) = EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } else { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } ! yystype_destructor(expr _INLINE_TLS); } } --- 217,230 ---- if (GLOBAL(Execute)) { tc_set_token(&GLOBAL(token_cache_manager), while_token->offset, WHILE); ! if (pval_is_true(expr)) { GLOBAL(ExecuteFlag) = EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } else { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } ! pval_destructor(expr _INLINE_TLS); } } *************** *** 283,295 **** fprintf(stderr, "end of while, execute=%d, changecount=%d, changetype=%d\n", Execute, GLOBAL(function_state).loop_change_level, GLOBAL(function_state).loop_change_level); #endif ! if (GLOBAL(Execute) && yystype_true(expr)) { ! yystype_destructor(expr _INLINE_TLS); tc_set_token(&GLOBAL(token_cache_manager), do_token->offset, CONTINUED_DOWHILE); seek_token(&GLOBAL(token_cache_manager), do_token->offset, yychar); } else { if (GLOBAL(Execute)) { ! yystype_destructor(expr _INLINE_TLS); } if ((GLOBAL(function_state).loop_change_type != DO_NOTHING) && (GLOBAL(function_state).loop_change_level == GLOBAL(function_state).loop_nest_level)) { GLOBAL(function_state).loop_change_type = DO_NOTHING; --- 283,295 ---- fprintf(stderr, "end of while, execute=%d, changecount=%d, changetype=%d\n", Execute, GLOBAL(function_state).loop_change_level, GLOBAL(function_state).loop_change_level); #endif ! if (GLOBAL(Execute) && pval_is_true(expr)) { ! pval_destructor(expr _INLINE_TLS); tc_set_token(&GLOBAL(token_cache_manager), do_token->offset, CONTINUED_DOWHILE); seek_token(&GLOBAL(token_cache_manager), do_token->offset, yychar); } else { if (GLOBAL(Execute)) { ! pval_destructor(expr _INLINE_TLS); } if ((GLOBAL(function_state).loop_change_type != DO_NOTHING) && (GLOBAL(function_state).loop_change_level == GLOBAL(function_state).loop_nest_level)) { GLOBAL(function_state).loop_change_type = DO_NOTHING; *************** *** 308,321 **** stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); /* push current state to stack */ if (GLOBAL(Execute)) { /* we're in a code block that needs to be evaluated */ ! if (yystype_true(expr)) { /* the IF expression is yystype_true, execute IF code */ GLOBAL(ExecuteFlag) = EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } else { /* the IF expression is false, don't execute IF code */ GLOBAL(ExecuteFlag) = BEFORE_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } ! yystype_destructor(expr _INLINE_TLS); } else { GLOBAL(ExecuteFlag) = DONT_EXECUTE; } --- 308,321 ---- stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); /* push current state to stack */ if (GLOBAL(Execute)) { /* we're in a code block that needs to be evaluated */ ! if (pval_is_true(expr)) { /* the IF expression is pval_is_true, execute IF code */ GLOBAL(ExecuteFlag) = EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } else { /* the IF expression is false, don't execute IF code */ GLOBAL(ExecuteFlag) = BEFORE_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } ! pval_destructor(expr _INLINE_TLS); } else { GLOBAL(ExecuteFlag) = DONT_EXECUTE; } *************** *** 344,363 **** php3_error(E_ERROR, "Cannot %s from %d loop(s) from nesting level %d", (op_type == DO_BREAK ? "break" : "continue"), (expr ? expr->value.lval : 1), GLOBAL(function_state).loop_nest_level); if (expr) { ! yystype_destructor(expr _INLINE_TLS); } return FAILURE; } else if (GLOBAL(function_state).loop_change_level > GLOBAL(function_state).loop_nest_level) { php3_error(E_ERROR, "Cannot continue from %d loops", (expr ? expr->value.lval : -1)); if (expr) { ! yystype_destructor(expr _INLINE_TLS); } return FAILURE; } GLOBAL(function_state).loop_change_type = op_type; GLOBAL(Execute) = 0; if (expr) { ! yystype_destructor(expr _INLINE_TLS); } } return SUCCESS; --- 344,363 ---- php3_error(E_ERROR, "Cannot %s from %d loop(s) from nesting level %d", (op_type == DO_BREAK ? "break" : "continue"), (expr ? expr->value.lval : 1), GLOBAL(function_state).loop_nest_level); if (expr) { ! pval_destructor(expr _INLINE_TLS); } return FAILURE; } else if (GLOBAL(function_state).loop_change_level > GLOBAL(function_state).loop_nest_level) { php3_error(E_ERROR, "Cannot continue from %d loops", (expr ? expr->value.lval : -1)); if (expr) { ! pval_destructor(expr _INLINE_TLS); } return FAILURE; } GLOBAL(function_state).loop_change_type = op_type; GLOBAL(Execute) = 0; if (expr) { ! pval_destructor(expr _INLINE_TLS); } } return SUCCESS; *************** *** 396,406 **** GLOBAL(Execute) = SHOULD_EXECUTE; } if (GLOBAL(ExecuteFlag) == BEFORE_EXECUTE) { ! if (yystype_true(expr)) { GLOBAL(ExecuteFlag) = EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } ! yystype_destructor(expr _INLINE_TLS); } } --- 396,406 ---- GLOBAL(Execute) = SHOULD_EXECUTE; } if (GLOBAL(ExecuteFlag) == BEFORE_EXECUTE) { ! if (pval_is_true(expr)) { GLOBAL(ExecuteFlag) = EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } ! pval_destructor(expr _INLINE_TLS); } } *************** *** 433,448 **** _php3_hash_update(GLOBAL(active_symbol_table), varname->value.str.val, varname->value.str.len+1, &tmp, sizeof(pval), NULL); } else if (!_php3_hash_index_is_pointer(GLOBAL(active_symbol_table), GLOBAL(param_index))) { /* passed by value */ tmp = *data; ! yystype_copy_constructor(&tmp); _php3_hash_update(GLOBAL(active_symbol_table), varname->value.str.val, varname->value.str.len+1, &tmp, sizeof(pval), NULL); if (default_value) { ! yystype_destructor(default_value _INLINE_TLS); } } else { /* passed by reference */ _php3_hash_pointer_update(GLOBAL(active_symbol_table), varname->value.str.val, varname->value.str.len+1, data); _php3_hash_index_del(GLOBAL(active_symbol_table), GLOBAL(param_index)); if (default_value) { ! yystype_destructor(default_value _INLINE_TLS); } } } else if (!GLOBAL(php3_display_source)) { --- 433,448 ---- _php3_hash_update(GLOBAL(active_symbol_table), varname->value.str.val, varname->value.str.len+1, &tmp, sizeof(pval), NULL); } else if (!_php3_hash_index_is_pointer(GLOBAL(active_symbol_table), GLOBAL(param_index))) { /* passed by value */ tmp = *data; ! pval_copy_constructor(&tmp); _php3_hash_update(GLOBAL(active_symbol_table), varname->value.str.val, varname->value.str.len+1, &tmp, sizeof(pval), NULL); if (default_value) { ! pval_destructor(default_value _INLINE_TLS); } } else { /* passed by reference */ _php3_hash_pointer_update(GLOBAL(active_symbol_table), varname->value.str.val, varname->value.str.len+1, data); _php3_hash_index_del(GLOBAL(active_symbol_table), GLOBAL(param_index)); if (default_value) { ! pval_destructor(default_value _INLINE_TLS); } } } else if (!GLOBAL(php3_display_source)) { *************** *** 486,492 **** if (_php3_hash_next_index_insert(GLOBAL(function_state).function_symbol_table, expr, sizeof(pval),NULL) == FAILURE) { php3_error(E_WARNING, "Error updating symbol table"); ! yystype_destructor(expr _INLINE_TLS); GLOBAL(function_state).function_type = 0; /* don't execute the function call */ } } --- 486,492 ---- if (_php3_hash_next_index_insert(GLOBAL(function_state).function_symbol_table, expr, sizeof(pval),NULL) == FAILURE) { php3_error(E_WARNING, "Error updating symbol table"); ! pval_destructor(expr _INLINE_TLS); GLOBAL(function_state).function_type = 0; /* don't execute the function call */ } } *************** *** 586,608 **** var_reset(expr3); } if (GLOBAL(Execute) && for_token->cs_data.switched) { ! if (yystype_true(expr3)) { GLOBAL(ExecuteFlag) = EXECUTE; } else { GLOBAL(ExecuteFlag) = DONT_EXECUTE; } GLOBAL(Execute) = SHOULD_EXECUTE; ! yystype_destructor(expr2 _INLINE_TLS); ! yystype_destructor(expr3 _INLINE_TLS); } else if (GLOBAL(Execute) && !for_token->cs_data.switched) { ! if (yystype_true(expr2)) { GLOBAL(ExecuteFlag) = EXECUTE; } else { GLOBAL(ExecuteFlag) = DONT_EXECUTE; } GLOBAL(Execute) = SHOULD_EXECUTE; ! yystype_destructor(expr2 _INLINE_TLS); ! yystype_destructor(expr3 _INLINE_TLS); } } --- 586,608 ---- var_reset(expr3); } if (GLOBAL(Execute) && for_token->cs_data.switched) { ! if (pval_is_true(expr3)) { GLOBAL(ExecuteFlag) = EXECUTE; } else { GLOBAL(ExecuteFlag) = DONT_EXECUTE; } GLOBAL(Execute) = SHOULD_EXECUTE; ! pval_destructor(expr2 _INLINE_TLS); ! pval_destructor(expr3 _INLINE_TLS); } else if (GLOBAL(Execute) && !for_token->cs_data.switched) { ! if (pval_is_true(expr2)) { GLOBAL(ExecuteFlag) = EXECUTE; } else { GLOBAL(ExecuteFlag) = DONT_EXECUTE; } GLOBAL(Execute) = SHOULD_EXECUTE; ! pval_destructor(expr2 _INLINE_TLS); ! pval_destructor(expr3 _INLINE_TLS); } } *************** *** 672,678 **** } if (expr) { print_variable(expr); ! yystype_destructor(expr); } } } --- 672,678 ---- } if (expr) { print_variable(expr); ! pval_destructor(expr); } } } *************** *** 710,716 **** include_file(expr,0); } tc_set_included(&GLOBAL(token_cache_manager), include_token->offset); ! yystype_destructor(expr _INLINE_TLS); } } --- 710,716 ---- include_file(expr,0); } tc_set_included(&GLOBAL(token_cache_manager), include_token->offset); ! pval_destructor(expr _INLINE_TLS); } } *************** *** 732,745 **** if (include_file(expr,1)==SUCCESS) { start_display_source(0 _INLINE_TLS); } ! yystype_destructor(expr _INLINE_TLS); } inline void cs_pre_boolean_or(pval *left_expr INLINE_TLS) { stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); ! if (GLOBAL(Execute) && yystype_true(left_expr)) { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE;; } --- 732,745 ---- if (include_file(expr,1)==SUCCESS) { start_display_source(0 _INLINE_TLS); } ! pval_destructor(expr _INLINE_TLS); } inline void cs_pre_boolean_or(pval *left_expr INLINE_TLS) { stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); ! if (GLOBAL(Execute) && pval_is_true(left_expr)) { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE;; } *************** *** 760,766 **** inline void cs_pre_boolean_and(pval *left_expr INLINE_TLS) { stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); ! if (GLOBAL(Execute) && !yystype_true(left_expr)) { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } --- 760,766 ---- inline void cs_pre_boolean_and(pval *left_expr INLINE_TLS) { stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); ! if (GLOBAL(Execute) && !pval_is_true(left_expr)) { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } *************** *** 781,787 **** inline void cs_questionmark_op_pre_expr1(pval *truth_value INLINE_TLS) { stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); ! if (GLOBAL(Execute) && !yystype_true(truth_value)) { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } --- 781,787 ---- inline void cs_questionmark_op_pre_expr1(pval *truth_value INLINE_TLS) { stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); ! if (GLOBAL(Execute) && !pval_is_true(truth_value)) { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } *************** *** 792,798 **** { GLOBAL(ExecuteFlag) = stack_int_top(&GLOBAL(css)); GLOBAL(Execute) = SHOULD_EXECUTE; ! if (GLOBAL(Execute) && yystype_true(truth_value)) { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } --- 792,798 ---- { GLOBAL(ExecuteFlag) = stack_int_top(&GLOBAL(css)); GLOBAL(Execute) = SHOULD_EXECUTE; ! if (GLOBAL(Execute) && pval_is_true(truth_value)) { GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } *************** *** 805,816 **** stack_del_top(&GLOBAL(css)); GLOBAL(Execute) = SHOULD_EXECUTE; if (GLOBAL(Execute)) { ! if (yystype_true(truth_value)) { *result = *expr1; } else { *result = *expr2; } ! yystype_destructor(truth_value _INLINE_TLS); } } --- 805,816 ---- stack_del_top(&GLOBAL(css)); GLOBAL(Execute) = SHOULD_EXECUTE; if (GLOBAL(Execute)) { ! if (pval_is_true(truth_value)) { *result = *expr1; } else { *result = *expr2; } ! pval_destructor(truth_value _INLINE_TLS); } } *************** *** 826,836 **** pval *data; if (class_ptr) { /* use member function rather than global function */ ! object = (pval *) class_ptr->value.varptr.yystype; if (!object) { if (free_function_name) { ! yystype_destructor(function_name _INLINE_TLS); } php3_error(E_ERROR, "Member function used on a non-object"); return; --- 826,836 ---- pval *data; if (class_ptr) { /* use member function rather than global function */ ! object = (pval *) class_ptr->value.varptr.pvalue; if (!object) { if (free_function_name) { ! pval_destructor(function_name _INLINE_TLS); } php3_error(E_ERROR, "Member function used on a non-object"); return; *************** *** 840,846 **** if (function_name->type != IS_STRING) { php3_error(E_ERROR, "Function names must be strings"); if (free_function_name) { ! yystype_destructor(function_name _INLINE_TLS); } return; } --- 840,846 ---- if (function_name->type != IS_STRING) { php3_error(E_ERROR, "Function names must be strings"); if (free_function_name) { ! pval_destructor(function_name _INLINE_TLS); } return; } *************** *** 870,876 **** GLOBAL(function_state).symbol_table = NULL; return; } ! if (_php3_hash_init(GLOBAL(function_state).function_symbol_table, 0, NULL, pval_DESTRUCTOR, 0) == FAILURE) { php3_error(E_ERROR, "Unable to initialize new symbol table in function call"); function_name->cs_data.function_call_type=0; GLOBAL(function_state).symbol_table = NULL; --- 870,876 ---- GLOBAL(function_state).symbol_table = NULL; return; } ! if (_php3_hash_init(GLOBAL(function_state).function_symbol_table, 0, NULL, PVAL_DESTRUCTOR, 0) == FAILURE) { php3_error(E_ERROR, "Unable to initialize new symbol table in function call"); function_name->cs_data.function_call_type=0; GLOBAL(function_state).symbol_table = NULL; *************** *** 948,954 **** efree(GLOBAL(function_state).object_pointer); } if (free_function_name) { ! yystype_destructor(function_name _INLINE_TLS); } while (stack_int_top(&GLOBAL(for_stack)) != -1) { /* pop FOR stack */ --- 948,954 ---- efree(GLOBAL(function_state).object_pointer); } if (free_function_name) { ! pval_destructor(function_name _INLINE_TLS); } while (stack_int_top(&GLOBAL(for_stack)) != -1) { /* pop FOR stack */ *************** *** 1004,1012 **** /* if case_expr is NULL, we're in the special 'default' case */ if (case_expr) { expr = se->expr; ! yystype_copy_constructor(&expr); is_equal_function(&result, &expr, case_expr _INLINE_TLS); ! is_equal = yystype_true(&result); } if (!case_expr || is_equal) { se->offset=-1; --- 1004,1012 ---- /* if case_expr is NULL, we're in the special 'default' case */ if (case_expr) { expr = se->expr; ! pval_copy_constructor(&expr); is_equal_function(&result, &expr, case_expr _INLINE_TLS); ! is_equal = pval_is_true(&result); } if (!case_expr || is_equal) { se->offset=-1; *************** *** 1018,1024 **** } } else { if (case_expr) { ! yystype_destructor(case_expr _INLINE_TLS); } } } --- 1018,1024 ---- } } else { if (case_expr) { ! pval_destructor(case_expr _INLINE_TLS); } } } *************** *** 1046,1052 **** stack_top(&GLOBAL(switch_stack), (void **) &se); if (se->Execute) { ! yystype_destructor(expr _INLINE_TLS); } stack_del_top(&GLOBAL(switch_stack)); GLOBAL(function_state).loop_nest_level--; --- 1046,1052 ---- stack_top(&GLOBAL(switch_stack), (void **) &se); if (se->Execute) { ! pval_destructor(expr _INLINE_TLS); } stack_del_top(&GLOBAL(switch_stack)); GLOBAL(function_state).loop_nest_level--; *************** *** 1067,1077 **** return; } new_class = *parent_ptr; ! yystype_copy_constructor(&new_class); } else { new_class.type = IS_CLASS; new_class.value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! _php3_hash_init(new_class.value.ht, 0, NULL, pval_DESTRUCTOR, 0); } if (_php3_hash_update(&GLOBAL(function_table), classname->value.str.val, classname->value.str.len+1, &new_class, sizeof(pval),NULL) == FAILURE) { php3_error(E_ERROR, "Unable to initialize new class"); --- 1067,1077 ---- return; } new_class = *parent_ptr; ! pval_copy_constructor(&new_class); } else { new_class.type = IS_CLASS; new_class.value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! _php3_hash_init(new_class.value.ht, 0, NULL, PVAL_DESTRUCTOR, 0); } if (_php3_hash_update(&GLOBAL(function_table), classname->value.str.val, classname->value.str.len+1, &new_class, sizeof(pval),NULL) == FAILURE) { php3_error(E_ERROR, "Unable to initialize new class"); *************** *** 1101,1111 **** GLOBAL(array_ptr) = NULL; } else { if (class_ptr) { ! pval *object=(pval *) class_ptr->value.varptr.yystype; if (!object) { GLOBAL(array_ptr)=NULL; ! yystype_destructor(array_name _INLINE_TLS); return; } target_symbol_table = object->value.ht; --- 1101,1111 ---- GLOBAL(array_ptr) = NULL; } else { if (class_ptr) { ! pval *object=(pval *) class_ptr->value.varptr.pvalue; if (!object) { GLOBAL(array_ptr)=NULL; ! pval_destructor(array_name _INLINE_TLS); return; } target_symbol_table = object->value.ht; *************** *** 1131,1144 **** GLOBAL(array_ptr) = NULL; } } ! yystype_destructor(array_name _INLINE_TLS); } } inline void start_dimensions_parsing(pval *result INLINE_TLS) { if (GLOBAL(Execute)) { ! result->value.varptr.yystype = GLOBAL(array_ptr); if (GLOBAL(array_ptr)) { result->cs_data.array_write=GLOBAL(array_ptr)->cs_data.array_write; } --- 1131,1144 ---- GLOBAL(array_ptr) = NULL; } } ! pval_destructor(array_name _INLINE_TLS); } } inline void start_dimensions_parsing(pval *result INLINE_TLS) { if (GLOBAL(Execute)) { ! result->value.varptr.pvalue = GLOBAL(array_ptr); if (GLOBAL(array_ptr)) { result->cs_data.array_write=GLOBAL(array_ptr)->cs_data.array_write; } *************** *** 1153,1180 **** result->cs_data.array_write = dimension->cs_data.array_write; ! if (dimension->value.varptr.yystype) { ! pval *localdata,tmp,*arr_ptr=dimension->value.varptr.yystype; int new_array=0; /* whether we created the array just now */ if (arr_ptr->type==IS_STRING && arr_ptr->value.str.val!=empty_string && arr_ptr->value.str.val!=undefined_variable_string) { if (dimension->value.varptr.string_offset == -1) { /* ok */ if (!expr) { php3_error(E_WARNING,"No string index specified"); ! result->value.varptr.yystype=NULL; return; } convert_to_long(expr); if (expr->value.lval<0 || expr->value.lval>=arr_ptr->value.str.len) { php3_error(E_WARNING,"Illegal string index"); ! result->value.varptr.yystype=NULL; return; } result->value.varptr.string_offset = expr->value.lval; return; } else { php3_error(E_WARNING,"Cannot index a string index"); ! result->value.varptr.yystype=NULL; return; } } --- 1153,1180 ---- result->cs_data.array_write = dimension->cs_data.array_write; ! if (dimension->value.varptr.pvalue) { ! pval *localdata,tmp,*arr_ptr=dimension->value.varptr.pvalue; int new_array=0; /* whether we created the array just now */ if (arr_ptr->type==IS_STRING && arr_ptr->value.str.val!=empty_string && arr_ptr->value.str.val!=undefined_variable_string) { if (dimension->value.varptr.string_offset == -1) { /* ok */ if (!expr) { php3_error(E_WARNING,"No string index specified"); ! result->value.varptr.pvalue=NULL; return; } convert_to_long(expr); if (expr->value.lval<0 || expr->value.lval>=arr_ptr->value.str.len) { php3_error(E_WARNING,"Illegal string index"); ! result->value.varptr.pvalue=NULL; return; } result->value.varptr.string_offset = expr->value.lval; return; } else { php3_error(E_WARNING,"Cannot index a string index"); ! result->value.varptr.pvalue=NULL; return; } } *************** *** 1184,1191 **** new_array=1; } else if (arr_ptr->type!=IS_ARRAY) { php3_error(E_WARNING,"Index referencing a non-array"); ! result->value.varptr.yystype=NULL; ! yystype_destructor(expr _INLINE_TLS); return; } if (expr) { --- 1184,1191 ---- new_array=1; } else if (arr_ptr->type!=IS_ARRAY) { php3_error(E_WARNING,"Index referencing a non-array"); ! result->value.varptr.pvalue=NULL; ! pval_destructor(expr _INLINE_TLS); return; } if (expr) { *************** *** 1196,1202 **** if (new_array || _php3_hash_index_find(arr_ptr->value.ht, expr->value.lval, (void **) &localdata) == FAILURE) { tmp.type = IS_NULL; _php3_hash_index_update(arr_ptr->value.ht, expr->value.lval, (void *)&tmp, sizeof(pval),(void **) &localdata); ! result->value.varptr.yystype = localdata; result->cs_data.array_write = 1; if (!original_array_write) { /* we raised the write flag just now, record this variable */ variable_tracker vt; --- 1196,1202 ---- if (new_array || _php3_hash_index_find(arr_ptr->value.ht, expr->value.lval, (void **) &localdata) == FAILURE) { tmp.type = IS_NULL; _php3_hash_index_update(arr_ptr->value.ht, expr->value.lval, (void *)&tmp, sizeof(pval),(void **) &localdata); ! result->value.varptr.pvalue = localdata; result->cs_data.array_write = 1; if (!original_array_write) { /* we raised the write flag just now, record this variable */ variable_tracker vt; *************** *** 1207,1224 **** stack_push(&GLOBAL(variable_unassign_stack),(void *) &vt, sizeof(variable_tracker)); } } else { ! result->value.varptr.yystype = localdata; } break; case IS_STRING: if (new_array || _php3_hash_find(arr_ptr->value.ht, expr->value.str.val, expr->value.str.len+1, (void **) &localdata)==FAILURE) { tmp.type = IS_NULL; if (_php3_hash_update(arr_ptr->value.ht, expr->value.str.val, expr->value.str.len+1, (void *) &tmp, sizeof(pval),(void **) &localdata)==FAILURE) { ! result->value.varptr.yystype=NULL; STR_FREE(expr->value.str.val); return; } ! result->value.varptr.yystype = localdata; result->cs_data.array_write = 1; if (!original_array_write) { /* we raised the write flag just now, record this variable */ variable_tracker vt; --- 1207,1224 ---- stack_push(&GLOBAL(variable_unassign_stack),(void *) &vt, sizeof(variable_tracker)); } } else { ! result->value.varptr.pvalue = localdata; } break; case IS_STRING: if (new_array || _php3_hash_find(arr_ptr->value.ht, expr->value.str.val, expr->value.str.len+1, (void **) &localdata)==FAILURE) { tmp.type = IS_NULL; if (_php3_hash_update(arr_ptr->value.ht, expr->value.str.val, expr->value.str.len+1, (void *) &tmp, sizeof(pval),(void **) &localdata)==FAILURE) { ! result->value.varptr.pvalue=NULL; STR_FREE(expr->value.str.val); return; } ! result->value.varptr.pvalue = localdata; result->cs_data.array_write = 1; if (!original_array_write) { /* we raised the write flag just now, record this variable */ variable_tracker vt; *************** *** 1230,1240 **** stack_push(&GLOBAL(variable_unassign_stack),(void *) &vt, sizeof(variable_tracker)); } } else { ! result->value.varptr.yystype = localdata; } break; default: ! result->value.varptr.yystype = NULL; php3_error(E_WARNING, "Illegal index type"); break; } --- 1230,1240 ---- stack_push(&GLOBAL(variable_unassign_stack),(void *) &vt, sizeof(variable_tracker)); } } else { ! result->value.varptr.pvalue = localdata; } break; default: ! result->value.varptr.pvalue = NULL; php3_error(E_WARNING, "Illegal index type"); break; } *************** *** 1243,1249 **** tmp.type = IS_NULL; _php3_hash_next_index_insert(arr_ptr->value.ht, (void *) &tmp, sizeof(pval), (void **) &localdata); ! result->value.varptr.yystype = localdata; result->cs_data.array_write=1; if (!original_array_write) { /* we raised the write flag just now, record this variable */ variable_tracker vt; --- 1243,1249 ---- tmp.type = IS_NULL; _php3_hash_next_index_insert(arr_ptr->value.ht, (void *) &tmp, sizeof(pval), (void **) &localdata); ! result->value.varptr.pvalue = localdata; result->cs_data.array_write=1; if (!original_array_write) { /* we raised the write flag just now, record this variable */ variable_tracker vt; *************** *** 1255,1264 **** } } } else { ! result->value.varptr.yystype=NULL; } if (expr) { ! yystype_destructor(expr _INLINE_TLS); } } } --- 1255,1264 ---- } } } else { ! result->value.varptr.pvalue=NULL; } if (expr) { ! pval_destructor(expr _INLINE_TLS); } } } *************** *** 1267,1273 **** inline void end_array_parsing(pval *result, pval *dimensions INLINE_TLS) { if (GLOBAL(Execute)) { ! pval *ptr=(pval *) dimensions->value.varptr.yystype; *result = *dimensions; if (ptr && ptr->type==IS_NULL) { --- 1267,1273 ---- inline void end_array_parsing(pval *result, pval *dimensions INLINE_TLS) { if (GLOBAL(Execute)) { ! pval *ptr=(pval *) dimensions->value.varptr.pvalue; *result = *dimensions; if (ptr && ptr->type==IS_NULL) { *************** *** 1303,1319 **** inline void get_class_variable_pointer(pval *result, pval *class_ptr, pval *varname INLINE_TLS) { if (GLOBAL(Execute)) { ! pval *object = (pval *) class_ptr->value.varptr.yystype; if (!object) { ! result->value.varptr.yystype = NULL; ! yystype_destructor(varname _INLINE_TLS); return; } if ((varname->type != IS_STRING)) { php3_error(E_WARNING,"Illegal property name"); ! result->value.varptr.yystype = NULL; ! yystype_destructor(varname _INLINE_TLS); return; } else { pval *data; --- 1303,1319 ---- inline void get_class_variable_pointer(pval *result, pval *class_ptr, pval *varname INLINE_TLS) { if (GLOBAL(Execute)) { ! pval *object = (pval *) class_ptr->value.varptr.pvalue; if (!object) { ! result->value.varptr.pvalue = NULL; ! pval_destructor(varname _INLINE_TLS); return; } if ((varname->type != IS_STRING)) { php3_error(E_WARNING,"Illegal property name"); ! result->value.varptr.pvalue = NULL; ! pval_destructor(varname _INLINE_TLS); return; } else { pval *data; *************** *** 1334,1342 **** } else { result->cs_data.array_write = 0; } ! result->value.varptr.yystype = data; result->value.str.len = -1; /* Not indexed string */ ! yystype_destructor(varname _INLINE_TLS); } } } --- 1334,1342 ---- } else { result->cs_data.array_write = 0; } ! result->value.varptr.pvalue = data; result->value.str.len = -1; /* Not indexed string */ ! pval_destructor(varname _INLINE_TLS); } } } *************** *** 1361,1367 **** read_pointer_value(&tmp,var _INLINE_TLS); if (_php3_hash_next_index_insert(GLOBAL(function_state).function_symbol_table, &tmp, sizeof(pval),NULL) == FAILURE) { php3_error(E_WARNING, "Error updating symbol table"); ! yystype_destructor(&tmp _INLINE_TLS); GLOBAL(function_state).function_type = 0; /* don't execute the function call */ return; } --- 1361,1367 ---- read_pointer_value(&tmp,var _INLINE_TLS); if (_php3_hash_next_index_insert(GLOBAL(function_state).function_symbol_table, &tmp, sizeof(pval),NULL) == FAILURE) { php3_error(E_WARNING, "Error updating symbol table"); ! pval_destructor(&tmp _INLINE_TLS); GLOBAL(function_state).function_type = 0; /* don't execute the function call */ return; } *************** *** 1369,1379 **** if (var->cs_data.array_write) { clean_unassigned_variable_top(0 _INLINE_TLS); } ! if (var->value.varptr.yystype==NULL) { GLOBAL(function_state).function_type = 0; return; } ! if (_php3_hash_next_index_pointer_insert(GLOBAL(function_state).function_symbol_table, (void *) var->value.varptr.yystype) == FAILURE) { php3_error(E_WARNING, "Error updating symbol table"); GLOBAL(function_state).function_type = 0; /* don't execute the function call */ return; --- 1369,1379 ---- if (var->cs_data.array_write) { clean_unassigned_variable_top(0 _INLINE_TLS); } ! if (var->value.varptr.pvalue==NULL) { GLOBAL(function_state).function_type = 0; return; } ! if (_php3_hash_next_index_pointer_insert(GLOBAL(function_state).function_symbol_table, (void *) var->value.varptr.pvalue) == FAILURE) { php3_error(E_WARNING, "Error updating symbol table"); GLOBAL(function_state).function_type = 0; /* don't execute the function call */ return; *************** *** 1391,1397 **** if (php3_ini.safe_mode) { php3_error(E_WARNING,"Cannot execute using backqutoes in safe mode"); ! yystype_destructor(expr _INLINE_TLS); var_reset(result); return; } --- 1391,1397 ---- if (php3_ini.safe_mode) { php3_error(E_WARNING,"Cannot execute using backqutoes in safe mode"); ! pval_destructor(expr _INLINE_TLS); var_reset(result); return; } *************** *** 1468,1474 **** get_regular_variable_contents(&index,var_index,0 _INLINE_TLS); get_array_variable(&tmp,varname,&index _INLINE_TLS); concat_function(result,encaps,&tmp,1 _INLINE_TLS); ! yystype_destructor(&index _INLINE_TLS); } } --- 1468,1474 ---- get_regular_variable_contents(&index,var_index,0 _INLINE_TLS); get_array_variable(&tmp,varname,&index _INLINE_TLS); concat_function(result,encaps,&tmp,1 _INLINE_TLS); ! pval_destructor(&index _INLINE_TLS); } } Index: php3/internal_functions.c diff -c php3/internal_functions.c:1.325 php3/internal_functions.c:1.326 *** php3/internal_functions.c:1.325 Wed Sep 9 08:38:05 1998 --- php3/internal_functions.c Thu Sep 10 19:56:54 1998 *************** *** 29,35 **** */ ! /* $Id: internal_functions.c,v 1.325 1998/09/09 12:38:05 ssb Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: internal_functions.c,v 1.326 1998/09/10 23:56:54 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 212,218 **** inline PHPAPI int array_init(pval *arg) { arg->value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! if (!arg->value.ht || _php3_hash_init(arg->value.ht, 0, NULL, pval_DESTRUCTOR, 0)) { php3_error(E_CORE_ERROR, "Cannot allocate memory for array"); return FAILURE; } --- 212,218 ---- inline PHPAPI int array_init(pval *arg) { arg->value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! if (!arg->value.ht || _php3_hash_init(arg->value.ht, 0, NULL, PVAL_DESTRUCTOR, 0)) { php3_error(E_CORE_ERROR, "Cannot allocate memory for array"); return FAILURE; } *************** *** 223,229 **** inline PHPAPI int object_init(pval *arg) { arg->value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! if (!arg->value.ht || _php3_hash_init(arg->value.ht, 0, NULL, pval_DESTRUCTOR, 0)) { php3_error(E_CORE_ERROR, "Cannot allocate memory for array"); return FAILURE; } --- 223,229 ---- inline PHPAPI int object_init(pval *arg) { arg->value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! if (!arg->value.ht || _php3_hash_init(arg->value.ht, 0, NULL, PVAL_DESTRUCTOR, 0)) { php3_error(E_CORE_ERROR, "Cannot allocate memory for array"); return FAILURE; } Index: php3/language-parser.y diff -c php3/language-parser.y:1.172 php3/language-parser.y:1.173 *** php3/language-parser.y:1.172 Mon Sep 7 12:47:20 1998 --- php3/language-parser.y Thu Sep 10 19:56:54 1998 *************** *** 31,37 **** */ ! /* $Id: language-parser.y,v 1.172 1998/09/07 16:47:20 shane Exp $ */ /* --- 31,37 ---- */ ! /* $Id: language-parser.y,v 1.173 1998/09/10 23:56:54 zeev Exp $ */ /* *************** *** 281,287 **** | WHILE '(' expr ')' { cs_start_while(&$1, &$3 _INLINE_TLS); } while_statement { cs_end_while(&$1,&yychar _INLINE_TLS); } while_iterations | DO { cs_start_do_while(&$1 _INLINE_TLS); } statement WHILE { cs_force_eval_do_while( _INLINE_TLS_VOID); } '(' expr ')' ';'{ cs_end_do_while(&$1,&$7,&yychar _INLINE_TLS); } do_while_iterations | FOR { for_pre_expr1(&$1 _INLINE_TLS); } ! '(' for_expr { if (GLOBAL(Execute)) yystype_destructor(&$4 _INLINE_TLS); for_pre_expr2(&$1 _INLINE_TLS); } ';' for_expr { for_pre_expr3(&$1,&$7 _INLINE_TLS); } ';' for_expr { for_pre_statement(&$1,&$7,&$10 _INLINE_TLS); } ')' for_statement { for_post_statement(&$1,&$6,&$9,&$12,&yychar _INLINE_TLS); } for_iterations --- 281,287 ---- | WHILE '(' expr ')' { cs_start_while(&$1, &$3 _INLINE_TLS); } while_statement { cs_end_while(&$1,&yychar _INLINE_TLS); } while_iterations | DO { cs_start_do_while(&$1 _INLINE_TLS); } statement WHILE { cs_force_eval_do_while( _INLINE_TLS_VOID); } '(' expr ')' ';'{ cs_end_do_while(&$1,&$7,&yychar _INLINE_TLS); } do_while_iterations | FOR { for_pre_expr1(&$1 _INLINE_TLS); } ! '(' for_expr { if (GLOBAL(Execute)) pval_destructor(&$4 _INLINE_TLS); for_pre_expr2(&$1 _INLINE_TLS); } ';' for_expr { for_pre_expr3(&$1,&$7 _INLINE_TLS); } ';' for_expr { for_pre_statement(&$1,&$7,&$10 _INLINE_TLS); } ')' for_statement { for_post_statement(&$1,&$6,&$9,&$12,&yychar _INLINE_TLS); } for_iterations *************** *** 303,309 **** | CLASS STRING EXTENDS STRING { cs_start_class_decleration(&$2,&$4 _INLINE_TLS); } '{' class_statement_list '}' { cs_end_class_decleration( _INLINE_TLS_VOID); } | PHP_ECHO echo_expr_list ';' | INLINE_HTML { if (GLOBAL(Execute)) { if (php3_header()) PUTS($1.value.str.val); } } ! | expr ';' { if (GLOBAL(Execute)) yystype_destructor(&$1 _INLINE_TLS); } | REQUIRE { cs_start_include(&$1 _INLINE_TLS); } expr ';' { cs_end_include(&$1,&$3 _INLINE_TLS); } | HIGHLIGHT_FILE expr ';' { if (GLOBAL(Execute)) cs_show_source(&$2 _INLINE_TLS); } | HIGHLIGHT_STRING '(' expr ')' ';' { if (GLOBAL(Execute)) eval_string(&$3,NULL,1 _INLINE_TLS); } --- 303,309 ---- | CLASS STRING EXTENDS STRING { cs_start_class_decleration(&$2,&$4 _INLINE_TLS); } '{' class_statement_list '}' { cs_end_class_decleration( _INLINE_TLS_VOID); } | PHP_ECHO echo_expr_list ';' | INLINE_HTML { if (GLOBAL(Execute)) { if (php3_header()) PUTS($1.value.str.val); } } ! | expr ';' { if (GLOBAL(Execute)) pval_destructor(&$1 _INLINE_TLS); } | REQUIRE { cs_start_include(&$1 _INLINE_TLS); } expr ';' { cs_end_include(&$1,&$3 _INLINE_TLS); } | HIGHLIGHT_FILE expr ';' { if (GLOBAL(Execute)) cs_show_source(&$2 _INLINE_TLS); } | HIGHLIGHT_STRING '(' expr ')' ';' { if (GLOBAL(Execute)) eval_string(&$3,NULL,1 _INLINE_TLS); } *************** *** 346,352 **** for_iterations: /* empty */ | for_iterations CONTINUED_FOR { for_pre_expr1(&$2 _INLINE_TLS); } ! '(' for_expr { if (GLOBAL(Execute)) yystype_destructor(&$5 _INLINE_TLS); for_pre_expr2(&$2 _INLINE_TLS); } ';' for_expr { for_pre_expr3(&$2,&$8 _INLINE_TLS); } ';' for_expr { for_pre_statement(&$2,&$8,&$11 _INLINE_TLS); } ')' for_statement { for_post_statement(&$2,&$7,&$10,&$13,&yychar _INLINE_TLS); } --- 346,352 ---- for_iterations: /* empty */ | for_iterations CONTINUED_FOR { for_pre_expr1(&$2 _INLINE_TLS); } ! '(' for_expr { if (GLOBAL(Execute)) pval_destructor(&$5 _INLINE_TLS); for_pre_expr2(&$2 _INLINE_TLS); } ';' for_expr { for_pre_expr3(&$2,&$8 _INLINE_TLS); } ';' for_expr { for_pre_statement(&$2,&$8,&$11 _INLINE_TLS); } ')' for_statement { for_post_statement(&$2,&$7,&$10,&$13,&yychar _INLINE_TLS); } *************** *** 468,481 **** echo_expr_list: /* empty */ ! | echo_expr_list ',' expr { if (GLOBAL(Execute)) { print_variable(&$3 _INLINE_TLS); yystype_destructor(&$3 _INLINE_TLS); } } ! | expr { if (GLOBAL(Execute)) { print_variable(&$1 _INLINE_TLS); yystype_destructor(&$1 _INLINE_TLS); } } ; for_expr: /* empty */ { $$.value.lval=1; $$.type=IS_LONG; } /* ensure empty truth values are considered TRUE */ ! | for_expr ',' expr { if (GLOBAL(Execute)) { $$ = $3; yystype_destructor(&$1 _INLINE_TLS); } } | expr { if (GLOBAL(Execute)) $$ = $1; } ; --- 468,481 ---- echo_expr_list: /* empty */ ! | echo_expr_list ',' expr { if (GLOBAL(Execute)) { print_variable(&$3 _INLINE_TLS); pval_destructor(&$3 _INLINE_TLS); } } ! | expr { if (GLOBAL(Execute)) { print_variable(&$1 _INLINE_TLS); pval_destructor(&$1 _INLINE_TLS); } } ; for_expr: /* empty */ { $$.value.lval=1; $$.type=IS_LONG; } /* ensure empty truth values are considered TRUE */ ! | for_expr ',' expr { if (GLOBAL(Execute)) { $$ = $3; pval_destructor(&$1 _INLINE_TLS); } } | expr { if (GLOBAL(Execute)) $$ = $1; } ; *************** *** 538,544 **** possible_function_call { cs_functioncall_end(&$$,&$4,&$8,&yychar,1 _INLINE_TLS); } | NEW var { assign_new_object(&$$,&$2,1 _INLINE_TLS); } | NEW var { assign_new_object(&$$,&$2,0 _INLINE_TLS); } ! '(' { if (!GLOBAL(shutdown_requested)) { pval object_pointer; object_pointer.value.varptr.yystype = &$3; cs_functioncall_pre_variable_passing(&$2, &object_pointer, 1 _INLINE_TLS); } } function_call_parameter_list ')' { cs_functioncall_post_variable_passing(&$2, &yychar _INLINE_TLS); } possible_function_call { cs_functioncall_end(&$$, &$2, &$7, &yychar, 1 _INLINE_TLS); $$ = $3; } | INT_CAST expr { if (GLOBAL(Execute)) { convert_to_long(&$2); $$ = $2; } } --- 538,544 ---- possible_function_call { cs_functioncall_end(&$$,&$4,&$8,&yychar,1 _INLINE_TLS); } | NEW var { assign_new_object(&$$,&$2,1 _INLINE_TLS); } | NEW var { assign_new_object(&$$,&$2,0 _INLINE_TLS); } ! '(' { if (!GLOBAL(shutdown_requested)) { pval object_pointer; object_pointer.value.varptr.pvalue = &$3; cs_functioncall_pre_variable_passing(&$2, &object_pointer, 1 _INLINE_TLS); } } function_call_parameter_list ')' { cs_functioncall_post_variable_passing(&$2, &yychar _INLINE_TLS); } possible_function_call { cs_functioncall_end(&$$, &$2, &$7, &yychar, 1 _INLINE_TLS); $$ = $3; } | INT_CAST expr { if (GLOBAL(Execute)) { convert_to_long(&$2); $$ = $2; } } *************** *** 548,560 **** | OBJECT_CAST expr { if (GLOBAL(Execute)) { convert_to_object(&$2); $$ = $2; } } | EXIT { if (GLOBAL(Execute)) { php3_header(); GLOBAL(shutdown_requested)=ABNORMAL_SHUTDOWN; $$.type=IS_LONG; $$.value.lval=1; } } | EXIT '(' ')' { if (GLOBAL(Execute)) { php3_header(); GLOBAL(shutdown_requested)=ABNORMAL_SHUTDOWN; $$.type=IS_LONG; $$.value.lval=1; } } ! | EXIT '(' expr ')' { if (GLOBAL(Execute)) { if (php3_header()) { convert_to_string(&$3); PUTS($3.value.str.val); yystype_destructor(&$3 _INLINE_TLS); } GLOBAL(shutdown_requested)=ABNORMAL_SHUTDOWN; $$.type=IS_LONG; $$.value.lval=1; } } | '@' { $1.cs_data.error_reporting=GLOBAL(error_reporting); GLOBAL(error_reporting)=0; } expr { GLOBAL(error_reporting)=$1.cs_data.error_reporting; $$ = $3; } | '@' error { php3_error(E_ERROR,"@ operator may only be used on expressions"); } | scalar { if (GLOBAL(Execute)) $$ = $1; } | PHP_ARRAY '(' array_pair_list ')' { if (GLOBAL(Execute)) $$ = $3; } | '' encaps_list '' { cs_system(&$$,&$2 _INLINE_TLS); } ! | PHP_PRINT expr { if (GLOBAL(Execute)) { print_variable(&$2 _INLINE_TLS); yystype_destructor(&$2 _INLINE_TLS); $$.value.lval=1; $$.type=IS_LONG; } } ; scalar: --- 548,560 ---- | OBJECT_CAST expr { if (GLOBAL(Execute)) { convert_to_object(&$2); $$ = $2; } } | EXIT { if (GLOBAL(Execute)) { php3_header(); GLOBAL(shutdown_requested)=ABNORMAL_SHUTDOWN; $$.type=IS_LONG; $$.value.lval=1; } } | EXIT '(' ')' { if (GLOBAL(Execute)) { php3_header(); GLOBAL(shutdown_requested)=ABNORMAL_SHUTDOWN; $$.type=IS_LONG; $$.value.lval=1; } } ! | EXIT '(' expr ')' { if (GLOBAL(Execute)) { if (php3_header()) { convert_to_string(&$3); PUTS($3.value.str.val); pval_destructor(&$3 _INLINE_TLS); } GLOBAL(shutdown_requested)=ABNORMAL_SHUTDOWN; $$.type=IS_LONG; $$.value.lval=1; } } | '@' { $1.cs_data.error_reporting=GLOBAL(error_reporting); GLOBAL(error_reporting)=0; } expr { GLOBAL(error_reporting)=$1.cs_data.error_reporting; $$ = $3; } | '@' error { php3_error(E_ERROR,"@ operator may only be used on expressions"); } | scalar { if (GLOBAL(Execute)) $$ = $1; } | PHP_ARRAY '(' array_pair_list ')' { if (GLOBAL(Execute)) $$ = $3; } | '' encaps_list '' { cs_system(&$$,&$2 _INLINE_TLS); } ! | PHP_PRINT expr { if (GLOBAL(Execute)) { print_variable(&$2 _INLINE_TLS); pval_destructor(&$2 _INLINE_TLS); $$.value.lval=1; $$.type=IS_LONG; } } ; scalar: *************** *** 601,607 **** unambiguous_class_name: unambiguous_class_name PHP_CLASS_OPERATOR varname_scalar { get_object_symtable(&$$,&$1,&$3 _INLINE_TLS); } ! | multi_dimensional_array { if (GLOBAL(Execute)) { if ($1.value.varptr.yystype && ((pval *)$1.value.varptr.yystype)->type == IS_OBJECT) { $$=$1; } else { $$.value.varptr.yystype=NULL; } } } | varname_scalar { get_object_symtable(&$$,NULL,&$1 _INLINE_TLS); } ; --- 601,607 ---- unambiguous_class_name: unambiguous_class_name PHP_CLASS_OPERATOR varname_scalar { get_object_symtable(&$$,&$1,&$3 _INLINE_TLS); } ! | multi_dimensional_array { if (GLOBAL(Execute)) { if ($1.value.varptr.pvalue && ((pval *)$1.value.varptr.pvalue)->type == IS_OBJECT) { $$=$1; } else { $$.value.varptr.pvalue=NULL; } } } | varname_scalar { get_object_symtable(&$$,NULL,&$1 _INLINE_TLS); } ; *************** *** 625,631 **** | assignment_list ',' { if (GLOBAL(Execute)) { $$=$1; ! $2.value.varptr.yystype = NULL; /* $2 is just used as temporary space */ _php3_hash_next_index_insert($$.value.ht,&$2,sizeof(pval),NULL); } } --- 625,631 ---- | assignment_list ',' { if (GLOBAL(Execute)) { $$=$1; ! $2.value.varptr.pvalue = NULL; /* $2 is just used as temporary space */ _php3_hash_next_index_insert($$.value.ht,&$2,sizeof(pval),NULL); } } *************** *** 636,642 **** $$.value.ht = (HashTable *) emalloc(sizeof(HashTable)); _php3_hash_init($$.value.ht,0,NULL,NULL,0); $$.type = IS_ARRAY; ! tmp.value.varptr.yystype = NULL; _php3_hash_next_index_insert($$.value.ht,&tmp,sizeof(pval),NULL); } } --- 636,642 ---- $$.value.ht = (HashTable *) emalloc(sizeof(HashTable)); _php3_hash_init($$.value.ht,0,NULL,NULL,0); $$.type = IS_ARRAY; ! tmp.value.varptr.pvalue = NULL; _php3_hash_next_index_insert($$.value.ht,&tmp,sizeof(pval),NULL); } } *************** *** 671,677 **** array_pair_list: ! /* empty */ { if (GLOBAL(Execute)) { $$.value.ht = (HashTable *) emalloc(sizeof(HashTable)); _php3_hash_init($$.value.ht,0,NULL,pval_DESTRUCTOR,0); $$.type = IS_ARRAY; } } | non_empty_array_pair_list { $$ = $1; } ; --- 671,677 ---- array_pair_list: ! /* empty */ { if (GLOBAL(Execute)) { $$.value.ht = (HashTable *) emalloc(sizeof(HashTable)); _php3_hash_init($$.value.ht,0,NULL,PVAL_DESTRUCTOR,0); $$.type = IS_ARRAY; } } | non_empty_array_pair_list { $$ = $1; } ; *************** *** 762,768 **** tc_set_token(&token_cache_manager, func->offset, IC_FUNCTION); if (object) { ! class_ptr.value.varptr.yystype = object; cs_functioncall_pre_variable_passing(function_name, &class_ptr, 0 _INLINE_TLS); } else { cs_functioncall_pre_variable_passing(function_name,NULL, 0 _INLINE_TLS); --- 762,768 ---- tc_set_token(&token_cache_manager, func->offset, IC_FUNCTION); if (object) { ! class_ptr.value.varptr.pvalue = object; cs_functioncall_pre_variable_passing(function_name, &class_ptr, 0 _INLINE_TLS); } else { cs_functioncall_pre_variable_passing(function_name,NULL, 0 _INLINE_TLS); Index: php3/language-scanner.lex diff -c php3/language-scanner.lex:1.171 php3/language-scanner.lex:1.172 *** php3/language-scanner.lex:1.171 Sun Sep 6 16:19:03 1998 --- php3/language-scanner.lex Thu Sep 10 19:56:55 1998 *************** *** 227,233 **** if (!display_source) { tcm_new(&GLOBAL(token_cache_manager)); } else { ! if (display_source==2 && !yystype_true(return_offset)) { display_source=1; } if (display_source==1) { --- 227,233 ---- if (!display_source) { tcm_new(&GLOBAL(token_cache_manager)); } else { ! if (display_source==2 && !pval_is_true(return_offset)) { display_source=1; } if (display_source==1) { *************** *** 271,277 **** php3_error(E_WARNING,"Failed opening '%s' for inclusion", php3_strip_url_passwd(file->value.str.val)); stack_del_top(&GLOBAL(input_source_stack)); ! yystype_destructor(file _INLINE_TLS); return FAILURE; } yyin = tmp; --- 271,277 ---- php3_error(E_WARNING,"Failed opening '%s' for inclusion", php3_strip_url_passwd(file->value.str.val)); stack_del_top(&GLOBAL(input_source_stack)); ! pval_destructor(file _INLINE_TLS); return FAILURE; } yyin = tmp; Index: php3/main.c diff -c php3/main.c:1.466 php3/main.c:1.467 *** php3/main.c:1.466 Fri Sep 4 15:16:06 1998 --- php3/main.c Thu Sep 10 19:56:55 1998 *************** *** 29,35 **** +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 1.466 1998/09/04 19:16:06 shane Exp $ */ /* #define CRASH_DETECTION */ --- 29,35 ---- +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 1.467 1998/09/10 23:56:55 zeev Exp $ */ /* #define CRASH_DETECTION */ *************** *** 599,605 **** GLOBAL(initialized) |= INIT_REQUEST_INFO; /* prepare general symbol table hash */ ! if (_php3_hash_init(&GLOBAL(symbol_table), 50, NULL, pval_DESTRUCTOR, 0) == FAILURE) { php3_printf("Unable to initialize symbol table.\n"); return FAILURE; } --- 599,605 ---- GLOBAL(initialized) |= INIT_REQUEST_INFO; /* prepare general symbol table hash */ ! if (_php3_hash_init(&GLOBAL(symbol_table), 50, NULL, PVAL_DESTRUCTOR, 0) == FAILURE) { php3_printf("Unable to initialize symbol table.\n"); return FAILURE; } *************** *** 740,746 **** SHUTDOWN_DEBUG("Switch stack"); while (stack_top(&GLOBAL(switch_stack), (void **) &se) != FAILURE) { ! yystype_destructor(&se->expr _INLINE_TLS); stack_del_top(&GLOBAL(switch_stack)); } stack_destroy(&GLOBAL(switch_stack)); --- 740,746 ---- SHUTDOWN_DEBUG("Switch stack"); while (stack_top(&GLOBAL(switch_stack), (void **) &se) != FAILURE) { ! pval_destructor(&se->expr _INLINE_TLS); stack_del_top(&GLOBAL(switch_stack)); } stack_destroy(&GLOBAL(switch_stack)); *************** *** 1120,1126 **** #endif /* prepare function table hash */ ! if (_php3_hash_init(&GLOBAL(function_table), 100, NULL, pval_DESTRUCTOR, 1) == FAILURE) { php3_printf("Unable to initialize function table.\n"); return FAILURE; } --- 1120,1126 ---- #endif /* prepare function table hash */ ! if (_php3_hash_init(&GLOBAL(function_table), 100, NULL, PVAL_DESTRUCTOR, 1) == FAILURE) { php3_printf("Unable to initialize function table.\n"); return FAILURE; } *************** *** 1300,1306 **** /* insert special variables */ if (_php3_hash_find(&GLOBAL(symbol_table), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) & tmp_ptr) == SUCCESS) { tmp2 = *tmp_ptr; ! yystype_copy_constructor(&tmp2); _php3_hash_update(&GLOBAL(symbol_table), "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void *) & tmp2, sizeof(pval), NULL); } tmp.value.str.len = strlen(GLOBAL(php3_rqst)->uri); --- 1300,1306 ---- /* insert special variables */ if (_php3_hash_find(&GLOBAL(symbol_table), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) & tmp_ptr) == SUCCESS) { tmp2 = *tmp_ptr; ! pval_copy_constructor(&tmp2); _php3_hash_update(&GLOBAL(symbol_table), "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void *) & tmp2, sizeof(pval), NULL); } tmp.value.str.len = strlen(GLOBAL(php3_rqst)->uri); *************** *** 1400,1406 **** TLS_VARS; arr.value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! if (!arr.value.ht || _php3_hash_init(arr.value.ht, 0, NULL, pval_DESTRUCTOR, 0) == FAILURE) { php3_error(E_WARNING, "Unable to create argv array"); } else { arr.type = IS_ARRAY; --- 1400,1406 ---- TLS_VARS; arr.value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! if (!arr.value.ht || _php3_hash_init(arr.value.ht, 0, NULL, PVAL_DESTRUCTOR, 0) == FAILURE) { php3_error(E_WARNING, "Unable to create argv array"); } else { arr.type = IS_ARRAY; Index: php3/operators.c diff -c php3/operators.c:1.96 php3/operators.c:1.97 *** php3/operators.c:1.96 Thu Aug 13 16:22:53 1998 --- php3/operators.c Thu Sep 10 19:56:56 1998 *************** *** 29,35 **** */ ! /* $Id: operators.c,v 1.96 1998/08/13 20:22:53 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: operators.c,v 1.97 1998/09/10 23:56:56 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 107,119 **** case IS_ARRAY: case IS_OBJECT: tmp = (_php3_hash_num_elements(op->value.ht)?1:0); ! yystype_destructor(op _INLINE_TLS); op->value.lval = tmp; op->type = IS_LONG; break; default: php3_error(E_WARNING, "Cannot convert to ordinal value"); ! yystype_destructor(op _INLINE_TLS); op->value.lval = 0; op->type = IS_LONG; break; --- 107,119 ---- case IS_ARRAY: case IS_OBJECT: tmp = (_php3_hash_num_elements(op->value.ht)?1:0); ! pval_destructor(op _INLINE_TLS); op->value.lval = tmp; op->type = IS_LONG; break; default: php3_error(E_WARNING, "Cannot convert to ordinal value"); ! pval_destructor(op _INLINE_TLS); op->value.lval = 0; op->type = IS_LONG; break; *************** *** 146,158 **** case IS_ARRAY: case IS_OBJECT: tmp = (_php3_hash_num_elements(op->value.ht)?1:0); ! yystype_destructor(op _INLINE_TLS); op->value.dval = tmp; op->type = IS_DOUBLE; break; default: php3_error(E_WARNING, "Cannot convert to real value"); ! yystype_destructor(op _INLINE_TLS); op->value.dval = 0; op->type = IS_DOUBLE; break; --- 146,158 ---- case IS_ARRAY: case IS_OBJECT: tmp = (_php3_hash_num_elements(op->value.ht)?1:0); ! pval_destructor(op _INLINE_TLS); op->value.dval = tmp; op->type = IS_DOUBLE; break; default: php3_error(E_WARNING, "Cannot convert to real value"); ! pval_destructor(op _INLINE_TLS); op->value.dval = 0; op->type = IS_DOUBLE; break; *************** *** 188,199 **** case IS_ARRAY: case IS_OBJECT: tmp = (_php3_hash_num_elements(op->value.ht)?1:0); ! yystype_destructor(op _INLINE_TLS); op->value.lval = tmp; op->type = IS_LONG; break; default: ! yystype_destructor(op _INLINE_TLS); op->value.lval = 0; op->type = IS_LONG; break; --- 188,199 ---- case IS_ARRAY: case IS_OBJECT: tmp = (_php3_hash_num_elements(op->value.ht)?1:0); ! pval_destructor(op _INLINE_TLS); op->value.lval = tmp; op->type = IS_LONG; break; default: ! pval_destructor(op _INLINE_TLS); op->value.lval = 0; op->type = IS_LONG; break; *************** *** 232,250 **** break; } case IS_ARRAY: ! yystype_destructor(op _INLINE_TLS); op->value.str.val = estrndup("Array",sizeof("Array")-1); op->value.str.len = sizeof("Array")-1; op->type = IS_STRING; break; case IS_OBJECT: ! yystype_destructor(op _INLINE_TLS); op->value.str.val = estrndup("Object",sizeof("Object")-1); op->value.str.len = sizeof("Object")-1; op->type = IS_STRING; break; default: ! yystype_destructor(op _INLINE_TLS); var_reset(op); break; } --- 232,250 ---- break; } case IS_ARRAY: ! pval_destructor(op _INLINE_TLS); op->value.str.val = estrndup("Array",sizeof("Array")-1); op->value.str.len = sizeof("Array")-1; op->type = IS_STRING; break; case IS_OBJECT: ! pval_destructor(op _INLINE_TLS); op->value.str.val = estrndup("Object",sizeof("Object")-1); op->value.str.len = sizeof("Object")-1; op->type = IS_STRING; break; default: ! pval_destructor(op _INLINE_TLS); var_reset(op); break; } *************** *** 256,262 **** pval tmp = *op; op->value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! _php3_hash_init(op->value.ht, 0, NULL, pval_DESTRUCTOR, 0); switch (type) { case IS_ARRAY: _php3_hash_index_update(op->value.ht, 0, (void *) &tmp, sizeof(pval), NULL); --- 256,262 ---- pval tmp = *op; op->value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! _php3_hash_init(op->value.ht, 0, NULL, PVAL_DESTRUCTOR, 0); switch (type) { case IS_ARRAY: _php3_hash_index_update(op->value.ht, 0, (void *) &tmp, sizeof(pval), NULL); *************** *** 310,318 **** if (op1->type == IS_ARRAY && op2->type == IS_ARRAY) { pval tmp; ! _php3_hash_merge(op1->value.ht,op2->value.ht,(void (*)(void *pData)) yystype_copy_constructor, (void *) &tmp, sizeof(pval)); *result = *op1; ! yystype_destructor(op2 _INLINE_TLS); return SUCCESS; } if (php3_ini.warn_plus_overloading) { --- 310,318 ---- if (op1->type == IS_ARRAY && op2->type == IS_ARRAY) { pval tmp; ! _php3_hash_merge(op1->value.ht,op2->value.ht,(void (*)(void *pData)) pval_copy_constructor, (void *) &tmp, sizeof(pval)); *result = *op1; ! pval_destructor(op2 _INLINE_TLS); return SUCCESS; } if (php3_ini.warn_plus_overloading) { *************** *** 349,356 **** result->value.dval = op1->value.dval + op2->value.dval; return SUCCESS; } ! yystype_destructor(op1 _INLINE_TLS); ! yystype_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } --- 349,356 ---- result->value.dval = op1->value.dval + op2->value.dval; return SUCCESS; } ! pval_destructor(op1 _INLINE_TLS); ! pval_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } *************** *** 386,393 **** result->value.dval = op1->value.dval - op2->value.dval; return SUCCESS; } ! yystype_destructor(op1 _INLINE_TLS); ! yystype_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } --- 386,393 ---- result->value.dval = op1->value.dval - op2->value.dval; return SUCCESS; } ! pval_destructor(op1 _INLINE_TLS); ! pval_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } *************** *** 423,430 **** result->value.dval = op1->value.dval * op2->value.dval; return SUCCESS; } ! yystype_destructor(op1 _INLINE_TLS); ! yystype_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } --- 423,430 ---- result->value.dval = op1->value.dval * op2->value.dval; return SUCCESS; } ! pval_destructor(op1 _INLINE_TLS); ! pval_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } *************** *** 462,469 **** result->value.dval = op1->value.dval / op2->value.dval; return SUCCESS; } ! yystype_destructor(op1 _INLINE_TLS); ! yystype_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } --- 462,469 ---- result->value.dval = op1->value.dval / op2->value.dval; return SUCCESS; } ! pval_destructor(op1 _INLINE_TLS); ! pval_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } *************** *** 578,584 **** } return SUCCESS; } ! yystype_destructor(op1 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } --- 578,584 ---- } return SUCCESS; } ! pval_destructor(op1 _INLINE_TLS); var_reset(result); return FAILURE; /* unknown datatype */ } *************** *** 703,710 **** int add_char_to_string(pval *result, pval *op1, pval *op2 INLINE_TLS) { if (op1->type != IS_STRING) { ! yystype_destructor(op1 _INLINE_TLS); ! yystype_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; } --- 703,710 ---- int add_char_to_string(pval *result, pval *op1, pval *op2 INLINE_TLS) { if (op1->type != IS_STRING) { ! pval_destructor(op1 _INLINE_TLS); ! pval_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; } *************** *** 740,748 **** } return SUCCESS; } ! yystype_destructor(op1 _INLINE_TLS); if (free_op2) { ! yystype_destructor(op2 _INLINE_TLS); } var_reset(result); return FAILURE; /* unknown datatype */ --- 740,748 ---- } return SUCCESS; } ! pval_destructor(op1 _INLINE_TLS); if (free_op2) { ! pval_destructor(op2 _INLINE_TLS); } var_reset(result); return FAILURE; /* unknown datatype */ *************** *** 776,783 **** if ((op1->type & IS_HASH) && (op2->type & IS_HASH)) { php3_error(E_WARNING,"Cannot compare arrays or objects"); } ! yystype_destructor(op1 _INLINE_TLS); ! yystype_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; } --- 776,783 ---- if ((op1->type & IS_HASH) && (op2->type & IS_HASH)) { php3_error(E_WARNING,"Cannot compare arrays or objects"); } ! pval_destructor(op1 _INLINE_TLS); ! pval_destructor(op2 _INLINE_TLS); var_reset(result); return FAILURE; } *************** *** 1057,1063 **** return SUCCESS; } ! int yystype_true(pval *op) { convert_to_boolean_long(op); return (op->value.lval ? 1 : 0); --- 1057,1063 ---- return SUCCESS; } ! int pval_is_true(pval *op) { convert_to_boolean_long(op); return (op->value.lval ? 1 : 0); Index: php3/operators.h diff -c php3/operators.h:1.34 php3/operators.h:1.35 *** php3/operators.h:1.34 Fri Jul 3 02:21:26 1998 --- php3/operators.h Thu Sep 10 19:56:56 1998 *************** *** 30,36 **** */ ! /* $Id: operators.h,v 1.34 1998/07/03 06:21:26 zeev Exp $ */ #ifndef _OPERATORS_H --- 30,36 ---- */ ! /* $Id: operators.h,v 1.35 1998/09/10 23:56:56 zeev Exp $ */ #ifndef _OPERATORS_H *************** *** 80,86 **** extern int add_char_to_string(pval *result, pval *op1, pval *op2 INLINE_TLS); extern PHPAPI void convert_to_double(pval *op); ! extern int yystype_true(pval *op); extern int compare_function(pval *result, pval *op1, pval *op2 INLINE_TLS); extern void php3_str_tolower(char *str, unsigned int length); --- 80,86 ---- extern int add_char_to_string(pval *result, pval *op1, pval *op2 INLINE_TLS); extern PHPAPI void convert_to_double(pval *op); ! extern int pval_is_true(pval *op); extern int compare_function(pval *result, pval *op1, pval *op2 INLINE_TLS); extern void php3_str_tolower(char *str, unsigned int length); Index: php3/php.h diff -c php3/php.h:1.34 php3/php.h:1.35 *** php3/php.h:1.34 Thu Sep 10 18:55:07 1998 --- php3/php.h Thu Sep 10 19:56:56 1998 *************** *** 28,34 **** +----------------------------------------------------------------------+ */ ! /* $Id: php.h,v 1.34 1998/09/10 22:55:07 zeev Exp $ */ #ifndef _PHP_H #define _PHP_H --- 28,34 ---- +----------------------------------------------------------------------+ */ ! /* $Id: php.h,v 1.35 1998/09/10 23:56:56 zeev Exp $ */ #ifndef _PHP_H #define _PHP_H *************** *** 400,409 **** } func; struct { ! pval *yystype; /* used for implementation of multi-dimensional arrays */ int string_offset; } varptr; ! } yystype_value; struct _pval_struct { --- 400,409 ---- } func; struct { ! pval *pvalue; /* used for implementation of multi-dimensional arrays */ int string_offset; } varptr; ! } pvalue_value; struct _pval_struct { *************** *** 414,420 **** control_structure_data cs_data; unsigned int offset; ! yystype_value value; /* value */ }; typedef struct { --- 414,420 ---- control_structure_data cs_data; unsigned int offset; ! pvalue_value value; /* value */ }; typedef struct { Index: php3/token_cache.c diff -c php3/token_cache.c:1.88 php3/token_cache.c:1.89 *** php3/token_cache.c:1.88 Tue Sep 1 11:54:02 1998 --- php3/token_cache.c Thu Sep 10 19:56:57 1998 *************** *** 29,35 **** */ ! /* $Id: token_cache.c,v 1.88 1998/09/01 15:54:02 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: token_cache.c,v 1.89 1998/09/10 23:56:57 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 311,317 **** TLS_VARS; for (i = 0; i < tc->count; i++) { ! yystype_destructor(&tc->tokens[i].phplval _INLINE_TLS); } if (tc->tokens) { efree(tc->tokens); --- 311,317 ---- TLS_VARS; for (i = 0; i < tc->count; i++) { ! pval_destructor(&tc->tokens[i].phplval _INLINE_TLS); } if (tc->tokens) { efree(tc->tokens); Index: php3/variables.c diff -c php3/variables.c:1.153 php3/variables.c:1.154 *** php3/variables.c:1.153 Thu Sep 10 17:27:18 1998 --- php3/variables.c Thu Sep 10 19:56:57 1998 *************** *** 29,35 **** */ ! /* $Id: variables.c,v 1.153 1998/09/10 21:27:18 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: variables.c,v 1.154 1998/09/10 23:56:57 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 71,109 **** } ! inline void yystype_destructor(pval *yystype INLINE_TLS) { ! if (yystype->type == IS_STRING) { ! STR_FREE(yystype->value.str.val); ! } else if (yystype->type & (IS_ARRAY | IS_CLASS | IS_OBJECT)) { ! if (yystype->value.ht && (yystype->value.ht != &GLOBAL(symbol_table))) { ! _php3_hash_destroy(yystype->value.ht); ! efree(yystype->value.ht); } ! } else if (yystype->type==IS_USER_FUNCTION) { ! if (yystype->value.func.addr.statics) { ! _php3_hash_destroy(yystype->value.func.addr.statics); ! efree(yystype->value.func.addr.statics); } ! if (yystype->value.func.arg_types) { ! efree(yystype->value.func.arg_types); } } } ! void php3tls_yystype_destructor(pval *yystype) { TLS_VARS; ! yystype_destructor(yystype _INLINE_TLS); } ! /* returns 1 if the type of yystype is NOT IS_INTERNAL_FUNCTION */ ! inline int is_not_internal_function(pval *yystype) { ! if (yystype->type == IS_INTERNAL_FUNCTION) { return 0; } else { return 1; --- 71,109 ---- } ! inline void pval_destructor(pval *pvalue INLINE_TLS) { ! if (pvalue->type == IS_STRING) { ! STR_FREE(pvalue->value.str.val); ! } else if (pvalue->type & (IS_ARRAY | IS_CLASS | IS_OBJECT)) { ! if (pvalue->value.ht && (pvalue->value.ht != &GLOBAL(symbol_table))) { ! _php3_hash_destroy(pvalue->value.ht); ! efree(pvalue->value.ht); } ! } else if (pvalue->type==IS_USER_FUNCTION) { ! if (pvalue->value.func.addr.statics) { ! _php3_hash_destroy(pvalue->value.func.addr.statics); ! efree(pvalue->value.func.addr.statics); } ! if (pvalue->value.func.arg_types) { ! efree(pvalue->value.func.arg_types); } } } ! void php3tls_pval_destructor(pval *pvalue) { TLS_VARS; ! pval_destructor(pvalue _INLINE_TLS); } ! /* returns 1 if the type of pvalue is NOT IS_INTERNAL_FUNCTION */ ! inline int is_not_internal_function(pval *pvalue) { ! if (pvalue->type == IS_INTERNAL_FUNCTION) { return 0; } else { return 1; *************** *** 111,158 **** } ! PHPAPI int yystype_copy_constructor(pval *yystype) { TLS_VARS; ! if (yystype->type == IS_STRING && yystype->value.str.val) { ! if (yystype->value.str.len==0) { ! if (yystype->value.str.val==undefined_variable_string) { ! yystype->value.str.val = undefined_variable_string; } else { ! yystype->value.str.val = empty_string; } return SUCCESS; } ! yystype->value.str.val = (char *) estrndup(yystype->value.str.val, yystype->value.str.len); ! if (!yystype->value.str.val) { ! var_reset(yystype); return FAILURE; } ! } else if (yystype->type & (IS_ARRAY | IS_CLASS | IS_OBJECT)) { pval tmp; ! if (!yystype->value.ht || (yystype->value.ht == &GLOBAL(symbol_table))) { ! var_reset(yystype); return FAILURE; } ! _php3_hash_copy(&(yystype->value.ht), yystype->value.ht, (void (*)(void *pData)) yystype_copy_constructor, (void *) &tmp, sizeof(pval)); ! if (!yystype->value.ht) { ! var_reset(yystype); return FAILURE; } ! } else if (yystype->type & VALID_FUNCTION) { ! if (yystype->value.func.arg_types) { ! unsigned char *arg_types = yystype->value.func.arg_types; ! yystype->value.func.arg_types = emalloc(sizeof(unsigned char)*(arg_types[0]+1)); ! memcpy(yystype->value.func.arg_types, arg_types, sizeof(unsigned char)*(arg_types[0]+1)); } ! if (yystype->type == IS_USER_FUNCTION && yystype->value.func.addr.statics) { ! HashTable *statics = yystype->value.func.addr.statics; pval tmp; ! _php3_hash_copy(&yystype->value.func.addr.statics, statics, (void (*)(void *)) yystype_copy_constructor, &tmp, sizeof(pval)); } } --- 111,158 ---- } ! PHPAPI int pval_copy_constructor(pval *pvalue) { TLS_VARS; ! if (pvalue->type == IS_STRING && pvalue->value.str.val) { ! if (pvalue->value.str.len==0) { ! if (pvalue->value.str.val==undefined_variable_string) { ! pvalue->value.str.val = undefined_variable_string; } else { ! pvalue->value.str.val = empty_string; } return SUCCESS; } ! pvalue->value.str.val = (char *) estrndup(pvalue->value.str.val, pvalue->value.str.len); ! if (!pvalue->value.str.val) { ! var_reset(pvalue); return FAILURE; } ! } else if (pvalue->type & (IS_ARRAY | IS_CLASS | IS_OBJECT)) { pval tmp; ! if (!pvalue->value.ht || (pvalue->value.ht == &GLOBAL(symbol_table))) { ! var_reset(pvalue); return FAILURE; } ! _php3_hash_copy(&(pvalue->value.ht), pvalue->value.ht, (void (*)(void *pData)) pval_copy_constructor, (void *) &tmp, sizeof(pval)); ! if (!pvalue->value.ht) { ! var_reset(pvalue); return FAILURE; } ! } else if (pvalue->type & VALID_FUNCTION) { ! if (pvalue->value.func.arg_types) { ! unsigned char *arg_types = pvalue->value.func.arg_types; ! pvalue->value.func.arg_types = emalloc(sizeof(unsigned char)*(arg_types[0]+1)); ! memcpy(pvalue->value.func.arg_types, arg_types, sizeof(unsigned char)*(arg_types[0]+1)); } ! if (pvalue->type == IS_USER_FUNCTION && pvalue->value.func.addr.statics) { ! HashTable *statics = pvalue->value.func.addr.statics; pval tmp; ! _php3_hash_copy(&pvalue->value.func.addr.statics, statics, (void (*)(void *)) pval_copy_constructor, &tmp, sizeof(pval)); } } *************** *** 171,212 **** if (_php3_hash_index_find(list->value.ht, i, (void **)&varp) == FAILURE) { continue; } ! if (!varp->value.varptr.yystype) { continue; /* Bad variable name */ } if (varp->cs_data.array_write) { clean_unassigned_variable_top(0 _INLINE_TLS); } ! vardata = (pval *)varp->value.varptr.yystype; ! yystype_destructor(vardata _INLINE_TLS); if (expr->type != IS_ARRAY) { if (i != 0) { var_uninit(vardata); } else { *vardata = *expr; ! yystype_copy_constructor(vardata); } } else { if (_php3_hash_index_find(expr->value.ht, i, (void **)&exprdata) == FAILURE) { var_uninit(vardata); } else { *vardata = *exprdata; ! yystype_copy_constructor(vardata); } } } *result = *expr; ! yystype_destructor(list _INLINE_TLS); } } int assign_to_variable(pval *result, pval *var_ptr, pval *expr, int (*func) (pval *, pval *, pval * INLINE_TLS) INLINE_TLS) { ! pval *var = var_ptr->value.varptr.yystype; if (!var) { /* didn't parse the variable successfully */ ! yystype_destructor(expr _INLINE_TLS); var_uninit(result); if (var_ptr->cs_data.array_write) { /* I'm not sure it can happen - should check it -- Zeev */ clean_unassigned_variable_top(1 _INLINE_TLS); --- 171,212 ---- if (_php3_hash_index_find(list->value.ht, i, (void **)&varp) == FAILURE) { continue; } ! if (!varp->value.varptr.pvalue) { continue; /* Bad variable name */ } if (varp->cs_data.array_write) { clean_unassigned_variable_top(0 _INLINE_TLS); } ! vardata = (pval *)varp->value.varptr.pvalue; ! pval_destructor(vardata _INLINE_TLS); if (expr->type != IS_ARRAY) { if (i != 0) { var_uninit(vardata); } else { *vardata = *expr; ! pval_copy_constructor(vardata); } } else { if (_php3_hash_index_find(expr->value.ht, i, (void **)&exprdata) == FAILURE) { var_uninit(vardata); } else { *vardata = *exprdata; ! pval_copy_constructor(vardata); } } } *result = *expr; ! pval_destructor(list _INLINE_TLS); } } int assign_to_variable(pval *result, pval *var_ptr, pval *expr, int (*func) (pval *, pval *, pval * INLINE_TLS) INLINE_TLS) { ! pval *var = var_ptr->value.varptr.pvalue; if (!var) { /* didn't parse the variable successfully */ ! pval_destructor(expr _INLINE_TLS); var_uninit(result); if (var_ptr->cs_data.array_write) { /* I'm not sure it can happen - should check it -- Zeev */ clean_unassigned_variable_top(1 _INLINE_TLS); *************** *** 237,247 **** func(result, var, expr _INLINE_TLS); *((pval *)var) = *result; } else { ! yystype_destructor((pval *)var _INLINE_TLS); *((pval *)var) = *expr; *result = *expr; } ! return yystype_copy_constructor(result); } else { /* indexed string */ if (func) { php3_error(E_WARNING,"Only simple assignment supported with string indices"); --- 237,247 ---- func(result, var, expr _INLINE_TLS); *((pval *)var) = *result; } else { ! pval_destructor((pval *)var _INLINE_TLS); *((pval *)var) = *expr; *result = *expr; } ! return pval_copy_constructor(result); } else { /* indexed string */ if (func) { php3_error(E_WARNING,"Only simple assignment supported with string indices"); *************** *** 269,275 **** php3_error(E_WARNING, "Illegal variable name"); var_reset(result); if (free_varname) { ! yystype_destructor(varname _INLINE_TLS); } return FAILURE; } else { --- 269,275 ---- php3_error(E_WARNING, "Illegal variable name"); var_reset(result); if (free_varname) { ! pval_destructor(varname _INLINE_TLS); } return FAILURE; } else { *************** *** 285,291 **** if (free_varname) { STR_FREE(varname->value.str.val); } ! return yystype_copy_constructor(result); } } } --- 285,291 ---- if (free_varname) { STR_FREE(varname->value.str.val); } ! return pval_copy_constructor(result); } } } *************** *** 329,335 **** return; } else { *result = *data; ! if (yystype_copy_constructor(result) == FAILURE) { var_reset(result); return; } --- 329,335 ---- return; } else { *result = *data; ! if (pval_copy_constructor(result) == FAILURE) { var_reset(result); return; } *************** *** 341,347 **** return; } else { *result = *data; ! if (yystype_copy_constructor(result) == FAILURE) { var_reset(result); return; } --- 341,347 ---- return; } else { *result = *data; ! if (pval_copy_constructor(result) == FAILURE) { var_reset(result); return; } *************** *** 356,364 **** int incdec_variable(pval *result, pval *var_ptr, int (*func) (pval *), int post INLINE_TLS) { int ret=0; ! pval *var = var_ptr->value.varptr.yystype; ! if (!var_ptr->value.varptr.yystype) { /* didn't successfully parse the array */ var_reset(result); if (var_ptr->cs_data.array_write) { /* can probably not happen - should check -- Zeev */ clean_unassigned_variable_top(1 _INLINE_TLS); --- 356,364 ---- int incdec_variable(pval *result, pval *var_ptr, int (*func) (pval *), int post INLINE_TLS) { int ret=0; ! pval *var = var_ptr->value.varptr.pvalue; ! if (!var_ptr->value.varptr.pvalue) { /* didn't successfully parse the array */ var_reset(result); if (var_ptr->cs_data.array_write) { /* can probably not happen - should check -- Zeev */ clean_unassigned_variable_top(1 _INLINE_TLS); *************** *** 386,398 **** } if (post) { /* post increment, use the original value */ ! *result = *((pval *)var_ptr->value.varptr.yystype); ! ret=yystype_copy_constructor(result); } ! func(var_ptr->value.varptr.yystype); if (!post) { ! *result = *((pval *)var_ptr->value.varptr.yystype); ! ret=yystype_copy_constructor(result); } return ret; --- 386,398 ---- } if (post) { /* post increment, use the original value */ ! *result = *((pval *)var_ptr->value.varptr.pvalue); ! ret=pval_copy_constructor(result); } ! func(var_ptr->value.varptr.pvalue); if (!post) { ! *result = *((pval *)var_ptr->value.varptr.pvalue); ! ret=pval_copy_constructor(result); } return ret; *************** *** 417,429 **** { if (initialize) { result->value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! _php3_hash_init(result->value.ht, 0, NULL, pval_DESTRUCTOR, 0); result->type = IS_ARRAY; } if (index) { if (index->type == IS_STRING) { _php3_hash_update(result->value.ht, index->value.str.val, index->value.str.len+1, value, sizeof(pval),NULL); ! yystype_destructor(index _INLINE_TLS); return; } else if (index->type == IS_LONG || index->type == IS_DOUBLE) { if (index->type == IS_DOUBLE) { --- 417,429 ---- { if (initialize) { result->value.ht = (HashTable *) emalloc(sizeof(HashTable)); ! _php3_hash_init(result->value.ht, 0, NULL, PVAL_DESTRUCTOR, 0); result->type = IS_ARRAY; } if (index) { if (index->type == IS_STRING) { _php3_hash_update(result->value.ht, index->value.str.val, index->value.str.len+1, value, sizeof(pval),NULL); ! pval_destructor(index _INLINE_TLS); return; } else if (index->type == IS_LONG || index->type == IS_DOUBLE) { if (index->type == IS_DOUBLE) { *************** *** 431,438 **** } _php3_hash_index_update(result->value.ht, index->value.lval, value, sizeof(pval),NULL); } else { ! yystype_destructor(index _INLINE_TLS); ! yystype_destructor(value _INLINE_TLS); var_reset(result); } } else { --- 431,438 ---- } _php3_hash_index_update(result->value.ht, index->value.lval, value, sizeof(pval),NULL); } else { ! pval_destructor(index _INLINE_TLS); ! pval_destructor(value _INLINE_TLS); var_reset(result); } } else { *************** *** 456,463 **** if (!var_ptr || var_ptr->cs_data.array_write) { /* variable didn't exist before unset(), remove it completely */ clean_unassigned_variable_top(1 _INLINE_TLS); } else { ! var = var_ptr->value.varptr.yystype; ! yystype_destructor(var _INLINE_TLS); var->value.str.val = undefined_variable_string; var->value.str.len=0; var->type = IS_STRING; --- 456,463 ---- if (!var_ptr || var_ptr->cs_data.array_write) { /* variable didn't exist before unset(), remove it completely */ clean_unassigned_variable_top(1 _INLINE_TLS); } else { ! var = var_ptr->value.varptr.pvalue; ! pval_destructor(var _INLINE_TLS); var->value.str.val = undefined_variable_string; var->value.str.len=0; var->type = IS_STRING; *************** *** 476,482 **** pval *var; result->type = IS_LONG; ! if (!var_ptr || var_ptr->cs_data.array_write || !(var=var_ptr->value.varptr.yystype) || (var->type == IS_STRING && var->value.str.val==undefined_variable_string)) { result->value.lval=0; if (var_ptr && var_ptr->cs_data.array_write) { --- 476,482 ---- pval *var; result->type = IS_LONG; ! if (!var_ptr || var_ptr->cs_data.array_write || !(var=var_ptr->value.varptr.pvalue) || (var->type == IS_STRING && var->value.str.val==undefined_variable_string)) { result->value.lval=0; if (var_ptr && var_ptr->cs_data.array_write) { *************** *** 498,511 **** php3_isset(result,var_ptr); if (result->value.lval) { /* variable is set */ ! pval var = *((pval *) var_ptr->value.varptr.yystype); if ((var.type == IS_STRING) && (var.value.str.len == 1) && (var.value.str.val[0] == '0')) { /* don't consider "0" as empty */ result->value.lval=0; } else { ! yystype_copy_constructor(&var); ! if (yystype_true(&var)) { result->value.lval=0; } } --- 498,511 ---- php3_isset(result,var_ptr); if (result->value.lval) { /* variable is set */ ! pval var = *((pval *) var_ptr->value.varptr.pvalue); if ((var.type == IS_STRING) && (var.value.str.len == 1) && (var.value.str.val[0] == '0')) { /* don't consider "0" as empty */ result->value.lval=0; } else { ! pval_copy_constructor(&var); ! if (pval_is_true(&var)) { result->value.lval=0; } } *************** *** 535,551 **** void get_object_property(pval *result, pval *class_ptr, pval *varname INLINE_TLS) { ! pval *data,*object=(pval *) class_ptr->value.varptr.yystype; var_reset(result); if (!object) { ! yystype_destructor(varname _INLINE_TLS); return; } if (varname->type != IS_STRING) { php3_error(E_WARNING, "Cannot use a numeric value as a variable name"); ! yystype_destructor(varname _INLINE_TLS); return; } if (_php3_hash_find(object->value.ht, varname->value.str.val, varname->value.str.len+1, (void **) &data) == FAILURE) { --- 535,551 ---- void get_object_property(pval *result, pval *class_ptr, pval *varname INLINE_TLS) { ! pval *data,*object=(pval *) class_ptr->value.varptr.pvalue; var_reset(result); if (!object) { ! pval_destructor(varname _INLINE_TLS); return; } if (varname->type != IS_STRING) { php3_error(E_WARNING, "Cannot use a numeric value as a variable name"); ! pval_destructor(varname _INLINE_TLS); return; } if (_php3_hash_find(object->value.ht, varname->value.str.val, varname->value.str.len+1, (void **) &data) == FAILURE) { *************** *** 555,567 **** return; } else { *result = *data; ! yystype_copy_constructor(result); STR_FREE(varname->value.str.val); } } ! /* Use varptr.yystype to maintain a pointer to the right symbol table. * At the end of the parsing, we should be pointing to the right symbol table. * 'parent' doesn't have to be cleaned since its just a pointer and doesn't * contain any actual data. --- 555,567 ---- return; } else { *result = *data; ! pval_copy_constructor(result); STR_FREE(varname->value.str.val); } } ! /* Use varptr.pvalue to maintain a pointer to the right symbol table. * At the end of the parsing, we should be pointing to the right symbol table. * 'parent' doesn't have to be cleaned since its just a pointer and doesn't * contain any actual data. *************** *** 573,582 **** pval *data; if (parent) { ! pval *object=(pval *) parent->value.varptr.yystype; if (!object) { ! result->value.varptr.yystype=NULL; return; } target_symbol_table = object->value.ht; --- 573,582 ---- pval *data; if (parent) { ! pval *object=(pval *) parent->value.varptr.pvalue; if (!object) { ! result->value.varptr.pvalue=NULL; return; } target_symbol_table = object->value.ht; *************** *** 590,604 **** if (_php3_hash_find(target_symbol_table, child->value.str.val, child->value.str.len+1, (void **) &data) == FAILURE) { php3_error(E_WARNING, "Object %s not found", child->value.str.val); ! result->value.varptr.yystype=NULL; return; } if (data->type != IS_OBJECT) { php3_error(E_WARNING, "$%s is not an object", child->value.str.val); ! result->value.varptr.yystype=NULL; return; } ! result->value.varptr.yystype = data; /* not running copy constructor intentionally */ } } --- 590,604 ---- if (_php3_hash_find(target_symbol_table, child->value.str.val, child->value.str.len+1, (void **) &data) == FAILURE) { php3_error(E_WARNING, "Object %s not found", child->value.str.val); ! result->value.varptr.pvalue=NULL; return; } if (data->type != IS_OBJECT) { php3_error(E_WARNING, "$%s is not an object", child->value.str.val); ! result->value.varptr.pvalue=NULL; return; } ! result->value.varptr.pvalue = data; /* not running copy constructor intentionally */ } } *************** *** 616,628 **** } *result = *data; result->type = IS_OBJECT; ! yystype_copy_constructor(result); if (implicit_ctor) { if (call_user_function(NULL, result, classname, &ctor_retval, 0, NULL)==SUCCESS) { ! yystype_destructor(&ctor_retval); } ! yystype_destructor(classname); } } } --- 616,628 ---- } *result = *data; result->type = IS_OBJECT; ! pval_copy_constructor(result); if (implicit_ctor) { if (call_user_function(NULL, result, classname, &ctor_retval, 0, NULL)==SUCCESS) { ! pval_destructor(&ctor_retval); } ! pval_destructor(classname); } } } *************** *** 630,636 **** void read_pointer_value(pval *result,pval *var_ptr INLINE_TLS) { ! pval *var=var_ptr->value.varptr.yystype; if (var) { if (var_ptr->cs_data.array_write || (var->type==IS_STRING && var->value.str.val==undefined_variable_string)) { --- 630,636 ---- void read_pointer_value(pval *result,pval *var_ptr INLINE_TLS) { ! pval *var=var_ptr->value.varptr.pvalue; if (var) { if (var_ptr->cs_data.array_write || (var->type==IS_STRING && var->value.str.val==undefined_variable_string)) { *************** *** 655,661 **** } else { if (var_ptr->value.str.len == -1) { /* not indexed string */ *result = *((pval *)var); ! yystype_copy_constructor(result); } else { /* indexed string */ result->value.str.val = (char *) emalloc(2); result->value.str.val[0]=var->value.str.val[var_ptr->value.str.len]; --- 655,661 ---- } else { if (var_ptr->value.str.len == -1) { /* not indexed string */ *result = *((pval *)var); ! pval_copy_constructor(result); } else { /* indexed string */ result->value.str.val = (char *) emalloc(2); result->value.str.val[0]=var->value.str.val[var_ptr->value.str.len]; *************** *** 675,681 **** if (GLOBAL(Execute)) { if ((varname->type != IS_STRING)) { php3_error(E_WARNING,"Illegal variable name"); ! result->value.varptr.yystype = NULL; return; } else { pval *data; --- 675,681 ---- if (GLOBAL(Execute)) { if ((varname->type != IS_STRING)) { php3_error(E_WARNING,"Illegal variable name"); ! result->value.varptr.pvalue = NULL; return; } else { pval *data; *************** *** 696,705 **** } else { result->cs_data.array_write = 0; } ! result->value.varptr.yystype = data; result->value.str.len = -1; /* Not indexed string */ } ! yystype_destructor(varname _INLINE_TLS); } } --- 696,705 ---- } else { result->cs_data.array_write = 0; } ! result->value.varptr.pvalue = data; result->value.str.len = -1; /* Not indexed string */ } ! pval_destructor(varname _INLINE_TLS); } } Index: php3/variables.h diff -c php3/variables.h:1.49 php3/variables.h:1.50 *** php3/variables.h:1.49 Thu Sep 10 16:40:16 1998 --- php3/variables.h Thu Sep 10 19:56:57 1998 *************** *** 29,35 **** */ ! /* $Id: variables.h,v 1.49 1998/09/10 20:40:16 zeev Exp $ */ #ifndef _VARIABLES_H --- 29,35 ---- */ ! /* $Id: variables.h,v 1.50 1998/09/10 23:56:57 zeev Exp $ */ #ifndef _VARIABLES_H *************** *** 45,51 **** extern int incdec_variable(pval *result, pval *varname, int (*func) (pval *), int post INLINE_TLS); /*not used ?? extern void incdec_class_variable(pval *result, pval *classname, pval *varname, int (*func) (pval *), int post);*/ extern void print_variable(pval *var INLINE_TLS); ! extern int is_not_internal_function(pval *yystype); extern void array_assign_next(pval *result, pval *varname, pval *expr); extern void add_array_pair_list(pval *result, pval *idx, pval *value, int initialize INLINE_TLS); extern void declare_class_variable(pval *varname, pval *expr INLINE_TLS); --- 45,51 ---- extern int incdec_variable(pval *result, pval *varname, int (*func) (pval *), int post INLINE_TLS); /*not used ?? extern void incdec_class_variable(pval *result, pval *classname, pval *varname, int (*func) (pval *), int post);*/ extern void print_variable(pval *var INLINE_TLS); ! extern int is_not_internal_function(pval *pvalue); extern void array_assign_next(pval *result, pval *varname, pval *expr); extern void add_array_pair_list(pval *result, pval *idx, pval *value, int initialize INLINE_TLS); extern void declare_class_variable(pval *varname, pval *expr INLINE_TLS); *************** *** 53,63 **** extern void get_object_symtable(pval *result, pval *parent, pval *child INLINE_TLS); extern void assign_new_object(pval *result, pval *classname, unsigned char implicit_ctor INLINE_TLS); ! extern PHPAPI void php3tls_yystype_destructor(pval *yystype); ! extern void yystype_destructor(pval *yystype INLINE_TLS); ! extern PHPAPI int yystype_copy_constructor(pval *yystype); ! #define pval_DESTRUCTOR (void (*)(void *)) yystype_destructor ! #define pval_COPY_CTOR (void (*)(void *)) yystype_copy_constructor /* Internal functions which have a YACC rule */ extern void php3_unset(pval *result, pval *var_ptr); --- 53,63 ---- extern void get_object_symtable(pval *result, pval *parent, pval *child INLINE_TLS); extern void assign_new_object(pval *result, pval *classname, unsigned char implicit_ctor INLINE_TLS); ! extern PHPAPI void php3tls_pval_destructor(pval *pvalue); ! extern void pval_destructor(pval *pvalue INLINE_TLS); ! extern PHPAPI int pval_copy_constructor(pval *pvalue); ! #define PVAL_DESTRUCTOR (void (*)(void *)) pval_destructor ! #define PVAL_COPY_CTOR (void (*)(void *)) pval_copy_constructor /* Internal functions which have a YACC rule */ extern void php3_unset(pval *result, pval *var_ptr); -- 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 (#948) next »