Skip to content

Commit

Permalink
This commit was manufactured by cvs2svn to create tag
Browse files Browse the repository at this point in the history
'BEFORE_NEW_OPERATOR_FIX'.
  • Loading branch information
SVN Migration committed Jul 25, 1999
1 parent b1617d8 commit 5bfa702
Show file tree
Hide file tree
Showing 65 changed files with 1,906 additions and 9,079 deletions.
22 changes: 22 additions & 0 deletions ChangeLog
Expand Up @@ -2,6 +2,28 @@ PHP 4.0 CHANGE LOG ChangeLog
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


??? ?? 1999, Version 4.0 Beta 2 ??? ?? 1999, Version 4.0 Beta 2
- Fixed a problem with the PHP error handler that could result in a crash
on certain operating systems (Zeev)
- Apache php_flag values only recognized 'On' (case sensitive) - changed
to case insensitive (Zeev)
- Fixed a memory leak with switch statement containing return statements
(Andi & Zeev, libzend)
- Fixed a crash problem in switch statements that had a string offset
as a conditional (Andi & Zeev, libzend)
- Imported PHP3 fixes for rand() and mt_rand() (Rasmus)
- Added function entries for strip_tags() and similar_text() (Andrey)
- Fixed a bug in WDDX that would cause a crash if a number was passed in
instead of a variable name (Andrey)
- Ported strtotime() function from PHP3 (Andrey)
- Merged in gdttf stuff from php3 (Sascha)
- buildconf now checks your installation (Stig)
- XML module now built dynamically with --with-xml=shared (Stig)
- Added a check for freetype.h - fixed build on RedHat 6.0 (Zeev)
- Fixed array_walk() to work in PHP4 (Andrey)
- Ported all remaining date() format options from PHP3 (Andrey)
- $php_errormsg now works (Andrey)
- Added locale support for Perl Compatible Regexp functions (Andrey)
- Informix module ported (Danny)
- Removed --with-shared-apache (Sascha) - Removed --with-shared-apache (Sascha)
- Added patch for reverse lookup table in base64_decode (Sascha) - Added patch for reverse lookup table in base64_decode (Sascha)
Submitted by bfranklin@dct.com Submitted by bfranklin@dct.com
Expand Down
2 changes: 1 addition & 1 deletion Makefile.in
Expand Up @@ -135,7 +135,7 @@ distclean: clean distclean-recursive
-rm -f *-parser.[ch] *-scanner.c *.output -rm -f *-parser.[ch] *-scanner.c *.output
-rm -f config.status config.cache config.log -rm -f config.status config.cache config.log
-rm -f Makefile Makefile.depend php_config.h build-defs.h -rm -f Makefile Makefile.depend php_config.h build-defs.h
-rm -f libphp4.module stamp-h -rm -f libphp4.module stamp-h buildconf.stamp
-rm -f regex/*.o regex/*.a regex/*.ih -rm -f regex/*.o regex/*.a regex/*.ih
-rm -f doc/checkdoc doc/funcparse doc/version.ent -rm -f doc/checkdoc doc/funcparse doc/version.ent
-rm -f do-conf test/test.log -rm -f do-conf test/test.log
Expand Down
17 changes: 16 additions & 1 deletion Zend/zend.h
Expand Up @@ -241,8 +241,23 @@ extern zend_utility_values zend_uv;
(z)->EA.is_ref = 0; \ (z)->EA.is_ref = 0; \
(z)->EA.locks = 0; (z)->EA.locks = 0;


#define MAKE_STD_ZVAL(zv) \ #define MAKE_STD_ZVAL(zv) \
zv = (zval *) emalloc(sizeof(zval)); \ zv = (zval *) emalloc(sizeof(zval)); \
INIT_PZVAL(zv); INIT_PZVAL(zv);


#define SEPARATE_ZVAL(ppzv) \
{ \
zval *orig_ptr = *(ppzv); \
\
if (orig_ptr->refcount>1) { \
orig_ptr->refcount--; \
*(ppzv) = (zval *) emalloc(sizeof(zval)); \
**(ppzv) = *orig_ptr; \
zval_copy_ctor(*(ppzv)); \
(*(ppzv))->refcount=1; \
(*(ppzv))->EA.is_ref = 0; \
(*(ppzv))->EA.locks = 0; \
} \
}

#endif /* _ZEND_H */ #endif /* _ZEND_H */
26 changes: 23 additions & 3 deletions Zend/zend_compile.c
Expand Up @@ -588,7 +588,6 @@ void do_free(znode *op1 CLS_DC)
&& opline->result.u.var == op1->u.var) { && opline->result.u.var == op1->u.var) {
opline->result.u.EA.type |= EXT_TYPE_UNUSED; opline->result.u.EA.type |= EXT_TYPE_UNUSED;
} else { } else {

/* This should be an object instanciation /* This should be an object instanciation
* Find JMP_NO_CTOR, mark the preceding ASSIGN and the * Find JMP_NO_CTOR, mark the preceding ASSIGN and the
* proceeding INIT_FCALL_BY_NAME as unused * proceeding INIT_FCALL_BY_NAME as unused
Expand Down Expand Up @@ -833,10 +832,28 @@ void do_pass_param(znode *param, int op, int offset CLS_DC)
} }




void do_return(znode *expr CLS_DC) static void generate_free_switch_expr(zend_switch_entry *switch_entry CLS_DC)
{ {
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC); zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);


opline->opcode = ZEND_SWITCH_FREE;
opline->op1 = switch_entry->cond;
SET_UNUSED(opline->op2);
}


void do_return(znode *expr CLS_DC)
{
zend_op *opline;

#ifdef ZTS
zend_stack_apply_with_argument(&CG(switch_cond_stack), (void (*)(void *element, void *)) generate_free_switch_expr, ZEND_STACK_APPLY_TOPDOWN CLS_CC);
#else
zend_stack_apply(&CG(switch_cond_stack), (void (*)(void *element)) generate_free_switch_expr, ZEND_STACK_APPLY_TOPDOWN);
#endif

opline = get_next_op(CG(active_op_array) CLS_CC);

opline->opcode = ZEND_RETURN; opline->opcode = ZEND_RETURN;
if (expr) { if (expr) {
opline->op1 = *expr; opline->op1 = *expr;
Expand Down Expand Up @@ -1096,7 +1113,10 @@ void do_switch_end(znode *case_list CLS_DC)
CG(active_op_array)->current_brk_cont = CG(active_op_array)->brk_cont_array[CG(active_op_array)->current_brk_cont].parent; CG(active_op_array)->current_brk_cont = CG(active_op_array)->brk_cont_array[CG(active_op_array)->current_brk_cont].parent;


/* emit free for the switch condition*/ /* emit free for the switch condition*/
do_free(&switch_entry_ptr->cond CLS_CC); opline = get_next_op(CG(active_op_array) CLS_CC);
opline->opcode = ZEND_SWITCH_FREE;
opline->op1 = switch_entry_ptr->cond;
SET_UNUSED(opline->op2);
if (switch_entry_ptr->cond.op_type == IS_CONST) { if (switch_entry_ptr->cond.op_type == IS_CONST) {
zval_dtor(&switch_entry_ptr->cond.u.constant); zval_dtor(&switch_entry_ptr->cond.u.constant);
} }
Expand Down
117 changes: 59 additions & 58 deletions Zend/zend_compile.h
Expand Up @@ -418,8 +418,8 @@ int zendlex(znode *zendlval CLS_DC);
#define ZEND_ASSIGN 36 #define ZEND_ASSIGN 36
#define ZEND_ASSIGN_REF 37 #define ZEND_ASSIGN_REF 37


#define ZEND_ECHO 38 #define ZEND_ECHO 38
#define ZEND_PRINT 39 #define ZEND_PRINT 39


#define ZEND_JMP 40 #define ZEND_JMP 40
#define ZEND_JMPZ 41 #define ZEND_JMPZ 41
Expand All @@ -428,74 +428,75 @@ int zendlex(znode *zendlval CLS_DC);
#define ZEND_JMPZ_EX 44 #define ZEND_JMPZ_EX 44
#define ZEND_JMPNZ_EX 45 #define ZEND_JMPNZ_EX 45
#define ZEND_CASE 46 #define ZEND_CASE 46
#define ZEND_BRK 47 #define ZEND_SWITCH_FREE 47
#define ZEND_CONT 48 #define ZEND_BRK 48
#define ZEND_BOOL 49 #define ZEND_CONT 49

#define ZEND_BOOL 50
#define ZEND_INIT_STRING 50
#define ZEND_ADD_CHAR 51 #define ZEND_INIT_STRING 51
#define ZEND_ADD_STRING 52 #define ZEND_ADD_CHAR 52
#define ZEND_ADD_VAR 53 #define ZEND_ADD_STRING 53

#define ZEND_ADD_VAR 54
#define ZEND_BEGIN_SILENCE 54
#define ZEND_END_SILENCE 55 #define ZEND_BEGIN_SILENCE 55

#define ZEND_END_SILENCE 56
#define ZEND_INIT_FCALL_BY_NAME 56
#define ZEND_DO_FCALL 57 #define ZEND_INIT_FCALL_BY_NAME 57
#define ZEND_DO_FCALL_BY_NAME 58 #define ZEND_DO_FCALL 58
#define ZEND_RETURN 59 #define ZEND_DO_FCALL_BY_NAME 59

#define ZEND_RETURN 60
#define ZEND_RECV 60
#define ZEND_RECV_INIT 61 #define ZEND_RECV 61
#define ZEND_RECV_INIT 62


#define ZEND_SEND_VAL 62 #define ZEND_SEND_VAL 63
#define ZEND_SEND_VAR 63 #define ZEND_SEND_VAR 64
#define ZEND_SEND_REF 64 #define ZEND_SEND_REF 65


#define ZEND_NEW 65 #define ZEND_NEW 66
#define ZEND_JMP_NO_CTOR 66 #define ZEND_JMP_NO_CTOR 67
#define ZEND_FREE 67 #define ZEND_FREE 68


#define ZEND_INIT_ARRAY 68 #define ZEND_INIT_ARRAY 69
#define ZEND_ADD_ARRAY_ELEMENT 69 #define ZEND_ADD_ARRAY_ELEMENT 70


#define ZEND_INCLUDE_OR_EVAL 70 #define ZEND_INCLUDE_OR_EVAL 71


#define ZEND_UNSET_VAR 71 #define ZEND_UNSET_VAR 72
#define ZEND_UNSET_DIM_OBJ 72 #define ZEND_UNSET_DIM_OBJ 73
#define ZEND_ISSET_ISEMPTY 73 #define ZEND_ISSET_ISEMPTY 74


#define ZEND_FE_RESET 74 #define ZEND_FE_RESET 75
#define ZEND_FE_FETCH 75 #define ZEND_FE_FETCH 76


#define ZEND_EXIT 76 #define ZEND_EXIT 77




/* the following 12 opcodes are 4 groups of 3 opcodes each, and must /* the following 12 opcodes are 4 groups of 3 opcodes each, and must
* remain in that order! * remain in that order!
*/ */
#define ZEND_FETCH_R 77 #define ZEND_FETCH_R 78
#define ZEND_FETCH_DIM_R 78 #define ZEND_FETCH_DIM_R 79
#define ZEND_FETCH_OBJ_R 79 #define ZEND_FETCH_OBJ_R 80
#define ZEND_FETCH_W 80 #define ZEND_FETCH_W 81
#define ZEND_FETCH_DIM_W 81 #define ZEND_FETCH_DIM_W 82
#define ZEND_FETCH_OBJ_W 82 #define ZEND_FETCH_OBJ_W 83
#define ZEND_FETCH_RW 83 #define ZEND_FETCH_RW 84
#define ZEND_FETCH_DIM_RW 84 #define ZEND_FETCH_DIM_RW 85
#define ZEND_FETCH_OBJ_RW 85 #define ZEND_FETCH_OBJ_RW 86
#define ZEND_FETCH_IS 86 #define ZEND_FETCH_IS 87
#define ZEND_FETCH_DIM_IS 87 #define ZEND_FETCH_DIM_IS 88
#define ZEND_FETCH_OBJ_IS 88 #define ZEND_FETCH_OBJ_IS 89


#define ZEND_FETCH_DIM_TMP_VAR 89 #define ZEND_FETCH_DIM_TMP_VAR 90
#define ZEND_FETCH_CONSTANT 90 #define ZEND_FETCH_CONSTANT 91


#define ZEND_DECLARE_FUNCTION_OR_CLASS 91 #define ZEND_DECLARE_FUNCTION_OR_CLASS 92


#define ZEND_EXT_STMT 92 #define ZEND_EXT_STMT 93
#define ZEND_EXT_FCALL_BEGIN 93 #define ZEND_EXT_FCALL_BEGIN 94
#define ZEND_EXT_FCALL_END 94 #define ZEND_EXT_FCALL_END 95
#define ZEND_EXT_NOP 95 #define ZEND_EXT_NOP 96


/* end of block */ /* end of block */


Expand Down
45 changes: 38 additions & 7 deletions Zend/zend_execute.c
Expand Up @@ -1592,14 +1592,45 @@ binary_assign_op_addr: {
continue; continue;
} }
break; break;
case ZEND_CASE: case ZEND_CASE: {
if (opline->op1.op_type == IS_VAR) { int switch_expr_is_overloaded=0;
PZVAL_LOCK(*Ts[opline->op1.u.var].var);
if (opline->op1.op_type==IS_VAR) {
if (Ts[opline->op1.u.var].var) {
PZVAL_LOCK(*Ts[opline->op1.u.var].var);
} else {
switch_expr_is_overloaded = 1;
if (Ts[opline->op1.u.var].EA.type==IS_STRING_OFFSET) {
Ts[opline->op1.u.var].EA.str->refcount++;
}
}
}
is_equal_function(&Ts[opline->result.u.var].tmp_var,
get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R),
get_zval_ptr(&opline->op2, Ts, &free_op2, BP_VAR_R));

FREE_OP(&opline->op2, free_op2);
if (switch_expr_is_overloaded) {
/* We only free op1 if this is a string offset,
* Since if it is a TMP_VAR, it'll be reused by
* other CASE opcodes (whereas string offsets
* are allocated at each get_zval_ptr())
*/
FREE_OP(&opline->op1, free_op1);
Ts[opline->op1.u.var].var = NULL;
}
}
break;
case ZEND_SWITCH_FREE:
switch (opline->op1.op_type) {
case IS_VAR:
get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R);
FREE_OP(&opline->op1, free_op1);
break;
case IS_TMP_VAR:
zendi_zval_dtor(Ts[opline->op1.u.var].tmp_var);
break;
} }
is_equal_function(&Ts[opline->result.u.var].tmp_var,
get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R),
get_zval_ptr(&opline->op2, Ts, &free_op2, BP_VAR_R) );
FREE_OP(&opline->op2, free_op2);
break; break;
case ZEND_NEW: { case ZEND_NEW: {
zval *tmp = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R); zval *tmp = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R);
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_execute.h
Expand Up @@ -28,7 +28,7 @@ typedef union _temp_variable {
zval tmp_var; zval tmp_var;
zval **var; zval **var;
struct { struct {
zval **var_dummy; /* a dummy */ zval tmp_var; /* a dummy */


zval *str; zval *str;
int offset; int offset;
Expand Down
7 changes: 1 addition & 6 deletions Zend/zend_operators.c
Expand Up @@ -162,34 +162,29 @@ ZEND_API void convert_to_long_base(zval *op, int base)
case IS_BOOL: case IS_BOOL:
case IS_RESOURCE: case IS_RESOURCE:
case IS_LONG: case IS_LONG:
return; break;
case IS_DOUBLE: case IS_DOUBLE:
op->value.lval = (long) op->value.dval; op->value.lval = (long) op->value.dval;
op->type = IS_LONG;
break; break;
case IS_STRING: case IS_STRING:
strval = op->value.str.val; strval = op->value.str.val;
op->value.lval = strtol(strval, NULL, base); op->value.lval = strtol(strval, NULL, base);
op->type = IS_LONG;
STR_FREE(strval); STR_FREE(strval);
break; break;
case IS_ARRAY: case IS_ARRAY:
tmp = (zend_hash_num_elements(op->value.ht)?1:0); tmp = (zend_hash_num_elements(op->value.ht)?1:0);
zval_dtor(op); zval_dtor(op);
op->value.lval = tmp; op->value.lval = tmp;
op->type = IS_LONG;
break; break;
case IS_OBJECT: case IS_OBJECT:
tmp = (zend_hash_num_elements(op->value.obj.properties)?1:0); tmp = (zend_hash_num_elements(op->value.obj.properties)?1:0);
zval_dtor(op); zval_dtor(op);
op->value.lval = tmp; op->value.lval = tmp;
op->type = IS_LONG;
break; break;
default: default:
zend_error(E_WARNING, "Cannot convert to ordinal value"); zend_error(E_WARNING, "Cannot convert to ordinal value");
zval_dtor(op); zval_dtor(op);
op->value.lval = 0; op->value.lval = 0;
op->type = IS_LONG;
break; break;
} }


Expand Down
38 changes: 38 additions & 0 deletions Zend/zend_stack.c
Expand Up @@ -116,3 +116,41 @@ ZEND_API int zend_stack_count(zend_stack *stack)
{ {
return stack->top; return stack->top;
} }


ZEND_API void zend_stack_apply(zend_stack *stack, void (*apply_function)(void *element), int type)
{
int i;

switch (type) {
case ZEND_STACK_APPLY_TOPDOWN:
for (i=stack->top-1; i>=0; i--) {
apply_function(stack->elements[i]);
}
break;
case ZEND_STACK_APPLY_BOTTOMUP:
for (i=0; i<stack->top; i++) {
apply_function(stack->elements[i]);
}
break;
}
}


ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, void (*apply_function)(void *element, void *arg), int type, void *arg)
{
int i;

switch (type) {
case ZEND_STACK_APPLY_TOPDOWN:
for (i=stack->top-1; i>=0; i--) {
apply_function(stack->elements[i], arg);
}
break;
case ZEND_STACK_APPLY_BOTTOMUP:
for (i=0; i<stack->top; i++) {
apply_function(stack->elements[i], arg);
}
break;
}
}

0 comments on commit 5bfa702

Please sign in to comment.