Merge branch 'master' into phpng

* master: (77 commits)
  NEWS entry for Fix potential segfault in dns_get_record()
  NEWS entry for "Fix potential segfault in dns_get_record()"
  NEWS entry for Fix potential segfault in dns_get_record(
  Fix potential segfault in dns_get_record()
  Revert "Add optional second arg to unserialize()"
  5.5.15 now
  update NEWS
  Fix bug #66127 (Segmentation fault with ArrayObject unset)
  5.4.31 next
  Add NEWS. This doesn't need UPGRADING (or an RFC), IMO.
  Fix broken test.
  Add a mime type map generation script and update the header.
  Move the mime type map out of php_cli_server.c for easier generation.
  Replace the CLI server's linear search for extensions with a hash table.
  fix test
  Remove unused included file
  NEWS
  NEWS
  NEWS
  Fixed Bug #67413 	fileinfo: cdf_read_property_info insufficient boundary chec
  ...

Conflicts:
	Zend/zend_closures.c
	Zend/zend_execute.c
	Zend/zend_vm_def.h
	Zend/zend_vm_execute.h
	ext/spl/spl_array.c
	ext/standard/basic_functions.c
	ext/standard/dns.c
	ext/standard/var.c
This commit is contained in:
Dmitry Stogov 2014-06-12 05:07:33 +04:00
commit dd1c68e67f
74 changed files with 3228 additions and 3601 deletions

View file

@ -36,4 +36,6 @@ before_script:
- . ./travis/ext/pdo_pgsql/setup.sh
# Run PHPs run-tests.php
script: ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120
script:
- ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120
- ./sapi/cli/php sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg sapi/phpdbg/phpdbg

5
NEWS
View file

@ -2,6 +2,11 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 20??, PHP 5.7.0
- CLI server:
. Refactor MIME type handling to use a hash table instead of linear search.
(Adam)
. Update the MIME type list from the one shipped by Apache HTTPD. (Adam)
- DBA:
. Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike)

View file

@ -0,0 +1,22 @@
--TEST--
Closure 049: static::class in static closure in non-static method.
--FILE--
<?php
class A {
function foo() {
$f = static function() {
return static::class;
};
return $f();
}
}
class B extends A {}
$b = new B;
var_dump($b->foo());
--EXPECT--
string(1) "B"

View file

@ -0,0 +1,22 @@
--TEST--
Closure 050: static::class in non-static closure in non-static method.
--FILE--
<?php
class A {
function foo() {
$f = function() {
return static::class;
};
return $f();
}
}
class B extends A {}
$b = new B;
var_dump($b->foo());
--EXPECT--
string(1) "B"

View file

@ -0,0 +1,21 @@
--TEST--
Closure 051: static::class in static closure in static method.
--FILE--
<?php
class A {
static function foo() {
$f = static function() {
return static::class;
};
return $f();
}
}
class B extends A {}
var_dump(B::foo());
--EXPECT--
string(1) "B"

View file

@ -0,0 +1,21 @@
--TEST--
Closure 052: static::class in non-static closure in static method.
--FILE--
<?php
class A {
static function foo() {
$f = function() {
return static::class;
};
return $f();
}
}
class B extends A {}
var_dump(B::foo());
--EXPECT--
string(1) "B"

View file

@ -0,0 +1,22 @@
--TEST--
Closure 053: self::class in static closure in non-static method.
--FILE--
<?php
class A {
function foo() {
$f = static function() {
return self::class;
};
return $f();
}
}
class B extends A {}
$b = new B;
var_dump($b->foo());
--EXPECT--
string(1) "A"

View file

@ -0,0 +1,22 @@
--TEST--
Closure 054: self::class in non-static closure in non-static method.
--FILE--
<?php
class A {
function foo() {
$f = function() {
return self::class;
};
return $f();
}
}
class B extends A {}
$b = new B;
var_dump($b->foo());
--EXPECT--
string(1) "A"

View file

@ -0,0 +1,21 @@
--TEST--
Closure 055: self::class in static closure in static method.
--FILE--
<?php
class A {
static function foo() {
$f = static function() {
return self::class;
};
return $f();
}
}
class B extends A {}
var_dump(B::foo());
--EXPECT--
string(1) "A"

View file

@ -0,0 +1,21 @@
--TEST--
Closure 056: self::class in non-static closure in static method.
--FILE--
<?php
class A {
static function foo() {
$f = function() {
return self::class;
};
return $f();
}
}
class B extends A {}
var_dump(B::foo());
--EXPECT--
string(1) "A"

View file

@ -0,0 +1,37 @@
--TEST--
Bug 66622: Closures do not correctly capture the late bound class (static::) in some cases
--FILE--
<?php
class A {
static function name() { return 'A'; }
function foo() {
$fn = function() { return static::name(); };
echo static::name() . ' vs ' . $fn() . "\n";
}
function bar() {
$fn = static function() { return static::name(); };
echo static::name() . ' vs ' . $fn() . "\n";
}
static function baz() {
$fn = function() { return static::name(); };
echo static::name() . ' vs ' . $fn() . "\n";
}
}
class B extends A {
static function name() { return 'B'; }
}
function test() {
(new B)->foo();
(new B)->bar();
(new B)->baz();
B::baz();
}
test();
--EXPECT--
B vs B
B vs B
B vs B
B vs B

View file

@ -76,4 +76,4 @@ NULL
Notice: Undefined offset: 3 in %s on line %d
Fatal error: Call to a member function bar() on a non-object in %s on line %d
Fatal error: Call to a member function bar() on null in %s on line %d

View file

@ -245,16 +245,16 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(func_num_args, arginfo_zend__void)
ZEND_FE(func_get_arg, arginfo_func_get_arg)
ZEND_FE(func_get_args, arginfo_zend__void)
ZEND_FE(strlen, arginfo_strlen)
ZEND_FE(strcmp, arginfo_strcmp)
ZEND_FE(strncmp, arginfo_strncmp)
ZEND_FE(strcasecmp, arginfo_strcmp)
ZEND_FE(strlen, arginfo_strlen)
ZEND_FE(strcmp, arginfo_strcmp)
ZEND_FE(strncmp, arginfo_strncmp)
ZEND_FE(strcasecmp, arginfo_strcmp)
ZEND_FE(strncasecmp, arginfo_strncmp)
ZEND_FE(each, arginfo_each)
ZEND_FE(each, arginfo_each)
ZEND_FE(error_reporting, arginfo_error_reporting)
ZEND_FE(define, arginfo_define)
ZEND_FE(defined, arginfo_defined)
ZEND_FE(get_class, arginfo_get_class)
ZEND_FE(define, arginfo_define)
ZEND_FE(defined, arginfo_defined)
ZEND_FE(get_class, arginfo_get_class)
ZEND_FE(get_called_class, arginfo_zend__void)
ZEND_FE(get_parent_class, arginfo_get_class)
ZEND_FE(method_exists, arginfo_method_exists)
@ -274,13 +274,13 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(get_included_files, arginfo_zend__void)
ZEND_FALIAS(get_required_files, get_included_files, arginfo_zend__void)
ZEND_FE(is_subclass_of, arginfo_is_subclass_of)
ZEND_FE(is_a, arginfo_is_subclass_of)
ZEND_FE(is_a, arginfo_is_subclass_of)
ZEND_FE(get_class_vars, arginfo_get_class_vars)
ZEND_FE(get_object_vars, arginfo_get_object_vars)
ZEND_FE(get_class_methods, arginfo_get_class_methods)
ZEND_FE(trigger_error, arginfo_trigger_error)
ZEND_FALIAS(user_error, trigger_error, arginfo_trigger_error)
ZEND_FE(set_error_handler, arginfo_set_error_handler)
ZEND_FE(set_error_handler, arginfo_set_error_handler)
ZEND_FE(restore_error_handler, arginfo_zend__void)
ZEND_FE(set_exception_handler, arginfo_set_exception_handler)
ZEND_FE(restore_exception_handler, arginfo_zend__void)
@ -288,14 +288,14 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(get_declared_traits, arginfo_zend__void)
ZEND_FE(get_declared_interfaces, arginfo_zend__void)
ZEND_FE(get_defined_functions, arginfo_zend__void)
ZEND_FE(get_defined_vars, arginfo_zend__void)
ZEND_FE(create_function, arginfo_create_function)
ZEND_FE(get_resource_type, arginfo_get_resource_type)
ZEND_FE(get_defined_vars, arginfo_zend__void)
ZEND_FE(create_function, arginfo_create_function)
ZEND_FE(get_resource_type, arginfo_get_resource_type)
ZEND_FE(get_loaded_extensions, arginfo_get_loaded_extensions)
ZEND_FE(extension_loaded, arginfo_extension_loaded)
ZEND_FE(extension_loaded, arginfo_extension_loaded)
ZEND_FE(get_extension_funcs, arginfo_extension_loaded)
ZEND_FE(get_defined_constants, arginfo_get_defined_constants)
ZEND_FE(debug_backtrace, arginfo_debug_backtrace)
ZEND_FE(debug_backtrace, arginfo_debug_backtrace)
ZEND_FE(debug_print_backtrace, arginfo_debug_print_backtrace)
#if ZEND_DEBUG
ZEND_FE(zend_test_func, NULL)
@ -305,7 +305,7 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
#endif
ZEND_FE(gc_collect_cycles, arginfo_zend__void)
ZEND_FE(gc_enabled, arginfo_zend__void)
ZEND_FE(gc_enable, arginfo_zend__void)
ZEND_FE(gc_enable, arginfo_zend__void)
ZEND_FE(gc_disable, arginfo_zend__void)
ZEND_FE_END
};

View file

@ -456,6 +456,7 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent
}
}
ZVAL_UNDEF(&closure->this_ptr);
/* Invariants:
* If the closure is unscoped, it has no bound object.
* The the closure is scoped, it's either static or it's bound */
@ -466,10 +467,7 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent
ZVAL_COPY(&closure->this_ptr, this_ptr);
} else {
closure->func.common.fn_flags |= ZEND_ACC_STATIC;
ZVAL_UNDEF(&closure->this_ptr);
}
} else {
ZVAL_UNDEF(&closure->this_ptr);
}
}
/* }}} */

View file

@ -1474,7 +1474,7 @@ ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_i
} else {
zval *return_value = EX_VAR_2(execute_data_ptr, execute_data_ptr->opline->result.var);
execute_data_ptr->function_state.function->internal_function.handler(
execute_data_ptr->opline->extended_value, return_value TSRMLS_CC
execute_data_ptr->opline->extended_value + execute_data_ptr->call->num_additional_args, return_value TSRMLS_CC
);
}
}

View file

@ -2451,7 +2451,7 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV)
FREE_OP2();
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -3813,7 +3813,7 @@ ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY)
{
USE_OPLINE
zend_free_op free_op1;
zval *expr, tmp;
zval *expr;
zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
@ -5374,6 +5374,7 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED)
{
USE_OPLINE
zval *zfunc;
int closure_is_static, closure_is_being_defined_inside_static_context;
SAVE_OPLINE();
@ -5382,7 +5383,13 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED)
zend_error_noreturn(E_ERROR, "Base lambda function for closure not found");
}
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC);
closure_is_static = Z_FUNC_P(zfunc)->common.fn_flags & ZEND_ACC_STATIC;
closure_is_being_defined_inside_static_context = EX(prev_execute_data) && EX(prev_execute_data)->function_state.function->common.fn_flags & ZEND_ACC_STATIC;
if (closure_is_static || closure_is_being_defined_inside_static_context) {
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(called_scope), NULL TSRMLS_CC);
} else {
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC);
}
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();

View file

@ -2802,7 +2802,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
zval *expr, tmp;
zval *expr;
zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
@ -6665,6 +6665,7 @@ static int ZEND_FASTCALL ZEND_DECLARE_LAMBDA_FUNCTION_SPEC_CONST_UNUSED_HANDLER
{
USE_OPLINE
zval *zfunc;
int closure_is_static, closure_is_being_defined_inside_static_context;
SAVE_OPLINE();
@ -6673,7 +6674,13 @@ static int ZEND_FASTCALL ZEND_DECLARE_LAMBDA_FUNCTION_SPEC_CONST_UNUSED_HANDLER
zend_error_noreturn(E_ERROR, "Base lambda function for closure not found");
}
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC);
closure_is_static = Z_FUNC_P(zfunc)->common.fn_flags & ZEND_ACC_STATIC;
closure_is_being_defined_inside_static_context = EX(prev_execute_data) && EX(prev_execute_data)->function_state.function->common.fn_flags & ZEND_ACC_STATIC;
if (closure_is_static || closure_is_being_defined_inside_static_context) {
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(called_scope), NULL TSRMLS_CC);
} else {
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC);
}
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
@ -7991,7 +7998,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
zend_free_op free_op1;
zval *expr, tmp;
zval *expr;
zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
@ -9110,7 +9117,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CONST_HANDLER(ZEND_OPCO
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -9945,7 +9952,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE
zval_dtor(free_op2.var);
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -10779,7 +10786,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE
zval_ptr_dtor_nogc(free_op2.var);
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -12163,7 +12170,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -13235,7 +13242,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
zend_free_op free_op1;
zval *expr, tmp;
zval *expr;
zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
@ -15359,7 +15366,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -17591,7 +17598,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE
zval_dtor(free_op2.var);
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -19789,7 +19796,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE
zval_ptr_dtor_nogc(free_op2.var);
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -23162,7 +23169,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -24743,7 +24750,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CONST_HANDLER(ZEND_O
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -26120,7 +26127,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPC
zval_dtor(free_op2.var);
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -27401,7 +27408,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPC
zval_ptr_dtor_nogc(free_op2.var);
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -29192,7 +29199,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CV_HANDLER(ZEND_OPCO
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -30392,7 +30399,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
zval *expr, tmp;
zval *expr;
zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
@ -32363,7 +32370,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CONST_HANDLER(ZEND_OPCOD
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -34409,7 +34416,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_
zval_dtor(free_op2.var);
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -36489,7 +36496,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_
zval_ptr_dtor_nogc(free_op2.var);
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
@ -39610,7 +39617,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_H
HANDLE_EXCEPTION();
}
zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {

View file

@ -1711,7 +1711,7 @@ int main(int argc, char *argv[])
{
FILE *fp;
long position;
char *filename = "/tmp/phpglibccheck";
char *filename = tmpnam(NULL);
fp = fopen(filename, "w");
if (fp == NULL) {

View file

@ -1,7 +1,7 @@
# +----------------------------------------------------------------------+
# | PHP Version 5 |
# +----------------------------------------------------------------------+
# | Copyright (c) 1997-2006 The PHP Group |
# | Copyright (c) 1997-2014 The PHP Group |
# +----------------------------------------------------------------------+
# | This source file is subject to version 3.01 of the PHP license, |
# | that is bundled with this package in the file LICENSE, and is |
@ -14,8 +14,6 @@
# | Author: Sascha Schumann <sascha@schumann.cx> |
# +----------------------------------------------------------------------+
#
# $Id$
#
#
# Makefile to generate build tools
#
@ -61,16 +59,6 @@ snapshot:
md5sum $$distname.tar.bz2; \
bzip2 -t $$distname.tar.bz2
cvsclean-work:
@for i in `find . -name .cvsignore`; do \
(cd `dirname $$i` 2>/dev/null && rm -rf `cat .cvsignore | grep -v config.nice | sed 's/[[:space:]]/ /g'` *.o *.a *.lo *.la *.gcno *.gcda .libs || true); \
done
svnclean-work:
@for i in `find . -type d ! -path '*/.svn/*' | grep -v '.svn'`; do \
(cd $$i 2>/dev/null && rm -rf `svn propget svn:ignore . | grep -v config.nice` *.o *.a *.lo *.la *.gcno *.gcda .libs || true); \
done
gitclean-work:
@if (test ! -f '.git/info/exclude' || grep -s "git-ls-files" .git/info/exclude); then \
(echo "Rebuild .git/info/exclude" && echo '*.o' > .git/info/exclude && git svn propget svn:ignore | grep -v config.nice >> .git/info/exclude); \

View file

@ -23,4 +23,4 @@ class mydt extends datetime
new mydt("Funktionsansvarig rådgivning och juridik", "UTC");
?>
--EXPECTF--
Fatal error: Call to a member function format() on a non-object in %sbug67118.php on line %d
Fatal error: Call to a member function format() on null in %sbug67118.php on line %d

View file

@ -18,7 +18,7 @@ exif.encode_unicode=ISO-8859-1
test4.jpg is a 1*1 image that contains Exif tags written by WindowsXP
*/
$image = exif_read_data(dirname(__FILE__).'/test4.jpg','',true,false);
echo var_dump($image['WINXP']);
var_dump($image['WINXP']);
?>
--EXPECT--
array(5) {

View file

@ -277,13 +277,15 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
{
const char *b = (const char *)sst->sst_tab;
const char *e = ((const char *)p) + tail;
size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
(void)&line;
if (e >= b && (size_t)(e - b) <= CDF_SEC_SIZE(h) * sst->sst_len)
if (e >= b && (size_t)(e - b) <= ss * sst->sst_len)
return 0;
DPRINTF(("%d: offset begin %p < end %p || %" SIZE_T_FORMAT "u"
" > %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
SIZE_T_FORMAT "u]\n", line, b, e, (size_t)(e - b),
CDF_SEC_SIZE(h) * sst->sst_len, CDF_SEC_SIZE(h), sst->sst_len));
ss * sst->sst_len, ss, sst->sst_len));
errno = EFTYPE;
return -1;
}
@ -468,7 +470,8 @@ size_t
cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
{
size_t i, j;
cdf_secid_t maxsector = (cdf_secid_t)(sat->sat_len * size);
cdf_secid_t maxsector = (cdf_secid_t)((sat->sat_len * size)
/ sizeof(maxsector));
DPRINTF(("Chain:"));
for (j = i = 0; sid >= 0; i++, j++) {
@ -478,8 +481,8 @@ cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
errno = EFTYPE;
return (size_t)-1;
}
if (sid > maxsector) {
DPRINTF(("Sector %d > %d\n", sid, maxsector));
if (sid >= maxsector) {
DPRINTF(("Sector %d >= %d\n", sid, maxsector));
errno = EFTYPE;
return (size_t)-1;
}
@ -812,7 +815,11 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
goto out;
for (i = 0; i < sh.sh_properties; i++) {
size_t ofs = CDF_GETUINT32(p, (i << 1) + 1);
size_t ofs, tail = (i << 1) + 1;
if (cdf_check_stream_offset(sst, h, p, tail * sizeof(uint32_t),
__LINE__) == -1)
goto out;
ofs = CDF_GETUINT32(p, tail);
q = (const uint8_t *)(const void *)
((const char *)(const void *)p + ofs
- 2 * sizeof(uint32_t));

View file

@ -918,10 +918,18 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
return 1;
}
case FILE_PSTRING: {
char *ptr1 = p->s, *ptr2 = ptr1 + file_pstring_length_size(m);
size_t sz = file_pstring_length_size(m);
char *ptr1 = p->s, *ptr2 = ptr1 + sz;
size_t len = file_pstring_get_length(m, ptr1);
if (len >= sizeof(p->s))
len = sizeof(p->s) - 1;
if (len >= sizeof(p->s)) {
/*
* The size of the pascal string length (sz)
* is 1, 2, or 4. We need at least 1 byte for NUL
* termination, but we've already truncated the
* string by p->s, so we need to deduct sz.
*/
len = sizeof(p->s) - sz;
}
while (len--)
*ptr1++ = *ptr2++;
*ptr1 = '\0';

View file

@ -1,14 +0,0 @@
#!/bin/sh
function cvsclean_sub() {
prev_pwd=`pwd`
cd $1
cat .cvsignore | while read fname; do
rm -r -f $fname
done
cd "$prev_pwd"
}
cvsclean_sub .
cvsclean_sub mbfl
cvsclean_sub filters
cvsclean_sub nls

View file

@ -26,4 +26,4 @@ $DB->query_single('SELECT DATE()');
?>
--EXPECTF--
Fatal error: Call to a member function fetch_row() on a non-object in %sbug33491.php on line %d
Fatal error: Call to a member function fetch_row() on boolean in %sbug33491.php on line %d

View file

@ -705,7 +705,7 @@ static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */
char * thestr;
long gmadjust = 0;
if (ASN1_STRING_type(timestr) != V_ASN1_UTCTIME) {
if (ASN1_STRING_type(timestr) != V_ASN1_UTCTIME && ASN1_STRING_type(timestr) != V_ASN1_GENERALIZEDTIME) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "illegal ASN1 data type for timestamp");
return (time_t)-1;
}
@ -720,6 +720,11 @@ static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */
return (time_t)-1;
}
if (ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME && ASN1_STRING_length(timestr) < 15) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to parse time string %s correctly", timestr->data);
return (time_t)-1;
}
strbuf = estrdup((char *)ASN1_STRING_data(timestr));
memset(&thetime, 0, sizeof(thetime));
@ -741,14 +746,21 @@ static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */
*thestr = '\0';
thestr -= 2;
thetime.tm_mon = atoi(thestr)-1;
*thestr = '\0';
thestr -= 2;
thetime.tm_year = atoi(thestr);
if (thetime.tm_year < 68) {
thetime.tm_year += 100;
*thestr = '\0';
if( ASN1_STRING_type(timestr) == V_ASN1_UTCTIME ) {
thestr -= 2;
thetime.tm_year = atoi(thestr);
if (thetime.tm_year < 68) {
thetime.tm_year += 100;
}
} else if( ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME ) {
thestr -= 4;
thetime.tm_year = atoi(thestr) - 1900;
}
thetime.tm_isdst = -1;
ret = mktime(&thetime);

View file

@ -0,0 +1,28 @@
-----BEGIN CERTIFICATE-----
MIIEsTCCA5mgAwIBAgIQdwrGwrpRpBwdXS+ZsmsMGjANBgkqhkiG9w0BAQUFADA+
MQswCQYDVQQGEwJQTDEbMBkGA1UEChMSVW5pemV0byBTcC4geiBvLm8uMRIwEAYD
VQQDEwlDZXJ0dW0gQ0EwIhgPMjAwOTAzMDMxMjUzMThaGA8yMDI0MDMwMzEyNTMx
OFowdzELMAkGA1UEBhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVz
IFMuQS4xJzAlBgNVBAsTHkNlcnR1bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEb
MBkGA1UEAxMSQ2VydHVtIExldmVsIElJIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIBCgKCAQEA4LE0Ixw8h5Lper9tHVtZkWIujxYsPVgUZABeZZgQsKTdJjaG
VP64B/oiEV5Hd3AxRqaZ7dRRsf4Pg/PSS/2mHRQQ/SH3XACbrDHmucDvYgtU/WoZ
yp9d6PXVPY4j7J5t/52s+EbZD5swSuQLGjZ9iwg9sXX3JdJ9Ty+B3z80oiajpK0B
wqAxrcX3DekEOknj7LkAOK6iuQKI85REj4IVb9kD7KKIWdISGbfL4Ezh/TP51e0L
/WhTJ7lHbHbRzFfPU/oi3Qyt5tEexrPKe+6N+Jrejdb5Ya7Ne3tKujDU7KlbO+dn
pzFH7VHkBPJcQJ7QUrprPaqVsVg3JJ1PXTqVnwIDAQABo4IBbDCCAWgwDwYDVR0T
AQH/BAUwAwEB/zAdBgNVHQ4EFgQUgGIR3sBrpxDhCPBVtDCDv/qPCGAwUgYDVR0j
BEswSaFCpEAwPjELMAkGA1UEBhMCUEwxGzAZBgNVBAoTElVuaXpldG8gU3AuIHog
by5vLjESMBAGA1UEAxMJQ2VydHVtIENBggMBACAwDgYDVR0PAQH/BAQDAgEGMCwG
A1UdHwQlMCMwIaAfoB2GG2h0dHA6Ly9jcmwuY2VydHVtLnBsL2NhLmNybDBoBggr
BgEFBQcBAQRcMFowKAYIKwYBBQUHMAGGHGh0dHA6Ly9zdWJjYS5vY3NwLWNlcnR1
bS5jb20wLgYIKwYBBQUHMAKGImh0dHA6Ly9yZXBvc2l0b3J5LmNlcnR1bS5wbC9j
YS5jZXIwOgYDVR0gBDMwMTAvBgRVHSAAMCcwJQYIKwYBBQUHAgEWGWh0dHBzOi8v
d3d3LmNlcnR1bS5wbC9DUFMwDQYJKoZIhvcNAQEFBQADggEBAI/jSDAW/w9qLzF6
4oQiIRB7dGKp2Nlj27xZFYDBRINn4DKyZExkpanASF2of9eEzvrS+qoDY29mhXCi
MkiGr0vCsVhn0ReUpjg4Z5SsiQhZ2BGSjXiOJgaDI7Dw1MH7Ru6jdfSbLyd97EFj
ER0ERGdrcA2kLw7KfQm78IkClXEEKjKnAUTn1d/5Y4UuBWDCEL0FLgO9AqNXEzIy
rlXVGIs73kdefAK+Z1T6dm83vUrDMyzemWNRBI2tVBujkN6zkaF6uPjE4hfoIkEQ
Z4317byFkG4mxjATU+tQLG1Bs88HUAOrxtJOo/WoeCNsFJaxbYPt4oQGxIVYdz29
OUX9CQA=
-----END CERTIFICATE-----

View file

@ -0,0 +1,19 @@
--TEST--
Bug #65689 (GeneralizedTime format parsing)
--SKIPIF--
<?php
if (!extension_loaded("openssl")) die("skip");
?>
--FILE--
<?php
$crt = substr(__FILE__, 0, -4).'.crt';
$info = openssl_x509_parse("file://$crt");
var_dump($info["validFrom"], $info["validFrom_time_t"], $info["validTo"], $info["validTo_time_t"]);
?>
Done
--EXPECTF--
string(15) "20090303125318Z"
int(1236084798)
string(15) "20240303125318Z"
int(1709470398)
Done

View file

@ -12,7 +12,7 @@ var_dump($info['issuer']['emailAddress'], $info["validFrom_time_t"]);
?>
Done
--EXPECTF--
%s openssl_x509_parse(): illegal ASN1 data type for timestamp in %s%ecve-2013-6420.php on line 3
%s openssl_x509_parse(): illegal length in timestamp in %s%ecve-2013-6420.php on line 3
string(27) "stefan.esser@sektioneins.de"
int(-1)
Done

View file

@ -93,4 +93,4 @@ array(1) {
Warning: PDO::prepare(): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'unknown_column' in 'field list' in %s on line %d
Fatal error: Call to a member function execute() on a non-object in %s on line %d
Fatal error: Call to a member function execute() on boolean in %s on line %d

View file

@ -36,4 +36,4 @@ Warning: PDO::prepare(): SQLSTATE[HY093]: Invalid parameter number: mixed named
Warning: PDO::prepare(): SQLSTATE[HY093]: Invalid parameter number in %s on line %d
Fatal error: Call to a member function execute() on a non-object in %s on line %d
Fatal error: Call to a member function execute() on boolean in %s on line %d

View file

@ -56,4 +56,4 @@ Testing native PS...
Warning: PDO::prepare(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d
Fatal error: Call to a member function execute() on a non-object in %s on line %d
Fatal error: Call to a member function execute() on boolean in %s on line %d

View file

@ -99,4 +99,4 @@ Native Prepared Statements...
Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%SSELECT label FROM test ORDER BY id ASC LIMIT 1' at line %d in %s on line %d
Fatal error: Call to a member function errorInfo() on a non-object in %s on line %d
Fatal error: Call to a member function errorInfo() on boolean in %s on line %d

View file

@ -13,6 +13,6 @@ if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION
<?php
$closure = function($param) { return "this is a closure"; };
$rc = new ReflectionFunction($closure);
echo var_dump($rc->isClosure());
var_dump($rc->isClosure());
--EXPECTF--
bool(true)

View file

@ -10,6 +10,6 @@ if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION
--FILE--
<?php
$rc = new ReflectionFunction('ereg');
echo var_dump($rc->isDeprecated());
var_dump($rc->isDeprecated());
--EXPECTF--
bool(true)

View file

@ -12,6 +12,6 @@ disable_functions=is_file
--FILE--
<?php
$rc = new ReflectionFunction('is_file');
echo var_dump($rc->isDisabled());
var_dump($rc->isDisabled());
--EXPECTF--
bool(true)

View file

@ -225,6 +225,7 @@ PHP_METHOD(SoapClient, __getFunctions);
PHP_METHOD(SoapClient, __getTypes);
PHP_METHOD(SoapClient, __doRequest);
PHP_METHOD(SoapClient, __setCookie);
PHP_METHOD(SoapClient, __getCookies);
PHP_METHOD(SoapClient, __setLocation);
PHP_METHOD(SoapClient, __setSoapHeaders);
@ -368,6 +369,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_soapclient___setcookie, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_soapclient___getcookies, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_soapclient___setsoapheaders, 0, 0, 1)
ZEND_ARG_INFO(0, soapheaders)
ZEND_END_ARG_INFO()
@ -422,6 +426,7 @@ static const zend_function_entry soap_client_functions[] = {
PHP_ME(SoapClient, __getTypes, arginfo_soapclient___gettypes, 0)
PHP_ME(SoapClient, __doRequest, arginfo_soapclient___dorequest, 0)
PHP_ME(SoapClient, __setCookie, arginfo_soapclient___setcookie, 0)
PHP_ME(SoapClient, __getCookies, arginfo_soapclient___getcookies, 0)
PHP_ME(SoapClient, __setLocation, arginfo_soapclient___setlocation, 0)
PHP_ME(SoapClient, __setSoapHeaders, arginfo_soapclient___setsoapheaders, 0)
PHP_FE_END
@ -3146,6 +3151,26 @@ PHP_METHOD(SoapClient, __setCookie)
}
/* }}} */
/* {{{ proto array SoapClient::__getCookies ( void )
Returns list of cookies */
PHP_METHOD(SoapClient, __getCookies)
{
zval *cookies;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((cookies = zend_hash_str_find(Z_OBJPROP_P(getThis()), "_cookies", sizeof("_cookies")-1)) != NULL) {
ZVAL_NEW_ARR(return_value);
zend_array_dup(Z_ARRVAL_P(return_value), Z_ARRVAL_P(cookies));
} else {
array_init(return_value);
}
}
/* }}} */
/* {{{ proto void SoapClient::__setSoapHeaders(array SoapHeaders)
Sets SOAP headers for subsequent calls (replaces any previous
values).

View file

@ -0,0 +1,14 @@
--TEST--
Test for bug #49898: SoapClient::__getCookies() implementation
--CREDITS--
Boro Sitnikovski <buritomath@yahoo.com>
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$client = new SoapClient(null, array('uri' => 'mo:http://www.w3.org/', 'location' => 'http://some.url'));
$client->__setCookie("CookieTest", "HelloWorld");
var_dump($client->__getCookies()['CookieTest'][0]);
?>
--EXPECT--
string(10) "HelloWorld"

View file

@ -0,0 +1,25 @@
--TEST--
Bug #66127 (Segmentation fault with ArrayObject unset)
--INI--
error_reporting = E_ALL & ~E_NOTICE
--FILE--
<?php
function crash()
{
set_error_handler(function () {});
$var = 1;
trigger_error('error');
$var2 = $var;
$var3 = $var;
trigger_error('error');
}
$items = new ArrayObject();
unset($items[0]);
unset($items[0][0]);
crash();
echo "Worked!\n";
?>
--EXPECT--
Worked!

View file

@ -12,4 +12,6 @@ $a[] = &$tmp;
echo "Done\n";
?>
--EXPECTF--
Notice: Indirect modification of overloaded element of ArrayIterator has no effect in %s on line %d
Fatal error: Cannot assign by reference to overloaded object in %s on line %d

View file

@ -2636,7 +2636,6 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, variable_representation)
ZEND_ARG_INFO(1, consumed)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memory_get_usage, 0, 0, 0)
@ -4042,92 +4041,91 @@ PHP_FUNCTION(putenv)
{
char *setting;
int setting_len;
char *p, **env;
putenv_entry pe;
#ifdef PHP_WIN32
char *value = NULL;
int equals = 0;
int error_code;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &setting, &setting_len) == FAILURE) {
return;
}
if(setting_len == 0 || setting[0] == '=') {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter syntax");
RETURN_FALSE;
}
if (setting_len) {
char *p, **env;
putenv_entry pe;
pe.putenv_string = estrndup(setting, setting_len);
pe.key = estrndup(setting, setting_len);
if ((p = strchr(pe.key, '='))) { /* nullify the '=' if there is one */
*p = '\0';
#ifdef PHP_WIN32
char *value = NULL;
int equals = 0;
int error_code;
equals = 1;
#endif
}
pe.putenv_string = estrndup(setting, setting_len);
pe.key = estrndup(setting, setting_len);
if ((p = strchr(pe.key, '='))) { /* nullify the '=' if there is one */
*p = '\0';
pe.key_len = strlen(pe.key);
#ifdef PHP_WIN32
equals = 1;
#endif
}
pe.key_len = strlen(pe.key);
#ifdef PHP_WIN32
if (equals) {
if (pe.key_len < setting_len - 1) {
value = p + 1;
} else {
/* empty string*/
value = p;
}
}
#endif
zend_hash_str_del(&BG(putenv_ht), pe.key, pe.key_len);
/* find previous value */
pe.previous_value = NULL;
for (env = environ; env != NULL && *env != NULL; env++) {
if (!strncmp(*env, pe.key, pe.key_len) && (*env)[pe.key_len] == '=') { /* found it */
#if defined(PHP_WIN32)
/* must copy previous value because MSVCRT's putenv can free the string without notice */
pe.previous_value = estrdup(*env);
#else
pe.previous_value = *env;
#endif
break;
}
}
#if HAVE_UNSETENV
if (!p) { /* no '=' means we want to unset it */
unsetenv(pe.putenv_string);
}
if (!p || putenv(pe.putenv_string) == 0) { /* success */
#else
# ifndef PHP_WIN32
if (putenv(pe.putenv_string) == 0) { /* success */
# else
error_code = SetEnvironmentVariable(pe.key, value);
# if _MSC_VER < 1500
/* Yet another VC6 bug, unset may return env not found */
if (error_code != 0 ||
(error_code == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)) {
# else
if (error_code != 0) { /* success */
# endif
# endif
#endif
zend_hash_str_add_mem(&BG(putenv_ht), pe.key, pe.key_len, &pe, sizeof(putenv_entry));
#ifdef HAVE_TZSET
if (!strncmp(pe.key, "TZ", pe.key_len)) {
tzset();
}
#endif
RETURN_TRUE;
if (equals) {
if (pe.key_len < setting_len - 1) {
value = p + 1;
} else {
efree(pe.putenv_string);
efree(pe.key);
RETURN_FALSE;
/* empty string*/
value = p;
}
}
#endif
zend_hash_str_del(&BG(putenv_ht), pe.key, pe.key_len);
/* find previous value */
pe.previous_value = NULL;
for (env = environ; env != NULL && *env != NULL; env++) {
if (!strncmp(*env, pe.key, pe.key_len) && (*env)[pe.key_len] == '=') { /* found it */
#if defined(PHP_WIN32)
/* must copy previous value because MSVCRT's putenv can free the string without notice */
pe.previous_value = estrdup(*env);
#else
pe.previous_value = *env;
#endif
break;
}
}
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter syntax");
RETURN_FALSE;
#if HAVE_UNSETENV
if (!p) { /* no '=' means we want to unset it */
unsetenv(pe.putenv_string);
}
if (!p || putenv(pe.putenv_string) == 0) { /* success */
#else
# ifndef PHP_WIN32
if (putenv(pe.putenv_string) == 0) { /* success */
# else
error_code = SetEnvironmentVariable(pe.key, value);
# if _MSC_VER < 1500
/* Yet another VC6 bug, unset may return env not found */
if (error_code != 0 ||
(error_code == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)) {
# else
if (error_code != 0) { /* success */
# endif
# endif
#endif
zend_hash_str_add_mem(&BG(putenv_ht), pe.key, pe.key_len, &pe, sizeof(putenv_entry));
#ifdef HAVE_TZSET
if (!strncmp(pe.key, "TZ", pe.key_len)) {
tzset();
}
#endif
RETURN_TRUE;
} else {
efree(pe.putenv_string);
efree(pe.key);
RETURN_FALSE;
}
}
/* }}} */
#endif

View file

@ -515,6 +515,10 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
while (ll < dlen) {
n = cp[ll];
if ((ll + n) >= dlen) {
// Invalid chunk length, truncate
n = dlen - (ll + 1);
}
memcpy(tp->val + ll , cp + ll + 1, n);
add_next_index_stringl(&entries, (char*)cp + ll + 1, n);
ll = ll + n + 1;

View file

@ -15,6 +15,9 @@ var_dump(getenv($var_name));
var_dump(putenv($var_name));
var_dump(getenv($var_name));
var_dump(putenv("=123"));
var_dump(putenv(""));
echo "Done\n";
?>
--EXPECTF--
@ -25,4 +28,10 @@ bool(true)
string(0) ""
bool(true)
bool(false)
Warning: putenv(): Invalid parameter syntax in %s on line %d
bool(false)
Warning: putenv(): Invalid parameter syntax in %s on line %d
bool(false)
Done

View file

@ -35,7 +35,7 @@ $expected = array(
$headers = headers_list();
if (($i = count($expected)) > count($headers))
{
echo "Less headers are being sent than expected - aborting";
echo "Fewer headers are being sent than expected - aborting";
return;
}
@ -67,4 +67,4 @@ echo ($i === 0)
--EXPECTHEADERS--
--EXPECT--
OK
OK

View file

@ -21,7 +21,7 @@ var_dump( unserialize() );
//Test serialize with one more than the expected number of arguments
var_dump( serialize(1,2) );
var_dump( unserialize(1,$x,2) );
var_dump( unserialize(1,2) );
echo "Done";
?>
@ -31,12 +31,12 @@ echo "Done";
Warning: serialize() expects exactly 1 parameter, 0 given in %s on line 16
NULL
Warning: unserialize() expects at least 1 parameter, 0 given in %s on line 17
Warning: unserialize() expects exactly 1 parameter, 0 given in %s on line 17
bool(false)
Warning: serialize() expects exactly 1 parameter, 2 given in %s on line 20
NULL
Warning: unserialize() expects at most 2 parameters, 3 given in %s on line 21
Warning: unserialize() expects exactly 1 parameter, 2 given in %s on line 21
bool(false)
Done

View file

@ -1,27 +0,0 @@
--TEST--
Unserialization of partial strings
--FILE--
<?php
$data = [123,4.56,true];
$ser = serialize($data);
$serlen = strlen($ser);
$unser = unserialize($ser, $consumed);
echo "Consume full string: ";
var_dump($serlen == $consumed);
echo "Return original data: ";
var_dump($unser === $data);
$ser .= "junk\x01data";
$unser = unserialize($ser, $consumed);
echo "Consume full string(junk): ";
var_dump($serlen == $consumed);
echo "Return original data(junk): ";
var_dump($unser === $data);
--EXPECT--
Consume full string: bool(true)
Return original data: bool(true)
Consume full string(junk): bool(true)
Return original data(junk): bool(true)

View file

@ -1008,7 +1008,7 @@ PHP_FUNCTION(serialize)
}
/* }}} */
/* {{{ proto mixed unserialize(string variable_representation[, int &consumed])
/* {{{ proto mixed unserialize(string variable_representation)
Takes a string representation of variable and recreates it */
PHP_FUNCTION(unserialize)
{
@ -1016,9 +1016,8 @@ PHP_FUNCTION(unserialize)
int buf_len;
const unsigned char *p;
php_unserialize_data_t var_hash;
zval *consumed = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/", &buf, &buf_len, &consumed) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
RETURN_FALSE;
}
@ -1037,11 +1036,6 @@ PHP_FUNCTION(unserialize)
RETURN_FALSE;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
if (consumed) {
zval_dtor(consumed);
ZVAL_LONG(consumed, ((char*)p) - buf);
}
}
/* }}} */

View file

@ -0,0 +1,15 @@
--TEST--
Bug 67395: token_name() does not return name for T_POW and T_POW_EQUAL token
--FILE--
<?php
$powToken = token_get_all('<?php **')[1][0];
var_dump(token_name($powToken));
$powEqualToken = token_get_all('<?php **=')[1][0];
var_dump(token_name($powEqualToken));
?>
--EXPECT--
string(5) "T_POW"
string(11) "T_POW_EQUAL"

View file

@ -39,6 +39,7 @@ void tokenizer_register_constants(INIT_FUNC_ARGS) {
REGISTER_LONG_CONSTANT("T_LOGICAL_AND", T_LOGICAL_AND, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_PRINT", T_PRINT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_YIELD", T_YIELD, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_POW_EQUAL", T_POW_EQUAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_SR_EQUAL", T_SR_EQUAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_SL_EQUAL", T_SL_EQUAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_XOR_EQUAL", T_XOR_EQUAL, CONST_CS | CONST_PERSISTENT);
@ -70,6 +71,7 @@ void tokenizer_register_constants(INIT_FUNC_ARGS) {
REGISTER_LONG_CONSTANT("T_INT_CAST", T_INT_CAST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_DEC", T_DEC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_INC", T_INC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_POW", T_POW, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_CLONE", T_CLONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_NEW", T_NEW, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("T_EXIT", T_EXIT, CONST_CS | CONST_PERSISTENT);
@ -176,6 +178,7 @@ char *get_token_type_name(int token_type)
case T_LOGICAL_AND: return "T_LOGICAL_AND";
case T_PRINT: return "T_PRINT";
case T_YIELD: return "T_YIELD";
case T_POW_EQUAL: return "T_POW_EQUAL";
case T_SR_EQUAL: return "T_SR_EQUAL";
case T_SL_EQUAL: return "T_SL_EQUAL";
case T_XOR_EQUAL: return "T_XOR_EQUAL";
@ -207,6 +210,7 @@ char *get_token_type_name(int token_type)
case T_INT_CAST: return "T_INT_CAST";
case T_DEC: return "T_DEC";
case T_INC: return "T_INC";
case T_POW: return "T_POW";
case T_CLONE: return "T_CLONE";
case T_NEW: return "T_NEW";
case T_EXIT: return "T_EXIT";

View file

@ -24,7 +24,7 @@ gzclose($h);
echo "\nreading the output file\n";
$h = gzopen($f, 'r');
echo gzread($h, strlen($str1))."\n";
echo var_dump(bin2hex(gzread($h, 20)));
var_dump(bin2hex(gzread($h, 20)));
echo gzread($h, strlen($str2))."\n";
gzclose($h);
unlink($f);

View file

@ -20,7 +20,7 @@ gzwrite($h, $str2);
gzclose($h);
$h = gzopen($f, 'r');
echo gzread($h, strlen($str1))."\n";
echo var_dump(bin2hex(gzread($h, 20)));
var_dump(bin2hex(gzread($h, 20)));
echo gzread($h, strlen($str2))."\n";
gzclose($h);
unlink($f);

View file

@ -24,7 +24,7 @@ gzclose($h);
echo "\nreading the output file\n";
$h = gzopen($f, 'r');
echo gzread($h, strlen($str1))."\n";
echo var_dump(bin2hex(gzread($h, 20)));
var_dump(bin2hex(gzread($h, 20)));
echo gzread($h, strlen($str2))."\n";
gzclose($h);
unlink($f);

View file

@ -24,7 +24,7 @@ gzclose($h);
echo "\nreading the output file\n";
$h = gzopen($f, 'r');
echo gzread($h, strlen($str1))."\n";
echo var_dump(bin2hex(gzread($h, 20)));
var_dump(bin2hex(gzread($h, 20)));
echo gzread($h, strlen($str2))."\n";
gzclose($h);
unlink($f);

View file

@ -0,0 +1,76 @@
#!/usr/bin/env php
<?php
// Check if we are being given a mime.types file or if we should use the
// default URL.
$source = count($_SERVER['argv']) > 1 ? $_SERVER['argv'][1] : 'https://raw.githubusercontent.com/apache/httpd/trunk/docs/conf/mime.types';
// See if we can actually load it.
$types = @file($source);
if ($types === false) {
fprintf(STDERR, "Error: unable to read $source\n");
exit(1);
}
// Remove comments and flip into an extensions array.
$extensions = [];
array_walk($types, function ($line) use (&$extensions) {
$line = trim($line);
if ($line && $line[0] != '#') {
$fields = preg_split('/\s+/', $line);
if (count($fields) > 1) {
$mime = array_shift($fields);
foreach ($fields as $extension) {
$extensions[$extension] = $mime;
}
}
}
});
?>
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Moriyoshi Koizumi <moriyoshi@php.net> |
+----------------------------------------------------------------------+
*/
/* This is a generated file. Rather than modifying it, please run
* "php generate_mime_type_map.php > mime_type_map.h" to regenerate the file. */
#ifndef PHP_CLI_SERVER_MIME_TYPE_MAP_H
#define PHP_CLI_SERVER_MIME_TYPE_MAP_H
typedef struct php_cli_server_ext_mime_type_pair {
const char *ext;
const char *mime_type;
} php_cli_server_ext_mime_type_pair;
static php_cli_server_ext_mime_type_pair mime_type_map[] = {
<?php foreach ($extensions as $extension => $mime): ?>
{ "<?= addcslashes($extension, "\0..\37!@\@\177..\377") ?>", "<?= addcslashes($mime, "\0..\37!@\@\177..\377") ?>" },
<?php endforeach ?>
{ NULL, NULL }
};
#endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/

1024
sapi/cli/mime_type_map.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -104,6 +104,7 @@
#include "php_http_parser.h"
#include "php_cli_server.h"
#include "mime_type_map.h"
#include "php_cli_process_title.h"
@ -194,6 +195,7 @@ typedef struct php_cli_server {
size_t router_len;
socklen_t socklen;
HashTable clients;
HashTable extension_mime_types;
} php_cli_server;
typedef struct php_cli_server_http_response_status_code_pair {
@ -201,11 +203,6 @@ typedef struct php_cli_server_http_response_status_code_pair {
const char *str;
} php_cli_server_http_response_status_code_pair;
typedef struct php_cli_server_ext_mime_type_pair {
const char *ext;
const char *mime_type;
} php_cli_server_ext_mime_type_pair;
static php_cli_server_http_response_status_code_pair status_map[] = {
{ 100, "Continue" },
{ 101, "Switching Protocols" },
@ -260,64 +257,6 @@ static php_cli_server_http_response_status_code_pair template_map[] = {
{ 501, "<h1>%s</h1><p>Request method not supported.</p>" }
};
static php_cli_server_ext_mime_type_pair mime_type_map[] = {
{ "html", "text/html" },
{ "htm", "text/html" },
{ "js", "text/javascript" },
{ "css", "text/css" },
{ "gif", "image/gif" },
{ "jpg", "image/jpeg" },
{ "jpeg", "image/jpeg" },
{ "jpe", "image/jpeg" },
{ "pdf", "application/pdf" },
{ "png", "image/png" },
{ "svg", "image/svg+xml" },
{ "txt", "text/plain" },
{ "webm", "video/webm" },
{ "ogv", "video/ogg" },
{ "ogg", "audio/ogg" },
{ "3gp", "video/3gpp" }, /* This is standard video format used for MMS in phones */
{ "apk", "application/vnd.android.package-archive" },
{ "avi", "video/x-msvideo" },
{ "bmp", "image/x-ms-bmp" },
{ "csv", "text/comma-separated-values" },
{ "doc", "application/msword" },
{ "docx", "application/msword" },
{ "flac", "audio/flac" },
{ "gz", "application/x-gzip" },
{ "gzip", "application/x-gzip" },
{ "ics", "text/calendar" },
{ "kml", "application/vnd.google-earth.kml+xml" },
{ "kmz", "application/vnd.google-earth.kmz" },
{ "m4a", "audio/mp4" },
{ "mp3", "audio/mpeg" },
{ "mp4", "video/mp4" },
{ "mpg", "video/mpeg" },
{ "mpeg", "video/mpeg" },
{ "mov", "video/quicktime" },
{ "odp", "application/vnd.oasis.opendocument.presentation" },
{ "ods", "application/vnd.oasis.opendocument.spreadsheet" },
{ "odt", "application/vnd.oasis.opendocument.text" },
{ "oga", "audio/ogg" },
{ "pdf", "application/pdf" },
{ "pptx", "application/vnd.ms-powerpoint" },
{ "pps", "application/vnd.ms-powerpoint" },
{ "qt", "video/quicktime" },
{ "swf", "application/x-shockwave-flash" },
{ "tar", "application/x-tar" },
{ "text", "text/plain" },
{ "tif", "image/tiff" },
{ "wav", "audio/wav" },
{ "wmv", "video/x-ms-wmv" },
{ "xls", "application/vnd.ms-excel" },
{ "xlsx", "application/vnd.ms-excel" },
{ "zip", "application/x-zip-compressed" },
{ "xml", "application/xml" },
{ "xsl", "application/xml" },
{ "xsd", "application/xml" },
{ NULL, NULL }
};
static int php_cli_output_is_tty = OUTPUT_NOT_CHECKED;
static size_t php_cli_server_client_send_through(php_cli_server_client *client, const char *str, size_t str_len);
@ -463,16 +402,9 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c
smart_str_appendl_ex(buffer, "Connection: close\r\n", sizeof("Connection: close\r\n") - 1, persistent);
} /* }}} */
static const char *get_mime_type(const char *ext, size_t ext_len) /* {{{ */
static const char *get_mime_type(const php_cli_server *server, const char *ext, size_t ext_len) /* {{{ */
{
php_cli_server_ext_mime_type_pair *pair;
for (pair = mime_type_map; pair->ext; pair++) {
size_t len = strlen(pair->ext);
if (len == ext_len && memcmp(pair->ext, ext, len) == 0) {
return pair->mime_type;
}
}
return NULL;
return (const char*)zend_hash_str_find_ptr(&server->extension_mime_types, ext, ext_len);
} /* }}} */
PHP_FUNCTION(apache_request_headers) /* {{{ */
@ -893,13 +825,11 @@ static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode
#endif
} /* }}} */
static int php_cli_server_poller_poll(php_cli_server_poller *poller, const struct timeval *tv) /* {{{ */
static int php_cli_server_poller_poll(php_cli_server_poller *poller, struct timeval *tv) /* {{{ */
{
struct timeval t = *tv;
memmove(&poller->active.rfds, &poller->rfds, sizeof(poller->rfds));
memmove(&poller->active.wfds, &poller->wfds, sizeof(poller->wfds));
return php_select(poller->max_fd + 1, &poller->active.rfds, &poller->active.wfds, NULL, &t);
return php_select(poller->max_fd + 1, &poller->active.rfds, &poller->active.wfds, NULL, tv);
} /* }}} */
static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, void *opaque, int(*callback)(void *, int fd, int events)) /* {{{ */
@ -2043,7 +1973,7 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
{
php_cli_server_chunk *chunk;
smart_str buffer = { 0 };
const char *mime_type = get_mime_type(client->request.ext, client->request.ext_len);
const char *mime_type = get_mime_type(server, client->request.ext, client->request.ext_len);
if (!mime_type) {
mime_type = "application/octet-stream";
}
@ -2203,9 +2133,28 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client
}
/* }}} */
static int php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_server_ext_mime_type_pair *mime_type_map) /* {{{ */
{
const php_cli_server_ext_mime_type_pair *pair;
zend_hash_init(&server->extension_mime_types, 0, NULL, NULL, 1);
for (pair = mime_type_map; pair->ext; pair++) {
size_t ext_len = 0, mime_type_len = 0;
ext_len = strlen(pair->ext);
mime_type_len = strlen(pair->mime_type);
zend_hash_str_add_mem(&server->extension_mime_types, pair->ext, ext_len, (void*)pair->mime_type, mime_type_len + 1);
}
return SUCCESS;
} /* }}} */
static void php_cli_server_dtor(php_cli_server *server TSRMLS_DC) /* {{{ */
{
zend_hash_destroy(&server->clients);
zend_hash_destroy(&server->extension_mime_types);
if (server->server_sock >= 0) {
closesocket(server->server_sock);
}
@ -2325,6 +2274,11 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c
server->router_len = 0;
}
if (php_cli_server_mime_type_ctor(server, mime_type_map) == FAILURE) {
retval = FAILURE;
goto out;
}
server->is_running = 1;
out:
if (retval != SUCCESS) {
@ -2476,7 +2430,7 @@ static int php_cli_server_do_event_loop(php_cli_server *server TSRMLS_DC) /* {{{
{
int retval = SUCCESS;
while (server->is_running) {
static const struct timeval tv = { 1, 0 };
struct timeval tv = { 1, 0 };
int n = php_cli_server_poller_poll(&server->poller, &tv);
if (n > 0) {
php_cli_server_do_event_for_each_fd(server,

View file

@ -48,7 +48,7 @@ foo.html => Content-Type: text/html; charset=UTF-8
foo.htm => Content-Type: text/html; charset=UTF-8
foo.svg => Content-Type: image/svg+xml
foo.css => Content-Type: text/css; charset=UTF-8
foo.js => Content-Type: text/javascript; charset=UTF-8
foo.js => Content-Type: application/javascript
foo.png => Content-Type: image/png
foo.webm => Content-Type: video/webm
foo.ogv => Content-Type: video/ogg

View file

@ -2,4 +2,5 @@
phpdbg
*.lo
*.o
*.output
build

View file

@ -8,14 +8,17 @@ $(BUILD_SHARED): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS)
$(BUILD_BINARY): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS)
$(BUILD_PHPDBG)
$(builddir)/sapi/phpdbg/phpdbg_lexer.lo: $(srcdir)/sapi/phpdbg/phpdbg_parser.h
%.c: %.y
%.c: %.l
$(srcdir)/sapi/phpdbg/phpdbg_lexer.c: $(srcdir)/sapi/phpdbg/phpdbg_lexer.l
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l)
$(builddir)/phpdbg_lexer.lo: $(srcdir)/phpdbg_parser.h
$(srcdir)/sapi/phpdbg/phpdbg_parser.h: $(srcdir)/sapi/phpdbg/phpdbg_parser.c
$(srcdir)/sapi/phpdbg/phpdbg_parser.c: $(srcdir)/sapi/phpdbg/phpdbg_parser.y
@$(YACC) -p phpdbg_ -v -d $(srcdir)/sapi/phpdbg/phpdbg_parser.y -o $@
$(srcdir)/phpdbg_lexer.c: $(srcdir)/phpdbg_lexer.l
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo $(srcdir)/phpdbg_lexer.c $(srcdir)/phpdbg_lexer.l)
$(srcdir)/phpdbg_parser.h: $(srcdir)/phpdbg_parser.c
$(srcdir)/phpdbg_parser.c: $(srcdir)/phpdbg_parser.y
@$(YACC) -p phpdbg_ -v -d $(srcdir)/phpdbg_parser.y -o $@
install-phpdbg: $(BUILD_BINARY)
@echo "Installing phpdbg binary: $(INSTALL_ROOT)$(bindir)/"

View file

@ -28,7 +28,7 @@ if test "$PHP_PHPDBG" != "no"; then
PHP_SUBST(PHP_PHPDBG_FILES)
PHP_SUBST(PHPDBG_EXTRA_LIBS)
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag])
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag], [$abs_srcdir/sapi/phpdbg], [$abs_builddir/sapi/phpdbg])
PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)])
BUILD_BINARY="sapi/phpdbg/phpdbg"

View file

@ -69,11 +69,14 @@
# include <readline/history.h>
#endif
#include "phpdbg_lexer.h"
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
#include "phpdbg_btree.h"
#include "phpdbg_watch.h"
int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
#ifdef ZTS
# define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v)
#else
@ -176,10 +179,12 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
phpdbg_frame_t frame; /* frame */
zend_uint last_line; /* last executed line */
phpdbg_lexer_data lexer; /* lexer data */
phpdbg_param_t *parser_stack; /* param stack during lexer / parser phase */
#ifndef _WIN32
struct sigaction old_sigsegv_signal; /* segv signal handler */
#endif
phpdbg_btree watchpoint_tree; /* tree with watchpoints */
phpdbg_btree watch_HashTables; /* tree with original dtors of watchpoints */
HashTable watchpoints; /* watchpoints */

File diff suppressed because it is too large Load diff

View file

@ -1,348 +1,41 @@
#ifndef yyHEADER_H
#define yyHEADER_H 1
#define yyIN_HEADER 1
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Felipe Pena <felipe@php.net> |
| Authors: Joe Watkins <joe.watkins@live.co.uk> |
| Authors: Bob Weinand <bwoebi@php.net> |
+----------------------------------------------------------------------+
*/
#line 6 "sapi/phpdbg/phpdbg_lexer.h"
#ifndef PHPDBG_LEXER_H
#define PHPDBG_LEXER_H
#line 8 "sapi/phpdbg/phpdbg_lexer.h"
#include "phpdbg_cmd.h"
#define YY_INT_ALIGNED short int
typedef struct {
unsigned int len;
unsigned char *text;
unsigned char *cursor;
unsigned char *marker;
int state;
} phpdbg_lexer_data;
/* A lexical scanner generated by flex */
#define yyparse phpdbg_parse
#define yylex phpdbg_lex
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 37
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
void phpdbg_init_lexer (phpdbg_param_t *stack, char *input TSRMLS_DC);
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
/* end standard C headers. */
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST
#else /* ! __cplusplus */
/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)
#define YY_USE_CONST
#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif
/* For convenience, these vars (plus the bison vars far below)
are macros in the reentrant scanner. */
#define yyin yyg->yyin_r
#define yyout yyg->yyout_r
#define yyextra yyg->yyextra_r
#define yyleng yyg->yyleng_r
#define yytext yyg->yytext_r
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE 16384
#endif
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
void yyrestart (FILE *input_file ,yyscan_t yyscanner );
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
void yypop_buffer_state (yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
void *yyalloc (yy_size_t ,yyscan_t yyscanner );
void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
void yyfree (void * ,yyscan_t yyscanner );
/* Begin user sect3 */
#define yywrap(yyscanner) 1
#define YY_SKIP_YYWRAP
#define yytext_ptr yytext_r
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
#define INITIAL 0
#define RAW 1
#define NORMAL 2
int phpdbg_lex (phpdbg_param_t* yylval);
#endif
#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
* down here because we want the user's section 1 to have been scanned first.
* The user has a chance to override it with an option.
*/
#include <unistd.h>
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
int yylex_init (yyscan_t* scanner);
int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
int yylex_destroy (yyscan_t yyscanner );
int yyget_debug (yyscan_t yyscanner );
void yyset_debug (int debug_flag ,yyscan_t yyscanner );
YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner );
void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
FILE *yyget_in (yyscan_t yyscanner );
void yyset_in (FILE * in_str ,yyscan_t yyscanner );
FILE *yyget_out (yyscan_t yyscanner );
void yyset_out (FILE * out_str ,yyscan_t yyscanner );
yy_size_t yyget_leng (yyscan_t yyscanner );
char *yyget_text (yyscan_t yyscanner );
int yyget_lineno (yyscan_t yyscanner );
void yyset_lineno (int line_number ,yyscan_t yyscanner );
int yyget_column (yyscan_t yyscanner );
void yyset_column (int column_no ,yyscan_t yyscanner );
YYSTYPE * yyget_lval (yyscan_t yyscanner );
void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap (yyscan_t yyscanner );
#else
extern int yywrap (yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
#endif
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
extern int yylex \
(YYSTYPE * yylval_param ,yyscan_t yyscanner);
#define YY_DECL int yylex \
(YYSTYPE * yylval_param , yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
#undef YY_NEW_FILE
#undef YY_FLUSH_BUFFER
#undef yy_set_bol
#undef yy_new_buffer
#undef yy_set_interactive
#undef YY_DO_BEFORE_ACTION
#ifdef YY_DECL_IS_OURS
#undef YY_DECL_IS_OURS
#undef YY_DECL
#endif
#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l"
#line 347 "sapi/phpdbg/phpdbg_lexer.h"
#undef yyIN_HEADER
#endif /* yyHEADER_H */

View file

@ -1,131 +1,169 @@
%{
/*
* phpdbg_lexer.l
*/
#include "phpdbg.h"
#include "phpdbg_cmd.h"
#define YYSTYPE phpdbg_param_t
#include "phpdbg_parser.h"
%}
#define LEX(v) (PHPDBG_G(lexer).v)
%s RAW
%s NORMAL
#define YYCTYPE unsigned char
#define YYSETCONDITION(x) LEX(state) = x;
#define YYGETCONDITION() LEX(state)
#define YYCURSOR LEX(cursor)
#define YYMARKER LEX(marker)
#define yyleng LEX(len)
#define yytext ((char*) LEX(text))
#undef YYDEBUG
#define YYDEBUG(a, b)
#define YYFILL(n)
%option outfile="sapi/phpdbg/phpdbg_lexer.c" header-file="sapi/phpdbg/phpdbg_lexer.h"
%option warn nodefault
%option reentrant noyywrap never-interactive nounistd
%option bison-bridge
#define NORMAL 0
#define RAW 1
#define INITIAL 2
T_TRUE "true"
T_YES "yes"
T_ON "on"
T_ENABLED "enabled"
T_FALSE "false"
T_NO "no"
T_OFF "off"
T_DISABLED "disabled"
T_EVAL "ev"
T_SHELL "sh"
T_IF "if"
T_RUN "run"
T_RUN_SHORT "r"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
WS [ \r\n\t]+
DIGITS [0-9\.]+
ID [^ \r\n\t:#]+
ADDR 0x[a-fA-F0-9]+
OPCODE (ZEND_|zend_)([A-Za-z])+
INPUT [^\n]+
%%
void phpdbg_init_lexer (phpdbg_param_t *stack, char *input TSRMLS_DC) {
PHPDBG_G(parser_stack) = stack;
<INITIAL>{
{T_EVAL} {
BEGIN(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_EVAL;
}
{T_SHELL} {
BEGIN(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_SHELL;
}
{T_RUN}|{T_RUN_SHORT} {
BEGIN(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_RUN;
}
YYSETCONDITION(INITIAL);
.+ {
BEGIN(NORMAL);
REJECT;
}
LEX(text) = YYCURSOR = (unsigned char *) input;
LEX(len) = strlen(input);
}
<NORMAL>{
{T_IF} {
BEGIN(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_IF;
}
int phpdbg_lex (phpdbg_param_t* yylval) {
TSRMLS_FETCH(); /* Slow, but this is not a major problem here. TODO: Use TSRMLS_DC */
restart:
LEX(text) = YYCURSOR;
/*!re2c
re2c:yyfill:check = 0;
T_TRUE "true"
T_YES "yes"
T_ON "on"
T_ENABLED "enabled"
T_FALSE "false"
T_NO "no"
T_OFF "off"
T_DISABLED "disabled"
T_EVAL "ev"
T_SHELL "sh"
T_IF "if"
T_RUN "run"
T_RUN_SHORT "r"
WS [ \r\n\t]+
DIGITS [0-9\.]+
ID [^ \r\n\t:#\000]+
ADDR [0][x][a-fA-F0-9]+
OPCODE (ZEND_|zend_)([A-Za-z])+
INPUT [^\n\000]+
<!*> := yyleng = (size_t) YYCURSOR - (size_t) yytext;
<*>[\n\000] {
return 0;
}
<INITIAL,NORMAL>{
{ID}[:]{1}[//]{2} {
phpdbg_init_param(yylval, STR_PARAM);
yylval->str = zend_strndup(yytext, yyleng);
yylval->len = yyleng;
return T_PROTO;
}
[#]{1} { return T_POUND; }
[:]{2} { return T_DCOLON; }
[:]{1} { return T_COLON; }
{T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = 1;
return T_TRUTHY;
}
{T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = 0;
return T_FALSY;
}
{DIGITS} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = atoi(yytext);
return T_DIGITS;
}
{ADDR} {
phpdbg_init_param(yylval, ADDR_PARAM);
yylval->addr = strtoul(yytext, 0, 16);
return T_ADDR;
}
{OPCODE} {
phpdbg_init_param(yylval, OP_PARAM);
yylval->str = zend_strndup(yytext, yyleng);
yylval->len = yyleng;
return T_OPCODE;
}
{ID} {
phpdbg_init_param(yylval, STR_PARAM);
yylval->str = zend_strndup(yytext, yyleng);
yylval->len = yyleng;
return T_ID;
}
<NORMAL>{T_IF} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_IF;
}
<RAW>{INPUT} {
<NORMAL>{ID}[:]{1}[//]{2} {
phpdbg_init_param(yylval, STR_PARAM);
yylval->str = zend_strndup(yytext, yyleng);
yylval->len = yyleng;
return T_PROTO;
}
<NORMAL>[#]{1} {
return T_POUND;
}
<NORMAL>[:]{2} {
return T_DCOLON;
}
<NORMAL>[:]{1} {
return T_COLON;
}
<NORMAL>{T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = 1;
return T_TRUTHY;
}
<NORMAL>{T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = 0;
return T_FALSY;
}
<NORMAL>{DIGITS} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = atoi(yytext);
return T_DIGITS;
}
<NORMAL>{ADDR} {
phpdbg_init_param(yylval, ADDR_PARAM);
yylval->addr = strtoul(yytext, 0, 16);
return T_ADDR;
}
<NORMAL>{OPCODE} {
phpdbg_init_param(yylval, OP_PARAM);
yylval->str = zend_strndup(yytext, yyleng);
yylval->len = yyleng;
return T_OPCODE;
}
<NORMAL>{ID} {
phpdbg_init_param(yylval, STR_PARAM);
yylval->str = zend_strndup(yytext, yyleng);
yylval->len = yyleng;
return T_ID;
}
<RAW>{INPUT} {
phpdbg_init_param(yylval, STR_PARAM);
yylval->str = zend_strndup(yytext, yyleng);
yylval->len = yyleng;
BEGIN(INITIAL);
return T_INPUT;
}
{WS} { /* ignore whitespace */ }
%%
<*>{WS} {
/* ignore whitespace */
goto restart;
}
<INITIAL>{T_EVAL} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_EVAL;
}
<INITIAL>{T_SHELL} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_SHELL;
}
<INITIAL>{T_RUN}|{T_RUN_SHORT} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_RUN;
}
<INITIAL>. {
YYSETCONDITION(NORMAL);
YYCURSOR = LEX(text);
goto restart;
}
*/
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.7. */
/* A Bison parser, made by GNU Bison 2.6.2. */
/* Bison interface for Yacc-like parsers in C
@ -30,18 +30,18 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED
# define YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED
#ifndef PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H
# define PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
extern int phpdbg_debug;
#endif
/* "%code requires" blocks. */
/* Line 2058 of yacc.c */
#line 40 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y"
/* Line 2055 of yacc.c */
#line 31 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
#include "phpdbg.h"
#ifndef YY_TYPEDEF_YY_SCANNER_T
@ -50,7 +50,7 @@ typedef void* yyscan_t;
#endif
/* Line 2058 of yacc.c */
/* Line 2055 of yacc.c */
#line 55 "sapi/phpdbg/phpdbg_parser.h"
/* Tokens. */
@ -111,16 +111,16 @@ typedef int YYSTYPE;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
int phpdbg_parse (void *YYPARSE_PARAM);
#else
int yyparse ();
int phpdbg_parse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (phpdbg_param_t *stack, yyscan_t scanner);
int phpdbg_parse (void *tsrm_ls);
#else
int yyparse ();
int phpdbg_parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */
#endif /* !PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H */

View file

@ -1,4 +1,3 @@
%error-verbose
%{
/*
@ -19,23 +18,15 @@
#include "phpdbg_parser.h"
#include "phpdbg_lexer.h"
#undef yyerror
static int yyerror(void ***tsrm_ls, const char *msg);
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) {
TSRMLS_FETCH();
phpdbg_error("Parse Error: %s", msg);
{
const phpdbg_param_t *top = stack;
while (top) {
phpdbg_param_debug(
top, "--> ");
top = top->next;
}
}
return 0;
}
%}
%pure-parser
%error-verbose
%code requires {
#include "phpdbg.h"
@ -44,59 +35,58 @@ int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) {
typedef void* yyscan_t;
#endif
}
%parse-param { void *tsrm_ls }
%output "sapi/phpdbg/phpdbg_parser.c"
%defines "sapi/phpdbg/phpdbg_parser.h"
%define api.pure
%lex-param { yyscan_t scanner }
%parse-param { phpdbg_param_t *stack }
%parse-param { yyscan_t scanner }
%token T_EVAL "eval"
%token T_RUN "run"
%token T_SHELL "shell"
%token T_IF "if (condition)"
%token T_TRUTHY "truthy (true, on, yes or enabled)"
%token T_FALSY "falsy (false, off, no or disabled)"
%token T_STRING "string (some input, perhaps)"
%token T_COLON ": (colon)"
%token T_DCOLON ":: (double colon)"
%token T_POUND "# (pound sign)"
%token T_PROTO "protocol (file://)"
%token T_DIGITS "digits (numbers)"
%token T_LITERAL "literal (string)"
%token T_ADDR "address"
%token T_OPCODE "opcode"
%token T_ID "identifier (command or function name)"
%token T_INPUT "input (input string or data)"
%token T_UNEXPECTED "input"
%%
%token T_EVAL "eval"
%token T_RUN "run"
%token T_SHELL "shell"
%token T_IF "if (condition)"
%token T_TRUTHY "truthy (true, on, yes or enabled)"
%token T_FALSY "falsy (false, off, no or disabled)"
%token T_STRING "string (some input, perhaps)"
%token T_COLON ": (colon)"
%token T_DCOLON ":: (double colon)"
%token T_POUND "# (pound sign)"
%token T_PROTO "protocol (file://)"
%token T_DIGITS "digits (numbers)"
%token T_LITERAL "literal (string)"
%token T_ADDR "address"
%token T_OPCODE "opcode"
%token T_ID "identifier (command or function name)"
%token T_INPUT "input (input string or data)"
%token T_UNEXPECTED "input"
%% /* Rules */
input
: parameters
| /* nothing */
;
: parameters
| full_expression { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); }
| /* nothing */
;
parameters
: parameter { phpdbg_stack_push(stack, &$1); }
| parameters parameter { phpdbg_stack_push(stack, &$2); }
: parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); }
| parameters parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$2); }
;
parameter
: T_ID T_COLON T_DIGITS {
: T_ID T_COLON T_DIGITS {
$$.type = FILE_PARAM;
$$.file.name = $2.str;
$$.file.line = $3.num;
}
| T_ID T_COLON T_POUND T_DIGITS {
| T_ID T_COLON T_POUND T_DIGITS {
$$.type = NUMERIC_FILE_PARAM;
$$.file.name = $1.str;
$$.file.line = $4.num;
}
| T_PROTO T_ID T_COLON T_DIGITS {
| T_PROTO T_ID T_COLON T_DIGITS {
$$.type = FILE_PARAM;
$$.file.name = malloc($1.len +
$2.len + 1);
$$.file.name = malloc($1.len + $2.len + 1);
if ($$.file.name) {
memcpy(&$$.file.name[0], $1.str, $1.len);
memcpy(&$$.file.name[$1.len], $2.str, $2.len);
@ -104,10 +94,9 @@ parameter
}
$$.file.line = $4.num;
}
| T_PROTO T_ID T_COLON T_POUND T_DIGITS {
| T_PROTO T_ID T_COLON T_POUND T_DIGITS {
$$.type = NUMERIC_FILE_PARAM;
$$.file.name = malloc($1.len +
$2.len + 1);
$$.file.name = malloc($1.len + $2.len + 1);
if ($$.file.name) {
memcpy(&$$.file.name[0], $1.str, $1.len);
memcpy(&$$.file.name[$1.len], $2.str, $2.len);
@ -115,54 +104,81 @@ parameter
}
$$.file.line = $5.num;
}
| T_ID T_DCOLON T_ID {
| T_ID T_DCOLON T_ID {
$$.type = METHOD_PARAM;
$$.method.class = $1.str;
$$.method.name = $3.str;
}
| T_ID T_DCOLON T_ID T_POUND T_DIGITS {
| T_ID T_DCOLON T_ID T_POUND T_DIGITS {
$$.type = NUMERIC_METHOD_PARAM;
$$.method.class = $1.str;
$$.method.name = $3.str;
$$.num = $5.num;
}
| T_ID T_POUND T_DIGITS {
| T_ID T_POUND T_DIGITS {
$$.type = NUMERIC_FUNCTION_PARAM;
$$.str = $1.str;
$$.len = $1.len;
$$.num = $3.num;
}
| T_IF T_INPUT {
| T_OPCODE { $$ = $1; }
| T_ADDR { $$ = $1; }
| T_LITERAL { $$ = $1; }
| T_TRUTHY { $$ = $1; }
| T_FALSY { $$ = $1; }
| T_DIGITS { $$ = $1; }
| T_ID { $$ = $1; }
;
full_expression
: T_IF T_INPUT {
$$.type = COND_PARAM;
$$.str = $2.str;
$$.len = $2.len;
}
| T_EVAL T_INPUT {
| T_EVAL T_INPUT {
$$.type = EVAL_PARAM;
$$.str = $2.str;
$$.len = $2.len;
}
| T_SHELL T_INPUT {
| T_SHELL T_INPUT {
$$.type = SHELL_PARAM;
$$.str = $2.str;
$$.len = $2.len;
}
| T_RUN {
| T_RUN {
$$.type = RUN_PARAM;
$$.len = 0;
}
| T_RUN T_INPUT {
| T_RUN T_INPUT {
$$.type = RUN_PARAM;
$$.str = $2.str;
$$.len = $2.len;
}
| T_OPCODE { $$ = $1; }
| T_ADDR { $$ = $1; }
| T_LITERAL { $$ = $1; }
| T_TRUTHY { $$ = $1; }
| T_FALSY { $$ = $1; }
| T_DIGITS { $$ = $1; }
| T_ID { $$ = $1; }
;
%%
static int yyerror(void ***tsrm_ls, const char *msg) {
phpdbg_error("Parse Error: %s", msg);
{
const phpdbg_param_t *top = PHPDBG_G(parser_stack);
while (top) {
phpdbg_param_debug(top, "--> ");
top = top->next;
}
}
return 0;
}
int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC) {
phpdbg_init_lexer(stack, input TSRMLS_CC);
#ifdef ZTS
return yyparse(TSRMLS_C);
#else
return yyparse(NULL);
#endif
}

View file

@ -38,8 +38,6 @@
#include "phpdbg_lexer.h"
#include "phpdbg_parser.h"
int yyparse(phpdbg_param_t *stack, yyscan_t scanner);
/* {{{ command declarations */
const phpdbg_command_t phpdbg_prompt_commands[] = {
PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, "s"),
@ -248,20 +246,10 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_
char *why = NULL;
char *input = phpdbg_read_input(cmd TSRMLS_CC);
phpdbg_param_t stack;
yyscan_t scanner;
YY_BUFFER_STATE state;
phpdbg_init_param(&stack, STACK_PARAM);
if (yylex_init(&scanner)) {
phpdbg_error(
"could not initialize scanner");
break;
}
state = yy_scan_string(input, scanner);
if (yyparse(&stack, scanner) <= 0) {
if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) {
switch (phpdbg_stack_execute(&stack, &why TSRMLS_CC)) {
case FAILURE:
// if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
@ -274,15 +262,12 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_
break;
}
}
if (why) {
free(why);
why = NULL;
}
yy_delete_buffer(state, scanner);
yylex_destroy(scanner);
phpdbg_stack_free(&stack);
phpdbg_destroy_input(&input TSRMLS_CC);
}
@ -1014,20 +999,9 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
if (input) {
do {
yyscan_t scanner;
YY_BUFFER_STATE state;
phpdbg_init_param(&stack, STACK_PARAM);
if (yylex_init(&scanner)) {
phpdbg_error(
"could not initialize scanner");
return FAILURE;
}
state = yy_scan_string(input, scanner);
if (yyparse(&stack, scanner) <= 0) {
if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) {
switch (ret = phpdbg_stack_execute(&stack, &why TSRMLS_CC)) {
case FAILURE:
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
@ -1061,9 +1035,6 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
why = NULL;
}
yy_delete_buffer(state, scanner);
yylex_destroy(scanner);
phpdbg_stack_free(&stack);
phpdbg_destroy_input(&input TSRMLS_CC);

View file

@ -1,6 +1,7 @@
#!/usr/bin/env sh
git clone https://github.com/php/php-src
cd php-src/sapi
rm -rf phpdbg
git clone https://github.com/krakjoe/phpdbg.git
cd ../
./buildconf --force

View file

@ -1,2 +0,0 @@
@echo off
cscript /nologo win32\build\cvsclean.js

View file

@ -47,5 +47,6 @@ $TS \
--with-bz2 \
--with-openssl \
--with-gmp \
--enable-bcmath
--enable-bcmath \
--enable-phpdbg
make --quiet

View file

@ -1,10 +1,6 @@
#! /bin/sh
if test -d 'CVS'; then
${MAKE:-make} -f build/build.mk cvsclean-work
elif test -d '.svn'; then
${MAKE:-make} -f build/build.mk svnclean-work
elif test -d '.git'; then
if test -d '.git'; then
${MAKE:-make} -f build/build.mk gitclean-work
else
echo "Can't figure out your VCS, not cleaning."

View file

@ -1,120 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
| Pierre A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
// Cleans up files that do not belong in the repository
var FSO = WScript.CreateObject("Scripting.FileSystemObject");
var WshShell = WScript.CreateObject("WScript.Shell");
var STDOUT = WScript.StdOut;
/* svn propget svn:ignore dirname */
function find_ignore(dirname)
{
dirname = "" + dirname;
dirname_len = dirname.length;
if (!FSO.FolderExists(dirname) || (dirname_len >= 4 &&
dirname.substring(dirname_len - 4) == ".svn")) {
return;
}
var f = FSO.GetFolder(dirname);
var fc = new Enumerator(f.SubFolders);
for (; !fc.atEnd(); fc.moveNext()) {
find_ignore(fc.item());
}
kill_from_ignore(dirname);
}
/* recursive remove using ignore props style wildcard matching;
* note that FSO.DeleteFolder and FSO.DeleteFile methods both
* accept wildcards, but that they are dangerous to use eg:
* "*.php" will match "*.phpt" */
function rm_r(filename)
{
if (FSO.FolderExists(filename)) {
var fc = new Enumerator(FSO.GetFolder(filename).SubFolders);
for (; !fc.atEnd(); fc.moveNext()) {
rm_r(fc.item());
}
fc = new Enumerator(FSO.GetFolder(filename).Files);
for (; !fc.atEnd(); fc.moveNext()) {
FSO.DeleteFile(fc.item(), true);
}
FSO.DeleteFolder(filename, true);
} else if (FSO.FileExists(filename)) {
FSO.DeleteFile(filename, true);
} else {
/* we need to handle wildcards here */
var foldername = FSO.GetParentFolderName(filename);
if (foldername == "")
foldername = ".";
var filename = FSO.GetFileName(filename);
var retext = filename.replace(/\./g, '\\.');
retext = '^' + retext.replace(/\*/g, '.*') + "$";
var re = new RegExp(retext);
var folder = FSO.GetFolder(foldername);
var fc = new Enumerator(folder.SubFolders);
for (; !fc.atEnd(); fc.moveNext()) {
var item = FSO.GetFileName(fc.item());
if (item.match(re)) {
rm_r(fc.item());
}
}
var fc = new Enumerator(folder.Files);
for (; !fc.atEnd(); fc.moveNext()) {
item = FSO.GetFileName(fc.item());
if (item.match(re)) {
FSO.DeleteFile(fc.item(), true);
}
}
}
}
function kill_from_ignore(dirname)
{
var l;
var e = WshShell.Exec("svn propget svn:ignore " + dirname);
var re = /^(config\.nice.*)|(\*)$/i;
while (!e.StdOut.atEndOfStream) {
l = e.StdOut.ReadLine();
if (l.length == 0 || re.test(l)) {
continue;
}
rm_r(dirname + l);
}
}
find_ignore(".");

View file

@ -1,120 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
| Pierre A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
// Cleans up files that do not belong in the repository
var FSO = WScript.CreateObject("Scripting.FileSystemObject");
var WshShell = WScript.CreateObject("WScript.Shell");
var STDOUT = WScript.StdOut;
/* svn propget svn:ignore dirname */
function find_ignore(dirname)
{
dirname = "" + dirname;
dirname_len = dirname.length;
if (!FSO.FolderExists(dirname) || (dirname_len >= 4 &&
dirname.substring(dirname_len - 4) == ".svn")) {
return;
}
var f = FSO.GetFolder(dirname);
var fc = new Enumerator(f.SubFolders);
for (; !fc.atEnd(); fc.moveNext()) {
find_ignore(fc.item());
}
kill_from_ignore(dirname);
}
/* recursive remove using ignore props style wildcard matching;
* note that FSO.DeleteFolder and FSO.DeleteFile methods both
* accept wildcards, but that they are dangerous to use eg:
* "*.php" will match "*.phpt" */
function rm_r(filename)
{
if (FSO.FolderExists(filename)) {
var fc = new Enumerator(FSO.GetFolder(filename).SubFolders);
for (; !fc.atEnd(); fc.moveNext()) {
rm_r(fc.item());
}
fc = new Enumerator(FSO.GetFolder(filename).Files);
for (; !fc.atEnd(); fc.moveNext()) {
FSO.DeleteFile(fc.item(), true);
}
FSO.DeleteFolder(filename, true);
} else if (FSO.FileExists(filename)) {
FSO.DeleteFile(filename, true);
} else {
/* we need to handle wildcards here */
var foldername = FSO.GetParentFolderName(filename);
if (foldername == "")
foldername = ".";
var filename = FSO.GetFileName(filename);
var retext = filename.replace(/\./g, '\\.');
retext = '^' + retext.replace(/\*/g, '.*') + "$";
var re = new RegExp(retext);
var folder = FSO.GetFolder(foldername);
var fc = new Enumerator(folder.SubFolders);
for (; !fc.atEnd(); fc.moveNext()) {
var item = FSO.GetFileName(fc.item());
if (item.match(re)) {
rm_r(fc.item());
}
}
var fc = new Enumerator(folder.Files);
for (; !fc.atEnd(); fc.moveNext()) {
item = FSO.GetFileName(fc.item());
if (item.match(re)) {
FSO.DeleteFile(fc.item(), true);
}
}
}
}
function kill_from_ignore(dirname)
{
var l;
var e = WshShell.Exec("svn propget svn:ignore " + dirname);
var re = /^(config\.nice.*)|(\*)$/i;
while (!e.StdOut.atEndOfStream) {
l = e.StdOut.ReadLine();
if (l.length == 0 || re.test(l)) {
continue;
}
rm_r(dirname + l);
}
}
find_ignore(".");