CVS update: php31/main

From: Date: Thu, 13 Aug 1998 22:49:01 +0000
Subject: CVS update: php31/main
Groups: php.dev 
Request: Send a blank email to php-dev+get-186@lists.php.net to get a copy of this message
Date: Thursday August 13, 1998 @ 18:49 Author: shane Update of /repository/php31/main In directory asf:/tmp/cvs-serv8477/main Modified Files: control_structures_inline.h internal_functions.h language-parser.y language-scanner.l main.c main.h php.h php3_ini.h token_cache.c token_cache.h variables.c variables.h Log Message: 3.0-3.1 patch porting caught up in files listed except perhapes main.c/h and php.h Index: php31/main/control_structures_inline.h diff -c php31/main/control_structures_inline.h:2.2 php31/main/control_structures_inline.h:2.3 *** php31/main/control_structures_inline.h:2.2 Sat Jul 11 15:46:16 1998 --- php31/main/control_structures_inline.h Thu Aug 13 18:48:58 1998 *************** *** 29,35 **** */ ! /* $Id: control_structures_inline.h,v 2.2 1998/07/11 19:46:16 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: control_structures_inline.h,v 2.3 1998/08/13 22:48:58 shane Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 80,88 **** extern inline void cs_questionmark_op_pre_expr1(pval *truth_value INLINE_TLS); extern inline void cs_questionmark_op_pre_expr2(pval *truth_value INLINE_TLS); extern inline void cs_questionmark_op_post_expr2(pval *result, pval *truth_value, pval *expr1, pval *expr2 INLINE_TLS); ! extern inline void cs_functioncall_pre_variable_passing(pval *function_name, pval *class_ptr INLINE_TLS); extern inline void cs_functioncall_post_variable_passing(pval *function_name, int *yychar INLINE_TLS); ! extern inline void cs_functioncall_end(pval *result, pval *function_name, pval *close_parentheses, int *yychar INLINE_TLS); extern inline void cs_switch_start(pval *switch_token, pval *expr INLINE_TLS); extern inline void cs_switch_case_pre(pval *case_expr INLINE_TLS); extern inline void cs_switch_case_post( INLINE_TLS_VOID); --- 80,88 ---- extern inline void cs_questionmark_op_pre_expr1(pval *truth_value INLINE_TLS); extern inline void cs_questionmark_op_pre_expr2(pval *truth_value INLINE_TLS); extern inline void cs_questionmark_op_post_expr2(pval *result, pval *truth_value, pval *expr1, pval *expr2 INLINE_TLS); ! extern inline void cs_functioncall_pre_variable_passing(pval *function_name, pval *class_ptr, unsigned char free_function_name INLINE_TLS); extern inline void cs_functioncall_post_variable_passing(pval *function_name, int *yychar INLINE_TLS); ! extern inline void cs_functioncall_end(pval *result, pval *function_name, pval *close_parentheses, int *yychar, unsigned char free_function_name INLINE_TLS); extern inline void cs_switch_start(pval *switch_token, pval *expr INLINE_TLS); extern inline void cs_switch_case_pre(pval *case_expr INLINE_TLS); extern inline void cs_switch_case_post( INLINE_TLS_VOID); *************** *** 493,499 **** } ! inline void start_function_decleration( INLINE_TLS_VOID) { stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); GLOBAL(ExecuteFlag) = DONT_EXECUTE; --- 493,499 ---- } ! inline void start_function_decleration(INLINE_TLS_VOID) { stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); GLOBAL(ExecuteFlag) = DONT_EXECUTE; *************** *** 653,658 **** --- 653,659 ---- inline void cs_return(pval *expr INLINE_TLS) { if (GLOBAL(Execute)) { + if (GLOBAL(function_state).function_name) { if (expr) { GLOBAL(return_value) = *expr; } else { *************** *** 661,666 **** --- 662,680 ---- GLOBAL(function_state).returned = 1; GLOBAL(ExecuteFlag) = DONT_EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; + } else { + int retval; + + if (end_current_file_execution(&retval _INLINE_TLS) && retval==0) { + /* the scanner return 0, terminate execution completely (behave like exit()) */ + php3_header(); + GLOBAL(shutdown_requested) = ABNORMAL_SHUTDOWN; + } + if (expr) { + print_variable(expr _INLINE_TLS); + yystype_destructor(expr _INLINE_TLS); + } + } } } *************** *** 801,807 **** } ! inline void cs_functioncall_pre_variable_passing(pval *function_name, pval *class_ptr INLINE_TLS) { int minus_one = -1; HashTable *target_symbol_table; /* the symbol table in which the function would be searched */ --- 815,821 ---- } ! inline void cs_functioncall_pre_variable_passing(pval *function_name, pval *class_ptr, unsigned char free_function_name INLINE_TLS) { int minus_one = -1; HashTable *target_symbol_table; /* the symbol table in which the function would be searched */ *************** *** 811,821 **** if (GLOBAL(Execute)) { pval *data; ! if (class_ptr) { /* use member function rather than global function */ object = (pval *) class_ptr->value.varptr.yystype; if (!object) { ! yystype_destructor(function_name _INLINE_TLS); php3_error(E_ERROR, "Member function used on a non-object"); return; } --- 825,837 ---- if (GLOBAL(Execute)) { 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; } *************** *** 823,829 **** } if (function_name->type != IS_STRING) { php3_error(E_ERROR, "Function names must be strings"); ! yystype_destructor(function_name _INLINE_TLS); return; } php3_str_tolower(function_name->value.str.val, function_name->value.str.len); --- 839,847 ---- } 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; } php3_str_tolower(function_name->value.str.val, function_name->value.str.len); *************** *** 862,868 **** _php3_hash_pointer_update(GLOBAL(function_state).function_symbol_table, "GLOBALS", sizeof("GLOBALS"), (void *) &GLOBAL(globals)); } if (object) { /* push $this */ ! _php3_hash_pointer_update(GLOBAL(function_state).function_symbol_table, "this", sizeof("this"), (void *) object); } } else { php3_error(E_ERROR, "Call to unsupported or undefined function %s()", function_name->value.str.val); --- 880,890 ---- _php3_hash_pointer_update(GLOBAL(function_state).function_symbol_table, "GLOBALS", sizeof("GLOBALS"), (void *) &GLOBAL(globals)); } if (object) { /* push $this */ ! GLOBAL(function_state).object_pointer = (pval *) emalloc(sizeof(pval)); ! *(GLOBAL(function_state).object_pointer) = *object; ! _php3_hash_pointer_update(GLOBAL(function_state).function_symbol_table, "this", sizeof("this"), (void *) GLOBAL(function_state).object_pointer); ! } else { ! GLOBAL(function_state).object_pointer = NULL; } } else { php3_error(E_ERROR, "Call to unsupported or undefined function %s()", function_name->value.str.val); *************** *** 901,907 **** } ! inline void cs_functioncall_end(pval *result, pval *function_name, pval *close_parentheses, int *yychar INLINE_TLS) { if (function_name->cs_data.function_call_type) { FunctionState *fs_ptr; --- 923,929 ---- } ! inline void cs_functioncall_end(pval *result, pval *function_name, pval *close_parentheses, int *yychar, unsigned char free_function_name INLINE_TLS) { if (function_name->cs_data.function_call_type) { FunctionState *fs_ptr; *************** *** 913,941 **** } /* clean up */ ! _php3_hash_destroy(GLOBAL(function_state).symbol_table); ! efree(GLOBAL(function_state).symbol_table); ! yystype_destructor(function_name _INLINE_TLS); while (stack_int_top(&GLOBAL(for_stack)) != -1) { /* pop FOR stack */ stack_del_top(&GLOBAL(for_stack)); } stack_del_top(&GLOBAL(for_stack)); - /* jump back */ if (GLOBAL(function_state).function_type == IS_USER_FUNCTION) { seek_token(&GLOBAL(token_cache_manager), close_parentheses->offset + 1, yychar); } - /* get previous function state */ stack_top(&GLOBAL(function_state_stack), (void **) &fs_ptr); GLOBAL(function_state) = *fs_ptr; stack_del_top(&GLOBAL(function_state_stack)); GLOBAL(active_symbol_table) = GLOBAL(function_state).symbol_table; - /* restore execution state */ GLOBAL(ExecuteFlag) = stack_int_top(&GLOBAL(css)); stack_del_top(&GLOBAL(css)); --- 935,967 ---- } /* clean up */ ! if (GLOBAL(function_state).symbol_table) { ! _php3_hash_destroy(GLOBAL(function_state).symbol_table); ! efree(GLOBAL(function_state).symbol_table); ! } ! if (GLOBAL(function_state).object_pointer) { ! 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 */ stack_del_top(&GLOBAL(for_stack)); } stack_del_top(&GLOBAL(for_stack)); /* jump back */ if (GLOBAL(function_state).function_type == IS_USER_FUNCTION) { seek_token(&GLOBAL(token_cache_manager), close_parentheses->offset + 1, yychar); } /* get previous function state */ stack_top(&GLOBAL(function_state_stack), (void **) &fs_ptr); GLOBAL(function_state) = *fs_ptr; stack_del_top(&GLOBAL(function_state_stack)); GLOBAL(active_symbol_table) = GLOBAL(function_state).symbol_table; /* restore execution state */ GLOBAL(ExecuteFlag) = stack_int_top(&GLOBAL(css)); stack_del_top(&GLOBAL(css)); *************** *** 1028,1034 **** if (_php3_hash_exists(&GLOBAL(function_table), classname->value.str.val, classname->value.str.len+1)) { php3_error(E_ERROR,"%s is already a function or class",classname->value.str.val); } ! if (parent) { if (_php3_hash_find(&GLOBAL(function_table), parent->value.str.val, parent->value.str.len+1, (void **) &parent_ptr) == FAILURE) { php3_error(E_ERROR, "Cannot extend non existant class %s", parent->value.str.val); return; --- 1054,1060 ---- if (_php3_hash_exists(&GLOBAL(function_table), classname->value.str.val, classname->value.str.len+1)) { php3_error(E_ERROR,"%s is already a function or class",classname->value.str.val); } ! if (parent) {/* inheritance */ if (_php3_hash_find(&GLOBAL(function_table), parent->value.str.val, parent->value.str.len+1, (void **) &parent_ptr) == FAILURE) { php3_error(E_ERROR, "Cannot extend non existant class %s", parent->value.str.val); return; Index: php31/main/internal_functions.h diff -c php31/main/internal_functions.h:2.0 php31/main/internal_functions.h:2.1 *** php31/main/internal_functions.h:2.0 Fri Jul 3 09:17:18 1998 --- php31/main/internal_functions.h Thu Aug 13 18:48:59 1998 *************** *** 29,35 **** */ ! /* $Id: internal_functions.h,v 2.0 1998/07/03 13:17:18 rasmus Exp $ */ #ifndef _INTERNAL_FUNCTIONS_H --- 29,35 ---- */ ! /* $Id: internal_functions.h,v 2.1 1998/08/13 22:48:59 shane Exp $ */ #ifndef _INTERNAL_FUNCTIONS_H *************** *** 43,49 **** extern unsigned char second_arg_force_ref[]; extern unsigned char second_arg_allow_ref[]; ! extern int _php3_next_free_module(); extern PHPAPI int getParameters(HashTable *ht, int param_count,...); extern PHPAPI int getParametersArray(HashTable *ht, int param_count, pval **argument_array); --- 43,49 ---- extern unsigned char second_arg_force_ref[]; extern unsigned char second_arg_allow_ref[]; ! extern int _php3_next_free_module(void); extern PHPAPI int getParameters(HashTable *ht, int param_count,...); extern PHPAPI int getParametersArray(HashTable *ht, int param_count, pval **argument_array); *************** *** 89,94 **** --- 89,96 ---- extern inline PHPAPI int add_get_index_double(pval *arg, uint idx, double d, void **dest); extern inline PHPAPI int add_get_index_string(pval *arg, uint idx, char *str, void **dest, int duplicate); extern inline PHPAPI int add_get_index_stringl(pval *arg, uint idx, char *str, uint length, void **dest, int duplicate); + + extern PHPAPI int call_user_function(HashTable *function_table, pval *object, pval *function_name, pval *retval, int param_count, pval *params[]); #define add_property_long(arg,key,n) add_assoc_long((arg),(key),(n)) #define add_property_double(arg,key,d) add_assoc_double((arg),(key),(n)) Index: php31/main/language-parser.y diff -c php31/main/language-parser.y:2.1 php31/main/language-parser.y:2.2 *** php31/main/language-parser.y:2.1 Fri Jul 3 12:00:39 1998 --- php31/main/language-parser.y Thu Aug 13 18:48:59 1998 *************** *** 31,37 **** */ ! /* $Id: language-parser.y,v 2.1 1998/07/03 16:00:39 shane Exp $ */ /* --- 31,37 ---- */ ! /* $Id: language-parser.y,v 2.2 1998/08/13 22:48:59 shane Exp $ */ /* *************** *** 55,63 **** #endif #include "php.h" #include "php3_list.h" - #include "php3_hash.h" #include "control_structures.h" ! #include "control_structures_inline.h" #include "main.h" #include "head.h" --- 55,62 ---- #endif #include "php.h" #include "php3_list.h" #include "control_structures.h" ! #include "main.h" #include "head.h" *************** *** 132,137 **** --- 131,139 ---- extern int shutdown_requested; #endif /* THREAD SAFE*/ + #include "control_structures_inline.h" + + int init_resource_list(void) { TLS_VARS; *************** *** 235,243 **** %token CONTINUED_WHILE %token CONTINUED_DOWHILE %token CONTINUED_FOR - %token OLD_FUNCTION %token FUNCTION %token PHP_CONST %token RETURN %token INCLUDE --- 237,245 ---- %token CONTINUED_WHILE %token CONTINUED_DOWHILE %token CONTINUED_FOR %token OLD_FUNCTION %token FUNCTION + %token IC_FUNCTION %token PHP_CONST %token RETURN %token INCLUDE *************** *** 290,295 **** --- 292,298 ---- parameter_list '(' statement_list ')' ';' { end_function_decleration(&$1,&$2 _INLINE_TLS); } | FUNCTION STRING '(' { start_function_decleration(_INLINE_TLS_VOID); } parameter_list ')' '{' statement_list '}' { end_function_decleration(&$1,&$2 _INLINE_TLS); } + | IC_FUNCTION STRING { tc_set_token(&GLOBAL(token_cache_manager), $1.offset, FUNCTION); } '(' parameter_list ')' '{' statement_list '}' { if (!GLOBAL(shutdown_requested)) GLOBAL(shutdown_requested) = TERMINATE_CURRENT_PHPPARSE; } | RETURN ';' { cs_return(NULL _INLINE_TLS); } | RETURN expr ';' { cs_return(&$2 _INLINE_TLS); } | PHP_GLOBAL global_var_list *************** *** 524,537 **** | expr '?' { cs_questionmark_op_pre_expr1(&$1 _INLINE_TLS); } expr ':' { cs_questionmark_op_pre_expr2(&$1 _INLINE_TLS); } expr { cs_questionmark_op_post_expr2(&$$,&$1,&$4,&$7 _INLINE_TLS); } ! | var { cs_functioncall_pre_variable_passing(&$1,NULL _INLINE_TLS); } '(' function_call_parameter_list ')' { cs_functioncall_post_variable_passing(&$1,&yychar _INLINE_TLS); } ! possible_function_call { cs_functioncall_end(&$$,&$1,&$5,&yychar _INLINE_TLS);} | internal_functions_in_yacc ! | '$' unambiguous_class_name PHP_CLASS_OPERATOR var { cs_functioncall_pre_variable_passing(&$4,&$2 _INLINE_TLS); } '(' function_call_parameter_list ')' { cs_functioncall_post_variable_passing(&$4,&yychar _INLINE_TLS); } ! possible_function_call { cs_functioncall_end(&$$,&$4,&$8,&yychar _INLINE_TLS); } ! | NEW var { assign_new_object(&$$,&$2 _INLINE_TLS); } | INT_CAST expr { if (GLOBAL(Execute)) { convert_to_long(&$2); $$ = $2; } } | DOUBLE_CAST expr { if (GLOBAL(Execute)) { convert_to_double(&$2); $$ = $2; } } | STRING_CAST expr { if (GLOBAL(Execute)) { convert_to_string(&$2); $$ = $2; } } --- 527,544 ---- | expr '?' { cs_questionmark_op_pre_expr1(&$1 _INLINE_TLS); } expr ':' { cs_questionmark_op_pre_expr2(&$1 _INLINE_TLS); } expr { cs_questionmark_op_post_expr2(&$$,&$1,&$4,&$7 _INLINE_TLS); } ! | var { cs_functioncall_pre_variable_passing(&$1,NULL,1 _INLINE_TLS); } '(' function_call_parameter_list ')' { cs_functioncall_post_variable_passing(&$1,&yychar _INLINE_TLS); } ! possible_function_call { cs_functioncall_end(&$$,&$1,&$5,&yychar,1 _INLINE_TLS);} | internal_functions_in_yacc ! | '$' unambiguous_class_name PHP_CLASS_OPERATOR var { cs_functioncall_pre_variable_passing(&$4,&$2,1 _INLINE_TLS); } '(' function_call_parameter_list ')' { cs_functioncall_post_variable_passing(&$4,&yychar _INLINE_TLS); } ! 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) && GLOBAL(Execute)) { 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; } } | DOUBLE_CAST expr { if (GLOBAL(Execute)) { convert_to_double(&$2); $$ = $2; } } | STRING_CAST expr { if (GLOBAL(Execute)) { convert_to_string(&$2); $$ = $2; } } *************** *** 548,554 **** | PHP_PRINT expr { if (GLOBAL(Execute)) { print_variable(&$2 _INLINE_TLS); yystype_destructor(&$2 _INLINE_TLS); $$.value.lval=1; $$.type=IS_LONG; } } ; - scalar: LNUMBER { if (GLOBAL(Execute)) $$ = $1; } | DNUMBER { if (GLOBAL(Execute)) $$ = $1; } --- 555,560 ---- *************** *** 722,725 **** --- 728,781 ---- *yychar=YYEMPTY; } } + + + /*** Manhattan project ***/ + /* Be able to call user-levle functions from C */ + /* "A beer and serious lack of sleep do wonders" -- Zeev */ + int call_user_function(HashTable *function_table, pval *object, pval *function_name, pval *retval, int param_count, pval *params[]) + { + pval *func; + pval return_offset; + int i; + pval class_ptr; + int original_shutdown_requested; + TLS_VARS; + original_shutdown_requested=GLOBAL(shutdown_requested); + + /* save the location to go back to */ + return_offset.offset = tc_get_current_offset(&GLOBAL(token_cache_manager) _INLINE_TLS)-1; + + if (object) { + function_table = object->value.ht; + } + php3_str_tolower(function_name->value.str.val, function_name->value.str.len); + if (_php3_hash_find(function_table, function_name->value.str.val, function_name->value.str.len+1, (void **) &func)==FAILURE + || func->type != IS_USER_FUNCTION) { + return FAILURE; + } + /* Do some magic... */ + GLOBAL(ExecuteFlag) = EXECUTE; + GLOBAL(Execute) = SHOULD_EXECUTE; + GLOBAL(shutdown_requested) = 0; + + tc_set_token(&GLOBAL(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); + } + for (i=0; i<param_count; i++) { + _php3_hash_next_index_pointer_insert(GLOBAL(function_state).function_symbol_table, params[i]); + } + cs_functioncall_post_variable_passing(function_name, NULL _INLINE_TLS); + phpparse(); + if (GLOBAL(shutdown_requested)) { /* we died during this function call */ + return FAILURE; + } + GLOBAL(shutdown_requested) = original_shutdown_requested; + cs_functioncall_end(retval,function_name,&return_offset,NULL,0 _INLINE_TLS); + return SUCCESS; + } Index: php31/main/language-scanner.l diff -c php31/main/language-scanner.l:2.1 php31/main/language-scanner.l:2.2 *** php31/main/language-scanner.l:2.1 Fri Jul 17 12:03:43 1998 --- php31/main/language-scanner.l Thu Aug 13 18:48:59 1998 *************** *** 290,295 **** --- 290,376 ---- return SUCCESS; } + int end_current_file_execution(int *retval INLINE_TLS) + { + YY_TLS_VARS + if (stack_is_empty(&GLOBAL(input_source_stack))) { + *retval = 0; + return 1; + } else { + PHPLexState *lex_state; + + yy_delete_buffer(YY_CURRENT_BUFFER); + stack_top(&GLOBAL(input_source_stack),(void **) &lex_state); + + GLOBAL(phplineno) = lex_state->lineno; + GLOBAL(in_eval) = lex_state->in_eval; + + switch(lex_state->type) { + case LEX_STATE_CONDITIONAL_INCLUDE: /* switching out of include() */ + seek_token(&GLOBAL(token_cache_manager),lex_state->return_offset, NULL); + #if WIN32|WINNT + if(yyin->_tmpfname=="url"){ + closesocket(yyin->_file); + efree(yyin); + } else { + fclose(yyin); + } + #else + fclose(yyin); + #endif + BEGIN(lex_state->state); + yy_switch_to_buffer(lex_state->buffer_state); + stack_del_top(&GLOBAL(input_source_stack)); + *retval = DONE_EVAL; + return 1; + break; + case LEX_STATE_EVAL: /* switching out of eval() */ + seek_token(&GLOBAL(token_cache_manager),lex_state->return_offset, NULL); + BEGIN(lex_state->state); + yy_switch_to_buffer(lex_state->buffer_state); + STR_FREE(lex_state->eval_string); + stack_del_top(&GLOBAL(input_source_stack)); + *retval = DONE_EVAL; + return 1; + break; + case LEX_STATE_HIGHLIGHT_STRING: + GLOBAL(php3_display_source)=0; + GLOBAL(ExecuteFlag) = stack_int_top(&GLOBAL(css)); + stack_del_top(&GLOBAL(css)); + GLOBAL(Execute) = SHOULD_EXECUTE; + END_COLOR(); + BEGIN(lex_state->state); + yy_switch_to_buffer(lex_state->buffer_state); + STR_FREE(lex_state->eval_string); + stack_del_top(&GLOBAL(input_source_stack)); + break; + case LEX_STATE_HIGHLIGHT_FILE: + GLOBAL(php3_display_source)=0; + GLOBAL(ExecuteFlag) = stack_int_top(&GLOBAL(css)); + stack_del_top(&GLOBAL(css)); + GLOBAL(Execute) = SHOULD_EXECUTE; + END_COLOR(); + /* break missing intentionally */ + case LEX_STATE_INCLUDE: + #if WIN32|WINNT + if (yyin->_tmpfname=="url") { + closesocket(yyin->_file); + efree(yyin); + } else { + fclose(yyin); + } + #else + fclose(yyin); + #endif + BEGIN(lex_state->state); + yy_switch_to_buffer(lex_state->buffer_state); + stack_del_top(&GLOBAL(input_source_stack)); + break; + } + } + return 0; + } + void clean_input_source_stack(void) { *************** *** 706,712 **** } ! <INITIAL>(([^<]|"<"[^?s]){1,400})|"<s" { phplval->value.str.val = (char *) estrndup(yytext, yyleng); phplval->value.str.len = yyleng; phplval->type = IS_STRING; --- 787,793 ---- } ! <INITIAL>(([^<]|"<"[^?s<]){1,400})|"<s"|"<" { phplval->value.str.val = (char *) estrndup(yytext, yyleng); phplval->value.str.len = yyleng; phplval->type = IS_STRING; *************** *** 947,952 **** --- 1028,1035 ---- phplval->value.chval = yytext[0]; if (yyleng == 2) { unput(yytext[1]); + yytext[1] = 0; + yyleng--; } return CHARACTER; } Index: php31/main/main.c diff -c php31/main/main.c:2.6 php31/main/main.c:2.7 *** php31/main/main.c:2.6 Fri Jul 17 22:52:57 1998 --- php31/main/main.c Thu Aug 13 18:48:59 1998 *************** *** 29,35 **** +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 2.6 1998/07/18 02:52:57 shane Exp $ */ /* #define CRASH_DETECTION */ --- 29,35 ---- +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 2.7 1998/08/13 22:48:59 shane Exp $ */ /* #define CRASH_DETECTION */ *************** *** 383,388 **** --- 383,391 ---- #endif if (!GLOBAL(initialized) || GLOBAL(shutdown_requested)) { + if (GLOBAL(shutdown_requested)==TERMINATE_CURRENT_PHPPARSE) { + GLOBAL(shutdown_requested)=0; + } return 0; } if (GLOBAL(sapi_rqst)->aborted(SAPI_GLOBAL_PASS_V)) { *************** *** 658,663 **** --- 661,669 ---- #if defined(CRASH_DETECTION) debug_log("php3_request_shutdown()"); #endif + /* clean temporary dl's, run request shutdown's for modules */ + _php3_hash_apply(&GLOBAL(module_registry), (int (*)(void *)) module_registry_cleanup); + if (GLOBAL(initialized) & INIT_SYMBOL_TABLE) { _php3_hash_destroy(&GLOBAL(symbol_table)); GLOBAL(initialized) &= ~INIT_SYMBOL_TABLE; *************** *** 765,781 **** #if 0 debug_log("%d:INIT_LIST\n",GetCurrentThreadId()); #endif - /* clean temporary dl's, run request shutdown's for modules */ - _php3_hash_apply(&GLOBAL(module_registry), (int (*)(void *)) module_registry_cleanup); - #if 0 - debug_log("%d:temporary dl's\n",GetCurrentThreadId()); - #endif if (GLOBAL(module_initialized) & INIT_CONSTANTS) { /* clean temporary defined constants */ clean_non_persistent_constants(); } #if 0 debug_log("%d:INIT_CONSTANTS\n",GetCurrentThreadId()); #endif --- 771,783 ---- #if 0 debug_log("%d:INIT_LIST\n",GetCurrentThreadId()); #endif if (GLOBAL(module_initialized) & INIT_CONSTANTS) { /* clean temporary defined constants */ clean_non_persistent_constants(); } + #if 0 debug_log("%d:INIT_CONSTANTS\n",GetCurrentThreadId()); #endif *************** *** 992,997 **** --- 994,1005 ---- if (cfg_get_string("gpc_order", &php3_ini_master.gpc_order) == FAILURE) { php3_ini_master.gpc_order = "GPC"; } + if (cfg_get_string("fopen_basedir", &php3_ini_master.fopen_basedir) == FAILURE) { + php3_ini_master.fopen_basedir = NULL; + } + if (cfg_get_long("enable_dl", &php3_ini_master.enable_dl) == FAILURE) { + php3_ini_master.enable_dl = 1; + } } #if defined(CRASH_DETECTION) debug_log("%d:INI OK\n",GetCurrentThreadId()); *************** *** 1070,1076 **** } ! void php3_module_shutdown_for_exec() { register int i; --- 1078,1084 ---- } ! void php3_module_shutdown_for_exec(void) { register int i; *************** *** 1290,1296 **** TLS_VARS; switch (c) { case '\n': ! PUTS("<br>\n"); break; case '<': PUTS("&lt;"); --- 1298,1304 ---- TLS_VARS; switch (c) { case '\n': ! PUTS("<br>"); break; case '<': PUTS("&lt;"); *************** *** 1306,1312 **** break; case '\t': PUTS("&nbsp; &nbsp; &nbsp; &nbsp; "); ! /* break missing intentionally */ default: PUTC(c); break; --- 1314,1320 ---- break; case '\t': PUTS("&nbsp; &nbsp; &nbsp; &nbsp; "); ! break; default: PUTC(c); break; Index: php31/main/main.h diff -c php31/main/main.h:2.1 php31/main/main.h:2.2 *** php31/main/main.h:2.1 Fri Jul 17 12:03:44 1998 --- php31/main/main.h Thu Aug 13 18:49:00 1998 *************** *** 29,35 **** */ ! /* $Id: main.h,v 2.1 1998/07/17 16:03:44 ssb Exp $ */ #ifndef _MAIN_H --- 29,35 ---- */ ! /* $Id: main.h,v 2.2 1998/08/13 22:49:00 shane Exp $ */ #ifndef _MAIN_H *************** *** 61,66 **** --- 61,67 ---- #define NORMAL_SHUTDOWN 1 #define NO_SHUTDOWN 0 #define ABNORMAL_SHUTDOWN -1 + #define TERMINATE_CURRENT_PHPPARSE 2 #define PREPROCESS_NONE 0 #define PREPROCESS_PREPROCESS 1 *************** *** 71,77 **** extern void php3_request_shutdown_for_exec(void *dummy); extern int php3_module_startup(INLINE_TLS_VOID); extern void php3_module_shutdown(INLINE_TLS_VOID); ! extern void php3_module_shutdown_for_exec(); extern int php3_get_lineno(int lineno); extern char *php3_get_filename(int lineno); --- 72,78 ---- extern void php3_request_shutdown_for_exec(void *dummy); extern int php3_module_startup(INLINE_TLS_VOID); extern void php3_module_shutdown(INLINE_TLS_VOID); ! extern void php3_module_shutdown_for_exec(void); extern int php3_get_lineno(int lineno); extern char *php3_get_filename(int lineno); Index: php31/main/php.h diff -c php31/main/php.h:2.3 php31/main/php.h:2.4 *** php31/main/php.h:2.3 Tue Aug 11 08:10:56 1998 --- php31/main/php.h Thu Aug 13 18:49:00 1998 *************** *** 28,34 **** +----------------------------------------------------------------------+ */ ! /* $Id: php.h,v 2.3 1998/08/11 12:10:56 ssb Exp $ */ #ifndef _PHP_H #define _PHP_H --- 28,34 ---- +----------------------------------------------------------------------+ */ ! /* $Id: php.h,v 2.4 1998/08/13 22:49:00 shane Exp $ */ #ifndef _PHP_H #define _PHP_H *************** *** 232,237 **** --- 232,242 ---- #define INTERNAL_FUNCTION_PARAMETERS HashTable *ht, pval *return_value, HashTable *list, HashTable *plist #define INTERNAL_FUNCTION_PARAM_PASSTHRU ht, return_value, list, plist + #define PHP_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS) + #define PHP3_FUNCTION(name) PHP_FUNCTION(php3_##name) + + #define PHP_FE(php_name, name, arg_types) { #php_name, name, arg_types }, + #define PHP3_FE(name, arg_types) { #name, php3_##name, arg_types }, typedef union { long lval; /* long value */ *************** *** 288,293 **** --- 293,299 ---- char *function_name; unsigned short function_type; void (*handler)(INTERNAL_FUNCTION_PARAMETERS); + pval *object_pointer; } FunctionState; *************** *** 374,379 **** --- 380,386 ---- extern int cfgparse(void); extern void reset_scanner(void); extern void html_putc(char c); + extern int end_current_file_execution(int *retval INLINE_TLS); /* functions */ #ifndef THREAD_SAFE Index: php31/main/php3_ini.h diff -c php31/main/php3_ini.h:2.1 php31/main/php3_ini.h:2.2 *** php31/main/php3_ini.h:2.1 Fri Jul 17 13:23:11 1998 --- php31/main/php3_ini.h Thu Aug 13 18:49:00 1998 *************** *** 84,89 **** --- 84,93 ---- char *gpc_order; long y2k_compliance; long define_syslog_variables; + char *error_prepend_string; + char *error_append_string; + char *fopen_basedir; + long enable_dl; } php3_ini_structure; #if MSVC5 Index: php31/main/token_cache.c diff -c php31/main/token_cache.c:2.0 php31/main/token_cache.c:2.1 *** php31/main/token_cache.c:2.0 Fri Jul 3 09:17:38 1998 --- php31/main/token_cache.c Thu Aug 13 18:49:00 1998 *************** *** 29,35 **** */ ! /* $Id: token_cache.c,v 2.0 1998/07/03 13:17:38 rasmus Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: token_cache.c,v 2.1 1998/08/13 22:49:00 shane Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 256,261 **** --- 256,277 ---- return SUCCESS; } + inline int tc_get_token(TokenCacheManager *tcm, int offset) + { + TokenCache *tc = &tcm->token_caches[offset / MAX_TOKENS_PER_CACHE]; + + offset -= tcm->active * MAX_TOKENS_PER_CACHE; + if (offset < 0 || offset >= tc->count) { + return FAILURE; + } + return tc->tokens[offset].token_type; + } + + + int tc_get_current_offset(TokenCacheManager *tcm INLINE_TLS) + { + return tcm->active * MAX_TOKENS_PER_CACHE + GLOBAL(tc)->pos; + } inline int tc_set_switched(TokenCacheManager *tcm, int offset) { *************** *** 467,473 **** } ! inline int last_token_suggests_variable_reference() { if (last_token_type=='$' || last_token_type==PHP_CLASS_OPERATOR) { return 1; --- 483,489 ---- } ! inline int last_token_suggests_variable_reference(void) { if (last_token_type=='$' || last_token_type==PHP_CLASS_OPERATOR) { return 1; Index: php31/main/token_cache.h diff -c php31/main/token_cache.h:2.0 php31/main/token_cache.h:2.1 *** php31/main/token_cache.h:2.0 Fri Jul 3 09:17:39 1998 --- php31/main/token_cache.h Thu Aug 13 18:49:01 1998 *************** *** 29,35 **** */ ! /* $Id: token_cache.h,v 2.0 1998/07/03 13:17:39 rasmus Exp $ */ #ifndef _TOKEN_CACHE --- 29,35 ---- */ ! /* $Id: token_cache.h,v 2.1 1998/08/13 22:49:01 shane Exp $ */ #ifndef _TOKEN_CACHE *************** *** 69,76 **** --- 69,78 ---- extern int seek_token(TokenCacheManager *tcm, int offset, int *yychar); extern int tc_switch(TokenCacheManager *tcm, int start, int end, int middle); extern inline int tc_set_token(TokenCacheManager *tcm, int offset, int type); + extern inline int tc_get_token(TokenCacheManager *tcm, int offset); extern inline int tc_set_switched(TokenCacheManager *tcm, int offset); extern inline int tc_set_included(TokenCacheManager *tcm, int offset); + extern int tc_get_current_offset(TokenCacheManager *tcm INLINE_TLS); extern int tc_destroy(TokenCache *tc); extern void tcm_destroy(TokenCacheManager *tcm); extern int tcm_new(TokenCacheManager *tcm); *************** *** 78,83 **** extern int tcm_load(TokenCacheManager *tcm, FILE *input); extern void clear_lookahead(int *yychar); ! extern inline int last_token_suggests_variable_reference(); #endif --- 80,85 ---- extern int tcm_load(TokenCacheManager *tcm, FILE *input); extern void clear_lookahead(int *yychar); ! extern inline int last_token_suggests_variable_reference(void); #endif Index: php31/main/variables.c diff -c php31/main/variables.c:2.2 php31/main/variables.c:2.3 *** php31/main/variables.c:2.2 Fri Jul 10 09:10:21 1998 --- php31/main/variables.c Thu Aug 13 18:49:01 1998 *************** *** 29,35 **** */ ! /* $Id: variables.c,v 2.2 1998/07/10 13:10:21 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: variables.c,v 2.3 1998/08/13 22:49:01 shane Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 43,48 **** --- 43,49 ---- #endif #include <stdio.h> #include "control_structures.h" + #include "internal_functions.h" #include "head.h" PHPAPI char *empty_string = ""; /* in order to save emalloc() and efree() time for *************** *** 69,75 **** var->value.str.len = 0; } ! inline void yystype_destructor(pval *yystype INLINE_TLS) { if (yystype->type == IS_STRING) { STR_FREE(yystype->value.str.val); --- 70,76 ---- var->value.str.len = 0; } ! inline PHPAPI void yystype_destructor(pval *yystype INLINE_TLS) { if (yystype->type == IS_STRING) { STR_FREE(yystype->value.str.val); *************** *** 588,597 **** } ! void assign_new_object(pval *result, pval *classname INLINE_TLS) { if (GLOBAL(Execute)) { ! pval *data; convert_to_string(classname); if (_php3_hash_find(&GLOBAL(function_table), classname->value.str.val, classname->value.str.len+1, (void **) &data) == FAILURE --- 589,598 ---- } ! void assign_new_object(pval *result, pval *classname, unsigned char implicit_ctor INLINE_TLS) { if (GLOBAL(Execute)) { ! pval *data, ctor_retval; convert_to_string(classname); if (_php3_hash_find(&GLOBAL(function_table), classname->value.str.val, classname->value.str.len+1, (void **) &data) == FAILURE *************** *** 602,608 **** *result = *data; result->type = IS_OBJECT; yystype_copy_constructor(result); ! yystype_destructor(classname _INLINE_TLS); } } --- 603,614 ---- *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 _INLINE_TLS); ! } ! yystype_destructor(classname _INLINE_TLS); ! } } } Index: php31/main/variables.h diff -c php31/main/variables.h:2.0 php31/main/variables.h:2.1 *** php31/main/variables.h:2.0 Fri Jul 3 09:17:41 1998 --- php31/main/variables.h Thu Aug 13 18:49:01 1998 *************** *** 29,35 **** */ ! /* $Id: variables.h,v 2.0 1998/07/03 13:17:41 rasmus Exp $ */ #ifndef _VARIABLES_H --- 29,35 ---- */ ! /* $Id: variables.h,v 2.1 1998/08/13 22:49:01 shane Exp $ */ #ifndef _VARIABLES_H *************** *** 51,59 **** extern void declare_class_variable(pval *varname, pval *expr INLINE_TLS); extern void get_object_property(pval *result, pval *classname, pval *varname INLINE_TLS); extern void get_object_symtable(pval *result, pval *parent, pval *child INLINE_TLS); ! extern void assign_new_object(pval *result, pval *classname INLINE_TLS); ! 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 --- 51,60 ---- extern void declare_class_variable(pval *varname, pval *expr INLINE_TLS); extern void get_object_property(pval *result, pval *classname, pval *varname INLINE_TLS); 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 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 -- 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 (#186) next »