Compare commits

..
2201 changed files with 84200 additions and 155268 deletions

No files matched your search

+1 -12
View File
@@ -273,18 +273,6 @@ document printzops
dump operands of the current opline
end
define zbacktrace
____executor_globals
dump_bt $eg.current_execute_data
end
document zbacktrace
prints backtrace.
This command is almost a short cut for
> (gdb) ____executor_globals
> (gdb) dump_bt $eg.current_execute_data
end
define zmemcheck
set $p = alloc_globals.head
set $stat = "?"
@@ -357,3 +345,4 @@ document zmemcheck
usage: zmemcheck [ptr].
if ptr is 0, all blocks will be listed.
end
+2 -21
View File
@@ -133,22 +133,7 @@ Naming Conventions
[5] Variable names should be in lowercase. Use underscores to separate
between words.
[6] Method names follow the 'studlyCaps' (also referred to as 'bumpy case'
or 'camel caps') naming convention, with care taken to minimize the
letter count. The initial letter of the name is lowercase, and each
letter that starts a new 'word' is capitalized.
Good:
'connect()'
'getData()'
'buildSomeWidget()'
Bad:
'get_Data()'
'buildsomewidget'
'getI()'
[7] Classes should be given descriptive names. Avoid using abbreviations
[6] Classes should be given descriptive names. Avoid using abbreviations
where possible. Each word in the class name should start with a capital
letter, with words underscore delimited. The class name should be prefixed
with the name of the 'parent set'.
@@ -183,7 +168,7 @@ Syntax and indentation
indentation and comment styles and up to function declaration
syntax.
(see also http://www.catb.org/~esr/jargon/html/I/indent-style.html)
(see also http://www.tuxedo.org/~esr/jargon/html/entry/indent-style.html)
[3] Be generous with whitespace and braces. Always prefer:
@@ -204,10 +189,6 @@ Syntax and indentation
four spaces. It is important to maintain consistency in indenture so
that definitions, comments, and control structures line up correctly.
[5] Preprocessor statements (#if and such) MUST start at column one. To
indent preprocessor directives you should put the # at the beginning
of a line, followed by any number of whitespace.
Documentation and Folding Hooks
-------------------------------
+28443 -18150
View File
File diff suppressed because it is too large. Load diff
BIN
View File
Binary file not shown.
+6 -12
View File
@@ -119,7 +119,8 @@ STATUS: Working
COMMENT: DBM abstraction for db2, db3, db4, dbm, ndbm, gdbm, ini
-------------------------------------------------------------------------------
EXTENSION: dbase
MAINTENANCE: Orphaned
PRIMARY MAINTAINER: Jim Winstead <jimw@php.net>
MAINTENANCE: Odd Fixes
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: dbx
@@ -197,8 +198,7 @@ MAINTENANCE: Unknown
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: oci8
PRIMARY MAINTAINER: Antony Dovgal <tony2001@php.net>
MAINTENANCE: Maintained
MAINTENANCE: Orphaned
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: odbc
@@ -220,13 +220,13 @@ COMMENT: Using the new OCI8 driver is encouraged where possible.
EXTENSION: dom
PRIMARY MAINTAINER: Christian Stocker <chregu@php.net>, Rob Richards <rrichards@php.net>, Marcus Boerger <helly@php.net>
MAINTENANCE: Maintained
STATUS: Working
STATUS: Experimental
SINCE: 5.0
-------------------------------------------------------------------------------
EXTENSION: simplexml
PRIMARY MAINTAINER: Sterling Hughes <sterling@php.net>
MAINTENANCE: Maintained
STATUS: Working
STATUS: Experimental
SINCE: 5.0
-------------------------------------------------------------------------------
EXTENSION: wddx
@@ -247,7 +247,7 @@ STATUS: Experimental
EXTENSION: xsl
PRIMARY MAINTAINER: Christian Stocker <chregu@php.net>, Rob Richards <rrichards@php.net>
MAINTENANCE: Maintained
STATUS: Working
STATUS: Experimental
SINCE: 5.0
-------------------------------------------------------------------------------
@@ -427,12 +427,6 @@ MAINTENANCE: Maintained
STATUS: Experimental
SINCE: 4.0.2
-------------------------------------------------------------------------------
EXTENSION: spl
PRIMARY MAINTAINER: Marcus Boerger <helly@php.net>
MAINTENANCE: Maintained
STATUS: Working
SINCE: 5.0.0
-------------------------------------------------------------------------------
EXTENSION: sysvmsg
MAINTENANCE: Unknown
STATUS: Unknown
+379 -1298
View File
File diff suppressed because it is too large. Load diff
+19 -372
View File
@@ -1,358 +1,5 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2004, PHP 5.1.0
- Allow gettimeofday() return a float if optional argument is specified. (Ilia)
- Added sqlite_fetch_column_types() 3rd argument for arrays. (Ilia)
- Added optional offset parameter to stream_get_contents() and
file_get_contents(). (Ilia)
- Improved performance of:
. general execution/compilation. (Andi, Thies, Sterling, Dmitry, Marcus)
. switch statement. (Dmitry)
. several array functions. (Marcus)
. virtual path handling by adding a realpath() cache. (Andi)
. variable fetches. (Andi)
. magic method invocations. (Marcus)
- Removed garbage manager in Zend Engine which results in more aggressive
freeing of data. (Dmitry, Andi)
- Implemented access to INI variables from within .ini file. (Andrei)
- PHP will now respect extension dependencies when initializing. (Wez)
- Added SAPI hook to get the current request time. (Rasmus)
- Added new functions:
. array_diff_key() (Andrey)
. array_diff_ukey() (Andrey)
. array_intersect_key() (Christiano Duarte)
. array_intersect_ukey() (Christiano Duarte)
. stream_context_get_default() (Wez)
. stream_socket_enable_crypto() (Wez)
. stream_wrapper_unregister() (Sara)
. stream_wrapper_restore() (Sara)
. stream_filter_remove() (Sara)
. DomDocumentFragment::appendXML() (Christian)
. SimpleXMLElement::registerXPathNamespace() (Christian)
. mysqli::client_info property (Georg)
. inet_pton() (Sara)
. inet_ntop() (Sara)
. fputcsv() (David Sklar)
- Added DomDocument::$recover property for parsing not well-formed
XML Documents. (Christian)
- Added Cursor support for MySQL 5.0.x in mysqli (Georg)
- Added proxy support to ftp wrapper via http. (Sara)
- Added MDTM support to ftp_url_stat. (Sara)
- Added zlib stream filter support. (Sara)
- Added bz2 stream filter support. (Sara)
- Added HTTP/1.1 and chunked encoding support to http:// wrapper. (Sara)
- Added support of parameter=>value arrays to xsl_xsltprocessor_set_parameter()
(Tony)
- Changed stream_filter_(ap|pre)pend() to return resource. (Sara)
- Fixed bug with raw_post_data not getting set. (Brian)
- Fixed bug in mysql::client_version(). (Georg)
- Fixed ZTS destruction. (Marcus)
- Fixed bug #29728 (Reflection API Feature: Default parameter value). (Marcus)
- Fixed bug #29522 (accessing properties without connection). (Georg)
- Fixed bug #29335 (fetch functions now use MYSQLI_BOTH as default). (Georg)
- Fixed bug #29311 (calling parent constructor in mysqli). (Georg)
- Fixed bug #29256 (SOAP HTTP Error when envelop size is more than 24345 bytes)
(Dmitry, Wez)
- Fixed bug #29236 (memory error when wsdl-cache is enabled). (Dmitry)
- Fixed bug #29109 (SoapFault exception: [WSDL] Out of memory). (Dmitry)
- Fixed bug #29061 (soap extension segfaults). (Dmitry)
- Fixed bug #28985 (__getTypes() returning nothing on complex WSDL). (Dmitry)
- Fixed bug #28969 (Wrong data encoding of special characters). (Dmitry)
13 Jul 2004, PHP 5.0.0
- Rewritten UNIX and Windows install help files. (Documentation Team)
- Updated PCRE to provide better error handling in certain cases. (Andrei)
- Changed doc comments to require a single white space after '/**'. (Marcus)
- Fixed bug #29019 (Database not closing). (Marcus)
- Fixed bug #29008 (array_combine() does not handle non-numeric/string keys).
(Ilia)
- Fixed bug #28999 (fixed behaviour of exec() to work as it did in 4.X). (Ilia)
- Fixed bug #28895 (ReflectionClass::isAbstract always returns false). (Marcus)
- Fixed bug #28868 (Internal filter registry not thread safe). (Sara)
- Fixed bug #28851 (call_user_func_array has typo in error message). (Marcus)
- Fixed bug #28831 (ArrayObject::offsetGet() does the work of offsetUnset()).
(Marcus)
- Fixed bug #28822 (ArrayObject::offsetExists() works inverted). (Marcus)
- Fixed bug #28789 (ReflectionProperty getValue() fails on public static
members). (Marcus)
- Fixed bug #28771 (Segfault when using xslt and clone). (Rob)
- Fixed bug #28751 (SoapServer does not call _autoload()). (Dmitry)
- Fixed bug #28739 (array_*diff() and array_*intersect() not clearing the fci
cache before work). (Andrey)
- Fixed bug #28721 (appendChild() and insertBefore() unset DOMText).(Rob)
- Fixed bug #28702 (SOAP does not parse WSDL service address correctly). (Dmitry)
- Fixed bug #28699 (Reflection api bugs). (Marcus)
- Fixed bug #28694 (ReflectionExtension::getFunctions() crashes PHP). (Marcus)
- Fixed bug #28512 (Allocate enough space to store MSSQL data). (Frank)
- Fixed bug #28325 (Circular references not properly serialised). (Moriyoshi)
- Fixed strip_tags() to correctly handle '\0' characters. (Stefan)
7 Jun 2004, PHP 5 Release Candidate 3
- Moved the PDFLib extension to PECL. (Wez)
- Added MySQL 4.1.2-alpha and 4.1.3-beta support to MySQLI extension. (Georg)
- Added support for dumping private/protected properties to var_dump().
(Andrey)
- Added count() support for COM arrays. (Wez)
- Added Firebird/InterBase UDF source that allows PHP functions to be called
from SQL (Ard)
- Removed Firebird/Interbase function ibase_timefmt() (Ard)
- Changed user error handler mechanism to relay to built-in error handler if it
returns false. (Andrei)
- Changed class type hints for function parameters to not allow the passing of
NULL values. (Andi)
- Changed tidy_node to tidyNode and removed tidy_exception. (John)
- Fixed ip2long() to return FALSE if an IP address passed to this function
is not valid. (Derick)
- Fixed memory leak in memory manager. (Andi)
- Fixed problem with exceptions returning from include(). (Dmitry)
- Fixed bug #28641 (Instance of Interface). (Marcus)
- Fixed bug #28430 (Extending mysqli class). (Georg)
- Fixed bug #28311 (Transparency detection code is off by 1).
(Ilia, pikeman at pikeman dot sytes dot net)
- Fixed bug #28304 (Missing bounds check inside imagefilter()). (Ilia)
- Fixed bug #28300 (Userspace stream/filter names forced to lowercase). (Sara)
- Fixed bug #28287 (stream_*_register() not calling __autoload()). (Sara)
- Fixed bug #28267 (php_image_filter_contrast calls gdImageBrightness). (Ilia)
- Fixed bug #28239 (No results returned on SOAP call, no error given). (Dmitry)
- Fixed bug #28205 (num_rows property for statement object). (Georg)
- Fixed bug #28161 (COM: Array style properties could not be accessed). (Wez)
- Fixed bug #28125 (ArrayObject leaks when accessing elements). (Marcus)
- Fixed bug #28100 (NULL parameter support for mysqli_ssl_set). (Georg)
- Fixed bug #28099 (ArrayObject doesn't implement ArrayAccess). (Marcus)
- Fixed bug #27929 (SPL: change visibility of ArrayIterator::__construct).
(Marcus)
- Fixed bug #27640 (memory leak of registered_zend_ini_directives). (Dmitry)
- Fixed bug #27063 (SPL: ArrayObject does not handle PPP correctly). (Marcus)
25 Apr 2004, PHP 5 Release Candidate 2
- Implementing an interface/abstract method with the wrong prototype is now
a fatal error. (Zeev)
- Reimplemented zend.ze1_compatibility_mode to have better PHP 4 compliance.
(Dmitry, Andi)
- Under CLI, fclose() on php://stdin, php://stdout and php://stderr will now
close the real stream. Please update your CLI scripts to use STDIN, STDOUT
and STDERR constants instead of fopen()/fclose(). (Wez)
- Moved yaz extension to PECL. (Wez)
- Added pty support to proc_open(). (Wez)
- Added possibility to check in which extension an internal class was defined
in using reflection API. (Marcus)
- Changed tidy error handling to no longer use exceptions and
renamed the "error_buf" property to errorBuffer. (John)
- Changed class and method names to use studlyCaps convention. (Marcus)
- Changed language parser to throw errors when a non-empty signature is used in
a destructor definition. (Marcus)
- Changed HTTP file uploads not to throw E_WARNINGs and E_NOTICEs. The error
value in the $_FILES global should be used for error handling. (Derick)
- Changed __construct() to always take precedence over old style constructor.
(Dmitry)
- Fixed handling of return values from storred procedures in mssql_execute()
with multiple result sets returned. (Frank)
- Fixed bug #28096 (stream_socket_accept() doesn't work with ssl). (Wez)
- Fixed bug #28007 (compile mssql extension with old versions of FreeTDS
fails). (Frank)
- Fixed bug #27997 (SPL: Crash with getInnerIterator()). (Marcus)
- Fixed bug #27974 (COM doesn't pass array parameters). (Wez)
- Fixed bug #27928 (sqlite incorrectly handles invalid filenames). (Ilia)
- Fixed bug $27923 (in some cases using foreach() to iterate over values
led to a false error message about the key being a reference). (Adam)
- Fixed bug #27865 (STDIN, STDOUT, STDERR are dup()d under CLI). (Wez)
- Fixed bug #27821 (xml_parse() segfaults when xml_set_object() is called from
class method). (Andi, Rob)
- Fixed bug #27742 (WDSL SOAP Parsing Schema bug). (Dmitry)
- Fixed bug #27722 (Segfault on schema without targetNamespace). (Dmitry)
- Fixed bug #27719 (mktime issues on and around DST changeover). (Rasmus)
- Fixed bug #27681 (soap extension fails without HAVE_TM_GMTOFF). (Dmitry)
- Fixed bug #27641 (Object cloning in ze1_compatibility_mode was reimplemented)
(Dmitry, Andi)
- Fixed bug #27628 (Simplify the process of making a POST request via stream
context). (Ilia)
- Fixed bug #27619 (filters not applied to pre-buffered stream data). (Sara)
- Fixed bug #27519 (Reflection_Function constructor crashes with non-existant
function's name). (Marcus)
- Fixed bug #27469 (serialize() objects of incomplete class). (Dmitry)
- Fixed bug #27457 (handling of numeric indexes in strtr()). (Dmitry)
- Fixed bug #27397 (debug_backtrace() not showing function arguments). (Zeev)
- Fixed bug #27283 (The last catch statement was sometimes skipped). (Andi)
- Fixed bug #26441 (When __set() returned a value it corrupted it). (Andi)
- Fixed bug #19749 (shouldn't mmap() files larger than memory_limit). (Wez)
18 March 2004, PHP 5 Release Candidate 1
- Fixed numerous bugs with the just-in-time auto-global initialization, that
could cause $_SERVER, $argv/$argc and other variables not to work properly.
(Zeev)
- Fixed data corruption with constant assignments to object properties. (Zeev)
- Changed __toString() to be called automatically only with print and echo
statements. (Andi)
- Replaced the exec_finished hook by the zend_post_deactive hook for
extensions. The new hook will be run after the symbol table and destructors
are run. (Derick)
- Fixed possible crash when internal get_method() is not defined. (Andi)
- Fixed calling methods using call_user_func() in conjunction with
the array("Class","Method") syntax to use the scope of the PHP user function.
(Dmitry)
- Fixed php-cgi to not ignore command-line switches when run in a web context.
This fixes our test cases allowing INI with GET sections to work. (Rasmus)
- Fixed getopt() so it works without $_SERVER. (Rasmus, bfrance)
- Added support for PHP 4 style object comparisons which is enabled in
ze1_compatiblity_mode. (Andi)
- Added support for PHP 4 style object conversion to long, double, and boolean
values which is enabled in ze1_compatibility_mode. (Andi, Stas)
- Allow object oriented extensions to overload comparison functions and other
operations. Solves problems using SimpleXML values. (Andi, Zeev)
- Fixed crash when accessing a class constant with a value which in turn is
also a constant. (Dmitry)
- Fixed object's truth value conversion. It is always true unless
ze1_compatibility_mode is on in which it behaves like in PHP 4. (Stas)
- Improved out of memory handling in new memory manager. (Stas)
- Fixed crash when an object references itself during destructor call. (Andi)
- Fixed crash in foreach() when iterating over object properties or a method's
return values. (Andi)
- Fixed crash when an exception is thrown in a destructor. Such exceptions are
now ignored as destruction happens out of context at no definite time. (Andi)
- Fixed crashes in exception handling. (Dmitry, Andi)
- Changed prototype checks so that they aren't done on constructors. (Andi)
- Changed prototype checks to output an E_STRICT message instead of
an E_COMPILE_ERROR. (Andi)
- Changed Iterator::has_more() to Iterator::valid(). (Marcus)
- Upgraded bundled oniguruma library to version 2.2.2. (Rui, Moriyoshi)
- Added mb_list_encoding() to return an array with all mbstring supported
encodings. (Derick)
- Added support for more ISO8601 datetime formats in strtotime(). (Moriyoshi)
. Timezone specifier (ex. "20040301T02:00:00+19:00")
. Week specifier (ex. "1997W021")
- Renamed php.ini option "zend2.implicit_clone" to
"zend.ze1_compatibility_mode" as it doesn't only affect implicit cloning.
(Andi, Zeev)
- Methods that override parent methods are now subject to prototype checking,
and have to be compatible with the method they're overriding - this check is
disabled in compatibility mode. (Andi, Zeev)
- Fixed crash in php_ini_scanned_files() when no additional INI files were
actually parsed. (Jon)
- Fixed bug in gdImageFilledRectangle in the bundled GD library, that required
x1 < x2 and y1 < y2 for coordinates. (Derick)
- Fixed crash with foreach() and temporary objects($obj->method()->a ...) where
method returns a non-referenced object. (Andi, Zeev)
- Fixed problem preventing startup errors from being displayed. (Marcus)
- Fixed start-up problem if both SPL and SimpleXML were enabled. The double
initialization of apache 1.3 was causing problems here. (Marcus, Derick)
- Fixed bug #27606 (Expression must be a modifiable lvalue compiler error).
(Derick)
- Fixed bug #27597 (pg_fetch_array not returning false). (Marcus)
- Fixed bug #27586 (ArrayObject::getIterator crashes with [] assignment).
(Marcus)
- Fixed bug #27537 (Objects pointing to each other segfaults). (Dmitry)
- Fixed bug #27535 (Problem with object freeing mechanism). (Dmitry)
- Fixed bug #27504 (Visibility bugs in call_user_function()). (Dmitry)
- Fixed bug #27338 (memory leak inside tsrm_virtual_cwd.c on win32). (Ilia)
- Fixed bug #27291 (get_browser matches browscap.ini patterns incorrectly).
(Jay)
- Fixed bug #27287 (wddx segfaults during deserialization). (Moriyoshi)
- Fixed bug #27263 (session extension crashes when unserializing referenced
values / objects). (Moriyoshi)
- Fixed bug #27237 (Working with simplexml crashes apache2). (Rob)
- Fixed bug #27227 (Mixed case class names causes Fatal Error in Constructor
call). (Marcus)
- Fixed bug #27125 (strval() doesn't work for objects with __toString()).
(Marcus)
- Fixed bug #27123 (Fix crash caused by bug in get_object_vars()). (Andi)
- Fixed bug #26677 (mbstring compile errors with IRIX compiler).
(K.Kosako <kosako at sofnec dot co dot jp>, Rui, Moriyoshi)
- Fixed bug #26206 (register_long_arrays breaks superglobals). (Zeev)
- Fixed bug #25724 (argv and argc not defined). (Zeev)
12 Feb 2004, PHP 5 Beta 4
- Changed exceptions so that they must now inherit from the built-in Exception
class. This allows for a general catch(Exception $e) statement to catch all
exceptions. (Andi, Zeev)
- Added SPL extension. (Marcus, Derick)
- Added checks for invalid characters in a cookie name and cookie data
into set[raw]cookie(). (Brian)
- Added support for ++ and += (and similar) to SimpleXML. (Andi, Zeev)
- Added infrastructure for ++ and += (and similar) to object overloading
modules. (Andi, Zeev)
- Added error message when trying to re-assign to $this variable. (Zeev, Andi)
- Added support for an interface to extend another interface. (Zeev)
- Added new pspell functions: (Brian)
. pspell_config_dict_dir()
. pspell_config_data_dir()
- Added new Interbase functions: (Ard)
. ibase_service_attach() and ibase_service_detach().
. ibase_backup() and ibase_restore().
. ibase_maintain_db(), ibase_db_info() and ibase_server_info().
- Added context option "http"/"request_fulluri" to send entire URI in request
which is required format for some proxies. (Sara)
- Added optional third parameter 'strict' to array_keys(). (Andrey)
- Added stream_lock() method to userspace streams interface. (Hartmut, Wez)
- Added xsltprocessor->registerPHPFunctions(). (Christian)
- Readded support for using classes before they are declared according to
the behavior in PHP 4. This won't work with classes who are using PHP 5
features such as interfaces. (Zeev, Andi)
- Completely overhauled SimpleXML extension. (Marcus, Rob, Sterling)
- Upgraded bundled SQLite library to version 2.8.11. (Ilia, Wez)
- Improved destructor implementation to always call destructors on clean
shutdown. An order of destruction is not guaranteed. (Zeev, Andi)
- Redesigned exception support. This fixes many bugs in the previous design
such as nested try's and problems with overloaded extensions. (Zeev, Andi)
- Redesigned clone by adding a clone keyword (clone $obj) and copying all
properties before __clone() is called. Also allows calling parent __clone
function by using parent::__clone(). (Zeev, Andi)
- Fixed interfaces to check for function return-by-reference equality when
inheriting and implementing interfaces. (Andi, Zeev)
- Fixed foreach() to respect property visibility. (Marcus)
- Fixed problem with parse error in include() file not stopping PHP's
execution. (Ilia)
- Fixed var_export() to show public, protected and private modifiers properly.
(Derick)
- Fixed problems with longlong values in mysqli. (Georg)
- Fixed class name case preserving of user defined classes. (Marcus)
- Fixed bug #27145 (Unmangle private/protected property names before printing
them inside error messages). (Ilia)
- Fixed bug #27103 (preg_split('//u') incorrectly splits UTF-8 strings into
octets). (Moriyoshi)
- Fixed bug #27042 (SPL: SeekableIterator seek() broken). (Marcus)
- Fixed bug #27008 (Every class method can be called as static). (Marcus)
- Fixed bug #26938 (exec() has problems reading long lines).
(Ilia, runekl[at]opoint[dot]com
- Fixed bug #26947 (ext/dom: Crash when using DomDocument::getElementById()).
(Christian)
- Fixed bug #26911 (crash in sqlite extension when fetching data from empty
queries). (Ilia)
- Fixed bug #26844 (ext/mime_magic: magic file validation broken). (Jani)
- Fixed bug #26819 (http_build_query() crashes on NULL output). (Ilia)
- Fixed bug #26817 (http_build_query() does not handle private & protected
object properties correctly). (Ilia)
- Fixed bug #26815 (foreach of (DOM) childnodes crashes when Xinclude is used).
(Rob)
- Fixed bug #26796 (SQLite causes crashes with other extensions *connect()
calls). (Marcus)
- Fixed bug #26762 (unserialize() produces lowercase classnames). (Marcus)
- Fixed bug #26743 (getElementsByTagName doesn't work properly). (Rob)
- Fixed bug #26736 (__autoload not invoked for parent classes). (Marcus)
- Fixed bug #26723 (domNode::appendChild() changes child node namespace). (Rob)
- Fixed bug #26697 (calling class_exists() on a nonexistent class in __autoload
results in segfault). (Marcus)
- Fixed bug #26696 (string index in a switch() crashes with multiple matches).
(Andi)
- Fixed bug #26695 (Reflection API does not recognize mixed-case class hints).
(Marcus)
- Fixed bug #26690 (make xsltProcessor->transformToUri use streams wrappers).
(Ilia)
- Fixed bug #26680 (Added version check in mysqli_report_index). (Georg)
- Fixed bug #26675 (Segfault on ArrayAccess use). (Marcus)
- Fixed bug #26640 (__autoload() not invoked by Reflection classes). (Jani)
- Fixed bug #26543 (call_user_func() broken for self, parent). (Stanislav)
- Fixed bug #26077 (memory leak when new() result is not assigned and no
constructor is defined). (Stanislav)
- Fixed bug #26065 (Crash when nesting classes). (Marcus)
- Fixed bug #25816 (disallow arrays in class constants). (Stanislav)
- Fixed bug #25329 (sqlite_create_function with method and reference to $this).
(Marcus)
- Fixed bug #25038 (call_user_func() issues a warning if function throws an
exception). (Marcus)
- Fixed bug #24608 (__set not triggered when overloading with array).
(Stanislav)
- Fixed bug #24243 (enabling browscap causes segfault). (Wez)
21 Dec 2003, PHP 5 Beta 3
- Bundled new tidy extension (John, Wez)
- Upgraded PCRE library to version 4.5. (Andrei)
@@ -394,19 +41,19 @@ PHP NEWS
- Fixed get_declared_classes() to return only classes. (Andrey, Marcus)
- Fixed __autoload() to preserve case of the passed class name. (Andi)
- Fixed bug #26615 () (runekl at opoint dot com, Derick)
- Fixed bug #26591 ("__autoload threw an exception" during an uncaught).
- Fixed bug #26591 ("__autoload threw an exception" during an uncaught).
(Marcus)
- Fixed bug #26534 (stream_get_meta_data() -> Access Violation). (Wez)
- Fixed bug #26528 (HTML entities are not being decoded by
- Fixed bug #26528 (HTML entities are not being decoded by
xml_parse()/xml_parse_into_struct()). (Ilia)
- Fixed bug #26182 (Object properties created redundantly). (Andi)
- Fixed bug #26156 (REPLACE_ZVAL_VALUE works on uninit stack-based zvals).
(Moriyoshi)
- Fixed bug #26083 (Non-working write support in ext/dom). (Ilia)
- Fixed bug #26072 (--disable-libxml does not work). (Jani)
- Fixed bug #26001 (serialize crashes when accessing an overloaded object that
- Fixed bug #26001 (serialize crashes when accessing an overloaded object that
has no properties (NULL hashtable)). (Wez)
- Fixed bug #25664 (COM crashes when calling a Delphi implementations of
- Fixed bug #25664 (COM crashes when calling a Delphi implementations of
ITypeInfo). (Wez)
- Fixed bug #24837 (Incorrect behaviour of PPP using foreach). (Marcus)
- Fixed bug #24693 (Allow session.use_trans_sid to be enabled/disabled from
@@ -432,10 +79,10 @@ PHP NEWS
statements into ibase_query()
. Added ability to bind PHP arrays to native Interbase arrays
. Added ibase_commit_ret() and ibase_rollback_ret()
. Added ibase_drop_db()
. Added ibase_drop_db()
. Added ibase_gen_id()
. Added ibase_name_result()
. Added ibase_errcode()
. Added ibase_errcode()
. Added ibase_affected_rows() and ibase_num_params()
. Added ibase_param_info()
. Added ibase_wait_event()
@@ -464,7 +111,7 @@ PHP NEWS
- Fixed IPv6 support in MacOSX Panther. (Dan, Marko)
- Fixed fgetcsv() to correctly handle international (non-ascii) characters.
(Moriyoshi)
- Fixed support for <![CDATA[]]> fields within XML documents in ext/xml.
- Fixed support for <![CDATA[]]> fields within XML documents in ext/xml.
(Sterling)
- Fixed visibility of __construct and __clone. (Marcus)
- Fixed bug #25756 (SimpleXML's validate_schema_file() broken). (Moriyoshi)
@@ -472,24 +119,24 @@ PHP NEWS
files). (Marcus)
- Fixed bug #25494 (array_merge*() allows non-arrays as argument). (Jay)
- Fixed bug #24766 (strange result array from unpack()). (Moriyoshi)
- Fixed bug #24729 ($obj = new $className; causes crash when $className is not
- Fixed bug #24729 ($obj = new $className; causes crash when $className is not
set). (Marcus)
- Fixed bug #24565 (cannot read array elements received via $_REQUEST). (Zeev)
- Fixed bug #24445 (get_parent_class() returns different values).
(Sterling, Stanislav)
- Fixed bug #24403 (preg_replace() problem: Using $this when not in object
context). (Zeev)
- Fixed bug #24399 (PEAR DB isError crash [instanceof_function fault?]).
- Fixed bug #24399 (PEAR DB isError crash [instanceof_function fault?]).
(Sterling, Marcus)
- Fixed bug #24396 (foreach ($k=>$v), the key $k is missing). (Zeev)
- Fixed bug #24279 (__get() crash when no value is returned). (Ilia)
- Fixed bug #22367 (undefined variable has a value). (Zeev)
- Fixed bug #19859 (allow fast_call_user_function to support __call).
- Fixed bug #19859 (allow fast_call_user_function to support __call).
(Stanislav)
- Fixed bug #17997 (Warning when switch() and reference are combined). (Zeev)
- Fixed bug #17988 (strtotime failed to parse postgresql timestamp). (Derick)
29 Jun 2003, PHP 5 Beta 1
29 Jun 2003, PHP 5 Beta 1
- Removed the bundled MySQL client library. (Sterling)
- Switched to Zend Engine 2, which includes numerous engine level improvements.
A full list is available at http://www.php.net/zend-engine-2.php.
@@ -507,17 +154,17 @@ PHP NEWS
. "session.hash_function" and "session.hash_bits_per_character". (Sascha)
. "mail.force_extra_paramaters". (Derick)
. "register_long_arrays". (Zeev)
- Improved the speed of internal functions that use callbacks by 40% due to a
- Improved the speed of internal functions that use callbacks by 40% due to a
new internal fast_call_user_function() function. (Sterling)
- Improved the streams support: (Wez)
. Improved performance of readfile(), fpassthru() and some internal streams
operations under Win32.
. stream_socket_client() - similar to fsockopen(), but more powerful.
. stream_socket_server() - Creates a server socket.
. stream_socket_client() - similar to fsockopen(), but more powerful.
. stream_socket_server() - Creates a server socket.
. stream_socket_accept() - Accept a client connection.
. stream_socket_get_name() - Get local or remote name of socket.
. stream_copy_to_stream()
. stream_get_line() - Reads either the specified number of bytes or until
. stream_get_line() - Reads either the specified number of bytes or until
the ending string is found. (Ilia)
. Added context property to userspace streams object. (Sara)
. Added generic crypto interface for streams.
@@ -535,7 +182,7 @@ PHP NEWS
o imageline() and imagepolygon() antialias support
- Changed the length parameter in fgetss() to be optional. (Moriyoshi)
- Changed ini parser to allow for handling of quoted multi-line values. (Ilia)
- Changed get_extension_funcs() to return list of the built-in Zend Engine
- Changed get_extension_funcs() to return list of the built-in Zend Engine
functions if "zend" is specified as the module name. (Ilia)
- Changed array_search() to accept also objects as a needle. (Moriyoshi)
- Changed ext/mcrypt to require libmcrypt version 2.5.6 or greater. (Derick)
@@ -558,7 +205,7 @@ PHP NEWS
. strpbrk() - Searches a string for a list of characters. (Ilia)
. get_headers() - Returns headers sent by the server of the specified URL.
(Ilia)
. str_split() - Breaks down a string into an array of elements based on
. str_split() - Breaks down a string into an array of elements based on
length. (Ilia)
. array_walk_recursive(). (Ilia)
. array_combine(). (Andrey)
@@ -582,7 +229,7 @@ PHP NEWS
html_entity_decode(). (Moriyoshi)
- Added IPv6 support to ext/sockets. (Sara)
- Added "ftp://" wrapper support to opendir(), stat() and unlink(). (Sara)
- Added context options 'method', 'header' and 'content' for "http://" fopen
- Added context options 'method', 'header' and 'content' for "http://" fopen
wrapper. (Sara)
- Added input filter support. See README.input_filter for more info. (Rasmus)
- Added a replace count for str_[i]replace(), see bug #8218. (Sara)
@@ -590,5 +237,5 @@ PHP NEWS
- Fixed dirname() and strip_tags() to be binary-safe. (Moriyoshi)
- Fixed bug #24098 (crash in pathinfo()). (Ilia)
- Fixed bug #21985 and #22064 (various mb_send_mail() issues). (Moriyoshi)
- Fixed bug #21600 (Assign by reference function call changes variable
- Fixed bug #21600 (Assign by reference function call changes variable
contents). (Zeev)
+18 -10
View File
@@ -37,11 +37,8 @@ The next few rules are more of a technical nature.
messages every day. Woe be to those who attempt to mess with it.
2. All news updates intended for public viewing, such as new features,
bug fixes, improvements, etc., should go into the NEWS file.
NB! Lines, starting with @ will go automagically into NEWS file, but
this is NOT recommended, though. Please, add news entries directly to
NEWS file and don't forget to keep them adjusted and sorted.
bug fixes, improvements, etc., should go into the NEWS file. Also see
the note below about automatically updating NEWS in your commit message.
3. Do not commit multiple file and dump all messages in one commit. If you
modified several unrelated files, commit each group separately and
@@ -62,10 +59,14 @@ The next few rules are more of a technical nature.
The format of the commit messages is pretty simple.
If a line begins with #, it is taken to be a comment and will not appear
in the ChangeLog. Everything else goes into the ChangeLog.
in the ChangeLog. If the line begins with @, it will be redirected to the
NEWS file. Everything else goes into the ChangeLog.
It is important to note that if your comment or news logline spans multiple
lines, you have to put # at the beginning of _every_ such line.
lines, you have to put # or @ at the beginning of _every_ such line. Every
entry in NEWS has to have a name after it, so if you did it with someone's
help, put both your names there. Your name WILL NOT be automatically put
at the end of the NEWS entry - so, please provide it yourself.
Example. Say you modified two files, datetime.c and string.c. In datetime.c
you added a new format option for date() function, and in string.c you fixed
@@ -77,12 +78,17 @@ For datetime.c:
(PHP date) Added new 'K' format modifier for printing out number of
days until New Year's Eve.
@- Added new 'K' format modifier that will output the number of days
@ until New Year's Eve. (Bob)
For string.c:
(php_trim) Fixed a memory leak resulting from improper use of zval_dtor().
# Man, that thing was leaking all over the place!
@- Fixed memory leak in trim(). (Bob)
The # lines will be omitted from the ChangeLog automagically.
The lines above marked with @ will go into NEWS file automagically, and the
# lines will be omitted from the ChangeLog. Alternatively, you might want
to modify NEWS file directly and not use the @ lines.
If you fix some bugs, you should note the bug ID numbers in your
commit message. Bug ID should be prefixed by "#" for easier access to
@@ -91,10 +97,12 @@ bug report when developers are browsing CVS via. LXR or Bonsai.
Example:
Fixed pgsql notice handler double free crash bug. Bug #14016
@ Fixed pgsql notice handler double free crash bug. Bug #14016
If you don't see your messages in ChangeLog right away, don't worry!
If you don't see your messages in ChangeLog and NEWS right away, don't worry!
These files are updated once a day, so your stuff will not show up until
somewhat later.
somewhat later. Don't go adding stuff to NEWS by hand if you already put @
lines in the commit message.
You can use LXR (http://lxr.php.net/) and Bonsai (http://bonsai.php.net/)
to look at PHP CVS repository in various ways.
+3 -117
View File
@@ -1,5 +1,5 @@
1. strrpos() and strripos() now use the entire string as a needle. Be aware
that the existing scripts may no longer work as you expect.
1. strrpos() and strripos() now use the entire string as a needle.
Be aware that the existing scripts may no longer work as you expect.
EX :
<?php
@@ -34,122 +34,8 @@
- mysqli_fetch_assoc()
5. PATH_TRANSLATED server variable is no longer set implicitly under
Apache2 SAPI in contrast to the situation in PHP 4, where it is set to the
Apache2 SAPI in contrast to the situation in PHP4, where it is set to the
same value as the SCRIPT_FILENAME server variable when it is not populated
by Apache. This change was made to comply with the CGI specification.
Please refer to bug #23610 for further information.
6. Starting PHP 5.0.0 the T_ML_CONSTANT constant is no longer defined by the
ext/tokenizer extension. If error_reporting is set to E_ALL notices will
be produced. Instead of T_ML_CONSTANT for /* */ the T_COMMENT constant
is used, thus both // and /* */ are resolved as the T_COMMENT constant.
However the PHPDoc style comments /** */ ,which starting PHP 5 are parsed
by PHP, are recongnized as T_DOC_COMMENT.
7. $_SERVER should be populated with argc and argv if variables_order
includes "S". If you have specifically configured your system to not
create $_SERVER, then of course it shouldn't be there. The change was to
always make argc and argv available in the CLI version regardless of the
variables_order setting. As in, the CLI version will now always populate
the global $argc and $argv variables.
8. In some cases classes must be declared before used. It only happens only
if some of the new features of PHP 5 are used. Otherwise the behaviour is
the old.
Example 1 (works with no errors):
<?php
$a = new a();
class a {
}
?>
Example 2 (throws an error):
<?php
$a = new a();
interface b{
}
class a implements b {
}
?>
Output (example 2) :
Fatal error: Class 'a' not found in /tmp/cl.php on line 2
9. get_class() starting PHP 5 returns the name of the class as it was
declared which may lead to problems in older scripts that rely on
the previous behaviour - the class name is lowercased. Expect the
same behaviour from get_parent_class() when applicable.
Example :
<?php
class FooBar {
}
class ExtFooBar extends FooBar{}
$a = new FooBar();
var_dump(get_class($a), get_parent_class($a));
?>
Output (PHP 4):
string(6) "foobar"
string(9) "extfoobar"
Output (PHP 5):
string(6) "FooBar"
string(9) "ExtFooBar"
----------------------------------------------------------------------
Example code that will break :
//....
function someMethod($p) {
if (get_class($p) != 'helpingclass') {
return FALSE;
}
//...
}
//...
Possible solution is to search for get_class() and get_parent_class() in
all your scripts and use strtolower().
10. get_class_methods() returns the names of the methods of a class as they
declared. In PHP4 the names are all lowercased.
Example code :
<?php
class Foo{
function doFoo(){}
function hasFoo(){}
}
var_dump(get_class_methods("Foo"));
?>
Output (PHP4):
array(2) {
[0]=>
string(5) "dofoo"
[1]=>
string(6) "hasfoo"
}
Output (PHP5):
array(2) {
[0]=>
string(5) "doFoo"
[1]=>
string(6) "hasFoo"
}
11. Assignment $this is impossible. Starting PHP 5.0.0 $this has special
meaning in class methods and is recognized by the PHP parser. The latter
will generate a parse error when assignment to $this is found
Example code :
<?php
class Foo {
function assignNew($obj) {
$this = $obj;
}
}
$a = new Foo();
$b = new Foo();
$a->assignNew($b);
echo "I was executed\n";
?>
Output (PHP 4):
I was executed
Output (PHP 5):
PHP Fatal error: Cannot re-assign $this in /tmp/this_ex.php on line 4
+2 -2
View File
@@ -90,7 +90,7 @@ Please add the prefix "[PATCH]" to your email subject and make sure
to include the patch as a MIME attachment even if it is short.
NOTE: only MIME attachments of type 'text/*' are accepted. The
easiest way to accomplish this, is to make the extension
easiest way to acclomplish this, is to make the extension
'.txt'.
Test scripts should be included in the same email.
@@ -100,7 +100,7 @@ Finally, add the bug Id(s) which can be closed by your patch, if any.
What happens after you submit your patch
----------------------------------------
--------------------------------------
If your patch is easy to review and has obviously no side-effects,
it might take up to a few hours until someone commits it.
+2 -11
View File
@@ -1,20 +1,11 @@
[IMPORTANT NOTICE]
------------------
Failed tests usualy indicate a problem with your local system setup
and not within PHP itself (at least for official PHP release versions).
You may decide to automaticaly submit a test summary to our QA workflow
at the end of a test run.
Please do *not* submit a failed test as a bug or ask for help on why
it failed on your system without providing substantial backup information
on *why* the test failed on your special setup. Thank you :-)
Please do not ask developers why some or all tests are failing in
your environment! Let us know if you find why it fails. Thank you.
[Testing Basics]
----------------
The easiest way to test your PHP build is to run "make test" from the
command line after successfully compiling. This will run the complete
tests for all enabled functionalities and extensions using the PHP
CLI binary.
To execute test scripts, you must build PHP with some SAPI, then you
type "make test" to execute all or some test scripts saved under
"tests" directory under source root directory.
+7 -18
View File
@@ -2,8 +2,11 @@ The Win32 Build System.
$Id$
Wez Furlong <wez@thebrainroom.com>
If you need help with the build system, send mail to
internals@lists.php.net; please don't email me directly.
NB: Please don't mail me asking for help on this, unless
you are a Core PHP developer, or you are prepared to donate
some money via paypal or buy me something from my wishlist.
http://pecl.php.net/user/wez
Thanks :-)
===========================================================
Contents:
@@ -15,7 +18,6 @@ Contents:
e. Building
f. Cleaning up
g. Running the test suite
h. snapshot building
2. How to write config.w32 files
x. to be written.
@@ -26,8 +28,9 @@ a. Requirements
You need:
- Windows Scripting Host (cscript.exe)
- Microsoft Build Tools from:
- Microsoft Build Tools from either:
Microsoft Visual Studio (VC6) or later
Microsoft Platform SDK
You also need:
- bindlib_w32 [http://www.php.net/extra/bindlib_w32.zip]
@@ -156,19 +159,5 @@ g. Running the test suite
sqlite test suite only, you would type
"nmake /D TESTS=ext/sqlite/tests test"
h. Snapshot Building
If you want to set up an automated build that will tolerate
breakages in some of the modules, you can use the
--enable-snapshot-build configure option to generate a
makefile optimized for that purpose. A snapshot build will
switch the argument parser so that the default option for
configure switches that your don't specify will be set
to "shared". The effect of this is to turn on all options
unless you explicitly disable them. When you have configured
your snapshot build, you can use "nmake build-snap" to build
everything, ignoring build errors in individual extensions
or SAPI.
vim:tw=78:sw=1:ts=1:et
+1 -1
View File
@@ -1,4 +1,4 @@
Using PHP 5 with the Zeus Web Server
Using PHP4 with the Zeus Web Server
-----------------------------------
Zeus fully supports running PHP in combination with our
+4 -4
View File
@@ -1,12 +1,12 @@
Input Filter Support in PHP 5
-----------------------------
Input Filter Support in PHP5
----------------------------
XSS (Cross Site Scripting) hacks are becoming more and more prevalent,
and can be quite difficult to prevent. Whenever you accept user data
and somehow display this data back to users, you are likely vulnerable
to XSS hacks.
The Input Filter support in PHP 5 is aimed at providing the framework
The Input Filter support in PHP5 is aimed at providing the framework
through which a company-wide or site-wide security policy can be
enforced. It is implemented as a SAPI hook and is called from the
treat_data and post handler functions. To implement your own security
@@ -155,7 +155,7 @@ PHP_FUNCTION(my_get_raw)
HashTable *hash_ptr;
char *raw_var;
if(zend_parse_parameters(2 TSRMLS_CC, "ls", &arg, &var, &var_len) == FAILURE) {
if(zend_parse_parameters(2 TSRMLS_CC, "ls|l", &arg, &var, &var_len) == FAILURE) {
return;
}
+4
View File
@@ -7,9 +7,13 @@ Zend
dimensional arrays.
* Look at replacing c-lib call tolower().
* Make hash API functions work with HASH_OF() to save time.
* Allow to set a default value for call-by-reference-parameters.
eg: function hello (&$pallo = NULL) {}
* Add configure test to determine if dlsym() requires underscore and set
DLSYM_NEEDS_UNDERSCORE accordingly. Perl and zsh have it in configure,
for example. (DONE?)
* Allow foreach ($array as $k => &$val) syntax. right now we cannot
traverse an array without copying each element.
* Native large number support (probably with GNU GMP)
* Const'ify APIs. Right now, many functions leave parameters untouched,
but don't declare those as const. This makes interaction with other
-10
View File
@@ -1,10 +0,0 @@
Zend Engine
-----------
- Look at making zend_constant value member be a zval* instead of zval. (Andi)
- Implement inheritance rules for type hints. (Marcus)
- Implement typehinting for arrays (apply the patch). (Andi, Marcus)
- Find a keyword for the if-set-or operator (apply the patch). (Marcus, all)
Standard Library
----------------
- Implement new time/date parsing and handling functions. (Derick)
+102
View File
@@ -16,6 +16,83 @@ Responsibility: Andi, Stig?
Time frame: ?
Component: Introspection
get_function_definition(<is_callable> [field]) =>
array(
file => filename
line_start =>
line_end =>
parameters => array( name, byref, default )
static_variables => array( name, value/default )
scope => 'namespace' | 'class' | null
namespace => classname | namespacename | 'main'
protection => protection_flags
phpdoc => pre-scanned-phpdoc-string
type => 'internal' | 'user'
)
get_class_definition(<class> [field]) =>
array(
type => 'internal' | 'user'
file => filename
line_start =>
line_end =>
name => pretty-name
parent => classname | namespace | null
flags => bitfield (ABSTRACT)
methods => array( array( name, phpdoc ) )
default_properties => array( array( name, value, phpdoc ) )
private_properties => array( array( name, value, phpdoc ) )
protected_properties => array( array( name, value, phpdoc ) )
public_properties => array( array( name, value, phpdoc ) )
static_members => array( array( name, value, phpdoc ) )
constants => array( array( name, value, phpdoc ) )
classes => array( array( name, phpdoc ) )
phpdoc => pre-scanned-phpdoc-string
)
get_constant_definition(<constant> [field]) =>
array(
file => filename
line_start =>
line_end =>
name =>
value =>
phpdoc =>
)
get_global_variable_defintion(<name> [field]) =>
array(
file =>
line_start =>
line_end =>
name =>
phpdoc =>
)
We tried to take into account the implementation of each piece of
information, and there are some that are problematic, especially those
regarding constants and global variables (where do we store the extra
information?)
With "pre-scanned-phpdoc-string" we mean converting:
/**
* Blah blah blah
* @param foo ...
*/
to:
Blah blah blah
@param foo
The rest of the phpdoc handling should be left to an extension.
Responsibility: Stig, Andrei, Harald
Time frame: ?
Component: Redesign of API Versioning
Responsibility: ?
Time frame: 1 month
@@ -95,6 +172,31 @@ Responsibility: Sterling, Harald
Time frame: ?
Component: MySQL Extension
Complete rewrite, leveraging the new MySQL 4 / MySQL 5
features.
Responsibility: Georg Richter, Zak Greant
Timeframe: ?
Component: XML
- Rewrite DOMXML and incorporate all (or most of) W3C-DOM2.
- Use the new ZE2 features (Exceptions, setter/getter).
- Add SAX(2), XML Schema.
- XSLT, HTML, XPath, XPointer, DTD Validation will still be
supported, have to find a meaningful API for it.
- Break BC, warn users now.
- Look at the libxml2 patch by lukas schröder and see if we can prevent
memory leaks with it (anyway, getting rid of mem-leaks and intelligent
memory management is on top prio...)
- In the longer term, domxml (or another name, as with todays features
domxml is a little bit misleading) shall be the main xml-class, which
covers most of what's needed for decent XML support in PHP ;)
But there is certainly place for others like Sablotron etc.
Responsibility: Christian Stocker
Timeframe: ?
Component: Test Suite
Extending the test suite with atleast a test for every
function in an extension that doesn't require external
+6 -43
View File
@@ -34,7 +34,6 @@ typedef struct {
size_t size;
ts_allocate_ctor ctor;
ts_allocate_dtor dtor;
int done;
} tsrm_resource_type;
@@ -159,12 +158,10 @@ TSRM_API void tsrm_shutdown(void)
next_p = p->next;
for (j=0; j<p->count; j++) {
if (p->storage[j]) {
if (resource_types_table && !resource_types_table[j].done && resource_types_table[j].dtor) {
resource_types_table[j].dtor(p->storage[j], &p->storage);
}
free(p->storage[j]);
if (resource_types_table && resource_types_table[j].dtor) {
resource_types_table[j].dtor(p->storage[j], &p->storage);
}
free(p->storage[j]);
}
free(p->storage);
free(p);
@@ -222,7 +219,6 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].size = size;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].ctor = ctor;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].dtor = dtor;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].done = 0;
/* enlarge the arrays for the already active threads */
for (i=0; i<tsrm_tls_table_size; i++) {
@@ -277,14 +273,9 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
tsrm_new_thread_begin_handler(thread_id, &((*thread_resources_ptr)->storage));
}
for (i=0; i<id_count; i++) {
if (resource_types_table[i].done) {
(*thread_resources_ptr)->storage[i] = NULL;
} else
{
(*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size);
if (resource_types_table[i].ctor) {
resource_types_table[i].ctor((*thread_resources_ptr)->storage[i], &(*thread_resources_ptr)->storage);
}
(*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size);
if (resource_types_table[i].ctor) {
resource_types_table[i].ctor((*thread_resources_ptr)->storage[i], &(*thread_resources_ptr)->storage);
}
}
@@ -429,34 +420,6 @@ void ts_free_thread(void)
/* deallocates all occurrences of a given id */
void ts_free_id(ts_rsrc_id id)
{
int i;
int j = TSRM_UNSHUFFLE_RSRC_ID(id);
tsrm_mutex_lock(tsmm_mutex);
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Freeing resource id %d", id));
if (tsrm_tls_table) {
for (i=0; i<tsrm_tls_table_size; i++) {
tsrm_tls_entry *p = tsrm_tls_table[i];
while (p) {
if (p->count > j && p->storage[j]) {
if (resource_types_table && resource_types_table[j].dtor) {
resource_types_table[j].dtor(p->storage[j], &p->storage);
}
free(p->storage[j]);
p->storage[j] = NULL;
}
p = p->next;
}
}
}
resource_types_table[j].done = 1;
tsrm_mutex_unlock(tsmm_mutex);
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully freed resource id %d", id));
}
-10
View File
@@ -1,10 +0,0 @@
// vim:ft=javascript
// $Id$
if (CHECK_HEADER_ADD_INCLUDE("NewAPIs.h", "CFLAGS_PHP", php_usual_include_suspects)) {
// Need to add the flag directly, since TSRM doesn't include the config
// header
ADD_FLAG("CFLAGS_PHP", "/DHAVE_NEWAPIS_H=1");
}
ADD_SOURCES("TSRM", "TSRM.c tsrm_strtok_r.c tsrm_virtual_cwd.c tsrm_win32.c");
+2 -2
View File
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
| Copyright (c) 1997-2003 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+2 -2
View File
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
| Copyright (c) 1997-2003 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+51 -163
View File
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
| Copyright (c) 1997-2003 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -27,7 +27,6 @@
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <time.h>
#include "tsrm_virtual_cwd.h"
#include "tsrm_strtok_r.h"
@@ -35,11 +34,11 @@
#ifdef TSRM_WIN32
#include <io.h>
#include "tsrm_win32.h"
# if HAVE_NEWAPIS_H
# define WANT_GETLONGPATHNAME_WRAPPER
# define COMPILE_NEWAPIS_STUBS
# include <NewAPIs.h>
# endif
#endif
#ifdef NETWARE
/*#include "pipe.h"*/
#include "tsrm_nw.h"
#endif
#ifndef HAVE_REALPATH
@@ -56,9 +55,9 @@ MUTEX_T cwd_mutex;
#endif
#ifdef ZTS
ts_rsrc_id cwd_globals_id;
static ts_rsrc_id cwd_globals_id;
#else
virtual_cwd_globals cwd_globals;
static virtual_cwd_globals cwd_globals;
#endif
cwd_state main_cwd_state; /* True global */
@@ -138,9 +137,15 @@ static int php_check_dots(const char *element, int n)
static int php_is_dir_ok(const cwd_state *state)
{
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
struct stat buf;
if (stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode))
#else
struct stat_libc buf;
if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISDIR(buf.st_mode))
#endif
return (0);
return (1);
@@ -148,9 +153,15 @@ static int php_is_dir_ok(const cwd_state *state)
static int php_is_file_ok(const cwd_state *state)
{
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
struct stat buf;
if (stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode))
#else
struct stat_libc buf;
if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISREG(buf.st_mode))
#endif
return (0);
return (1);
@@ -159,31 +170,11 @@ static int php_is_file_ok(const cwd_state *state)
static void cwd_globals_ctor(virtual_cwd_globals *cwd_globals TSRMLS_DC)
{
CWD_STATE_COPY(&cwd_globals->cwd, &main_cwd_state);
#ifdef REALPATH_CACHE
cwd_globals->realpath_cache_size = 0;
cwd_globals->realpath_cache_size_limit = REALPATH_CACHE_SIZE;
cwd_globals->realpath_cache_ttl = REALPATH_CACHE_TTL;
memset(cwd_globals->realpath_cache, 0, sizeof(cwd_globals->realpath_cache));
#endif
}
static void cwd_globals_dtor(virtual_cwd_globals *cwd_globals TSRMLS_DC)
{
CWD_STATE_FREE(&cwd_globals->cwd);
#ifdef REALPATH_CACHE
{
int i;
for (i = 0; i < sizeof(cwd_globals->realpath_cache)/sizeof(cwd_globals->realpath_cache[0]); i++) {
realpath_cache_bucket *p = cwd_globals->realpath_cache[i];
while (p != NULL) {
realpath_cache_bucket *r = p;
p = p->next;
free(r);
}
}
}
#endif
}
static char *tsrm_strndup(const char *s, size_t length)
@@ -291,65 +282,6 @@ CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC)
return buf;
}
#ifdef REALPATH_CACHE
static inline unsigned long realpath_cache_key(const char *path, int path_len)
{
register unsigned long h;
const char *e = path + path_len;
for (h = 2166136261U; path < e; ) {
h *= 16777619;
h ^= *path++;
}
return h;
}
static inline void realpath_cache_add(const char *path, int path_len, const char *realpath, int realpath_len, time_t t TSRMLS_DC)
{
long size = sizeof(realpath_cache_bucket) + path_len + 1 + realpath_len + 1;
if (CWDG(realpath_cache_size) + size <= CWDG(realpath_cache_size_limit)) {
realpath_cache_bucket *bucket = malloc(size);
unsigned long n;
bucket->key = realpath_cache_key(path, path_len);
bucket->path = (char*)bucket + sizeof(realpath_cache_bucket);
memcpy(bucket->path, path, path_len+1);
bucket->path_len = path_len;
bucket->realpath = bucket->path + (path_len + 1);
memcpy(bucket->realpath, realpath, realpath_len+1);
bucket->realpath_len = realpath_len;
bucket->expires = t + CWDG(realpath_cache_ttl);
n = bucket->key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
bucket->next = CWDG(realpath_cache)[n];
CWDG(realpath_cache)[n] = bucket;
CWDG(realpath_cache_size) += size;
}
}
static inline realpath_cache_bucket* realpath_cache_find(const char *path, int path_len, time_t t TSRMLS_DC)
{
unsigned long key = realpath_cache_key(path, path_len);
unsigned long n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
realpath_cache_bucket **bucket = &CWDG(realpath_cache)[n];
while (*bucket != NULL) {
if (CWDG(realpath_cache_ttl) && (*bucket)->expires < t) {
realpath_cache_bucket *r = *bucket;
*bucket = (*bucket)->next;
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
free(r);
} else if (key == (*bucket)->key && path_len == (*bucket)->path_len &&
memcmp(path, (*bucket)->path, path_len) == 0) {
return *bucket;
} else {
*bucket = (*bucket)->next;
}
}
return NULL;
}
#endif
/* Resolve path relatively to state and put the real path into state */
/* returns 0 for ok, 1 for error */
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath)
@@ -358,60 +290,18 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
char *ptr, *path_copy;
char *tok = NULL;
int ptr_length;
cwd_state old_state;
cwd_state *old_state;
int ret = 0;
int copy_amount = -1;
char *free_path;
unsigned char is_absolute = 0;
#ifndef TSRM_WIN32
char resolved_path[MAXPATHLEN];
#else
char *new_path;
#endif
#ifdef REALPATH_CACHE
char orig_path[MAXPATHLEN];
int orig_path_len;
realpath_cache_bucket *bucket;
time_t t;
TSRMLS_FETCH();
#endif
if (path_length == 0)
return (0);
#ifdef REALPATH_CACHE
if (use_realpath && CWDG(realpath_cache_size_limit)) {
if (IS_ABSOLUTE_PATH(path, path_length) || (state->cwd_length < 1)) {
memcpy(orig_path, path, path_length+1);
orig_path_len = path_length;
} else {
orig_path_len = path_length + state->cwd_length + 1;
if (orig_path_len+1 > MAXPATHLEN) {
return 1;
}
memcpy(orig_path, state->cwd, state->cwd_length);
orig_path[state->cwd_length] = DEFAULT_SLASH;
memcpy(orig_path + state->cwd_length + 1, path, path_length + 1);
}
t = CWDG(realpath_cache_ttl)?time(NULL):0;
if ((bucket = realpath_cache_find(orig_path, orig_path_len, t TSRMLS_CC)) != NULL) {
int len = bucket->realpath_len;
CWD_STATE_COPY(&old_state, state);
state->cwd = (char *) realloc(state->cwd, len+1);
memcpy(state->cwd, bucket->realpath, len+1);
state->cwd_length = len;
if (verify_path && verify_path(state)) {
CWD_STATE_FREE(state);
*state = old_state;
return 1;
} else {
CWD_STATE_FREE(&old_state);
return 0;
}
}
}
#endif
#if !defined(TSRM_WIN32) && !defined(NETWARE)
/* cwd_length can be 0 when getcwd() fails.
* This can happen under solaris when a dir does not have read permissions
@@ -445,6 +335,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
#if defined(TSRM_WIN32)
{
char *dummy = NULL;
char *new_path;
int new_path_length;
new_path_length = GetLongPathName(path, dummy, 0) + 1;
@@ -461,13 +352,13 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
path_length = new_path_length;
} else {
free(new_path);
new_path = NULL;
}
}
#endif
free_path = path_copy = tsrm_strndup(path, path_length);
CWD_STATE_COPY(&old_state, state);
old_state = (cwd_state *) malloc(sizeof(cwd_state));
CWD_STATE_COPY(old_state, state);
#if VIRTUAL_CWD_DEBUG
fprintf(stderr,"cwd = %s path = %s\n", state->cwd, path);
#endif
@@ -487,7 +378,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
memcpy(state->cwd, path_copy, copy_amount);
path_copy += copy_amount;
} else {
memcpy(state->cwd, old_state.cwd, copy_amount);
memcpy(state->cwd, old_state->cwd, copy_amount);
}
}
state->cwd[copy_amount] = '\0';
@@ -530,19 +421,8 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
}
#elif defined(NETWARE)
/*
Below code keeps appending to state->cwd a File system seperator
cases where this appending should not happen is given below,
a) sys: should just be left as it is
b) sys:system should just be left as it is,
Colon is allowed only in the first token as volume names alone can have the : in their names.
Files and Directories cannot have : in their names
So the check goes like this,
For second token and above simply append the DEFAULT_SLASH to the state->cwd.
For first token check for the existence of :
if it exists don't append the DEFAULT_SLASH to the state->cwd.
*/
if(((state->cwd_length == 0) && (strchr(ptr, ':') == NULL)) || (state->cwd_length > 0)) {
/* If the token is a volume name, it will have colon at the end -- so, no slash before it */
if (ptr[ptr_length-1] != ':') {
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
}
#else
@@ -566,28 +446,20 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
state->cwd_length = path_length;
}
#ifdef TSRM_WIN32
if (new_path) {
free(new_path);
}
#endif
free(free_path);
#ifdef REALPATH_CACHE
if (ret == 0 && use_realpath && CWDG(realpath_cache_size_limit)) {
realpath_cache_add(orig_path, orig_path_len, state->cwd, state->cwd_length, t TSRMLS_CC);
}
#endif
if (verify_path && verify_path(state)) {
CWD_STATE_FREE(state);
*state = old_state;
*state = *old_state;
ret = 1;
} else {
CWD_STATE_FREE(&old_state);
CWD_STATE_FREE(old_state);
ret = 0;
}
free(old_state);
free(free_path);
#if VIRTUAL_CWD_DEBUG
fprintf (stderr, "virtual_file_ex() = %s\n",state->cwd);
#endif
@@ -816,6 +688,7 @@ CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC)
return retval;
}
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
{
cwd_state new_state;
@@ -829,6 +702,21 @@ CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
CWD_STATE_FREE(&new_state);
return retval;
}
#else
CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC)
{
cwd_state new_state;
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, path, NULL, 1);
retval = stat(new_state.cwd, (struct stat*)buf);
CWD_STATE_FREE(&new_state);
return retval;
}
#endif
#if !defined(TSRM_WIN32) && !defined(NETWARE)
CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC)
+8 -29
View File
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
| Copyright (c) 1997-2003 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -70,15 +70,14 @@ typedef unsigned short mode_t;
#include <dirent.h>
#endif
#define DEFAULT_SLASH '\\'
#define DEFAULT_SLASH '/'
#define DEFAULT_DIR_SEPARATOR ';'
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
#define IS_SLASH_P(c) IS_SLASH(*(c))
#define COPY_WHEN_ABSOLUTE(path) \
(strchr(path, ':') - path + 1) /* Take the volume name which ends with a colon */
/* Colon indicates volume name, either first character should be forward slash or backward slash */
#define IS_ABSOLUTE_PATH(path, len) \
((strchr(path, ':') != NULL) || ((len >= 1) && ((path[0] == '/') || (path[0] == '\\'))))
(strchr(path, ':') != NULL) /* Colon indicates volume name */
#else
#ifdef HAVE_DIRENT_H
@@ -142,7 +141,11 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC);
CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...);
CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC);
CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC);
#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC);
#else
CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC);
#endif
#if !defined(TSRM_WIN32) && !defined(NETWARE)
CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC);
#endif
@@ -197,37 +200,13 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath);
#define REALPATH_CACHE
#define REALPATH_CACHE_TTL (2*60) /* 2 minutes */
#define REALPATH_CACHE_SIZE 0 /* disabled while php.ini isn't loaded */
#ifdef REALPATH_CACHE
typedef struct _realpath_cache_bucket {
unsigned long key;
char *path;
int path_len;
char *realpath;
int realpath_len;
time_t expires;
struct _realpath_cache_bucket *next;
} realpath_cache_bucket;
#endif
typedef struct _virtual_cwd_globals {
cwd_state cwd;
#ifdef REALPATH_CACHE
long realpath_cache_size;
long realpath_cache_size_limit;
long realpath_cache_ttl;
realpath_cache_bucket *realpath_cache[1024];
#endif
} virtual_cwd_globals;
#ifdef ZTS
extern ts_rsrc_id cwd_globals_id;
# define CWDG(v) TSRMG(cwd_globals_id, virtual_cwd_globals *, v)
#else
extern virtual_cwd_globals cwd_globals;
# define CWDG(v) (cwd_globals.v)
#endif
+2 -3
View File
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
| Copyright (c) 1997-2003 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -29,7 +29,6 @@
#include "TSRM.h"
#ifdef TSRM_WIN32
#include "tsrm_win32.h"
#ifdef ZTS
+2 -2
View File
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
| Copyright (c) 1997-2003 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
-3560
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -16,7 +16,7 @@ libZend_la_SOURCES=\
zend_ini.c zend_qsort.c zend_objects.c zend_object_handlers.c \
zend_objects_API.c zend_ts_hash.c zend_stream.c zend_mm.c \
zend_default_classes.c zend_reflection_api.c \
zend_iterators.c zend_interfaces.c zend_exceptions.c
zend_iterators.c zend_interfaces.c
libZend_la_LDFLAGS =
libZend_la_LIBADD = @ZEND_EXTRA_LIBS@
-1
View File
@@ -1 +0,0 @@
Zend/zend_execute.lo: $(srcdir)/zend_vm_spec.h $(srcdir)/zend_vm_handlers.h
+1 -1
View File
@@ -51,7 +51,7 @@ write_property is used to directly write object's property by
name. This handler is used to assign property variables or to change them
in operations like += or ++ (unless get_property_zval_ptr is also set).
get_property_zval_ptr is used to obtain pointer to modifiable zval for
get_property_zval_ptr is used to obtain pointer to modifyable zval for
operations like += or ++. This should be used only if your object model
stores properties as real zval's that can be modified from outside.
Otherwise this handler should be NULL and the engine will use
-92
View File
@@ -1,92 +0,0 @@
ZEND_VM
=======
ZEND_VM architecture allows specializing opcode handlers according to op_type
fields and using different execution methods (call threading, switch threading
and direct threading). As a result ZE2 got more then 20% speedup on raw PHP
code execution (with specialized executor and direct threading execution
method). As most in most PHP applications raw execution speed isn't the
limiting factor but system calls and database callls are, your mileage with
this patch will vary.
Most parts of the old zend_execute.c go into zend_vm_handlers.h. Here you can
find opcode handlers and helpers. The typical opcode handler template looks
like this:
#define <OPCODE>_SPEC() OPDEF(<OPCODE>, <OP1_TYPES>, <OP2_TYPES>)
#if HAVE_OP(<OPCODE>)
ZEND_VM_HANDLER(<OPCODE>)
{
<HANDLER'S CODE>
}
#endif
<OPCODE> is an opcode name (ZEN_NOP, ZEND_ADD, :)
<OP1_TYPES> & <OP2_TYPES> are masks for allowed operand op_types. Specializer
will generate code only for defined combination of types. You can also use
M_ANY mask to disable specialization according operand's op_type.
<HANDLER'S CODE> is a handler's code itself. For most handlers it stills the
same as in old zend_execute.c, but now it uses macros to access opcode operands
and some internal executor data.
You can see the conformity of new macros to old code in the following list:
EXECUTE_DATA
execute_data
ZEND_VM_DISPATCH_TO_HANDLER(<OP>)
return <OP>_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)
ZEND_VM_DISPATCH_TO_HELPER(<NAME>)
return <NAME>(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)
ZEND_VM_DISPATCH_TO_HELPER_EX(<NAME>,<PARAM>,<VAL>)
return <NAME>(<VAL>, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)
ZEND_VM_CONTINUE()
return 0
ZEND_VM_NEXT_OPCOD()
NEXT_OPCODE()
ZEND_VM_SET_OPCODE(<TARGET>
SET_OPCODE(<TARGET>
ZEND_VM_INC_OPCODE()
INC_OPCOD()
ZEND_VM_RETURN_FROM_EXECUTE_LOOP()
RETURN_FROM_EXECUTE_LOOP()
ZEND_VM_C_LABEL(<LABEL>):
<LABEL>:
ZEND_VM_C_GOTO(<LABEL>)
goto <LABEL>
OP<X>_TYPE
opline->op<X>.op_type
GET_OP<X>_ZVAL_PTR(<TYPE>)
get_zval_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
GET_OP<X>_ZVAL_PTR_PTR(<TYPE>)
get_zval_ptr_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
GET_OP<X>_OBJ_ZVAL_PTR(<TYPE>)
get_obj_zval_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
GET_OP<X>_OBJ_ZVAL_PTR_PTR(<TYPE>)
get_obj_zval_ptr_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
IS_OP<X>_TMP_FREE()
IS_TMP_FREE(free_op<X>)
FREE_OP<X>()
FREE_OP(free_op<X>)
FREE_OP<X>_IF_VAR()
FREE_VAR(free_op<X>)
FREE_OP<X>_VAR_PTR()
FREE_VAR_PTR(free_op<X>)
If handler can receive control form some other handler it should be defined
with macro ZEND_VM_HANDLER_EX() instead of ZEND_VM_HANDLER().
The additional parameters of helpers (see ZEND_VM_DISPATCH_TO_HELPER_EX) mast
be defined in the start of execute() function inside ZEND_VM_HELPER_VAR() macro.
zend_vm.h and zend_vm_spec.h are used for abstraction of execution method and
operands specialization. They mainly contain macros that are used for
compile-time specialization.
You can switch specialization on/off with define/undefined of the ZEND_VM_SPEC
in the start of zend.vm.h and select execution method by defining ZEND_VM_KIND
in the same place.
Zend Engine II currently includes two executors during the build process, one
is the specialized version and the other is the old one non-specialized with
function handlers. By default Zend Engine II uses the specialized one but you
can switch to the old executor at runtime by calling zend_vm_use_old_executor().
+1 -1
View File
@@ -1,6 +1,6 @@
Title: Zend 2.0 Namespaces
Version: $Revision$
Status: declined
Status: draft
Maintainer: Stig S. Bakken <ssb@php.net>
Created: 2001-09-08
Modified: 2001-09-08
+118 -250
View File
@@ -19,43 +19,11 @@ Changes in the Zend Engine 2.0
the box or after a very small amount of modifications would be
high.
* $this
Unlike in Zend Engine 1 the pseudo variable $this cannot be
exchanged in Zend Engine 2. You can of course modify or work with
an object by using $this but you cannot replace $this with another
object to change the original object.
Example:
<?php
class Foo {
function replace($other)
{
$this = $other;
}
}
$object = new Foo;
$object->prop = 'Hello';
$other = new Foo;
$other->prop = 'Bye';
$object->replace($other);
print $object->prop; // still shows 'Hello'
?>
Zend Engine 2.0 will issue a compile error, if an assignment
to $this is found.
* Private and Protected Members.
The Zend Engine 2.0 introduces private and protected member
variables. Note that for performance reasons no error message is
emitted in case of an illegal access to a private or protectecd
The Zend Engine 2.0 introduces private and protected member
variables. Note that for performance reasons no error message is
emitted in case of an illegal access to a private or protectecd
member variable.
Example:
@@ -75,7 +43,7 @@ Changes in the Zend Engine 2.0
class MyClass2 extends MyClass {
protected $Foo;
function printHello() {
MyClass::printHello(); /* Should print */
print "MyClass2::printHello() " . $this->Hello; /* Shouldn't print out anything */
@@ -96,9 +64,9 @@ Changes in the Zend Engine 2.0
print $obj->Foo; /* Shouldn't print out anything */
$obj->printHello();
?>
Protected member variables can be accessed in classes extending the
class they are declared in, whereas private member variables can
Protected member variables can be accessed in classes extending the
class they are declared in, whereas private member variables can
only be accessed by the class they belong to.
* Private and protected methods.
@@ -130,14 +98,14 @@ Changes in the Zend Engine 2.0
$o->aPublicMethod();
?>
Old code that has no user-defined classes or functions named
Old code that has no user-defined classes or functions named
'public', 'protected' or 'private' should run without modifications.
* Abstract Classes and Methods.
The Zend Engine 2.0 introduces abstract classes and methods. An
abstract method only declares the method's signature and does not
provide an implementation. A class that contains abstract methods
The Zend Engine 2.0 introduces abstract classes and methods. An
abstract method only declares the method's signature and does not
provide an implementation. A class that contains abstract methods
needs to be declared abstract.
Example:
@@ -160,7 +128,7 @@ Changes in the Zend Engine 2.0
Classes that do not have abstract methods can be declared abstract
to prevent them from being instantiated.
Old code that has no user-defined classes or functions named
Old code that has no user-defined classes or functions named
'abstract' should run without modifications.
* Interfaces.
@@ -182,47 +150,13 @@ Changes in the Zend Engine 2.0
}
?>
Old code that has no user-defined classes or functions named
Old code that has no user-defined classes or functions named
'interface' or 'implements' should run without modifications.
An interface may extend one or more base interfaces (but not
implement them). Neither a class nor an interface can inherit
methods of the same name from different root interfaces.
Interfaces may contain abstract static methods.
Example:
<?php
interface Printable {
function dump();
}
interface Streamable extends Printable {
function writeToStream();
static function readFromStream();
}
class PrintableExample implements Streamable {
public function dump() {
// ...
}
function writeToStream() {
// ...
}
static function readFromStream() {
// ...
}
}
?>
A class that does not implement all interface methods must be
declared as an abstract class.
* Class Type Hints.
While remaining loosely typed the Zend Engine 2.0 introduces the
ability to use class type hints to declare the expected class of
While remaining loosely typed the Zend Engine 2.0 introduces the
ability to use class type hints to declare the expected class of
objects that are passed as parameters to a method.
Example:
@@ -275,7 +209,8 @@ Changes in the Zend Engine 2.0
* Final methods and classes.
The Zend Engine 2.0 introduces the "final" keyword to declare
final methods. Those cannot be overridden by sub-classes.
final members and methods. Those cannot be overridden by
sub-classes.
Example:
@@ -287,8 +222,8 @@ Changes in the Zend Engine 2.0
}
?>
It is furthermore possible to make a class final. Doing this
prevents a class from being specialized (it cannot be inherited
It is furthermore possible to make a class final. Doing this
prevents a class from being specialized (it cannot be inherited
by another class). There's no need to declare the methods of
a final class themselves as final.
@@ -302,9 +237,9 @@ Changes in the Zend Engine 2.0
// class Bork extends Foo {}
?>
Properties cannot be final. See per-class constants below.
Properties cannot be final.
Old code that has no user-defined classes or functions named
Old code that has no user-defined classes or functions named
'final' should run without modifications.
* Object Cloning.
@@ -325,12 +260,13 @@ Changes in the Zend Engine 2.0
replicate the parent object you want to create a new instance of
this other object so that the replica has its own separate copy.
An object copy is created by using the clone operator.
An object copy is created by calling the object's __clone()
method.
Example:
<?php
$copy_of_object = clone $object;
$copy_of_object = $object->__clone();
?>
When the developer asks to create a new copy of an object, the
@@ -339,40 +275,40 @@ Changes in the Zend Engine 2.0
all of the object's properties. If a __clone() method is
defined, then it will be responsible to set the necessary
properties in the created object. For convenience, the engine
ensures, that the clone will be initialized with all of the
properties from the source object, so that developers can start
with a by-value replica of the source object, and only override
properties that need to be changed.
will supply a function that imports all of the properties from
the source object, so that they can start with a by-value
replica of the source object, and only override properties that
need to be changed. [The function hasn't been implemented yet]
Example:
<?php
class MyCloneable {
static $id = 0;
static $id = 0;
function MyCloneable() {
$this->id = self::$id++;
}
function MyCloneable() {
$this->id = self::$id++;
}
function __clone() {
$this->address = 'New York';
$this->id = self::$id++;
}
function __clone() {
$this->name = $that->name;
$this->address = 'New York';
$this->id = self::$id++;
}
}
$obj = new MyCloneable();
$obj->name = 'Hello';
$obj->name = 'Hello';
$obj->address = 'Tel-Aviv';
$obj_clone = clone $obj;
print $obj->id . "\n";
$obj = $obj->__clone();
print $obj->id . "\n";
print $obj->name . "\n";
print $obj->address . "\n";
print $obj_clone->id . "\n";
print $obj_clone->name . "\n";
print $obj_clone->address . "\n";
?>
* Unified Constructors.
@@ -474,7 +410,7 @@ Changes in the Zend Engine 2.0
echo 'Foo::constant = ' . Foo::constant . "\n";
?>
Old code that has no user-defined classes or functions
Old code that has no user-defined classes or functions
named 'const' will run without modifications.
* Exceptions.
@@ -483,16 +419,16 @@ Changes in the Zend Engine 2.0
introduces a exception model similar to that of other programming
languages. But there is no catch all and no finally clause.
Old code that has no user-defined classes or functions 'catch',
Old code that has no user-defined classes or functions 'catch',
'throw' and 'try' will run without modifications.
Exceptions can be rethrown in catch blocks. Also it is possible to
have multiple catch blocks. In that case the caught exception is
compared with the classtype of each catch block from top to bottom
have multiple catch blocks. In that case the caught exception is
compare with the classtype of each catch block from top to bottom
and the first block that has a 'instanceof' match gets executed.
When the catch block finishes execution continues at the end of
When the catch block finishes execution continues at the end of
the last catch block. If no catch block has a 'instanceof' match
then the next try/catch block is searched until no more try/catch
then the next try/catch block is searched until no more try/catch
blocks are available. In that case the exception is an uncaught
exception and the program terminates with showing the exception.
@@ -529,23 +465,24 @@ Changes in the Zend Engine 2.0
echo $exception;
}
?>
Even though the above example shows that it is possible to define
exception classes that don't inherit from Exception it is best to
do so. This is because the internal Exception class can gather a
lot of information otherwise not available. The PHP code emulation
code would look something like shown below. The comments show the
meaning of each property. As the code shows it is possible to read
any available information by using the getter methods. But since
some of the methods are used internally they are marked final. All
in all the class is very restrictive because it must be ensured
that anything used internally always works as expected.
meaning of each proerty and hence there getter methods. As the code
shows it is possible to read any available information by using the
getter methods. But since some og the methods are used internally
they are marked final. All in all the class is very restrictive
because it must be ensured that anything used internally always
works as expected.
Emulating class Exception:
<?php
class Exception {
function __construct(/*string*/ $message=NULL, /*int*/ $code=0) {
function __construct(string $message=NULL, int code=0) {
if (func_num_args()) {
$this->message = $message;
}
@@ -555,15 +492,15 @@ Changes in the Zend Engine 2.0
$this->trace = debug_backtrace();
$this->string = StringFormat($this);
}
protected $message = 'Unknown exception'; // exception message
protected $message = 'Unknown exception'; // exception message
protected $code = 0; // user defined exception code
protected $file; // source filename of exception
protected $line; // source line of exception
private $trace; // backtrace of exception
private $string; // internal only!!
final function getMessage() {
return $this->message;
}
@@ -592,37 +529,11 @@ Changes in the Zend Engine 2.0
}
}
?>
If you derive your exception classes from this Exception base class
your exceptions will be nicely shown in the builtin handler for
your exceptions will be nicely shown in the builtin handler for
uncaught exceptions.
Note: The method getMessage() is a final read only access method to
the private proeprty message that is set in the constructor. If you
feel a need to overwrite the exception display then overload method
__toString() in your derived class or implement your own extneral
exception display function to accomplish your desired formatting.
Example:
<?php
function display_exception(Exception $ex)
{
echo 'Exception: ' . $ex->getMessage() . 'with backtrace: <pre>';
echo $ex->getTrace();
echo '</pre>';
}
try
{
// your code here
}
catch (Exception $ex)
{
display_exeption($ex);
}
?>
* Dereferencing objects returned from functions.
Example:
@@ -662,9 +573,9 @@ Changes in the Zend Engine 2.0
}
print foo::$my_static;
$obj = foo;
print $obj->my_prop;
?>
@@ -691,20 +602,27 @@ Changes in the Zend Engine 2.0
* instanceof.
New support for an instanceof operator which checks if an object
is of a certain class or interface type.
Example:
<?php
class Foo {
}
$obj = new Foo();
if ($obj instanceof Foo) {
print "Yay!\n";
}
?>
* Static function variables.
Statics are now treated at compile-time which allows developers
to assign variables to statics by reference. This change also
greatly improves their performance but means that indirect
references to statics will not work anymore.
* Parameters that are passed by reference to a function
may now have default values.
@@ -720,9 +638,9 @@ Changes in the Zend Engine 2.0
* __autoload().
The __autoload() interceptor function will be automatically called
when an undeclared class is to be instantiated. The name of that
class will be passed to the __autoload() interceptor function as its
The __autoload() interceptor function will be automatically called
when an undeclared class is to be instantiated. The name of that
class will be passed to the __autoload() interceptor function as its
only argument. __autoload() must succeed in loading the class. If it
doesn't then an E_ERROR is emitted.
@@ -799,8 +717,7 @@ Changes in the Zend Engine 2.0
* Iteration
Objects may be iterated in an overloaded way when used with
foreach. The default behavior is to iterate over all properties
with respect to property visibility.
foreach. The default behavior is to iterate over all properties.
Example:
@@ -817,31 +734,34 @@ Changes in the Zend Engine 2.0
}
?>
Each class whose instances can be iterated with foreach should
TBD: Respect visibility: Show protected only when inside class
method and only otherwise public properties only.
Each class whose instances can be iterated with foreach should
implement the empty interface 'Traversable'. Hence any object
that says it implements 'Traversable' can be used with foreach.
The interfaces 'IteratorAggregate' and 'Iterator' allow to specify
how class objects are iterated in PHP code. The first of them simply
has a method 'getIterator' which must return an object that either
implements the interface 'Iterator' or is instantiated from an
has a method 'getIterator' which must return an object that either
implements the interface 'Iterator' or is instantiated from an
internal class that can be iterated.
Example:
<?php
class ObjectIterator implements Iterator {
private $obj;
private $num;
function __construct($obj) {
$this->obj = $obj;
}
function rewind() {
$this->num = 0;
}
function valid() {
function hasMore() {
return $this->num < $this->obj->max;
}
function key() {
@@ -859,82 +779,41 @@ Changes in the Zend Engine 2.0
$this->num++;
}
}
class Object implements IteratorAggregate {
public $max = 3;
function getIterator() {
return new ObjectIterator($this);
}
}
}
$obj = new Object;
// this foreach ...
foreach($obj as $key => $val) {
echo "$key = $val\n";
}
// matches the following 7 lines with the for directive.
$it = $obj->getIterator();
for($it->rewind(); $it->valid(); $it->next()) {
$key = $it->key();
$val = $it->current();
for($it->rewind(); $it->hasMore(); $it->next) {
$key = $it->current();
$val = $it->key();
echo "$key = $val\n";
}
unset($it);
?>
The matching for directive is very intersting here since it shows
The matching for directive is very intersting here since it shows
the use of all abstract methods declared in the interfaces Iterator
and IteratorAggregate respectively.
* Array overloading
Objects can be used with Array notation when they implement the
interface ArrayAccess. You cannot use such objects in standard
array functions, however you have full control over the array
notation. This allows lazy initialization or read only array.
Note that setting [] results in a call to offsetSet() with
index being NULL. That means that as with standard arrays you
cannot store NULL keys.
Example:
<?php
class ArrayClass implements ArrayAccess {
public $a = array();
function offsetExists($index) {
return array_key_exists($index, $this->a);
}
function offsetGet($index) {
return $this->a[$index];
}
function offsetSet($index, $newval) {
return $this->a[$index] = $newval;
}
function offsetUnset($index) {
unset($this->a[$index]);
}
}
$obj = new ArrayClass;
$obj[0] = 'bla'; // calls offsetSet(0,'bla')
$obj[] = 42; // calls offsetSet(NULL, 42)
$x = $obj[0]; // calls offsetGet(0)
$b = isset($obj[0]); // calls offsetExists(0)
unset($obj[0]); // calls offsetUnset(0)
?>
* __METHOD__
The pseudo constant __METHOD__ shows the current class and method
when used inside a method and the function when used outside of a
The pseudo constant __METHOD__ shows the current class and method
when used inside a method and the function when used outside of a
class.
Example:
@@ -952,13 +831,8 @@ Changes in the Zend Engine 2.0
* __toString()
The magic method __toString() allows to overload the object to
string conversion. This conversion is only done automatically for
the printing functions (echo, print) but not for other functions
that expect strings. Also the function __toString is not used in
places where objects are not allowed but strings are like array
indices. Note that specialized objects may be converted to a string
in any place but without calling __toString().
The magic method __toString() allows to overload the object to
string conversion.
Example:
@@ -966,31 +840,26 @@ Changes in the Zend Engine 2.0
class Foo {
function __toString() {
return "What ever";
}
}
$obj = new Foo;
$obj = Foo;
$str = (string) $obj; // call __toString()
echo $obj; // call __toString()
$ar = array();
$ar[(string)$obj]; // this works
$ar[$obj]; // this is not allowed
?>
* Reflection API
PHP 5 comes with a complete Reflection API that adds the ability to
PHP5 comes with a complete reflection API that adds the ability to
reverse-engineer classes, interfaces, functions and methods as well
as extensions.
The Reflection API also offers ways of getting doc comments for
The reflection API also offers ways of getting doc comments for
functions, classes and methods.
Nearly all aspects of object oriented code can be reflected by
using the Reflection API which is documented separately:
using the reflection API which is documented separatley:
http://sitten-polizei.de/php/reflection_api/docs/language.reflection.html
Example:
@@ -1000,14 +869,13 @@ Changes in the Zend Engine 2.0
public $prop;
function Func($name) {
echo "Hello $name";
}
}
ReflectionClass::export('Foo');
ReflectionObject::export(new Foo);
ReflectionMethod::export('Foo', 'func');
ReflectionProperty::export('Foo', 'prop');
ReflectionExtension::export('standard');
reflection_class::export('Foo');
reflection_object::export(new Foo);
reflection_method::export('Foo', 'func');
reflection_property::export('Foo', 'prop');
reflection_extension::export('standard');
?>
* New memory manager
@@ -1018,7 +886,7 @@ Changes in the Zend Engine 2.0
* Others
Probably other changes which we forgot to list. This list will be kept up-to-date
as much as possible.
Changes in the Zend Engine 1.0
-16
View File
@@ -108,22 +108,6 @@ AC_ARG_ENABLE(debug,
AC_DEFUN(LIBZEND_OTHER_CHECKS,[
PHP_ARG_WITH(zend-vm,[virtual machine dispatch method],
[ --with-zend-vm=TYPE Sets virtual machine dispatch methos. Type is
one of "CALL" (default), "SWITCH" or "GOTO"], CALL, no)
case $PHP_ZEND_VM in
SWITCH)
AC_DEFINE(ZEND_VM_KIND,ZEND_VM_KIND_SWITCH,[virtual machine dispatch method])
;;
GOTO)
AC_DEFINE(ZEND_VM_KIND,ZEND_VM_KIND_GOTO,[virtual machine dispatch method])
;;
*)
AC_DEFINE(ZEND_VM_KIND,ZEND_VM_KIND_CALL,[virtual machine dispatch method])
;;
esac
AC_ARG_ENABLE(maintainer-zts,
[ --enable-maintainer-zts Enable thread safety - for code maintainers only],[
ZEND_MAINTAINER_ZTS=$enableval
+6 -14
View File
@@ -160,11 +160,11 @@ SOURCE=.\zend_default_classes.c
# End Source File
# Begin Source File
SOURCE=.\zend_dynamic_array.c
SOURCE=.\zend_interfaces.c
# End Source File
# Begin Source File
SOURCE=.\zend_exceptions.c
SOURCE=.\zend_dynamic_array.c
# End Source File
# Begin Source File
@@ -204,10 +204,6 @@ SOURCE=.\zend_ini_scanner.c
# End Source File
# Begin Source File
SOURCE=.\zend_interfaces.c
# End Source File
# Begin Source File
SOURCE=.\zend_iterators.c
# End Source File
# Begin Source File
@@ -324,6 +320,10 @@ SOURCE=.\zend_default_classes.h
# End Source File
# Begin Source File
SOURCE=.\zend_interfaces.h
# End Source File
# Begin Source File
SOURCE=.\zend_dynamic_array.h
# End Source File
# Begin Source File
@@ -332,10 +332,6 @@ SOURCE=.\zend_errors.h
# End Source File
# Begin Source File
SOURCE=.\zend_exceptions.h
# End Source File
# Begin Source File
SOURCE=.\zend_execute.h
# End Source File
# Begin Source File
@@ -380,10 +376,6 @@ SOURCE=.\zend_ini_scanner.h
# End Source File
# Begin Source File
SOURCE=.\zend_interfaces.h
# End Source File
# Begin Source File
SOURCE=.\zend_istdiostream.h
# End Source File
# Begin Source File
+3 -16
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -37,8 +37,6 @@
@BOTTOM@
#endif
#ifndef ZEND_ACCONFIG_H_NO_C_PROTOS
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
@@ -47,10 +45,6 @@
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_IEEEFP_H
# include <ieeefp.h>
#endif
@@ -69,16 +63,11 @@ int zend_sprintf(char *buffer, const char *format, ...);
#include <math.h>
/* To enable the is_nan, is_infinite and is_finite PHP functions */
#ifdef NETWARE
#define HAVE_ISNAN 1
#define HAVE_ISINF 1
#define HAVE_ISFINITE 1
#endif
#ifndef zend_isnan
#ifdef HAVE_ISNAN
#define zend_isnan(a) isnan(a)
#elif defined(NAN)
#define zend_isnan(a) (((a)==NAN)?1:0)
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
#else
@@ -107,8 +96,6 @@ int zend_sprintf(char *buffer, const char *format, ...);
#define zend_finite(a) (zend_isnan(a) ? 0 : zend_isinf(a) ? 0 : 1)
#endif
#endif /* ifndef ZEND_ACCONFIG_H_NO_C_PROTOS */
/*
* Local variables:
* tab-width: 4
-412
View File
@@ -1,412 +0,0 @@
<?php
function simple() {
for ($i = 0; $i < 1000000; $i++)
$a++;
for ($thisisalongname = 0; $thisisalongname < 1000000; $thisisalongname++)
$thisisanotherlongname++;
}
/****/
function simplecall() {
for ($i = 0; $i < 1000000; $i++)
strlen("hallo");
}
/****/
function hallo($a) {
}
function simpleucall() {
for ($i = 0; $i < 1000000; $i++)
hallo("hallo");
}
/****/
function simpleudcall() {
for ($i = 0; $i < 1000000; $i++)
hallo2("hallo");
}
function hallo2($a) {
}
/****/
function mandel() {
$w1=50;
$h1=150;
$recen=-.45;
$imcen=0.0;
$r=0.7;
$s=0; $rec=0; $imc=0; $re=0; $im=0; $re2=0; $im2=0;
$x=0; $y=0; $w2=0; $h2=0; $color=0;
$s=2*$r/$w1;
$w2=40;
$h2=12;
for ($y=0 ; $y<=$w1; $y=$y+1) {
$imc=$s*($y-$h2)+$imcen;
for ($x=0 ; $x<=$h1; $x=$x+1) {
$rec=$s*($x-$w2)+$recen;
$re=$rec;
$im=$imc;
$color=1000;
$re2=$re*$re;
$im2=$im*$im;
while( ((($re2+$im2)<1000000) && $color>0)) {
$im=$re*$im*2+$imc;
$re=$re2-$im2+$rec;
$re2=$re*$re;
$im2=$im*$im;
$color=$color-1;
}
if ( $color==0 ) {
print "_";
} else {
print "#";
}
}
print "<br>".$vbCr;
flush();
}
}
/****/
function mandel2() {
$b = " .:,;!/>)|&IH%*#";
//float r, i, z, Z, t, c, C;
for ($y=30; printf("\n"), $C = $y*0.1 - 1.5, $y--;){
for ($x=0; $c = $x*0.04 - 2, $z=0, $Z=0, $x++ < 75;){
for ($r=$c, $i=$C, $k=0; $t = $z*$z - $Z*$Z + $r, $Z = 2*$z*$Z + $i, $z=$t, $k<5000; $k++)
if ($z*$z + $Z*$Z > 500000) break;
echo $b[$k%16];
}
}
}
/****/
function Ack($m, $n){
if($m == 0) return $n+1;
if($n == 0) return Ack($m-1, 1);
return Ack($m - 1, Ack($m, ($n - 1)));
}
function ackermann($n) {
$r = Ack(3,$n);
print "Ack(3,$n): $r\n";
}
/****/
function ary($n) {
for ($i=0; $i<$n; $i++) {
$X[$i] = $i;
}
for ($i=$n-1; $i>=0; $i--) {
$Y[$i] = $X[$i];
}
$last = $n-1;
print "$Y[$last]\n";
}
/****/
function ary2($n) {
for ($i=0; $i<$n;) {
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
}
for ($i=$n-1; $i>=0; $i--) {
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
}
$last = $n-1;
print "$Y[$last]\n";
}
/****/
function ary3($n) {
for ($i=0; $i<$n; $i++) {
$X[$i] = $i + 1;
}
for ($k=0; $k<1000; $k++) {
for ($i=$n-1; $i>=0; $i--) {
$Y[$i] += $X[$i];
}
}
$last = $n-1;
print "$Y[0] $Y[$last]\n";
}
/****/
function fibo_r($n){
return(($n < 2) ? 1 : fibo($n - 2) + fibo_r($n - 1));
}
function fibo($n) {
$r = fibo_r($n);
print "$r\n";
}
/****/
function hash($n) {
for ($i = 1; $i <= $n; $i++) {
$X[dechex($i)] = $i;
}
for ($i = $n; $i > 0; $i--) {
if ($X[$i]) { $c++; }
}
print "$c\n";
}
/****/
function hash2($n) {
for ($i = 0; $i < 10000; $i++) {
$hash1["foo_$i"] = $i;
}
for ($i = $n; $i > 0; $i--) {
foreach($hash1 as $key => $value) $hash2[$key] += $value;
}
print "$hash1[foo_1] $hash1[foo_9999] $hash2[foo_1] $hash2[foo_9999]\n";
}
/****/
function gen_random ($n) {
global $LAST;
return( ($n * ($LAST = ($LAST * IA + IC) % IM)) / IM );
}
function heapsort_r($n, &$ra) {
$l = ($n >> 1) + 1;
$ir = $n;
while (1) {
if ($l > 1) {
$rra = $ra[--$l];
} else {
$rra = $ra[$ir];
$ra[$ir] = $ra[1];
if (--$ir == 1) {
$ra[1] = $rra;
return;
}
}
$i = $l;
$j = $l << 1;
while ($j <= $ir) {
if (($j < $ir) && ($ra[$j] < $ra[$j+1])) {
$j++;
}
if ($rra < $ra[$j]) {
$ra[$i] = $ra[$j];
$j += ($i = $j);
} else {
$j = $ir + 1;
}
}
$ra[$i] = $rra;
}
}
function heapsort($N) {
global $LAST;
define("IM", 139968);
define("IA", 3877);
define("IC", 29573);
$LAST = 42;
for ($i=1; $i<=$N; $i++) {
$ary[$i] = gen_random(1);
}
heapsort_r($N, $ary);
printf("%.10f\n", $ary[$N]);
}
/****/
function mkmatrix ($rows, $cols) {
$count = 1;
$mx = array();
for ($i=0; $i<$rows; $i++) {
for ($j=0; $j<$cols; $j++) {
$mx[$i][$j] = $count++;
}
}
return($mx);
}
function mmult ($rows, $cols, $m1, $m2) {
$m3 = array();
for ($i=0; $i<$rows; $i++) {
for ($j=0; $j<$cols; $j++) {
$x = 0;
for ($k=0; $k<$cols; $k++) {
$x += $m1[$i][$k] * $m2[$k][$j];
}
$m3[$i][$j] = $x;
}
}
return($m3);
}
function matrix($n) {
$SIZE = 30;
$m1 = mkmatrix($SIZE, $SIZE);
$m2 = mkmatrix($SIZE, $SIZE);
while ($n--) {
$mm = mmult($SIZE, $SIZE, $m1, $m2);
}
print "{$mm[0][0]} {$mm[2][3]} {$mm[3][2]} {$mm[4][4]}\n";
}
/****/
function nestedloop($n) {
$x = 0;
for ($a=0; $a<$n; $a++)
for ($b=0; $b<$n; $b++)
for ($c=0; $c<$n; $c++)
for ($d=0; $d<$n; $d++)
for ($e=0; $e<$n; $e++)
for ($f=0; $f<$n; $f++)
$x++;
print "$x\n";
}
/****/
function sieve($n) {
$count = 0;
while ($n-- > 0) {
$count = 0;
$flags = range (0,8192);
for ($i=2; $i<8193; $i++) {
if ($flags[$i] > 0) {
for ($k=$i+$i; $k <= 8192; $k+=$i) {
$flags[$k] = 0;
}
$count++;
}
}
}
print "Count: $count\n";
}
/****/
function strcat($n) {
$str = "";
while ($n-- > 0) {
$str .= "hello\n";
}
$len = strlen($str);
print "$len\n";
}
/*****/
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function start_test()
{
ob_start();
return getmicrotime();
}
function end_test($start, $name)
{
global $total;
$end = getmicrotime();
ob_end_clean();
$total += $end-$start;
$num = number_format($end-$start,3);
$pad = str_repeat(" ", 24-strlen($name)-strlen($num));
echo $name.$pad.$num."\n";
ob_start();
return getmicrotime();
}
function total()
{
global $total;
$pad = str_repeat("-", 24);
echo $pad."\n";
$num = number_format($total,3);
$pad = str_repeat(" ", 24-strlen("Total")-strlen($num));
echo "Total".$pad.$num."\n";
}
$t0 = $t = start_test();
simple();
$t = end_test($t, "simple");
simplecall();
$t = end_test($t, "simplecall");
simpleucall();
$t = end_test($t, "simpleucall");
simpleudcall();
$t = end_test($t, "simpleudcall");
mandel();
$t = end_test($t, "mandel");
mandel2();
$t = end_test($t, "mandel2");
ackermann(7);
$t = end_test($t, "ackermann(7)");
ary(50000);
$t = end_test($t, "ary(50000)");
ary2(50000);
$t = end_test($t, "ary2(50000)");
ary3(2000);
$t = end_test($t, "ary3(2000)");
fibo(30);
$t = end_test($t, "fibo(30)");
hash(50000);
$t = end_test($t, "hash(50000)");
hash2(50);
$t = end_test($t, "hash2(50)");
heapsort(20000);
$t = end_test($t, "heapsort(20000)");
matrix(20);
$t = end_test($t, "matrix(20)");
nestedloop(12);
$t = end_test($t, "nestedloop(12)");
sieve(30);
$t = end_test($t, "sieve(30)");
strcat(200000);
$t = end_test($t, "strcat(200000)");
total($t0, "Total");
?>
+1 -1
View File
@@ -39,5 +39,5 @@ echo "Done\n";
2
3
Done
test::__destruct
test::destructor
test::__destruct
+4 -54
View File
@@ -7,9 +7,9 @@ Bug #22836 (returning references to NULL)
function &f()
{
$x = "foo";
var_dump($x);
print "'$x'\n";
return ($a);
var_dump($x);
print "'$x'\n";
return ($a);
}
for ($i = 0; $i < 8; $i++) {
$h =& f();
@@ -21,54 +21,4 @@ string(3) "foo"
Notice: Undefined variable: a in %s on line %d
Strict Standards: Only variable references should be returned by reference in %s on line %d
string(3) "foo"
'foo'
Notice: Undefined variable: a in %s on line %d
Strict Standards: Only variable references should be returned by reference in %s on line %d
string(3) "foo"
'foo'
Notice: Undefined variable: a in %s on line %d
Strict Standards: Only variable references should be returned by reference in %s on line %d
string(3) "foo"
'foo'
Notice: Undefined variable: a in %s on line %d
Strict Standards: Only variable references should be returned by reference in %s on line %d
string(3) "foo"
'foo'
Notice: Undefined variable: a in %s on line %d
Strict Standards: Only variable references should be returned by reference in %s on line %d
string(3) "foo"
'foo'
Notice: Undefined variable: a in %s on line %d
Strict Standards: Only variable references should be returned by reference in %s on line %d
string(3) "foo"
'foo'
Notice: Undefined variable: a in %s on line %d
Strict Standards: Only variable references should be returned by reference in %s on line %d
string(3) "foo"
'foo'
Notice: Undefined variable: a in %s on line %d
Strict Standards: Only variable references should be returned by reference in %s on line %d
string(3) "foo"
'foo'
Notice: Undefined variable: a in %s on line %d
Strict Standards: Only variable references should be returned by reference in %s on line %d
Fatal error: Only variables or references can be returned by reference in %s on line %d
+2 -2
View File
@@ -15,7 +15,7 @@ class Test {
}
else
{
return clone $this;
return $this->__clone();
}
}
}
@@ -24,5 +24,5 @@ $test2 = $test->__copy();
var_dump($test2);
?>
--EXPECT--
object(Test)#2 (0) {
object(test)#2 (0) {
}
-9
View File
@@ -1,9 +0,0 @@
--TEST--
Bug #26077 Memory leaks when creating an instance of an object
--FILE--
<?php
class foo {} new foo();
?>
===DONE===
--EXPECT--
===DONE===
+2 -2
View File
@@ -1,5 +1,5 @@
--TEST--
Bug #26166 (__toString() crash when no values returned)
Bug #26166: __toString() crash when no values returned
--FILE--
<?php
class Foo
@@ -64,4 +64,4 @@ Hello World!
Got the exception
===NONE===
Fatal error: Method None::__toString() must return a string value in %sbug26166.php on line %d
Fatal error: Method none::__toString() must return a string value in %sbug26166.php on line %d
-21
View File
@@ -1,21 +0,0 @@
--TEST--
Bug #26229 (getIterator() segfaults when it returns arrays or scalars)
--FILE--
<?php
class array_iterator implements IteratorAggregate {
public function getIterator() {
return array('foo', 'bar');
}
}
$obj = new array_iterator;
foreach ($obj as $property => $value) {
var_dump($value);
}
?>
===DONE===
--EXPECTF--
Warning: Objects returned by array_iterator::getIterator() must be traversable or implement interface Iterator in %sbug26229.php on line %d
===DONE===
-22
View File
@@ -1,22 +0,0 @@
--TEST--
Bug #26696 (crash in switch() when string index is used)
--FILE--
<?php
$str = 'asdd/?';
$len = strlen($str);
for ($i = 0; $i < $len; $i++) {
switch ($str[$i]) {
case '?':
echo "?+\n";
break;
default:
echo $str[$i].'-';
break;
}
}
?>
===DONE===
--EXPECT--
a-s-d-d-/-?+
===DONE===
-24
View File
@@ -1,24 +0,0 @@
--TEST--
Bug #26697 (calling class_exists on a nonexistent class in __autoload results in segfault)
--SKIPIF--
<?php if (function_exists('__autoload')) die('skip __autoload() declared in auto_prepend_file');?>
--FILE--
<?php
function __autoload($name)
{
echo __METHOD__ . "($name)\n";
var_dump(class_exists('NotExistingClass'));
echo __METHOD__ . "($name), done\n";
}
var_dump(class_exists('NotExistingClass'));
?>
===DONE===
--EXPECTF--
__autoload(NotExistingClass)
bool(false)
__autoload(NotExistingClass), done
bool(false)
===DONE===
-73
View File
@@ -1,73 +0,0 @@
--TEST--
Bug #26698 (Thrown exceptions while evaluting argument to pass as parameter crash PHP)
--FILE--
<?php
ini_set("report_memleaks", 0); // the exception thrown in this test results in a memory leak, which is fine
class Object
{
function getNone()
{
throw new Exception('NONE');
}
}
class Proxy
{
function three($a, $b, $c)
{
}
function callOne()
{
try
{
$res = new Object();
$this->three($res->getNone());
}
catch(Exception $e)
{
echo 'Caught: '.$e->getMessage()."\n";
}
}
function callTwo()
{
try
{
$res = new Object();
$this->three(1, $res->getNone());
}
catch(Exception $e)
{
echo 'Caught: '.$e->getMessage()."\n";
}
}
function callThree()
{
try
{
$res = new Object();
$this->three(1, 2, $res->getNone());
}
catch(Exception $e)
{
echo 'Caught: '.$e->getMessage()."\n";
}
}
}
$p = new Proxy();
$p->callOne();
$p->callTwo();
$p->callThree();
?>
===DONE===
--EXPECT--
Caught: NONE
Caught: NONE
Caught: NONE
===DONE===
-22
View File
@@ -1,22 +0,0 @@
--TEST--
Bug #26801 (switch ($a{0}) crash)
--FILE--
<?php
$a = '11';
$b = $a{0};
switch ($b) {
case '-':
break;
}
$a = '22';
switch ($a{0}) {
case '-':
break;
}
?>
===DONE===
--EXPECT--
===DONE===
-37
View File
@@ -1,37 +0,0 @@
--TEST--
Bug #26802 (Can't call static method using a variable)
--FILE--
<?php
function global_func()
{
echo __METHOD__ . "\n";
}
$function = 'global_func';
$function();
class foo
{
static $method = 'global_func';
static public function foo_func()
{
echo __METHOD__ . "\n";
}
}
/* The following is a BC break with PHP 4 where it would
* call foo::fail. In PHP 5 we first evaluate static class
* properties and then do the function call.
*/
$method = 'foo_func';
foo::$method();
?>
===DONE===
--EXPECT--
global_func
foo::foo_func
===DONE===
-13
View File
@@ -1,13 +0,0 @@
--TEST--
Bug #27145 (Errors messages print unmangled PPP property names)
--FILE--
<?php
class a {
protected static $v = "aa";
}
class b extends a {
protected static $v = "bb";
}
?>
--EXPECTF--
Fatal error: Cannot redeclare property static protected a::$v in class b in %s on line %d
-42
View File
@@ -1,42 +0,0 @@
--TEST--
Bug #27641 (zend.ze1_compatibility_mode = On causes object properties to be misreported)
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?>
--FILE--
<?php
class A {
public $a = "Default for A";
public $b = "Default for B";
function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
function A() {
$args = func_get_args();
call_user_func_array(Array(&$this, '__construct'), $args);
}
}
$t = new A("New A", "New B");
print_r($t);
print_r(get_class_vars(get_class($t)));
print_r(get_object_vars($t));
?>
--EXPECTF--
Strict Standards: Redefining already defined constructor for class A in %sbug27641.php on line %d
A Object
(
[a] => New A
[b] => New B
)
Array
(
[a] => Default for A
[b] => Default for B
)
Array
(
[a] => New A
[b] => New B
)
-18
View File
@@ -1,18 +0,0 @@
--TEST--
Bug #27669 (PHP 5 didn't support all possibilities for calling static methods dynamically)
--FILE--
<?php
error_reporting(E_ALL & !E_STRICT);
class A {
function hello() {
echo "Hello World\n";
}
}
$y[0] = 'hello';
A::$y[0]();
?>
===DONE===
--EXPECTF--
Hello World
===DONE===
-10
View File
@@ -1,10 +0,0 @@
--TEST--
Bug #27731 (error_reporing() call inside @ block does not work correctly)
--FILE--
<?php
error_reporting(E_ALL ^ E_NOTICE);
@error_reporting(E_WARNING);
var_dump(error_reporting());
?>
--EXPECT--
int(2)
-72
View File
@@ -1,72 +0,0 @@
--TEST--
Bug #27798 (private / protected variables not exposed by get_object_vars() inside class)
--FILE--
<?php
class Base
{
public $Foo = 1;
protected $Bar = 2;
private $Baz = 3;
function __construct()
{
echo __METHOD__ . "\n";
var_dump(get_object_vars($this));
}
}
class Child extends Base
{
private $Baz = 4;
function __construct()
{
parent::__construct();
echo __METHOD__ . "\n";
var_dump(get_object_vars($this));
}
}
var_dump(get_object_vars(new Base));
var_dump(get_object_vars(new Child));
?>
===DONE===
--EXPECT--
Base::__construct
array(3) {
["Foo"]=>
int(1)
["Bar"]=>
int(2)
["Baz"]=>
int(3)
}
array(1) {
["Foo"]=>
int(1)
}
Base::__construct
array(3) {
["Baz"]=>
int(4)
["Foo"]=>
int(1)
["Bar"]=>
int(2)
}
Child::__construct
array(3) {
["Baz"]=>
int(4)
["Foo"]=>
int(1)
["Bar"]=>
int(2)
}
array(1) {
["Foo"]=>
int(1)
}
===DONE===
-74
View File
@@ -1,74 +0,0 @@
--TEST--
Bug #28444 (Cannot access undefined property for object with overloaded property access)
--FILE--
<?php
class Object
{
public $x;
function __construct($x)
{
$this->x = $x;
}
}
class Overloaded
{
public $props = array();
public $x;
function __construct($x)
{
$this->x = new Object($x);
}
function __get($prop)
{
echo __METHOD__ . "($prop)\n";
return $this->props[$prop];
}
function __set($prop, $val)
{
echo __METHOD__ . "($prop,$val)\n";
$this->props[$prop] = $val;
}
}
$y = new Overloaded(2);
var_dump($y->x);
var_dump($y->x->x);
var_dump($y->x->x = 3);
var_dump($y->y = 3);
var_dump($y->y);
var_dump($y->z = new Object(4));
var_dump($y->z->x);
$t = $y->z;
var_dump($t->x = 5);
var_dump($y->z->x = 6);
?>
===DONE===
--EXPECTF--
object(Object)#%d (1) {
["x"]=>
int(2)
}
int(2)
int(3)
Overloaded::__set(y,3)
int(3)
Overloaded::__get(y)
int(3)
Overloaded::__set(z,Object id #3)
object(Object)#%d (1) {
["x"]=>
int(4)
}
Overloaded::__get(z)
int(4)
Overloaded::__get(z)
int(5)
Overloaded::__get(z)
int(6)
===DONE===
-34
View File
@@ -1,34 +0,0 @@
--TEST--
Bug #29368 (The destructor is called when an exception is thrown from the constructor)
--FILE--
<?
class Foo
{
function __construct()
{
echo __METHOD__ . "\n";
throw new Exception;
}
function __destruct()
{
echo __METHOD__ . "\n";
}
}
try
{
$bar = new Foo;
} catch(Exception $exc)
{
echo "Caught exception!\n";
}
unset($bar);
?>
===DONE===
--EXPECTF--
Foo::__construct
Caught exception!
===DONE===
-31
View File
@@ -1,31 +0,0 @@
--TEST--
Bug #29505 (get_class_vars() severely broken when used with arrays)
--FILE--
<?php
class Test {
public $empty = array();
public $three = array(1, "b"=>"c", 3=>array());
}
var_dump(get_class_vars('Test'));
?>
===DONE===
--EXPECT--
array(2) {
["empty"]=>
array(0) {
}
["three"]=>
array(3) {
[0]=>
int(1)
["b"]=>
string(1) "c"
[3]=>
array(0) {
}
}
}
===DONE===
-3
View File
@@ -1,3 +0,0 @@
<?php
unset($x)
?>
-13
View File
@@ -1,13 +0,0 @@
--TEST--
unset() CV 1 (unset() global variable)
--FILE--
<?php
$x = "ok\n";
echo $x;
unset($x);
echo $x;
?>
--EXPECTF--
ok
Notice: Undefined variable: x in %sunset_cv01.php on line %d
-13
View File
@@ -1,13 +0,0 @@
--TEST--
unset() CV 2 (unset() global variable in $GLOBALS)
--FILE--
<?php
$x = "ok\n";
echo $x;
unset($GLOBALS["x"]);
echo $x;
?>
--EXPECTF--
ok
Notice: Undefined variable: x in %sunset_cv02.php on line %d
-13
View File
@@ -1,13 +0,0 @@
--TEST--
unset() CV 3 (unset() global variable in included file)
--FILE--
<?php
$x = "ok\n";
echo $x;
include "unset.inc";
echo $x;
?>
--EXPECTF--
ok
Notice: Undefined variable: x in %sunset_cv03.php on line %d
-16
View File
@@ -1,16 +0,0 @@
--TEST--
unset() CV 4 (unset() local variable in included file)
--FILE--
<?php
function f() {
$x = "ok\n";
echo $x;
include "unset.inc";
echo $x;
}
f();
?>
--EXPECTF--
ok
Notice: Undefined variable: x in %sunset_cv04.php on line %d
-20
View File
@@ -1,20 +0,0 @@
--TEST--
unset() CV 5 (indirect unset() of global variable in session_start())
--SKIPIF--
<?php include('../../ext/session/tests/skipif.inc'); ?>
--FILE--
<?php
$HTTP_SESSION_VARS = "ok\n";
echo $HTTP_SESSION_VARS;
session_start();
echo $HTTP_SESSION_VARS;
echo "\nok\n";
?>
--EXPECTF--
ok
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at %sunset_cv05.php on line %d
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at %sunset_cv05.php:%d) in %sunset_cv05.php on line %d
Array
ok
-24
View File
@@ -1,24 +0,0 @@
--TEST--
unset() CV 6 (indirect unset() of global variable in session_unset())
--SKIPIF--
<?php include('../../ext/session/tests/skipif.inc'); ?>
--INI--
register_globals=1
--FILE--
<?php
$x = "1\n";
session_start();
echo $x;
session_register('x');
$_SESSION['x'] = "2\n";
echo $x;
session_unset();
echo $x;
echo "ok\n";
?>
--EXPECTF--
1
2
Notice: Undefined variable: x in %sunset_cv06.php on line %d
ok
-20
View File
@@ -1,20 +0,0 @@
--TEST--
unset() CV 7 (indirect unset() of global variable in import_request_variables())
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--INI--
error_reporting=2039
--GET--
x=2
--FILE--
<?php
$x = "1\n";
echo $x;
import_request_variables("g");
echo $x;
echo "\nok\n";
?>
--EXPECT--
1
2
ok
-16
View File
@@ -1,16 +0,0 @@
--TEST--
unset() CV 8 (unset() of global variable in array_unique($GLOBALS))
--FILE--
<?php
$a = "ok\n";
$b = "ok\n";
array_unique($GLOBALS);
echo $a;
echo $b;
echo "ok\n";
?>
--EXPECTF--
ok
Notice: Undefined variable: b in %sunset_cv08.php on line %d
ok
-14
View File
@@ -1,14 +0,0 @@
--TEST--
unset() CV 9 (unset() of global variable in array_pop($GLOBALS))
--FILE--
<?php
$x = "ok\n";
echo array_pop($GLOBALS);
echo $x;
echo "ok\n";
?>
--EXPECTF--
ok
Notice: Undefined variable: x in %sunset_cv09.php on line %d
ok
-18
View File
@@ -1,18 +0,0 @@
--TEST--
unset() CV 10 (unset() of global variable in ArrayObject::offsetUnset($GLOBALS))
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
$a = new ArrayObject($GLOBALS);
$x = "ok\n";
echo $x;
$a->offsetUnset('x');
echo $x;
echo "ok\n";
?>
--EXPECTF--
ok
Notice: Undefined variable: x in %sunset_cv10.php on line %d
ok
-21
View File
@@ -1,21 +0,0 @@
--TEST--
unset() CV 11 (unset() of copy destoies original value)
--FILE--
<?php
$x = array("default"=>"ok");
var_dump($x);
$cf = $x;
unset($cf['default']);
var_dump($x);
echo "ok\n";
?>
--EXPECT--
array(1) {
["default"]=>
string(2) "ok"
}
array(1) {
["default"]=>
string(2) "ok"
}
ok
-12
View File
@@ -1,12 +0,0 @@
--TEST--
Operator precedence
--FILE--
<?php /* $Id$ */
var_dump((object)1 instanceof stdClass);
var_dump(! (object)1 instanceof Exception);
?>
--EXPECT--
bool(true)
bool(true)
+65 -60
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -25,7 +25,7 @@
#include "zend_constants.h"
#include "zend_list.h"
#include "zend_API.h"
#include "zend_exceptions.h"
#include "zend_default_classes.h"
#include "zend_builtin_functions.h"
#include "zend_ini.h"
@@ -55,7 +55,6 @@ ZEND_API void (*zend_unblock_interruptions)(void);
ZEND_API void (*zend_ticks_function)(int ticks);
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
void (*zend_on_timeout)(int seconds TSRMLS_DC);
@@ -74,9 +73,20 @@ static ZEND_INI_MH(OnUpdateErrorReporting)
}
static ZEND_INI_MH(OnUpdateImplicitClone)
{
if (!new_value) {
EG(implicit_clone) = 0;
} else {
EG(implicit_clone) = atoi(new_value) ? 1 : 0;
}
return SUCCESS;
}
ZEND_INI_BEGIN()
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
STD_ZEND_INI_BOOLEAN("zend.ze1_compatibility_mode", "0", ZEND_INI_ALL, OnUpdateBool, ze1_compatibility_mode, zend_executor_globals, executor_globals)
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
ZEND_INI_ENTRY("zend2.implicit_clone", NULL, ZEND_INI_ALL, OnUpdateImplicitClone)
ZEND_INI_END()
@@ -84,6 +94,7 @@ ZEND_INI_END()
ZEND_API int compiler_globals_id;
ZEND_API int executor_globals_id;
ZEND_API int alloc_globals_id;
zend_class_entry global_main_class;
HashTable *global_function_table;
HashTable *global_class_table;
HashTable *global_constants_table;
@@ -97,7 +108,7 @@ ZEND_API zval zval_used_for_init; /* True global variable */
/* version information */
static char *zend_version_info;
static uint zend_version_info_length;
#define ZEND_CORE_VERSION_INFO "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2004 Zend Technologies\n"
#define ZEND_CORE_VERSION_INFO "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2003 Zend Technologies\n"
#define PRINT_ZVAL_INDENT 4
@@ -127,7 +138,7 @@ static void print_hash(HashTable *ht, int indent, zend_bool is_object TSRMLS_DC)
if (is_object) {
char *prop_name, *class_name;
zend_unmangle_property_name(string_key, &class_name, &prop_name);
unmangle_property_name(string_key, &class_name, &prop_name);
ZEND_PUTS(prop_name);
if (class_name) {
if (class_name[0]=='*') {
@@ -194,7 +205,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
switch (expr->type) {
case IS_NULL:
expr_copy->value.str.len = 0;
expr_copy->value.str.val = STR_EMPTY_ALLOC();
expr_copy->value.str.val = empty_string;
break;
case IS_BOOL:
if (expr->value.lval) {
@@ -202,7 +213,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
expr_copy->value.str.val = estrndup("1", 1);
} else {
expr_copy->value.str.len = 0;
expr_copy->value.str.val = STR_EMPTY_ALLOC();
expr_copy->value.str.val = empty_string;
}
break;
case IS_RESOURCE:
@@ -214,35 +225,19 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
expr_copy->value.str.val = estrndup("Array", expr_copy->value.str.len);
break;
case IS_OBJECT:
{
if (expr->value.obj.handlers->cast_object) {
TSRMLS_FETCH();
#if 0
/* Standard PHP objects */
if (Z_OBJ_HT_P(expr) == &std_object_handlers || !Z_OBJ_HT_P(expr)->cast_object) {
if (expr->value.obj.handlers->cast_object == zend_std_cast_object) {
if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
break;
}
zend_error(E_NOTICE, "Object of class %s could not be converted to string", Z_OBJCE_P(expr)->name);
}
#endif
if (Z_OBJ_HANDLER_P(expr, cast_object)) {
if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
break;
}
} else {
if(Z_OBJ_HANDLER_P(expr, get)) {
zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC);
if(Z_TYPE_P(z) != IS_OBJECT) {
zend_make_printable_zval(z, expr_copy, use_copy);
FREE_ZVAL(z);
return;
}
}
} else if (expr->value.obj.handlers->cast_object(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
break;
}
if (EG(exception)) {
zval_dtor(expr_copy);
expr_copy->value.str.len = 0;
expr_copy->value.str.val = STR_EMPTY_ALLOC();
expr_copy->value.str.val = empty_string;
break;
}
}
@@ -405,7 +400,7 @@ static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
static void register_standard_class(TSRMLS_D)
{
zend_standard_class_def = calloc(1, sizeof(zend_class_entry));
zend_standard_class_def = malloc(sizeof(zend_class_entry));
zend_standard_class_def->type = ZEND_INTERNAL_CLASS;
zend_standard_class_def->name_length = sizeof("stdClass") - 1;
@@ -429,7 +424,7 @@ static void zend_set_default_compile_time_values(TSRMLS_D)
static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS_DC)
{
zend_function tmp_func;
zend_class_entry *tmp_class;
zend_class_entry tmp_class;
compiler_globals->compiled_filename = NULL;
@@ -439,7 +434,7 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
zend_hash_copy(compiler_globals->class_table, global_class_table, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry *));
zend_hash_copy(compiler_globals->class_table, global_class_table, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry));
zend_set_default_compile_time_values(TSRMLS_C);
@@ -477,9 +472,7 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS
EG(user_error_handler) = NULL;
EG(user_exception_handler) = NULL;
EG(in_execution) = 0;
EG(in_autoload) = NULL;
EG(current_execute_data) = NULL;
EG(current_module) = NULL;
}
@@ -512,8 +505,8 @@ static void alloc_globals_dtor(zend_alloc_globals *alloc_globals_p TSRMLS_DC)
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
/* FreeBSD and DragonFly floating point precision fix */
#ifdef __FreeBSD__
/* FreeBSD floating point precision fix */
#include <floatingpoint.h>
#endif
@@ -554,8 +547,8 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
alloc_globals_ctor(&alloc_globals TSRMLS_CC);
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
/* FreeBSD and DragonFly floating point precision fix */
#ifdef __FreeBSD__
/* FreeBSD floating point precision fix */
fpsetmask(0);
#endif
@@ -577,12 +570,10 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
zend_ticks_function = utility_functions->ticks_function;
zend_on_timeout = utility_functions->on_timeout;
zend_vspprintf = utility_functions->vspprintf_function;
zend_getenv = utility_functions->getenv_function;
zend_compile_file = compile_file;
zend_execute = execute;
zend_execute_internal = NULL;
zend_throw_exception_hook = NULL;
zend_init_opcodes_handlers();
@@ -620,7 +611,6 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
tsrm_ls = ts_resource_ex(0, NULL);
compiler_globals_dtor(compiler_globals TSRMLS_CC);
compiler_globals->in_compilation = 0;
compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
@@ -650,6 +640,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
if (start_builtin_functions) {
zend_startup_builtin_functions(TSRMLS_C);
}
zend_register_default_classes(TSRMLS_C);
zend_ini_startup(TSRMLS_C);
@@ -687,7 +678,6 @@ void zend_post_startup(TSRMLS_D)
compiler_globals_ctor(compiler_globals, tsrm_ls);
free(EG(zend_constants));
executor_globals_ctor(executor_globals, tsrm_ls);
zend_new_thread_end_handler(tsrm_thread_id() TSRMLS_CC);
}
#endif
@@ -701,6 +691,7 @@ void zend_shutdown(TSRMLS_D)
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
#endif
zend_hash_graceful_reverse_destroy(&module_registry);
zend_destroy_rsrc_list_dtors();
zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
zend_hash_destroy(GLOBAL_CLASS_TABLE);
@@ -721,7 +712,6 @@ void zend_shutdown(TSRMLS_D)
GLOBAL_CLASS_TABLE = NULL;
GLOBAL_AUTO_GLOBALS_TABLE = NULL;
#endif
zend_destroy_rsrc_list_dtors();
}
@@ -806,13 +796,6 @@ void zend_deactivate_modules(TSRMLS_D)
} zend_end_try();
}
void zend_call_destructors(TSRMLS_D)
{
zend_try {
shutdown_destructors(TSRMLS_C);
} zend_end_try();
}
void zend_deactivate(TSRMLS_D)
{
/* we're no longer executing anything */
@@ -838,14 +821,14 @@ void zend_deactivate(TSRMLS_D)
static int exec_done_cb(zend_module_entry *module TSRMLS_DC)
{
if (module->post_deactivate_func) {
module->post_deactivate_func();
if (module->exec_finished_func) {
module->exec_finished_func();
}
return 0;
}
void zend_post_deactivate_modules(TSRMLS_D)
void zend_exec_finished(TSRMLS_D)
{
zend_hash_apply(&module_registry, (apply_func_t) exec_done_cb TSRMLS_CC);
}
@@ -880,6 +863,8 @@ ZEND_API void zend_error(int type, const char *format, ...)
char *error_filename;
uint error_lineno;
zval *orig_user_error_handler;
zval *orig_garbage[2];
int orig_garbage_ptr;
TSRMLS_FETCH();
/* Obtain relevant filename and lineno */
@@ -922,8 +907,7 @@ ZEND_API void zend_error(int type, const char *format, ...)
va_start(args, format);
/* if we don't have a user defined error handler */
if (!EG(user_error_handler)
|| !(EG(user_error_handler_error_reporting) & type)) {
if (!EG(user_error_handler)) {
zend_error_cb(type, error_filename, error_lineno, format, args);
} else switch (type) {
case E_ERROR:
@@ -972,11 +956,14 @@ ZEND_API void zend_error(int type, const char *format, ...)
orig_user_error_handler = EG(user_error_handler);
EG(user_error_handler) = NULL;
orig_garbage_ptr = EG(garbage_ptr);
EG(garbage_ptr) = 0;
if (orig_garbage_ptr > 0) {
memcpy(&orig_garbage, &EG(garbage), sizeof(zval*)*orig_garbage_ptr);
}
if (call_user_function_ex(CG(function_table), NULL, orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC)==SUCCESS) {
if (retval) {
if (Z_TYPE_P(retval) == IS_BOOL && Z_LVAL_P(retval) == 0) {
zend_error_cb(type, error_filename, error_lineno, format, args);
}
zval_ptr_dtor(&retval);
}
} else {
@@ -984,6 +971,14 @@ ZEND_API void zend_error(int type, const char *format, ...)
zend_error_cb(type, error_filename, error_lineno, format, args);
}
if (orig_garbage_ptr > 0) {
while (EG(garbage_ptr)) {
zval_ptr_dtor(&EG(garbage)[--EG(garbage_ptr)]);
}
EG(garbage_ptr) = orig_garbage_ptr;
memcpy(&EG(garbage), &orig_garbage, sizeof(zval*)*orig_garbage_ptr);
}
EG(user_error_handler) = orig_user_error_handler;
efree(params);
@@ -1059,6 +1054,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
} else {
strcpy(ex_class_name, "Unknown Exception");
}
#if 1 /* support set_exception_handler() */
if (EG(user_exception_handler)) {
zval *orig_user_exception_handler;
zval ***params, *retval2, *old_exception;
@@ -1073,6 +1069,8 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
}
} else {
zend_exception_error(EG(exception) TSRMLS_CC);
zval_ptr_dtor(&EG(exception));
EG(exception) = NULL;
}
efree(params);
zval_ptr_dtor(&old_exception);
@@ -1082,12 +1080,19 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
}
} else {
zend_exception_error(EG(exception) TSRMLS_CC);
zval_ptr_dtor(&EG(exception));
EG(exception) = NULL;
}
if (retval == NULL && *EG(return_value_ptr_ptr) != NULL) {
zval_ptr_dtor(EG(return_value_ptr_ptr));
local_retval = NULL;
}
} else if (!retval && *EG(return_value_ptr_ptr)) {
#else
zend_exception_error(EG(exception) TSRMLS_CC);
zval_ptr_dtor(&EG(exception));
EG(exception) = NULL;
#endif
} else if (!retval) {
zval_ptr_dtor(EG(return_value_ptr_ptr));
local_retval = NULL;
}
+25 -33
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -22,7 +22,7 @@
#ifndef ZEND_H
#define ZEND_H
#define ZEND_VERSION "2.0.1-dev"
#define ZEND_VERSION "2.0.0-dev"
#define ZEND_ENGINE_2
@@ -46,7 +46,6 @@
#elif defined(NETWARE)
# include "zend_config.nw.h"
# include "acconfig.h"
# define ZEND_PATHS_SEPARATOR ';'
#elif defined(__riscos__)
# include "zend_config.h"
# define ZEND_PATHS_SEPARATOR ';'
@@ -92,7 +91,7 @@ const char *zend_mh_bundle_error(void);
#endif /* HAVE_MACH_O_DYLD_H */
#if defined(HAVE_LIBDL) && !defined(HAVE_MACH_O_DYLD_H)
#if defined(HAVE_LIBDL)
# ifndef RTLD_LAZY
# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
@@ -102,11 +101,7 @@ const char *zend_mh_bundle_error(void);
# define RTLD_GLOBAL 0
# endif
# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
# else
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
# endif
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
# define DL_UNLOAD dlclose
# if defined(DLSYM_NEEDS_UNDERSCORE)
# define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s)
@@ -151,7 +146,6 @@ char *alloca ();
# endif
#endif
/* GCC x.y.z supplies __GNUC__ = x and __GNUC_MINOR__ = y */
#ifdef __GNUC__
# define ZEND_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
#else
@@ -170,7 +164,7 @@ char *alloca ();
# define ZEND_ATTRIBUTE_FORMAT(type, idx, first)
#endif
#if ZEND_GCC_VERSION >= 3001
#if ZEND_GCC_VERSION >= 3002
# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
#else
# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first)
@@ -300,6 +294,8 @@ struct _zval_struct {
/* A lot of stuff needs shifiting around in order to include zend_compile.h here */
union _zend_function;
#define ZEND_CE_ABSTRACT ZEND_ACC_ABSTRACT /* same as ZEND_ACC_ABSTRACT */
#include "zend_iterators.h"
struct _zend_class_entry {
@@ -340,8 +336,6 @@ struct _zend_class_entry {
zend_uint line_end;
char *doc_comment;
zend_uint doc_comment_len;
struct _zend_module_entry *module;
};
#include "zend_stream.h"
@@ -358,7 +352,6 @@ typedef struct _zend_utility_functions {
void (*on_timeout)(int seconds TSRMLS_DC);
int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
} zend_utility_functions;
@@ -386,18 +379,20 @@ typedef int (*zend_write_func_t)(const char *str, uint str_length);
/* data types */
/* All data types <= IS_BOOL have their constructor/destructors skipped */
#define IS_NULL 0
#define IS_LONG 1
#define IS_DOUBLE 2
#define IS_BOOL 3
#define IS_STRING 3
#define IS_ARRAY 4
#define IS_OBJECT 5
#define IS_STRING 6
#define IS_BOOL 6
#define IS_RESOURCE 7
#define IS_CONSTANT 8
#define IS_CONSTANT_ARRAY 9
/* Special data type to temporarily mark large numbers */
#define FLAG_IS_BC 10 /* for parser internal use only */
/* Ugly hack to support constants as static array indices */
#define IS_CONSTANT_INDEX 0x80
@@ -440,7 +435,6 @@ END_EXTERN_C()
}
#define zend_first_try EG(bailout_set)=0; zend_try
BEGIN_EXTERN_C()
ZEND_API char *get_zend_version(void);
ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy);
ZEND_API int zend_print_zval(zval *expr, int indent);
@@ -449,14 +443,12 @@ ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC);
ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC);
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
END_EXTERN_C()
void zend_activate(TSRMLS_D);
void zend_deactivate(TSRMLS_D);
void zend_call_destructors(TSRMLS_D);
void zend_activate_modules(TSRMLS_D);
void zend_deactivate_modules(TSRMLS_D);
void zend_post_deactivate_modules(TSRMLS_D);
void zend_exec_finished(TSRMLS_D);
#if ZEND_DEBUG
#define Z_DBG(expr) (expr)
@@ -464,19 +456,21 @@ void zend_post_deactivate_modules(TSRMLS_D);
#define Z_DBG(expr)
#endif
BEGIN_EXTERN_C()
ZEND_API extern char *empty_string;
ZEND_API void free_estring(char **str_p);
END_EXTERN_C()
/* FIXME: Check if we can save if (ptr) too */
#define STR_FREE(ptr) if (ptr) { efree(ptr); }
#define STR_FREE_REL(ptr) if (ptr) { efree_rel(ptr); }
#define STR_FREE(ptr) if (ptr && ptr!=empty_string) { efree(ptr); }
#define STR_FREE_REL(ptr) if (ptr && ptr!=empty_string) { efree_rel(ptr); }
#define STR_EMPTY_ALLOC() estrndup("", sizeof("")-1)
#define STR_REALLOC(ptr, size) \
ptr = (char *) erealloc(ptr, size);
#define STR_REALLOC(ptr, size) \
if (ptr!=empty_string) { \
ptr = (char *) erealloc(ptr, size); \
} else { \
ptr = (char *) emalloc(size); \
memset(ptr, 0, size); \
}
/* output support */
#define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
@@ -495,7 +489,6 @@ extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, cons
extern void (*zend_on_timeout)(int seconds TSRMLS_DC);
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
@@ -518,9 +511,9 @@ END_EXTERN_C()
BEGIN_EXTERN_C()
ZEND_API void zend_message_dispatcher(long message, void *data);
END_EXTERN_C()
ZEND_API int zend_get_configuration_directive(char *name, uint name_length, zval *contents);
END_EXTERN_C()
/* Messages for applications of Zend */
@@ -605,7 +598,6 @@ END_EXTERN_C()
#define ZEND_MAX_RESERVED_RESOURCES 4
#include "zend_variables.h"
#endif /* ZEND_H */
+84 -236
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -159,28 +159,6 @@ ZEND_API int _zend_get_parameters_array_ex(int param_count, zval ***argument_arr
}
ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array TSRMLS_DC)
{
void **p;
int arg_count;
p = EG(argument_stack).top_element-2;
arg_count = (ulong) *p;
if (param_count>arg_count) {
return FAILURE;
}
while (param_count-->0) {
zval **param = (zval **) p-(arg_count--);
zval_add_ref(param);
add_next_index_zval(argument_array, *param);
}
return SUCCESS;
}
ZEND_API void zend_wrong_param_count(TSRMLS_D)
{
zend_error(E_WARNING, "Wrong parameter count for %s()", get_active_function_name(TSRMLS_C));
@@ -338,13 +316,11 @@ static char *zend_parse_arg_impl(zval **arg, va_list *va, char **spec TSRMLS_DC)
*pl = Z_STRLEN_PP(arg);
break;
case IS_OBJECT: {
if (Z_OBJ_HANDLER_PP(arg, cast_object)) {
SEPARATE_ZVAL_IF_NOT_REF(arg);
if (Z_OBJ_HANDLER_PP(arg, cast_object)(*arg, *arg, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
*pl = Z_STRLEN_PP(arg);
*p = Z_STRVAL_PP(arg);
break;
}
if (Z_OBJ_HANDLER_PP(arg, cast_object)
&& Z_OBJ_HANDLER_PP(arg, cast_object)(*arg, *arg, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
*pl = Z_STRLEN_PP(arg);
*p = Z_STRVAL_PP(arg);
break;
}
}
@@ -627,41 +603,52 @@ ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr
}
ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...)
ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, zend_class_entry *ce, void **object, ...)
{
void **arg_stack = EG(argument_stack).top_element;
va_list va;
int retval;
char *p = type_spec;
zval **object;
zend_class_entry *ce;
int quiet = flags & ZEND_PARSE_PARAMS_QUIET;
if (!this_ptr) {
va_start(va, type_spec);
retval = zend_parse_va_args(num_args, type_spec, &va, 0 TSRMLS_CC);
va_end(va);
} else {
p++;
va_start(va, type_spec);
*object = this_ptr;
object = va_arg(va, zval **);
ce = va_arg(va, zend_class_entry *);
*object = this_ptr;
if (ce && !instanceof_function(Z_OBJCE_P(this_ptr), ce TSRMLS_CC)) {
if (!*object) {
zval **parameter;
if (zend_get_parameters_ex(1, &parameter) != SUCCESS) {
if (!quiet) {
zend_error(E_CORE_ERROR, "%s::%s() must be derived from %s::%s",
ce->name, get_active_function_name(TSRMLS_C), Z_OBJCE_P(this_ptr)->name, get_active_function_name(TSRMLS_C));
zend_error(E_WARNING, "%s() expects an object of class %s as first parameter, none was given",
get_active_function_name(TSRMLS_C), ce->name);
}
return FAILURE;
}
retval = zend_parse_va_args(num_args, p, &va, flags TSRMLS_CC);
va_end(va);
return FAILURE;
} else {
if (Z_TYPE_PP(parameter) == IS_OBJECT &&
instanceof_function(Z_OBJCE_PP(parameter), ce TSRMLS_CC)) {
*object = *parameter;
} else {
if (!quiet) {
zend_error(E_WARNING, "%s() expects parameter 1 to be %s, %s given",
get_active_function_name(TSRMLS_C), ce->name,
zend_zval_type_name(*parameter));
}
return FAILURE;
}
EG(argument_stack).top_element++;
}
}
va_start(va, object);
retval = zend_parse_va_args(num_args, type_spec, &va, flags TSRMLS_CC);
va_end(va);
EG(argument_stack).top_element = arg_stack;
return retval;
}
/* Argument parsing API -- andrei */
@@ -718,11 +705,6 @@ ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type
zval *tmp;
zend_object *object;
if (class_type->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
char *what = class_type->ce_flags & ZEND_ACC_INTERFACE ? "interface" : "abstract class";
zend_error(E_ERROR, "Cannot instantiate %s %s", what, class_type->name);
}
if (!class_type->constants_updated) {
zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
zend_hash_apply_with_argument(class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
@@ -1187,85 +1169,27 @@ ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *valu
return SUCCESS;
}
ZEND_API int zend_register_module_ex(zend_module_entry *module TSRMLS_DC)
ZEND_API int zend_startup_module(zend_module_entry *module)
{
int name_len;
char *lcname;
zend_module_entry *module_ptr;
if (!module) {
return FAILURE;
}
if (module) {
module->module_number = zend_next_free_module();
if (module->module_startup_func) {
TSRMLS_FETCH();
#if 0
zend_printf("%s: Registering module %d\n", module->name, module->module_number);
#endif
name_len = strlen(module->name);
lcname = zend_str_tolower_dup(module->name, name_len);
if (zend_hash_add(&module_registry, lcname, name_len+1, (void *)module, sizeof(zend_module_entry), (void**)&module_ptr)==FAILURE) {
zend_error(E_CORE_WARNING, "Module '%s' already loaded", module->name);
efree(lcname);
return FAILURE;
}
efree(lcname);
module = module_ptr;
if (module->functions && zend_register_functions(NULL, module->functions, NULL, module->type TSRMLS_CC)==FAILURE) {
zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load", module->name);
return FAILURE;
}
if (!module->module_started && module->module_startup_func) {
EG(current_module) = module;
if (module->module_startup_func(module->type, module->module_number TSRMLS_CC)==FAILURE) {
zend_error(E_CORE_ERROR,"Unable to start %s module", module->name);
EG(current_module) = NULL;
return FAILURE;
if (module->module_startup_func(MODULE_PERSISTENT, module->module_number TSRMLS_CC)==FAILURE) {
zend_error(E_CORE_ERROR,"Unable to start %s module", module->name);
return FAILURE;
}
}
EG(current_module) = NULL;
module->type = MODULE_PERSISTENT;
zend_register_module(module);
}
module->module_started=1;
return SUCCESS;
}
ZEND_API int zend_startup_module(zend_module_entry *module)
{
TSRMLS_FETCH();
module->module_number = zend_next_free_module();
module->type = MODULE_PERSISTENT;
return zend_register_module_ex(module TSRMLS_CC);
}
ZEND_API void zend_check_magic_method_implementation(zend_class_entry *ce, zend_function *fptr, int error_type TSRMLS_DC)
{
char lcname[16];
int name_len;
/* we don't care if the function name is longer, in fact lowercasing only
* the beginning of the name speeds up the check process */
name_len = strlen(fptr->common.function_name);
zend_str_tolower_copy(lcname, fptr->common.function_name, MIN(name_len, sizeof(lcname)-1));
lcname[sizeof(lcname)-1] = '\0'; /* zend_str_tolower_copy won't necessarily set the zero byte */
if (name_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME)) && fptr->common.num_args != 0) {
zend_error(error_type, "Destuctor %s::%s() cannot take arguments", ce->name, ZEND_DESTRUCTOR_FUNC_NAME);
} else if (name_len == sizeof(ZEND_CLONE_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME)) && fptr->common.num_args != 0) {
zend_error(error_type, "Method %s::%s() cannot accept any arguments", ce->name, ZEND_CLONE_FUNC_NAME);
} else if (name_len == sizeof(ZEND_GET_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME)) && fptr->common.num_args != 1) {
zend_error(error_type, "Method %s::%s() must take exactly 1 argument", ce->name, ZEND_GET_FUNC_NAME);
} else if (name_len == sizeof(ZEND_SET_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)) && fptr->common.num_args != 2) {
zend_error(error_type, "Method %s::%s() must take exactly 2 arguments", ce->name, ZEND_SET_FUNC_NAME);
} else if (name_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)) && fptr->common.num_args != 2) {
zend_error(error_type, "Method %s::%s() must take exactly 2 arguments", ce->name, ZEND_CALL_FUNC_NAME);
}
}
/* registers all functions in *library_functions in the function hash */
ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC)
int zend_register_functions(zend_class_entry *scope, zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC)
{
zend_function_entry *ptr = functions;
zend_function function, *reg_function;
@@ -1273,11 +1197,9 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
int count=0, unload=0;
HashTable *target_function_table = function_table;
int error_type;
zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__call = NULL;
zend_function *ctor = NULL, *dtor = NULL, *clone = NULL;
char *lowercase_name;
int fname_len;
char *lc_class_name;
int class_name_len;
if (type==MODULE_PERSISTENT) {
error_type = E_CORE_WARNING;
@@ -1289,11 +1211,6 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
target_function_table = CG(function_table);
}
internal_function->type = ZEND_INTERNAL_FUNCTION;
if (scope) {
class_name_len = strlen(scope->name);
lc_class_name = zend_str_tolower_dup(scope->name, class_name_len);
}
while (ptr->fname) {
internal_function->handler = ptr->handler;
@@ -1303,20 +1220,11 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
if (ptr->arg_info) {
internal_function->arg_info = ptr->arg_info+1;
internal_function->num_args = ptr->num_args;
/* Currently you cannot denote that the function can accept less arguments than num_args */
if (ptr->arg_info[0].required_num_args == -1) {
internal_function->required_num_args = ptr->num_args;
} else {
internal_function->required_num_args = ptr->arg_info[0].required_num_args;
}
internal_function->pass_rest_by_reference = ptr->arg_info[0].pass_by_reference;
internal_function->return_reference = ptr->arg_info[0].return_reference;
} else {
internal_function->arg_info = NULL;
internal_function->num_args = 0;
internal_function->required_num_args = 0;
internal_function->pass_rest_by_reference = 0;
internal_function->return_reference = 0;
}
if (ptr->flags) {
if (!(ptr->flags & ZEND_ACC_PPP_MASK)) {
@@ -1328,19 +1236,12 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
} else {
internal_function->fn_flags = ZEND_ACC_PUBLIC;
}
if (ptr->flags & ZEND_ACC_ABSTRACT) {
if (ptr->flags&ZEND_ACC_ABSTRACT) {
if (scope) {
/* This is a class that must be abstract itself. Here we set the check info. */
scope->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
if (!(scope->ce_flags & ZEND_ACC_INTERFACE)) {
/* Since the class is not an interface it needs to be declared as a abstract class. */
/* Since here we are handling internal functions only we can add the keyword flag. */
/* This time we set the flag for the keyword 'abstratc'. */
scope->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
}
scope->ce_flags |= ZEND_ACC_ABSTRACT;
}
} else {
if (scope && (scope->ce_flags & ZEND_ACC_INTERFACE)) {
if (scope && scope->ce_flags&ZEND_ACC_INTERFACE) {
zend_error(error_type, "Interface %s cannot contain non abstract method %s()", scope->name, ptr->fname);
return FAILURE;
}
@@ -1363,28 +1264,14 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
* If it's an old-style constructor, store it only if we don't have
* a constructor already.
*/
if ((fname_len == class_name_len) && !memcmp(lowercase_name, lc_class_name, class_name_len+1) && !ctor) {
if (!strcmp(ptr->fname, scope->name) && !ctor) {
ctor = reg_function;
} else if ((fname_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {
} else if (!strcmp(ptr->fname, ZEND_CONSTRUCTOR_FUNC_NAME)) {
ctor = reg_function;
} else if ((fname_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME))) {
} else if (!strcmp(ptr->fname, ZEND_DESTRUCTOR_FUNC_NAME)) {
dtor = reg_function;
if (internal_function->num_args) {
zend_error(error_type, "Destructor %s::%s() cannot take arguments", scope->name, ptr->fname);
}
} else if ((fname_len == sizeof(ZEND_CLONE_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME))) {
} else if (!strcmp(ptr->fname, ZEND_CLONE_FUNC_NAME)) {
clone = reg_function;
} else if ((fname_len == sizeof(ZEND_CALL_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME))) {
__call = reg_function;
} else if ((fname_len == sizeof(ZEND_GET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME))) {
__get = reg_function;
} else if ((fname_len == sizeof(ZEND_SET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME))) {
__set = reg_function;
} else {
reg_function = NULL;
}
if (reg_function) {
zend_check_magic_method_implementation(scope, reg_function, error_type TSRMLS_CC);
}
}
ptr++;
@@ -1392,9 +1279,6 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
free_alloca(lowercase_name);
}
if (unload) { /* before unloading, display all remaining bad function in the module */
if (scope) {
efree(lc_class_name);
}
while (ptr->fname) {
if (zend_hash_exists(target_function_table, ptr->fname, strlen(ptr->fname)+1)) {
zend_error(error_type, "Function registration failed - duplicate name - %s", ptr->fname);
@@ -1408,49 +1292,18 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
scope->constructor = ctor;
scope->destructor = dtor;
scope->clone = clone;
scope->__call = __call;
scope->__get = __get;
scope->__set = __set;
if (ctor) {
ctor->common.fn_flags |= ZEND_ACC_CTOR;
if (ctor->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Constructor %s::%s() cannot be static", scope->name, ctor->common.function_name);
zend_error(error_type, "Constructor %s::%s cannot be static", ctor->common.scope->name, ctor->common.function_name);
}
ctor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (dtor) {
dtor->common.fn_flags |= ZEND_ACC_DTOR;
if (dtor->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Destructor %s::%s() cannot be static", scope->name, dtor->common.function_name);
zend_error(error_type, "Destructor %s::%s cannot be static", dtor->common.scope->name, dtor->common.function_name);
}
dtor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (clone) {
clone->common.fn_flags |= ZEND_ACC_CLONE;
if (clone->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Constructor %s::%s() cannot be static", scope->name, clone->common.function_name);
}
clone->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__call) {
if (__call->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __call->common.function_name);
}
__call->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__get) {
if (__get->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __get->common.function_name);
}
__get->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__set) {
if (__set->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __set->common.function_name);
}
__set->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
efree(lc_class_name);
}
return SUCCESS;
}
@@ -1458,7 +1311,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
/* count=-1 means erase all functions, otherwise,
* erase the first count functions
*/
ZEND_API void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC)
void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC)
{
zend_function_entry *ptr = functions;
int i=0;
@@ -1484,16 +1337,16 @@ ZEND_API void zend_unregister_functions(zend_function_entry *functions, int coun
ZEND_API int zend_register_module(zend_module_entry *module)
{
TSRMLS_FETCH();
return zend_register_module_ex(module TSRMLS_CC);
}
ZEND_API int zend_get_module_started(char *module_name)
{
zend_module_entry *module;
return (zend_hash_find(&module_registry, module_name, strlen(module_name)+1, (void**)&module) == SUCCESS && module->module_started) ? SUCCESS : FAILURE;
#if 0
zend_printf("%s: Registering module %d\n", module->name, module->module_number);
#endif
if (module->functions && zend_register_functions(NULL, module->functions, NULL, module->type TSRMLS_CC)==FAILURE) {
zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load", module->name);
return FAILURE;
}
module->module_started=1;
return zend_hash_add(&module_registry, module->name, strlen(module->name)+1, (void *)module, sizeof(zend_module_entry), NULL);
}
@@ -1521,11 +1374,9 @@ void module_destructor(zend_module_entry *module)
}
#if HAVE_LIBDL
#if !(defined(NETWARE) && defined(APACHE_1_BUILD))
if (module->handle) {
dlclose(module->handle);
}
#endif
if (module->handle) {
dlclose(module->handle);
}
#endif
}
@@ -1584,7 +1435,6 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class
class_entry->type = ZEND_INTERNAL_CLASS;
zend_initialize_class_data(class_entry, 0 TSRMLS_CC);
class_entry->ce_flags = ce_flags;
class_entry->module = EG(current_module);
if (class_entry->builtin_functions) {
zend_register_functions(class_entry, class_entry->builtin_functions, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC);
@@ -1651,7 +1501,7 @@ ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *orig_c
ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry TSRMLS_DC)
{
return do_register_internal_class(orig_class_entry, ZEND_ACC_INTERFACE TSRMLS_CC);
return do_register_internal_class(orig_class_entry, ZEND_ACC_ABSTRACT|ZEND_ACC_INTERFACE TSRMLS_CC);
}
ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
@@ -1738,17 +1588,15 @@ ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char
switch (Z_TYPE_P(callable)) {
case IS_STRING:
if (callable_name) {
if (callable_name)
*callable_name = estrndup(Z_STRVAL_P(callable), Z_STRLEN_P(callable));
}
if (syntax_only) {
if (syntax_only)
return 1;
}
lcname = zend_str_tolower_dup(Z_STRVAL_P(callable), Z_STRLEN_P(callable));
if (zend_hash_exists(EG(function_table), lcname, Z_STRLEN_P(callable)+1)) {
if (zend_hash_exists(EG(function_table), lcname, Z_STRLEN_P(callable)+1))
retval = 1;
}
efree(lcname);
break;
@@ -1781,7 +1629,7 @@ ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char
if (syntax_only)
return 1;
lcname = zend_str_tolower_dup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj));
lcname = zend_str_tolower_dup(Z_STRVAL_PP(method), Z_STRLEN_PP(method));
if (EG(active_op_array) && strcmp(lcname, "self") == 0) {
ce = EG(active_op_array)->scope;
@@ -1793,7 +1641,7 @@ ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char
efree(lcname);
} else {
ce = Z_OBJCE_PP(obj); /* TBFixed: what if it's overloaded? */
ce = Z_OBJCE_PP(obj); /* ??? */
if (callable_name) {
char *ptr;
@@ -1913,7 +1761,7 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_le
char *priv_name;
int priv_name_length;
zend_mangle_property_name(&priv_name, &priv_name_length, ce->name, ce->name_length, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
mangle_property_name(&priv_name, &priv_name_length, ce->name, ce->name_length, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_hash_update(target_symbol_table, priv_name, priv_name_length+1, &property, sizeof(zval *), NULL);
property_info.name = priv_name;
property_info.name_length = priv_name_length;
@@ -1923,7 +1771,7 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_le
char *prot_name;
int prot_name_length;
zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_hash_update(target_symbol_table, prot_name, prot_name_length+1, &property, sizeof(zval *), NULL);
property_info.name = prot_name;
property_info.name_length = prot_name_length;
@@ -1934,7 +1782,7 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_le
char *prot_name;
int prot_name_length;
zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_hash_del(target_symbol_table, prot_name, prot_name_length+1);
pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS);
}
+14 -32
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -53,18 +53,15 @@ typedef struct _zend_function_entry {
#define ZEND_FALIAS(name, alias, arg_info) ZEND_FENTRY(name, ZEND_FN(alias), arg_info, 0)
#define ZEND_ME(classname, name, arg_info, flags) ZEND_FENTRY(name, ZEND_FN(classname##_##name), arg_info, flags)
#define ZEND_ABSTRACT_ME(classname, name, arg_info) ZEND_FENTRY(name, NULL, arg_info, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
#define ZEND_MALIAS(classname, name, alias, arg_info, flags) \
#define ZEND_MALIAS(name, classname, alias, arg_info, flags) \
ZEND_FENTRY(name, ZEND_FN(classname##_##alias), arg_info, flags)
#define ZEND_ME_MAPPING(name, func_name, arg_types) ZEND_NAMED_FE(name, ZEND_FN(func_name), arg_types)
#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, pass_by_ref, 0, 0 },
#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, pass_by_ref, 0, 0 },
#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, sizeof(#name)-1, #classname, sizeof(#classname)-1, allow_null, pass_by_ref, 0, 0 },
#define ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, return_reference, required_num_args) \
zend_arg_info name[] = { \
{ NULL, 0, NULL, 0, 0, pass_rest_by_reference, return_reference, required_num_args },
#define ZEND_BEGIN_ARG_INFO(name, pass_rest_by_reference) \
ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, ZEND_RETURN_REFERENCE_AGNOSTIC, -1)
#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, pass_by_ref },
#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, pass_by_ref },
#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, sizeof(#name)-1, #classname, sizeof(#classname)-1, allow_null, pass_by_ref },
#define ZEND_BEGIN_ARG_INFO(name, pass_rest_by_reference) \
zend_arg_info name[] = { \
ZEND_ARG_PASS_INFO(pass_rest_by_reference)
#define ZEND_END_ARG_INFO() };
/* Name macros */
@@ -72,7 +69,7 @@ typedef struct _zend_function_entry {
#define ZEND_MODULE_SHUTDOWN_N(module) zm_shutdown_##module
#define ZEND_MODULE_ACTIVATE_N(module) zm_activate_##module
#define ZEND_MODULE_DEACTIVATE_N(module) zm_deactivate_##module
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module) zm_post_zend_deactivate_##module
#define ZEND_MODULE_EXEC_FINISHED_N(module) zm_exec_finished_##module
#define ZEND_MODULE_INFO_N(module) zm_info_##module
/* Declaration macros */
@@ -80,7 +77,7 @@ typedef struct _zend_function_entry {
#define ZEND_MODULE_SHUTDOWN_D(module) int ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS)
#define ZEND_MODULE_ACTIVATE_D(module) int ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS)
#define ZEND_MODULE_DEACTIVATE_D(module) int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS)
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void)
#define ZEND_MODULE_EXEC_FINISHED_D(module) int ZEND_MODULE_EXEC_FINISHED_N(module)(void)
#define ZEND_MODULE_INFO_D(module) void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS)
#define ZEND_GET_MODULE(name) \
@@ -130,25 +127,18 @@ typedef struct _zend_function_entry {
class_container.__call = handle_fcall; \
class_container.__get = handle_propget; \
class_container.__set = handle_propset; \
class_container.parent = NULL; \
class_container.num_interfaces = 0; \
class_container.interfaces = NULL; \
class_container.get_iterator = NULL; \
class_container.iterator_funcs.funcs = NULL; \
class_container.module = NULL; \
}
int zend_next_free_module(void);
BEGIN_EXTERN_C()
ZEND_API int zend_get_parameters(int ht, int param_count, ...);
ZEND_API int _zend_get_parameters_array(int ht, int param_count, zval **argument_array TSRMLS_DC);
ZEND_API int zend_get_parameters_ex(int param_count, ...);
ZEND_API int _zend_get_parameters_array_ex(int param_count, zval ***argument_array TSRMLS_DC);
/* internal function to efficiently copy parameters when executing __call() */
ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array TSRMLS_DC);
#define zend_get_parameters_array(ht, param_count, argument_array) \
_zend_get_parameters_array(ht, param_count, argument_array TSRMLS_CC)
#define zend_get_parameters_array_ex(param_count, argument_array) \
@@ -163,15 +153,13 @@ ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *t
ZEND_API char *zend_zval_type_name(zval *arg);
ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...);
ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...);
ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, zend_class_entry *ce, void **object, ...);
/* End of parameter parsing API -- andrei */
ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC);
ZEND_API void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC);
int zend_register_functions(zend_class_entry *scope, zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC);
void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC);
ZEND_API int zend_register_module(zend_module_entry *module_entry);
ZEND_API int zend_register_module_ex(zend_module_entry *module TSRMLS_DC);
ZEND_API void zend_check_magic_method_implementation(zend_class_entry *ce, zend_function *fptr, int error_type TSRMLS_DC);
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC);
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC);
@@ -185,7 +173,6 @@ ZEND_API void zend_wrong_param_count(TSRMLS_D);
ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name);
ZEND_API zend_bool zend_make_callable(zval *callable, char **callable_name TSRMLS_DC);
ZEND_API char *zend_get_module_version(char *module_name);
ZEND_API int zend_get_module_started(char *module_name);
ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int name_length, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_long(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC);
@@ -303,7 +290,6 @@ ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *valu
ZEND_API int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, zend_uint param_count, zval *params[] TSRMLS_DC);
ZEND_API int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, zend_uint param_count, zval **params[], int no_separation, HashTable *symbol_table TSRMLS_DC);
END_EXTERN_C()
typedef struct _zend_fcall_info {
size_t size;
@@ -324,7 +310,6 @@ typedef struct _zend_fcall_info_cache {
zval **object_pp;
} zend_fcall_info_cache;
BEGIN_EXTERN_C()
ZEND_API extern zend_fcall_info_cache empty_fcall_info_cache;
ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC);
@@ -333,13 +318,10 @@ ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci
ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
zend_bool is_ref, int num_symbol_tables, ...);
ZEND_API int zend_delete_global_variable(char *name, int name_len TSRMLS_DC);
#define add_method(arg, key, method) add_assoc_function((arg), (key), (method))
ZEND_API ZEND_FUNCTION(display_disabled_function);
ZEND_API ZEND_FUNCTION(display_disabled_class);
END_EXTERN_C()
#if ZEND_DEBUG
#define CHECK_ZVAL_STRING(z) \
@@ -391,7 +373,7 @@ END_EXTERN_C()
#define ZVAL_EMPTY_STRING(z) { \
(z)->value.str.len = 0; \
(z)->value.str.val = STR_EMPTY_ALLOC(); \
(z)->value.str.val = empty_string; \
(z)->type = IS_STRING; \
}
+85 -101
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -75,7 +75,7 @@ static long mem_block_end_magic = MEM_BLOCK_END_MAGIC;
#define _CHECK_MEMORY_LIMIT(s, rs, file, lineno) { AG(allocated_memory) += rs;\
if (AG(memory_limit)<AG(allocated_memory)) {\
int php_mem_limit = AG(memory_limit); \
if (EG(in_execution) && AG(memory_limit)+1048576 > AG(allocated_memory) - rs) { \
if (AG(memory_limit)+1048576 > AG(allocated_memory) - rs) { \
AG(memory_limit) = AG(allocated_memory) + 1048576; \
if (file) { \
zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes)", php_mem_limit, file, lineno, s); \
@@ -99,7 +99,6 @@ static long mem_block_end_magic = MEM_BLOCK_END_MAGIC;
#endif
#if ZEND_DEBUG || !defined(ZEND_MM)
#define REMOVE_POINTER_FROM_LIST(p) \
if (p==AG(head)) { \
AG(head) = p->pNext; \
@@ -109,21 +108,14 @@ static long mem_block_end_magic = MEM_BLOCK_END_MAGIC;
if (p->pNext) { \
p->pNext->pLast = p->pLast; \
}
#else
#define REMOVE_POINTER_FROM_LIST(p)
#endif
#if ZEND_DEBUG || !defined(ZEND_MM)
#define ADD_POINTER_TO_LIST(p) \
#define ADD_POINTER_TO_LIST(p) \
p->pNext = AG(head); \
if (AG(head)) { \
AG(head)->pLast = p; \
} \
AG(head) = p; \
p->pLast = (zend_mem_header *) NULL;
#else
#define ADD_POINTER_TO_LIST(p)
#endif
#define DECLARE_CACHE_VARS() \
unsigned int real_size; \
@@ -163,6 +155,7 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
AG(cache_stats)[CACHE_INDEX][1]++;
memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long));
#endif
p->cached = 0;
p->size = size;
return (void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING);
} else {
@@ -171,12 +164,6 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
if (CACHE_INDEX<MAX_CACHED_MEMORY) {
AG(cache_stats)[CACHE_INDEX][0]++;
}
#endif
#if MEMORY_LIMIT
CHECK_MEMORY_LIMIT(size, SIZE);
if (AG(allocated_memory) > AG(allocated_memory_peak)) {
AG(allocated_memory_peak) = AG(allocated_memory);
}
#endif
p = (zend_mem_header *) ZEND_DO_MALLOC(sizeof(zend_mem_header) + MEM_HEADER_PADDING + SIZE + END_MAGIC_SIZE);
#if !ZEND_DISABLE_MEMORY_CACHE
@@ -195,7 +182,10 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
HANDLE_UNBLOCK_INTERRUPTIONS();
return (void *)p;
}
p->cached = 0;
#if ZEND_DEBUG || !defined(ZEND_MM)
ADD_POINTER_TO_LIST(p);
#endif
p->size = size; /* Save real size for correct cache output */
#if ZEND_DEBUG
p->filename = __zend_filename;
@@ -209,6 +199,12 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
# endif
memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long));
#endif
#if MEMORY_LIMIT
CHECK_MEMORY_LIMIT(size, SIZE);
if (AG(allocated_memory) > AG(allocated_memory_peak)) {
AG(allocated_memory_peak) = AG(allocated_memory);
}
#endif
HANDLE_UNBLOCK_INTERRUPTIONS();
return (void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING);
@@ -241,30 +237,6 @@ ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_
return 0;
}
ZEND_API void *_safe_malloc(size_t nmemb, size_t size, size_t offset)
{
if (nmemb < LONG_MAX
&& size < LONG_MAX
&& offset < LONG_MAX
&& nmemb >= 0
&& size >= 0
&& offset >= 0) {
long lval;
double dval;
int use_dval;
ZEND_SIGNED_MULTIPLY_LONG(nmemb, size, lval, dval, use_dval);
if (!use_dval
&& lval < (long) (LONG_MAX - offset)) {
return pemalloc(lval + offset, 1);
}
}
zend_error(E_ERROR, "Possible integer overflow in memory allocation (%zd * %zd + %zd)", nmemb, size, offset);
return 0;
}
ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
@@ -292,6 +264,7 @@ ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
#if !ZEND_DISABLE_MEMORY_CACHE
if ((CACHE_INDEX < MAX_CACHED_MEMORY) && (AG(cache_count)[CACHE_INDEX] < MAX_CACHED_ENTRIES)) {
AG(cache)[CACHE_INDEX][AG(cache_count)[CACHE_INDEX]++] = p;
p->cached = 1;
#if ZEND_DEBUG
p->magic = MEM_BLOCK_CACHED_MAGIC;
#endif
@@ -299,7 +272,9 @@ ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
}
#endif
HANDLE_BLOCK_INTERRUPTIONS();
#if ZEND_DEBUG || !defined(ZEND_MM)
REMOVE_POINTER_FROM_LIST(p);
#endif
#if MEMORY_LIMIT
AG(allocated_memory) -= SIZE;
@@ -356,13 +331,9 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN
CALCULATE_REAL_SIZE_AND_CACHE_INDEX(size);
HANDLE_BLOCK_INTERRUPTIONS();
#if MEMORY_LIMIT
CHECK_MEMORY_LIMIT(size - p->size, SIZE - REAL_SIZE(p->size));
if (AG(allocated_memory) > AG(allocated_memory_peak)) {
AG(allocated_memory_peak) = AG(allocated_memory);
}
#endif
#if ZEND_DEBUG || !defined(ZEND_MM)
REMOVE_POINTER_FROM_LIST(p);
#endif
p = (zend_mem_header *) ZEND_DO_REALLOC(p, sizeof(zend_mem_header)+MEM_HEADER_PADDING+SIZE+END_MAGIC_SIZE);
if (!p) {
if (!allow_failure) {
@@ -373,17 +344,27 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN
exit(1);
#endif
}
#if ZEND_DEBUG || !defined(ZEND_MM)
ADD_POINTER_TO_LIST(orig);
#endif
HANDLE_UNBLOCK_INTERRUPTIONS();
return (void *)NULL;
}
#if ZEND_DEBUG || !defined(ZEND_MM)
ADD_POINTER_TO_LIST(p);
#endif
#if ZEND_DEBUG
p->filename = __zend_filename;
p->lineno = __zend_lineno;
p->magic = MEM_BLOCK_START_MAGIC;
memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long));
#endif
#if MEMORY_LIMIT
CHECK_MEMORY_LIMIT(size - p->size, SIZE - REAL_SIZE(p->size));
if (AG(allocated_memory) > AG(allocated_memory_peak)) {
AG(allocated_memory_peak) = AG(allocated_memory);
}
#endif
p->size = size;
@@ -487,7 +468,7 @@ ZEND_API void start_memory_manager(TSRMLS_D)
}
ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC)
ZEND_API void shutdown_memory_manager(int silent, int clean_cache TSRMLS_DC)
{
#if ZEND_DEBUG || !defined(ZEND_MM)
zend_mem_header *p, *t;
@@ -496,35 +477,13 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC)
zend_uint grand_total_leaks=0;
#endif
#if !ZEND_DISABLE_MEMORY_CACHE
/* Free memory cache even on partial shutdown to avoid fragmentation */
if (1 || full_shutdown) {
unsigned int i, j;
zend_mem_header *ptr;
for (i=0; i<MAX_CACHED_MEMORY; i++) {
for (j=0; j<AG(cache_count)[i]; j++) {
ptr = (zend_mem_header *) AG(cache)[i][j];
# if MEMORY_LIMIT
AG(allocated_memory) -= REAL_SIZE(ptr->size);
# endif
REMOVE_POINTER_FROM_LIST(ptr);
ZEND_DO_FREE(ptr);
}
AG(cache_count)[i] = 0;
}
}
#endif /* !ZEND_DISABLE_MEMORY_CACHE */
#if defined(ZEND_MM) && !ZEND_DEBUG
zend_mm_shutdown(&AG(mm_heap));
if (full_shutdown) {
if (clean_cache) {
zend_mm_shutdown(&AG(mm_heap));
return;
}
zend_mm_startup(&AG(mm_heap), 256*1024);
#elif defined(ZEND_WIN32) && !ZEND_DEBUG
if (full_shutdown && AG(memory_heap)) {
if (clean_cache && AG(memory_heap)) {
HeapDestroy(AG(memory_heap));
return;
}
@@ -547,40 +506,65 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC)
}
#endif /* ZEND_ENABLE_FAST_CACHE */
#if !ZEND_DISABLE_MEMORY_CACHE && !defined(ZEND_MM)
if (1 || clean_cache) {
unsigned int i, j;
zend_mem_header *ptr;
for (i=1; i<MAX_CACHED_MEMORY; i++) {
for (j=0; j<AG(cache_count)[i]; j++) {
ptr = (zend_mem_header *) AG(cache)[i][j];
#if MEMORY_LIMIT
AG(allocated_memory) -= REAL_SIZE(ptr->size);
#endif
REMOVE_POINTER_FROM_LIST(ptr);
ZEND_DO_FREE(ptr);
}
AG(cache_count)[i] = 0;
}
}
#endif /* !ZEND_DISABLE_MEMORY_CACHE */
#if ZEND_DEBUG || !defined(ZEND_MM)
p = AG(head);
t = AG(head);
while (t) {
if (!t->cached) {
#if ZEND_DEBUG
if (!t->reported) {
zend_mem_header *iterator;
int total_leak=0, total_leak_count=0;
if (!t->cached && !t->reported) {
zend_mem_header *iterator;
int total_leak=0, total_leak_count=0;
grand_total_leaks++;
if (!silent) {
zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, t);
}
t->reported = 1;
for (iterator=t->pNext; iterator; iterator=iterator->pNext) {
if (iterator->filename==t->filename && iterator->lineno==t->lineno) {
total_leak += iterator->size;
total_leak_count++;
iterator->reported = 1;
grand_total_leaks++;
if (!silent) {
zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, t);
}
t->reported = 1;
for (iterator=t->pNext; iterator; iterator=iterator->pNext) {
if (!iterator->cached
&& iterator->filename==t->filename
&& iterator->lineno==t->lineno) {
total_leak += iterator->size;
total_leak_count++;
iterator->reported = 1;
}
}
if (!silent && total_leak_count>0) {
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *) (long) (total_leak_count));
}
grand_total_leaks += total_leak_count;
}
if (!silent && total_leak_count>0) {
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *) (long) (total_leak_count));
}
grand_total_leaks += total_leak_count;
}
#endif
#if MEMORY_LIMIT
AG(allocated_memory) -= REAL_SIZE(t->size);
AG(allocated_memory) -= REAL_SIZE(t->size);
#endif
p = t->pNext;
REMOVE_POINTER_FROM_LIST(t);
ZEND_DO_FREE(t);
t = p;
p = t->pNext;
REMOVE_POINTER_FROM_LIST(t);
ZEND_DO_FREE(t);
t = p;
} else {
t = t->pNext;
}
}
#if ZEND_DEBUG
@@ -600,7 +584,7 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC)
zval display_memory_cache_stats;
int i, j;
if (full_shutdown) {
if (clean_cache) {
/* we're shutting down completely, don't even touch the INI subsystem */
break;
}
@@ -638,13 +622,12 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC)
#endif
#if defined(ZEND_MM) && ZEND_DEBUG
zend_mm_shutdown(&AG(mm_heap));
if (full_shutdown) {
if (clean_cache) {
zend_mm_shutdown(&AG(mm_heap));
return;
}
zend_mm_startup(&AG(mm_heap), 256*1024);
#elif defined(ZEND_WIN32) && ZEND_DEBUG
if (full_shutdown && AG(memory_heap)) {
if (clean_cache && AG(memory_heap)) {
HeapDestroy(AG(memory_heap));
return;
}
@@ -800,6 +783,7 @@ ZEND_API void _full_mem_check(int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D
}
#endif
/*
* Local variables:
* tab-width: 4
+7 -58
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -50,7 +50,8 @@ typedef struct _zend_mem_header {
struct _zend_mem_header *pNext;
struct _zend_mem_header *pLast;
#endif
unsigned int size;
unsigned int size:31;
unsigned int cached:1;
} zend_mem_header;
typedef union _align_test {
@@ -78,17 +79,12 @@ ZEND_API char *zend_strndup(const char *s, unsigned int length) ZEND_ATTRIBUTE_M
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API void *_safe_malloc(size_t nmemb, size_t size, size_t offset) ZEND_ATTRIBUTE_MALLOC;
ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
#define USE_ZEND_ALLOC 1
#if USE_ZEND_ALLOC
/* Standard wrapper macros */
#define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define safe_emalloc(nmemb, size, offset) _safe_emalloc((nmemb), (size), (offset) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
@@ -111,7 +107,6 @@ ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZE
/* Selective persistent/non persistent allocation macros */
#define pemalloc(size, persistent) ((persistent)?malloc(size):emalloc(size))
#define safe_pemalloc(nmemb, size, offset, persistent) ((persistent)?_safe_malloc(nmemb, size, offset):safe_emalloc(nmemb, size, offset))
#define pefree(ptr, persistent) ((persistent)?free(ptr):efree(ptr))
#define pecalloc(nmemb, size, persistent) ((persistent)?calloc((nmemb), (size)):ecalloc((nmemb), (size)))
#define perealloc(ptr, size, persistent) ((persistent)?realloc((ptr), (size)):erealloc((ptr), (size)))
@@ -125,60 +120,13 @@ ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZE
#define perealloc_recoverable_rel(ptr, size, persistent) ((persistent)?realloc((ptr), (size)):erealloc_recoverable_rel((ptr), (size)))
#define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s))
#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):STR_EMPTY_ALLOC())
#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):STR_EMPTY_ALLOC())
#else
#define _GNU_SOURCE
#include <string.h>
#undef _GNU_SOURCE
/* Standard wrapper macros */
#define emalloc(size) malloc(size)
#define safe_emalloc(nmemb, size, offset) malloc((nmemb) * (size) + (offset))
#define efree(ptr) free(ptr)
#define ecalloc(nmemb, size) calloc((nmemb), (size))
#define erealloc(ptr, size) realloc((ptr), (size))
#define erealloc_recoverable(ptr, size) realloc((ptr), (size))
#define estrdup(s) strdup(s)
#define estrndup(s, length) strndup((s), (length))
/* Relay wrapper macros */
#define emalloc_rel(size) malloc(size)
#define safe_emalloc_rel(nmemb, size, offset) malloc((nmemb) * (size) + (offset))
#define efree_rel(ptr) free(ptr)
#define ecalloc_rel(nmemb, size) calloc((nmemb), (size))
#define erealloc_rel(ptr, size) realloc((ptr), (size))
#define erealloc_recoverable_rel(ptr, size) realloc((ptr), (size))
#define estrdup_rel(s) strdup(s)
#define estrndup_rel(s, length) strndup((s), (length))
/* Selective persistent/non persistent allocation macros */
#define pemalloc(size, persistent) malloc(size)
#define safe_pemalloc(nmemb, size, offset, persistent) malloc((nmemb) * (size) + (offset))
#define pefree(ptr, persistent) free(ptr)
#define pecalloc(nmemb, size, persistent) calloc((nmemb), (size))
#define perealloc(ptr, size, persistent) realloc((ptr), (size))
#define perealloc_recoverable(ptr, size, persistent) realloc((ptr), (size))
#define pestrdup(s, persistent) strdup(s)
#define pemalloc_rel(size, persistent) malloc(size)
#define pefree_rel(ptr, persistent) free(ptr)
#define pecalloc_rel(nmemb, size, persistent) calloc((nmemb), (size))
#define perealloc_rel(ptr, size, persistent) realloc((ptr), (size))
#define perealloc_recoverable_rel(ptr, size, persistent) realloc((ptr), (size))
#define pestrdup_rel(s, persistent) strdup(s)
#define safe_estrdup(ptr) ((ptr)?(strdup(ptr)):(empty_string))
#define safe_estrndup(ptr, len) ((ptr)?(strndup((ptr), (len))):(empty_string))
#endif
#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):(empty_string))
#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):(empty_string))
ZEND_API int zend_set_memory_limit(unsigned int memory_limit);
ZEND_API void start_memory_manager(TSRMLS_D);
ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC);
ZEND_API void shutdown_memory_manager(int silent, int clean_cache TSRMLS_DC);
#if ZEND_DEBUG
ZEND_API int _mem_block_check(void *ptr, int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
@@ -191,6 +139,7 @@ void zend_debug_alloc_output(char *format, ...);
#define full_mem_check(silent)
#endif
END_EXTERN_C()
#endif
+65 -214
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -44,7 +44,6 @@ static ZEND_FUNCTION(get_class);
static ZEND_FUNCTION(get_parent_class);
static ZEND_FUNCTION(method_exists);
static ZEND_FUNCTION(class_exists);
static ZEND_FUNCTION(interface_exists);
static ZEND_FUNCTION(function_exists);
#if ZEND_DEBUG
static ZEND_FUNCTION(leak);
@@ -103,7 +102,6 @@ static zend_function_entry builtin_functions[] = {
ZEND_FE(get_parent_class, NULL)
ZEND_FE(method_exists, NULL)
ZEND_FE(class_exists, NULL)
ZEND_FE(interface_exists, NULL)
ZEND_FE(function_exists, NULL)
#if ZEND_DEBUG
ZEND_FE(leak, NULL)
@@ -508,15 +506,15 @@ ZEND_FUNCTION(defined)
convert_to_string_ex(var);
if (zend_get_constant((*var)->value.str.val, (*var)->value.str.len, &c TSRMLS_CC)) {
zval_dtor(&c);
RETURN_TRUE;
RETURN_LONG(1);
} else {
RETURN_FALSE;
RETURN_LONG(0);
}
}
/* }}} */
/* {{{ proto string get_class([object object])
/* {{{ proto string get_class(object object)
Retrieves the class name */
ZEND_FUNCTION(get_class)
{
@@ -524,13 +522,6 @@ ZEND_FUNCTION(get_class)
char *name = "";
zend_uint name_len = 0;
if (!ZEND_NUM_ARGS()) {
if (EG(scope)) {
RETURN_STRINGL(EG(scope)->name, EG(scope)->name_length, 1);
} else {
zend_error(E_ERROR, "get_class() called without object from outside a class");
}
}
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &arg)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
@@ -555,8 +546,8 @@ ZEND_FUNCTION(get_class)
/* }}} */
/* {{{ proto string get_parent_class([mixed object])
Retrieves the parent class name for object or class or current scope. */
/* {{{ proto string get_parent_class(mixed object)
Retrieves the parent class name for object or class. */
ZEND_FUNCTION(get_parent_class)
{
zval **arg;
@@ -564,14 +555,6 @@ ZEND_FUNCTION(get_parent_class)
char *name;
zend_uint name_length;
if (!ZEND_NUM_ARGS()) {
ce = EG(scope);
if (ce && ce->parent) {
RETURN_STRINGL(ce->parent->name, ce->parent->name_length, 1);
} else {
RETURN_FALSE;
}
}
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &arg)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
@@ -665,72 +648,30 @@ ZEND_FUNCTION(is_a)
/* }}} */
/* {{{ add_class_vars */
static void add_class_vars(zend_class_entry *ce, HashTable *properties, zval *return_value TSRMLS_DC)
{
int instanceof = EG(scope) && instanceof_function(EG(scope), ce TSRMLS_CC);
if (zend_hash_num_elements(properties) > 0) {
HashPosition pos;
zval **prop;
zend_hash_internal_pointer_reset_ex(properties, &pos);
while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) {
char *key, *class_name, *prop_name;
uint key_len;
ulong num_index;
zval *prop_copy;
zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos);
zend_hash_move_forward_ex(properties, &pos);
zend_unmangle_property_name(key, &class_name, &prop_name);
if (class_name) {
if (class_name[0] != '*' && strcmp(class_name, ce->name)) {
/* filter privates from base classes */
continue;
} else if (!instanceof) {
/* filter protected if not inside class */
continue;
}
}
/* copy: enforce read only access */
ALLOC_ZVAL(prop_copy);
*prop_copy = **prop;
zval_copy_ctor(prop_copy);
INIT_PZVAL(prop_copy);
/* this is necessary to make it able to work with default array
* properties, returned to user */
if (Z_TYPE_P(prop_copy) == IS_CONSTANT_ARRAY || Z_TYPE_P(prop_copy) == IS_CONSTANT) {
zval_update_constant(&prop_copy, 0 TSRMLS_CC);
}
add_assoc_zval(return_value, prop_name, prop_copy);
}
}
}
/* }}} */
/* {{{ proto array get_class_vars(string class_name)
Returns an array of default properties of the class. */
Returns an array of default properties of the class */
ZEND_FUNCTION(get_class_vars)
{
char *class_name;
int class_name_len;
zend_class_entry **pce;
zval **class_name;
zend_class_entry *ce, **pce;
zval *tmp;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &class_name, &class_name_len) == FAILURE) {
return;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class_name)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
if (zend_lookup_class(class_name, class_name_len, &pce TSRMLS_CC) == FAILURE) {
convert_to_string_ex(class_name);
if (zend_lookup_class(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), &pce TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
} else {
ce = *pce;
array_init(return_value);
add_class_vars(*pce, &(*pce)->default_properties, return_value TSRMLS_CC);
add_class_vars(*pce, (*pce)->static_members, return_value TSRMLS_CC);
if (!ce->constants_updated) {
zend_hash_apply_with_argument(&ce->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
ce->constants_updated = 1;
}
zend_hash_copy(return_value->value.ht, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
}
}
/* }}} */
@@ -744,10 +685,9 @@ ZEND_FUNCTION(get_object_vars)
zval **value;
HashTable *properties;
HashPosition pos;
char *key, *prop_name, *class_name;
char *key;
uint key_len;
ulong num_index;
int instanceof;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &obj) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
@@ -760,27 +700,14 @@ ZEND_FUNCTION(get_object_vars)
RETURN_FALSE;
}
instanceof = EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), Z_OBJCE_PP(obj) TSRMLS_CC);
array_init(return_value);
properties = Z_OBJ_HT_PP(obj)->get_properties(*obj TSRMLS_CC);
zend_hash_internal_pointer_reset_ex(properties, &pos);
while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) {
if (zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) {
if (key[0]) {
/* Not separating references */
(*value)->refcount++;
add_assoc_zval_ex(return_value, key, key_len, *value);
} else if (instanceof) {
zend_unmangle_property_name(key, &class_name, &prop_name);
if (!memcmp(class_name, "*", 2) || (Z_OBJCE_P(EG(This)) == Z_OBJCE_PP(obj) && !strcmp(Z_OBJCE_P(EG(This))->name, class_name))) {
/* Not separating references */
(*value)->refcount++;
add_assoc_zval_ex(return_value, prop_name, strlen(prop_name)+1, *value);
}
}
if (zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING && key[0]) {
add_assoc_zval_ex(return_value, key, key_len, *value);
}
zend_hash_move_forward_ex(properties, &pos);
}
@@ -797,7 +724,6 @@ ZEND_FUNCTION(get_class_methods)
zend_class_entry *ce = NULL, **pce;
HashPosition pos;
zend_function *mptr;
int instanceof;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
@@ -819,22 +745,18 @@ ZEND_FUNCTION(get_class_methods)
RETURN_NULL();
}
instanceof = EG(scope) && instanceof_function(EG(scope), ce TSRMLS_CC);
array_init(return_value);
zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);
while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
if ((mptr->common.fn_flags & ZEND_ACC_PUBLIC)
|| (instanceof && ((mptr->common.fn_flags & ZEND_ACC_PROTECTED) || EG(scope) == mptr->common.scope))) {
MAKE_STD_ZVAL(method_name);
ZVAL_STRING(method_name, mptr->common.function_name, 1);
zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL);
}
MAKE_STD_ZVAL(method_name);
ZVAL_STRING(method_name, mptr->common.function_name, 1);
zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL);
zend_hash_move_forward_ex(&ce->function_table, &pos);
}
}
/* }}} */
\
/* {{{ proto bool method_exists(object object, string method)
@@ -868,62 +790,21 @@ ZEND_FUNCTION(method_exists)
}
/* }}} */
/* {{{ proto bool class_exists(string classname [, bool autoload])
/* {{{ proto bool class_exists(string classname)
Checks if the class exists */
ZEND_FUNCTION(class_exists)
{
char *class_name, *lc_name;
zval **class_name;
zend_class_entry **ce;
int class_name_len;
zend_bool autoload = 1;
int found;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &class_name, &class_name_len, &autoload) == FAILURE) {
return;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class_name)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
if (!autoload) {
lc_name = do_alloca(class_name_len + 1);
zend_str_tolower_copy(lc_name, class_name, class_name_len);
found = zend_hash_find(EG(class_table), lc_name, class_name_len+1, (void **) &ce);
free_alloca(lc_name);
RETURN_BOOL(found == SUCCESS && !((*ce)->ce_flags & ZEND_ACC_INTERFACE));
}
convert_to_string_ex(class_name);
if (zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC) == SUCCESS) {
RETURN_BOOL(((*ce)->ce_flags & ZEND_ACC_INTERFACE) == 0);
} else {
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto bool interface_exists(string classname [, bool autoload])
Checks if the class exists */
ZEND_FUNCTION(interface_exists)
{
char *iface_name, *lc_name;
zend_class_entry **ce;
int iface_name_len;
zend_bool autoload = 1;
int found;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &iface_name, &iface_name_len, &autoload) == FAILURE) {
return;
}
if (!autoload) {
lc_name = do_alloca(iface_name_len + 1);
zend_str_tolower_copy(lc_name, iface_name, iface_name_len);
found = zend_hash_find(EG(class_table), lc_name, iface_name_len+1, (void **) &ce);
free_alloca(lc_name);
RETURN_BOOL(found == SUCCESS && (*ce)->ce_flags & ZEND_ACC_INTERFACE);
}
if (zend_lookup_class(iface_name, iface_name_len, &ce TSRMLS_CC) == SUCCESS) {
RETURN_BOOL(((*ce)->ce_flags & ZEND_ACC_INTERFACE) > 0);
if (zend_lookup_class(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == SUCCESS) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
@@ -1053,20 +934,19 @@ ZEND_FUNCTION(trigger_error)
/* }}} */
/* {{{ proto string set_error_handler(string error_handler [, int error_types])
/* {{{ proto string set_error_handler(string error_handler)
Sets a user-defined error handler function. Returns the previously defined error handler, or false on error */
ZEND_FUNCTION(set_error_handler)
{
zval *error_handler;
zval **error_handler;
zend_bool had_orig_error_handler=0;
char *error_handler_name = NULL;
long error_type = E_ALL | E_STRICT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) {
return;
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &error_handler)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
if (!zend_is_callable(error_handler, 0, &error_handler_name)) {
if (!zend_is_callable(*error_handler, 0, &error_handler_name)) {
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name:"unknown");
efree(error_handler_name);
@@ -1078,19 +958,17 @@ ZEND_FUNCTION(set_error_handler)
had_orig_error_handler = 1;
*return_value = *EG(user_error_handler);
zval_copy_ctor(return_value);
zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting)));
zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler));
}
ALLOC_ZVAL(EG(user_error_handler));
if (!zend_is_true(error_handler)) { /* unset user-defined handler */
if (!zend_is_true(*error_handler)) { /* unset user-defined handler */
FREE_ZVAL(EG(user_error_handler));
EG(user_error_handler) = NULL;
RETURN_TRUE;
}
EG(user_error_handler_error_reporting) = (int)error_type;
*EG(user_error_handler) = *error_handler;
*EG(user_error_handler) = **error_handler;
zval_copy_ctor(EG(user_error_handler));
if (!had_orig_error_handler) {
@@ -1105,17 +983,11 @@ ZEND_FUNCTION(set_error_handler)
ZEND_FUNCTION(restore_error_handler)
{
if (EG(user_error_handler)) {
zval *zeh = EG(user_error_handler);
EG(user_error_handler) = NULL;
zval_ptr_dtor(&zeh);
zval_ptr_dtor(&EG(user_error_handler));
}
if (zend_ptr_stack_num_elements(&EG(user_error_handlers))==0) {
EG(user_error_handler) = NULL;
} else {
EG(user_error_handler_error_reporting) = zend_stack_int_top(&EG(user_error_handlers_error_reporting));
zend_stack_del_top(&EG(user_error_handlers_error_reporting));
EG(user_error_handler) = zend_ptr_stack_pop(&EG(user_error_handlers));
}
RETURN_TRUE;
@@ -1123,28 +995,18 @@ ZEND_FUNCTION(restore_error_handler)
/* }}} */
/* {{{ proto string set_exception_handler(callable exception_handler)
/* {{{ proto string set_exception_handler(string exception_handler)
Sets a user-defined exception handler function. Returns the previously defined exception handler, or false on error */
ZEND_FUNCTION(set_exception_handler)
{
zval **exception_handler;
char *exception_handler_name = NULL;
zend_bool had_orig_exception_handler=0;
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &exception_handler)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
if (Z_TYPE_PP(exception_handler) != IS_NULL) { /* NULL == unset */
if (!zend_is_callable(*exception_handler, 0, &exception_handler_name)) {
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name:"unknown");
efree(exception_handler_name);
return;
}
efree(exception_handler_name);
}
convert_to_string_ex(exception_handler);
if (EG(user_exception_handler)) {
had_orig_exception_handler = 1;
*return_value = *EG(user_exception_handler);
@@ -1153,7 +1015,7 @@ ZEND_FUNCTION(set_exception_handler)
}
ALLOC_ZVAL(EG(user_exception_handler));
if (Z_TYPE_PP(exception_handler) == IS_NULL) { /* unset user-defined handler */
if (Z_STRLEN_PP(exception_handler)==0) { /* unset user-defined handler */
FREE_ZVAL(EG(user_exception_handler));
EG(user_exception_handler) = NULL;
RETURN_TRUE;
@@ -1189,9 +1051,9 @@ ZEND_FUNCTION(restore_exception_handler)
static int copy_class_or_interface_name(zend_class_entry **pce, int num_args, va_list args, zend_hash_key *hash_key)
{
zval *array = va_arg(args, zval *);
zend_uint mask = va_arg(args, zend_uint);
zend_uint comply = va_arg(args, zend_uint);
zend_uint comply_mask = (comply)? mask:0;
int mask = va_arg(args, int);
int comply = va_arg(args, int);
int comply_mask = (comply)? mask:0;
zend_class_entry *ce = *pce;
if ((hash_key->nKeyLength==0 || hash_key->arKey[0]!=0)
@@ -1206,8 +1068,8 @@ static int copy_class_or_interface_name(zend_class_entry **pce, int num_args, va
Returns an array of all declared classes. */
ZEND_FUNCTION(get_declared_classes)
{
zend_uint mask = ZEND_ACC_INTERFACE;
zend_uint comply = 0;
int mask = ZEND_ACC_INTERFACE;
int comply = 0;
if (ZEND_NUM_ARGS() != 0) {
ZEND_WRONG_PARAM_COUNT();
@@ -1222,8 +1084,8 @@ ZEND_FUNCTION(get_declared_classes)
Returns an array of all declared interfaces. */
ZEND_FUNCTION(get_declared_interfaces)
{
zend_uint mask = ZEND_ACC_INTERFACE;
zend_uint comply = 1;
int mask = ZEND_ACC_INTERFACE;
int comply = 1;
if (ZEND_NUM_ARGS() != 0) {
ZEND_WRONG_PARAM_COUNT();
@@ -1505,8 +1367,7 @@ bad_module_id:
/* }}} */
static zval *debug_backtrace_get_args(void ***curpos TSRMLS_DC)
{
static zval *debug_backtrace_get_args(void ***curpos TSRMLS_DC) {
void **p = *curpos - 2;
zval *arg_array, **arg;
int arg_count = (ulong) *p;
@@ -1563,14 +1424,14 @@ ZEND_FUNCTION(debug_print_backtrace)
ZEND_WRONG_PARAM_COUNT();
}
while (--args > EG(argument_stack).elements) {
while (--args >= EG(argument_stack).elements) {
if (*args--) {
break;
}
args -= *(ulong*)args;
frames_on_stack++;
if ((args-1) == EG(argument_stack).elements) {
if (args == EG(argument_stack).elements) {
arg_stack_consistent = 1;
break;
}
@@ -1586,7 +1447,6 @@ ZEND_FUNCTION(debug_print_backtrace)
array_init(return_value);
while (ptr) {
class_name = call_type = NULL;
if (ptr->op_array) {
filename = ptr->op_array->filename;
lineno = ptr->opline->lineno;
@@ -1684,14 +1544,14 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRML
int arg_stack_consistent = 0;
int frames_on_stack = 0;
while (--args > EG(argument_stack).elements) {
while (--args >= EG(argument_stack).elements) {
if (*args--) {
break;
}
args -= *(ulong*)args;
frames_on_stack++;
if ((args-1) == EG(argument_stack).elements) {
if (args == EG(argument_stack).elements) {
arg_stack_consistent = 1;
break;
}
@@ -1699,11 +1559,10 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRML
ptr = EG(current_execute_data);
/* skip debug_backtrace() */
ptr = ptr->prev_execute_data;
if (skip_last--) {
int arg_count = *((ulong*)(cur_arg_pos - 2));
cur_arg_pos -= (arg_count + 2);
/* skip debug_backtrace() */
ptr = ptr->prev_execute_data;
if (skip_last) {
cur_arg_pos -= 2;
frames_on_stack--;
}
@@ -1757,11 +1616,6 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRML
/* i know this is kinda ugly, but i'm trying to avoid extra cycles in the main execution loop */
zend_bool build_filename_arg = 1;
if (!ptr->opline) {
/* can happen when calling eval from a custom sapi */
function_name = "unknown";
build_filename_arg = 0;
} else
switch (ptr->opline->op2.u.constant.value.lval) {
case ZEND_EVAL:
function_name = "eval";
@@ -1831,20 +1685,17 @@ ZEND_FUNCTION(debug_backtrace)
ZEND_FUNCTION(extension_loaded)
{
zval **extension_name;
char *lcname;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &extension_name)) {
ZEND_WRONG_PARAM_COUNT();
}
convert_to_string_ex(extension_name);
lcname = zend_str_tolower_dup(Z_STRVAL_PP(extension_name), Z_STRLEN_PP(extension_name));
if (zend_hash_exists(&module_registry, lcname, Z_STRLEN_PP(extension_name)+1)) {
RETVAL_TRUE;
if (zend_hash_exists(&module_registry, Z_STRVAL_PP(extension_name), Z_STRLEN_PP(extension_name)+1)) {
RETURN_TRUE;
} else {
RETVAL_FALSE;
RETURN_FALSE;
}
efree(lcname);
}
/* }}} */
+1 -4
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -23,10 +23,7 @@
#define ZEND_BUILTIN_FUNCTIONS_H
int zend_startup_builtin_functions(TSRMLS_D);
BEGIN_EXTERN_C()
ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRMLS_DC);
END_EXTERN_C()
#endif /* ZEND_BUILTIN_FUNCTIONS_H */
+377 -652
View File
File diff suppressed because it is too large. Load diff
+29 -75
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -33,6 +33,7 @@
#define DEBUG_ZEND 0
#define FREE_PNODE(znode) zval_dtor(&znode->u.constant);
#define FREE_OP(Ts, op, should_free) if (should_free) zval_dtor(should_free);
#define SET_UNUSED(op) (op).op_type = IS_UNUSED
@@ -51,6 +52,7 @@ typedef struct _zend_op zend_op;
typedef struct _znode {
int op_type;
zend_llist *throw_list; /* Try and save this space later on */
union {
zval constant;
@@ -67,12 +69,12 @@ typedef struct _znode {
typedef struct _zend_execute_data zend_execute_data;
#define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data TSRMLS_DC
#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data TSRMLS_CC
#define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data, zend_op_array *op_array TSRMLS_DC
#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data, op_array TSRMLS_CC
typedef int (*opcode_handler_t) (ZEND_OPCODE_HANDLER_ARGS);
extern ZEND_API opcode_handler_t *zend_opcode_handlers;
extern opcode_handler_t zend_opcode_handlers[512];
struct _zend_op {
opcode_handler_t handler;
@@ -92,27 +94,13 @@ typedef struct _zend_brk_cont_element {
} zend_brk_cont_element;
typedef struct _zend_try_catch_element {
zend_uint try_op;
zend_uint catch_op; /* ketchup! */
} zend_try_catch_element;
/* method flags (types) */
#define ZEND_ACC_STATIC 0x01
#define ZEND_ACC_ABSTRACT 0x02
#define ZEND_ACC_FINAL 0x04
#define ZEND_ACC_IMPLEMENTED_ABSTRACT 0x08
#define ZEND_ACC_INTERFACE 0x08
#define ZEND_ACC_ABSTRACT_CLASS 0x10
#define ZEND_ACC_FINAL_CLASS 0x20
/* class flags (types) */
/* ZEND_ACC_IMPLICIT_ABSTRACT_CLASS is used for abstract classes (since it is set by any abstract method even interfaces MAY have it set, too). */
/* ZEND_ACC_EXPLICIT_ABSTRACT_CLASS denotes that a class was explicitly defined as abstract by using the keyword. */
#define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS 0x10
#define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS 0x20
#define ZEND_ACC_FINAL_CLASS 0x40
#define ZEND_ACC_INTERFACE 0x80
/* method flags (visibility) */
/* The order of those must be kept - public < protected < private */
#define ZEND_ACC_PUBLIC 0x100
#define ZEND_ACC_PROTECTED 0x200
@@ -122,13 +110,8 @@ typedef struct _zend_try_catch_element {
#define ZEND_ACC_CHANGED 0x800
#define ZEND_ACC_IMPLICIT_PUBLIC 0x1000
/* method flags (special method detection) */
#define ZEND_ACC_CTOR 0x2000
#define ZEND_ACC_DTOR 0x4000
#define ZEND_ACC_CLONE 0x8000
/* method flag (bc only), any method that has this flag can be used statically and non statically. */
#define ZEND_ACC_ALLOW_STATIC 0x10000
#define ZEND_ACC_DTOR 0x4000
char *zend_visibility_string(zend_uint fn_flags);
@@ -148,16 +131,8 @@ typedef struct _zend_arg_info {
zend_uint class_name_len;
zend_bool allow_null;
zend_bool pass_by_reference;
zend_bool return_reference;
int required_num_args;
} zend_arg_info;
typedef struct _zend_compiled_variable {
char *name;
int name_len;
ulong hash_value;
} zend_compiled_variable;
struct _zend_op_array {
/* Common elements */
zend_uchar type;
@@ -166,10 +141,8 @@ struct _zend_op_array {
zend_uint fn_flags;
union _zend_function *prototype;
zend_uint num_args;
zend_uint required_num_args;
zend_arg_info *arg_info;
zend_bool pass_rest_by_reference;
unsigned char return_reference;
/* END of common elements */
zend_uint *refcount;
@@ -177,24 +150,19 @@ struct _zend_op_array {
zend_op *opcodes;
zend_uint last, size;
zend_compiled_variable *vars;
int last_var, size_var;
zend_uint T;
zend_brk_cont_element *brk_cont_array;
zend_uint last_brk_cont;
zend_uint current_brk_cont;
zend_try_catch_element *try_catch_array;
int last_try_catch;
/* static variables support */
HashTable *static_variables;
zend_op *start_op;
int backpatch_count;
zend_bool return_reference;
zend_bool done_pass_two;
zend_bool uses_this;
@@ -208,10 +176,6 @@ struct _zend_op_array {
};
#define ZEND_RETURN_VALUE 0
#define ZEND_RETURN_REFERENCE 1
#define ZEND_RETURN_REFERENCE_AGNOSTIC 2
typedef struct _zend_internal_function {
/* Common elements */
zend_uchar type;
@@ -220,10 +184,8 @@ typedef struct _zend_internal_function {
zend_uint fn_flags;
union _zend_function *prototype;
zend_uint num_args;
zend_uint required_num_args;
zend_arg_info *arg_info;
zend_bool pass_rest_by_reference;
unsigned char return_reference;
/* END of common elements */
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
@@ -241,10 +203,8 @@ typedef union _zend_function {
zend_uint fn_flags;
union _zend_function *prototype;
zend_uint num_args;
zend_uint required_num_args;
zend_arg_info *arg_info;
zend_bool pass_rest_by_reference;
unsigned char return_reference;
} common;
zend_op_array op_array;
@@ -282,10 +242,8 @@ struct _zend_execute_data {
zend_op_array *op_array;
zval *object;
union _temp_variable *Ts;
zval ***CVs;
zend_bool original_in_execution;
zend_class_entry *calling_scope;
HashTable *symbol_table;
struct _zend_execute_data *prev_execute_data;
};
@@ -296,7 +254,6 @@ struct _zend_execute_data {
#define IS_TMP_VAR (1<<1)
#define IS_VAR (1<<2)
#define IS_UNUSED (1<<3) /* Unused variable */
#define IS_CV (1<<4) /* Compiled variable */
#define EXT_TYPE_UNUSED (1<<0)
@@ -326,6 +283,8 @@ int zend_get_zendleng(TSRMLS_D);
/* parser-driven code generators */
void zend_do_fold_binary_op(zend_uchar op, znode *result, znode *op1, znode *op2 TSRMLS_DC);
void zend_do_fold_constant(znode *result, znode *constant_name TSRMLS_DC);
void zend_do_binary_op(zend_uchar op, znode *result, znode *op1, znode *op2 TSRMLS_DC);
void zend_do_unary_op(zend_uchar op, znode *result, znode *op1 TSRMLS_DC);
void zend_do_binary_assign_op(zend_uchar op, znode *result, znode *op1, znode *op2 TSRMLS_DC);
@@ -340,7 +299,7 @@ void zend_do_fetch_global_variable(znode *varname, znode *static_assignment, int
void fetch_array_begin(znode *result, znode *varname, znode *first_dim TSRMLS_DC);
void fetch_array_dim(znode *result, znode *parent, znode *dim TSRMLS_DC);
void fetch_string_offset(znode *result, znode *parent, znode *offset TSRMLS_DC);
void zend_do_fetch_static_member(znode *result, znode *class_znode TSRMLS_DC);
void zend_do_fetch_static_member(znode *class_znode TSRMLS_DC);
void zend_do_print(znode *result, znode *arg TSRMLS_DC);
void zend_do_echo(znode *arg TSRMLS_DC);
typedef int (*unary_op_type)(zval *, zval *);
@@ -382,23 +341,21 @@ void zend_do_end_function_declaration(znode *function_token TSRMLS_DC);
void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initialization, znode *class_type, znode *varname, zend_bool pass_by_reference TSRMLS_DC);
int zend_do_begin_function_call(znode *function_name TSRMLS_DC);
void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC);
void zend_do_clone(znode *result, znode *expr TSRMLS_DC);
void zend_do_begin_dynamic_function_call(znode *function_name TSRMLS_DC);
void zend_do_fetch_class(znode *result, znode *class_name TSRMLS_DC);
void zend_do_fetch_class_name(znode *result, znode *class_entry, znode *class_name TSRMLS_DC);
void zend_do_begin_class_member_function_call(znode *class_name, znode *method_name TSRMLS_DC);
void zend_do_begin_class_member_function_call(TSRMLS_D);
void zend_do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC);
void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC);
void zend_do_handle_exception(TSRMLS_D);
void zend_do_try(znode *try_token TSRMLS_DC);
void zend_do_begin_catch(znode *try_token, znode *catch_class, znode *catch_var, zend_bool first_catch TSRMLS_DC);
void zend_do_end_catch(znode *try_token TSRMLS_DC);
void zend_do_throw(znode *expr TSRMLS_DC);
ZEND_API int do_bind_function(zend_op *opline, HashTable *function_table, zend_bool compile_time);
ZEND_API zend_class_entry *do_bind_class(zend_op *opline, HashTable *class_table, zend_bool compile_time TSRMLS_DC);
ZEND_API zend_class_entry *do_bind_inherited_class(zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC);
ZEND_API int do_bind_function(zend_op *opline, HashTable *function_table, HashTable *class_table, int compile_time);
ZEND_API zend_class_entry *do_bind_class(zend_op *opline, HashTable *function_table, HashTable *class_table TSRMLS_DC);
ZEND_API zend_class_entry *do_bind_inherited_class(zend_op *opline, HashTable *function_table, HashTable *class_table, zend_class_entry *parent_ce TSRMLS_DC);
ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC);
ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC);
void zend_do_implements_interface(znode *interface_znode TSRMLS_DC);
@@ -505,14 +462,13 @@ ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC);
ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC);
ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC);
ZEND_API void zend_function_dtor(zend_function *function);
ZEND_API void destroy_zend_class(zend_class_entry **pce);
void zend_class_add_ref(zend_class_entry **ce);
ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length, int internal);
ZEND_API void zend_unmangle_property_name(char *mangled_property, char **prop_name, char **class_name);
void mangle_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length, int internal);
void unmangle_property_name(char *mangled_property, char **prop_name, char **class_name);
#define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor
#define ZEND_FUNCTION_DTOR (void (*)(void *)) destroy_zend_function
#define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class
zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC);
@@ -522,9 +478,6 @@ int print_class(zend_class_entry *class_entry TSRMLS_DC);
void print_op_array(zend_op_array *op_array, int optimizations);
int pass_two(zend_op_array *op_array TSRMLS_DC);
zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array);
void zend_do_first_catch(znode *open_parentheses TSRMLS_DC);
void zend_initialize_try_catch_element(znode *try_token TSRMLS_DC);
void zend_do_mark_last_catch(znode *first_catch, znode *last_additional_catch TSRMLS_DC);
ZEND_API zend_bool zend_is_compiling(TSRMLS_D);
ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC);
ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers TSRMLS_DC);
@@ -541,7 +494,6 @@ typedef struct _zend_auto_global {
void zend_auto_global_dtor(zend_auto_global *auto_global);
ZEND_API int zend_register_auto_global(char *name, uint name_len, zend_auto_global_callback auto_global_callback TSRMLS_DC);
ZEND_API zend_bool zend_is_auto_global(char *name, uint name_len TSRMLS_DC);
ZEND_API int zend_auto_global_disable_jit(char *varname, zend_uint varname_length TSRMLS_DC);
int zendlex(znode *zendlval TSRMLS_DC);
@@ -723,8 +675,6 @@ int zendlex(znode *zendlval TSRMLS_DC);
#define ZEND_ISSET_ISEMPTY_PROP_OBJ 148
#define ZEND_HANDLE_EXCEPTION 149
/* end of block */
/* END: OPCODES */
@@ -805,14 +755,19 @@ int zendlex(znode *zendlval TSRMLS_DC);
#define ZEND_FETCH_STANDARD 0
#define ZEND_FETCH_ADD_LOCK 1
#define ZEND_FE_FETCH_BYREF 1
#define ZEND_FE_FETCH_WITH_KEY 2
#define ZEND_MEMBER_FUNC_CALL 1<<0
#define ZEND_ARG_SEND_BY_REF (1<<0)
#define ZEND_ARG_COMPILE_TIME_BOUND (1<<1)
#define AI_USE_PTR(ai) \
if ((ai).ptr_ptr) { \
(ai).ptr = *((ai).ptr_ptr); \
(ai).ptr_ptr = &((ai).ptr); \
} else { \
(ai).ptr = NULL; \
}
/* Lost In Stupid Parentheses */
#define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \
( \
@@ -846,7 +801,6 @@ END_EXTERN_C()
#define ZEND_GET_FUNC_NAME "__get"
#define ZEND_SET_FUNC_NAME "__set"
#define ZEND_CALL_FUNC_NAME "__call"
#define ZEND_AUTOLOAD_FUNC_NAME "__autoload"
#endif /* ZEND_COMPILE_H */
+2 -3
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -34,8 +34,7 @@ typedef unsigned int uint;
/* #include <malloc.h> */
#define HAVE_STRING_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_STDLIB_H 1
#undef HAVE_KILL
#define HAVE_GETPID 1
/* #define HAVE_ALLOCA_H 1 */
+1 -2
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -55,7 +55,6 @@ typedef unsigned int uint;
#define HAVE_STDARG_H 1
#define HAVE_SNPRINTF 1
#define HAVE_VSNPRINTF 1
#define HAVE_STRCOLL 1
#define snprintf _snprintf
#define vsnprintf _vsnprintf
+19 -19
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -231,8 +231,10 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
scope = CG(active_class_entry);
}
class_name = estrndup(name, class_name_len);
class_name = do_alloca(class_name_len+1);
memcpy(class_name, name, class_name_len);
class_name[class_name_len] = '\0';
if (class_name_len == sizeof("self")-1 && strcmp(class_name, "self") == 0) {
if (scope) {
ce = &scope;
@@ -253,7 +255,7 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
retval = 0;
}
}
efree(class_name);
free_alloca(class_name);
if (retval && ce) {
if (zend_hash_find(&((*ce)->constants_table), constant_name, const_name_len+1, (void **) &ret_constant) != SUCCESS) {
@@ -264,7 +266,6 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
}
if (retval) {
zval_update_constant(ret_constant, (void*)1 TSRMLS_CC);
*result = **ret_constant;
zval_copy_ctor(result);
}
@@ -273,8 +274,9 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
}
if (zend_hash_find(EG(zend_constants), name, name_len+1, (void **) &c) == FAILURE) {
lookup_name = estrndup(name, name_len);
zend_str_tolower(lookup_name, name_len);
lookup_name = do_alloca(name_len+1);
zend_str_tolower_copy(lookup_name, name, name_len);
lookup_name[name_len] = '\0';
if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) {
if ((c->flags & CONST_CS) && memcmp(c->name, name, name_len)!=0) {
@@ -283,7 +285,7 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
} else {
retval=0;
}
efree(lookup_name);
free_alloca(lookup_name);
}
if (retval) {
@@ -299,8 +301,7 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
{
char *lowercase_name = NULL;
char *name;
char *lowercase_name;
int ret = SUCCESS;
#if 0
@@ -309,24 +310,23 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
if (!(c->flags & CONST_CS)) {
/* keep in mind that c->name_len already contains the '\0' */
lowercase_name = estrndup(c->name, c->name_len);
zend_str_tolower(lowercase_name, c->name_len);
name = lowercase_name;
lowercase_name = do_alloca(c->name_len);
zend_str_tolower_copy(lowercase_name, c->name, c->name_len - 1);
} else {
name = c->name;
lowercase_name = do_alloca(c->name_len + 1);
memcpy(lowercase_name, c->name, c->name_len);
lowercase_name[c->name_len] = '\0';
}
if (zend_hash_add(EG(zend_constants), name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
zend_error(E_NOTICE,"Constant %s already defined", name);
if (zend_hash_add(EG(zend_constants), lowercase_name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
free(c->name);
if (!(c->flags & CONST_PERSISTENT)) {
zval_dtor(&c->value);
}
zend_error(E_NOTICE,"Constant %s already defined", lowercase_name);
ret = FAILURE;
}
if (lowercase_name) {
efree(lowercase_name);
}
free_alloca(lowercase_name);
return ret;
}
+3 -3
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -27,7 +27,7 @@
#define CONST_CS (1<<0) /* Case Sensitive */
#define CONST_PERSISTENT (1<<1) /* Persistent */
#define PHP_USER_CONSTANT INT_MAX /* a constant defined in user space */
#define PHP_USER_CONSTANT LONG_MAX /* a constant defined in user space */
typedef struct _zend_constant {
zval value;
@@ -62,7 +62,7 @@ ZEND_API void zend_register_stringl_constant(char *name, uint name_len, char *st
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC);
void zend_copy_constants(HashTable *target, HashTable *sourc);
void copy_zend_constant(zend_constant *c);
END_EXTERN_C()
END_EXTERN_C();
#define ZEND_CONSTANT_DTOR (void (*)(void *)) free_zend_constant
+489 -2
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -24,8 +24,495 @@
#include "zend_reflection_api.h"
#include "zend_builtin_functions.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"
static zend_class_entry *default_exception_ptr;
static zend_object_handlers default_exception_handlers;
ZEND_API void zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC);
static zend_object_value zend_default_exception_new(zend_class_entry *class_type TSRMLS_DC)
{
zval tmp, obj;
zend_object *object;
zval *trace;
obj.value.obj = zend_objects_new(&object, class_type TSRMLS_CC);
obj.value.obj.handlers = &default_exception_handlers;
ALLOC_HASHTABLE(object->properties);
zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
ALLOC_ZVAL(trace);
trace->is_ref = 0;
trace->refcount = 0;
zend_fetch_debug_backtrace(trace, 0 TSRMLS_CC);
zend_update_property_string(class_type, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
zend_update_property_long(class_type, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
zend_update_property(class_type, &obj, "trace", sizeof("trace")-1, trace TSRMLS_CC);
return obj.value.obj;
}
ZEND_METHOD(exception, __clone)
{
/* Should never be executable */
zend_throw_exception(NULL, "Cannot clone object using __clone()", 0 TSRMLS_CC);
}
ZEND_METHOD(exception, __construct)
{
char *message = NULL;
long code = 0;
zval *object;
int argc = ZEND_NUM_ARGS(), message_len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|sl", &message, &message_len, &code) == FAILURE) {
zend_error(E_CORE_ERROR, "Wrong parameter count for exception([string $exception [, long $code ]])");
}
object = getThis();
if (message) {
zend_update_property_string(Z_OBJCE_P(object), object, "message", sizeof("message")-1, message TSRMLS_CC);
}
if (code) {
zend_update_property_long(Z_OBJCE_P(object), object, "code", sizeof("code")-1, code TSRMLS_CC);
}
}
#define DEFAULT_0_PARAMS \
if (ZEND_NUM_ARGS() > 0) { \
ZEND_WRONG_PARAM_COUNT(); \
}
static void _default_exception_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC)
{
zval *value;
value = zend_read_property(Z_OBJCE_P(object), object, name, name_len, 0 TSRMLS_CC);
*return_value = *value;
zval_copy_ctor(return_value);
}
ZEND_METHOD(exception, getFile)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "file", sizeof("file")-1, return_value TSRMLS_CC);
}
ZEND_METHOD(exception, getLine)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "line", sizeof("line")-1, return_value TSRMLS_CC);
}
ZEND_METHOD(exception, getMessage)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "message", sizeof("message")-1, return_value TSRMLS_CC);
}
ZEND_METHOD(exception, getCode)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "code", sizeof("code")-1, return_value TSRMLS_CC);
}
ZEND_METHOD(exception, getTrace)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "trace", sizeof("trace")-1, return_value TSRMLS_CC);
}
/* {{{ ZEND_METHOD(exception, gettraceasstring) */
#define TRACE_APPEND_CHR(chr) \
*str = (char*)erealloc(*str, *len + 1 + 1); \
(*str)[(*len)++] = chr
#define TRACE_APPEND_STRL(val, vallen) \
{ \
int l = vallen; \
*str = (char*)erealloc(*str, *len + l + 1); \
memcpy((*str) + *len, val, l); \
*len += l; \
}
#define TRACE_APPEND_STR(val) \
TRACE_APPEND_STRL(val, sizeof(val)-1)
#define TRACE_APPEND_KEY(key) \
if (zend_hash_find(ht, key, sizeof(key), (void**)&tmp) == SUCCESS) { \
TRACE_APPEND_STRL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); \
}
static int _build_trace_args(zval **arg, int num_args, va_list args, zend_hash_key *hash_key)
{
char **str;
int *len;
str = va_arg(args, char**);
len = va_arg(args, int*);
/* the trivial way would be to do:
* conver_to_string_ex(arg);
* append it and kill the now tmp arg.
* but that could cause some E_NOTICE and also damn long lines.
*/
switch (Z_TYPE_PP(arg)) {
case IS_NULL:
TRACE_APPEND_STR("NULL, ");
break;
case IS_STRING: {
int l_added;
TRACE_APPEND_CHR('\'');
if (Z_STRLEN_PP(arg) > 15) {
TRACE_APPEND_STRL(Z_STRVAL_PP(arg), 15);
TRACE_APPEND_STR("...', ");
l_added = 15 + 6 + 1; /* +1 because of while (--l_added) */
} else {
l_added = Z_STRLEN_PP(arg);
TRACE_APPEND_STRL(Z_STRVAL_PP(arg), l_added);
TRACE_APPEND_STR("', ");
l_added += 3 + 1;
}
while (--l_added) {
if ((*str)[*len - l_added] < 32) {
(*str)[*len - l_added] = '?';
}
}
break;
}
case IS_BOOL:
if (Z_LVAL_PP(arg)) {
TRACE_APPEND_STR("true, ");
} else {
TRACE_APPEND_STR("false, ");
}
break;
case IS_RESOURCE:
TRACE_APPEND_STR("Resource id #");
/* break; */
case IS_LONG: {
long lval = Z_LVAL_PP(arg);
char s_tmp[MAX_LENGTH_OF_LONG + 1];
int l_tmp = zend_sprintf(s_tmp, "%ld", lval); /* SAFE */
TRACE_APPEND_STRL(s_tmp, l_tmp);
TRACE_APPEND_STR(", ");
break;
}
case IS_DOUBLE: {
double dval = Z_DVAL_PP(arg);
char *s_tmp;
int l_tmp;
TSRMLS_FETCH();
s_tmp = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
l_tmp = zend_sprintf(s_tmp, "%.*G", (int) EG(precision), dval); /* SAFE */
TRACE_APPEND_STRL(s_tmp, l_tmp);
/* %G already handles removing trailing zeros from the fractional part, yay */
efree(s_tmp);
TRACE_APPEND_STR(", ");
break;
}
case IS_ARRAY:
TRACE_APPEND_STR("Array, ");
break;
case IS_OBJECT: {
TSRMLS_FETCH();
TRACE_APPEND_STR("Object(");
TRACE_APPEND_STRL(Z_OBJCE_PP(arg)->name, strlen(Z_OBJCE_PP(arg)->name));
TRACE_APPEND_STR("), ");
break;
}
default:
break;
}
return ZEND_HASH_APPLY_KEEP;
}
static int _build_trace_string(zval **frame, int num_args, va_list args, zend_hash_key *hash_key)
{
char *s_tmp, **str;
int *len, *num;
long line;
HashTable *ht = Z_ARRVAL_PP(frame);
zval **file, **tmp;
str = va_arg(args, char**);
len = va_arg(args, int*);
num = va_arg(args, int*);
s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 1 + 1);
sprintf(s_tmp, "#%d ", (*num)++);
TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
efree(s_tmp);
if (zend_hash_find(ht, "file", sizeof("file"), (void**)&file) == SUCCESS) {
if (zend_hash_find(ht, "line", sizeof("line"), (void**)&tmp) == SUCCESS) {
line = Z_LVAL_PP(tmp);
} else {
line = 0;
}
s_tmp = emalloc(Z_STRLEN_PP(file) + MAX_LENGTH_OF_LONG + 2 + 1);
sprintf(s_tmp, "%s(%ld): ", Z_STRVAL_PP(file), line);
TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
efree(s_tmp);
} else {
TRACE_APPEND_STR("[internal function]: ");
}
TRACE_APPEND_KEY("class");
TRACE_APPEND_KEY("type");
TRACE_APPEND_KEY("function");
TRACE_APPEND_CHR('(');
if (zend_hash_find(ht, "args", sizeof("args"), (void**)&tmp) == SUCCESS) {
int last_len = *len;
zend_hash_apply_with_arguments(Z_ARRVAL_PP(tmp), (apply_func_args_t)_build_trace_args, 2, str, len);
if (last_len != *len) {
*len -= 2; /* remove last ', ' */
}
}
TRACE_APPEND_STR(")\n");
return ZEND_HASH_APPLY_KEEP;
}
ZEND_METHOD(exception, getTraceAsString)
{
zval *trace;
char *res = estrdup(""), **str = &res, *s_tmp;
int res_len = 0, *len = &res_len, num = 0;
trace = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
zend_hash_apply_with_arguments(Z_ARRVAL_P(trace), (apply_func_args_t)_build_trace_string, 3, str, len, &num);
s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1);
sprintf(s_tmp, "#%d {main}", num);
TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
efree(s_tmp);
res[res_len] = '\0';
RETURN_STRINGL(res, res_len, 0);
}
/* }}} */
int zend_spprintf(char **message, int max_len, char *format, ...)
{
va_list arg;
int len;
va_start(arg, format);
len = zend_vspprintf(message, max_len, format, arg);
va_end(arg);
return len;
}
ZEND_METHOD(exception, __toString)
{
zval *message, *file, *line, *trace;
char *str;
int len;
zend_fcall_info fci;
zval fname;
message = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "message", sizeof("message")-1, 1 TSRMLS_CC);
file = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "line", sizeof("line")-1, 1 TSRMLS_CC);
ZVAL_STRINGL(&fname, "gettraceasstring", sizeof("gettraceasstring")-1, 0);
fci.size = sizeof(fci);
fci.function_table = &Z_OBJCE_P(getThis())->function_table;
fci.function_name = &fname;
fci.symbol_table = NULL;
fci.object_pp = &getThis();
fci.retval_ptr_ptr = &trace;
fci.param_count = 0;
fci.params = NULL;
fci.no_separation = 1;
zend_call_function(&fci, NULL TSRMLS_CC);
len = zend_spprintf(&str, 0, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s",
Z_OBJCE_P(getThis())->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line),
Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n");
/* We store the result in the private property string so we can access
* the result in uncaught exception handlers without memleaks. */
zend_update_property_string(default_exception_ptr, getThis(), "string", sizeof("string")-1, str TSRMLS_CC);
zval_ptr_dtor(&trace);
RETURN_STRINGL(str, len, 0);
}
/* All functions that may be used in uncaught exception handlers must be final
* and must not throw exceptions. Otherwise we would need a facility to handle
* such exceptions in that handler.
* Also all getXY() methods are final because thy serve as read only access to
* their corresponding properties, no more, no less. If after all you need to
* override somthing then it is method __toString().
* And never try to change the state of exceptions and never implement anything
* that gives the user anything to accomplish this.
*/
static zend_function_entry default_exception_functions[] = {
ZEND_ME(exception, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
ZEND_ME(exception, __construct, NULL, 0)
ZEND_ME(exception, getMessage, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getCode, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getFile, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getLine, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getTrace, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getTraceAsString, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, __toString, NULL, 0)
{NULL, NULL, NULL}
};
static void zend_register_default_exception(TSRMLS_D)
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "exception", default_exception_functions);
default_exception_ptr = zend_register_internal_class(&ce TSRMLS_CC);
default_exception_ptr->create_object = zend_default_exception_new;
memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
default_exception_handlers.clone_obj = NULL;
zend_declare_property_string(default_exception_ptr, "message", sizeof("message")-1, "Unknown exception", ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_string(default_exception_ptr, "string", sizeof("string")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_long(default_exception_ptr, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(default_exception_ptr, "file", sizeof("file")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(default_exception_ptr, "line", sizeof("line")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(default_exception_ptr, "trace", sizeof("trace")-1, ZEND_ACC_PRIVATE TSRMLS_CC);
}
ZEND_API zend_class_entry *zend_exception_get_default(void)
{
return default_exception_ptr;
}
ZEND_API void zend_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, char *format, ...)
{
zval *ex;
va_list arg;
char *message;
va_start(arg, format);
zend_vspprintf(&message, 0, format, arg);
va_end(arg);
MAKE_STD_ZVAL(ex);
if (exception_ce) {
if (!instanceof_function(exception_ce, default_exception_ptr TSRMLS_CC)) {
zend_error(E_NOTICE, "Exceptions must be derived from exception");
exception_ce = default_exception_ptr;
}
} else {
exception_ce = default_exception_ptr;
}
object_init_ex(ex, exception_ce);
if (message) {
zend_update_property_string(exception_ce, ex, "message", sizeof("message")-1, message TSRMLS_CC);
}
if (code) {
zend_update_property_long(exception_ce, ex, "code", sizeof("code")-1, code TSRMLS_CC);
}
efree(message);
EG(exception) = ex;
}
/* at the moment we can't use zend_throw_exception_ex because we don't have a protable
* vsnprintf that tells us the number of characters needed nor do we have spprintf from
* php or asprintf from glibc always.
*/
ZEND_API void zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC)
{
zval *ex;
MAKE_STD_ZVAL(ex);
if (exception_ce) {
if (!instanceof_function(exception_ce, default_exception_ptr TSRMLS_CC)) {
zend_error(E_NOTICE, "Exceptions must be derived from exception");
exception_ce = default_exception_ptr;
}
} else {
exception_ce = default_exception_ptr;
}
object_init_ex(ex, exception_ce);
if (message) {
zend_update_property_string(exception_ce, ex, "message", sizeof("message")-1, message TSRMLS_CC);
}
if (code) {
zend_update_property_long(exception_ce, ex, "code", sizeof("code")-1, code TSRMLS_CC);
}
EG(exception) = ex;
}
static void zend_error_va(int type, const char *file, uint lineno, const char *format, ...)
{
va_list args;
va_start(args, format);
zend_error_cb(type, file, lineno, format, args);
va_end(args);
}
ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
{
zend_class_entry *ce_exception = Z_OBJCE_P(exception);
if (instanceof_function(ce_exception, default_exception_ptr TSRMLS_CC)) {
zval *str, *file, *line;
zval *old_exception = EG(exception);
EG(exception) = NULL;
zend_call_method_with_0_params(&exception, ce_exception, NULL, "__tostring", &str);
if (!EG(exception)) {
if (Z_TYPE_P(str) != IS_STRING) {
zend_error(E_WARNING, "%s::__toString() must return a string", ce_exception->name);
} else {
zend_update_property_string(default_exception_ptr, exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name : Z_STRVAL_P(str) TSRMLS_CC);
}
}
zval_ptr_dtor(&str);
if (EG(exception)) {
/* do the best we can to inform about the inner exception */
if (instanceof_function(ce_exception, default_exception_ptr TSRMLS_CC)) {
file = zend_read_property(default_exception_ptr, EG(exception), "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(default_exception_ptr, EG(exception), "line", sizeof("line")-1, 1 TSRMLS_CC);
} else {
file = NULL;
line = NULL;
}
zend_error_va(E_WARNING, file ? Z_STRVAL_P(file) : NULL, line ? Z_LVAL_P(line) : 0, "Uncaught %s in exception handling during call to %s::__tostring()", Z_OBJCE_P(EG(exception))->name, ce_exception->name);
}
str = zend_read_property(default_exception_ptr, exception, "string", sizeof("string")-1, 1 TSRMLS_CC);
file = zend_read_property(default_exception_ptr, exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(default_exception_ptr, exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
EG(exception) = old_exception;
zend_error_va(E_ERROR, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %s\n thrown", Z_STRVAL_P(str));
} else {
zend_error(E_ERROR, "Uncaught exception '%s'", ce_exception->name);
}
}
ZEND_API void zend_register_default_classes(TSRMLS_D)
{
+48
View File
@@ -0,0 +1,48 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Sterling Hughes <sterling@php.net> |
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef ZEND_DEFAULT_CLASSES_H
#define ZEND_DEFAULT_CLASSES_H
BEGIN_EXTERN_C()
ZEND_API zend_class_entry *zend_exception_get_default(void);
ZEND_API void zend_register_default_classes(TSRMLS_D);
/* exception_ce NULL or zend_exception_get_default() or a derived class
* message NULL or the message of the exception */
ZEND_API void zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC);
ZEND_API void zend_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, char *format, ...);
/* show an exception using zend_error(E_ERROR,...) */
ZEND_API void zend_exception_error(zval *exception TSRMLS_DC);
END_EXTERN_C()
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: t
* End:
*/
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
+2 -2
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -30,7 +30,7 @@ typedef struct _dynamic_array {
} dynamic_array;
BEGIN_EXTERN_C()
ZEND_API int zend_dynamic_array_init(dynamic_array *da, unsigned int element_size, unsigned int size);
ZEND_API int zend_dynamic_array_init(dynamic_array *da);
ZEND_API void *zend_dynamic_array_push(dynamic_array *da);
ZEND_API void *zend_dynamic_array_pop(dynamic_array *da);
ZEND_API void *zend_dynamic_array_get_element(dynamic_array *da, unsigned int index);
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
+94 -277
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -12,10 +12,8 @@
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Authors: Sterling Hughes <sterling@php.net> |
| Marcus Boerger <helly@php.net> |
| Sterling Hughes <sterling@php.net> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
@@ -26,56 +24,12 @@
#include "zend_reflection_api.h"
#include "zend_builtin_functions.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"
zend_class_entry *default_exception_ce;
zend_class_entry *error_exception_ce;
static zend_class_entry *default_exception_ptr;
static zend_object_handlers default_exception_handlers;
ZEND_API void (*zend_throw_exception_hook)(zval *ex TSRMLS_DC);
ZEND_API void zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC);
void zend_throw_exception_internal(zval *exception TSRMLS_DC)
{
if (exception != NULL) {
if (EG(exception)) {
/* FIXME: bail out? */
return;
}
EG(exception) = exception;
}
if (!EG(current_execute_data)) {
zend_error(E_ERROR, "Exception thrown without a stack frame");
}
if (zend_throw_exception_hook) {
zend_throw_exception_hook(exception TSRMLS_CC);
}
if ((EG(current_execute_data)->opline+1)->opcode == ZEND_HANDLE_EXCEPTION) {
/* no need to rethrow the exception */
return;
}
EG(opline_before_exception) = EG(current_execute_data)->opline;
EG(current_execute_data)->opline = &EG(active_op_array)->opcodes[EG(active_op_array)->last-1-1];
}
ZEND_API void zend_clear_exception(TSRMLS_D)
{
if (!EG(exception)) {
return;
}
zval_ptr_dtor(&EG(exception));
EG(exception) = NULL;
EG(current_execute_data)->opline = EG(opline_before_exception);
#if ZEND_DEBUG
EG(opline_before_exception) = NULL;
#endif
}
static zend_object_value zend_default_exception_new_ex(zend_class_entry *class_type, int skip_top_traces TSRMLS_DC)
static zend_object_value zend_default_exception_new(zend_class_entry *class_type TSRMLS_DC)
{
zval tmp, obj;
zend_object *object;
@@ -91,38 +45,21 @@ static zend_object_value zend_default_exception_new_ex(zend_class_entry *class_t
ALLOC_ZVAL(trace);
trace->is_ref = 0;
trace->refcount = 0;
zend_fetch_debug_backtrace(trace, skip_top_traces TSRMLS_CC);
zend_fetch_debug_backtrace(trace, 0 TSRMLS_CC);
zend_update_property_string(default_exception_ce, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
zend_update_property_long(default_exception_ce, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
zend_update_property(default_exception_ce, &obj, "trace", sizeof("trace")-1, trace TSRMLS_CC);
zend_update_property_string(class_type, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
zend_update_property_long(class_type, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
zend_update_property(class_type, &obj, "trace", sizeof("trace")-1, trace TSRMLS_CC);
return obj.value.obj;
}
static zend_object_value zend_default_exception_new(zend_class_entry *class_type TSRMLS_DC)
{
return zend_default_exception_new_ex(class_type, 0 TSRMLS_CC);
}
static zend_object_value zend_error_exception_new(zend_class_entry *class_type TSRMLS_DC)
{
return zend_default_exception_new_ex(class_type, 2 TSRMLS_CC);
}
/* {{{ proto Exception Exception::__clone()
Clone the exception object */
ZEND_METHOD(exception, __clone)
{
/* Should never be executable */
zend_throw_exception(NULL, "Cannot clone object using __clone()", 0 TSRMLS_CC);
}
/* }}} */
/* {{{ proto Exception::__construct(string message, int code)
Exception constructor */
ZEND_METHOD(exception, __construct)
{
char *message = NULL;
@@ -137,50 +74,13 @@ ZEND_METHOD(exception, __construct)
object = getThis();
if (message) {
zend_update_property_string(default_exception_ce, object, "message", sizeof("message")-1, message TSRMLS_CC);
zend_update_property_string(Z_OBJCE_P(object), object, "message", sizeof("message")-1, message TSRMLS_CC);
}
if (code) {
zend_update_property_long(default_exception_ce, object, "code", sizeof("code")-1, code TSRMLS_CC);
zend_update_property_long(Z_OBJCE_P(object), object, "code", sizeof("code")-1, code TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto ErrorException::__construct(string message, int code, int severity [, $filename [, $lineno]])
ErrorException constructor */
ZEND_METHOD(error_exception, __construct)
{
char *message = NULL, *filename = NULL;
long code = 0, severity = E_ERROR, lineno;
zval *object;
int argc = ZEND_NUM_ARGS(), message_len, filename_len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|sllsl", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno) == FAILURE) {
zend_error(E_CORE_ERROR, "Wrong parameter count for exception([string $exception [, long $code ]])");
}
object = getThis();
if (message) {
zend_update_property_string(default_exception_ce, object, "message", sizeof("message")-1, message TSRMLS_CC);
}
if (code) {
zend_update_property_long(default_exception_ce, object, "code", sizeof("code")-1, code TSRMLS_CC);
}
zend_update_property_long(default_exception_ce, object, "severity", sizeof("severity")-1, severity TSRMLS_CC);
if (argc >= 4) {
zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, filename TSRMLS_CC);
if (argc < 5) {
lineno = 0; // invalidate lineno
}
zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, lineno TSRMLS_CC);
}
}
/* }}} */
#define DEFAULT_0_PARAMS \
if (ZEND_NUM_ARGS() > 0) { \
@@ -191,77 +91,46 @@ static void _default_exception_get_entry(zval *object, char *name, int name_len,
{
zval *value;
value = zend_read_property(default_exception_ce, object, name, name_len, 0 TSRMLS_CC);
value = zend_read_property(Z_OBJCE_P(object), object, name, name_len, 0 TSRMLS_CC);
*return_value = *value;
zval_copy_ctor(return_value);
}
/* {{{ proto string Exception::getFile()
Get the file in which the exception occurred */
ZEND_METHOD(exception, getFile)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "file", sizeof("file")-1, return_value TSRMLS_CC);
}
/* }}} */
/* {{{ proto int Exception::getLine()
Get the line in which the exception occurred */
ZEND_METHOD(exception, getLine)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "line", sizeof("line")-1, return_value TSRMLS_CC);
}
/* }}} */
/* {{{ proto string Exception::getMessage()
Get the exception message */
ZEND_METHOD(exception, getMessage)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "message", sizeof("message")-1, return_value TSRMLS_CC);
}
/* }}} */
/* {{{ proto int Exception::getCode()
Get the exception code */
ZEND_METHOD(exception, getCode)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "code", sizeof("code")-1, return_value TSRMLS_CC);
}
/* }}} */
/* {{{ proto array Exception::getTrace()
Get the stack trace for the location in which the exception occurred */
ZEND_METHOD(exception, getTrace)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "trace", sizeof("trace")-1, return_value TSRMLS_CC);
}
/* }}} */
/* {{{ proto int ErrorException::getSeverity()
Get the exception severity */
ZEND_METHOD(error_exception, getSeverity)
{
DEFAULT_0_PARAMS;
_default_exception_get_entry(getThis(), "severity", sizeof("severity")-1, return_value TSRMLS_CC);
}
/* }}} */
/* {{{ ZEND_METHOD(exception, gettraceasstring) */
#define TRACE_APPEND_CHR(chr) \
@@ -415,16 +284,13 @@ static int _build_trace_string(zval **frame, int num_args, va_list args, zend_ha
return ZEND_HASH_APPLY_KEEP;
}
/* {{{ proto string Exception::getTraceAsString()
Obtain the backtrace for the exception as a string (instead of an array) */
ZEND_METHOD(exception, getTraceAsString)
{
zval *trace;
char *res = estrdup(""), **str = &res, *s_tmp;
int res_len = 0, *len = &res_len, num = 0;
trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
trace = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
zend_hash_apply_with_arguments(Z_ARRVAL_P(trace), (apply_func_args_t)_build_trace_string, 3, str, len, &num);
s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1);
@@ -437,7 +303,7 @@ ZEND_METHOD(exception, getTraceAsString)
}
/* }}} */
static int zend_spprintf(char **message, int max_len, char *format, ...)
int zend_spprintf(char **message, int max_len, char *format, ...)
{
va_list arg;
int len;
@@ -448,24 +314,17 @@ static int zend_spprintf(char **message, int max_len, char *format, ...)
return len;
}
/* {{{ proto string Exception::__toString()
Obtain the string representation of the Exception object */
ZEND_METHOD(exception, __toString)
{
zval message, file, line, *trace;
zval *message, *file, *line, *trace;
char *str;
int len;
zend_fcall_info fci;
zval fname;
_default_exception_get_entry(getThis(), "message", sizeof("message")-1, &message TSRMLS_CC);
_default_exception_get_entry(getThis(), "file", sizeof("file")-1, &file TSRMLS_CC);
_default_exception_get_entry(getThis(), "line", sizeof("line")-1, &line TSRMLS_CC);
convert_to_string(&message);
convert_to_string(&file);
convert_to_long(&line);
message = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "message", sizeof("message")-1, 1 TSRMLS_CC);
file = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "line", sizeof("line")-1, 1 TSRMLS_CC);
ZVAL_STRINGL(&fname, "gettraceasstring", sizeof("gettraceasstring")-1, 0);
@@ -481,35 +340,18 @@ ZEND_METHOD(exception, __toString)
zend_call_function(&fci, NULL TSRMLS_CC);
if (Z_TYPE_P(trace) != IS_STRING) {
trace = NULL;
}
if (Z_STRLEN(message) > 0) {
len = zend_spprintf(&str, 0, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s",
Z_OBJCE_P(getThis())->name, Z_STRVAL(message), Z_STRVAL(file), Z_LVAL(line),
(trace && Z_STRLEN_P(trace)) ? Z_STRVAL_P(trace) : "#0 {main}\n");
} else {
len = zend_spprintf(&str, 0, "exception '%s' in %s:%ld\nStack trace:\n%s",
Z_OBJCE_P(getThis())->name, Z_STRVAL(file), Z_LVAL(line),
(trace && Z_STRLEN_P(trace)) ? Z_STRVAL_P(trace) : "#0 {main}\n");
}
len = zend_spprintf(&str, 0, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s",
Z_OBJCE_P(getThis())->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line),
Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n");
/* We store the result in the private property string so we can access
* the result in uncaught exception handlers without memleaks. */
zend_update_property_string(default_exception_ce, getThis(), "string", sizeof("string")-1, str TSRMLS_CC);
zend_update_property_string(default_exception_ptr, getThis(), "string", sizeof("string")-1, str TSRMLS_CC);
if (trace) {
zval_ptr_dtor(&trace);
}
zval_dtor(&message);
zval_dtor(&file);
zval_dtor(&line);
zval_ptr_dtor(&trace);
RETURN_STRINGL(str, len, 0);
}
/* }}} */
/* All functions that may be used in uncaught exception handlers must be final
* and must not throw exceptions. Otherwise we would need a facility to handle
@@ -520,15 +362,9 @@ ZEND_METHOD(exception, __toString)
* And never try to change the state of exceptions and never implement anything
* that gives the user anything to accomplish this.
*/
static
ZEND_BEGIN_ARG_INFO(arginfo_exception___construct, 0)
ZEND_ARG_INFO(0, message)
ZEND_ARG_INFO(0, code)
ZEND_END_ARG_INFO();
static zend_function_entry default_exception_functions[] = {
ZEND_ME(exception, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
ZEND_ME(exception, __construct, arginfo_exception___construct, ZEND_ACC_PUBLIC)
ZEND_ME(exception, __construct, NULL, 0)
ZEND_ME(exception, getMessage, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getCode, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getFile, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
@@ -539,103 +375,91 @@ static zend_function_entry default_exception_functions[] = {
{NULL, NULL, NULL}
};
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_error_exception___construct, 0, 0, 3)
ZEND_ARG_INFO(0, message)
ZEND_ARG_INFO(0, code)
ZEND_ARG_INFO(0, severity)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, lineno)
ZEND_END_ARG_INFO();
static zend_function_entry error_exception_functions[] = {
ZEND_ME(error_exception, __construct, arginfo_error_exception___construct, ZEND_ACC_PUBLIC)
ZEND_ME(error_exception, getSeverity, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
{NULL, NULL, NULL}
};
void zend_register_default_exception(TSRMLS_D)
static void zend_register_default_exception(TSRMLS_D)
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "Exception", default_exception_functions);
default_exception_ce = zend_register_internal_class(&ce TSRMLS_CC);
default_exception_ce->create_object = zend_default_exception_new;
INIT_CLASS_ENTRY(ce, "exception", default_exception_functions);
default_exception_ptr = zend_register_internal_class(&ce TSRMLS_CC);
default_exception_ptr->create_object = zend_default_exception_new;
memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
default_exception_handlers.clone_obj = NULL;
zend_declare_property_string(default_exception_ce, "message", sizeof("message")-1, "", ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_string(default_exception_ce, "string", sizeof("string")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_long(default_exception_ce, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(default_exception_ce, "file", sizeof("file")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(default_exception_ce, "line", sizeof("line")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(default_exception_ce, "trace", sizeof("trace")-1, ZEND_ACC_PRIVATE TSRMLS_CC);
INIT_CLASS_ENTRY(ce, "ErrorException", error_exception_functions);
error_exception_ce = zend_register_internal_class_ex(&ce, default_exception_ce, NULL TSRMLS_CC);
error_exception_ce->create_object = zend_error_exception_new;
zend_declare_property_long(error_exception_ce, "severity", sizeof("severity")-1, E_ERROR, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_string(default_exception_ptr, "message", sizeof("message")-1, "Unknown exception", ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_string(default_exception_ptr, "string", sizeof("string")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_long(default_exception_ptr, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(default_exception_ptr, "file", sizeof("file")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(default_exception_ptr, "line", sizeof("line")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(default_exception_ptr, "trace", sizeof("trace")-1, ZEND_ACC_PRIVATE TSRMLS_CC);
}
ZEND_API zend_class_entry *zend_exception_get_default(void)
{
return default_exception_ce;
return default_exception_ptr;
}
ZEND_API zend_class_entry *zend_get_error_exception(void)
{
return error_exception_ce;
}
ZEND_API zval * zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC)
ZEND_API void zend_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, char *format, ...)
{
zval *ex;
va_list arg;
char *message;
va_start(arg, format);
zend_vspprintf(&message, 0, format, arg);
va_end(arg);
MAKE_STD_ZVAL(ex);
if (exception_ce) {
if (!instanceof_function(exception_ce, default_exception_ce TSRMLS_CC)) {
zend_error(E_NOTICE, "Exceptions must be derived from the Exception base class");
exception_ce = default_exception_ce;
if (!instanceof_function(exception_ce, default_exception_ptr TSRMLS_CC)) {
zend_error(E_NOTICE, "Exceptions must be derived from exception");
exception_ce = default_exception_ptr;
}
} else {
exception_ce = default_exception_ce;
exception_ce = default_exception_ptr;
}
object_init_ex(ex, exception_ce);
if (message) {
zend_update_property_string(default_exception_ce, ex, "message", sizeof("message")-1, message TSRMLS_CC);
zend_update_property_string(exception_ce, ex, "message", sizeof("message")-1, message TSRMLS_CC);
}
if (code) {
zend_update_property_long(default_exception_ce, ex, "code", sizeof("code")-1, code TSRMLS_CC);
zend_update_property_long(exception_ce, ex, "code", sizeof("code")-1, code TSRMLS_CC);
}
zend_throw_exception_internal(ex TSRMLS_CC);
return ex;
}
ZEND_API zval * zend_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, char *format, ...)
{
va_list arg;
char *message;
zval *zexception;
va_start(arg, format);
zend_vspprintf(&message, 0, format, arg);
va_end(arg);
zexception = zend_throw_exception(exception_ce, message, code TSRMLS_CC);
efree(message);
return zexception;
EG(exception) = ex;
}
ZEND_API zval * zend_throw_error_exception(zend_class_entry *exception_ce, char *message, long code, int severity TSRMLS_DC)
/* at the moment we can't use zend_throw_exception_ex because we don't have a protable
* vsnprintf that tells us the number of characters needed nor do we have spprintf from
* php or asprintf from glibc always.
*/
ZEND_API void zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC)
{
zval *ex = zend_throw_exception(exception_ce, message, code TSRMLS_CC);
zend_update_property_long(default_exception_ce, ex, "severity", sizeof("severity")-1, severity TSRMLS_CC);
return ex;
zval *ex;
MAKE_STD_ZVAL(ex);
if (exception_ce) {
if (!instanceof_function(exception_ce, default_exception_ptr TSRMLS_CC)) {
zend_error(E_NOTICE, "Exceptions must be derived from exception");
exception_ce = default_exception_ptr;
}
} else {
exception_ce = default_exception_ptr;
}
object_init_ex(ex, exception_ce);
if (message) {
zend_update_property_string(exception_ce, ex, "message", sizeof("message")-1, message TSRMLS_CC);
}
if (code) {
zend_update_property_long(exception_ce, ex, "code", sizeof("code")-1, code TSRMLS_CC);
}
EG(exception) = ex;
}
static void zend_error_va(int type, const char *file, uint lineno, const char *format, ...)
@@ -647,12 +471,12 @@ static void zend_error_va(int type, const char *file, uint lineno, const char *f
va_end(args);
}
/* This function doesn't return as it calls E_ERROR */
ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
{
zend_class_entry *ce_exception = Z_OBJCE_P(exception);
if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) {
if (instanceof_function(ce_exception, default_exception_ptr TSRMLS_CC)) {
zval *str, *file, *line;
zval *old_exception = EG(exception);
EG(exception) = NULL;
@@ -661,16 +485,16 @@ ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
if (Z_TYPE_P(str) != IS_STRING) {
zend_error(E_WARNING, "%s::__toString() must return a string", ce_exception->name);
} else {
zend_update_property_string(default_exception_ce, exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name : Z_STRVAL_P(str) TSRMLS_CC);
zend_update_property_string(default_exception_ptr, exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name : Z_STRVAL_P(str) TSRMLS_CC);
}
}
zval_ptr_dtor(&str);
if (EG(exception)) {
/* do the best we can to inform about the inner exception */
if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) {
file = zend_read_property(default_exception_ce, EG(exception), "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(default_exception_ce, EG(exception), "line", sizeof("line")-1, 1 TSRMLS_CC);
if (instanceof_function(ce_exception, default_exception_ptr TSRMLS_CC)) {
file = zend_read_property(default_exception_ptr, EG(exception), "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(default_exception_ptr, EG(exception), "line", sizeof("line")-1, 1 TSRMLS_CC);
} else {
file = NULL;
line = NULL;
@@ -678,9 +502,11 @@ ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
zend_error_va(E_WARNING, file ? Z_STRVAL_P(file) : NULL, line ? Z_LVAL_P(line) : 0, "Uncaught %s in exception handling during call to %s::__tostring()", Z_OBJCE_P(EG(exception))->name, ce_exception->name);
}
str = zend_read_property(default_exception_ce, exception, "string", sizeof("string")-1, 1 TSRMLS_CC);
file = zend_read_property(default_exception_ce, exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(default_exception_ce, exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
str = zend_read_property(default_exception_ptr, exception, "string", sizeof("string")-1, 1 TSRMLS_CC);
file = zend_read_property(default_exception_ptr, exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(default_exception_ptr, exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
EG(exception) = old_exception;
zend_error_va(E_ERROR, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %s\n thrown", Z_STRVAL_P(str));
} else {
@@ -688,21 +514,12 @@ ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
}
}
ZEND_API void zend_throw_exception_object(zval *exception TSRMLS_DC)
ZEND_API void zend_register_default_classes(TSRMLS_D)
{
zend_class_entry *exception_ce;
if (exception == NULL || exception->type != IS_OBJECT) {
zend_error(E_ERROR, "Need to supply an object when throwing an exception");
}
exception_ce = Z_OBJCE_P(exception);
if (!exception_ce || !instanceof_function(exception_ce, default_exception_ce TSRMLS_CC)) {
zend_error(E_ERROR, "Exceptions must be valid objects derived from the Exception base class");
}
zend_throw_exception_internal(exception TSRMLS_CC);
zend_register_interfaces(TSRMLS_C);
zend_register_default_exception(TSRMLS_C);
zend_register_reflection_api(TSRMLS_C);
zend_register_iterator_wrapper(TSRMLS_C);
}
/*
+6 -19
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -12,38 +12,25 @@
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Authors: Sterling Hughes <sterling@php.net> |
| Marcus Boerger <helly@php.net> |
| Sterling Hughes <sterling@php.net> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef ZEND_EXCEPTIONS_H
#define ZEND_EXCEPTIONS_H
#ifndef ZEND_DEFAULT_CLASSES_H
#define ZEND_DEFAULT_CLASSES_H
BEGIN_EXTERN_C()
void zend_throw_exception_internal(zval *exception TSRMLS_DC);
void zend_register_default_exception(TSRMLS_D);
ZEND_API zend_class_entry *zend_exception_get_default(void);
ZEND_API zend_class_entry *zend_get_error_exception(void);
ZEND_API void zend_register_default_classes(TSRMLS_D);
/* exception_ce NULL or zend_exception_get_default() or a derived class
* message NULL or the message of the exception */
ZEND_API zval * zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC);
ZEND_API zval * zend_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, char *format, ...);
ZEND_API void zend_throw_exception_object(zval *exception TSRMLS_DC);
ZEND_API void zend_clear_exception(TSRMLS_D);
ZEND_API zval * zend_throw_error_exception(zend_class_entry *exception_ce, char *message, long code, int severity TSRMLS_DC);
extern ZEND_API void (*zend_throw_exception_hook)(zval *ex TSRMLS_DC);
ZEND_API void zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC);
ZEND_API void zend_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, char *format, ...);
/* show an exception using zend_error(E_ERROR,...) */
ZEND_API void zend_exception_error(zval *exception TSRMLS_DC);
+3521 -938
View File
File diff suppressed because it is too large. Load diff
+13 -24
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -32,15 +32,12 @@ typedef union _temp_variable {
struct {
zval **ptr_ptr;
zval *ptr;
struct {
zval *str;
zend_uint offset;
} str_offset;
zend_bool fcall_returned_reference;
} var;
struct {
zval **ptr_ptr;
zval *ptr;
zend_bool fcall_returned_reference;
zval *str;
zend_uint offset;
} str_offset;
zend_class_entry *class_entry;
} temp_variable;
@@ -51,17 +48,15 @@ ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_pt
void init_executor(TSRMLS_D);
void shutdown_executor(TSRMLS_D);
void shutdown_destructors(TSRMLS_D);
ZEND_API void execute(zend_op_array *op_array TSRMLS_DC);
ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
ZEND_API int zend_is_true(zval *op);
#define safe_free_zval_ptr(p) safe_free_zval_ptr_rel(p ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
static inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
static inline void safe_free_zval_ptr(zval *p)
{
TSRMLS_FETCH();
if (p!=EG(uninitialized_zval_ptr)) {
FREE_ZVAL_REL(p);
FREE_ZVAL(p);
}
}
ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
@@ -96,16 +91,8 @@ static inline int i_zend_is_true(zval *op)
result = (zend_hash_num_elements(op->value.ht)?1:0);
break;
case IS_OBJECT:
if(IS_ZEND_STD_OBJECT(*op)) {
TSRMLS_FETCH();
if(EG(ze1_compatibility_mode)) {
result = (zend_hash_num_elements(Z_OBJPROP_P(op))?1:0);
} else {
result = 1;
}
} else {
result = 1;
}
/* OBJ-TBI */
result = 1;
break;
default:
result = 0;
@@ -145,7 +132,6 @@ void execute_new_code(TSRMLS_D);
/* services */
ZEND_API char *get_active_class_name(char **space TSRMLS_DC);
ZEND_API char *get_active_function_name(TSRMLS_D);
ZEND_API char *zend_get_executed_filename(TSRMLS_D);
ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
@@ -155,7 +141,6 @@ ZEND_API void zend_set_timeout(long seconds);
ZEND_API void zend_unset_timeout(TSRMLS_D);
ZEND_API void zend_timeout(int dummy);
ZEND_API zend_class_entry *zend_fetch_class(char *class_name, uint class_name_len, int fetch_type TSRMLS_DC);
void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC);
#ifdef ZEND_WIN32
void zend_init_timeout_thread();
@@ -169,6 +154,10 @@ void zend_shutdown_timeout_thread();
#define active_opline (*EG(opline_ptr))
void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts TSRMLS_DC);
#define IS_STRING_OFFSET 2
/* The following tries to resolve the classname of a zval of type object.
* Since it is slow it should be only used in error messages.
*/
+85 -299
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -29,8 +29,7 @@
#include "zend_ptr_stack.h"
#include "zend_constants.h"
#include "zend_extensions.h"
#include "zend_exceptions.h"
#include "zend_vm.h"
#include "zend_default_classes.h"
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
@@ -50,6 +49,7 @@ static DWORD timeout_thread_id;
static int timeout_thread_initialized=0;
#endif
#if ZEND_DEBUG
static void (*original_sigsegv_handler)(int);
static void zend_handle_sigsegv(int dummy)
@@ -117,7 +117,7 @@ static int is_not_internal_class(zend_class_entry **ce TSRMLS_DC)
void init_executor(TSRMLS_D)
{
INIT_ZVAL(EG(uninitialized_zval));
/* trick to make uninitialized_zval never be modified, passed by ref, etc. */
/* trick to make uninitialized_zval never be modified, passed by ref, etc. */
EG(uninitialized_zval).refcount++;
INIT_ZVAL(EG(error_zval));
EG(uninitialized_zval_ptr)=&EG(uninitialized_zval);
@@ -132,16 +132,14 @@ void init_executor(TSRMLS_D)
EG(symtable_cache_ptr) = EG(symtable_cache)-1;
EG(symtable_cache_limit)=EG(symtable_cache)+SYMTABLE_CACHE_SIZE-1;
EG(no_extensions)=0;
EG(implicit_clone)=0;
EG(function_table) = CG(function_table);
EG(class_table) = CG(class_table);
EG(in_execution) = 0;
EG(in_autoload) = NULL;
EG(autoload_func) = NULL;
zend_ptr_stack_init(&EG(argument_stack));
zend_ptr_stack_push(&EG(argument_stack), (void *) NULL);
zend_hash_init(&EG(symbol_table), 50, NULL, ZVAL_PTR_DTOR, 0);
{
@@ -158,6 +156,7 @@ void init_executor(TSRMLS_D)
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator TSRMLS_CC);
EG(opline_ptr) = NULL;
EG(garbage_ptr) = 0;
zend_hash_init(&EG(included_files), 5, NULL, NULL, 0);
@@ -167,7 +166,6 @@ void init_executor(TSRMLS_D)
EG(current_execute_data) = NULL;
zend_stack_init(&EG(user_error_handlers_error_reporting));
zend_ptr_stack_init(&EG(user_error_handlers));
zend_ptr_stack_init(&EG(user_exception_handlers));
@@ -182,20 +180,13 @@ void init_executor(TSRMLS_D)
EG(scope) = NULL;
EG(current_execute_data) = NULL;
EG(This) = NULL;
EG(float_separator)[0] = '.';
}
void shutdown_destructors(TSRMLS_D) {
zend_try {
zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC);
} zend_catch {
/* if we couldn't destruct cleanly, mark all objects as destructed anyway */
zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC);
} zend_end_try();
}
void shutdown_executor(TSRMLS_D)
{
zend_try {
@@ -215,6 +206,7 @@ void shutdown_executor(TSRMLS_D)
}
*/
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator TSRMLS_CC);
zend_hash_graceful_reverse_destroy(&EG(symbol_table));
} zend_end_try();
@@ -236,25 +228,29 @@ void shutdown_executor(TSRMLS_D)
FREE_ZVAL(zeh);
}
zend_stack_destroy(&EG(user_error_handlers_error_reporting));
zend_stack_init(&EG(user_error_handlers_error_reporting));
zend_ptr_stack_clean(&EG(user_error_handlers), ZVAL_DESTRUCTOR, 1);
zend_ptr_stack_clean(&EG(user_exception_handlers), ZVAL_DESTRUCTOR, 1);
} zend_end_try();
zend_try {
/* Cleanup static data for functions and arrays.
We need a separate cleanup stage because of the following problem:
Suppose we destroy class X, which destroys the class's function table,
and in the function table we have function foo() that has static $bar.
Now if an object of class X is assigned to $bar, its destructor will be
called and will fail since X's function table is in mid-destruction.
We need separate cleanup stage because of the following problem:
Suppose we destroy class X, which destroys function table,
and in function table we have function foo() that has static $bar. Now if
object of class X is assigned to $bar, its destructor will be called and will
fail since X's function table is in mid-destruction.
So we want first of all to clean up all data and then move to tables destruction.
Note that only run-time accessed data need to be cleaned up, pre-defined data can
not contain objects and thus are not probelmatic */
zend_hash_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data TSRMLS_CC);
zend_hash_apply(EG(class_table), (apply_func_t) zend_cleanup_class_data TSRMLS_CC);
while (EG(garbage_ptr)) {
if (EG(garbage)[--EG(garbage_ptr)]->refcount==1) {
zval_ptr_dtor(&EG(garbage)[EG(garbage_ptr)]);
}
}
zend_ptr_stack_destroy(&EG(argument_stack));
/* Destroy all op arrays */
@@ -271,7 +267,6 @@ void shutdown_executor(TSRMLS_D)
FREE_HASHTABLE(*EG(symtable_cache_ptr));
EG(symtable_cache_ptr)--;
}
zend_objects_store_free_object_storage(&EG(objects_store) TSRMLS_CC);
} zend_end_try();
zend_try {
@@ -291,47 +286,13 @@ void shutdown_executor(TSRMLS_D)
zend_hash_destroy(&EG(included_files));
zend_ptr_stack_destroy(&EG(arg_types_stack));
zend_stack_destroy(&EG(user_error_handlers_error_reporting));
zend_ptr_stack_destroy(&EG(user_error_handlers));
zend_ptr_stack_destroy(&EG(user_exception_handlers));
zend_objects_store_destroy(&EG(objects_store));
if (EG(in_autoload)) {
zend_hash_destroy(EG(in_autoload));
FREE_HASHTABLE(EG(in_autoload));
}
} zend_end_try();
}
/* return class name and "::" or "". */
ZEND_API char *get_active_class_name(char **space TSRMLS_DC)
{
if (!zend_is_executing(TSRMLS_C)) {
if (space) {
*space = "";
}
return "";
}
switch (EG(function_state_ptr)->function->type) {
case ZEND_USER_FUNCTION:
case ZEND_INTERNAL_FUNCTION:
{
zend_class_entry *ce = EG(function_state_ptr)->function->common.scope;
if (space) {
*space = ce ? "::" : "";
}
return ce ? ce->name : "";
}
default:
if (space) {
*space = "";
}
return "";
}
}
ZEND_API char *get_active_function_name(TSRMLS_D)
{
if (!zend_is_executing(TSRMLS_C)) {
@@ -391,7 +352,7 @@ ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC)
(*zval_ptr)->refcount--;
if ((*zval_ptr)->refcount==0) {
zval_dtor(*zval_ptr);
safe_free_zval_ptr_rel(*zval_ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC);
safe_free_zval_ptr(*zval_ptr);
} else if ((*zval_ptr)->refcount == 1) {
(*zval_ptr)->is_ref = 0;
}
@@ -498,7 +459,7 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
switch (const_value.type) {
case IS_STRING:
zend_symtable_update(p->value.ht, const_value.value.str.val, const_value.value.str.len+1, &new_val, sizeof(zval *), NULL);
zend_hash_update(p->value.ht, const_value.value.str.val, const_value.value.str.len+1, &new_val, sizeof(zval *), NULL);
break;
case IS_LONG:
zend_hash_index_update(p->value.ht, const_value.value.lval, &new_val, sizeof(zval *), NULL);
@@ -516,18 +477,13 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, zend_uint param_count, zval *params[] TSRMLS_DC)
{
zval ***params_array;
zval ***params_array = (zval ***) emalloc(sizeof(zval **)*param_count);
zend_uint i;
int ex_retval;
zval *local_retval_ptr;
if (param_count) {
params_array = (zval ***) emalloc(sizeof(zval **)*param_count);
for (i=0; i<param_count; i++) {
params_array[i] = &params[i];
}
} else {
params_array = NULL;
for (i=0; i<param_count; i++) {
params_array[i] = &params[i];
}
ex_retval = call_user_function_ex(function_table, object_pp, function_name, &local_retval_ptr, param_count, params_array, 1, NULL TSRMLS_CC);
if (local_retval_ptr) {
@@ -535,9 +491,7 @@ int call_user_function(HashTable *function_table, zval **object_pp, zval *functi
} else {
INIT_ZVAL(*retval_ptr);
}
if (params_array) {
efree(params_array);
}
efree(params_array);
return ex_retval;
}
@@ -568,8 +522,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
zend_function_state *original_function_state_ptr;
zend_op_array *original_op_array;
zend_op **original_opline_ptr;
zval *orig_free_op1, *orig_free_op2;
int (*orig_unary_op)(zval *result, zval *op1);
int (*orig_binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC);
zend_class_entry *current_scope;
zend_class_entry *calling_scope = NULL;
char *function_name_lc;
zval *current_this;
zend_execute_data execute_data;
zval *method_name;
@@ -585,19 +543,11 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
}
/* Initialize execute_data */
if (EG(current_execute_data)) {
execute_data = *EG(current_execute_data);
} else {
/* This only happens when we're called outside any execute()'s
* It shouldn't be strictly necessary to NULL execute_data out,
* but it may make bugs easier to spot
*/
memset(&execute_data, 0, sizeof(zend_execute_data));
}
/* we may return SUCCESS, and yet retval may be uninitialized,
* if there was an exception...
*/
EX(fbc) = NULL;
EX(object) = NULL;
EX(Ts) = NULL;
EX(op_array) = NULL;
EX(opline) = NULL;
*fci->retval_ptr_ptr = NULL;
if (!fci_cache || !fci_cache->initialized) {
@@ -636,44 +586,20 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
int found = FAILURE;
if (EG(active_op_array) && strcmp(Z_STRVAL_PP(fci->object_pp), "self") == 0) {
if (!EG(active_op_array)->scope) {
zend_error(E_ERROR, "Cannot access self:: when no class scope is active");
}
ce = &(EG(active_op_array)->scope);
found = (*ce != NULL?SUCCESS:FAILURE);
fci->object_pp = EG(This)?&EG(This):NULL;
} else if (strcmp(Z_STRVAL_PP(fci->object_pp), "parent") == 0 && EG(active_op_array)) {
if (!EG(active_op_array)->scope) {
zend_error(E_ERROR, "Cannot access parent:: when no class scope is active");
}
if (!EG(active_op_array)->scope->parent) {
zend_error(E_ERROR, "Cannot access parent:: when current class scope has no parent");
}
} else if (strcmp(Z_STRVAL_PP(fci->object_pp), "parent") == 0 && EG(active_op_array) && EG(active_op_array)->scope) {
ce = &(EG(active_op_array)->scope->parent);
found = (*ce != NULL?SUCCESS:FAILURE);
fci->object_pp = EG(This)?&EG(This):NULL;
} else {
zend_class_entry *scope;
scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL;
found = zend_lookup_class(Z_STRVAL_PP(fci->object_pp), Z_STRLEN_PP(fci->object_pp), &ce TSRMLS_CC);
if (found == FAILURE) {
zend_error(E_ERROR, "Class '%s' not found", Z_STRVAL_PP(fci->object_pp));
}
if (scope && EG(This) &&
instanceof_function(Z_OBJCE_P(EG(This)), scope TSRMLS_CC) &&
instanceof_function(scope, *ce TSRMLS_CC)) {
fci->object_pp = &EG(This);
} else {
fci->object_pp = NULL;
}
}
if (found == FAILURE)
return FAILURE;
fci->function_table = &(*ce)->function_table;
calling_scope = *ce;
fci->object_pp = NULL;
}
if (fci->function_table == NULL) {
@@ -685,41 +611,25 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
return FAILURE;
}
if (fci->object_pp) {
if (Z_OBJ_HT_PP(fci->object_pp)->get_method == NULL) {
zend_error(E_ERROR, "Object does not support method calls");
}
EX(function_state).function =
Z_OBJ_HT_PP(fci->object_pp)->get_method(*fci->object_pp, Z_STRVAL_P(fci->function_name), Z_STRLEN_P(fci->function_name) TSRMLS_CC);
} else if (calling_scope) {
char *function_name_lc = zend_str_tolower_dup(Z_STRVAL_P(fci->function_name), Z_STRLEN_P(fci->function_name));
function_name_lc = zend_str_tolower_dup(fci->function_name->value.str.val, fci->function_name->value.str.len);
EX(function_state).function =
zend_std_get_static_method(calling_scope, function_name_lc, Z_STRLEN_P(fci->function_name) TSRMLS_CC);
efree(function_name_lc);
} else {
char *function_name_lc = zend_str_tolower_dup(Z_STRVAL_P(fci->function_name), Z_STRLEN_P(fci->function_name));
if (zend_hash_find(fci->function_table, function_name_lc, fci->function_name->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) {
EX(function_state).function = NULL;
}
efree(function_name_lc);
}
if (EX(function_state).function == NULL) {
if (zend_hash_find(fci->function_table, function_name_lc, fci->function_name->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) {
/* try calling __call */
if (calling_scope && calling_scope->__call) {
EX(function_state).function = calling_scope->__call;
/* prepare params */
ALLOC_INIT_ZVAL(method_name);
ZVAL_STRINGL(method_name, Z_STRVAL_P(fci->function_name), Z_STRLEN_P(fci->function_name), 0);
ZVAL_STRINGL(method_name, function_name_lc, fci->function_name->value.str.len, 0);
ALLOC_INIT_ZVAL(params_array);
array_init(params_array);
call_via_handler = 1;
} else {
efree(function_name_lc);
return FAILURE;
}
} else {
efree(function_name_lc);
}
if (fci_cache) {
fci_cache->function_handler = EX(function_state).function;
@@ -775,7 +685,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
fci->param_count = 2;
}
zend_ptr_stack_2_push(&EG(argument_stack), (void *) (long) fci->param_count, NULL);
zend_ptr_stack_n_push(&EG(argument_stack), 2, (void *) (long) fci->param_count, NULL);
original_function_state_ptr = EG(function_state_ptr);
EG(function_state_ptr) = &EX(function_state);
@@ -786,34 +696,21 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
current_this = EG(This);
if (fci->object_pp) {
if ((EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) {
EG(This) = NULL;
EG(This) = *fci->object_pp;
if (!PZVAL_IS_REF(EG(This))) {
EG(This)->refcount++; /* For $this pointer */
} else {
EG(This) = *fci->object_pp;
zval *this_ptr;
if (!PZVAL_IS_REF(EG(This))) {
EG(This)->refcount++; /* For $this pointer */
} else {
zval *this_ptr;
ALLOC_ZVAL(this_ptr);
*this_ptr = *EG(This);
INIT_PZVAL(this_ptr);
zval_copy_ctor(this_ptr);
EG(This) = this_ptr;
}
ALLOC_ZVAL(this_ptr);
*this_ptr = *EG(This);
INIT_PZVAL(this_ptr);
zval_copy_ctor(this_ptr);
EG(This) = this_ptr;
}
} else {
EG(This) = NULL;
if (calling_scope && !(EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) {
int severity;
if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
severity = E_STRICT;
} else {
severity = E_ERROR;
}
zend_error(E_STRICT, "Non-static method %s::%s() cannot be called statically", calling_scope->name, EX(function_state).function->common.function_name);
}
}
EX(prev_execute_data) = EG(current_execute_data);
@@ -834,6 +731,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(return_value_ptr_ptr) = fci->retval_ptr_ptr;
EG(active_op_array) = (zend_op_array *) EX(function_state).function;
original_opline_ptr = EG(opline_ptr);
orig_free_op1 = EG(free_op1);
orig_free_op2 = EG(free_op2);
orig_unary_op = EG(unary_op);
orig_binary_op = EG(binary_op);
zend_execute(EG(active_op_array) TSRMLS_CC);
if (!fci->symbol_table) {
zend_hash_destroy(EG(active_symbol_table));
@@ -843,6 +744,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(active_op_array) = original_op_array;
EG(return_value_ptr_ptr)=original_return_value;
EG(opline_ptr) = original_opline_ptr;
EG(free_op1) = orig_free_op1;
EG(free_op2) = orig_free_op2;
EG(unary_op) = orig_unary_op;
EG(binary_op) = orig_binary_op;
} else {
ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr);
if (EX(function_state).function->common.scope) {
@@ -864,10 +769,6 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(scope) = current_scope;
EG(This) = current_this;
EG(current_execute_data) = EX(prev_execute_data);
if (EG(exception)) {
zend_throw_exception_internal(NULL TSRMLS_CC);
}
return SUCCESS;
}
@@ -881,10 +782,7 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
int retval;
char *lc_name;
zval *exception;
char dummy = 1;
zend_fcall_info fcall_info;
zend_fcall_info_cache fcall_cache;
lc_name = do_alloca(name_length + 1);
zend_str_tolower_copy(lc_name, name, name_length);
@@ -893,52 +791,16 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
return SUCCESS;
}
/* The compiler is not-reentrant. Make sure we __autoload() only during run-time
* (doesn't impact fuctionality of __autoload()
*/
if (zend_is_compiling(TSRMLS_C)) {
free_alloca(lc_name);
return FAILURE;
}
if (EG(in_autoload) == NULL) {
ALLOC_HASHTABLE(EG(in_autoload));
zend_hash_init(EG(in_autoload), 0, NULL, NULL, 0);
}
if (zend_hash_add(EG(in_autoload), lc_name, name_length+1, (void**)&dummy, sizeof(char), NULL) == FAILURE) {
free_alloca(lc_name);
return FAILURE;
}
ZVAL_STRINGL(&autoload_function, ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME)-1, 0);
ZVAL_STRINGL(&autoload_function, "__autoload", sizeof("__autoload")-1, 0);
INIT_PZVAL(class_name_ptr);
ZVAL_STRINGL(class_name_ptr, name, name_length, 0);
args[0] = &class_name_ptr;
fcall_info.size = sizeof(fcall_info);
fcall_info.function_table = EG(function_table);
fcall_info.function_name = &autoload_function;
fcall_info.symbol_table = NULL;
fcall_info.retval_ptr_ptr = &retval_ptr;
fcall_info.param_count = 1;
fcall_info.params = args;
fcall_info.object_pp = NULL;
fcall_info.no_separation = 1;
fcall_cache.initialized = EG(autoload_func) ? 1 : 0;
fcall_cache.function_handler = EG(autoload_func);
fcall_cache.calling_scope = NULL;
fcall_cache.object_pp = NULL;
exception = EG(exception);
EG(exception) = NULL;
retval = zend_call_function(&fcall_info, &fcall_cache TSRMLS_CC);
EG(autoload_func) = fcall_cache.function_handler;
zend_hash_del(EG(in_autoload), lc_name, name_length+1);
retval = call_user_function_ex(EG(function_table), NULL, &autoload_function, &retval_ptr, 1, args, 0, NULL TSRMLS_CC);
if (retval == FAILURE) {
EG(exception) = exception;
@@ -948,7 +810,7 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
if (EG(exception)) {
free_alloca(lc_name);
zend_error(E_ERROR, "Function %s(%s) threw an exception of type '%s'", ZEND_AUTOLOAD_FUNC_NAME, name, Z_OBJCE_P(EG(exception))->name);
zend_error(E_ERROR, "__autoload(%s) threw an exception of type '%s'", name, Z_OBJCE_P(EG(exception))->name);
return FAILURE;
}
EG(exception) = exception;
@@ -1031,10 +893,16 @@ ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSR
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC)
{
int result;
zval *exception = EG(exception);
if (handle_exceptions) {
EG(exception) = NULL;
}
result = zend_eval_string(str, retval_ptr, string_name TSRMLS_CC);
if (handle_exceptions && EG(exception)) {
zend_exception_error(EG(exception) TSRMLS_CC);
zval_ptr_dtor(&EG(exception));
EG(exception) = exception;
result = FAILURE;
}
return result;
@@ -1043,7 +911,7 @@ ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name,
void execute_new_code(TSRMLS_D)
{
zend_op *opline, *end;
zend_op *opline, *end;
zend_op *ret_opline;
zval *local_retval=NULL;
@@ -1067,18 +935,18 @@ void execute_new_code(TSRMLS_D)
opline=CG(active_op_array)->start_op;
end=CG(active_op_array)->opcodes+CG(active_op_array)->last;
while (opline<end) {
if (opline->op1.op_type==IS_CONST) {
opline->op1.u.constant.is_ref = 1;
opline->op1.u.constant.refcount = 2; /* Make sure is_ref won't be reset */
}
if (opline->op2.op_type==IS_CONST) {
opline->op2.u.constant.is_ref = 1;
opline->op2.u.constant.refcount = 2;
}
ZEND_VM_SET_OPCODE_HANDLER(opline);
while (opline<end) {
if (opline->op1.op_type==IS_CONST) {
opline->op1.u.constant.is_ref = 1;
opline->op1.u.constant.refcount = 2; /* Make sure is_ref won't be reset */
}
if (opline->op2.op_type==IS_CONST) {
opline->op2.u.constant.is_ref = 1;
opline->op2.u.constant.refcount = 2;
}
opline->handler = zend_opcode_handlers[opline->opcode];
opline++;
}
}
EG(return_value_ptr_ptr) = &local_retval;
EG(active_op_array) = CG(active_op_array);
@@ -1104,6 +972,7 @@ ZEND_API void zend_timeout(int dummy)
EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s");
}
#ifdef ZEND_WIN32
static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -1116,18 +985,7 @@ static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wPa
if (lParam==0) {
KillTimer(timeout_window, wParam);
} else {
#ifdef ZTS
void ***tsrm_ls;
#endif
SetTimer(timeout_window, wParam, lParam*1000, NULL);
#ifdef ZTS
tsrm_ls = ts_resource_ex(0, &wParam);
if (!tsrm_ls) {
/* shouldn't normally happen */
break;
}
#endif
EG(timed_out) = 0;
}
break;
case WM_UNREGISTER_ZEND_TIMEOUT:
@@ -1295,78 +1153,6 @@ check_fetch_type:
return *pce;
}
#define MAX_ABSTRACT_INFO_CNT 3
#define MAX_ABSTRACT_INFO_FMT "%s%s%s%s"
#define DISPLAY_ABSTRACT_FN(idx) \
ai.afn[idx] ? ZEND_FN_SCOPE_NAME(ai.afn[idx]) : "", \
ai.afn[idx] ? "::" : "", \
ai.afn[idx] ? ai.afn[idx]->common.function_name : "", \
ai.afn[idx] && ai.afn[idx+1] ? ", " : (ai.afn[idx] && ai.cnt >= MAX_ABSTRACT_INFO_CNT ? ", ..." : "")
typedef struct _zend_abstract_info {
zend_function *afn[MAX_ABSTRACT_INFO_CNT+1];
int cnt;
} zend_abstract_info;
static int zend_verify_abstract_class_function(zend_function *fn, zend_abstract_info *ai TSRMLS_DC)
{
if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
if (ai->cnt < MAX_ABSTRACT_INFO_CNT) {
ai->afn[ai->cnt] = fn;
}
ai->cnt++;
}
return 0;
}
void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC)
{
zend_abstract_info ai;
if ((ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) && !(ce->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
memset(&ai, 0, sizeof(ai));
zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t) zend_verify_abstract_class_function, &ai TSRMLS_CC);
if (ai.cnt) {
zend_error(E_ERROR, "Class %s contains %d abstract methods and must therefore be declared abstract (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
ce->name, ai.cnt,
DISPLAY_ABSTRACT_FN(0),
DISPLAY_ABSTRACT_FN(1),
DISPLAY_ABSTRACT_FN(2)
);
}
}
}
ZEND_API int zend_delete_global_variable(char *name, int name_len TSRMLS_DC)
{
zend_execute_data *ex;
ulong hash_value = zend_inline_hash_func(name, name_len+1);
if (zend_hash_quick_exists(&EG(symbol_table), name, name_len+1, hash_value)) {
for (ex = EG(current_execute_data); ex; ex = ex->prev_execute_data) {
if (ex->symbol_table == &EG(symbol_table)) {
int i;
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == name_len &&
!memcmp(ex->op_array->vars[i].name, name, name_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
}
return zend_hash_del(&EG(symbol_table), name, name_len+1);
}
return FAILURE;
}
/*
* Local variables:
* tab-width: 4
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
+5 -12
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -24,10 +24,7 @@
#include "zend_compile.h"
/* The first number is the engine version and the rest is the date.
* This way engine 2 API no. is always greater than engine 1 API no..
*/
#define ZEND_EXTENSION_API_NO 220040718
#define ZEND_EXTENSION_API_NO 90021012
typedef struct _zend_extension_version_info {
int zend_extension_api_no;
@@ -92,10 +89,9 @@ struct _zend_extension {
int resource_number;
};
BEGIN_EXTERN_C()
ZEND_API int zend_get_resource_handle(zend_extension *extension);
ZEND_API void zend_extension_dispatch_message(int message, void *arg);
END_EXTERN_C()
#define ZEND_EXTMSG_NEW_EXTENSION 1
@@ -110,16 +106,13 @@ END_EXTERN_C()
ZEND_API extern zend_llist zend_extensions;
void zend_extension_dtor(zend_extension *extension);
ZEND_API int zend_load_extension(char *path);
ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle);
void zend_append_version_info(zend_extension *extension);
int zend_startup_extensions_mechanism(void);
int zend_startup_extensions(void);
void zend_shutdown_extensions(TSRMLS_D);
BEGIN_EXTERN_C()
ZEND_API int zend_load_extension(char *path);
ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle);
ZEND_API zend_extension *zend_get_extension(char *extension_name);
END_EXTERN_C()
#endif /* ZEND_EXTENSIONS_H */
+2 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -104,6 +104,7 @@ typedef struct _zend_fast_cache_list_entry {
/* fast cache for zval's */
#define ALLOC_ZVAL(z) \
ZEND_FAST_ALLOC(z, zval, ZVAL_CACHE_LIST)
+9 -10
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -34,7 +34,6 @@
#include "zend_fast_cache.h"
#include "zend_objects.h"
#include "zend_objects_API.h"
#include "zend_modules.h"
#ifdef ZEND_MULTIBYTE
#include "zend_multibyte.h"
@@ -116,6 +115,7 @@ struct _zend_compiler_globals {
zend_llist open_files;
zend_llist *throw_list;
long catch_begin;
struct _zend_ini_parser_param *ini_parser_param;
@@ -191,11 +191,9 @@ struct _zend_executor_globals {
int ticks_count;
zend_bool in_execution;
HashTable *in_autoload;
zend_function *autoload_func;
zend_bool bailout_set;
zend_bool full_tables_cleanup;
zend_bool ze1_compatibility_mode;
zend_bool implicit_clone;
/* for extended information support */
zend_bool no_extensions;
@@ -208,11 +206,15 @@ struct _zend_executor_globals {
HashTable persistent_list;
zend_ptr_stack argument_stack;
zval *free_op1, *free_op2;
int (*unary_op)(zval *result, zval *op1);
int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC);
zval *garbage[2];
int garbage_ptr;
int user_error_handler_error_reporting;
zval *user_error_handler;
zval *user_exception_handler;
zend_stack user_error_handlers_error_reporting;
zend_ptr_stack user_error_handlers;
zend_ptr_stack user_exception_handlers;
@@ -224,12 +226,9 @@ struct _zend_executor_globals {
HashTable *ini_directives;
zend_objects_store objects_store;
zval *exception;
zend_op *opline_before_exception;
struct _zend_execute_data *current_execute_data;
struct _zend_module_entry *current_module;
zend_property_info std_property_info;
/* locale stuff */
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
+20 -32
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -137,7 +137,6 @@ ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength)
ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
{
uint i = 3;
Bucket **tmp;
SET_INCONSISTENT(HT_OK);
@@ -147,8 +146,18 @@ ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunctio
ht->nTableSize = 1 << i;
ht->nTableMask = ht->nTableSize - 1;
/* Uses ecalloc() so that Bucket* == NULL */
if (persistent) {
ht->arBuckets = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *));
if (!ht->arBuckets) {
return FAILURE;
}
} else {
ht->arBuckets = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *));
}
ht->pDestructor = pDestructor;
ht->arBuckets = NULL;
ht->pListHead = NULL;
ht->pListTail = NULL;
ht->nNumOfElements = 0;
@@ -157,21 +166,6 @@ ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunctio
ht->persistent = persistent;
ht->nApplyCount = 0;
ht->bApplyProtection = 1;
/* Uses ecalloc() so that Bucket* == NULL */
if (persistent) {
tmp = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *));
if (!tmp) {
return FAILURE;
}
ht->arBuckets = tmp;
} else {
tmp = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *));
if (tmp) {
ht->arBuckets = tmp;
}
}
return SUCCESS;
}
@@ -1138,20 +1132,14 @@ ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
ht->pListTail = NULL;
ht->pInternalPointer = ht->pListHead;
arTmp[0]->pListLast = NULL;
if (i > 1) {
arTmp[0]->pListNext = arTmp[1];
for (j = 1; j < i-1; j++) {
arTmp[j]->pListLast = arTmp[j-1];
arTmp[j]->pListNext = arTmp[j+1];
}
arTmp[j]->pListLast = ht->pListTail;
arTmp[j]->pListNext = NULL;
} else {
arTmp[0]->pListNext = NULL;
}
ht->pListTail = arTmp[i-1];
for (j = 0; j < i; j++) {
if (ht->pListTail) {
ht->pListTail->pListNext = arTmp[j];
}
arTmp[j]->pListLast = ht->pListTail;
arTmp[j]->pListNext = NULL;
ht->pListTail = arTmp[j];
}
pefree(arTmp, ht->persistent);
HANDLE_UNBLOCK_INTERRUPTIONS();
+1 -1
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
+16 -20
View File
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
| Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -105,7 +105,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
int in_string=0;
zend_printf("<code>");
zend_printf("<span style=\"color: %s\">\n", last_color);
zend_printf("<font color=\"%s\">\n", last_color);
/* highlight stuff coming back from zendlex() */
token.type = 0;
while ((token_type=lex_scan(&token TSRMLS_CC))) {
@@ -137,34 +137,30 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
continue;
break;
default:
if (in_string) {
next_color = syntax_highlighter_ini->highlight_string;
} else if (token.type == 0) {
if (token.type==0) {
next_color = syntax_highlighter_ini->highlight_keyword;
} else {
next_color = syntax_highlighter_ini->highlight_default;
if (in_string) {
next_color = syntax_highlighter_ini->highlight_string;
} else {
next_color = syntax_highlighter_ini->highlight_default;
}
}
break;
}
if (last_color != next_color) {
if (last_color != syntax_highlighter_ini->highlight_html) {
zend_printf("</span>");
zend_printf("</font>");
}
last_color = next_color;
if (last_color != syntax_highlighter_ini->highlight_html) {
zend_printf("<span style=\"color: %s\">", last_color);
zend_printf("<font color=\"%s\">", last_color);
}
}
switch (token_type) {
case T_END_HEREDOC:
zend_html_puts(token.value.str.val, token.value.str.len TSRMLS_CC);
{
char *ptr = LANG_SCNG(yy_text);
if (ptr[LANG_SCNG(yy_leng) - 1] != ';') {
zend_html_putc('\n');
}
}
break;
default:
zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(yy_leng) TSRMLS_CC);
@@ -190,9 +186,9 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
token.type = 0;
}
if (last_color != syntax_highlighter_ini->highlight_html) {
zend_printf("</span>\n");
zend_printf("</font>\n");
}
zend_printf("</span>\n");
zend_printf("</font>\n");
zend_printf("</code>");
}
@@ -209,7 +205,7 @@ ZEND_API void zend_strip(TSRMLS_D)
switch (token_type) {
case T_WHITESPACE:
if (!prev_space) {
zend_write(" ", sizeof(" ") - 1);
putchar(' ');
prev_space = 1;
}
/* lack of break; is intentional */
@@ -221,9 +217,9 @@ ZEND_API void zend_strip(TSRMLS_D)
case T_END_HEREDOC: {
char *ptr = LANG_SCNG(yy_text);
zend_write(ptr, LANG_SCNG(yy_leng) - 1);
fwrite(ptr, LANG_SCNG(yy_leng) - 1, 1, stdout);
/* The ensure that we only write one ; and that it followed by the required newline */
zend_write("\n", sizeof("\n") - 1);
putchar('\n');
if (ptr[LANG_SCNG(yy_leng) - 1] == ';') {
lex_scan(&token TSRMLS_CC);
}
@@ -232,7 +228,7 @@ ZEND_API void zend_strip(TSRMLS_D)
break;
default:
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
fwrite(LANG_SCNG(yy_text), LANG_SCNG(yy_leng), 1, stdout);
break;
}
Loaded 100 of 2201 files, more files were not shown because too many files have changed in this diff. Show more