CVS update: php3

From: Date: Sat, 08 Aug 1998 14:13:30 +0000
Subject: CVS update: php3
Groups: php.dev 
Request: Send a blank email to php-dev+get-2@lists.php.net to get a copy of this message
Date: Saturday August 8, 1998 @ 10:13 Author: zeev Update of /repository/php3 In directory asf:/tmp/cvs-serv4107 Modified Files: ChangeLog control_structures_inline.h language-parser.y language-scanner.lex php.h Log Message: return stops the execution of the current file now Index: php3/ChangeLog diff -c php3/ChangeLog:1.430 php3/ChangeLog:1.431 *** php3/ChangeLog:1.430 Sat Aug 8 07:18:04 1998 --- php3/ChangeLog Sat Aug 8 10:13:27 1998 *************** *** 1,6 **** --- 1,7 ---- PHP 3.0 CHANGE LOG ChangeLog ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? Version 3.0.3 + - return in the global scope now terminates the execution of the current file. - Added the ability to register shutdown function(s), via register_shutdown_function($function_name). - Clean up const warnings Index: php3/control_structures_inline.h diff -c php3/control_structures_inline.h:1.182 php3/control_structures_inline.h:1.183 *** php3/control_structures_inline.h:1.182 Sun Jul 26 02:14:06 1998 --- php3/control_structures_inline.h Sat Aug 8 10:13:28 1998 *************** *** 29,35 **** */ ! /* $Id: control_structures_inline.h,v 1.182 1998/07/26 06:14:06 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: control_structures_inline.h,v 1.183 1998/08/08 14:13:28 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 653,666 **** inline void cs_return(pval *expr INLINE_TLS) { if (GLOBAL(Execute)) { ! if (expr) { ! GLOBAL(return_value) = *expr; } else { ! var_reset(&GLOBAL(return_value)); } - GLOBAL(function_state).returned = 1; - GLOBAL(ExecuteFlag) = DONT_EXECUTE; - GLOBAL(Execute) = SHOULD_EXECUTE; } } --- 653,680 ---- inline void cs_return(pval *expr INLINE_TLS) { if (GLOBAL(Execute)) { ! if (GLOBAL(function_state).function_name) { ! if (expr) { ! GLOBAL(return_value) = *expr; ! } else { ! var_reset(&GLOBAL(return_value)); ! } ! GLOBAL(function_state).returned = 1; ! GLOBAL(ExecuteFlag) = DONT_EXECUTE; ! GLOBAL(Execute) = SHOULD_EXECUTE; } else { ! int retval; ! ! if (end_current_file_execution(&retval) && retval==0) { ! /* the scanner return 0, terminate execution completely (behave like exit()) */ ! php3_header(); ! GLOBAL(shutdown_requested) = ABNORMAL_SHUTDOWN; ! } ! if (expr) { ! print_variable(expr); ! yystype_destructor(expr); ! } } } } Index: php3/language-parser.y diff -c php3/language-parser.y:1.169 php3/language-parser.y:1.170 *** php3/language-parser.y:1.169 Sat Aug 8 07:18:05 1998 --- php3/language-parser.y Sat Aug 8 10:13:28 1998 *************** *** 31,37 **** */ ! /* $Id: language-parser.y,v 1.169 1998/08/08 11:18:05 zeev Exp $ */ /* --- 31,37 ---- */ ! /* $Id: language-parser.y,v 1.170 1998/08/08 14:13:28 zeev Exp $ */ /* *************** *** 56,62 **** #include "php.h" #include "php3_list.h" #include "control_structures.h" ! #include "control_structures_inline.h" #include "main.h" #include "functions/head.h" --- 56,62 ---- #include "php.h" #include "php3_list.h" #include "control_structures.h" ! #include "main.h" #include "functions/head.h" *************** *** 130,135 **** --- 130,138 ---- extern int shutdown_requested; #endif /* THREAD SAFE*/ + + #include "control_structures_inline.h" + int init_resource_list(void) { Index: php3/language-scanner.lex diff -c php3/language-scanner.lex:1.168 php3/language-scanner.lex:1.169 *** php3/language-scanner.lex:1.168 Fri Jul 31 13:24:37 1998 --- php3/language-scanner.lex Sat Aug 8 10:13:29 1998 *************** *** 291,296 **** --- 291,377 ---- } + int end_current_file_execution(int *retval) + { + 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) { PHPLexState *lex_state; *************** *** 1044,1122 **** <DOUBLE_QUOTES,BACKQUOTE,INITIAL,IN_PHP><<EOF>> { ! if (stack_is_empty(&GLOBAL(input_source_stack))) { ! yyterminate(); ! } 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)); ! return DONE_EVAL; ! 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)); ! return DONE_EVAL; ! 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; ! } } } <IN_PHP,INITIAL,DOUBLE_QUOTES,BACKQUOTE,SINGLE_QUOTE>. { --- 1125,1138 ---- <DOUBLE_QUOTES,BACKQUOTE,INITIAL,IN_PHP><<EOF>> { ! int retval; ! if (end_current_file_execution(&retval)) { ! return retval; } } + + <IN_PHP,INITIAL,DOUBLE_QUOTES,BACKQUOTE,SINGLE_QUOTE>. { Index: php3/php.h diff -c php3/php.h:1.31 php3/php.h:1.32 *** php3/php.h:1.31 Sat Aug 8 07:18:07 1998 --- php3/php.h Sat Aug 8 10:13:30 1998 *************** *** 28,34 **** +----------------------------------------------------------------------+ */ ! /* $Id: php.h,v 1.31 1998/08/08 11:18:07 zeev Exp $ */ #ifndef _PHP_H #define _PHP_H --- 28,34 ---- +----------------------------------------------------------------------+ */ ! /* $Id: php.h,v 1.32 1998/08/08 14:13:30 zeev Exp $ */ #ifndef _PHP_H #define _PHP_H *************** *** 478,483 **** --- 478,484 ---- extern int conditional_include_file(pval *file, pval *return_offset); extern void initialize_input_file_buffer(FILE *f); extern void eval_string(pval *str, pval *return_offset, int display_source); + extern int end_current_file_execution(int *retval); #endif extern void clean_input_source_stack(void); extern int _php3_hash_environment(void);

« previous php.dev (#2) next »